X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-common%2Fdbus.c;h=ac54848772d0f36b1eb9f55b19b0f44b6eac0e57;hb=2aa690d481dba89652820faadeed15c8ad896041;hp=cebf56d51a8a288fb4003a2bfc2dd9e16e91d739;hpb=f6712902a92eb82b6c8d7e7fd0980a20a716fa0d;p=catta diff --git a/avahi-common/dbus.c b/avahi-common/dbus.c index cebf56d..ac54848 100644 --- a/avahi-common/dbus.c +++ b/avahi-common/dbus.c @@ -56,7 +56,7 @@ static const char * const table[- AVAHI_ERR_MAX] = { AVAHI_DBUS_ERR_ACCESS_DENIED, AVAHI_DBUS_ERR_INVALID_OPERATION, AVAHI_DBUS_ERR_DBUS_ERROR, - AVAHI_DBUS_ERR_NOT_CONNECTED, + AVAHI_DBUS_ERR_DISCONNECTED, AVAHI_DBUS_ERR_NO_MEMORY, AVAHI_DBUS_ERR_INVALID_OBJECT, AVAHI_DBUS_ERR_NO_DAEMON, @@ -83,11 +83,41 @@ static const char * const table[- AVAHI_ERR_MAX] = { AVAHI_DBUS_ERR_DNS_NOTZONE, AVAHI_DBUS_ERR_INVALID_RDATA, AVAHI_DBUS_ERR_INVALID_DNS_CLASS, - AVAHI_DBUS_ERR_INVALID_DNS_TYPE + AVAHI_DBUS_ERR_INVALID_DNS_TYPE, + AVAHI_DBUS_ERR_NOT_SUPPORTED, + + AVAHI_DBUS_ERR_NOT_PERMITTED, + AVAHI_DBUS_ERR_INVALID_ARGUMENT, + AVAHI_DBUS_ERR_IS_EMPTY, + AVAHI_DBUS_ERR_NO_CHANGE +}; + +struct error_map { + const char *dbus_error; + int avahi_error; +}; + +static struct error_map error_map[] = { + { DBUS_ERROR_FAILED, AVAHI_ERR_FAILURE }, + { DBUS_ERROR_NO_MEMORY, AVAHI_ERR_NO_MEMORY }, + { DBUS_ERROR_SERVICE_UNKNOWN, AVAHI_ERR_NO_DAEMON }, + { DBUS_ERROR_BAD_ADDRESS, AVAHI_ERR_NO_DAEMON }, + { DBUS_ERROR_NOT_SUPPORTED, AVAHI_ERR_NOT_SUPPORTED }, + { DBUS_ERROR_LIMITS_EXCEEDED, AVAHI_ERR_TOO_MANY_OBJECTS }, + { DBUS_ERROR_ACCESS_DENIED, AVAHI_ERR_ACCESS_DENIED }, + { DBUS_ERROR_AUTH_FAILED, AVAHI_ERR_ACCESS_DENIED }, + { DBUS_ERROR_NO_SERVER, AVAHI_ERR_NO_DAEMON }, + { DBUS_ERROR_TIMEOUT, AVAHI_ERR_TIMEOUT }, + { DBUS_ERROR_NO_NETWORK, AVAHI_ERR_NO_NETWORK }, + { DBUS_ERROR_DISCONNECTED, AVAHI_ERR_DISCONNECTED }, + { DBUS_ERROR_INVALID_ARGS, AVAHI_ERR_INVALID_ARGUMENT }, + { DBUS_ERROR_TIMED_OUT, AVAHI_ERR_TIMEOUT }, + { NULL, 0 } }; int avahi_error_dbus_to_number(const char *s) { int e; + const struct error_map *m; assert(s); @@ -95,6 +125,10 @@ int avahi_error_dbus_to_number(const char *s) { if (strcmp(s, table[-e]) == 0) return e; + for (m = error_map; m->dbus_error; m++) + if (strcmp(m->dbus_error, s) == 0) + return m->avahi_error; + return AVAHI_ERR_DBUS_ERROR; }