30#include "dbus-address.h"
31#include "dbus-internals.h"
33#include "dbus-string.h"
34#include "dbus-protocol.h"
35#include <dbus/dbus-test-tap.h>
71 const char *address_problem_type,
72 const char *address_problem_field,
73 const char *address_problem_other)
75 if (address_problem_type !=
NULL)
77 "Server address of type %s was missing argument %s",
78 address_problem_type, address_problem_field);
81 "Could not parse server address: %s",
82 address_problem_other);
89#define _DBUS_ADDRESS_OPTIONALLY_ESCAPED_BYTE(b) \
90 (((b) >= 'a' && (b) <= 'z') || \
91 ((b) >= 'A' && (b) <= 'Z') || \
92 ((b) >= '0' && (b) <= '9') || \
112 const unsigned char *p;
113 const unsigned char *end;
119 orig_len = _dbus_string_get_length (escaped);
120 p = _dbus_string_get_const_udata (unescaped);
121 end = p + _dbus_string_get_length (unescaped);
198 for (i = 0; entries[i] !=
NULL; i++)
199 dbus_address_entry_free (entries[i]);
234 return _dbus_string_get_const_data (&entry->
method);
262 return _dbus_string_get_const_data (values->
data);
284 p = _dbus_string_get_const_data (escaped) + escaped_start;
285 end = p + escaped_len;
305 "In D-Bus address, percent character was not followed by two hex digits");
318 _dbus_string_get_length (unescaped)))
324 "In D-Bus address, percent character was followed by characters other than hex digits");
332 "In D-Bus address, character '%c' should have been escaped\n",
344 _DBUS_SET_OOM (error);
374 int pos, end_pos, len, i;
378 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
384 len = _dbus_string_get_length (&str);
389 "Empty address '%s'", address);
399 entry = create_entry ();
411 dbus_address_entry_free (entry);
434 while (pos < end_pos)
436 int comma_pos, equals_pos;
442 equals_pos == pos || equals_pos + 1 == comma_pos)
445 "'=' character not found or has no value following it");
499 if (!append_unescaped_value (value, &str, equals_pos + 1,
500 comma_pos - equals_pos - 1, error))
549 entry_array [*array_len] =
NULL;
555 entry_array[i] = link->
data;
561 *entry_result = entry_array;
570 dbus_address_entry_free (link->
data);
636 if (!append_unescaped_value (&unescaped, &escaped,
637 0, _dbus_string_get_length (&escaped),
646 _DBUS_SET_OOM (error);
#define _DBUS_ADDRESS_OPTIONALLY_ESCAPED_BYTE(b)
TRUE if the byte need not be escaped when found in a dbus address.
dbus_bool_t _dbus_address_append_escaped(DBusString *escaped, const DBusString *unescaped)
Appends an escaped version of one string to another string, using the D-Bus address escaping mechanis...
void _dbus_set_bad_address(DBusError *error, const char *address_problem_type, const char *address_problem_field, const char *address_problem_other)
Sets DBUS_ERROR_BAD_ADDRESS.
void dbus_address_entries_free(DBusAddressEntry **entries)
Frees a NULL-terminated array of address entries.
dbus_bool_t dbus_parse_address(const char *address, DBusAddressEntry ***entry_result, int *array_len, DBusError *error)
Parses an address string of the form:
const char * dbus_address_entry_get_method(DBusAddressEntry *entry)
Returns the method string of an address entry.
char * dbus_address_unescape_value(const char *value, DBusError *error)
Unescapes the given string as a value in a key=value pair for a D-Bus address.
char * dbus_address_escape_value(const char *value)
Escapes the given string as a value in a key=value pair for a D-Bus address.
const char * dbus_address_entry_get_value(DBusAddressEntry *entry, const char *key)
Returns a value from a key of an entry.
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
dbus_bool_t dbus_error_is_set(const DBusError *error)
Checks whether an error occurred (the error is set).
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
DBusList * _dbus_list_get_first_link(DBusList **list)
Gets the first link in the list.
int _dbus_list_get_length(DBusList **list)
Gets the length of a list.
void _dbus_list_clear(DBusList **list)
Frees all links in the list and sets the list head to NULL.
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list.
#define _dbus_list_get_next_link(list, link)
Gets the next link in the list, or NULL if there are no more links.
#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().
#define dbus_new(type, count)
Safe macro for using dbus_malloc().
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
#define DBUS_ERROR_BAD_ADDRESS
A D-Bus bus address was malformed.
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
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_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_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_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...
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as _DBUS_STRING_IN...
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_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_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_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.
Internals of DBusAddressEntry.
DBusString method
The address type (unix, tcp, etc.)
DBusList * values
List of values.
DBusList * keys
List of keys.
Object representing an exception.
void * data
Data stored at this element.