33#include "dbus-internals.h"
34#include "dbus-string.h"
39#define DBUS_CAN_USE_DBUS_STRING_PRIVATE 1
40#include "dbus-string-private.h"
41#include "dbus-marshal-basic.h"
45#include "dbus-sysdeps.h"
88 unsigned char *aligned;
89 unsigned char *real_block;
90 unsigned int old_align_offset;
96 real_block = real->
str - old_align_offset;
98 aligned = _DBUS_ALIGN_ADDRESS (real_block, 8);
107 real_block + old_align_offset,
156 real->
str =
dbus_malloc (_DBUS_STRING_ALLOCATION_PADDING + allocate_size);
160 real->
allocated = _DBUS_STRING_ALLOCATION_PADDING + allocate_size;
162 real->
str[real->
len] =
'\0';
169 fixup_alignment (real);
230 real->
str = (
unsigned char*) value;
232 real->
allocated = real->
len + _DBUS_STRING_ALLOCATION_PADDING;
307 unsigned char *new_str;
311 waste = real->
allocated - (real->
len + _DBUS_STRING_ALLOCATION_PADDING);
313 if (waste <= max_waste)
316 new_allocated = real->
len + _DBUS_STRING_ALLOCATION_PADDING;
319 if (_DBUS_UNLIKELY (new_str ==
NULL))
324 fixup_alignment (real);
329#ifdef DBUS_ENABLE_EMBEDDED_TESTS
353 compact (real, MAX_WASTE);
362 unsigned char *new_str;
379#if defined (DBUS_ENABLE_EMBEDDED_TESTS) && !defined (DBUS_DISABLE_ASSERT)
386 new_allocated = MAX (new_allocated,
387 new_length + _DBUS_STRING_ALLOCATION_PADDING);
391 if (_DBUS_UNLIKELY (new_str ==
NULL))
396 fixup_alignment (real);
418 return compact (real, max_waste);
430 else if (new_length > (real->
allocated - _DBUS_STRING_ALLOCATION_PADDING) &&
431 _DBUS_UNLIKELY (!reallocate_for_length (real, new_length)))
435 real->
len = new_length;
436 real->
str[new_length] =
'\0';
452 if (!set_length (dest, dest->
len + len))
455 memmove (dest->
str + insert_at + len,
456 dest->
str + insert_at,
457 dest->
len - len - insert_at);
462#ifndef _dbus_string_get_data
479 return (
char*) real->
str;
484#ifndef _dbus_string_get_const_data
492_dbus_string_get_const_data (
const DBusString *str)
496 return (
const char*) real->
str;
524 return (
char*) real->
str + start;
528#ifndef _dbus_string_get_const_data_len
538_dbus_string_get_const_data_len (
const DBusString *str,
548 return (
const char*) real->
str + start;
553#ifndef _dbus_string_set_byte
575#ifndef _dbus_string_get_byte
593 return real->
str[start];
621 if (!open_gap (n_bytes, real, i))
624 memset (real->
str + i,
byte, n_bytes);
646 if (!open_gap (1, real, i))
671 undo_alignment (real);
673 *data_return = (
char*) real->
str;
679 real->
str = (
unsigned char*) *data_return;
681 fixup_alignment (real);
703 if (*data_return ==
NULL)
706 memcpy (*data_return, real->
str, real->
len + 1);
730 memcpy (buffer, real->
str, real->
len);
752 memcpy (buffer, real->
str, real->
len+1);
756#ifndef _dbus_string_get_length
763_dbus_string_get_length (
const DBusString *str)
785 int additional_length)
793 return set_length (real,
794 real->
len + additional_length);
805 int length_to_remove)
812 real->
len - length_to_remove);
832 return set_length (real, length);
836align_insert_point_then_open_gap (
DBusString *str,
841 unsigned long new_len;
842 unsigned long gap_pos;
849 insert_at = *insert_at_p;
853 gap_pos = _DBUS_ALIGN_VALUE (insert_at, alignment);
854 new_len = real->
len + (gap_pos - insert_at) + gap_size;
859 delta = new_len - real->
len;
864 _dbus_assert (((
unsigned long) *insert_at_p) == gap_pos);
868 if (_DBUS_UNLIKELY (!open_gap (new_len - real->
len,
873 if (gap_size < delta)
875 memset (&real->
str[insert_at],
'\0',
876 gap_pos - insert_at);
879 *insert_at_p = gap_pos;
887 int then_lengthen_by)
891 insert_at = _dbus_string_get_length (str);
893 return align_insert_point_then_open_gap (str,
895 alignment, then_lengthen_by);
910 return align_length_then_lengthen (str, alignment, 0);
944 memcpy (real->str + (real->len - buffer_len),
962 unsigned long buffer_len;
967 buffer_len = strlen (buffer);
971 return append (real, buffer, buffer_len);
975#define ASSIGN_2_OCTETS(p, octets) \
976 *((dbus_uint16_t*)(p)) = *((dbus_uint16_t*)(octets));
979#define ASSIGN_4_OCTETS(p, octets) \
980 *((dbus_uint32_t*)(p)) = *((dbus_uint32_t*)(octets));
983#define ASSIGN_8_OCTETS(p, octets) \
984 *((dbus_uint64_t*)(p)) = *((dbus_uint64_t*)(octets));
998 const unsigned char octets[2])
1002 if (!align_insert_point_then_open_gap (str, &insert_at, 2, 2))
1022 const unsigned char octets[4])
1026 if (!align_insert_point_then_open_gap (str, &insert_at, 4, 4))
1046 const unsigned char octets[8])
1050 if (!align_insert_point_then_open_gap (str, &insert_at, 8, 8))
1053 _dbus_assert (_DBUS_ALIGN_VALUE (insert_at, 8) == (
unsigned) insert_at);
1078 if (!align_insert_point_then_open_gap (str, insert_at, alignment, 0))
1081 _dbus_assert (_DBUS_ALIGN_VALUE (*insert_at, alignment) == (
unsigned) *insert_at);
1106 DBUS_VA_COPY (args_copy, args);
1119 vsprintf ((
char*) (real->
str + (real->
len - len)),
1145 va_start (args, format);
1169 return append (real, buffer, len);
1186 if (!set_length (real, real->
len + 1))
1189 real->
str[real->
len-1] = byte;
1202 memmove (real->
str + start, real->
str + start + len, real->
len - (start + len));
1204 real->
str[real->
len] =
'\0';
1227 delete (real, start, len);
1240 if (!open_gap (len, dest, insert_at))
1243 memmove (dest->
str + insert_at,
1244 source->
str + start,
1259#define DBUS_STRING_COPY_PREAMBLE(source, start, dest, insert_at) \
1260 DBusRealString *real_source = (DBusRealString*) source; \
1261 DBusRealString *real_dest = (DBusRealString*) dest; \
1262 _dbus_assert ((source) != (dest)); \
1263 DBUS_GENERIC_STRING_PREAMBLE (real_source); \
1264 DBUS_GENERIC_STRING_PREAMBLE (real_dest); \
1265 _dbus_assert (!real_dest->constant); \
1266 _dbus_assert (!real_dest->locked); \
1267 _dbus_assert ((start) >= 0); \
1268 _dbus_assert ((start) <= real_source->len); \
1269 _dbus_assert ((insert_at) >= 0); \
1270 _dbus_assert ((insert_at) <= real_dest->len)
1292 real_source->
len - start,
1314 return copy (real_source, start,
1315 real_source->len - start,
1348 else if (start == 0 &&
1349 len == real_source->len &&
1350 real_dest->len == 0)
1358#define ASSIGN_DATA(a, b) do { \
1359 (a)->str = (b)->str; \
1360 (a)->len = (b)->len; \
1361 (a)->allocated = (b)->allocated; \
1362 (a)->align_offset = (b)->align_offset; \
1367 ASSIGN_DATA (&tmp, real_source);
1368 ASSIGN_DATA (real_source, real_dest);
1369 ASSIGN_DATA (real_dest, &tmp);
1375 if (!copy (real_source, start, len,
1380 delete (real_source, start,
1410 return copy (real_source, start, len,
1441 _dbus_assert (replace_len <= real_dest->len - replace_at);
1443 if (len == replace_len)
1445 memmove (real_dest->str + replace_at,
1446 real_source->str + start, len);
1448 else if (len < replace_len)
1450 memmove (real_dest->str + replace_at,
1451 real_source->str + start, len);
1452 delete (real_dest, replace_at + len,
1461 diff = len - replace_len;
1467 if (!copy (real_source, start + replace_len, diff,
1468 real_dest, replace_at + replace_len))
1471 memmove (real_dest->str + replace_at,
1472 real_source->str + start, replace_len);
1496 char byte_string[2] =
"";
1500 byte_string[0] = (char)
byte;
1505 head_length = byte_position;
1506 tail_length = _dbus_string_get_length (source) - head_length - 1;
1529#define UTF8_COMPUTE(Char, Mask, Len) \
1535 else if ((Char & 0xe0) == 0xc0) \
1540 else if ((Char & 0xf0) == 0xe0) \
1545 else if ((Char & 0xf8) == 0xf0) \
1550 else if ((Char & 0xfc) == 0xf8) \
1555 else if ((Char & 0xfe) == 0xfc) \
1570#define UTF8_LENGTH(Char) \
1571 ((Char) < 0x80 ? 1 : \
1572 ((Char) < 0x800 ? 2 : \
1573 ((Char) < 0x10000 ? 3 : \
1574 ((Char) < 0x200000 ? 4 : \
1575 ((Char) < 0x4000000 ? 5 : 6)))))
1586#define UTF8_GET(Result, Chars, Count, Mask, Len) \
1587 (Result) = (Chars)[0] & (Mask); \
1588 for ((Count) = 1; (Count) < (Len); ++(Count)) \
1590 if (((Chars)[(Count)] & 0xc0) != 0x80) \
1596 (Result) |= ((Chars)[(Count)] & 0x3f); \
1609#define UNICODE_VALID(Char) \
1610 ((Char) < 0x110000 && \
1611 (((Char) & 0xFFFFF800) != 0xD800))
1663 while (i < real->len)
1665 if (real->
str[i] ==
'\r')
1667 if ((i+1) < real->
len && real->
str[i+1] ==
'\n')
1684 else if (real->
str[i] ==
'\n')
1737 if (*substr ==
'\0')
1747 if (real->
str[i] == substr[0])
1753 if (substr[j - i] ==
'\0')
1755 else if (real->
str[j] != substr[j - i])
1761 if (substr[j - i] ==
'\0')
1799 while (i < real->len)
1801 if (real->
str[i] ==
' ' ||
1802 real->
str[i] ==
'\t')
1837 while (i < real->len)
1871 while (i < real->len)
1944 _dbus_assert (eol == _dbus_string_get_length (source));
1970#ifdef DBUS_ENABLE_EMBEDDED_TESTS
1978_dbus_string_delete_first_word (
DBusString *str)
1989#ifdef DBUS_ENABLE_EMBEDDED_TESTS
1996_dbus_string_delete_leading_blanks (
DBusString *str)
2040 const unsigned char *ap;
2041 const unsigned char *bp;
2042 const unsigned char *a_end;
2048 if (real_a->
len != real_b->
len)
2053 a_end = real_a->
str + real_a->
len;
2084 const unsigned char *ap;
2085 const unsigned char *bp;
2086 const unsigned char *a_end;
2092 if (real_a->
len != real_b->
len &&
2093 (real_a->
len < len || real_b->
len < len))
2098 a_end = real_a->
str + MIN (real_a->
len, len);
2134 const unsigned char *ap;
2135 const unsigned char *bp;
2136 const unsigned char *a_end;
2148 if (a_len > real_b->
len - b_start)
2151 ap = real_a->
str + a_start;
2152 bp = real_b->
str + b_start;
2179 const unsigned char *ap;
2180 const unsigned char *bp;
2181 const unsigned char *a_end;
2187 bp = (
const unsigned char*) c_str;
2188 a_end = real_a->
str + real_a->
len;
2189 while (ap != a_end && *bp)
2198 if (ap != a_end || *bp)
2215 const unsigned char *ap;
2216 const unsigned char *bp;
2217 const unsigned char *a_end;
2223 bp = (
const unsigned char*) c_str;
2224 a_end = real_a->
str + real_a->
len;
2225 while (ap != a_end && *bp)
2252 char word_separator)
2261 data = _dbus_string_get_const_data (a);
2262 next_char = data[strlen (c_str)];
2263 return next_char ==
'\0' || next_char == word_separator;
2278 const char hexdigits[16] = {
2279 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
2280 'a',
'b',
'c',
'd',
'e',
'f'
2284 hexdigits[(
byte >> 4)]))
2288 hexdigits[(
byte & 0x0f)]))
2291 _dbus_string_get_length (str) - 1);
2315 const unsigned char *p;
2316 const unsigned char *end;
2319 _dbus_assert (start <= _dbus_string_get_length (source));
2326 p = (
const unsigned char*) _dbus_string_get_const_data (source);
2327 end = p + _dbus_string_get_length (source);
2366 const unsigned char *p;
2367 const unsigned char *end;
2371 _dbus_assert (start <= _dbus_string_get_length (source));
2379 p = (
const unsigned char*) _dbus_string_get_const_data (source);
2380 end = p + _dbus_string_get_length (source);
2458 len = _dbus_string_get_length (&result);
2460 b = _dbus_string_get_byte (&result, len - 1);
2464 _dbus_string_set_byte (&result, len - 1, b);
2467 high_bits = !high_bits;
2477 *end_return = p - (
const unsigned char*) _dbus_string_get_const_data (source);
2504 const unsigned char *s;
2505 const unsigned char *end;
2511 if (len > real->
len - start)
2514 s = real->
str + start;
2518 if (_DBUS_UNLIKELY (!_DBUS_ISASCII (*s)))
2547 s = real->
str + start;
2552 if (*s >=
'A' && *s <=
'Z')
2578 s = real->
str + start;
2583 if (*s >=
'a' && *s <=
'z')
2609 const unsigned char *p;
2610 const unsigned char *end;
2624 if (_DBUS_UNLIKELY (len > real->
len - start))
2627 p = real->
str + start;
2632 int i, mask, char_len;
2633 dbus_unichar_t result;
2653 if (_DBUS_UNLIKELY (char_len == 0))
2657 if (_DBUS_UNLIKELY ((end - p) < char_len))
2660 UTF8_GET (result, p, i, mask, char_len);
2663 if (_DBUS_UNLIKELY (
UTF8_LENGTH (result) != char_len))
2667 if (_DBUS_UNLIKELY (result == (dbus_unichar_t)-1))
2683 if (_DBUS_UNLIKELY (p != end))
2707 const unsigned char *s;
2708 const unsigned char *end;
2714 if (len > real->
len - start)
2717 s = real->
str + start;
2721 if (_DBUS_UNLIKELY (*s !=
'\0'))
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called.
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
#define NULL
A null pointer, defined appropriately for C or C++.
#define TRUE
Expands to "1".
#define FALSE
Expands to "0".
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
void * dbus_realloc(void *memory, size_t bytes)
Resizes a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
void * dbus_malloc(size_t bytes)
Allocates the given number of bytes, as with standard malloc().
#define _DBUS_STRING_MAX_LENGTH
The maximum length of a DBusString.
#define DBUS_STRING_PREAMBLE(str)
Checks assertions about a string object that needs to be modifiable - may not be locked or const.
#define DBUS_CONST_STRING_PREAMBLE(str)
Checks assertions about a string that may be const or locked.
#define DBUS_GENERIC_STRING_PREAMBLE(real)
Checks a bunch of assertions about a string object.
#define DBUS_IS_ASCII_BLANK(c)
Checks for ASCII blank byte.
#define DBUS_IS_ASCII_WHITE(c)
Checks for ASCII whitespace byte.
#define DBUS_LOCKED_STRING_PREAMBLE(str)
Checks assertions about a string object that may be locked but can't be const.
dbus_bool_t _dbus_string_set_length(DBusString *str, int length)
Sets the length of a string.
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_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
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_validate_nul(const DBusString *str, int start, int len)
Checks that the given range of the string is all nul bytes.
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.
#define UNICODE_VALID(Char)
Check whether a Unicode (5.2) char is in a valid range.
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.
#define UTF8_COMPUTE(Char, Mask, Len)
computes length and mask of a unicode character
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.
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 d...
dbus_bool_t _dbus_string_find_eol(const DBusString *str, int start, int *found, int *found_len)
Finds end of line ("\r\n" or "\n") in the string, returning TRUE and filling in the byte index where ...
#define ASSIGN_2_OCTETS(p, octets)
assign 2 bytes from one string to another
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_alloc_space(DBusString *str, int extra_bytes)
Preallocate extra_bytes such that a future lengthening of the string by extra_bytes is guaranteed to ...
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.
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_init_preallocated(DBusString *str, int allocate_size)
Initializes a string that can be up to the given allocation size before it has to realloc.
void _dbus_string_skip_white_reverse(const DBusString *str, int end, int *start)
Skips whitespace from end, storing the start index of the trailing whitespace in *start.
dbus_bool_t _dbus_string_init_from_string(DBusString *str, const DBusString *from)
Initializes a string from another string.
dbus_bool_t _dbus_string_split_on_byte(DBusString *source, unsigned char byte, DBusString *tail)
Looks for the first occurance of a byte, deletes that byte, and moves everything after the byte to th...
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 subst...
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_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_find_blank(const DBusString *str, int start, int *found)
Finds a blank (space or tab) in the string.
void _dbus_string_init_const_len(DBusString *str, const char *value, int len)
Initializes a constant string with a length.
void _dbus_string_tolower_ascii(const DBusString *str, int start, int len)
Converts the given range of the string to lower case.
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.
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as #_DBUS_STRING_I...
void _dbus_string_shorten(DBusString *str, int length_to_remove)
Makes a string shorter by the given number of bytes.
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_copy_data(const DBusString *str, char **data_return)
Copies the data from the string into a char*.
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.
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_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 s...
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_lengthen(DBusString *str, int additional_length)
Makes a string longer by the given number of bytes.
void _dbus_string_zero(DBusString *str)
Clears all allocated bytes in the string to zero.
#define UTF8_LENGTH(Char)
computes length of a unicode character in UTF-8
void _dbus_string_toupper_ascii(const DBusString *str, int start, int len)
Converts the given range of the string to upper case.
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_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_append_byte(DBusString *str, unsigned char byte)
Appends a single byte to the string, returning FALSE if not enough memory.
void _dbus_string_chop_white(DBusString *str)
Deletes leading and trailing whitespace.
dbus_bool_t _dbus_string_starts_with_words_c_str(const DBusString *a, const char *c_str, char word_separator)
Checks whether a string starts with the given C string, after which it ends or is separated from the ...
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.
#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...
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_insert_byte(DBusString *str, int i, unsigned char byte)
Inserts a single byte at the given position.
#define UTF8_GET(Result, Chars, Count, Mask, Len)
Gets a UTF-8 value.
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.
void _dbus_string_copy_to_buffer_with_nul(const DBusString *str, char *buffer, int avail_len)
Copies the contents of a DBusString into a different buffer.
dbus_bool_t _dbus_string_compact(DBusString *str, int max_waste)
Compacts the string to avoid wasted memory.
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.
#define ASSIGN_8_OCTETS(p, octets)
assign 8 bytes from one string to another
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_equal(const DBusString *a, const DBusString *b)
Tests two DBusString for equality.
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_2_aligned(DBusString *str, int insert_at, const unsigned char octets[2])
Inserts 2 bytes aligned on a 2 byte boundary with any alignment padding initialized to 0.
#define ASSIGN_4_OCTETS(p, octets)
assign 4 bytes from one string to another
dbus_bool_t _dbus_string_append_byte_as_hex(DBusString *str, unsigned char 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_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...
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 ...
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.
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_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.
int _dbus_printf_string_upper_bound(const char *format, va_list args)
Measure the length of the given format string and arguments, not including the terminating nul.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
unsigned int align_offset
str - align_offset is the actual malloc block
unsigned int valid
DBusString is valid (initialized and not freed)
unsigned int constant
String data is not owned by DBusString.
unsigned int locked
DBusString has been locked and can't be changed.
unsigned char * str
String data, plus nul termination.
int allocated
Allocated size of data.
int len
Length without nul.