src/stringlist.h
author Volker Birk <vb@pep-project.org>
Thu, 31 Mar 2016 14:01:45 +0200
changeset 523 afaf34a57cc6
parent 113 4bee48270834
child 826 51b1d46df1ae
permissions -rw-r--r--
delete from stringlist
     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(
    56         stringlist_t *stringlist,
    57         const char *value
    58     );
    59 
    60 
    61 // stringlist_append() - append stringlist to stringlist
    62 //
    63 //  parameters:
    64 //      stringlist (in)     stringlist struct to append to
    65 //      second (in)         stringlist struct to append
    66 //
    67 //  return value:
    68 //      pointer to last element in stringlist or NULL if out of memory
    69 //
    70 //  caveat:
    71 //      all values are being copied before being added to the list
    72 //      the original values are still being owned by the caller
    73 
    74 DYNAMIC_API stringlist_t *stringlist_append(
    75         stringlist_t *stringlist,
    76         stringlist_t *second
    77     );
    78 
    79 
    80 // stringlist_length() - get length of stringlist
    81 //
    82 //  parameters:
    83 //      stringlist (in)     stringlist struct to determine length of
    84 //
    85 //  return value:
    86 //      length of stringlist in number of elements
    87 
    88 DYNAMIC_API int stringlist_length(const stringlist_t *stringlist);
    89 
    90 
    91 // stringlist_delete() - delete entry from stringlist
    92 //
    93 //  parameters:
    94 //      stringlist (in)     stringlist struct to delete from
    95 //      value (in)          data to delete
    96 //
    97 //  return value:
    98 //      modified stringlist
    99 
   100 DYNAMIC_API stringlist_t *stringlist_delete(
   101         stringlist_t *stringlist,
   102         const char *value
   103     );
   104 
   105 
   106 // free_stringlist() - free memory occupied by stringlist
   107 //
   108 //  parameters:
   109 //      stringlist (in)    stringlist to free
   110 
   111 DYNAMIC_API void free_stringlist(stringlist_t *stringlist);
   112 
   113 
   114 #ifdef __cplusplus
   115 }
   116 #endif
   117