2 Copyright (C) 2012-2023 Ben Kibbey <bjk@luxsci.net>
4 This file is part of pwmd.
6 Pwmd is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
10 Pwmd is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with Pwmd. If not, see <http://www.gnu.org/licenses/>.
26 #include <sys/types.h>
28 #include <gpg-error.h>
41 // These mimic GLib's string utility functions.
42 void string_free (struct string_s
*s
, int with_data
);
43 struct string_s
*string_erase (struct string_s
*s
, ssize_t pos
, ssize_t len
);
44 struct string_s
*string_new (const char *str
);
45 struct string_s
*string_new_content (char *str
);
46 struct string_s
*string_append (struct string_s
*s
, const char *str
);
47 struct string_s
*string_truncate (struct string_s
*s
, size_t n
);
48 struct string_s
*string_prepend (struct string_s
*s
, const char *str
);
49 struct string_s
*string_append_printf (struct string_s
*s
, const char *fmt
,
51 struct string_s
*string_insert_c (struct string_s
*s
, ssize_t pos
, char c
);
52 gpg_error_t
string_large (struct string_s
*);
54 int strv_printf (char ***array
, const char *fmt
, ...);
55 void strv_free (char **str
);
56 char **strv_cat (char **a
, char *str
);
57 char **strv_catv (char **dst
, char **src
);
58 int strv_length (char **a
);
59 char **strv_dup (char **src
);
60 char *strv_join (const char *delim
, char **a
);
62 char **str_split (const char *str
, const char *delim
, int count
);
63 char **str_split_ws (const char *str
, const char *delim
, int count
);
64 char *str_down (char *str
);
65 char *str_chomp (char *str
);
66 char *str_dup (const char *);
67 char *str_asprintf (const char *fmt
, ...);
68 int str_vasprintf (char **result
, const char *fmt
, va_list ap
);