Strings and string handling functions, including malloc and string tokenizing. More...
Data Structures | |
struct | GNUNET_STRINGS_PortPolicy |
struct | GNUNET_STRINGS_IPv4NetworkPolicy |
IPV4 network in CIDR notation. More... | |
struct | GNUNET_STRINGS_IPv6NetworkPolicy |
network in CIDR notation for IPV6. More... | |
Enumerations | |
enum | GNUNET_STRINGS_FilenameCheck { GNUNET_STRINGS_CHECK_EXISTS = 0x00000001 , GNUNET_STRINGS_CHECK_IS_DIRECTORY = 0x00000002 , GNUNET_STRINGS_CHECK_IS_LINK = 0x00000004 , GNUNET_STRINGS_CHECK_IS_ABSOLUTE = 0x00000008 } |
Flags for what we should check a file for. More... | |
Functions | |
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... | |
char * | GNUNET_STRINGS_byte_size_fancy (unsigned long long size) |
Convert a given filesize into a fancy human-readable format. 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_utf8_normalize (const char *input) |
Normalize the utf-8 input string to NFC. 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... | |
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... | |
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... | |
const char * | GNUNET_STRINGS_get_short_name (const char *filename) |
"man basename" Returns a pointer to a part of filename (allocates nothing)! 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... | |
size_t | GNUNET_STRINGS_base64_encode (const void *in, size_t len, char **output) |
Encode into Base64. More... | |
size_t | GNUNET_STRINGS_urlencode (const char *data, size_t len, char **out) |
url/percent encode (RFC3986). 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 **output) |
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... | |
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, uint16_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, uint16_t addrlen, struct sockaddr_in *r_buf) |
Tries to convert zt_addr string to an IPv4 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... | |
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... | |
enum GNUNET_GenericReturnValue | GNUNET_STRINGS_get_utf8_args (int argc, char *const *argv, int *u8argc, char *const **u8argv) |
Returns utf-8 encoded arguments. More... | |
size_t | GNUNET_strlcpy (char *dst, const char *src, size_t n) |
Like strlcpy but portable. 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... | |
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... | |
Strings and string handling functions, including malloc and string tokenizing.
Flags for what we should check a file for.
Definition at line 530 of file gnunet_strings_lib.h.
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.
fancy_size | human readable string (e.g. 1 MB) |
size | set to the size in bytes |
Definition at line 138 of file strings.c.
Referenced by GNUNET_ATS_solvers_load_quotas(), parse_quota(), and print_quotas().
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.
fancy_time | human readable string (e.g. 1 minute) |
rtime | set to the relative time |
Definition at line 138 of file strings.c.
Referenced by create_did_ego_lockup_cb(), and parse_expiration().
char* GNUNET_STRINGS_byte_size_fancy | ( | unsigned long long | size | ) |
Convert a given filesize into a fancy human-readable format.
size | number of bytes |
Definition at line 106 of file strings.c.
References GNUNET_malloc, GNUNET_snprintf(), ret, and size.
Referenced by progress_cb(), and publish_inspector().
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.
input | input string |
len | number of bytes in input |
input_charset | character set used for input |
output_charset | desired character set for the return value |
Definition at line 343 of file strings.c.
References _, GNUNET_ERROR_TYPE_WARNING, GNUNET_malloc, GNUNET_memcpy, len, LOG, LOG_STRERROR, and ret.
Referenced by GNUNET_STRINGS_from_utf8(), and GNUNET_STRINGS_to_utf8().
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.
input | the input string (not necessarily 0-terminated) |
len | the number of bytes in the input |
charset | character set to convert from |
Definition at line 405 of file strings.c.
References GNUNET_STRINGS_conv(), and len.
char* GNUNET_STRINGS_utf8_normalize | ( | const char * | input | ) |
Normalize the utf-8 input string to NFC.
input | input string |
Definition at line 429 of file strings.c.
References GNUNET_malloc, GNUNET_memcpy, and len.
Referenced by GNUNET_GNSRECORD_label_check().
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.
input | the input string (not necessarily 0-terminated) |
len | the number of bytes in the input |
charset | character set to convert to |
Definition at line 417 of file strings.c.
References GNUNET_STRINGS_conv(), and len.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_utf8_tolower | ( | const char * | input, |
char * | output | ||
) |
Convert the utf-8 input string to lower case.
Output needs to be allocated appropriately.
input | input string |
output | output buffer |
Definition at line 429 of file strings.c.
Referenced by ego_create(), GNUNET_RECLAIM_attribute_new(), GNUNET_RECLAIM_credential_new(), handle_collect(), handle_create_message(), handle_delete_message(), handle_rename_message(), handle_verify(), and header_iterator().
enum GNUNET_GenericReturnValue GNUNET_STRINGS_utf8_toupper | ( | const char * | input, |
char * | output | ||
) |
Convert the utf-8 input string to upper case.
Output needs to be allocated appropriately.
input | input string |
output | output buffer |
Definition at line 429 of file strings.c.
Referenced by client_configure_plugin(), GNUNET_HOSTLIST_client_start(), and load_op_add_address().
char* GNUNET_STRINGS_filename_expand | ( | const char * | fil | ) |
Complete filename (a la shell) from abbrevition.
fil | the name of the file, may contain ~/ or be relative to the current directory |
Definition at line 494 of file strings.c.
References _, DIR_SEPARATOR, DIR_SEPARATOR_STR, getenv(), GNUNET_asprintf(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_malloc, GNUNET_strdup, len, LOG, and LOG_STRERROR.
Referenced by check_client_index_start(), GNUNET_DISK_directory_scan(), GNUNET_DISK_file_close(), GNUNET_FS_directory_scan_start(), GNUNET_FS_make_file_reader_context_(), GNUNET_log_setup(), handle_client_index_start(), hash_for_index_cb(), and print_filename_option().
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).
If "buffer" is NULL, only compute the amount of space required (sum of "strlen(arg)+1").
Unlike using "snprintf" with "%s", this function will add 0-terminators after each string. The "GNUNET_string_buffer_tokenize" function can be used to parse the buffer back into individual strings.
buffer | the buffer to fill with strings, can be NULL in which case only the necessary amount of space will be calculated |
size | number of bytes available in buffer |
count | number of strings that follow |
... | count 0-terminated strings to copy to buffer |
Definition at line 44 of file strings.c.
References GNUNET_assert, GNUNET_memcpy, and size.
Referenced by save(), transmit(), transmit_get(), transmit_set(), and transmit_watch().
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.
buffer | the buffer to parse |
size | size of the buffer |
count | number of strings to locate |
... | pointers to where to store the strings |
Definition at line 72 of file strings.c.
Referenced by check_get(), check_set(), check_statistics_value(), check_watch(), handle_get(), handle_set(), handle_statistics_value(), handle_watch(), and process_sblock().
const char* GNUNET_STRINGS_get_short_name | ( | const char * | filename | ) |
"man basename" Returns a pointer to a part of filename (allocates nothing)!
filename | filename to extract basename from |
Definition at line 639 of file strings.c.
References DIR_SEPARATOR_STR, and filename.
Referenced by expand_tree(), iter_check_config(), and iter_testbed_path().
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.
Does not append 0-terminator, but returns a pointer to the place where it should be placed, if needed.
data | data to encode |
size | size of data (in bytes) |
out | buffer to fill |
out_size | size of the buffer. Must be large enough to hold ((size*8) + (((size*8) % 5) > 0 ? 5 - ((size*8) % 5) : 0)) / 5 |
32 characters for encoding
Definition at line 708 of file strings.c.
References data, GNUNET_assert, GNUNET_break, size, and SIZE_MAX.
Referenced by auth_key_to_string(), channel_to_sh(), GNUNET_buffer_write_data_encoded(), GNUNET_CRYPTO_ecdsa_private_key_to_string(), GNUNET_CRYPTO_ecdsa_public_key_to_string(), GNUNET_CRYPTO_eddsa_private_key_to_string(), GNUNET_CRYPTO_eddsa_public_key_to_string(), GNUNET_CRYPTO_hash_from_string2(), GNUNET_GNSRECORD_record_get_expiration_time(), GNUNET_sh2s(), GNUNET_STRINGS_check_filename(), GNUNET_uuid2s(), output_message(), print_examples_ecdh(), run_edkey(), run_pkey(), run_with_key(), secret_ready_cb(), uri_loc_to_string(), and uri_sks_to_string().
char* GNUNET_STRINGS_data_to_string_alloc | ( | const void * | buf, |
size_t | size | ||
) |
Return the base32crockford encoding of the given buffer.
The returned string will be freshly allocated, and must be free'd with GNUNET_free().
buf | buffer with data |
size | size of the buffer buf |
Definition at line 763 of file strings.c.
Referenced by attr_collect(), attr_store_task(), conversation_value_to_string(), cred_collect(), cred_iter_cb(), cred_store_task(), d2j(), generate_id_token_body(), generate_userinfo_json(), GNUNET_b2s(), GNUNET_HELLO_builder_add_address(), GNUNET_IDENTITY_private_key_from_string(), GNUNET_IDENTITY_public_key_to_string(), GNUNET_JSON_from_data(), handle_attribute_delete_message(), handle_credential_delete_message(), issue_ticket(), iter_cb(), iterate_save_rooms(), lookup_authz_cb(), main(), messenger_value_to_string(), move_attr_finished(), move_attrs(), oidc_ticket_issue_cb(), process_attrs(), process_record(), purge_attributes(), RECLAIM_TICKETS_consume(), RECLAIM_TICKETS_revoke(), run(), rvk_move_attr_cb(), save_member(), save_operation(), setup_job_headers(), ticket_collect(), ticket_issue_cb(), ticket_iter(), value_to_string(), and write_encrypted_message().
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.
out_size must match exactly the size of the data before it was encoded.
enc | the encoding |
enclen | number of characters in enc (without 0-terminator, which can be missing) |
out | location where to store the decoded data |
out_size | size of the output buffer out |
Definition at line 763 of file strings.c.
Referenced by check_authorization(), conversation_string_to_value(), delete_attribute_cont(), delete_credential_cont(), ego_create(), expect_data_dynamic(), expect_data_fixed(), GNUNET_HELLO_builder_from_url(), GNUNET_HELLO_parse_uri(), lookup_redirect_uri_result(), main(), messenger_string_to_value(), parse_attr(), parse_credential(), parse_ticket(), read_service_conf(), run(), start_process(), string_to_value(), uri_loc_parse(), and uri_sks_parse().
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.
out_size will be determined from enc and out will be allocated to be large enough.
enc | the encoding | |
enclen | number of characters in enc (without 0-terminator, which can be missing) | |
[out] | out | location where to allocate and store the decoded data |
[out] | out_size | set to the size of the output buffer out |
Definition at line 763 of file strings.c.
Referenced by GNUNET_PQ_event_do_poll(), and read_encrypted_message().
size_t GNUNET_STRINGS_base64_encode | ( | const void * | in, |
size_t | len, | ||
char ** | output | ||
) |
Encode into Base64.
data | the data to encode |
len | the length of the input |
output | where to write the output (*output should be NULL, is allocated) |
Definition at line 1607 of file strings.c.
References cvt, data, FILLCHAR, GNUNET_assert, GNUNET_malloc, consensus-simulation::int, len, ret, and SIZE_MAX.
Referenced by api_send(), dns_value_to_string(), GNUNET_ABD_delegate_to_string(), GNUNET_HELLO_sign_address(), GNUNET_JSON_from_data64(), GNUNET_STRINGS_base64url_encode(), OIDC_access_token_new(), pabc_create_presentation(), and store_and_free_entries().
size_t GNUNET_STRINGS_urlencode | ( | const char * | data, |
size_t | len, | ||
char ** | out | ||
) |
url/percent encode (RFC3986).
data | the data to decode |
len | the length of the input |
out | where to write the output (*out should be NULL, is allocated) |
Definition at line 1850 of file strings.c.
References buf, data, GNUNET_break, GNUNET_buffer_clear(), GNUNET_buffer_reap_str(), GNUNET_buffer_write(), and GNUNET_buffer_write_fstr().
Referenced by GNUNET_HELLO_builder_add_address(), and login_redirect().
size_t GNUNET_STRINGS_base64url_encode | ( | const void * | in, |
size_t | len, | ||
char ** | output | ||
) |
Encode into Base64url.
RFC7515
in | the data to encode |
len | the length of the input |
output | where to write the output (*output should be NULL, is allocated) |
Definition at line 1656 of file strings.c.
References enc, GNUNET_STRINGS_base64_encode(), and len.
Referenced by check_code_challenge(), DID_key_convert_gnunet_to_multibase_base64(), ego_sign_data_cb(), and OIDC_generate_id_token_hmac().
size_t GNUNET_STRINGS_base64_decode | ( | const char * | data, |
size_t | len, | ||
void ** | output | ||
) |
Decode from Base64.
data | the data to encode | |
len | the length of the input | |
[out] | output | where to write the output (*output should be NULL, is allocated) |
Definition at line 1695 of file strings.c.
References CHECK_CRLF, cvtfind, data, END, FILLCHAR, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_malloc, len, ret, and SIZE_MAX.
Referenced by database_setup(), dns_string_to_value(), GNUNET_ABD_delegate_from_string(), GNUNET_HELLO_extract_address(), GNUNET_STRINGS_base64url_decode(), listenAndDistribute(), parse_credentials_basic_auth(), and parse_jwt().
size_t GNUNET_STRINGS_base64url_decode | ( | const char * | data, |
size_t | len, | ||
void ** | out | ||
) |
Decode from Base64url.
RFC7515
data | the data to decode |
len | the length of the input |
out | where to write the output (*out should be NULL, is allocated) |
Definition at line 1760 of file strings.c.
References data, GNUNET_assert, GNUNET_free, GNUNET_malloc, GNUNET_STRINGS_base64_decode(), len, ret, and SIZE_MAX.
Referenced by jwt_get_issuer(), jwt_parse_attributes(), and OIDC_parse_authz_code().
size_t GNUNET_STRINGS_urldecode | ( | const char * | data, |
size_t | len, | ||
char ** | out | ||
) |
url/percent encode (RFC3986).
data | the data to encode | |
len | the length of the input | |
[out] | out | where to write the output (*output should be NULL, is allocated) |
Definition at line 1806 of file strings.c.
References data, GNUNET_break_op, GNUNET_free, GNUNET_malloc, and len.
Referenced by get_url_parameter_copy(), and GNUNET_HELLO_builder_from_url().
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.
path | path to parse. Must be NULL-terminated. | |
[out] | scheme_part | pointer to a string that represents the URI scheme will be stored. Can be NULL. The string is allocated by the function, and should be freed by GNUNET_free() when it is no longer needed. |
path_part | a pointer to 'const char *' where a pointer to the path part of the URI will be stored. Can be NULL. Points to the same block of memory as path, and thus must not be freed. Might point to '\0', if path part is zero-length. |
Definition at line 763 of file strings.c.
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.
filename | filename to check |
can_be_uri | GNUNET_YES to check for being URI, GNUNET_NO - to assume it's not URI |
r_is_uri | a pointer to an int that is set to GNUNET_YES if 'filename' is URI and to GNUNET_NO otherwise. Can be NULL. If 'can_be_uri' is not GNUNET_YES, *r_is_uri is set to GNUNET_NO. |
r_uri_scheme | a pointer to a char * that is set to a pointer to URI scheme. The string is allocated by the function, and should be freed with GNUNET_free (). Can be NULL. |
Definition at line 763 of file strings.c.
Referenced by GNUNET_OS_check_helper_binary(), and GNUNET_OS_get_libexec_binary_path().
enum GNUNET_GenericReturnValue GNUNET_STRINGS_check_filename | ( | const char * | filename, |
enum GNUNET_STRINGS_FilenameCheck | checks | ||
) |
Perform checks on filename.
FIXME: some duplication with "GNUNET_DISK_"-APIs. We should unify those.
filename | file to check |
checks | checks to perform |
Definition at line 763 of file strings.c.
References buf, end, GNUNET_free, GNUNET_malloc, GNUNET_STRINGS_data_to_string(), len, and size.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_to_address_ipv6 | ( | const char * | zt_addr, |
uint16_t | addrlen, | ||
struct sockaddr_in6 * | r_buf | ||
) |
Tries to convert zt_addr string to an IPv6 address.
The string is expected to have the format "[ABCD::01]:80".
zt_addr | 0-terminated string. May be mangled by the function. |
addrlen | length of zt_addr (not counting 0-terminator). |
r_buf | a buffer to fill. Initially gets filled with zeroes, then its sin6_port, sin6_family and sin6_addr are set appropriately. |
Definition at line 763 of file strings.c.
Referenced by GNUNET_STRINGS_parse_socket_addr().
enum GNUNET_GenericReturnValue GNUNET_STRINGS_to_address_ipv4 | ( | const char * | zt_addr, |
uint16_t | addrlen, | ||
struct sockaddr_in * | r_buf | ||
) |
Tries to convert zt_addr string to an IPv4 address.
The string is expected to have the format "1.2.3.4:80".
zt_addr | 0-terminated string. May be mangled by the function. |
addrlen | length of zt_addr (not counting 0-terminator). |
r_buf | a buffer to fill. |
Definition at line 763 of file strings.c.
Referenced by GNUNET_STRINGS_parse_socket_addr().
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
.
addr | the address | |
[out] | af | set to the parsed address family (e.g. AF_INET) |
[out] | sa | set to the parsed address |
Definition at line 1149 of file strings.c.
References GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_to_address_ipv4(), and GNUNET_STRINGS_to_address_ipv6().
Referenced by run().
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.
Will automatically decide whether to treat 'addr' as v4 or v6 address.
addr | a string, may not be 0-terminated. |
addrlen | number of bytes in addr (if addr is 0-terminated, 0-terminator should not be counted towards addrlen). |
r_buf | a buffer to fill. |
Definition at line 763 of file strings.c.
Referenced by http_common_socket_from_address(), tcp_plugin_string_to_address(), and udp_string_to_address().
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args | ( | int | argc, |
char *const * | argv, | ||
int * | u8argc, | ||
char *const ** | u8argv | ||
) |
Returns utf-8 encoded arguments.
Does nothing (returns a copy of argc and argv) on any platform other than W32. Returned argv has u8argv[u8argc] == NULL
. Returned argv is a single memory block, and can be freed with a single GNUNET_free() call.
argc | argc (as given by main()) |
argv | argv (as given by main()) |
u8argc | a location to store new argc in (though it's th same as argc) |
u8argv | a location to store new argv in |
Definition at line 1200 of file strings.c.
Referenced by main().
size_t GNUNET_strlcpy | ( | char * | dst, |
const char * | src, | ||
size_t | n | ||
) |
Like strlcpy but portable.
The given string src is copied in full length (until its null byte). The destination buffer is guaranteed to be null-terminated.
to a destination buffer and ensures that the destination string is null-terminated.
dst | destination of the copy |
src | source of the copy, must be null-terminated |
n | the length of the string to copy, including its terminating null byte |
Definition at line 138 of file strings.c.
Referenced by add_unixpath(), create_keys(), GCP_2s(), GNUNET_CONNECTION_create_from_connect_to_unixpath(), GNUNET_i2s(), GNUNET_i2s2(), GNUNET_TESTBED_hosts_load_from_file(), handle_add_host(), handle_remote_overlay_connect(), mylog(), regex_split(), tokenizer_cb(), and try_unixpath().
char* GNUNET_STRINGS_get_suffix_from_binary_name | ( | const char * | argv0 | ) |
Sometimes we use the binary name to determine which specific test to run.
In those cases, the string after the last "_" in 'argv[0]' specifies a string that determines the configuration file or plugin to use.
This function returns the respective substring, taking care of issues such as binaries ending in '.exe' on W32.
argv0 | the name of the binary |
Definition at line 1976 of file strings.c.
References GNUNET_strdup, GNUNET_strndup, and ret.
struct GNUNET_STRINGS_IPv4NetworkPolicy* GNUNET_STRINGS_parse_ipv4_policy | ( | const char * | routeListX | ) |
Parse an IPv4 network policy.
The argument specifies a list of subnets. The format is (network[/netmask][:[!]SPORT-DPORT];)*
(no whitespace, must be terminated with a semicolon). The network must be given in dotted-decimal notation. The netmask can be given in CIDR notation (/16) or in dotted-decimal (/255.255.0.0).
routeListX | a string specifying the IPv4 subnets |
Definition at line 1290 of file strings.c.
References _, dummy, end, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_strdup, len, LOG, GNUNET_STRINGS_IPv4NetworkPolicy::netmask, parse_port_policy(), GNUNET_STRINGS_IPv4NetworkPolicy::pp, and result.
Referenced by GNUNET_TUN_ipv4policy2regex(), and process_acl4().
struct GNUNET_STRINGS_IPv6NetworkPolicy* GNUNET_STRINGS_parse_ipv6_policy | ( | const char * | routeListX | ) |
Parse an IPv6 network policy.
The argument specifies a list of subnets. The format is (network[/netmask[:[!]SPORT[-DPORT]]];)*
(no whitespace, must be terminated with a semicolon). The network must be given in colon-hex notation. The netmask must be given in CIDR notation (/16) or can be omitted to specify a single host. Note that the netmask is mandatory if ports are specified.
routeListX | a string specifying the policy |
Definition at line 1471 of file strings.c.
References _, dummy, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_strdup, len, LOG, LOG_STRERROR, GNUNET_STRINGS_IPv6NetworkPolicy::netmask, GNUNET_STRINGS_IPv6NetworkPolicy::network, parse_port_policy(), GNUNET_STRINGS_IPv6NetworkPolicy::pp, result, ret, save(), and start.
Referenced by GNUNET_TUN_ipv6policy2regex(), and process_acl6().