aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2010-09-27 22:40:43 +0000
committerJason Woodward2010-09-27 23:42:10 +0000
commite6dd5463d3329a726ae804df22630e4528bdb105 (patch)
tree9c25594bdd453701d734721a65fe600071a38804
parent9f084687d9d054ae3c38329aed7704ec15a08b15 (diff)
downloadslapt-get-e6dd5463d3329a726ae804df22630e4528bdb105.tar.gz
added slapt_search_list0.10.2g
-rw-r--r--doc/libslapt.31
-rw-r--r--src/common.c12
-rw-r--r--src/common.h1
3 files changed, 14 insertions, 0 deletions
diff --git a/doc/libslapt.3 b/doc/libslapt.3
index 187aaf0..0a64274 100644
--- a/doc/libslapt.3
+++ b/doc/libslapt.3
@@ -609,6 +609,7 @@ Miscellaneous functionality within libslapt.
.B slapt_list_t *slapt_init_list(void);
.B void slapt_add_list_item(slapt_list_t *list,const char *item);
.B void slapt_remove_list_item(slapt_list_t *list,const char *item);
+.B const char *slapt_search_list(slapt_list_t *list, const char *needle);
.B void slapt_free_list(slapt_list_t *list);
.fi
.sp
diff --git a/src/common.c b/src/common.c
index 23fda50..1cb2c9d 100644
--- a/src/common.c
+++ b/src/common.c
@@ -438,6 +438,18 @@ void slapt_remove_list_item(slapt_list_t *list, const char *item)
}
}
+const char *slapt_search_list(slapt_list_t *list, const char *needle)
+{
+ unsigned int i;
+
+ for (i = 0; i < list->count; i++) {
+ if (strcmp (list->items[i], needle) == 0)
+ return list->items[i];
+ }
+
+ return NULL;
+}
+
void slapt_free_list(slapt_list_t *list)
{
unsigned int i;
diff --git a/src/common.h b/src/common.h
index a889a66..d351f2a 100644
--- a/src/common.h
+++ b/src/common.h
@@ -84,4 +84,5 @@ slapt_list_t *slapt_parse_delimited_list(char *line, char delim);
slapt_list_t *slapt_init_list(void);
void slapt_add_list_item(slapt_list_t *list,const char *item);
void slapt_remove_list_item(slapt_list_t *list,const char *item);
+const char *slapt_search_list(slapt_list_t *list, const char *needle);
void slapt_free_list(slapt_list_t *list);