1 /*
2 * Copyright (c) 2009-2011 NLNet Labs. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
19 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
21 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
23 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 */
26
27 /**
28 *
29 * Status.
30 */
31
32 #include "config.h"
33 #include "status.h"
34
35 #include <stdlib.h>
36
37 ods_lookup_table ods_status_str[] = {
38 { ODS_STATUS_OK, "All OK" },
39 { ODS_STATUS_EOF, "End of file" },
40 { ODS_STATUS_NOTIMPL, "Not implemented"},
41 { ODS_STATUS_UPTODATE, "Up to date"},
42
43 { ODS_STATUS_ASSERT_ERR, "Assertion error"},
44 { ODS_STATUS_CFG_ERR, "Configuration error"},
45 { ODS_STATUS_CHDIR_ERR, "Change directory failed"},
46 { ODS_STATUS_CHROOT_ERR, "Change root failed"},
47 { ODS_STATUS_CMDHANDLER_ERR, "Command handler error"},
48 { ODS_STATUS_XFRHANDLER_ERR, "XFR handler error"},
49 { ODS_STATUS_CONFLICT_ERR, "Conflict detected"},
50 { ODS_STATUS_ERR, "General error"},
51 { ODS_STATUS_FOPEN_ERR, "Unable to open file"},
52 { ODS_STATUS_FSEEK_ERR, "fseek() failed"},
53 { ODS_STATUS_FORK_ERR, "fork() failed"},
54 { ODS_STATUS_FREAD_ERR, "Unable to read file"},
55 { ODS_STATUS_FWRITE_ERR, "Unable to write file"},
56 { ODS_STATUS_HSM_ERR, "HSM error"},
57 { ODS_STATUS_INSECURE, "Insecure"},
58 { ODS_STATUS_MALLOC_ERR, "Memory allocation error"},
59 { ODS_STATUS_RENAME_ERR, "Unable to rename file"},
60 { ODS_STATUS_UNLINK_ERR, "Unable to unlink file"},
61
62 { ODS_STATUS_SOCK_BIND, "Unable to bind socket"},
63 { ODS_STATUS_SOCK_FCNTL_NONBLOCK, "Unable to set socket to nonblocking"},
64 { ODS_STATUS_SOCK_GETADDRINFO, "Unable to retrieve address information"},
65 { ODS_STATUS_SOCK_LISTEN, "Unable to listen on socket"},
66 { ODS_STATUS_SOCK_SETSOCKOPT_V6ONLY, "Unable to set socket to v6only"},
67 { ODS_STATUS_SOCK_SOCKET_UDP, "Unable to create udp socket"},
68 { ODS_STATUS_SOCK_SOCKET_TCP, "Unable to create tcp socket"},
69
70 { ODS_STATUS_ACL_SUBNET_BAD_RANGE, "Bad subnet range"},
71 { ODS_STATUS_ACL_SUBNET_OUT_RANGE, "Subnet out of range"},
72
73 { ODS_STATUS_PARSE_ERR, "Parse error"},
74 { ODS_STATUS_PRIVDROP_ERR, "Unable to drop privileges"},
75 { ODS_STATUS_RNG_ERR, "RelaxNG error"},
76 { ODS_STATUS_SETSID_ERR, "setsid() failed"},
77 { ODS_STATUS_UNCHANGED, "Status unchanged"},
78 { ODS_STATUS_WRITE_PIDFILE_ERR, "Unable to write process id to pidfile"},
79 { ODS_STATUS_XML_ERR, "XML error"},
80
81 { ODS_STATUS_XFR_NOT_READY, "Incoming zone transfer not ready"},
82 { ODS_STATUS_SKIPDNAME, "Failed to skip domain name"},
83 { ODS_STATUS_BUFAVAIL, "Insufficient space available in buffer"},
84 { ODS_STATUS_PARSESOA, "Failed to parse SOA RR"},
85 { ODS_STATUS_REQAXFR, "Got IXFR, but AXFR required"},
86 { ODS_STATUS_INSERIAL, "Serial mismatch"},
87 { ODS_STATUS_XFRBADFORM, "XFR bad format"},
88 { ODS_STATUS_XFRINCOMPLETE, "XFR on disk incomplete (in progress?)"},
89
90 { ODS_STATUS_DB_ERR , "Database error"},
91
92 { 0, NULL }
93 };
94
95 ods_lookup_table*
ods_lookup_by_id(ods_lookup_table * table,int id)96 ods_lookup_by_id(ods_lookup_table *table, int id)
97 {
98 while (table->name != NULL) {
99 if (table->id == id) {
100 return table;
101 }
102 table++;
103 }
104 return NULL;
105 }
106
107
108 /**
109 * Look up a descriptive text by each status.
110 *
111 */
112 const char *
ods_status2str(ods_status status)113 ods_status2str(ods_status status)
114 {
115 ods_lookup_table *lt;
116 lt = ods_lookup_by_id(ods_status_str, status);
117 if (lt) {
118 return lt->name;
119 }
120 return "(Error code unknown)";
121 }
122
123