Let --no-agent work when compiled without gpg-agent support.
[pwmd.git] / src / util-string.h
blobf02319b69139dea3dc74c0541ac7a8af79d68946
1 /*
2 Copyright (C) 2012
3 Ben Kibbey <bjk@luxsci.net>
5 This file is part of pwmd.
7 Pwmd is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 2 of the License, or
10 (at your option) any later version.
12 Pwmd is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Pwmd. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef UTIL_STRING_H
21 #define UTIL_STRING_H
23 #include <stdarg.h>
25 struct string_s
27 size_t allocated;
28 size_t len;
29 char *str;
32 // These mimic GLib's string utility functions.
33 void string_free (struct string_s *s, int with_data);
34 struct string_s *string_erase (struct string_s *s, ssize_t pos, ssize_t len);
35 struct string_s *string_new (const char *str);
36 struct string_s *string_append (struct string_s *s, const char *str);
37 struct string_s *string_truncate (struct string_s *s, size_t n);
38 struct string_s *string_prepend (struct string_s *s, const char *str);
39 struct string_s *string_append_printf (struct string_s *s, const char *fmt,
40 ...);
41 struct string_s *string_insert_c (struct string_s *s, ssize_t pos, char c);
43 int strv_printf (char ***array, const char *fmt, ...);
44 void strv_free (char **str);
45 char **strv_cat (char **a, char *str);
46 char **strv_catv (char **dst, char **src);
47 int strv_length (char **a);
48 char **strv_dup (char **src);
49 char *strv_join (char *delim, char **a);
51 char **str_split (const char *str, const char *delim, int count);
52 char *str_down (char *str);
53 char *str_chomp (char *str);
54 char *str_dup (const char *);
55 char *str_asprintf (const char *fmt, ...);
56 int str_vasprintf (char **result, const char *fmt, va_list ap);
58 #endif