26 #include "dbus-address.h"    27 #include "dbus-internals.h"    28 #include "dbus-list.h"    29 #include "dbus-string.h"    30 #include "dbus-protocol.h"    66                        const char *address_problem_type,
    67                        const char *address_problem_field,
    68                        const char *address_problem_other)
    70   if (address_problem_type != 
NULL)
    72                     "Server address of type %s was missing argument %s",
    73                     address_problem_type, address_problem_field);
    76                     "Could not parse server address: %s",
    77                     address_problem_other);
    84 #define _DBUS_ADDRESS_OPTIONALLY_ESCAPED_BYTE(b)        \    85          (((b) >= 'a' && (b) <= 'z') ||                 \    86           ((b) >= 'A' && (b) <= 'Z') ||                 \    87           ((b) >= '0' && (b) <= '9') ||                 \   107   const unsigned char *p;
   108   const unsigned char *end;
   114   orig_len = _dbus_string_get_length (escaped);
   115   p = _dbus_string_get_const_udata (unescaped);
   116   end = p + _dbus_string_get_length (unescaped);
   193   for (i = 0; entries[i] != 
NULL; i++)
   194     dbus_address_entry_free (entries[i]);
   229   return _dbus_string_get_const_data (&entry->
method);
   257         return _dbus_string_get_const_data (values->
data);
   267 append_unescaped_value (
DBusString       *unescaped,
   279   p = _dbus_string_get_const_data (escaped) + escaped_start;
   280   end = p + escaped_len;
   300                               "In D-Bus address, percent character was not followed by two hex digits");
   313                                         _dbus_string_get_length (unescaped)))
   319                               "In D-Bus address, percent character was followed by characters other than hex digits");
   327                           "In D-Bus address, character '%c' should have been escaped\n",
   339     _DBUS_SET_OOM (error);
   369   int pos, end_pos, len, i;
   373   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
   379   len = _dbus_string_get_length (&str);
   384                     "Empty address '%s'", address);
   394       entry = create_entry ();
   406           dbus_address_entry_free (entry);
   429       while (pos < end_pos)
   431           int comma_pos, equals_pos;
   437               equals_pos == pos || equals_pos + 1 == comma_pos)
   440                               "'=' character not found or has no value following it");
   494               if (!append_unescaped_value (value, &str, equals_pos + 1,
   495                                            comma_pos - equals_pos - 1, error))
   544   entry_array [*array_len] = 
NULL;
   550       entry_array[i] = link->
data;
   556   *entry_result = entry_array;
   565       dbus_address_entry_free (link->
data);
   631   if (!append_unescaped_value (&unescaped, &escaped,
   632                                0, _dbus_string_get_length (&escaped),
   641     _DBUS_SET_OOM (error);
   651 #ifdef DBUS_ENABLE_EMBEDDED_TESTS   653 #ifndef DOXYGEN_SHOULD_SKIP_THIS   655 #include "dbus-test.h"   661   const char *unescaped;
   664 static const EscapeTest escape_tests[] = {
   665   { 
"abcde", 
"abcde" },
   670   { 
"abc%24", 
"abc$" },
   671   { 
"%24abc", 
"$abc" },
   672   { 
"abc%24abc", 
"abc$abc" },
   683   { 
"%c3%b6", 
"\xc3\xb6" }
   686 static const char* invalid_escaped_values[] = {
   700 _dbus_address_test (
void)
   710       const EscapeTest *test = &escape_tests[i];
   718       if (strcmp (escaped, test->escaped) != 0)
   720           _dbus_warn (
"Escaped '%s' as '%s' should have been '%s'",
   721                       test->unescaped, escaped, test->escaped);
   727       if (unescaped == 
NULL)
   735       if (strcmp (unescaped, test->unescaped) != 0)
   737           _dbus_warn (
"Unescaped '%s' as '%s' should have been '%s'",
   738                       test->escaped, unescaped, test->unescaped);
   753       if (unescaped != 
NULL)
   755           _dbus_warn (
"Should not have successfully unescaped '%s' to '%s'",
   756                       invalid_escaped_values[i], unescaped);
   768                            &entries, &len, &error))
 const char * message
public error message field 
#define NULL
A null pointer, defined appropriately for C or C++. 
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0(). 
#define _DBUS_ADDRESS_OPTIONALLY_ESCAPED_BYTE(b)
TRUE if the byte need not be escaped when found in a dbus address. 
#define dbus_new(type, count)
Safe macro for using dbus_malloc(). 
DBusString method
The address type (unix, tcp, etc.) 
#define _dbus_assert(condition)
Aborts with an error message if the condition is false. 
#define DBUS_ERROR_INIT
Expands to a suitable initializer for a DBusError on the stack. 
void * data
Data stored at this element. 
const char * dbus_address_entry_get_method(DBusAddressEntry *entry)
Returns the method string of an address entry. 
void dbus_error_free(DBusError *error)
Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...
void dbus_address_entries_free(DBusAddressEntry **entries)
Frees a NULL-terminated array of address entries. 
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a 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...
#define _dbus_list_get_next_link(list, link)
Gets the next link in the list, or NULL if there are no more links. 
const char * dbus_address_entry_get_value(DBusAddressEntry *entry, const char *key)
Returns a value from a key of an entry. 
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0(). 
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_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE. 
void _dbus_string_init_const(DBusString *str, const char *value)
Initializes a constant string. 
void _dbus_warn(const char *format,...)
Prints a warning message to stderr. 
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list. 
Internals of DBusAddressEntry. 
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. 
Object representing an exception. 
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...
#define DBUS_ERROR_BAD_ADDRESS
A D-Bus bus address was malformed. 
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError. 
#define _DBUS_N_ELEMENTS(array)
Computes the number of elements in a fixed-size array using sizeof(). 
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_free(DBusString *str)
Frees a string created by _dbus_string_init(). 
#define TRUE
Expands to "1". 
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called. 
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. 
DBusList * keys
List of keys. 
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. 
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_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 ...
int _dbus_list_get_length(DBusList **list)
Gets the length of a list. 
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation. 
DBusList * _dbus_list_get_first_link(DBusList **list)
Gets the first link in the list. 
#define FALSE
Expands to "0". 
dbus_bool_t _dbus_string_set_length(DBusString *str, int length)
Sets the length of a 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_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_error_is_set(const DBusError *error)
Checks whether an error occurred (the error is set). 
dbus_bool_t dbus_parse_address(const char *address, DBusAddressEntry ***entry_result, int *array_len, DBusError *error)
Parses an address string of the form: 
void _dbus_list_clear(DBusList **list)
Frees all links in the list and sets the list head to NULL. 
DBusList * values
List of values.