src/stringlist.h
author Krista Grothoff <krista@pep-project.org>
Mon, 13 Feb 2017 22:13:48 +0100
branchenigmail-color-tests
changeset 1582 7dd855780eef
parent 1513 e7f7e42385b5
child 1694 032e59ccdd93
permissions -rw-r--r--
closing branch
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
vb@98
    64
vb@98
    65
// stringlist_append() - append stringlist to stringlist
vb@98
    66
//
vb@98
    67
//  parameters:
vb@98
    68
//      stringlist (in)     stringlist struct to append to
vb@98
    69
//      second (in)         stringlist struct to append
vb@98
    70
//
vb@98
    71
//  return value:
vb@98
    72
//      pointer to last element in stringlist or NULL if out of memory
krista@836
    73
//      or stringpair_list is NULL
vb@98
    74
//
vb@98
    75
//  caveat:
vb@98
    76
//      all values are being copied before being added to the list
vb@98
    77
//      the original values are still being owned by the caller
vb@98
    78
vb@113
    79
DYNAMIC_API stringlist_t *stringlist_append(
vb@113
    80
        stringlist_t *stringlist,
vb@113
    81
        stringlist_t *second
vb@113
    82
    );
vb@98
    83
vb@98
    84
vb@98
    85
// stringlist_length() - get length of stringlist
vb@98
    86
//
vb@98
    87
//  parameters:
vb@98
    88
//      stringlist (in)     stringlist struct to determine length of
vb@98
    89
//
vb@98
    90
//  return value:
vb@98
    91
//      length of stringlist in number of elements
vb@98
    92
vb@98
    93
DYNAMIC_API int stringlist_length(const stringlist_t *stringlist);
vb@98
    94
vb@98
    95
vb@523
    96
// stringlist_delete() - delete entry from stringlist
vb@523
    97
//
vb@523
    98
//  parameters:
vb@523
    99
//      stringlist (in)     stringlist struct to delete from
vb@523
   100
//      value (in)          data to delete
vb@523
   101
//
vb@523
   102
//  return value:
vb@523
   103
//      modified stringlist
vb@523
   104
vb@523
   105
DYNAMIC_API stringlist_t *stringlist_delete(
vb@523
   106
        stringlist_t *stringlist,
vb@523
   107
        const char *value
vb@523
   108
    );
vb@523
   109
vb@523
   110
vb@98
   111
// free_stringlist() - free memory occupied by stringlist
vb@98
   112
//
vb@98
   113
//  parameters:
vb@98
   114
//      stringlist (in)    stringlist to free
vb@98
   115
vb@98
   116
DYNAMIC_API void free_stringlist(stringlist_t *stringlist);
vb@98
   117
vb@98
   118
vb@98
   119
#ifdef __cplusplus
vb@98
   120
}
vb@98
   121
#endif
vb@98
   122