* sysdeps/m68k/dl-machine.h (RTLD_START): Readd _dl_start_user
[glibc/pb-stable.git] / nis / nis_print_group_entry.c
blobe1970dca487d58cb2cf906cf00fd0f2de842f57a
1 /* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #include <string.h>
21 #include <libintl.h>
22 #include <rpcsvc/nis.h>
24 void
25 nis_print_group_entry (const_nis_name group)
27 if (group != NULL && group[0] != '\0')
29 size_t grouplen = strlen (group);
30 char buf[grouplen + 50];
31 char leafbuf[grouplen + 3];
32 char domainbuf[grouplen + 3];
33 unsigned long mem_exp_cnt = 0, mem_imp_cnt = 0, mem_rec_cnt = 0;
34 unsigned long nomem_exp_cnt = 0, nomem_imp_cnt = 0, nomem_rec_cnt = 0;
35 char **mem_exp, **mem_imp, **mem_rec;
36 char **nomem_exp, **nomem_imp, **nomem_rec;
37 nis_result *res;
38 char *cp, *cp2;
39 u_int i;
41 cp = stpcpy (buf, nis_leaf_of_r (group, leafbuf, sizeof (leafbuf) - 1));
42 cp = stpcpy (cp, ".groups_dir");
43 cp2 = nis_domain_of_r (group, domainbuf, sizeof (domainbuf) - 1);
44 if (cp2 != NULL && cp2[0] != '\0')
46 *cp++ = '.';
47 stpcpy (cp, cp2);
49 res = nis_lookup (buf, FOLLOW_LINKS | EXPAND_NAME);
51 if (NIS_RES_STATUS(res) != NIS_SUCCESS)
52 return;
54 if ((NIS_RES_NUMOBJ (res) != 1) ||
55 (__type_of (NIS_RES_OBJECT (res)) != NIS_GROUP_OBJ))
56 return;
58 mem_exp = malloc (sizeof (char *) * NIS_RES_NUMOBJ (res));
59 mem_imp = malloc (sizeof (char *) * NIS_RES_NUMOBJ (res));
60 mem_rec = malloc (sizeof (char *) * NIS_RES_NUMOBJ (res));
61 nomem_exp = malloc (sizeof (char *) * NIS_RES_NUMOBJ (res));
62 nomem_imp = malloc (sizeof (char *) * NIS_RES_NUMOBJ (res));
63 nomem_rec = malloc (sizeof (char *) * NIS_RES_NUMOBJ (res));
65 for (i = 0;
66 i < NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_len; ++i)
68 char *grmem =
69 NIS_RES_OBJECT (res)->GR_data.gr_members.gr_members_val[i];
70 int neg = grmem[0] == '-';
72 switch (grmem[neg])
74 case '*':
75 if (neg)
77 nomem_imp[nomem_imp_cnt] = grmem;
78 ++nomem_imp_cnt;
80 else
82 mem_imp[mem_imp_cnt] = grmem;
83 ++mem_imp_cnt;
85 break;
86 case '@':
87 if (neg)
89 nomem_rec[nomem_rec_cnt] = grmem;
90 ++nomem_rec_cnt;
92 else
94 mem_rec[mem_rec_cnt] = grmem;
95 ++mem_rec_cnt;
97 break;
98 default:
99 if (neg)
101 nomem_exp[nomem_exp_cnt] = grmem;
102 ++nomem_exp_cnt;
104 else
106 mem_exp[mem_exp_cnt] = grmem;
107 ++mem_exp_cnt;
109 break;
113 char buf[strlen (NIS_RES_OBJECT (res)->zo_domain) + 10];
114 printf (_("Group entry for \"%s.%s\" group:\n"),
115 NIS_RES_OBJECT (res)->zo_name,
116 nis_domain_of_r (NIS_RES_OBJECT (res)->zo_domain,
117 buf, strlen (NIS_RES_OBJECT (res)->zo_domain)
118 + 10));
120 if (mem_exp_cnt)
122 fputs (_(" Explicit members:\n"), stdout);
123 for (i = 0; i < mem_exp_cnt; ++i)
124 printf ("\t%s\n", mem_exp[i]);
126 else
127 fputs (_(" No explicit members\n"), stdout);
128 if (mem_imp_cnt)
130 fputs (_(" Implicit members:\n"), stdout);
131 for (i = 0; i < mem_imp_cnt; ++i)
132 printf ("\t%s\n", &mem_imp[i][2]);
134 else
135 fputs (_(" No implicit members\n"), stdout);
136 if (mem_rec_cnt)
138 fputs (_(" Recursive members:\n"), stdout);
139 for (i = 0; i < mem_rec_cnt; ++i)
140 printf ("\t%s\n", &mem_rec[i][1]);
142 else
143 fputs (_(" No recursive members\n"), stdout);
144 if (nomem_exp_cnt)
146 fputs (_(" Explicit nonmembers:\n"), stdout);
147 for (i = 0; i < nomem_exp_cnt; ++i)
148 printf ("\t%s\n", &nomem_exp[i][1]);
150 else
151 fputs (_(" No explicit nonmembers\n"), stdout);
152 if (nomem_imp_cnt)
154 fputs (_(" Implicit nonmembers:\n"), stdout);
155 for (i = 0; i < nomem_imp_cnt; ++i)
156 printf ("\t%s\n", &mem_imp[i][3]);
158 else
159 fputs (_(" No implicit nonmembers\n"), stdout);
160 if (nomem_rec_cnt)
162 fputs (_(" Explicit nonmembers:\n"), stdout);
163 for (i = 0; i < nomem_rec_cnt; ++i)
164 printf ("\t%s=n", &nomem_rec[i][2]);
166 else
167 fputs (_(" No recursive nonmembers\n"), stdout);
169 free (mem_exp);
170 free (mem_imp);
171 free (mem_rec);
172 free (nomem_exp);
173 free (nomem_imp);
174 free (nomem_rec);
175 nis_freeresult (res);