string.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * libdpkg - Debian packaging suite library routines
  3. * string.h - string handling routines
  4. *
  5. * Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
  6. *
  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.
  11. *
  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.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef LIBDPKG_STRING_H
  21. #define LIBDPKG_STRING_H
  22. #include <stdbool.h>
  23. #include <dpkg/macros.h>
  24. DPKG_BEGIN_DECLS
  25. /**
  26. * @defgroup string String handling
  27. * @ingroup dpkg-internal
  28. * @{
  29. */
  30. /**
  31. * Check if a string is either NULL or empty.
  32. */
  33. static inline bool
  34. str_is_unset(const char *str)
  35. {
  36. return str == NULL || str[0] == '\0';
  37. }
  38. /**
  39. * Check if a string has content.
  40. */
  41. static inline bool
  42. str_is_set(const char *str)
  43. {
  44. return str != NULL && str[0] != '\0';
  45. }
  46. char *str_escape_fmt(char *dest, const char *src, size_t n);
  47. char *str_quote_meta(const char *src);
  48. char *str_strip_quotes(char *str);
  49. /** @} */
  50. DPKG_END_DECLS
  51. #endif /* LIBDPKG_STRING_H */