/* * Data structure for dynamic string lists that works * similar to the stralloc library. * Return values: 1 if successful, 0 in case of failures. * afb 4/2003 */ #ifndef STRLIST_H #define STRLIST_H typedef struct strlist { char** list; unsigned int len; /* # of strings in list */ unsigned int allocated; /* allocated length for list */ } strlist; /* assure that there is at least room for len list entries */ int strlist_ready(strlist* list, unsigned int len); /* assure that there is room for len additional list entries */ int strlist_readyplus(strlist* list, unsigned int len); /* truncate the list to zero length */ int strlist_clear(strlist* list); /* append the string pointer to the list */ int strlist_push(strlist* list, char* string); #define strlist_push0(list) strlist_push((list), 0) /* free the strlist data structure but not the strings */ int strlist_free(strlist* list); #endif