src/stringlist.h
author vb
Wed, 11 Mar 2015 11:52:14 +0100
changeset 98 9e3d28932e7b
child 113 4bee48270834
permissions -rw-r--r--
reorga
     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 
    28 DYNAMIC_API stringlist_t *new_stringlist(const char *value);
    29 
    30 
    31 // stringlist_dup() - duplicate a stringlist
    32 //
    33 //  parameters:
    34 //      src (in)            stringlist to copy
    35 //
    36 //  return value:
    37 //      pointer to stringlist_t object or NULL if out of memory
    38 
    39 DYNAMIC_API stringlist_t *stringlist_dup(const stringlist_t *src);
    40 
    41 
    42 // stringlist_add() - add key to stringlist
    43 //
    44 //  parameters:
    45 //      stringlist (in)     stringlist struct or NULL to create a new one
    46 //      value (in)          value as C string
    47 //
    48 //  return value:
    49 //      pointer to last element in stringlist or NULL if out of memory
    50 //
    51 //  caveat:
    52 //      the value is being copied before being added to the list
    53 //      the original string is still being owned by the caller
    54 
    55 DYNAMIC_API stringlist_t *stringlist_add(stringlist_t *stringlist, const char *value);
    56 
    57 
    58 // stringlist_append() - append stringlist to stringlist
    59 //
    60 //  parameters:
    61 //      stringlist (in)     stringlist struct to append to
    62 //      second (in)         stringlist struct to append
    63 //
    64 //  return value:
    65 //      pointer to last element in stringlist or NULL if out of memory
    66 //
    67 //  caveat:
    68 //      all values are being copied before being added to the list
    69 //      the original values are still being owned by the caller
    70 
    71 DYNAMIC_API stringlist_t *stringlist_append(stringlist_t *stringlist,
    72         stringlist_t *second);
    73 
    74 
    75 // stringlist_length() - get length of stringlist
    76 //
    77 //  parameters:
    78 //      stringlist (in)     stringlist struct to determine length of
    79 //
    80 //  return value:
    81 //      length of stringlist in number of elements
    82 
    83 DYNAMIC_API int stringlist_length(const stringlist_t *stringlist);
    84 
    85 
    86 // free_stringlist() - free memory occupied by stringlist
    87 //
    88 //  parameters:
    89 //      stringlist (in)    stringlist to free
    90 
    91 DYNAMIC_API void free_stringlist(stringlist_t *stringlist);
    92 
    93 
    94 #ifdef __cplusplus
    95 }
    96 #endif
    97