Mercurial > hg-old > index.cgi
diff lwlib/lw_stringlist.c @ 326:2eb058346cad
Added string module and expanded stringlist module
author | lost |
---|---|
date | Sat, 13 Feb 2010 05:21:20 +0000 |
parents | be63116281b0 |
children | 80826bf2827b |
line wrap: on
line diff
--- a/lwlib/lw_stringlist.c Sat Feb 13 05:20:55 2010 +0000 +++ b/lwlib/lw_stringlist.c Sat Feb 13 05:21:20 2010 +0000 @@ -21,9 +21,11 @@ #include <config.h> +#include <stdlib.h> + #define ___lw_stringlist_c_seen___ #include "lw_stringlist.h" - +#include "lw_string.h" #include "lw_alloc.h" lw_stringlist_t lw_stringlist_create(void) @@ -43,3 +45,33 @@ lw_free(S); } } + +void lw_stringlist_addstring(lw_stringlist_t S, char *str) +{ + S -> strings = lw_realloc(S -> strings, sizeof(char *) * (S -> nstrings + 1)); + S -> strings[S -> nstrings] = lw_strdup(str); + S -> nstrings++; +} + +void lw_stringlist_reset(lw_stringlist_t S) +{ + S -> cstring = 0; +} + +char *lw_stringlist_current(lw_stringlist_t S) +{ + if (S -> cstring >= S -> nstrings) + return NULL; + return S -> strings[S -> cstring]; +} + +char *lw_stringlist_next(lw_stringlist_t S) +{ + S -> cstring++; + return lw_stringlist_current(S); +} + +int lw_stringlist_nstrings(lw_stringlist_t S) +{ + return S -> nstrings; +}