1 /* Copyright (c) 1997 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. */
21 #include <rpcsvc/nis.h>
22 #include <rpcsvc/nislib.h>
25 nis_nstype2str (const nstype type
)
51 nis_ttl2str (const u_long ttl
)
54 unsigned long int time
, s
, m
, h
;
63 snprintf (buf
, 63, "%lu:%02lu:%02lu", h
, m
, s
);
69 nis_flags2str (const u_long flags
)
71 static char buf
[1024];
73 snprintf (buf
, 1023, "%lu", flags
);
79 nis_print_rights (const u_long access
)
85 acc
= access
; /* Parameter is const ! */
86 result
[i
= 16] = '\0';
90 result
[i
+ 0] = (acc
& NIS_READ_ACC
) ? 'r' : '-';
91 result
[i
+ 1] = (acc
& NIS_MODIFY_ACC
) ? 'm' : '-';
92 result
[i
+ 2] = (acc
& NIS_CREATE_ACC
) ? 'c' : '-';
93 result
[i
+ 3] = (acc
& NIS_DESTROY_ACC
) ? 'd' : '-';
97 printf ("%s", result
);
101 nis_print_directory (const directory_obj
*dir
)
106 printf (_("Name : '%s'\n"), dir
->do_name
);
107 printf (_("Type : %s\n"), gettext (nis_nstype2str (dir
->do_type
)));
108 sptr
= dir
->do_servers
.do_servers_val
;
109 for (i
= 0; i
< dir
->do_servers
.do_servers_len
; i
++)
112 fputs (_("Master Server :\n"), stdout
);
114 fputs (_("Replicate :\n"), stdout
);
115 printf (_("\tName : %s\n"), sptr
->name
);
116 fputs (_("\tPublic Key : "), stdout
);
117 switch (sptr
->key_type
)
120 fputs (_("None.\n"), stdout
);
123 fputs (_("DH.\n"), stdout
);
126 fputs (_("RSA.\n"), stdout
);
129 fputs (_("Kerberous.\n"), stdout
);
132 fputs (_("Unknown.\n"), stdout
);
136 if (sptr
->ep
.ep_len
!= 0)
141 ptr
= sptr
->ep
.ep_val
;
142 printf (_("\tUniversal addresses (%u)\n"), sptr
->ep
.ep_len
);
143 for (j
= 0; j
< sptr
->ep
.ep_len
; j
++)
145 printf ("\t[%d] - ", j
+ 1);
146 if (ptr
->proto
!= NULL
&& strlen (ptr
->proto
) > 0)
147 printf ("%s, ", ptr
->proto
);
150 if (ptr
->family
!= NULL
&& strlen (ptr
->family
) > 0)
151 printf ("%s, ", ptr
->family
);
154 if (ptr
->uaddr
!= NULL
&& strlen (ptr
->uaddr
) > 0)
155 printf ("%s\n", ptr
->uaddr
);
164 printf (_("Time to live : %s\n"), nis_ttl2str (dir
->do_ttl
));
165 if (dir
->do_armask
.do_armask_len
!= 0)
169 ptr
= dir
->do_armask
.do_armask_val
;
170 for (i
= 0; i
< dir
->do_armask
.do_armask_len
; i
++)
172 fputs (_("Default Access rights: "), stdout
);
173 nis_print_rights (ptr
->oa_rights
);
174 printf (_("\nDirect Type : %d\n"), ptr
->oa_otype
);
181 nis_print_group (const group_obj
*obj
)
185 fputs (_("Group Flags :"), stdout
);
187 printf ("0x%08lX", obj
->gr_flags
);
188 fputs (_("\nGroup Members :\n"), stdout
);
190 for (i
= 0; i
< obj
->gr_members
.gr_members_len
; i
++)
191 printf ("\t%s\n", obj
->gr_members
.gr_members_val
[i
]);
195 nis_print_table (const table_obj
*obj
)
199 printf (_("Table Type : %s\n"), obj
->ta_type
);
200 printf (_("Number of Columns : %d\n"), obj
->ta_maxcol
);
201 printf (_("Character Separator : %c\n"), obj
->ta_sep
);
202 printf (_("Search Path : %s\n"), obj
->ta_path
);
203 fputs (_("Columns :\n"), stdout
);
204 for (i
= 0; i
< obj
->ta_cols
.ta_cols_len
; i
++)
206 printf (_("\t[%d]\tName : %s\n"), i
,
207 obj
->ta_cols
.ta_cols_val
[i
].tc_name
);
208 printf (_("\t\tAttributes : %s\n"),
209 nis_flags2str (obj
->ta_cols
.ta_cols_val
[i
].tc_flags
));
210 fputs (_("\t\tAccess Rights : "), stdout
);
211 nis_print_rights (obj
->ta_cols
.ta_cols_val
[i
].tc_rights
);
212 fputc ('\n', stdout
);
217 nis_print_link (const link_obj
*obj
)
219 printf (_("Type : %d\n"), obj
->li_rtype
);
220 printf (_("Name : %s\n"), obj
->li_name
);
221 printf (_("Attributes : %d\n"), obj
->li_attrs
.li_attrs_len
);
225 nis_print_entry (const entry_obj
*obj
)
229 printf (_("\tEntry data of type %s\n"), obj
->en_type
);
230 for (i
= 0; i
< obj
->en_cols
.en_cols_len
; i
++)
232 printf (_("\t[%u] - [%u bytes] "), i
,
233 obj
->en_cols
.en_cols_val
[i
].ec_value
.ec_value_len
);
234 if ((obj
->en_cols
.en_cols_val
[i
].ec_flags
& EN_CRYPT
) == EN_CRYPT
)
235 fputs (_("Encrypted data\n"), stdout
);
236 else if ((obj
->en_cols
.en_cols_val
[i
].ec_flags
& EN_BINARY
) == EN_BINARY
)
237 fputs (_("Binary data\n"), stdout
);
239 printf ("%s\n", obj
->en_cols
.en_cols_val
[i
].ec_value
.ec_value_val
);
244 nis_print_object (const nis_object
* obj
)
246 printf (_("Object Name : %s\n"), obj
->zo_name
);
247 printf (_("Directory : %s\n"), obj
->zo_domain
);
248 printf (_("Owner : %s\n"), obj
->zo_owner
);
249 printf (_("Group : %s\n"), obj
->zo_group
);
250 fputs (_("Access Rights : "), stdout
);
251 nis_print_rights (obj
->zo_access
);
252 printf (_("\nTime to Live : %lu (seconds)\n"), obj
->zo_ttl
);
253 printf (_("Creation Time : %s"), ctime (&obj
->zo_oid
.ctime
));
254 printf (_("Mod. Time : %s"), ctime (&obj
->zo_oid
.mtime
));
255 fputs (_("Object Type : "), stdout
);
256 switch (obj
->zo_data
.zo_type
)
259 fputs (_("BOGUS OBJECT\n"), stdout
);
262 fputs (_("NO OBJECT\n"), stdout
);
265 fputs (_("DIRECTORY\n"), stdout
);
266 nis_print_directory (&obj
->zo_data
.objdata_u
.di_data
);
269 fputs (_("GROUP\n"), stdout
);
270 nis_print_group (&obj
->zo_data
.objdata_u
.gr_data
);
273 fputs (_("TABLE\n"), stdout
);
274 nis_print_table (&obj
->zo_data
.objdata_u
.ta_data
);
277 fputs (_("ENTRY\n"), stdout
);
278 nis_print_entry (&obj
->zo_data
.objdata_u
.en_data
);
281 fputs (_("LINK\n"), stdout
);
282 nis_print_link (&obj
->zo_data
.objdata_u
.li_data
);
285 fputs (_("PRIVATE\n"), stdout
);
286 printf (_(" Data Length = %u\n"),
287 obj
->zo_data
.objdata_u
.po_data
.po_data_len
);
290 fputs (_("(Unknown object)\n"), stdout
);
296 nis_print_result (const nis_result
*res
)
300 printf (_("Status : %s\n"), nis_sperrno (res
->status
));
301 printf (_("Number of objects : %u\n"), res
->objects
.objects_len
);
303 for (i
= 0; i
< res
->objects
.objects_len
; i
++)
305 printf (_("Object #%d:\n"), i
);
306 nis_print_object (&res
->objects
.objects_val
[i
]);