8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / bnu / uuglist.c
blob7524860c329ba0093528a0eeb325e560dce729cd
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
33 #include "uucp.h"
35 #define MAXLENGTH 256
36 #define C_MAX 512
38 static void insert();
39 void rproc(), uproc();
41 static char Nnament[MAXLENGTH][NAMESIZE];
42 static char *Nptr[MAXLENGTH];
43 static short Nnames = 0;
45 int
46 main(argc, argv)
47 int argc;
48 char **argv;
50 int c, i, uopt = 0;
51 char prev[2 * NAMESIZE];
53 if (eaccess(GRADES, 04) == -1) {
54 (void) fprintf(stderr, "No administrator defined service grades available on this machine, use single letter/number only\n");
55 exit(0);
58 while ((c = getopt(argc, argv, "x:u")) != EOF)
59 switch(c) {
60 case 'u':
61 uopt++;
62 break;
63 case 'x':
64 Debug = atoi(optarg);
65 if (Debug < 0)
66 Debug = 1;
67 break;
68 default:
69 (void) fprintf(stderr, "usage: uuglist [-u] [-xLEVEL]\n");
70 exit(-1);
73 if (uopt) {
74 Uid = getuid();
76 if (Uid == 0)
77 (void) setuid(UUCPUID);
79 (void) guinfo(Uid, User);
81 uproc();
82 } else
83 rproc();
85 for (i = 0; i < Nnames; i++) {
87 if (EQUALS(Nptr[i], prev))
88 continue;
90 puts(Nptr[i]);
91 (void) strcpy(prev, Nptr[i]);
93 return (0);
95 static void
96 insert(name)
97 char *name;
99 int i,j;
100 char *p;
102 DEBUG(7, "insert(%s) ", name);
104 for (i = Nnames; i > 0; i--)
105 if (strcmp(name, Nptr[i-1]) > 0)
106 break;
108 if (i == MAXLENGTH)
109 return;
111 if (Nnames == MAXLENGTH)
112 p = strcpy(Nptr[--Nnames], name);
113 else
114 p = strcpy(Nnament[Nnames], name);
116 for (j = Nnames; j > i; j--)
117 Nptr[j] = Nptr[j-1];
119 DEBUG(7, "insert %s ", p);
120 DEBUG(7, "at %d\n", i);
121 Nptr[i] = p;
122 Nnames++;
123 return;
126 void
127 rproc()
129 FILE *cfd;
130 char line[BUFSIZ];
131 char *carray[C_MAX];
132 int na;
134 cfd = fopen(GRADES, "r");
136 while (rdfulline(cfd, line, BUFSIZ) != 0) {
138 na = getargs(line, carray, C_MAX);
139 insert(carray[0]);
142 (void) fclose(cfd);
143 return;
146 void
147 uproc()
149 FILE *cfd;
150 char line[BUFSIZ];
151 char *carray[C_MAX];
152 int na;
154 cfd = fopen(GRADES, "r");
156 while (rdfulline(cfd, line, BUFSIZ) != 0) {
158 na = getargs(line, carray, C_MAX);
160 if (upermit(carray, na) != FAIL)
161 insert(carray[0]);
164 (void) fclose(cfd);
165 return;
168 int Dfileused = FALSE;
169 void wfcommit() {}
170 void cleanup() {}
171 int gnamef() { return (0); }
172 int gdirf() { return (0); }
173 int cklock() { return (0); }
175 /*VARARGS*/
176 /*ARGSUSED*/
177 void
178 assert (s1, s2, i1, s3, i2)
179 char *s1, *s2, *s3;
180 int i1, i2;
181 { } /* for ASSERT in gnamef.c */
183 /*VARARGS*/
184 /*ARGSUSED*/
185 void
186 errent(s1, s2, i1, file, line)
187 char *s1, *s2, *file;