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