src/stringlist.h
author Krista Bennett <krista@pep-project.org>
Tue, 14 Aug 2018 13:45:34 +0200
branchENGINE-451
changeset 2826 07c080d73a63
parent 1694 032e59ccdd93
child 2963 a80bc5f9167e
permissions -rw-r--r--
ENGINE-451: abandoning branch - config files to be dealt with using gpgme (and hotfix will be external to engine
vb@1513
     1
// This file is under GNU General Public License 3.0
vb@1513
     2
// see LICENSE.txt
vb@1513
     3
vb@98
     4
#pragma once
vb@98
     5
vb@98
     6
#include "dynamic_api.h"
vb@98
     7
vb@98
     8
#ifdef __cplusplus
vb@98
     9
extern "C" {
vb@98
    10
#endif
vb@98
    11
vb@98
    12
vb@98
    13
typedef struct _stringlist_t {
vb@98
    14
    char *value;
vb@98
    15
    struct _stringlist_t *next;
vb@98
    16
} stringlist_t;
vb@98
    17
vb@98
    18
vb@98
    19
// new_stringlist() - allocate a new stringlist
vb@98
    20
//
vb@98
    21
//  parameters:
vb@98
    22
//      value (in)        initial value as C string or NULL for empty list
vb@98
    23
//
vb@98
    24
//  return value:
vb@98
    25
//      pointer to stringlist_t object or NULL if out of memory
vb@98
    26
//
vb@98
    27
//  caveat:
vb@98
    28
//      the value is being copied before being added to the list
vb@98
    29
//      the original string is still being owned by the caller
krista@909
    30
//      the "next" pointer of the returned object is NULL
vb@98
    31
vb@98
    32
DYNAMIC_API stringlist_t *new_stringlist(const char *value);
vb@98
    33
vb@98
    34
vb@98
    35
// stringlist_dup() - duplicate a stringlist
vb@98
    36
//
vb@98
    37
//  parameters:
vb@98
    38
//      src (in)            stringlist to copy
vb@98
    39
//
vb@98
    40
//  return value:
vb@98
    41
//      pointer to stringlist_t object or NULL if out of memory
vb@98
    42
vb@98
    43
DYNAMIC_API stringlist_t *stringlist_dup(const stringlist_t *src);
vb@98
    44
vb@98
    45
vb@98
    46
// stringlist_add() - add key to stringlist
vb@98
    47
//
vb@98
    48
//  parameters:
vb@98
    49
//      stringlist (in)     stringlist struct or NULL to create a new one
vb@98
    50
//      value (in)          value as C string
vb@98
    51
//
vb@98
    52
//  return value:
vb@98
    53
//      pointer to last element in stringlist or NULL if out of memory
vb@98
    54
//
vb@98
    55
//  caveat:
vb@98
    56
//      the value is being copied before being added to the list
vb@98
    57
//      the original string is still being owned by the caller
vb@98
    58
vb@113
    59
DYNAMIC_API stringlist_t *stringlist_add(
vb@113
    60
        stringlist_t *stringlist,
vb@113
    61
        const char *value
vb@113
    62
    );
vb@98
    63
edouard@1694
    64
// stringlist_add_unique() - add string to stringlist, if not already there
edouard@1694
    65
//
edouard@1694
    66
//  parameters:
edouard@1694
    67
//      stringlist (in)     stringlist struct or NULL to create a new one
edouard@1694
    68
//      value (in)          value as C string
edouard@1694
    69
//
edouard@1694
    70
//  return value:
edouard@1694
    71
//      pointer to last element in stringlist or NULL if out of memory
edouard@1694
    72
//
edouard@1694
    73
//  caveat:
edouard@1694
    74
//      the value is being copied before being added to the list
edouard@1694
    75
//      the original string is still being owned by the caller
edouard@1694
    76
edouard@1694
    77
DYNAMIC_API stringlist_t *stringlist_add_unique(
edouard@1694
    78
        stringlist_t *stringlist,
edouard@1694
    79
        const char *value
edouard@1694
    80
    );
edouard@1694
    81
vb@98
    82
vb@98
    83
// stringlist_append() - append stringlist to stringlist
vb@98
    84
//
vb@98
    85
//  parameters:
vb@98
    86
//      stringlist (in)     stringlist struct to append to
vb@98
    87
//      second (in)         stringlist struct to append
vb@98
    88
//
vb@98
    89
//  return value:
vb@98
    90
//      pointer to last element in stringlist or NULL if out of memory
krista@836
    91
//      or stringpair_list is NULL
vb@98
    92
//
vb@98
    93
//  caveat:
vb@98
    94
//      all values are being copied before being added to the list
vb@98
    95
//      the original values are still being owned by the caller
vb@98
    96
vb@113
    97
DYNAMIC_API stringlist_t *stringlist_append(
vb@113
    98
        stringlist_t *stringlist,
vb@113
    99
        stringlist_t *second
vb@113
   100
    );
vb@98
   101
vb@98
   102
vb@98
   103
// stringlist_length() - get length of stringlist
vb@98
   104
//
vb@98
   105
//  parameters:
vb@98
   106
//      stringlist (in)     stringlist struct to determine length of
vb@98
   107
//
vb@98
   108
//  return value:
vb@98
   109
//      length of stringlist in number of elements
vb@98
   110
vb@98
   111
DYNAMIC_API int stringlist_length(const stringlist_t *stringlist);
vb@98
   112
vb@98
   113
vb@523
   114
// stringlist_delete() - delete entry from stringlist
vb@523
   115
//
vb@523
   116
//  parameters:
vb@523
   117
//      stringlist (in)     stringlist struct to delete from
vb@523
   118
//      value (in)          data to delete
vb@523
   119
//
vb@523
   120
//  return value:
vb@523
   121
//      modified stringlist
vb@523
   122
vb@523
   123
DYNAMIC_API stringlist_t *stringlist_delete(
vb@523
   124
        stringlist_t *stringlist,
vb@523
   125
        const char *value
vb@523
   126
    );
vb@523
   127
vb@523
   128
vb@98
   129
// free_stringlist() - free memory occupied by stringlist
vb@98
   130
//
vb@98
   131
//  parameters:
vb@98
   132
//      stringlist (in)    stringlist to free
vb@98
   133
vb@98
   134
DYNAMIC_API void free_stringlist(stringlist_t *stringlist);
vb@98
   135
vb@98
   136
vb@98
   137
#ifdef __cplusplus
vb@98
   138
}
vb@98
   139
#endif
vb@98
   140