Skip to content
Snippets Groups Projects
Commit 3bef9d40 authored by rswindell's avatar rswindell
Browse files

Created strListIndexOf() to return the index of the passed string pointer.

parent 93ceeed9
Branches
Tags
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @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 * * This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#include "genwrap.h" /* stricmp */ #include "genwrap.h" /* stricmp */
#include "str_list.h" #include "str_list.h"
str_list_t strListInit() str_list_t strListInit(void)
{ {
str_list_t list; str_list_t list;
...@@ -63,6 +63,21 @@ size_t strListCount(const str_list_t list) ...@@ -63,6 +63,21 @@ size_t strListCount(const str_list_t list)
return(i); 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) static char* str_list_append(str_list_t* list, char* str, size_t index)
{ {
str_list_t lp; str_list_t lp;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @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 * * This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * 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); ...@@ -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 */ /* Count the number of strings in the list and returns the count */
size_t strListCount(const str_list_t); 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 */ /* Sort the strings in the string list */
void strListSortAlpha(str_list_t); void strListSortAlpha(str_list_t);
void strListSortAlphaReverse(str_list_t); void strListSortAlphaReverse(str_list_t);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment