string functions More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include <unicase.h>
#include <unistr.h>
#include <uniconv.h>
Go to the source code of this file.
Data Structures | |
struct | ConversionTable |
Unit conversion table entry for 'convert_with_table'. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "util-strings", __VA_ARGS__) |
#define | LOG_STRERROR(kind, syscall) GNUNET_log_from_strerror (kind, "util-strings", syscall) |
#define | FILLCHAR '=' |
******************** Base64 encoding More... | |
#define | cvtfind(a) |
#define | CHECK_CRLF |
Functions | |
size_t | GNUNET_STRINGS_buffer_fill (char *buffer, size_t size, unsigned int count,...) |
Fill a buffer of the given size with count 0-terminated strings (given as varargs). More... | |
unsigned int | GNUNET_STRINGS_buffer_tokenize (const char *buffer, size_t size, unsigned int count,...) |
Given a buffer of a given size, find "count" 0-terminated strings in the buffer and assign the count (varargs) of type "const char**" to the locations of the respective strings in the buffer. More... | |
char * | GNUNET_STRINGS_byte_size_fancy (unsigned long long size) |
Convert a given filesize into a fancy human-readable format. More... | |
size_t | GNUNET_strlcpy (char *dst, const char *src, size_t n) |
Like strlcpy but portable. More... | |
static enum GNUNET_GenericReturnValue | convert_with_table (const char *input, const struct ConversionTable *table, unsigned long long *output) |
Convert a string of the form "4 X 5 Y" into a numeric value by interpreting "X" and "Y" as units and then multiplying the numbers with the values associated with the respective unit from the conversion table. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size, unsigned long long *size) |
Convert a given fancy human-readable size to bytes. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_time, struct GNUNET_TIME_Relative *rtime) |
Convert a given fancy human-readable time to our internal representation. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, struct GNUNET_TIME_Absolute *atime) |
Convert a given fancy human-readable time to our internal representation. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_fancy_time_to_timestamp (const char *fancy_time, struct GNUNET_TIME_Timestamp *atime) |
Convert a given fancy human-readable time to our internal representation. More... | |
char * | GNUNET_STRINGS_conv (const char *input, size_t len, const char *input_charset, const char *output_charset) |
Convert the len characters long character sequence given in input that is in the given input charset to a string in given output charset. More... | |
char * | GNUNET_STRINGS_to_utf8 (const char *input, size_t len, const char *charset) |
Convert the len characters long character sequence given in input that is in the given charset to UTF-8. More... | |
char * | GNUNET_STRINGS_from_utf8 (const char *input, size_t len, const char *charset) |
Convert the len bytes-long UTF-8 string given in input to the given charset. More... | |
char * | GNUNET_STRINGS_utf8_normalize (const char *input) |
Normalize the utf-8 input string to NFC. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_utf8_tolower (const char *input, char *output) |
Convert the utf-8 input string to lower case. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_utf8_toupper (const char *input, char *output) |
Convert the utf-8 input string to upper case. More... | |
char * | GNUNET_STRINGS_filename_expand (const char *fil) |
Complete filename (a la shell) from abbrevition. More... | |
const char * | GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta, int do_round) |
Give relative time in human-readable fancy format. More... | |
const char * | GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t) |
Like asctime , except for GNUnet time. More... | |
const char * | GNUNET_STRINGS_get_short_name (const char *filename) |
"man basename" Returns a pointer to a part of filename (allocates nothing)! More... | |
static unsigned int | getValue__ (unsigned char a) |
Get the decoded value corresponding to a character according to Crockford Base32 encoding. More... | |
char * | GNUNET_STRINGS_data_to_string (const void *data, size_t size, char *out, size_t out_size) |
Convert binary data to ASCII encoding using CrockfordBase32. More... | |
char * | GNUNET_STRINGS_data_to_string_alloc (const void *buf, size_t size) |
Return the base32crockford encoding of the given buffer. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_string_to_data (const char *enc, size_t enclen, void *out, size_t out_size) |
Convert CrockfordBase32 encoding back to data. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_string_to_data_alloc (const char *enc, size_t enclen, void **out, size_t *out_size) |
Convert CrockfordBase32 encoding back to data. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_parse_uri (const char *path, char **scheme_part, const char **path_part) |
Parse a path that might be an URI. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_path_is_absolute (const char *filename, int can_be_uri, int *r_is_uri, char **r_uri_scheme) |
Check whether filename is absolute or not, and if it's an URI. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_check_filename (const char *filename, enum GNUNET_STRINGS_FilenameCheck checks) |
Perform checks on filename. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr, size_t addrlen, struct sockaddr_in6 *r_buf) |
Tries to convert zt_addr string to an IPv6 address. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr, size_t addrlen, struct sockaddr_in *r_buf) |
Tries to convert zt_addr string to an IPv4 address. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_to_address_ip (const char *addr, uint16_t addrlen, struct sockaddr_storage *r_buf) |
Tries to convert addr string to an IP (v4 or v6) address. More... | |
size_t | GNUNET_STRINGS_parse_socket_addr (const char *addr, uint8_t *af, struct sockaddr **sa) |
Parse an address given as a string into a struct sockaddr . More... | |
static char *const * | _make_continuous_arg_copy (int argc, char *const *argv) |
Makes a copy of argv that consists of a single memory chunk that can be freed with a single call to GNUNET_free();. More... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_get_utf8_args (int argc, char *const *argv, int *u8argc, char *const **u8argv) |
Returns utf-8 encoded arguments. More... | |
static enum GNUNET_GenericReturnValue | parse_port_policy (const char *port_policy, struct GNUNET_STRINGS_PortPolicy *pp) |
Parse the given port policy. More... | |
struct GNUNET_STRINGS_IPv4NetworkPolicy * | GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX) |
Parse an IPv4 network policy. More... | |
struct GNUNET_STRINGS_IPv6NetworkPolicy * | GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX) |
Parse an IPv6 network policy. More... | |
size_t | GNUNET_STRINGS_base64_encode (const void *in, size_t len, char **output) |
Encode into Base64. More... | |
size_t | GNUNET_STRINGS_base64url_encode (const void *in, size_t len, char **output) |
Encode into Base64url. More... | |
size_t | GNUNET_STRINGS_base64_decode (const char *data, size_t len, void **out) |
Decode from Base64. More... | |
size_t | GNUNET_STRINGS_base64url_decode (const char *data, size_t len, void **out) |
Decode from Base64url. More... | |
size_t | GNUNET_STRINGS_urldecode (const char *data, size_t len, char **out) |
url/percent encode (RFC3986). More... | |
size_t | GNUNET_STRINGS_urlencode (size_t len, const char data[static len], char **out) |
url/percent encode (RFC3986). More... | |
char * | GNUNET_STRINGS_get_suffix_from_binary_name (const char *argv0) |
Sometimes we use the binary name to determine which specific test to run. More... | |
Variables | |
static const char * | cvt |
string functions
Definition in file strings.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "util-strings", __VA_ARGS__) |
#define LOG_STRERROR | ( | kind, | |
syscall | |||
) | GNUNET_log_from_strerror (kind, "util-strings", syscall) |
#define FILLCHAR '=' |
#define cvtfind | ( | a | ) |
#define CHECK_CRLF |
|
static |
Convert a string of the form "4 X 5 Y" into a numeric value by interpreting "X" and "Y" as units and then multiplying the numbers with the values associated with the respective unit from the conversion table.
input | input string to parse |
table | table with the conversion of unit names to numbers |
output | where to store the result |
Definition at line 181 of file strings.c.
References GNUNET_free, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, GNUNET_YES, name, ret, and table.
Referenced by GNUNET_STRINGS_fancy_size_to_bytes(), and GNUNET_STRINGS_fancy_time_to_relative().
|
static |
Get the decoded value corresponding to a character according to Crockford Base32 encoding.
a | a character |
Definition at line 659 of file strings.c.
References dec.
Referenced by GNUNET_STRINGS_string_to_data().
|
static |
Makes a copy of argv that consists of a single memory chunk that can be freed with a single call to GNUNET_free();.
Definition at line 1201 of file strings.c.
References GNUNET_assert, GNUNET_malloc, p, and SIZE_MAX.
Referenced by GNUNET_STRINGS_get_utf8_args().
|
static |
Parse the given port policy.
The format is "[!]SPORT[-DPORT]".
port_policy | string to parse |
pp | policy to fill in |
Definition at line 1253 of file strings.c.
References _, GNUNET_STRINGS_PortPolicy::end_port, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_STRINGS_PortPolicy::negate_portrange, and GNUNET_STRINGS_PortPolicy::start_port.
Referenced by GNUNET_STRINGS_parse_ipv4_policy(), and GNUNET_STRINGS_parse_ipv6_policy().
|
static |
Definition at line 1616 of file strings.c.
Referenced by GNUNET_STRINGS_base64_encode().