1 // This file is under GNU General Public License 3.0
6 #include "dynamic_api.h"
13 typedef struct _stringpair_t {
14 char * key; // may point to "" but must not be NULL!
15 char * value; // may point to "" but must not be NULL!
19 // new_stringpair() - allocate new stringpair_t
22 // key (in) utf-8 string used as key, should not be NULL
23 // value (in) utf-8 string containing the value, should not be NULL
26 // pointer to stringpair_t or NULL on failure
29 // key and value are copied and remain in the ownership of the caller
31 DYNAMIC_API stringpair_t * new_stringpair(const char *key, const char *value);
34 // free_stringpair() - free memory allocated by stringpair_t
37 // pair (in) pointer to stringpair_t to free
39 DYNAMIC_API void free_stringpair(stringpair_t * pair);
42 // stringpair_dup() - duplicate stringpair_t (deep copy)
45 // src (in) pointer to stringpair_t to duplicate
48 // pointer to copy of src or NULL on failure
50 DYNAMIC_API stringpair_t * stringpair_dup(const stringpair_t *src);
53 typedef struct _stringpair_list_t {
55 struct _stringpair_list_t *next;
59 // new_stringpair_list() - allocate a new stringpair_list
62 // value (in) initial value
65 // pointer to stringpair_list_t object or NULL if out of memory
68 // the ownership of the value goes to the stringpair_list
69 // next pointer is NULL
71 DYNAMIC_API stringpair_list_t *new_stringpair_list(stringpair_t *value);
74 // stringpair_list_dup() - duplicate a stringpair_list (deep copy)
77 // src (in) stringpair_list to copy
80 // pointer to stringpair_list_t object or NULL if out of memory
81 // stringpair value copies created by this function belong to the returned list
83 DYNAMIC_API stringpair_list_t *stringpair_list_dup(
84 const stringpair_list_t *src
88 // stringpair_list_add() - add key to stringpair_list
91 // stringpair_list (in) stringpair_list struct or NULL to create a new
93 // value (in) stringpair to add
96 // pointer to last element in stringpair_list or NULL if out of memory
99 // the ownership of the value goes to the stringpair_list if add is successful
101 DYNAMIC_API stringpair_list_t *stringpair_list_add(
102 stringpair_list_t *stringpair_list,
107 // stringpair_list_append() - append stringpair_list to stringpair_list
110 // stringpair_list (in) stringpair_list struct to append to
111 // second (in) stringpair_list struct to append
114 // pointer to last element in stringpair_list or NULL if out of memory
115 // or stringpair_list is NULL
118 // all values are being copied before being added to the list
119 // the original values are still being owned by the caller
121 DYNAMIC_API stringpair_list_t *stringpair_list_append(
122 stringpair_list_t *stringpair_list,
123 stringpair_list_t *second
127 // stringpair_list_length() - get length of stringpair_list
130 // stringpair_list (in) stringpair_list struct to determine length of
133 // length of stringpair_list in number of elements
135 DYNAMIC_API int stringpair_list_length(
136 const stringpair_list_t *stringpair_list
140 // free_stringpair_list() - free memory occupied by stringpair_list
143 // stringpair_list (in) stringpair_list to free
145 DYNAMIC_API void free_stringpair_list(stringpair_list_t *stringpair_list);
148 // stringpair_list_find() - find element in list using key
151 // stringpair_list (in) list to search
152 // key (in) key to search for
155 // node with result if found or NULL if not
157 DYNAMIC_API stringpair_list_t *stringpair_list_find(
158 stringpair_list_t *stringpair_list,