util_string.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #ifndef TOR_UTIL_STRING_H
  6. #define TOR_UTIL_STRING_H
  7. #include "orconfig.h"
  8. #include "lib/cc/compat_compiler.h"
  9. #include <stddef.h>
  10. const void *tor_memmem(const void *haystack, size_t hlen, const void *needle,
  11. size_t nlen);
  12. const void *tor_memstr(const void *haystack, size_t hlen,
  13. const char *needle);
  14. int tor_mem_is_zero(const char *mem, size_t len);
  15. int tor_digest_is_zero(const char *digest);
  16. int tor_digest256_is_zero(const char *digest);
  17. /** Allowable characters in a hexadecimal string. */
  18. #define HEX_CHARACTERS "0123456789ABCDEFabcdef"
  19. void tor_strlower(char *s);
  20. void tor_strupper(char *s);
  21. int tor_strisprint(const char *s);
  22. int tor_strisnonupper(const char *s);
  23. int tor_strisspace(const char *s);
  24. int strcmp_opt(const char *s1, const char *s2);
  25. int strcmpstart(const char *s1, const char *s2);
  26. int strcmp_len(const char *s1, const char *s2, size_t len);
  27. int strcasecmpstart(const char *s1, const char *s2);
  28. int strcmpend(const char *s1, const char *s2);
  29. int strcasecmpend(const char *s1, const char *s2);
  30. int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix);
  31. void tor_strstrip(char *s, const char *strip);
  32. const char *eat_whitespace(const char *s);
  33. const char *eat_whitespace_eos(const char *s, const char *eos);
  34. const char *eat_whitespace_no_nl(const char *s);
  35. const char *eat_whitespace_eos_no_nl(const char *s, const char *eos);
  36. const char *find_whitespace(const char *s);
  37. const char *find_whitespace_eos(const char *s, const char *eos);
  38. const char *find_str_at_start_of_line(const char *haystack,
  39. const char *needle);
  40. int string_is_C_identifier(const char *string);
  41. #endif /* !defined(TOR_UTIL_STRING_H) */