[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r9198: Add a helper function for case-insensitive search through a (in tor/trunk: . src/common)



Author: nickm
Date: 2006-12-28 16:29:03 -0500 (Thu, 28 Dec 2006)
New Revision: 9198

Modified:
   tor/trunk/
   tor/trunk/src/common/container.c
   tor/trunk/src/common/container.h
Log:
 r11722@Kushana:  nickm | 2006-12-28 13:51:42 -0500
 Add a helper function for case-insensitive search through a smartlist



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11722] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/src/common/container.c
===================================================================
--- tor/trunk/src/common/container.c	2006-12-27 17:31:59 UTC (rev 9197)
+++ tor/trunk/src/common/container.c	2006-12-28 21:29:03 UTC (rev 9198)
@@ -197,6 +197,20 @@
   return 0;
 }
 
+/** Return true iff <b>sl</b> has some element E such that
+ * !strcasecmp(E,<b>element</b>)
+ */
+int
+smartlist_string_isin_case(const smartlist_t *sl, const char *element)
+{
+  int i;
+  if (!sl) return 0;
+  for (i=0; i < sl->num_used; i++)
+    if (strcasecmp((const char*)sl->list[i],element)==0)
+      return 1;
+  return 0;
+}
+
 /** Return true iff <b>sl</b> has some element E such that E is equal
  * to the decimal encoding of <b>num</b>.
  */

Modified: tor/trunk/src/common/container.h
===================================================================
--- tor/trunk/src/common/container.h	2006-12-27 17:31:59 UTC (rev 9197)
+++ tor/trunk/src/common/container.h	2006-12-28 21:29:03 UTC (rev 9198)
@@ -35,6 +35,8 @@
 int smartlist_isin(const smartlist_t *sl, const void *element) ATTR_PURE;
 int smartlist_string_isin(const smartlist_t *sl, const char *element)
   ATTR_PURE;
+int smartlist_string_isin_case(const smartlist_t *sl, const char *element)
+  ATTR_PURE;
 int smartlist_string_num_isin(const smartlist_t *sl, int num) ATTR_PURE;
 int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2)
   ATTR_PURE;