diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-01-31 16:08:51 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-01-31 16:08:51 -0500 |
commit | c55a46340a089fdbb3d7abdab97dbd7d32bfdffe (patch) | |
tree | 59c0890cf8a352db1f3e8832779fc0156e407847 /include/strlist.h | |
parent | a208097c9091137908beaa1f1f261072df55d3fa (diff) | |
download | spmc-c55a46340a089fdbb3d7abdab97dbd7d32bfdffe.tar.gz |
Initial commit of generic array handler code
Diffstat (limited to 'include/strlist.h')
-rw-r--r-- | include/strlist.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/include/strlist.h b/include/strlist.h new file mode 100644 index 0000000..285880a --- /dev/null +++ b/include/strlist.h @@ -0,0 +1,44 @@ +/** + * String array convenience functions + * @file strlist.h + */ +#ifndef SPM_STRLIST_H +#define SPM_STRLIST_H + +typedef struct { + size_t num_alloc; + size_t num_inuse; + char **data; +} StrList; + +#define STRLIST_DEFAULT 1 << 0 +#define STRLIST_ASC 1 << 1 +#define STRLIST_DSC 1 << 2 + +StrList *strlist_init(); +long double strlist_item_as_long_double(StrList *pStrList, size_t index); +double strlist_item_as_double(StrList *pStrList, size_t index); +float strlist_item_as_float(StrList *pStrList, size_t index); +unsigned long long strlist_item_as_ulong_long(StrList *pStrList, size_t index); +long long strlist_item_as_long_long(StrList *pStrList, size_t index); +unsigned long strlist_item_as_ulong(StrList *pStrList, size_t index); +long strlist_item_as_long(StrList *pStrList, size_t index); +unsigned int strlist_item_as_uint(StrList *pStrList, size_t index); +int strlist_item_as_int(StrList *pStrList, size_t index); +unsigned short strlist_item_as_ushort(StrList *pStrList, size_t index); +short strlist_item_as_short(StrList *pStrList, size_t index); +unsigned char strlist_item_as_uchar(StrList *pStrList, size_t index); +char strlist_item_as_char(StrList *pStrList, size_t index); +char *strlist_item_as_str(StrList *pStrList, size_t index); +char *strlist_item(StrList *pStrList, size_t index); +size_t strlist_count(StrList *pStrList); +void strlist_reverse(StrList *pStrList); +void strlist_sort(StrList *pStrList, unsigned int mode); +static int _strlist_dsc_cmpfn(const void *a, const void *b); +static int _strlist_asc_cmpfn(const void *a, const void *b); +static int _strlist_cmpfn(const void *a, const void *b); +void strlist_append_strlist(StrList *pStrList1, StrList *pStrList2); +void strlist_append(StrList *pStrList, char *str); +void strlist_free(StrList *pStrList); + +#endif //SPM_STRLIST_H |