tor  0.4.2.0-alpha-dev
util_string.h
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-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
11 #ifndef TOR_UTIL_STRING_H
12 #define TOR_UTIL_STRING_H
13 
14 #include "orconfig.h"
15 #include "lib/cc/compat_compiler.h"
16 
17 #include <stddef.h>
18 
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)
26 
27 int tor_digest_is_zero(const char *digest);
28 int tor_digest256_is_zero(const char *digest);
29 
31 #define HEX_CHARACTERS "0123456789ABCDEFabcdef"
32 void tor_strlower(char *s);
33 void tor_strupper(char *s);
34 int tor_strisprint(const char *s);
35 int tor_strisnonupper(const char *s);
36 int tor_strisspace(const char *s);
37 int strcmp_opt(const char *s1, const char *s2);
38 int strcmpstart(const char *s1, const char *s2);
39 int strcasecmpstart(const char *s1, const char *s2);
40 int strcmpend(const char *s1, const char *s2);
41 int strcasecmpend(const char *s1, const char *s2);
42 int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix);
43 
44 void tor_strstrip(char *s, const char *strip);
45 
46 const char *eat_whitespace(const char *s);
47 const char *eat_whitespace_eos(const char *s, const char *eos);
48 const char *eat_whitespace_no_nl(const char *s);
49 const char *eat_whitespace_eos_no_nl(const char *s, const char *eos);
50 const char *find_whitespace(const char *s);
51 const char *find_whitespace_eos(const char *s, const char *eos);
52 const char *find_str_at_start_of_line(const char *haystack,
53  const char *needle);
54 
55 int string_is_C_identifier(const char *string);
56 
57 int string_is_utf8(const char *str, size_t len);
58 int string_is_utf8_no_bom(const char *str, size_t len);
59 
60 #endif /* !defined(TOR_UTIL_STRING_H) */
const char * find_whitespace(const char *s)
Definition: util_string.c:344
const char * eat_whitespace_eos(const char *s, const char *eos)
Definition: util_string.c:295
int strcasecmpend(const char *s1, const char *s2)
Definition: util_string.c:255
int tor_digest256_is_zero(const char *digest)
Definition: util_string.c:103
int string_is_C_identifier(const char *string)
Definition: util_string.c:414
int tor_strisspace(const char *s)
Definition: util_string.c:175
int fast_mem_is_zero(const char *mem, size_t len)
Definition: util_string.c:74
const char * find_whitespace_eos(const char *s, const char *eos)
Definition: util_string.c:366
const char * eat_whitespace(const char *s)
Definition: util_string.c:268
const void * tor_memmem(const void *haystack, size_t hlen, const void *needle, size_t nlen)
Definition: util_string.c:29
Utility macros to handle different features and behavior in different compilers.
int strcmpstart(const char *s1, const char *s2)
Definition: util_string.c:206
int tor_strisnonupper(const char *s)
Definition: util_string.c:162
const char * eat_whitespace_eos_no_nl(const char *s, const char *eos)
Definition: util_string.c:333
const char * find_str_at_start_of_line(const char *haystack, const char *needle)
Definition: util_string.c:391
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:229
int strcmpend(const char *s1, const char *s2)
Definition: util_string.c:242
void tor_strlower(char *s)
Definition: util_string.c:127
int tor_digest_is_zero(const char *digest)
Definition: util_string.c:96
int strcmp_opt(const char *s1, const char *s2)
Definition: util_string.c:188
const char * eat_whitespace_no_nl(const char *s)
Definition: util_string.c:323
int string_is_utf8(const char *str, size_t len)
Definition: util_string.c:507
void tor_strstrip(char *s, const char *strip)
Definition: util_string.c:111
int string_is_utf8_no_bom(const char *str, size_t len)
Definition: util_string.c:531
int strcasecmpstart(const char *s1, const char *s2)
Definition: util_string.c:216
int tor_strisprint(const char *s)
Definition: util_string.c:149