Print this page
re #11201 nss: need local netgroup implementation
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/getent/getent.c
+++ new/usr/src/cmd/getent/getent.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright (c) 2014 Gary Mills
24 24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 25 * Use is subject to license terms.
26 26 */
27 27
28 28 #include <stdlib.h>
29 29 #include <stdio.h>
30 30 #include <string.h>
31 31 #include <locale.h>
32 32 #include <unistd.h>
33 33 #include "getent.h"
34 34
35 35 static const char *cmdname;
36 36
37 37 struct table {
38 38 char *name; /* name of the table */
39 39 int (*func)(const char **); /* function to do the lookup */
40 40 };
41 41
42 42 static struct table t[] = {
43 43 { "passwd", dogetpw },
|
↓ open down ↓ |
43 lines elided |
↑ open up ↑ |
44 44 { "shadow", dogetsp },
45 45 { "group", dogetgr },
46 46 { "hosts", dogethost },
47 47 { "ipnodes", dogetipnodes },
48 48 { "services", dogetserv },
49 49 { "protocols", dogetproto },
50 50 { "ethers", dogetethers },
51 51 { "networks", dogetnet },
52 52 { "netmasks", dogetnetmask },
53 53 { "project", dogetproject },
54 + { "netgroup", dogetnetgr },
54 55 { NULL, NULL }
55 56 };
56 57
57 58 static void usage(void) __NORETURN;
58 59
59 60 int
60 61 main(int argc, const char **argv)
61 62 {
62 63 struct table *p;
63 64
64 65 (void) setlocale(LC_ALL, "");
65 66
66 67 #if !defined(TEXT_DOMAIN)
67 68 #define TEXT_DOMAIN "SYS_TEXT"
68 69 #endif
69 70
70 71 (void) textdomain(TEXT_DOMAIN);
71 72
72 73 cmdname = argv[0];
73 74
74 75 if (argc < 2)
75 76 usage();
76 77
77 78 for (p = t; p->name != NULL; p++) {
78 79 if (strcmp(argv[1], p->name) == 0) {
79 80 int rc;
80 81
81 82 rc = (*p->func)(&argv[2]);
82 83 switch (rc) {
83 84 case EXC_SYNTAX:
84 85 (void) fprintf(stderr,
85 86 gettext("Syntax error\n"));
86 87 break;
87 88 case EXC_ENUM_NOT_SUPPORTED:
88 89 (void) fprintf(stderr,
89 90 gettext("Enumeration not supported on %s\n"), argv[1]);
90 91 break;
91 92 case EXC_NAME_NOT_FOUND:
92 93 break;
93 94 }
94 95 exit(rc);
95 96 }
96 97 }
97 98 (void) fprintf(stderr, gettext("Unknown database: %s\n"), argv[1]);
98 99 usage();
99 100 /* NOTREACHED */
100 101 }
101 102
102 103 static void
103 104 usage(void)
104 105 {
105 106 (void) fprintf(stderr,
106 107 gettext("usage: %s database [ key ... ]\n"), cmdname);
107 108 exit(EXC_SYNTAX);
108 109 }
|
↓ open down ↓ |
45 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX