po: Update German man pages translation
[dpkg.git] / lib / dpkg / string.h
blob47ecd048744bd6e821d8fcb460e42485ec245cbc
1 /*
2 * libdpkg - Debian packaging suite library routines
3 * string.h - string handling routines
5 * Copyright © 2008-2015 Guillem Jover <guillem@debian.org>
7 * This 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 * This 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 this program. If not, see <https://www.gnu.org/licenses/>.
21 #ifndef LIBDPKG_STRING_H
22 #define LIBDPKG_STRING_H
24 #include <stddef.h>
25 #include <stdbool.h>
27 #include <dpkg/macros.h>
29 DPKG_BEGIN_DECLS
31 /**
32 * @defgroup string String handling
33 * @ingroup dpkg-internal
34 * @{
37 /**
38 * Check if a string is either null or empty.
40 static inline bool
41 str_is_unset(const char *str)
43 return str == DPKG_NULL || str[0] == '\0';
46 /**
47 * Check if a string has content.
49 static inline bool
50 str_is_set(const char *str)
52 return str != DPKG_NULL && str[0] != '\0';
55 bool str_match_end(const char *str, const char *end);
57 unsigned int str_fnv_hash(const char *str);
59 char *str_concat(char *dst, ...) DPKG_ATTR_SENTINEL;
60 char *str_fmt(const char *fmt, ...) DPKG_ATTR_PRINTF(1);
61 char *str_escape_fmt(char *dest, const char *src, size_t n);
62 char *str_quote_meta(const char *src);
63 char *str_strip_quotes(char *str);
64 char *str_rtrim_spaces(const char *str, char *str_end);
66 struct str_crop_info {
67 int str_bytes;
68 int max_bytes;
71 int str_width(const char *str);
72 void str_gen_crop(const char *str, int max_width, struct str_crop_info *crop);
74 /** @} */
76 DPKG_END_DECLS
78 #endif /* LIBDPKG_STRING_H */