]> git.meshlink.io Git - catta/blob - avahi-common/dbus.c
3ea7cbd40e2a8e9c5d146e2bc08784704895589b
[catta] / avahi-common / dbus.c
1 /* $Id$ */
2
3 /***
4   This file is part of avahi.
5  
6   avahi is free software; you can redistribute it and/or modify it
7   under the terms of the GNU Lesser General Public License as
8   published by the Free Software Foundation; either version 2.1 of the
9   License, or (at your option) any later version.
10  
11   avahi is distributed in the hope that it will be useful, but WITHOUT
12   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14   Public License for more details.
15  
16   You should have received a copy of the GNU Lesser General Public
17   License along with avahi; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19   USA.
20 ***/
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <stdlib.h>
27 #include <string.h>
28 #include <assert.h>
29
30 #include <avahi-common/error.h>
31 #include <avahi-common/dbus.h>
32
33 static const char * const table[- AVAHI_ERR_MAX] = {
34     AVAHI_DBUS_ERR_OK,
35     AVAHI_DBUS_ERR_FAILURE,
36     AVAHI_DBUS_ERR_BAD_STATE,
37     AVAHI_DBUS_ERR_INVALID_HOST_NAME,
38     AVAHI_DBUS_ERR_INVALID_DOMAIN_NAME,
39     AVAHI_DBUS_ERR_NO_NETWORK,
40     AVAHI_DBUS_ERR_INVALID_TTL,
41     AVAHI_DBUS_ERR_IS_PATTERN,
42     AVAHI_DBUS_ERR_COLLISION,
43     AVAHI_DBUS_ERR_INVALID_RECORD,
44     
45     AVAHI_DBUS_ERR_INVALID_SERVICE_NAME,
46     AVAHI_DBUS_ERR_INVALID_SERVICE_TYPE,
47     AVAHI_DBUS_ERR_INVALID_PORT,
48     AVAHI_DBUS_ERR_INVALID_KEY,
49     AVAHI_DBUS_ERR_INVALID_ADDRESS,
50     AVAHI_DBUS_ERR_TIMEOUT,
51     AVAHI_DBUS_ERR_TOO_MANY_CLIENTS,
52     AVAHI_DBUS_ERR_TOO_MANY_OBJECTS,
53     AVAHI_DBUS_ERR_TOO_MANY_ENTRIES,
54     AVAHI_DBUS_ERR_OS,
55     
56     AVAHI_DBUS_ERR_ACCESS_DENIED,
57     AVAHI_DBUS_ERR_INVALID_OPERATION,
58     AVAHI_DBUS_ERR_DBUS_ERROR,
59     AVAHI_DBUS_ERR_NOT_CONNECTED,
60     AVAHI_DBUS_ERR_NO_MEMORY,
61     AVAHI_DBUS_ERR_INVALID_OBJECT,
62     AVAHI_DBUS_ERR_NO_DAEMON,
63     AVAHI_DBUS_ERR_INVALID_INTERFACE,
64     AVAHI_DBUS_ERR_INVALID_PROTOCOL,
65     AVAHI_DBUS_ERR_INVALID_FLAGS,
66     
67     AVAHI_DBUS_ERR_NOT_FOUND,
68     AVAHI_DBUS_ERR_INVALID_CONFIG,
69     AVAHI_DBUS_ERR_VERSION_MISMATCH,
70     AVAHI_DBUS_ERR_INVALID_SERVICE_SUBTYPE,
71     AVAHI_DBUS_ERR_INVALID_PACKET,
72     AVAHI_DBUS_ERR_INVALID_DNS_ERROR,
73     AVAHI_DBUS_ERR_DNS_FORMERR,
74     AVAHI_DBUS_ERR_DNS_SERVFAIL,
75     AVAHI_DBUS_ERR_DNS_NXDOMAIN,
76     AVAHI_DBUS_ERR_DNS_NOTIMP,
77     
78     AVAHI_DBUS_ERR_DNS_REFUSED,
79     AVAHI_DBUS_ERR_DNS_YXDOMAIN,
80     AVAHI_DBUS_ERR_DNS_YXRRSET,
81     AVAHI_DBUS_ERR_DNS_NXRRSET,
82     AVAHI_DBUS_ERR_DNS_NOTAUTH,
83     AVAHI_DBUS_ERR_DNS_NOTZONE,
84     AVAHI_DBUS_ERR_INVALID_RDATA,
85     AVAHI_DBUS_ERR_INVALID_DNS_CLASS,
86     AVAHI_DBUS_ERR_INVALID_DNS_TYPE,
87     AVAHI_DBUS_ERR_NOT_SUPPORTED,
88
89     AVAHI_DBUS_ERR_NOT_PERMITTED
90 };
91
92 int avahi_error_dbus_to_number(const char *s) {
93     int e;
94
95     assert(s);
96
97     for (e = -1; e > AVAHI_ERR_MAX; e--)
98         if (strcmp(s, table[-e]) == 0)
99             return e;
100
101     return AVAHI_ERR_DBUS_ERROR;
102 }
103
104 const char *avahi_error_number_to_dbus(int error) {
105     assert(error > AVAHI_ERR_MAX);
106     assert(error < 1);
107
108     return table[-error];
109 }