Defines | |
#define | ASSIGN_2_OCTETS(p, octets) *((dbus_uint16_t*)(p)) = *((dbus_uint16_t*)(octets)); |
assign 2 bytes from one string to another | |
#define | ASSIGN_4_OCTETS(p, octets) *((dbus_uint32_t*)(p)) = *((dbus_uint32_t*)(octets)); |
assign 4 bytes from one string to another | |
#define | ASSIGN_8_OCTETS(p, octets) *((dbus_uint64_t*)(p)) = *((dbus_uint64_t*)(octets)); |
assign 8 bytes from one string to another | |
#define | DBUS_STRING_COPY_PREAMBLE(source, start, dest, insert_at) |
Checks assertions for two strings we're copying a segment between, and declares real_source/real_dest variables. | |
#define | UTF8_COMPUTE(Char, Mask, Len) |
computes length and mask of a unicode character | |
#define | UTF8_LENGTH(Char) |
computes length of a unicode character in UTF-8 | |
#define | UTF8_GET(Result, Chars, Count, Mask, Len) |
Gets a UTF-8 value. | |
#define | UNICODE_VALID(Char) |
Check whether a unicode char is in a valid range. | |
Functions | |
dbus_bool_t | _dbus_string_ends_with_c_str (const DBusString *a, const char *c_str) |
Returns whether a string ends with the given suffix. | |
dbus_bool_t | _dbus_string_find_byte_backward (const DBusString *str, int start, unsigned char byte, int *found) |
Find the given byte scanning backward from the given start. | |
void | _dbus_string_skip_white (const DBusString *str, int start, int *end) |
Skips whitespace from start, storing the first non-whitespace in *end. | |
dbus_bool_t | _dbus_string_init_preallocated (DBusString *str, int allocate_size) |
Initializes a string that can be up to the given allocation size before it has to realloc. | |
dbus_bool_t | _dbus_string_init (DBusString *str) |
Initializes a string. | |
void | _dbus_string_init_const (DBusString *str, const char *value) |
Initializes a constant string. | |
void | _dbus_string_init_const_len (DBusString *str, const char *value, int len) |
Initializes a constant string with a length. | |
void | _dbus_string_free (DBusString *str) |
Frees a string created by _dbus_string_init(). | |
void | _dbus_string_lock (DBusString *str) |
Locks a string such that any attempts to change the string will result in aborting the program. | |
char * | _dbus_string_get_data_len (DBusString *str, int start, int len) |
Gets a sub-portion of the raw character buffer from the string. | |
dbus_bool_t | _dbus_string_insert_bytes (DBusString *str, int i, int n_bytes, unsigned char byte) |
Inserts a number of bytes of a given value at the given position. | |
dbus_bool_t | _dbus_string_insert_byte (DBusString *str, int i, unsigned char byte) |
Inserts a single byte at the given position. | |
dbus_bool_t | _dbus_string_steal_data (DBusString *str, char **data_return) |
Like _dbus_string_get_data(), but removes the gotten data from the original string. | |
dbus_bool_t | _dbus_string_steal_data_len (DBusString *str, char **data_return, int start, int len) |
Like _dbus_string_get_data_len(), but removes the gotten data from the original string. | |
dbus_bool_t | _dbus_string_copy_data (const DBusString *str, char **data_return) |
Copies the data from the string into a char*. | |
void | _dbus_string_copy_to_buffer (const DBusString *str, char *buffer, int avail_len) |
Copies the contents of a DBusString into a different buffer. | |
dbus_bool_t | _dbus_string_copy_data_len (const DBusString *str, char **data_return, int start, int len) |
Copies a segment of the string into a char*. | |
dbus_bool_t | _dbus_string_lengthen (DBusString *str, int additional_length) |
Makes a string longer by the given number of bytes. | |
void | _dbus_string_shorten (DBusString *str, int length_to_remove) |
Makes a string shorter by the given number of bytes. | |
dbus_bool_t | _dbus_string_set_length (DBusString *str, int length) |
Sets the length of a string. | |
dbus_bool_t | _dbus_string_align_length (DBusString *str, int alignment) |
Align the length of a string to a specific alignment (typically 4 or 8) by appending nul bytes to the string. | |
dbus_bool_t | _dbus_string_alloc_space (DBusString *str, int extra_bytes) |
Preallocate extra_bytes such that a future lengthening of the string by extra_bytes is guaranteed to succeed without an out of memory error. | |
dbus_bool_t | _dbus_string_append (DBusString *str, const char *buffer) |
Appends a nul-terminated C-style string to a DBusString. | |
dbus_bool_t | _dbus_string_append_4_aligned (DBusString *str, const unsigned char octets[4]) |
Appends 4 bytes aligned on a 4 byte boundary with any alignment padding initialized to 0. | |
dbus_bool_t | _dbus_string_append_8_aligned (DBusString *str, const unsigned char octets[8]) |
Appends 8 bytes aligned on an 8 byte boundary with any alignment padding initialized to 0. | |
dbus_bool_t | _dbus_string_insert_2_aligned (DBusString *str, int insert_at, const unsigned char octets[4]) |
Inserts 2 bytes aligned on a 2 byte boundary with any alignment padding initialized to 0. | |
dbus_bool_t | _dbus_string_insert_4_aligned (DBusString *str, int insert_at, const unsigned char octets[4]) |
Inserts 4 bytes aligned on a 4 byte boundary with any alignment padding initialized to 0. | |
dbus_bool_t | _dbus_string_insert_8_aligned (DBusString *str, int insert_at, const unsigned char octets[8]) |
Inserts 8 bytes aligned on an 8 byte boundary with any alignment padding initialized to 0. | |
dbus_bool_t | _dbus_string_insert_alignment (DBusString *str, int *insert_at, int alignment) |
Inserts padding at *insert_at such to align it to the given boundary. | |
dbus_bool_t | _dbus_string_append_printf_valist (DBusString *str, const char *format, va_list args) |
Appends a printf-style formatted string to the DBusString. | |
dbus_bool_t | _dbus_string_append_printf (DBusString *str, const char *format,...) |
Appends a printf-style formatted string to the DBusString. | |
dbus_bool_t | _dbus_string_append_len (DBusString *str, const char *buffer, int len) |
Appends block of bytes with the given length to a DBusString. | |
dbus_bool_t | _dbus_string_append_byte (DBusString *str, unsigned char byte) |
Appends a single byte to the string, returning FALSE if not enough memory. | |
dbus_bool_t | _dbus_string_append_unichar (DBusString *str, dbus_unichar_t ch) |
Appends a single Unicode character, encoding the character in UTF-8 format. | |
void | _dbus_string_delete (DBusString *str, int start, int len) |
Deletes a segment of a DBusString with length len starting at start. | |
dbus_bool_t | _dbus_string_move (DBusString *source, int start, DBusString *dest, int insert_at) |
Moves the end of one string into another string. | |
dbus_bool_t | _dbus_string_copy (const DBusString *source, int start, DBusString *dest, int insert_at) |
Like _dbus_string_move(), but does not delete the section of the source string that's copied to the dest string. | |
dbus_bool_t | _dbus_string_move_len (DBusString *source, int start, int len, DBusString *dest, int insert_at) |
Like _dbus_string_move(), but can move a segment from the middle of the source string. | |
dbus_bool_t | _dbus_string_copy_len (const DBusString *source, int start, int len, DBusString *dest, int insert_at) |
Like _dbus_string_copy(), but can copy a segment from the middle of the source string. | |
dbus_bool_t | _dbus_string_replace_len (const DBusString *source, int start, int len, DBusString *dest, int replace_at, int replace_len) |
Replaces a segment of dest string with a segment of source string. | |
void | _dbus_string_get_unichar (const DBusString *str, int start, dbus_unichar_t *ch_return, int *end_return) |
Gets a unicode character from a UTF-8 string. | |
dbus_bool_t | _dbus_string_find (const DBusString *str, int start, const char *substr, int *found) |
Finds the given substring in the string, returning TRUE and filling in the byte index where the substring was found, if it was found. | |
dbus_bool_t | _dbus_string_find_to (const DBusString *str, int start, int end, const char *substr, int *found) |
Finds the given substring in the string, up to a certain position, returning TRUE and filling in the byte index where the substring was found, if it was found. | |
dbus_bool_t | _dbus_string_find_blank (const DBusString *str, int start, int *found) |
Finds a blank (space or tab) in the string. | |
void | _dbus_string_skip_blank (const DBusString *str, int start, int *end) |
Skips blanks from start, storing the first non-blank in *end (blank is space or tab). | |
dbus_bool_t | _dbus_string_pop_line (DBusString *source, DBusString *dest) |
Assigns a newline-terminated or \r\n-terminated line from the front of the string to the given dest string. | |
void | _dbus_string_delete_first_word (DBusString *str) |
Deletes up to and including the first blank space in the string. | |
void | _dbus_string_delete_leading_blanks (DBusString *str) |
Deletes any leading blanks in the string. | |
dbus_bool_t | _dbus_string_equal (const DBusString *a, const DBusString *b) |
Tests two DBusString for equality. | |
dbus_bool_t | _dbus_string_equal_len (const DBusString *a, const DBusString *b, int len) |
Tests two DBusString for equality up to the given length. | |
dbus_bool_t | _dbus_string_equal_substring (const DBusString *a, int a_start, int a_len, const DBusString *b, int b_start) |
Tests two sub-parts of two DBusString for equality. | |
dbus_bool_t | _dbus_string_equal_c_str (const DBusString *a, const char *c_str) |
Checks whether a string is equal to a C string. | |
dbus_bool_t | _dbus_string_starts_with_c_str (const DBusString *a, const char *c_str) |
Checks whether a string starts with the given C string. | |
dbus_bool_t | _dbus_string_append_byte_as_hex (DBusString *str, int byte) |
Appends a two-character hex digit to a string, where the hex digit has the value of the given byte. | |
dbus_bool_t | _dbus_string_hex_encode (const DBusString *source, int start, DBusString *dest, int insert_at) |
Encodes a string in hex, the way MD5 and SHA-1 are usually encoded. | |
dbus_bool_t | _dbus_string_hex_decode (const DBusString *source, int start, int *end_return, DBusString *dest, int insert_at) |
Decodes a string from hex encoding. | |
dbus_bool_t | _dbus_string_validate_ascii (const DBusString *str, int start, int len) |
Checks that the given range of the string is valid ASCII with no nul bytes. | |
dbus_bool_t | _dbus_string_validate_utf8 (const DBusString *str, int start, int len) |
Checks that the given range of the string is valid UTF-8. | |
dbus_bool_t | _dbus_string_validate_nul (const DBusString *str, int start, int len) |
Checks that the given range of the string is all nul bytes. | |
void | _dbus_string_zero (DBusString *str) |
Clears all allocated bytes in the string to zero. | |
dbus_bool_t | _dbus_string_get_dirname (const DBusString *filename, DBusString *dirname) |
Get the directory name from a complete filename. | |
dbus_bool_t | _dbus_string_append_int (DBusString *str, long value) |
Appends an integer to a DBusString. | |
dbus_bool_t | _dbus_string_append_uint (DBusString *str, unsigned long value) |
Appends an unsigned integer to a DBusString. | |
dbus_bool_t | _dbus_string_append_double (DBusString *str, double value) |
Appends a double to a DBusString. | |
dbus_bool_t | _dbus_string_parse_int (const DBusString *str, int start, long *value_return, int *end_return) |
Parses an integer contained in a DBusString. | |
dbus_bool_t | _dbus_check_dir_is_private_to_user (DBusString *dir, DBusError *error) |
Checks to make sure the given directory is private to the user. | |
dbus_bool_t | _dbus_string_parse_uint (const DBusString *str, int start, unsigned long *value_return, int *end_return) |
Parses an unsigned integer contained in a DBusString. | |
dbus_bool_t | _dbus_string_parse_double (const DBusString *str, int start, double *value_return, int *end_return) |
Parses a floating point number contained in a DBusString. |
Types and functions related to DBusString. DBusString is intended to be a string class that makes it hard to mess up security issues (and just in general harder to write buggy code). It should be used (or extended and then used) rather than the libc stuff in string.h. The string class is a bit inconvenient at spots because it handles out-of-memory failures and tries to be extra-robust.
A DBusString has a maximum length set at initialization time; this can be used to ensure that a buffer doesn't get too big. The _dbus_string_lengthen() method checks for overflow, and for max length being exceeded.
Try to avoid conversion to a plain C string, i.e. add methods on the string object instead, only convert to C string when passing things out to the public API. In particular, no sprintf, strcpy, strcat, any of that should be used. The GString feature of accepting negative numbers for "length of string" is also absent, because it could keep us from detecting bogus huge lengths. i.e. if we passed in some bogus huge length it would be taken to mean "current length of string" instead of "broken crack"
|
Value: DBusRealString *real_source = (DBusRealString*) source; \ DBusRealString *real_dest = (DBusRealString*) dest; \ _dbus_assert ((source) != (dest)); \ DBUS_GENERIC_STRING_PREAMBLE (real_source); \ DBUS_GENERIC_STRING_PREAMBLE (real_dest); \ _dbus_assert (!real_dest->constant); \ _dbus_assert (!real_dest->locked); \ _dbus_assert ((start) >= 0); \ _dbus_assert ((start) <= real_source->len); \ _dbus_assert ((insert_at) >= 0); \ _dbus_assert ((insert_at) <= real_dest->len)
Definition at line 1424 of file dbus-string.c. Referenced by _dbus_string_copy(), _dbus_string_copy_len(), _dbus_string_move_len(), and _dbus_string_replace_len(). |
|
Value: ((Char) < 0x110000 && \ (((Char) & 0xFFFFF800) != 0xD800) && \ ((Char) < 0xFDD0 || (Char) > 0xFDEF) && \ ((Char) & 0xFFFF) != 0xFFFF)
Definition at line 1713 of file dbus-string.c. Referenced by _dbus_string_validate_utf8(). |
|
computes length and mask of a unicode character
Definition at line 1638 of file dbus-string.c. Referenced by _dbus_string_get_unichar(), and _dbus_string_validate_utf8(). |
|
Value: (Result) = (Chars)[0] & (Mask); \ for ((Count) = 1; (Count) < (Len); ++(Count)) \ { \ if (((Chars)[(Count)] & 0xc0) != 0x80) \ { \ (Result) = -1; \ break; \ } \ (Result) <<= 6; \ (Result) |= ((Chars)[(Count)] & 0x3f); \ }
Definition at line 1695 of file dbus-string.c. Referenced by _dbus_string_get_unichar(), and _dbus_string_validate_utf8(). |
|
Value: ((Char) < 0x80 ? 1 : \ ((Char) < 0x800 ? 2 : \ ((Char) < 0x10000 ? 3 : \ ((Char) < 0x200000 ? 4 : \ ((Char) < 0x4000000 ? 5 : 6)))))
Definition at line 1679 of file dbus-string.c. Referenced by _dbus_string_validate_utf8(). |
|
Checks to make sure the given directory is private to the user.
Definition at line 1234 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _dbus_strerror(), dbus_set_error(), FALSE, and TRUE. |
|
Align the length of a string to a specific alignment (typically 4 or 8) by appending nul bytes to the string.
Definition at line 934 of file dbus-string.c. |
|
Preallocate extra_bytes such that a future lengthening of the string by extra_bytes is guaranteed to succeed without an out of memory error.
Definition at line 950 of file dbus-string.c. References _dbus_string_lengthen(), _dbus_string_shorten(), FALSE, and TRUE. Referenced by _dbus_type_writer_write_basic(). |
|
Appends a nul-terminated C-style string to a DBusString.
Definition at line 986 of file dbus-string.c. References _dbus_assert, DBUS_STRING_PREAMBLE, FALSE, DBusRealString::max_length, and NULL. Referenced by _dbus_auth_script_run(), _dbus_become_daemon(), _dbus_directory_get_next_file(), _dbus_homedir_from_username(), _dbus_keyring_new_homedir(), _dbus_server_debug_pipe_new(), _dbus_server_new_for_domain_socket(), _dbus_server_new_for_tcp_socket(), _dbus_string_get_dirname(), _dbus_string_save_to_file(), _dbus_string_test(), _dbus_transport_debug_pipe_new(), _dbus_transport_new_for_domain_socket(), _dbus_transport_new_for_tcp_socket(), _dbus_user_at_console(), dbus_server_listen(), and dbus_set_error(). |
|
Appends 4 bytes aligned on a 4 byte boundary with any alignment padding initialized to 0.
Definition at line 1043 of file dbus-string.c. References ASSIGN_4_OCTETS, DBUS_STRING_PREAMBLE, FALSE, DBusRealString::len, DBusRealString::str, and TRUE. |
|
Appends 8 bytes aligned on an 8 byte boundary with any alignment padding initialized to 0.
Definition at line 1067 of file dbus-string.c. References ASSIGN_8_OCTETS, DBUS_STRING_PREAMBLE, FALSE, DBusRealString::len, DBusRealString::str, and TRUE. |
|
Appends a single byte to the string, returning FALSE if not enough memory.
Definition at line 1273 of file dbus-string.c. References DBUS_STRING_PREAMBLE, FALSE, DBusRealString::len, and TRUE. Referenced by _dbus_address_append_escaped(), _dbus_concat_dir_and_file(), _dbus_message_test(), _dbus_string_append_byte_as_hex(), _dbus_string_hex_decode(), and _dbus_string_test(). |
|
Appends a two-character hex digit to a string, where the hex digit has the value of the given byte.
Definition at line 2272 of file dbus-string.c. References _dbus_string_append_byte(), _dbus_string_set_length(), FALSE, and TRUE. Referenced by _dbus_address_append_escaped(), and _dbus_string_hex_encode(). |
|
Appends a double to a DBusString.
Definition at line 1156 of file dbus-sysdeps.c. References _dbus_string_get_data_len(), _dbus_string_lengthen(), _dbus_string_shorten(), FALSE, and TRUE. Referenced by _dbus_string_test(). |
|
Appends an integer to a DBusString.
Definition at line 1079 of file dbus-sysdeps.c. References _dbus_string_get_data_len(), _dbus_string_lengthen(), _dbus_string_shorten(), FALSE, and TRUE. Referenced by _dbus_become_daemon(), _dbus_server_new_for_tcp_socket(), _dbus_string_test(), _dbus_transport_new_for_tcp_socket(), and _dbus_user_at_console(). |
|
Appends block of bytes with the given length to a DBusString.
Definition at line 1253 of file dbus-string.c. References _dbus_assert, DBUS_STRING_PREAMBLE, and NULL. Referenced by _dbus_sha_final(), dbus_message_iter_get_signature(), and dbus_signature_iter_get_signature(). |
|
Appends a printf-style formatted string to the DBusString.
Definition at line 1230 of file dbus-string.c. References _dbus_string_append_printf_valist(). Referenced by dbus_connection_dispatch(). |
|
Appends a printf-style formatted string to the DBusString.
Definition at line 1191 of file dbus-string.c. References _dbus_string_lengthen(), DBUS_STRING_PREAMBLE, FALSE, DBusRealString::len, DBusRealString::str, and TRUE. Referenced by _dbus_string_append_printf(), dbus_message_new_error_printf(), and dbus_set_error(). |
|
Appends an unsigned integer to a DBusString.
Definition at line 1117 of file dbus-sysdeps.c. References _dbus_string_get_data_len(), _dbus_string_lengthen(), _dbus_string_shorten(), FALSE, and TRUE. Referenced by _dbus_auth_script_run(). |
|
Appends a single Unicode character, encoding the character in UTF-8 format.
Definition at line 1295 of file dbus-string.c. References DBUS_STRING_PREAMBLE, FALSE, DBusRealString::len, and DBusRealString::max_length. Referenced by _dbus_string_test(). |
|
Like _dbus_string_move(), but does not delete the section of the source string that's copied to the dest string.
Definition at line 1472 of file dbus-string.c. References DBUS_STRING_COPY_PREAMBLE. Referenced by _dbus_auth_decode_data(), _dbus_auth_encode_data(), _dbus_auth_script_run(), _dbus_auth_server_new(), _dbus_concat_dir_and_file(), _dbus_header_copy(), _dbus_keyring_new_homedir(), _dbus_string_save_to_file(), _dbus_string_test(), and dbus_message_copy(). |
|
Copies the data from the string into a char*.
Definition at line 696 of file dbus-string.c. References _dbus_assert, DBUS_CONST_STRING_PREAMBLE, dbus_malloc(), FALSE, DBusRealString::len, NULL, DBusRealString::str, and TRUE. Referenced by _dbus_transport_init_base(). |
|
Copies a segment of the string into a char*.
Definition at line 746 of file dbus-string.c. References _dbus_assert, _dbus_string_copy_len(), _dbus_string_free(), _dbus_string_init(), _dbus_string_steal_data(), DBUS_CONST_STRING_PREAMBLE, FALSE, DBusRealString::max_length, NULL, and TRUE. |
|
Like _dbus_string_copy(), but can copy a segment from the middle of the source string.
Definition at line 1567 of file dbus-string.c. References _dbus_assert, and DBUS_STRING_COPY_PREAMBLE. Referenced by _dbus_header_load(), _dbus_string_copy_data_len(), _dbus_string_get_dirname(), and dbus_parse_address(). |
|
Copies the contents of a DBusString into a different buffer. The resulting buffer will be nul-terminated.
Definition at line 720 of file dbus-string.c. References _dbus_assert, DBUS_CONST_STRING_PREAMBLE, DBusRealString::len, and DBusRealString::str. Referenced by _dbus_generate_random_bytes_buffer(). |
|
Deletes a segment of a DBusString with length len starting at start. (Hint: to clear an entire string, setting length to 0 with _dbus_string_set_length() is easier.)
Definition at line 1382 of file dbus-string.c. References _dbus_assert, and DBUS_STRING_PREAMBLE. Referenced by _dbus_auth_bytes_sent(), _dbus_auth_script_run(), _dbus_header_create(), _dbus_string_delete_first_word(), _dbus_string_delete_leading_blanks(), and _dbus_type_writer_write_reader_partial(). |
|
Deletes up to and including the first blank space in the string.
Definition at line 2017 of file dbus-string.c. References _dbus_string_delete(), _dbus_string_find_blank(), and _dbus_string_skip_blank(). Referenced by _dbus_auth_script_run(). |
|
Deletes any leading blanks in the string.
Definition at line 2035 of file dbus-string.c. References _dbus_string_delete(), and _dbus_string_skip_blank(). Referenced by _dbus_auth_script_run(). |
|
Returns whether a string ends with the given suffix.
Definition at line 44 of file dbus-string-util.c. References _dbus_assert, DBUS_GENERIC_STRING_PREAMBLE, FALSE, NULL, and TRUE. |
|
Tests two DBusString for equality.
Definition at line 2056 of file dbus-string.c. References DBUS_GENERIC_STRING_PREAMBLE, FALSE, DBusRealString::len, DBusRealString::str, and TRUE. Referenced by _dbus_auth_script_run(), _dbus_keyring_is_for_user(), and dbus_error_has_name(). |
|
Checks whether a string is equal to a C string.
Definition at line 2197 of file dbus-string.c. References _dbus_assert, DBUS_GENERIC_STRING_PREAMBLE, FALSE, NULL, and TRUE. Referenced by _dbus_string_test(), and dbus_address_entry_get_value(). |
|
Tests two DBusString for equality up to the given length. The strings may be shorter than the given length.
Definition at line 2100 of file dbus-string.c. References DBUS_GENERIC_STRING_PREAMBLE, FALSE, DBusRealString::len, DBusRealString::str, and TRUE. Referenced by _dbus_auth_script_run(). |
|
Tests two sub-parts of two DBusString for equality. The specified range of the first string must exist; the specified start position of the second string must exist.
Definition at line 2149 of file dbus-string.c. References _dbus_assert, DBUS_GENERIC_STRING_PREAMBLE, FALSE, DBusRealString::len, DBusRealString::str, and TRUE. Referenced by _dbus_string_test(). |
|
Finds the given substring in the string, returning TRUE and filling in the byte index where the substring was found, if it was found. Returns FALSE if the substring wasn't found. Sets *start to the length of the string if the substring is not found.
Definition at line 1783 of file dbus-string.c. References _dbus_string_find_to(). Referenced by _dbus_auth_script_run(), _dbus_keyring_validate_context(), _dbus_string_pop_line(), _dbus_string_test(), and dbus_parse_address(). |
|
Finds a blank (space or tab) in the string. Returns TRUE if found, FALSE otherwise. If a blank is not found sets *found to the length of the string.
Definition at line 1878 of file dbus-string.c. References _dbus_assert, DBUS_CONST_STRING_PREAMBLE, FALSE, DBusRealString::len, DBusRealString::str, and TRUE. Referenced by _dbus_keyring_validate_context(), and _dbus_string_delete_first_word(). |
|
Find the given byte scanning backward from the given start. Sets *found to -1 if the byte is not found.
Definition at line 88 of file dbus-string-util.c. References _dbus_assert, DBUS_CONST_STRING_PREAMBLE, and NULL. Referenced by _dbus_string_get_dirname(), and _dbus_string_test(). |
|
Finds the given substring in the string, up to a certain position, returning TRUE and filling in the byte index where the substring was found, if it was found. Returns FALSE if the substring wasn't found. Sets *start to the length of the string if the substring is not found.
Definition at line 1810 of file dbus-string.c. References _dbus_assert, DBUS_CONST_STRING_PREAMBLE, FALSE, NULL, DBusRealString::str, and TRUE. Referenced by _dbus_string_find(), _dbus_string_test(), and dbus_parse_address(). |
|
|
Gets a sub-portion of the raw character buffer from the string. The "len" field is required simply for error checking, to be sure you don't try to use more string than exists. The nul termination of the returned buffer remains at the end of the entire string, not at start + len.
Definition at line 456 of file dbus-string.c. References _dbus_assert, DBUS_STRING_PREAMBLE, and DBusRealString::str. Referenced by _dbus_header_toggle_flag(), _dbus_marshal_byteswap(), _dbus_read(), _dbus_string_append_double(), _dbus_string_append_int(), and _dbus_string_append_uint(). |
|
Get the directory name from a complete filename.
Definition at line 753 of file dbus-sysdeps-util.c. References _dbus_assert, _dbus_string_append(), _dbus_string_copy_len(), _dbus_string_find_byte_backward(), and NULL. |
|
Gets a unicode character from a UTF-8 string. Does no validation; you must verify that the string is valid UTF-8 in advance and must pass in the start of a character.
Definition at line 1731 of file dbus-string.c. References _dbus_assert, DBUS_CONST_STRING_PREAMBLE, DBusRealString::len, DBusRealString::str, UTF8_COMPUTE, and UTF8_GET. Referenced by _dbus_string_test(). |
|
Decodes a string from hex encoding.
Definition at line 2356 of file dbus-string.c. References _dbus_assert, _dbus_string_append_byte(), _dbus_string_free(), _dbus_string_init(), _dbus_string_move(), FALSE, and TRUE. Referenced by _dbus_string_test(). |
|
Encodes a string in hex, the way MD5 and SHA-1 are usually encoded. (Each byte is two hex digits.)
Definition at line 2306 of file dbus-string.c. References _dbus_assert, _dbus_string_append_byte_as_hex(), _dbus_string_free(), _dbus_string_init(), _dbus_string_move(), FALSE, and TRUE. Referenced by _dbus_auth_script_run(), _dbus_keyring_get_hex_key(), _dbus_server_init_base(), and _dbus_sha_compute(). |
|
Initializes a string. The string starts life with zero length. The string must eventually be freed with _dbus_string_free().
Definition at line 174 of file dbus-string.c. References _dbus_string_init_preallocated(). Referenced by _dbus_auth_client_new(), _dbus_auth_script_run(), _dbus_auth_server_new(), _dbus_become_daemon(), _dbus_generate_random_bytes_buffer(), _dbus_keyring_new_homedir(), _dbus_message_loader_new(), _dbus_server_debug_pipe_new(), _dbus_server_init_base(), _dbus_server_new_for_domain_socket(), _dbus_server_new_for_tcp_socket(), _dbus_sha_compute(), _dbus_string_copy_data_len(), _dbus_string_hex_decode(), _dbus_string_hex_encode(), _dbus_string_save_to_file(), _dbus_string_steal_data(), _dbus_string_steal_data_len(), _dbus_string_test(), _dbus_transport_debug_pipe_new(), _dbus_transport_new_for_domain_socket(), _dbus_transport_new_for_fd(), _dbus_transport_new_for_tcp_socket(), _dbus_user_at_console(), dbus_address_escape_value(), dbus_address_unescape_value(), dbus_connection_dispatch(), dbus_message_iter_get_signature(), dbus_message_new_error_printf(), dbus_parse_address(), dbus_server_listen(), dbus_set_error(), and dbus_signature_iter_get_signature(). |
|
Initializes a constant string. The value parameter is not copied (should be static), and the string may never be modified. It is safe but not necessary to call _dbus_string_free() on a const string. The string has a length limit of MAXINT - 8.
Definition at line 208 of file dbus-string.c. References _dbus_assert, _dbus_string_init_const_len(), and NULL. Referenced by _dbus_auth_script_run(), _dbus_keyring_new_homedir(), _dbus_server_debug_pipe_new(), _dbus_server_new_for_domain_socket(), _dbus_server_new_for_tcp_socket(), _dbus_string_test(), _dbus_test_oom_handling(), _dbus_transport_open(), dbus_address_escape_value(), dbus_address_unescape_value(), dbus_error_has_name(), dbus_message_iter_open_container(), dbus_parse_address(), dbus_server_listen(), and dbus_signature_validate(). |
|
Initializes a constant string with a length. The value parameter is not copied (should be static), and the string may never be modified. It is safe but not necessary to call _dbus_string_free() on a const string.
Definition at line 228 of file dbus-string.c. References _dbus_assert, _DBUS_STRING_MAX_MAX_LENGTH, DBusRealString::align_offset, DBusRealString::allocated, DBusRealString::constant, FALSE, DBusRealString::invalid, DBusRealString::len, DBusRealString::locked, DBusRealString::max_length, NULL, DBusRealString::str, and TRUE. Referenced by _dbus_server_init_base(), and _dbus_string_init_const(). |
|
Initializes a string that can be up to the given allocation size before it has to realloc. The string starts life with zero length. The string must eventually be freed with _dbus_string_free().
Definition at line 130 of file dbus-string.c. References _dbus_assert, _DBUS_STRING_MAX_MAX_LENGTH, DBusRealString::align_offset, DBusRealString::allocated, DBusRealString::constant, dbus_malloc(), FALSE, DBusRealString::invalid, DBusRealString::len, DBusRealString::locked, DBusRealString::max_length, NULL, DBusRealString::str, and TRUE. Referenced by _dbus_header_copy(), _dbus_header_init(), _dbus_string_init(), and dbus_message_copy(). |
|
Inserts 2 bytes aligned on a 2 byte boundary with any alignment padding initialized to 0.
Definition at line 1091 of file dbus-string.c. References ASSIGN_2_OCTETS, DBUS_STRING_PREAMBLE, FALSE, DBusRealString::str, and TRUE. |
|
Inserts 4 bytes aligned on a 4 byte boundary with any alignment padding initialized to 0.
Definition at line 1115 of file dbus-string.c. References ASSIGN_4_OCTETS, DBUS_STRING_PREAMBLE, FALSE, DBusRealString::str, and TRUE. |
|
Inserts 8 bytes aligned on an 8 byte boundary with any alignment padding initialized to 0.
Definition at line 1139 of file dbus-string.c. References _dbus_assert, ASSIGN_8_OCTETS, DBUS_STRING_PREAMBLE, FALSE, DBusRealString::str, and TRUE. |
|
Inserts padding at *insert_at such to align it to the given boundary. Initializes the padding to nul bytes. Sets *insert_at to the aligned position.
Definition at line 1167 of file dbus-string.c. References _dbus_assert, DBUS_STRING_PREAMBLE, FALSE, and TRUE. |
|
Inserts a single byte at the given position.
Definition at line 580 of file dbus-string.c. References _dbus_assert, DBUS_STRING_PREAMBLE, FALSE, DBusRealString::str, and TRUE. Referenced by _dbus_marshal_write_basic(). |
|
Inserts a number of bytes of a given value at the given position.
Definition at line 550 of file dbus-string.c. References _dbus_assert, DBUS_STRING_PREAMBLE, FALSE, DBusRealString::str, and TRUE. Referenced by _dbus_string_test(). |
|
Makes a string longer by the given number of bytes. Checks whether adding additional_length to the current length would overflow an integer, and checks for exceeding a string's max length. The new bytes are not initialized, other than nul-terminating the end of the string. The uninitialized bytes may contain nul bytes or other junk.
Definition at line 811 of file dbus-string.c. References _dbus_assert, DBUS_STRING_PREAMBLE, FALSE, DBusRealString::len, and DBusRealString::max_length. Referenced by _dbus_read(), _dbus_string_alloc_space(), _dbus_string_append_double(), _dbus_string_append_int(), _dbus_string_append_printf_valist(), and _dbus_string_append_uint(). |
|
Locks a string such that any attempts to change the string will result in aborting the program. Also, if the string is wasting a lot of memory (allocation is sufficiently larger than what the string is really using), _dbus_string_lock() will realloc the string's data to "compact" it.
Definition at line 287 of file dbus-string.c. References DBusRealString::align_offset, DBusRealString::allocated, DBUS_LOCKED_STRING_PREAMBLE, dbus_realloc(), DBusRealString::len, DBusRealString::locked, NULL, DBusRealString::str, and TRUE. |
|
Moves the end of one string into another string. Both strings must be initialized, valid strings.
Definition at line 1448 of file dbus-string.c. References _dbus_assert, _dbus_string_move_len(), and DBusRealString::len. Referenced by _dbus_string_hex_decode(), _dbus_string_hex_encode(), and _dbus_string_test(). |
|
Like _dbus_string_move(), but can move a segment from the middle of the source string.
Definition at line 1500 of file dbus-string.c. References _dbus_assert, DBUS_STRING_COPY_PREAMBLE, FALSE, and TRUE. Referenced by _dbus_string_move(), _dbus_string_pop_line(), and _dbus_string_steal_data_len(). |
|
Parses a floating point number contained in a DBusString. Either return parameter may be NULL if you aren't interested in it. The integer is parsed and stored in value_return. Return parameters are not initialized if the function returns FALSE.
Definition at line 1477 of file dbus-sysdeps.c. References FALSE, NULL, and TRUE. Referenced by _dbus_string_test(). |
|
Parses an integer contained in a DBusString. Either return parameter may be NULL if you aren't interested in it. The integer is parsed and stored in value_return. Return parameters are not initialized if the function returns FALSE.
Definition at line 1199 of file dbus-sysdeps.c. References FALSE, NULL, and TRUE. Referenced by _dbus_is_a_number(), _dbus_parse_uid(), _dbus_string_test(), _dbus_test_oom_handling(), _dbus_transport_open(), and dbus_server_listen(). |
|
Parses an unsigned integer contained in a DBusString. Either return parameter may be NULL if you aren't interested in it. The integer is parsed and stored in value_return. Return parameters are not initialized if the function returns FALSE.
Definition at line 1275 of file dbus-sysdeps.c. |
|
Assigns a newline-terminated or \r\n-terminated line from the front of the string to the given dest string. The dest string's previous contents are deleted. If the source string contains no newline, moves the entire source string to the dest string.
Definition at line 1958 of file dbus-string.c. References _dbus_assert, _dbus_string_find(), _dbus_string_move_len(), _dbus_string_set_length(), FALSE, and TRUE. Referenced by _dbus_auth_script_run(). |
|
Replaces a segment of dest string with a segment of source string.
Definition at line 1605 of file dbus-string.c. References _dbus_assert, DBUS_STRING_COPY_PREAMBLE, FALSE, and TRUE. Referenced by _dbus_auth_set_context(), and _dbus_string_test(). |
|
Sets the length of a string. Can be used to truncate or lengthen the string. If the string is lengthened, the function may fail and return FALSE. Newly-added bytes are not initialized, as with _dbus_string_lengthen().
Definition at line 853 of file dbus-string.c. References _dbus_assert, and DBUS_STRING_PREAMBLE. Referenced by _dbus_address_append_escaped(), _dbus_auth_delete_unused_bytes(), _dbus_directory_get_next_file(), _dbus_file_get_contents(), _dbus_generate_random_bytes(), _dbus_header_load(), _dbus_header_reinit(), _dbus_keyring_new_homedir(), _dbus_message_loader_new(), _dbus_read(), _dbus_string_append_byte_as_hex(), _dbus_string_pop_line(), and _dbus_string_test(). |
|
Makes a string shorter by the given number of bytes.
Definition at line 831 of file dbus-string.c. References _dbus_assert, DBUS_STRING_PREAMBLE, and DBusRealString::len. Referenced by _dbus_concat_dir_and_file(), _dbus_string_alloc_space(), _dbus_string_append_double(), _dbus_string_append_int(), _dbus_string_append_uint(), and _dbus_string_test(). |
|
Skips blanks from start, storing the first non-blank in *end (blank is space or tab).
Definition at line 1916 of file dbus-string.c. References _dbus_assert, DBUS_CONST_STRING_PREAMBLE, DBusRealString::len, and DBusRealString::str. Referenced by _dbus_string_delete_first_word(), and _dbus_string_delete_leading_blanks(). |
|
Skips whitespace from start, storing the first non-whitespace in *end. (whitespace is space, tab, newline, CR).
Definition at line 123 of file dbus-string-util.c. References _dbus_assert, and DBUS_CONST_STRING_PREAMBLE. |
|
Checks whether a string starts with the given C string.
Definition at line 2234 of file dbus-string.c. References _dbus_assert, DBUS_GENERIC_STRING_PREAMBLE, FALSE, NULL, and TRUE. Referenced by _dbus_auth_script_run(). |
|
Like _dbus_string_get_data(), but removes the gotten data from the original string. The caller must free the data returned. This function may fail due to lack of memory, and return FALSE.
Definition at line 607 of file dbus-string.c. References _dbus_assert, _dbus_string_init(), DBUS_STRING_PREAMBLE, FALSE, DBusRealString::max_length, NULL, DBusRealString::str, and TRUE. Referenced by _dbus_string_copy_data_len(), _dbus_string_steal_data_len(), _dbus_string_test(), dbus_address_escape_value(), dbus_address_unescape_value(), dbus_message_iter_get_signature(), dbus_set_error(), and dbus_signature_iter_get_signature(). |
|
Like _dbus_string_get_data_len(), but removes the gotten data from the original string. The caller must free the data returned. This function may fail due to lack of memory, and return FALSE. The returned string is nul-terminated and has length len.
Definition at line 652 of file dbus-string.c. References _dbus_assert, _dbus_string_free(), _dbus_string_init(), _dbus_string_move_len(), _dbus_string_steal_data(), _dbus_warn(), DBUS_STRING_PREAMBLE, FALSE, DBusRealString::max_length, NULL, and TRUE. |
|
Checks that the given range of the string is valid ASCII with no nul bytes. If the given range is not entirely contained in the string, returns FALSE.
Definition at line 2497 of file dbus-string.c. References _dbus_assert, DBUS_CONST_STRING_PREAMBLE, FALSE, DBusRealString::len, DBusRealString::str, and TRUE. Referenced by _dbus_generate_random_ascii(), and _dbus_keyring_validate_context(). |
|
Checks that the given range of the string is all nul bytes. If the given range is not entirely contained in the string, returns FALSE.
Definition at line 2638 of file dbus-string.c. References _dbus_assert, DBUS_CONST_STRING_PREAMBLE, FALSE, DBusRealString::len, DBusRealString::str, and TRUE. Referenced by _dbus_header_load(). |
|
Checks that the given range of the string is valid UTF-8. If the given range is not entirely contained in the string, returns FALSE. If the string contains any nul bytes in the given range, returns FALSE. If the start and start+len are not on character boundaries, returns FALSE.
Definition at line 2540 of file dbus-string.c. References _dbus_assert, DBUS_CONST_STRING_PREAMBLE, FALSE, DBusRealString::len, DBusRealString::str, TRUE, UNICODE_VALID, UTF8_COMPUTE, UTF8_GET, and UTF8_LENGTH. |
|
Clears all allocated bytes in the string to zero.
Definition at line 2670 of file dbus-string.c. References DBusRealString::align_offset, DBusRealString::allocated, DBUS_STRING_PREAMBLE, and DBusRealString::str. |