2018-06-22 15:23:30 +02:00
|
|
|
/* Copyright (c) 2003-2004, Roger Dingledine
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2019-01-16 18:33:22 +01:00
|
|
|
* Copyright (c) 2007-2019, The Tor Project, Inc. */
|
2018-06-22 15:23:30 +02:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
2018-07-10 18:22:01 +02:00
|
|
|
/**
|
|
|
|
* \file util_string.h
|
|
|
|
* \brief Header for util_string.c
|
|
|
|
**/
|
|
|
|
|
2018-06-22 15:23:30 +02:00
|
|
|
#ifndef TOR_UTIL_STRING_H
|
|
|
|
#define TOR_UTIL_STRING_H
|
|
|
|
|
|
|
|
#include "orconfig.h"
|
|
|
|
#include "lib/cc/compat_compiler.h"
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2018-06-27 21:36:42 +02:00
|
|
|
const void *tor_memmem(const void *haystack, size_t hlen, const void *needle,
|
2018-07-03 11:33:09 +02:00
|
|
|
size_t nlen);
|
2018-06-27 21:36:42 +02:00
|
|
|
const void *tor_memstr(const void *haystack, size_t hlen,
|
2018-07-03 11:33:09 +02:00
|
|
|
const char *needle);
|
2019-04-30 20:43:35 +02:00
|
|
|
int fast_mem_is_zero(const char *mem, size_t len);
|
|
|
|
#define fast_digest_is_zero(d) fast_mem_is_zero((d), DIGEST_LEN)
|
|
|
|
#define fast_digetst256_is_zero(d) fast_mem_is_zero((d), DIGEST256_LEN)
|
|
|
|
|
2018-06-27 21:36:42 +02:00
|
|
|
int tor_digest_is_zero(const char *digest);
|
|
|
|
int tor_digest256_is_zero(const char *digest);
|
|
|
|
|
2018-06-22 15:23:30 +02:00
|
|
|
/** Allowable characters in a hexadecimal string. */
|
|
|
|
#define HEX_CHARACTERS "0123456789ABCDEFabcdef"
|
2018-07-03 11:33:09 +02:00
|
|
|
void tor_strlower(char *s);
|
|
|
|
void tor_strupper(char *s);
|
|
|
|
int tor_strisprint(const char *s);
|
|
|
|
int tor_strisnonupper(const char *s);
|
2018-06-22 15:23:30 +02:00
|
|
|
int tor_strisspace(const char *s);
|
|
|
|
int strcmp_opt(const char *s1, const char *s2);
|
2018-07-03 11:33:09 +02:00
|
|
|
int strcmpstart(const char *s1, const char *s2);
|
|
|
|
int strcasecmpstart(const char *s1, const char *s2);
|
|
|
|
int strcmpend(const char *s1, const char *s2);
|
|
|
|
int strcasecmpend(const char *s1, const char *s2);
|
2018-06-22 15:23:30 +02:00
|
|
|
int fast_memcmpstart(const void *mem, size_t memlen, const char *prefix);
|
|
|
|
|
2018-07-03 11:33:09 +02:00
|
|
|
void tor_strstrip(char *s, const char *strip);
|
2018-06-22 15:23:30 +02:00
|
|
|
|
|
|
|
const char *eat_whitespace(const char *s);
|
|
|
|
const char *eat_whitespace_eos(const char *s, const char *eos);
|
|
|
|
const char *eat_whitespace_no_nl(const char *s);
|
|
|
|
const char *eat_whitespace_eos_no_nl(const char *s, const char *eos);
|
|
|
|
const char *find_whitespace(const char *s);
|
|
|
|
const char *find_whitespace_eos(const char *s, const char *eos);
|
|
|
|
const char *find_str_at_start_of_line(const char *haystack,
|
|
|
|
const char *needle);
|
|
|
|
|
|
|
|
int string_is_C_identifier(const char *string);
|
|
|
|
|
2018-08-29 05:22:30 +02:00
|
|
|
int string_is_utf8(const char *str, size_t len);
|
2018-08-29 15:32:52 +02:00
|
|
|
int string_is_utf8_no_bom(const char *str, size_t len);
|
2018-08-29 05:22:30 +02:00
|
|
|
|
2018-06-22 15:23:30 +02:00
|
|
|
#endif /* !defined(TOR_UTIL_STRING_H) */
|