D-Bus  1.9.2
Typedefs | Functions

Parsing addresses of D-Bus servers. More...

Typedefs

typedef struct DBusAddressEntry DBusAddressEntry
 Opaque type representing one of the semicolon-separated items in an address.
 

Functions

void dbus_address_entries_free (DBusAddressEntry **entries)
 Frees a NULL-terminated array of address entries. More...
 
const char * dbus_address_entry_get_method (DBusAddressEntry *entry)
 Returns the method string of an address entry. More...
 
const char * dbus_address_entry_get_value (DBusAddressEntry *entry, const char *key)
 Returns a value from a key of an entry. More...
 
dbus_bool_t dbus_parse_address (const char *address, DBusAddressEntry ***entry, int *array_len, DBusError *error)
 Parses an address string of the form: More...
 
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. More...
 
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. More...
 

Detailed Description

Parsing addresses of D-Bus servers.

Function Documentation

DBUS_EXPORT void dbus_address_entries_free ( DBusAddressEntry **  entries)

Frees a NULL-terminated array of address entries.

Parameters
entriesthe array.

Definition at line 189 of file dbus-address.c.

References dbus_free(), and NULL.

Referenced by dbus_server_listen().

DBUS_EXPORT const char * dbus_address_entry_get_method ( DBusAddressEntry entry)

Returns the method string of an address entry.

For example, given the address entry "tcp:host=example.com" it would return the string "tcp"

Parameters
entrythe entry.
Returns
a string describing the method. This string must not be freed.

Definition at line 227 of file dbus-address.c.

References _dbus_string_get_const_data(), and DBusAddressEntry::method.

Referenced by _dbus_server_listen_platform_specific(), _dbus_server_listen_socket(), _dbus_transport_open_platform_specific(), _dbus_transport_open_socket(), and dbus_server_listen().

DBUS_EXPORT const char * dbus_address_entry_get_value ( DBusAddressEntry entry,
const char *  key 
)

Returns a value from a key of an entry.

For example, given the address "tcp:host=example.com,port=8073" if you asked for the key "host" you would get the value "example.com"

The returned value is already unescaped.

Parameters
entrythe entry.
keythe key.
Returns
the key value. This string must not be freed.

Definition at line 244 of file dbus-address.c.

References _dbus_assert, _dbus_list_get_first_link(), _dbus_list_get_next_link, _dbus_string_equal_c_str(), _dbus_string_get_const_data(), DBusList::data, DBusAddressEntry::keys, NULL, and DBusAddressEntry::values.

Referenced by _dbus_server_listen_platform_specific(), _dbus_server_listen_socket(), _dbus_transport_open(), _dbus_transport_open_platform_specific(), and _dbus_transport_open_socket().

DBUS_EXPORT 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.

Parameters
valuethe unescaped value
Returns
newly-allocated escaped value or NULL if no memory

Definition at line 583 of file dbus-address.c.

References _dbus_address_append_escaped(), _dbus_string_free(), _dbus_string_init(), _dbus_string_init_const(), _dbus_string_steal_data(), and NULL.

DBUS_EXPORT 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.

Note that dbus_address_entry_get_value() returns an already-unescaped value.

Parameters
valuethe escaped value
errorerror to set if the unescaping fails
Returns
newly-allocated unescaped value or NULL if no memory

Definition at line 617 of file dbus-address.c.

References _dbus_assert, _dbus_string_free(), _dbus_string_get_length(), _dbus_string_init(), _dbus_string_init_const(), _dbus_string_steal_data(), dbus_error_is_set(), and NULL.

DBUS_EXPORT dbus_bool_t dbus_parse_address ( const char *  address,
DBusAddressEntry ***  entry,
int *  array_len,
DBusError error 
)

Parses an address string of the form:

method:key=value,key=value;method:key=value

See the D-Bus specification for complete docs on the format.

When connecting to an address, the first address entries in the semicolon-separated list should be tried first.

Parameters
addressthe address.
entryreturn location to an array of entries.
array_lenreturn location for array length.
erroraddress where an error can be returned.
Returns
TRUE on success, FALSE otherwise.

Definition at line 363 of file dbus-address.c.

References _dbus_assert, _dbus_list_append(), _dbus_list_clear(), _dbus_list_get_first_link(), _dbus_list_get_length(), _dbus_list_get_next_link, _dbus_string_copy_len(), _dbus_string_find(), _dbus_string_find_to(), _dbus_string_free(), _dbus_string_get_length(), _dbus_string_init(), _dbus_string_init_const(), DBusList::data, DBUS_ERROR_BAD_ADDRESS, dbus_error_is_set(), DBUS_ERROR_NO_MEMORY, dbus_free(), dbus_new, dbus_new0, dbus_set_error(), FALSE, DBusAddressEntry::keys, DBusAddressEntry::method, NULL, TRUE, and DBusAddressEntry::values.

Referenced by dbus_server_listen().