octstr_case_str_compare
"fred" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <020f01c51acf$98f1c0e0$0401a8c0@FRED4> |
Please consider this PATCH /* * Same as octstr_compare, but compares the content of the octet string to * a C string without case sensitivity. */ int octstr_case_str_compare(const Octstr *os1, const char*str); cheers
octstr.h.patch
(application/octet-stream, 826 B)
Index: octstr.h
===================================================================
RCS file: /home/cvs/gateway/gwlib/octstr.h,v
retrieving revision 1.87
diff -u -r1.87 octstr.h
--- octstr.h 11 Feb 2005 15:35:48 -0000 1.87
+++ octstr.h 25 Feb 2005 00:10:03 -0000
@@ -333,6 +333,11 @@
*/
int octstr_str_compare(const Octstr *ostr1, const char *str);
+/*
+ * Same as octstr_compare, but compares the content of the octet string to
+ * a C string without case sensitivity.
+ */
+int octstr_case_str_compare(const Octstr *os1, const char*str);
/*
* Same as octstr_str_compare, but comparing is done only up to n bytes.
@@ -723,4 +728,7 @@
*/
void octstr_convert_from_html_entities(Octstr* input);
+#define OctStrCreate(s) s ? octstr_create(s) : octstr_create("")
+#define STRLEN(s) ((s) ? strlen(s) : 0)
+
#endif
octstr.c.patch
(application/octet-stream, 640 B)
Index: octstr.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/octstr.c,v
retrieving revision 1.166
diff -u -r1.166 octstr.c
--- octstr.c 11 Feb 2005 15:35:48 -0000 1.166
+++ octstr.c 25 Feb 2005 00:07:33 -0000
@@ -954,6 +954,18 @@
return strcmp(ostr->data, str);
}
+int octstr_case_str_compare(const Octstr *os1, const char*str)
+{
+ seems_valid(os1);
+
+ if (str == NULL)
+ return -1;
+ if (os1->data == NULL)
+ return strcmp("", str);
+
+ return strcasecmp(os1->data, str);
+}
+
int octstr_str_ncompare(const Octstr *ostr, const char *str, long n)
{