util_string.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Copyright (c) 2003-2004, Roger Dingledine
  2. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  3. * Copyright (c) 2007-2019, 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 fast_mem_is_zero(const char *mem, size_t len);
  19. #define fast_digest_is_zero(d) fast_mem_is_zero((d), DIGEST_LEN)
  20. #define fast_digetst256_is_zero(d) fast_mem_is_zero((d), DIGEST256_LEN)
  21. int tor_digest_is_zero(const char *digest);
  22. int tor_digest256_is_zero(const char *digest);
  23. /** Allowable characters in a hexadecimal string. */
  24. #define HEX_CHARACTERS "0123456789ABCDEFabcdef"
  25. void tor_strlower(char *s);
  26. void tor_strupper(char *s);
  27. int tor_strisprint(const char *s);
  28. int tor_strisnonupper(const char *s);
  29. int tor_strisspace(const char *s);
  30. int strcmp_opt(const char *s1, const char *s2);
  31. int strcmpstart(const char *s1, const char *s2);
  32. int strcasecmpstart(const char *s1, const char *s2);
  33. int strcmpend(const char *s1, const char *s2);
  34. int strcasecmpend(const char *s1, const char *s2);
  35. int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix);
  36. void tor_strstrip(char *s, const char *strip);
  37. const char *eat_whitespace(const char *s);
  38. const char *eat_whitespace_eos(const char *s, const char *eos);
  39. const char *eat_whitespace_no_nl(const char *s);
  40. const char *eat_whitespace_eos_no_nl(const char *s, const char *eos);
  41. const char *find_whitespace(const char *s);
  42. const char *find_whitespace_eos(const char *s, const char *eos);
  43. const char *find_str_at_start_of_line(const char *haystack,
  44. const char *needle);
  45. int string_is_C_identifier(const char *string);
  46. int string_is_utf8(const char *str, size_t len);
  47. int string_is_utf8_no_bom(const char *str, size_t len);
  48. #endif /* !defined(TOR_UTIL_STRING_H) */