Commit ce4fd314 authored by Havoc Pennington's avatar Havoc Pennington

2003-03-24 Havoc Pennington <hp@redhat.com>

	* dbus/dbus-sysdeps.c (_dbus_set_fd_nonblocking): move to this
	file

	* dbus/dbus-errors.c (dbus_set_error, dbus_set_error_const): allow
	NULL argument for "message" if the error is a well-known one,
	fill in a generic message in this case.

	* dbus/dbus-errors.h (DBusResultCode): Kill DBusResultCode in
	favor of DBusError

	* bus/test.c (bus_test_flush_bus): add

	* bus/policy.c (bus_policy_test): test code stub
parent 44fff656
2003-03-24 Havoc Pennington <hp@redhat.com>
* dbus/dbus-sysdeps.c (_dbus_set_fd_nonblocking): move to this
file
* dbus/dbus-errors.c (dbus_set_error, dbus_set_error_const): allow
NULL argument for "message" if the error is a well-known one,
fill in a generic message in this case.
* dbus/dbus-errors.h (DBusResultCode): Kill DBusResultCode in
favor of DBusError
* bus/test.c (bus_test_flush_bus): add
* bus/policy.c (bus_policy_test): test code stub
2003-03-24 Havoc Pennington <hp@pobox.com>
* bus/connection.c (bus_connections_setup_connection): set up
......
......@@ -143,7 +143,6 @@ bus_context_new (const char *address,
DBusError *error)
{
BusContext *context;
DBusResultCode result;
context = dbus_new0 (BusContext, 1);
if (context == NULL)
......@@ -161,14 +160,9 @@ bus_context_new (const char *address,
goto failed;
}
context->server = dbus_server_listen (address, &result);
context->server = dbus_server_listen (address, error);
if (context->server == NULL)
{
dbus_set_error (error, DBUS_ERROR_FAILED,
"Failed to start server on %s: %s\n",
address, dbus_result_to_string (result));
goto failed;
}
goto failed;
context->activation = bus_activation_new (context, address, service_dirs,
error);
......
......@@ -441,22 +441,6 @@ typedef dbus_bool_t (* Check2Func) (BusContext *context,
static dbus_bool_t check_no_leftovers (BusContext *context);
static void
flush_bus (BusContext *context)
{
/* This is race condition city, obviously. since we're all in one
* process we can't block, we just have to wait for data we put in
* one end of the debug pipe to come out the other end...
* a more robust setup would be good.
*/
while (bus_loop_iterate (FALSE))
;
_dbus_sleep_milliseconds (15);
while (bus_loop_iterate (FALSE))
;
}
typedef struct
{
const char *expected_service_name;
......@@ -549,7 +533,7 @@ kill_client_connection (BusContext *context,
/* kick in the disconnect handler that unrefs the connection */
dbus_connection_disconnect (connection);
flush_bus (context);
bus_test_flush_bus (context);
_dbus_assert (bus_test_client_listed (connection));
......@@ -742,7 +726,7 @@ check_hello_message (BusContext *context,
dbus_message_unref (message);
message = NULL;
flush_bus (context);
bus_test_flush_bus (context);
if (!dbus_connection_get_is_connected (connection))
{
......@@ -891,13 +875,15 @@ static dbus_bool_t
check_hello_connection (BusContext *context)
{
DBusConnection *connection;
DBusResultCode result;
DBusError error;
result = DBUS_RESULT_SUCCESS;
connection = dbus_connection_open ("debug-pipe:name=test-server", &result);
dbus_error_init (&error);
connection = dbus_connection_open ("debug-pipe:name=test-server", &error);
if (connection == NULL)
{
_dbus_assert (result != DBUS_RESULT_SUCCESS);
_DBUS_ASSERT_ERROR_IS_SET (&error);
dbus_error_free (&error);
return TRUE;
}
......@@ -980,7 +966,6 @@ bus_dispatch_test (const DBusString *test_data_dir)
DBusConnection *foo;
DBusConnection *bar;
DBusConnection *baz;
DBusResultCode result;
dbus_error_init (&error);
context = bus_context_new ("debug-pipe:name=test-server",
......@@ -989,7 +974,7 @@ bus_dispatch_test (const DBusString *test_data_dir)
if (context == NULL)
_dbus_assert_not_reached ("could not alloc context");
foo = dbus_connection_open ("debug-pipe:name=test-server", &result);
foo = dbus_connection_open ("debug-pipe:name=test-server", &error);
if (foo == NULL)
_dbus_assert_not_reached ("could not alloc connection");
......@@ -999,7 +984,7 @@ bus_dispatch_test (const DBusString *test_data_dir)
if (!check_hello_message (context, foo))
_dbus_assert_not_reached ("hello message failed");
bar = dbus_connection_open ("debug-pipe:name=test-server", &result);
bar = dbus_connection_open ("debug-pipe:name=test-server", &error);
if (bar == NULL)
_dbus_assert_not_reached ("could not alloc connection");
......@@ -1009,7 +994,7 @@ bus_dispatch_test (const DBusString *test_data_dir)
if (!check_hello_message (context, bar))
_dbus_assert_not_reached ("hello message failed");
baz = dbus_connection_open ("debug-pipe:name=test-server", &result);
baz = dbus_connection_open ("debug-pipe:name=test-server", &error);
if (baz == NULL)
_dbus_assert_not_reached ("could not alloc connection");
......
......@@ -23,6 +23,7 @@
#include "policy.h"
#include "services.h"
#include "test.h"
#include <dbus/dbus-list.h>
#include <dbus/dbus-internals.h>
......@@ -421,3 +422,18 @@ bus_policy_check_can_own (BusPolicy *policy,
return allowed;
}
#ifdef DBUS_BUILD_TESTS
dbus_bool_t
bus_policy_test (const DBusString *test_data_dir)
{
/* This doesn't do anything for now because I decided to do it in
* dispatch.c instead by having some of the clients in dispatch.c
* have particular policies applied to them.
*/
return TRUE;
}
#endif /* DBUS_BUILD_TESTS */
......@@ -267,4 +267,22 @@ bus_test_client_listed (DBusConnection *connection)
return FALSE;
}
void
bus_test_flush_bus (BusContext *context)
{
/* This is race condition city, obviously. since we're all in one
* process we can't block, we just have to wait for data we put in
* one end of the debug pipe to come out the other end...
* a more robust setup would be good. Blocking on the other
* end of pipes we've pushed data into or something.
*/
while (bus_loop_iterate (FALSE))
;
_dbus_sleep_milliseconds (15);
while (bus_loop_iterate (FALSE))
;
}
#endif
......@@ -33,10 +33,12 @@
#include "connection.h"
dbus_bool_t bus_dispatch_test (const DBusString *test_data_dir);
dbus_bool_t bus_policy_test (const DBusString *test_data_dir);
dbus_bool_t bus_setup_debug_client (DBusConnection *connection);
void bus_test_clients_foreach (BusConnectionForeachFunction function,
void *data);
dbus_bool_t bus_test_client_listed (DBusConnection *connection);
void bus_test_flush_bus (BusContext *context);
#endif
......
......@@ -177,13 +177,15 @@ dbus_bool_t
dbus_parse_address (const char *address,
DBusAddressEntry ***entry,
int *array_len,
DBusResultCode *result)
DBusError *error)
{
DBusString str;
int pos, end_pos, len, i;
DBusList *entries, *link;
DBusAddressEntry **entry_array;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
_dbus_string_init_const (&str, address);
entries = NULL;
......@@ -199,7 +201,7 @@ dbus_parse_address (const char *address,
entry = create_entry ();
if (!entry)
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
goto error;
}
......@@ -207,7 +209,7 @@ dbus_parse_address (const char *address,
/* Append the entry */
if (!_dbus_list_append (&entries, entry))
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
dbus_address_entry_free (entry);
goto error;
}
......@@ -219,13 +221,13 @@ dbus_parse_address (const char *address,
/* Look for the colon : */
if (!_dbus_string_find_to (&str, pos, end_pos, ":", &found_pos))
{
dbus_set_result (result, DBUS_RESULT_BAD_ADDRESS);
dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS, "Address does not contain a colon");
goto error;
}
if (!_dbus_string_copy_len (&str, pos, found_pos - pos, &entry->method, 0))
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
goto error;
}
......@@ -241,8 +243,9 @@ dbus_parse_address (const char *address,
if (!_dbus_string_find (&str, pos, "=", &equals_pos) ||
equals_pos == pos || equals_pos + 1 == end_pos)
{
dbus_set_result (result, DBUS_RESULT_BAD_ADDRESS);
goto error;
dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
"'=' character not found or has no value following it");
goto error;
}
else
{
......@@ -253,21 +256,21 @@ dbus_parse_address (const char *address,
if (!key)
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
goto error;
}
value = dbus_new0 (DBusString, 1);
if (!value)
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
dbus_free (key);
goto error;
}
if (!_dbus_string_init (key, _DBUS_INT_MAX))
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
dbus_free (key);
dbus_free (value);
......@@ -276,7 +279,7 @@ dbus_parse_address (const char *address,
if (!_dbus_string_init (value, _DBUS_INT_MAX))
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_string_free (key);
dbus_free (key);
......@@ -286,7 +289,7 @@ dbus_parse_address (const char *address,
if (!_dbus_string_copy_len (&str, pos, equals_pos - pos, key, 0))
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_string_free (key);
_dbus_string_free (value);
......@@ -297,7 +300,7 @@ dbus_parse_address (const char *address,
if (!_dbus_string_copy_len (&str, equals_pos + 1, comma_pos - equals_pos - 1, value, 0))
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_string_free (key);
_dbus_string_free (value);
......@@ -308,7 +311,7 @@ dbus_parse_address (const char *address,
if (!_dbus_list_append (&entry->keys, key))
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_string_free (key);
_dbus_string_free (value);
......@@ -319,7 +322,7 @@ dbus_parse_address (const char *address,
if (!_dbus_list_append (&entry->values, value))
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_string_free (value);
dbus_free (value);
......@@ -339,7 +342,7 @@ dbus_parse_address (const char *address,
if (!entry_array)
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
goto error;
}
......@@ -358,7 +361,6 @@ dbus_parse_address (const char *address,
_dbus_list_clear (&entries);
*entry = entry_array;
dbus_set_result (result, DBUS_RESULT_SUCCESS);
return TRUE;
error:
......@@ -387,10 +389,12 @@ _dbus_address_test (void)
{
DBusAddressEntry **entries;
int len;
DBusResultCode result;
DBusError error;
dbus_error_init (&error);
if (!dbus_parse_address ("unix:path=/tmp/foo;debug:name=test,sliff=sloff;",
&entries, &len, &result))
&entries, &len, &error))
_dbus_assert_not_reached ("could not parse address");
_dbus_assert (len == 2);
_dbus_assert (strcmp (dbus_address_entry_get_value (entries[0], "path"), "/tmp/foo") == 0);
......@@ -400,26 +404,40 @@ _dbus_address_test (void)
dbus_address_entries_free (entries);
/* Different possible errors */
if (dbus_parse_address ("foo", &entries, &len, &result))
if (dbus_parse_address ("foo", &entries, &len, &error))
_dbus_assert_not_reached ("Parsed incorrect address.");
if (dbus_parse_address ("foo:bar", &entries, &len, &result))
else
dbus_error_free (&error);
if (dbus_parse_address ("foo:bar", &entries, &len, &error))
_dbus_assert_not_reached ("Parsed incorrect address.");
if (dbus_parse_address ("foo:bar,baz", &entries, &len, &result))
else
dbus_error_free (&error);
if (dbus_parse_address ("foo:bar,baz", &entries, &len, &error))
_dbus_assert_not_reached ("Parsed incorrect address.");
if (dbus_parse_address ("foo:bar=foo,baz", &entries, &len, &result))
else
dbus_error_free (&error);
if (dbus_parse_address ("foo:bar=foo,baz", &entries, &len, &error))
_dbus_assert_not_reached ("Parsed incorrect address.");
if (dbus_parse_address ("foo:bar=foo;baz", &entries, &len, &result))
else
dbus_error_free (&error);
if (dbus_parse_address ("foo:bar=foo;baz", &entries, &len, &error))
_dbus_assert_not_reached ("Parsed incorrect address.");
if (dbus_parse_address ("foo:=foo", &entries, &len, &result))
else
dbus_error_free (&error);
if (dbus_parse_address ("foo:=foo", &entries, &len, &error))
_dbus_assert_not_reached ("Parsed incorrect address.");
if (dbus_parse_address ("foo:foo=", &entries, &len, &result))
else
dbus_error_free (&error);
if (dbus_parse_address ("foo:foo=", &entries, &len, &error))
_dbus_assert_not_reached ("Parsed incorrect address.");
else
dbus_error_free (&error);
return TRUE;
}
......
......@@ -35,7 +35,7 @@ typedef struct DBusAddressEntry DBusAddressEntry;
dbus_bool_t dbus_parse_address (const char *address,
DBusAddressEntry ***entry,
int *array_len,
DBusResultCode *result);
DBusError *error);
const char *dbus_address_entry_get_value (DBusAddressEntry *entry,
const char *key);
const char *dbus_address_entry_get_method (DBusAddressEntry *entry);
......
......@@ -184,6 +184,8 @@ dbus_bus_register (DBusConnection *connection,
char *name;
BusData *bd;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
bd = ensure_bus_data (connection);
if (bd == NULL)
{
......@@ -363,6 +365,8 @@ dbus_bus_service_exists (DBusConnection *connection,
{
DBusMessage *message, *reply;
unsigned int exists;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
message = dbus_message_new (DBUS_SERVICE_DBUS,
DBUS_MESSAGE_SERVICE_EXISTS);
......
......@@ -800,19 +800,24 @@ _dbus_connection_set_connection_counter (DBusConnection *connection,
* in the reason for failure.
*
* @param address the address.
* @param result address where a result code can be returned.
* @param error address where an error can be returned.
* @returns new connection, or #NULL on failure.
*/
DBusConnection*
dbus_connection_open (const char *address,
DBusResultCode *result)
DBusError *error)
{
DBusConnection *connection;
DBusTransport *transport;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
transport = _dbus_transport_open (address, result);
transport = _dbus_transport_open (address, error);
if (transport == NULL)
return NULL;
{
_DBUS_ASSERT_ERROR_IS_SET (error);
return NULL;
}
connection = _dbus_connection_new_for_transport (transport);
......@@ -820,7 +825,7 @@ dbus_connection_open (const char *address,
if (connection == NULL)
{
dbus_set_result (result, DBUS_RESULT_NO_MEMORY);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
return NULL;
}
......@@ -1424,6 +1429,8 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection,
long end_tv_sec, end_tv_usec;
long tv_sec, tv_usec;
DBusDispatchStatus status;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
if (timeout_milliseconds == -1)
timeout_milliseconds = DEFAULT_TIMEOUT_VALUE;
......
......@@ -81,7 +81,7 @@ typedef dbus_bool_t (* DBusAllowUnixUserFunction) (DBusConnection *connection,
void *data);
DBusConnection* dbus_connection_open (const char *address,
DBusResultCode *result);
DBusError *error);
void dbus_connection_ref (DBusConnection *connection);
void dbus_connection_unref (DBusConnection *connection);
void dbus_connection_disconnect (DBusConnection *connection);
......
......@@ -25,6 +25,7 @@
#include "dbus-internals.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
/**
* @defgroup DBusErrors Error reporting
......@@ -65,73 +66,50 @@ typedef struct
} DBusRealError;
/**
* Set a result code at a result code location,
* if code_address is not #NULL.
* Returns a longer message describing an error name.
* If the error name is unknown, returns the name
* itself.
*
* @param code_address place to store the result code.
* @param code the result code itself.
* @param error the error to describe
* @returns a constant string describing the error.
*/
void
dbus_set_result (DBusResultCode *code_address,
DBusResultCode code)
{
if (code_address)
*code_address = code;
}
/**
* Returns a string describing the given result code.
*
* @param code the result code to describe.
* @returns a constant string describing the code.
*/
const char*
dbus_result_to_string (DBusResultCode code)
static const char*
message_from_error (const char *error)
{
/* This is a switch to the compiler will complain if we
* aren't handling some codes
*/
switch (code)
{
case DBUS_RESULT_SUCCESS:
return "Success";
case DBUS_RESULT_FAILED:
return "Unknown error";
case DBUS_RESULT_NO_MEMORY:
return "Not enough memory available";
case DBUS_RESULT_IO_ERROR:
return "Error reading or writing data";
case DBUS_RESULT_BAD_ADDRESS:
return "Could not parse address";
case DBUS_RESULT_NOT_SUPPORTED:
return "Feature not supported";
case DBUS_RESULT_LIMITS_EXCEEDED:
return "Resource limits exceeded";
case DBUS_RESULT_ACCESS_DENIED:
return "Permission denied";
case DBUS_RESULT_AUTH_FAILED:
return "Could not authenticate to server";
case DBUS_RESULT_NO_SERVER:
return "No server";
case DBUS_RESULT_TIMEOUT:
return "Connection timed out";
case DBUS_RESULT_NO_NETWORK:
return "Network unavailable";
case DBUS_RESULT_ADDRESS_IN_USE:
return "Address already in use";
case DBUS_RESULT_DISCONNECTED:
return "Disconnected.";
case DBUS_RESULT_INVALID_ARGS:
return "Invalid argumemts.";
case DBUS_RESULT_NO_REPLY:
return "Did not get a reply message.";
case DBUS_RESULT_FILE_NOT_FOUND:
return "File doesn't exist.";
/* no default, it would break our compiler warnings */
}
return "Invalid error code";
if (strcmp (error, DBUS_ERROR_FAILED) == 0)
return "Unknown error";
else if (strcmp (error, DBUS_ERROR_NO_MEMORY) == 0)
return "Not enough memory available";
else if (strcmp (error, DBUS_ERROR_IO_ERROR) == 0)
return "Error reading or writing data";
else if (strcmp (error, DBUS_ERROR_BAD_ADDRESS) == 0)
return "Could not parse address";
else if (strcmp (error, DBUS_ERROR_NOT_SUPPORTED) == 0)
return "Feature not supported";
else if (strcmp (error, DBUS_ERROR_LIMITS_EXCEEDED) == 0)
return "Resource limits exceeded";
else if (strcmp (error, DBUS_ERROR_ACCESS_DENIED) == 0)
return "Permission denied";
else if (strcmp (error, DBUS_ERROR_AUTH_FAILED) == 0)
return "Could not authenticate to server";
else if (strcmp (error, DBUS_ERROR_NO_SERVER) == 0)
return "No server";
else if (strcmp (error, DBUS_ERROR_TIMEOUT) == 0)
return "Connection timed out";
else if (strcmp (error, DBUS_ERROR_NO_NETWORK) == 0)
return "Network unavailable";
else if (strcmp (error, DBUS_ERROR_ADDRESS_IN_USE) == 0)
return "Address already in use";
else if (strcmp (error, DBUS_ERROR_DISCONNECTED) == 0)
return "Disconnected.";
else if (strcmp (error, DBUS_ERROR_INVALID_ARGS) == 0)
return "Invalid argumemts.";
else if (strcmp (error, DBUS_ERROR_NO_REPLY) == 0)
return "Did not get a reply message.";
else if (strcmp (error, DBUS_ERROR_FILE_NOT_FOUND) == 0)
return "File doesn't exist.";
else
return error;
}
/**
......@@ -179,7 +157,8 @@ dbus_error_free (DBusError *error)
/**
* Assigns an error name and message to a DBusError.
* Does nothing if error is #NULL.
* Does nothing if error is #NULL. The message may
* be NULL only if the error is DBUS_ERROR_NO_MEMORY.
*
* @param error the error.
* @param name the error name (not copied!!!)
......@@ -199,7 +178,9 @@ dbus_set_error_const (DBusError *error,
_dbus_assert (error->name == NULL);
_dbus_assert (error->message == NULL);
_dbus_assert (name != NULL);
_dbus_assert (message != NULL);
if (message == NULL)
message = message_from_error (name);
real = (DBusRealError *)error;
......@@ -280,6 +261,8 @@ dbus_error_is_set (const DBusError *error)
* Assigns an error name and message to a DBusError.
* Does nothing if error is #NULL.
*
* The format may be NULL only if the error is DBUS_ERROR_NO_MEMORY.
*
* If no memory can be allocated for the error message,
* an out-of-memory error message will be set instead.
*
......@@ -309,7 +292,9 @@ dbus_set_error (DBusError *error,
_dbus_assert (error->name == NULL);
_dbus_assert (error->message == NULL);
_dbus_assert (name != NULL);
_dbus_assert (format != NULL);
if (format == NULL)
format = message_from_error (name);
va_start (args, format);
/* Measure the message length */
......@@ -320,8 +305,7 @@ dbus_set_error (DBusError *error,
if (!message)
{
dbus_set_error_const (error, DBUS_ERROR_NO_MEMORY,
"Failed to allocate memory for error message.");
dbus_set_error_const (error, DBUS_ERROR_NO_MEMORY, NULL);
return;
}
......
......@@ -71,30 +71,6 @@ struct DBusError
#define DBUS_ERROR_FILE_NOT_FOUND "org.freedesktop.DBus.Error.FileNotFound"
#define DBUS_ERROR_UNKNOWN_MESSAGE "org.freedesktop.DBus.Error.UnknownMessage"
typedef enum
{
DBUS_RESULT_SUCCESS, /**< Operation was successful. */
DBUS_RESULT_FAILED, /**< Operation failed for unspecified reason. */
DBUS_RESULT_NO_MEMORY, /**< Operation failed for lack of memory. */
DBUS_RESULT_IO_ERROR, /**< Operation failed because of an IO error,
* typically the other end closed the
* connection.
*/
DBUS_RESULT_BAD_ADDRESS, /**< Address was bad, could not be parsed. */
DBUS_RESULT_NOT_SUPPORTED, /**< Feature is not supported. */
DBUS_RESULT_LIMITS_EXCEEDED, /**< Some kernel resource limit exceeded. */
DBUS_RESULT_ACCESS_DENIED, /**< Some sort of permissions/security problem. */
DBUS_RESULT_AUTH_FAILED, /**< Could not authenticate. */
DBUS_RESULT_NO_SERVER, /**< No one listening on the other end. */
DBUS_RESULT_TIMEOUT, /**< Timed out trying to connect. */
DBUS_RESULT_NO_NETWORK, /**< Can't find the network */
DBUS_RESULT_ADDRESS_IN_USE, /**< Someone's already using the address */
DBUS_RESULT_DISCONNECTED, /**< No more connection. */
DBUS_RESULT_INVALID_ARGS, /**< One or more invalid arguments encountered. */
DBUS_RESULT_NO_REPLY, /**< Did not get a reply message. */
DBUS_RESULT_FILE_NOT_FOUND /**< File doesn't exist */
} DBusResultCode;
void dbus_error_init (DBusError *error);
void dbus_error_free (DBusError *error);
void dbus_set_error (DBusError *error,
......@@ -110,11 +86,6 @@ dbus_bool_t dbus_error_has_name (const DBusError *error,
const char *name);
dbus_bool_t dbus_error_is_set (const DBusError *error);
void dbus_set_result (DBusResultCode *code_address,
DBusResultCode code);
const char* dbus_result_to_string (DBusResultCode code);
DBUS_END_DECLS;
#endif /* DBUS_ERROR_H */
......@@ -250,40 +250,6 @@ _dbus_strdup (const char *str)
return copy;
}
/**
* Sets a file descriptor to be nonblocking.
*
* @param fd the file descriptor.
* @param result address of result code.
* @returns #TRUE on success.
*/
dbus_bool_t
_dbus_set_fd_nonblocking (int fd,
DBusResultCode *result)
{
int val;
val = fcntl (fd, F_GETFL, 0);
if (val < 0)
{
dbus_set_result (result, _dbus_result_from_errno (errno));
_dbus_verbose ("Failed to get flags for fd %d: %s\n", fd,
_dbus_strerror (errno));
return FALSE;
}
if (fcntl (fd, F_SETFL, val | O_NONBLOCK) < 0)
{