diff --git a/src/xpdev/str_list.c b/src/xpdev/str_list.c index 70a97c3c6d5fb6b0494d9103156f8608a99ba0ac..d25f403cdf4cbf6db62c2e297de4faedb32972de 100644 --- a/src/xpdev/str_list.c +++ b/src/xpdev/str_list.c @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -43,7 +43,7 @@ #include "genwrap.h" /* stricmp */ #include "str_list.h" -str_list_t strListInit() +str_list_t strListInit(void) { str_list_t list; @@ -63,6 +63,21 @@ size_t strListCount(const str_list_t list) return(i); } +int strListIndexOf(const str_list_t list, const char* str) +{ + size_t i; + + if(list==NULL) + return -1; + + for(i=0; list[i]!=NULL; i++) { + if(list[i]==str) + return i; + } + + return -1; +} + static char* str_list_append(str_list_t* list, char* str, size_t index) { str_list_t lp; diff --git a/src/xpdev/str_list.h b/src/xpdev/str_list.h index 7a5710381492466ceba4cf4922b0d38d89626934..d762e47989f82967861906c3ef8387447344392d 100644 --- a/src/xpdev/str_list.h +++ b/src/xpdev/str_list.h @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -101,6 +101,9 @@ size_t strListMerge(str_list_t*, str_list_t append_list); /* Count the number of strings in the list and returns the count */ size_t strListCount(const str_list_t); +/* Returns the index of the specified str (by ptr compare) or -1 if not found */ +int strListIndexOf(const str_list_t, const char* str); + /* Sort the strings in the string list */ void strListSortAlpha(str_list_t); void strListSortAlphaReverse(str_list_t);