Merge branch 'tor-gitlab/mr/583' into maint-0.4.7
[tor.git] / src / lib / string / util_string.h
blobcf63d53f3719885b2489710fb945251d19cdcb53
1 /* Copyright (c) 2003-2004, Roger Dingledine
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2021, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
6 /**
7 * \file util_string.h
8 * \brief Header for util_string.c
9 **/
11 #ifndef TOR_UTIL_STRING_H
12 #define TOR_UTIL_STRING_H
14 #include "orconfig.h"
15 #include "lib/cc/compat_compiler.h"
17 #include <stddef.h>
19 const void *tor_memmem(const void *haystack, size_t hlen, const void *needle,
20 size_t nlen);
21 const void *tor_memstr(const void *haystack, size_t hlen,
22 const char *needle);
23 int fast_mem_is_zero(const char *mem, size_t len);
24 #define fast_digest_is_zero(d) fast_mem_is_zero((d), DIGEST_LEN)
25 #define fast_digetst256_is_zero(d) fast_mem_is_zero((d), DIGEST256_LEN)
27 int tor_digest_is_zero(const char *digest);
28 int tor_digest256_is_zero(const char *digest);
30 /** Allowable characters in a hexadecimal string. */
31 #define HEX_CHARACTERS "0123456789ABCDEFabcdef"
32 void tor_strlower(char *s);
33 void tor_strupper(char *s);
34 void tor_strreplacechar(char *s, char find, char replacement);
35 int tor_strisprint(const char *s);
36 int tor_strisnonupper(const char *s);
37 int tor_strisspace(const char *s);
38 int strcmp_opt(const char *s1, const char *s2);
39 int strcmpstart(const char *s1, const char *s2);
40 int strcasecmpstart(const char *s1, const char *s2);
41 int strcmpend(const char *s1, const char *s2);
42 int strcasecmpend(const char *s1, const char *s2);
43 int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix);
45 void tor_strstrip(char *s, const char *strip);
47 const char *eat_whitespace(const char *s);
48 const char *eat_whitespace_eos(const char *s, const char *eos);
49 const char *eat_whitespace_no_nl(const char *s);
50 const char *eat_whitespace_eos_no_nl(const char *s, const char *eos);
51 const char *find_whitespace(const char *s);
52 const char *find_whitespace_eos(const char *s, const char *eos);
53 const char *find_str_at_start_of_line(const char *haystack,
54 const char *needle);
56 int string_is_C_identifier(const char *string);
58 int string_is_utf8(const char *str, size_t len);
59 int string_is_utf8_no_bom(const char *str, size_t len);
61 #endif /* !defined(TOR_UTIL_STRING_H) */