src/stringlist.h
author Roker <roker@pep-project.org>
Tue, 27 Sep 2016 21:36:31 +0200
branchkeysync
changeset 1201 571f488333be
parent 909 e39e9fec2da0
child 1513 e7f7e42385b5
permissions -rw-r--r--
add "-luuid" to LDFLAGS due to linker errors on Ubuntu
     1 #pragma once
     2 
     3 #include "dynamic_api.h"
     4 
     5 #ifdef __cplusplus
     6 extern "C" {
     7 #endif
     8 
     9 
    10 typedef struct _stringlist_t {
    11     char *value;
    12     struct _stringlist_t *next;
    13 } stringlist_t;
    14 
    15 
    16 // new_stringlist() - allocate a new stringlist
    17 //
    18 //  parameters:
    19 //      value (in)        initial value as C string or NULL for empty list
    20 //
    21 //  return value:
    22 //      pointer to stringlist_t object or NULL if out of memory
    23 //
    24 //  caveat:
    25 //      the value is being copied before being added to the list
    26 //      the original string is still being owned by the caller
    27 //      the "next" pointer of the returned object is NULL
    28 
    29 DYNAMIC_API stringlist_t *new_stringlist(const char *value);
    30 
    31 
    32 // stringlist_dup() - duplicate a stringlist
    33 //
    34 //  parameters:
    35 //      src (in)            stringlist to copy
    36 //
    37 //  return value:
    38 //      pointer to stringlist_t object or NULL if out of memory
    39 
    40 DYNAMIC_API stringlist_t *stringlist_dup(const stringlist_t *src);
    41 
    42 
    43 // stringlist_add() - add key to stringlist
    44 //
    45 //  parameters:
    46 //      stringlist (in)     stringlist struct or NULL to create a new one
    47 //      value (in)          value as C string
    48 //
    49 //  return value:
    50 //      pointer to last element in stringlist or NULL if out of memory
    51 //
    52 //  caveat:
    53 //      the value is being copied before being added to the list
    54 //      the original string is still being owned by the caller
    55 
    56 DYNAMIC_API stringlist_t *stringlist_add(
    57         stringlist_t *stringlist,
    58         const char *value
    59     );
    60 
    61 
    62 // stringlist_append() - append stringlist to stringlist
    63 //
    64 //  parameters:
    65 //      stringlist (in)     stringlist struct to append to
    66 //      second (in)         stringlist struct to append
    67 //
    68 //  return value:
    69 //      pointer to last element in stringlist or NULL if out of memory
    70 //      or stringpair_list is NULL
    71 //
    72 //  caveat:
    73 //      all values are being copied before being added to the list
    74 //      the original values are still being owned by the caller
    75 
    76 DYNAMIC_API stringlist_t *stringlist_append(
    77         stringlist_t *stringlist,
    78         stringlist_t *second
    79     );
    80 
    81 
    82 // stringlist_length() - get length of stringlist
    83 //
    84 //  parameters:
    85 //      stringlist (in)     stringlist struct to determine length of
    86 //
    87 //  return value:
    88 //      length of stringlist in number of elements
    89 
    90 DYNAMIC_API int stringlist_length(const stringlist_t *stringlist);
    91 
    92 
    93 // stringlist_delete() - delete entry from stringlist
    94 //
    95 //  parameters:
    96 //      stringlist (in)     stringlist struct to delete from
    97 //      value (in)          data to delete
    98 //
    99 //  return value:
   100 //      modified stringlist
   101 
   102 DYNAMIC_API stringlist_t *stringlist_delete(
   103         stringlist_t *stringlist,
   104         const char *value
   105     );
   106 
   107 
   108 // free_stringlist() - free memory occupied by stringlist
   109 //
   110 //  parameters:
   111 //      stringlist (in)    stringlist to free
   112 
   113 DYNAMIC_API void free_stringlist(stringlist_t *stringlist);
   114 
   115 
   116 #ifdef __cplusplus
   117 }
   118 #endif
   119