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