str.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /** @file str.h
  2. * @brief Public interface for faux string functions.
  3. */
  4. #ifndef _faux_str_h
  5. #define _faux_str_h
  6. #include <stddef.h>
  7. #include <faux/faux.h>
  8. #define UTF8_MASK 0xC0
  9. #define UTF8_7BIT_MASK 0x80 // One byte or multibyte
  10. #define UTF8_11 0xC0 // First UTF8 byte
  11. #define UTF8_10 0x80 // Next UTF8 bytes
  12. C_DECL_BEGIN
  13. void faux_str_free(char *str);
  14. char *faux_str_dupn(const char *str, size_t n);
  15. char *faux_str_dup(const char *str);
  16. char *faux_str_catn(char **str, const char *text, size_t n);
  17. char *faux_str_cat(char **str, const char *text);
  18. char *faux_str_mcat(char **str, ...);
  19. char *faux_str_sprintf(const char *fmt, ...);
  20. char *faux_str_tolower(const char *str);
  21. char *faux_str_toupper(const char *str);
  22. int faux_str_casecmpn(const char *str1, const char *str2, size_t n);
  23. int faux_str_casecmp(const char *str1, const char *str2);
  24. char *faux_str_casestr(const char *haystack, const char *needle);
  25. char *faux_str_charsn(const char *str, const char *chars_to_search, size_t n);
  26. char *faux_str_chars(const char *str, const char *chars_to_search);
  27. bool_t faux_str_is_empty(const char *str);
  28. char *faux_str_c_esc(const char *src);
  29. char *faux_str_c_bin(const char *src, size_t n);
  30. char *faux_str_nextword(const char *str, const char **saveptr,
  31. const char *alt_quotes, bool_t *qclosed);
  32. //const char *faux_str_suffix(const char *string);
  33. /*
  34. * These are the escape characters which are used by default when
  35. * expanding variables. These characters will be backslash escaped
  36. * to prevent them from being interpreted in a script.
  37. *
  38. * This is a security feature to prevent users from arbitarily setting
  39. * parameters to contain special sequences.
  40. */
  41. //extern const char *faux_str_esc_default;
  42. //extern const char *faux_str_esc_regex;
  43. //extern const char *faux_str_esc_quoted;
  44. //char *faux_str_decode(const char *string);
  45. //char *faux_str_ndecode(const char *string, unsigned int len);
  46. //char *faux_str_encode(const char *string, const char *escape_chars);
  47. //unsigned int faux_str_equal_part(const char *str1, const char *str2,
  48. // bool_t utf8);
  49. C_DECL_END
  50. #endif /* _faux_str_h */