Libinfo-173.tar.gz
[apple/libinfo.git] / netinfo.subproj / ni_error.c
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * NetInfo error status -> string conversion.
27 * Copyright (C) 1989 by NeXT, Inc.
28 */
29 #include <netinfo/ni.h>
30
31 static const struct {
32 ni_status status;
33 char *message;
34 } ni_errmsgs[] = {
35 { NI_OK, "Operation succeeded" },
36 { NI_BADID, "ID is invalid" },
37 { NI_STALE, "Write attempted on stale version of object" },
38 { NI_NOSPACE, "No space available for write operation" },
39 { NI_PERM, "Permission denied" },
40 { NI_NODIR, "No such directory" },
41 { NI_NOPROP, "No such property" },
42 { NI_NONAME, "No such name" },
43 { NI_NOTEMPTY, "Cannot delete name object with children" },
44 { NI_UNRELATED, "Object is not child of parent: cannot destroy" },
45 { NI_SERIAL, "Serialization error" },
46 { NI_NETROOT, "Hit network root domain" },
47 { NI_NORESPONSE, "No response from remote parent" },
48 { NI_RDONLY, "No writes allowed: all objects are read-only" },
49 { NI_SYSTEMERR, "Remote system error" },
50 { NI_ALIVE, "Can't regenerate: already in use" },
51 { NI_NOTMASTER, "Operation makes no sense on clone" },
52 { NI_CANTFINDADDRESS, "Can't find address of server" },
53 { NI_DUPTAG, "Duplicate domain tag: can't serve it" },
54 { NI_NOTAG, "No such tag" },
55 { NI_AUTHERROR, "Authentication error" },
56 { NI_NOUSER, "No such user" },
57 { NI_MASTERBUSY, "Master server is busy" },
58 { NI_INVALIDDOMAIN, "Invalid domain" },
59 { NI_BADOP, "Invalid operation on master" },
60 { NI_FAILED, "Communication failure" }
61 };
62
63 #define NI_ERRMSGSZ (sizeof(ni_errmsgs)/sizeof(ni_errmsgs[0]))
64
65 const char *
66 ni_error(
67 ni_status status
68 )
69 {
70 int i;
71
72 for (i = 0; i < NI_ERRMSGSZ; i++) {
73 if (ni_errmsgs[i].status == status) {
74 return (ni_errmsgs[i].message);
75 }
76 }
77 return ("(unknown error)");
78 }