26 #include "dbus-internals.h" 
   27 #include "dbus-server-debug-pipe.h" 
   28 #include "dbus-transport-socket.h" 
   29 #include "dbus-connection-internal.h" 
   30 #include "dbus-hash.h" 
   31 #include "dbus-string.h" 
   32 #include "dbus-protocol.h" 
   34 #ifdef DBUS_ENABLE_EMBEDDED_TESTS 
   50 typedef struct DBusServerDebugPipe DBusServerDebugPipe;
 
   56 struct DBusServerDebugPipe
 
   67 static int server_pipe_hash_refcount = 0;
 
   72   if (!server_pipe_hash)
 
   78       if (!server_pipe_hash)
 
   82   server_pipe_hash_refcount = 1;
 
   88 pipe_hash_unref (
void)
 
   93   server_pipe_hash_refcount -= 1;
 
   94   if (server_pipe_hash_refcount == 0)
 
   97       server_pipe_hash = 
NULL;
 
  104   DBusServerDebugPipe *debug_server = (DBusServerDebugPipe*) server;
 
  117   ((DBusServerDebugPipe*)server)->disconnected = 
TRUE;
 
  133 _dbus_server_debug_pipe_new (
const char     *server_name,
 
  136   DBusServerDebugPipe *debug_server;
 
  140   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
  142   if (!pipe_hash_ref ())
 
  152   debug_server = 
dbus_new0 (DBusServerDebugPipe, 1);
 
  153   if (debug_server == 
NULL)
 
  165   if (debug_server->name == 
NULL)
 
  169                                &debug_vtable, &address,
 
  182   _dbus_server_trace_ref (&debug_server->base, 0, 1, 
"debug_pipe_new");
 
  196     _DBUS_SET_OOM (error);
 
  210 _dbus_transport_debug_pipe_new (
const char     *server_name,
 
  220   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
  222   if (server_pipe_hash == 
NULL)
 
  230   if (server == 
NULL ||
 
  231       ((DBusServerDebugPipe*)server)->disconnected)
 
  253       _dbus_verbose (
"failed to create full duplex pipe\n");
 
  261   if (client_transport == 
NULL)
 
  272   _dbus_socket_invalidate (&client_fd);
 
  275                                                      &server->guid_hex, 
NULL);
 
  276   if (server_transport == 
NULL)
 
  284   _dbus_socket_invalidate (&server_fd);
 
  287                                             (
const char**) server->auth_mechanisms))
 
  297   server_transport = 
NULL;
 
  299   if (connection == 
NULL)
 
  309   if (server->new_connection_function)
 
  312       (* server->new_connection_function) (server, connection,
 
  313                                            server->new_connection_data);
 
  323   return client_transport;
 
  337 DBusServerListenResult
 
  348   if (strcmp (method, 
"debug-pipe") == 0)
 
  356           return DBUS_SERVER_LISTEN_BAD_ADDRESS;
 
  359       *server_p = _dbus_server_debug_pipe_new (name, error);
 
  363           _DBUS_ASSERT_ERROR_IS_CLEAR(error);
 
  364           return DBUS_SERVER_LISTEN_OK;
 
  368           _DBUS_ASSERT_ERROR_IS_SET(error);
 
  369           return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  374       _DBUS_ASSERT_ERROR_IS_CLEAR(error);
 
  375       return DBUS_SERVER_LISTEN_NOT_HANDLED;
 
  387 DBusTransportOpenResult
 
  397   if (strcmp (method, 
"debug-pipe") == 0)
 
  405           return DBUS_TRANSPORT_OPEN_BAD_ADDRESS;
 
  408       *transport_p = _dbus_transport_debug_pipe_new (name, error);
 
  410       if (*transport_p == 
NULL)
 
  412           _DBUS_ASSERT_ERROR_IS_SET (error);
 
  413           return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
 
  417           _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
  418           return DBUS_TRANSPORT_OPEN_OK;
 
  423       _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
  424       return DBUS_TRANSPORT_OPEN_NOT_HANDLED;
 
  
dbus_bool_t _dbus_server_init_base(DBusServer *server, const DBusServerVTable *vtable, const DBusString *address, DBusError *error)
Initializes the members of the DBusServer base class.
void _dbus_hash_table_unref(DBusHashTable *table)
Decrements the reference count for a hash table, freeing the hash table if the count reaches zero.
void dbus_server_unref(DBusServer *server)
Decrements the reference count of a DBusServer.
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init().
void * _dbus_hash_table_lookup_string(DBusHashTable *table, const char *key)
Looks up the value for a given string in a hash table of type DBUS_HASH_STRING.
const char * dbus_address_entry_get_method(DBusAddressEntry *entry)
Returns the method string of an address entry.
#define DBUS_ERROR_ADDRESS_IN_USE
Can't bind a socket since its address is in use (i.e.
Implementation details of DBusConnection.
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
DBusHashTable * _dbus_hash_table_new(DBusHashType type, DBusFreeFunction key_free_function, DBusFreeFunction value_free_function)
Constructs a new hash table.
@ DBUS_HASH_STRING
Hash keys are strings.
#define DBUS_ERROR_FAILED
A generic error; "something went wrong" - see the error message for more.
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
DBusConnection * _dbus_connection_new_for_transport(DBusTransport *transport)
Creates a new connection for the given transport.
Internals of DBusAddressEntry.
Object representing a transport such as a socket.
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
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.
const char * dbus_address_entry_get_value(DBusAddressEntry *entry, const char *key)
Returns a value from a key of an entry.
dbus_bool_t _dbus_transport_set_auth_mechanisms(DBusTransport *transport, const char **mechanisms)
Sets the SASL authentication mechanisms supported by this transport.
dbus_bool_t dbus_error_is_set(const DBusError *error)
Checks whether an error occurred (the error is set).
Internals of DBusHashTable.
void _dbus_transport_unref(DBusTransport *transport)
Decrements the reference count for the transport.
dbus_bool_t _dbus_close_socket(DBusSocket fd, DBusError *error)
Closes a socket.
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_assert(condition)
Virtual table to be implemented by all server "subclasses".
DBusServer * dbus_server_ref(DBusServer *server)
Increments the reference count of a DBusServer.
dbus_bool_t _dbus_socketpair(DBusSocket *fd1, DBusSocket *fd2, dbus_bool_t blocking, DBusError *error)
Creates pair of connect sockets (as in socketpair()).
char * _dbus_strdup(const char *str)
Duplicates a string.
Object representing an exception.
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
void dbus_connection_unref(DBusConnection *connection)
Decrements the reference count of a DBusConnection, and finalizes it if the count reaches zero.
void _dbus_server_finalize_base(DBusServer *server)
Finalizes the members of the DBusServer base class.
#define DBUS_ERROR_NO_SERVER
Unable to connect to server (probably caused by ECONNREFUSED on a socket).
void _dbus_string_init_const(DBusString *str, const char *value)
Initializes a constant string.
#define dbus_new0(type, count)
dbus_bool_t _dbus_hash_table_insert_string(DBusHashTable *table, char *key, void *value)
Creates a hash entry with the given key and value.
DBusTransport * _dbus_transport_new_for_socket(DBusSocket fd, const DBusString *server_guid, const DBusString *address)
Creates a new transport for the given socket file descriptor.
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
void _dbus_connection_close_if_only_one_ref(DBusConnection *connection)
Used internally to handle the semantics of dbus_server_set_new_connection_function().
dbus_uint32_t dbus_bool_t