28#include "dbus-address.h"
29#include "dbus-internals.h"
31#include "dbus-string.h"
32#include "dbus-protocol.h"
33#include <dbus/dbus-test-tap.h>
69 const char *address_problem_type,
70 const char *address_problem_field,
71 const char *address_problem_other)
73 if (address_problem_type !=
NULL)
75 "Server address of type %s was missing argument %s",
76 address_problem_type, address_problem_field);
79 "Could not parse server address: %s",
80 address_problem_other);
87#define _DBUS_ADDRESS_OPTIONALLY_ESCAPED_BYTE(b) \
88 (((b) >= 'a' && (b) <= 'z') || \
89 ((b) >= 'A' && (b) <= 'Z') || \
90 ((b) >= '0' && (b) <= '9') || \
110 const unsigned char *p;
111 const unsigned char *end;
117 orig_len = _dbus_string_get_length (escaped);
118 p = _dbus_string_get_const_udata (unescaped);
119 end = p + _dbus_string_get_length (unescaped);
196 for (i = 0; entries[i] !=
NULL; i++)
197 dbus_address_entry_free (entries[i]);
232 return _dbus_string_get_const_data (&entry->
method);
260 return _dbus_string_get_const_data (values->
data);
282 p = _dbus_string_get_const_data (escaped) + escaped_start;
283 end = p + escaped_len;
303 "In D-Bus address, percent character was not followed by two hex digits");
316 _dbus_string_get_length (unescaped)))
322 "In D-Bus address, percent character was followed by characters other than hex digits");
330 "In D-Bus address, character '%c' should have been escaped\n",
342 _DBUS_SET_OOM (error);
372 int pos, end_pos, len, i;
376 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
382 len = _dbus_string_get_length (&str);
387 "Empty address '%s'", address);
397 entry = create_entry ();
409 dbus_address_entry_free (entry);
432 while (pos < end_pos)
434 int comma_pos, equals_pos;
440 equals_pos == pos || equals_pos + 1 == comma_pos)
443 "'=' character not found or has no value following it");
497 if (!append_unescaped_value (value, &str, equals_pos + 1,
498 comma_pos - equals_pos - 1, error))
547 entry_array [*array_len] =
NULL;
553 entry_array[i] = link->
data;
559 *entry_result = entry_array;
568 dbus_address_entry_free (link->
data);
634 if (!append_unescaped_value (&unescaped, &escaped,
635 0, _dbus_string_get_length (&escaped),
644 _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_I...
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.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
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.