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 (size_t len, const char data[static 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, 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... | |
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... | |
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 547 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 235 of file strings.c.
References convert_with_table(), size, and table.
Referenced by GNUNET_CONFIGURATION_get_value_size().
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 259 of file strings.c.
References convert_with_table(), GNUNET_OK, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_Relative::rel_value_us, ret, and table.
Referenced by create_did_ego_lockup_cb(), GNUNET_CONFIGURATION_get_value_time(), parse_expiration(), run(), set_relative_time(), and set_timetravel_time().
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 105 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 352 of file strings.c.
References _, GNUNET_ERROR_TYPE_WARNING, GNUNET_malloc, GNUNET_memcpy, 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 414 of file strings.c.
References GNUNET_STRINGS_conv().
char * GNUNET_STRINGS_utf8_normalize | ( | const char * | input | ) |
Normalize the utf-8 input string to NFC.
input | input string |
Definition at line 438 of file strings.c.
References GNUNET_malloc, and GNUNET_memcpy.
Referenced by GNUNET_GNSRECORD_string_normalize().
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 426 of file strings.c.
References GNUNET_STRINGS_conv().
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 459 of file strings.c.
References GNUNET_free, GNUNET_memcpy, GNUNET_OK, and GNUNET_SYSERR.
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 481 of file strings.c.
References GNUNET_free, GNUNET_memcpy, GNUNET_OK, and GNUNET_SYSERR.
Referenced by GNUNET_CRYPTO_hash_from_string2(), and GNUNET_HOSTLIST_client_start().
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 504 of file strings.c.
References _, DIR_SEPARATOR, DIR_SEPARATOR_STR, getenv(), GNUNET_asprintf(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_malloc, GNUNET_strdup, LOG, and LOG_STRERROR.
Referenced by check_client_index_start(), file_test_internal(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_load(), GNUNET_CONFIGURATION_parse(), GNUNET_CONFIGURATION_write(), GNUNET_DISK_directory_create(), GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_directory_scan(), GNUNET_DISK_file_open(), GNUNET_FS_directory_scan_start(), GNUNET_FS_make_file_reader_context_(), GNUNET_log_setup(), handle_client_index_start(), handle_inline(), hash_for_index_cb(), print_filename_option(), and set_filename().
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 43 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 71 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 663 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 732 of file strings.c.
References data, GNUNET_assert, GNUNET_break, size, and SIZE_MAX.
Referenced by auth_key_to_string(), gnunet-chk::encode_data_to_string(), 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_to_enc(), GNUNET_GNSRECORD_z2s(), GNUNET_PQ_event_notify(), GNUNET_sh2s(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_uuid2s(), output_message(), print_examples_ecdh(), run_edkey(), run_pkey(), run_with_key(), sh_to_channel(), 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 787 of file strings.c.
References end, GNUNET_free, GNUNET_malloc, GNUNET_STRINGS_data_to_string(), and size.
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_CRYPTO_private_key_to_string(), GNUNET_CRYPTO_public_key_to_string(), GNUNET_HELLO_builder_to_url2(), GNUNET_HELLO_parser_to_url(), GNUNET_JSON_from_data(), handle_attribute_delete_message(), handle_credential_delete_message(), issue_ticket(), iter_cb(), lookup_authz_cb(), main(), messenger_value_to_string(), move_attr_finished(), move_attrs(), oidc_ticket_issue_cb(), process_attrs(), process_record(), purge_attributes(), run(), rvk_move_attr_cb(), save_member(), save_member_session(), save_operation(), setup_job_headers(), 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 812 of file strings.c.
References enc, getValue__(), GNUNET_assert, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, ret, and SIZE_MAX.
Referenced by channel_to_sh(), check_authorization(), consume_fail(), conversation_string_to_value(), delete_attribute_cont(), delete_credential_cont(), ego_create(), expect_data_dynamic(), expect_data_fixed(), GNUNET_CONFIGURATION_get_data(), GNUNET_CRYPTO_ecdsa_public_key_from_string(), GNUNET_CRYPTO_eddsa_private_key_from_string(), GNUNET_CRYPTO_eddsa_public_key_from_string(), GNUNET_CRYPTO_hash_from_string2(), GNUNET_CRYPTO_private_key_from_string(), GNUNET_CRYPTO_public_key_from_string(), GNUNET_HELLO_parser_from_url(), GNUNET_STRINGS_string_to_data_alloc(), lookup_redirect_uri_result(), main(), messenger_string_to_value(), parse_attr(), parse_credential(), parse_fixed_data(), parse_rsa_public_key(), parse_rsa_signature(), read_service_conf(), run(), set_base32(), start_process(), string_to_auth_key(), 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 878 of file strings.c.
References data, enc, GNUNET_break_op, GNUNET_free, GNUNET_malloc, GNUNET_MAX_MALLOC_CHECKED, GNUNET_OK, GNUNET_STRINGS_string_to_data(), GNUNET_SYSERR, res, and size.
Referenced by GNUNET_PQ_event_do_poll(), parse_variable_data(), 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 1599 of file strings.c.
References cvt, data, FILLCHAR, GNUNET_assert, GNUNET_malloc, consensus-simulation::int, ret, and SIZE_MAX.
Referenced by 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 | ( | size_t | len, |
const char | data[static len], | ||
char ** | out | ||
) |
url/percent encode (RFC3986).
FIXME: awkward API, len is not actually used out is 0-terminated, should probably be changed to only input data and directly return @out or NULL.
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 1863 of file strings.c.
References data, end, GNUNET_break, GNUNET_buffer_clear(), GNUNET_buffer_reap_str(), GNUNET_buffer_write(), and GNUNET_buffer_write_fstr().
Referenced by GNUNET_HELLO_builder_to_url2(), GNUNET_HELLO_parser_to_url(), login_redirect(), PABC_load_public_parameters(), PABC_read_usr_ctx(), PABC_write_public_parameters(), and PABC_write_usr_ctx().
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 1648 of file strings.c.
References enc, and GNUNET_STRINGS_base64_encode().
Referenced by check_code_challenge(), DID_key_convert_gnunet_to_multibase_base64(), ego_sign_data_cb(), OIDC_build_authz_code(), 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 1701 of file strings.c.
References CHECK_CRLF, cvtfind, data, END, FILLCHAR, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_malloc, ret, and SIZE_MAX.
Referenced by database_setup(), dns_string_to_value(), GNUNET_ABD_delegate_from_string(), GNUNET_STRINGS_base64url_decode(), OIDC_access_token_parse(), parse_credentials_basic_auth(), and parse_fixed64_data().
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 1759 of file strings.c.
References data, GNUNET_assert, GNUNET_free, GNUNET_malloc, GNUNET_STRINGS_base64_decode(), ret, and SIZE_MAX.
Referenced by jwt_get_expiration(), jwt_get_issuer(), jwt_parse_attributes(), OIDC_parse_authz_code(), and set_attributes_from_idtoken().
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 1808 of file strings.c.
References data, GNUNET_break_op, GNUNET_free, and GNUNET_malloc.
Referenced by get_url_parameter_copy(), and GNUNET_HELLO_parser_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 920 of file strings.c.
References end, GNUNET_NO, GNUNET_strndup, and GNUNET_YES.
Referenced by GNUNET_STRINGS_path_is_absolute().
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 981 of file strings.c.
References filename, GNUNET_free, GNUNET_NO, GNUNET_STRINGS_parse_uri(), GNUNET_STRINGS_path_is_absolute(), GNUNET_YES, and uri.
Referenced by GNUNET_OS_check_helper_binary(), GNUNET_OS_get_libexec_binary_path(), GNUNET_OS_get_suid_binary_path(), GNUNET_STRINGS_check_filename(), and GNUNET_STRINGS_path_is_absolute().
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 1023 of file strings.c.
References filename, GNUNET_NO, GNUNET_STRINGS_CHECK_EXISTS, GNUNET_STRINGS_CHECK_IS_ABSOLUTE, GNUNET_STRINGS_CHECK_IS_DIRECTORY, GNUNET_STRINGS_CHECK_IS_LINK, GNUNET_STRINGS_path_is_absolute(), GNUNET_SYSERR, GNUNET_YES, S_ISLNK, and st.
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.
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 1056 of file strings.c.
References _, dummy, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, port, and ret.
Referenced by GNUNET_STRINGS_parse_socket_addr(), and GNUNET_STRINGS_to_address_ip().
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.
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 1126 of file strings.c.
References dummy, GNUNET_OK, GNUNET_SYSERR, and port.
Referenced by GNUNET_STRINGS_parse_socket_addr(), and GNUNET_STRINGS_to_address_ip().
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 1179 of file strings.c.
References GNUNET_free, GNUNET_malloc, GNUNET_OK, 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 1164 of file strings.c.
References GNUNET_STRINGS_to_address_ipv4(), and GNUNET_STRINGS_to_address_ipv6().
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 137 of file strings.c.
References GNUNET_assert, and strnlen().
Referenced by add_unixpath(), create_keys(), GCP_2s(), GNUNET_i2s(), GNUNET_i2s2(), mylog(), regex_split(), 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 2037 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 1275 of file strings.c.
References _, dummy, end, GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_new_array, GNUNET_OK, GNUNET_strdup, LOG, GNUNET_STRINGS_IPv4NetworkPolicy::netmask, parse_port_policy(), GNUNET_STRINGS_IPv4NetworkPolicy::pp, result, and SIZE_MAX.
Referenced by GNUNET_REGEX_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 1450 of file strings.c.
References _, dummy, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_new_array, GNUNET_OK, GNUNET_strdup, 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_REGEX_ipv6policy2regex(), and process_acl6().