8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / bnu / uuname.c
blob7dcc82e82b6b149117c5c6c83b38a90f14c1155e
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"
36 * returns a list of remote systems accessible to uucico
37 * option:
38 * -l -> returns only the local system name.
39 * -c -> print remote systems accessible to cu
41 int
42 main(argc,argv)
43 int argc;
44 char **argv;
46 int c, lflg = 0, cflg = 0;
47 char s[BUFSIZ], prev[BUFSIZ], name[BUFSIZ];
48 extern void setservice();
49 extern int sysaccess(), getsysline();
51 /* Set locale environment variables local definitions */
52 (void) setlocale(LC_ALL, "");
53 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
54 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */
55 #endif
56 (void) textdomain(TEXT_DOMAIN);
58 while ( (c = getopt(argc, argv, "lc")) != EOF )
59 switch(c) {
60 case 'c':
61 cflg++;
62 break;
63 case 'l':
64 lflg++;
65 break;
66 default:
67 (void) fprintf(stderr, gettext("usage: uuname [-l|-c]\n"));
68 exit(1);
71 if (lflg) {
72 if ( cflg )
73 (void) fprintf(stderr,
74 gettext("uuname: -l overrides -c ... -c option ignored\n"));
75 uucpname(name);
77 puts(name);
78 exit(0);
81 if ( cflg )
82 setservice("cu");
83 else
84 setservice("uucico");
86 if ( sysaccess(EACCESS_SYSTEMS) != 0 ) {
87 (void)fprintf(stderr, gettext(
88 "%s: cannot access Systems files\n"), argv[0]);
89 exit(1);
92 while ( getsysline(s, sizeof(s)) ) {
93 if((s[0] == '#') || (s[0] == ' ') || (s[0] == '\t') ||
94 (s[0] == '\n'))
95 continue;
96 (void) sscanf(s, "%s", name);
97 if (EQUALS(name, prev))
98 continue;
99 puts(name);
100 (void) strcpy(prev, name);
102 return (0);
105 /* small, private copies of assert(), logent(), */
106 /* cleanup() so we can use routines in sysfiles.c */
108 /*ARGSUSED*/
109 void
110 assert(s1, s2, i1, file, line)
111 char *s1, *s2, *file; int i1, line;
113 (void)fprintf(stderr, "uuname: %s %s\n", s2, s1);
114 return;
117 /*ARGSUSED*/
118 void logent(s1, s2)
119 char *s1, *s2;
122 void cleanup(code) { exit(code); }