Go to the documentation of this file.
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) */
Utility macros to handle different features and behavior in different compilers.
int tor_strisspace(const char *s)
Definition: util_string.c:184
const char * eat_whitespace_eos_no_nl(const char *s, const char *eos)
Definition: util_string.c:342
int strcasecmpstart(const char *s1, const char *s2)
Definition: util_string.c:225
void tor_strlower(char *s)
Definition: util_string.c:127
int strcmpstart(const char *s1, const char *s2)
Definition: util_string.c:215
int strcmpend(const char *s1, const char *s2)
Definition: util_string.c:251
const char * find_whitespace_eos(const char *s, const char *eos)
Definition: util_string.c:375
const char * find_whitespace(const char *s)
Definition: util_string.c:353
const void * tor_memmem(const void *haystack, size_t hlen, const void *needle, size_t nlen)
Definition: util_string.c:29
void tor_strupper(char *s)
Definition: util_string.c:138
int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix)
Definition: util_string.c:238
int strcasecmpend(const char *s1, const char *s2)
Definition: util_string.c:264
int tor_strisprint(const char *s)
Definition: util_string.c:158
const char * eat_whitespace_eos(const char *s, const char *eos)
Definition: util_string.c:304
int strcmp_opt(const char *s1, const char *s2)
Definition: util_string.c:197
const char * eat_whitespace(const char *s)
Definition: util_string.c:277
int string_is_utf8_no_bom(const char *str, size_t len)
Definition: util_string.c:557
int tor_digest256_is_zero(const char *digest)
Definition: util_string.c:103
int fast_mem_is_zero(const char *mem, size_t len)
Definition: util_string.c:74
int string_is_C_identifier(const char *string)
Definition: util_string.c:423
void tor_strstrip(char *s, const char *strip)
Definition: util_string.c:111
const char * eat_whitespace_no_nl(const char *s)
Definition: util_string.c:332
int tor_strisnonupper(const char *s)
Definition: util_string.c:171
const char * find_str_at_start_of_line(const char *haystack, const char *needle)
Definition: util_string.c:400
int string_is_utf8(const char *str, size_t len)
Definition: util_string.c:516
int tor_digest_is_zero(const char *digest)
Definition: util_string.c:96
void tor_strreplacechar(char *s, char find, char replacement)
Definition: util_string.c:148