util_string.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Copyright (c) 2003-2004, Roger Dingledine
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  4. /* See LICENSE for licensing information */
  5. /**
  6. * \file util_string.h
  7. * \brief Header for util_string.c
  8. **/
  9. #ifndef TOR_UTIL_STRING_H
  10. #define TOR_UTIL_STRING_H
  11. #include "orconfig.h"
  12. #include "lib/cc/compat_compiler.h"
  13. #include <stddef.h>
  14. const void *tor_memmem(const void *haystack, size_t hlen, const void *needle,
  15. size_t nlen);
  16. const void *tor_memstr(const void *haystack, size_t hlen,
  17. const char *needle);
  18. int tor_mem_is_zero(const char *mem, size_t len);
  19. int tor_digest_is_zero(const char *digest);
  20. int tor_digest256_is_zero(const char *digest);
  21. /** Allowable characters in a hexadecimal string. */
  22. #define HEX_CHARACTERS "0123456789ABCDEFabcdef"
  23. void tor_strlower(char *s);
  24. void tor_strupper(char *s);
  25. int tor_strisprint(const char *s);
  26. int tor_strisnonupper(const char *s);
  27. int tor_strisspace(const char *s);
  28. int strcmp_opt(const char *s1, const char *s2);
  29. int strcmpstart(const char *s1, const char *s2);
  30. int strcmp_len(const char *s1, const char *s2, size_t len);
  31. int strcasecmpstart(const char *s1, const char *s2);
  32. int strcmpend(const char *s1, const char *s2);
  33. int strcasecmpend(const char *s1, const char *s2);
  34. int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix);
  35. void tor_strstrip(char *s, const char *strip);
  36. const char *eat_whitespace(const char *s);
  37. const char *eat_whitespace_eos(const char *s, const char *eos);
  38. const char *eat_whitespace_no_nl(const char *s);
  39. const char *eat_whitespace_eos_no_nl(const char *s, const char *eos);
  40. const char *find_whitespace(const char *s);
  41. const char *find_whitespace_eos(const char *s, const char *eos);
  42. const char *find_str_at_start_of_line(const char *haystack,
  43. const char *needle);
  44. int string_is_C_identifier(const char *string);
  45. int string_is_utf8(const char *str, size_t len);
  46. int string_is_utf8_no_bom(const char *str, size_t len);
  47. #endif /* !defined(TOR_UTIL_STRING_H) */