Tor 0.4.9.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-2021, The Tor Project, Inc. */
4/* See LICENSE for licensing information */
5
6/**
7 * \file util_string.h
8 * \brief Header for util_string.c
9 **/
10
11#ifndef TOR_UTIL_STRING_H
12#define TOR_UTIL_STRING_H
13
14#include "orconfig.h"
16
17#include <stddef.h>
18
19const void *tor_memmem(const void *haystack, size_t hlen, const void *needle,
20 size_t nlen);
21const void *tor_memstr(const void *haystack, size_t hlen,
22 const char *needle);
23int 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
27int tor_digest_is_zero(const char *digest);
28int tor_digest256_is_zero(const char *digest);
29
30/** Allowable characters in a hexadecimal string. */
31#define HEX_CHARACTERS "0123456789ABCDEFabcdef"
32void tor_strlower(char *s);
33void tor_strupper(char *s);
34void tor_strreplacechar(char *s, char find, char replacement);
35int tor_strisprint(const char *s);
36int tor_strisnonupper(const char *s);
37int tor_strisspace(const char *s);
38int strcmp_opt(const char *s1, const char *s2);
39int strcmpstart(const char *s1, const char *s2);
40int strcasecmpstart(const char *s1, const char *s2);
41int strcmpend(const char *s1, const char *s2);
42int strcasecmpend(const char *s1, const char *s2);
43int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix);
44
45void tor_strstrip(char *s, const char *strip);
46
47const char *eat_whitespace(const char *s);
48const char *eat_whitespace_eos(const char *s, const char *eos);
49const char *eat_whitespace_no_nl(const char *s);
50const char *eat_whitespace_eos_no_nl(const char *s, const char *eos);
51const char *find_whitespace(const char *s);
52const char *find_whitespace_eos(const char *s, const char *eos);
53const char *find_str_at_start_of_line(const char *haystack,
54 const char *needle);
55
56int string_is_C_identifier(const char *string);
57
58int string_is_utf8(const char *str, size_t len);
59int string_is_utf8_no_bom(const char *str, size_t len);
60
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:186
const char * find_whitespace_eos(const char *s, const char *eos)
Definition: util_string.c:377
int strcasecmpstart(const char *s1, const char *s2)
Definition: util_string.c:227
void tor_strlower(char *s)
Definition: util_string.c:129
int strcmpstart(const char *s1, const char *s2)
Definition: util_string.c:217
int strcmpend(const char *s1, const char *s2)
Definition: util_string.c:253
const char * find_whitespace(const char *s)
Definition: util_string.c:355
void tor_strupper(char *s)
Definition: util_string.c:140
const char * eat_whitespace_eos(const char *s, const char *eos)
Definition: util_string.c:306
int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix)
Definition: util_string.c:240
int strcasecmpend(const char *s1, const char *s2)
Definition: util_string.c:266
int tor_strisprint(const char *s)
Definition: util_string.c:160
int strcmp_opt(const char *s1, const char *s2)
Definition: util_string.c:199
int string_is_utf8_no_bom(const char *str, size_t len)
Definition: util_string.c:559
int tor_digest256_is_zero(const char *digest)
Definition: util_string.c:105
int fast_mem_is_zero(const char *mem, size_t len)
Definition: util_string.c:76
int string_is_C_identifier(const char *string)
Definition: util_string.c:425
void tor_strstrip(char *s, const char *strip)
Definition: util_string.c:113
const char * find_str_at_start_of_line(const char *haystack, const char *needle)
Definition: util_string.c:402
const char * eat_whitespace(const char *s)
Definition: util_string.c:279
const void * tor_memmem(const void *haystack, size_t hlen, const void *needle, size_t nlen)
Definition: util_string.c:29
const char * eat_whitespace_eos_no_nl(const char *s, const char *eos)
Definition: util_string.c:344
const char * eat_whitespace_no_nl(const char *s)
Definition: util_string.c:334
int tor_strisnonupper(const char *s)
Definition: util_string.c:173
int string_is_utf8(const char *str, size_t len)
Definition: util_string.c:518
int tor_digest_is_zero(const char *digest)
Definition: util_string.c:98
void tor_strreplacechar(char *s, char find, char replacement)
Definition: util_string.c:150