1 /* 2 * CDDL HEADER START 3 * 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. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 1995 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 30 31 #pragma ident "%Z%%M% %I% %E% SMI" 32 33 #include "uucp.h" 34 35 /* 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 40 */ 41 main(argc,argv) 42 int argc; 43 char **argv; 44 { 45 int c, lflg = 0, cflg = 0; 46 char s[BUFSIZ], prev[BUFSIZ], name[BUFSIZ]; 47 extern void setservice(); 48 extern int sysaccess(), getsysline(); 49 50 /* Set locale environment variables local definitions */ 51 (void) setlocale(LC_ALL, ""); 52 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ 53 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */ 54 #endif 55 (void) textdomain(TEXT_DOMAIN); 56 57 while ( (c = getopt(argc, argv, "lc")) != EOF ) 58 switch(c) { 59 case 'c': 60 cflg++; 61 break; 62 case 'l': 63 lflg++; 64 break; 65 default: 66 (void) fprintf(stderr, gettext("usage: uuname [-l|-c]\n")); 67 exit(1); 68 } 69 70 if (lflg) { 71 if ( cflg ) 72 (void) fprintf(stderr, 73 gettext("uuname: -l overrides -c ... -c option ignored\n")); 74 uucpname(name); 75 76 puts(name); 77 exit(0); 78 } 79 80 if ( cflg ) 81 setservice("cu"); 82 else 83 setservice("uucico"); 84 85 if ( sysaccess(EACCESS_SYSTEMS) != 0 ) { 86 (void)fprintf(stderr, gettext( 87 "%s: cannot access Systems files\n"), argv[0]); 88 exit(1); 89 } 90 91 while ( getsysline(s, sizeof(s)) ) { 92 if((s[0] == '#') || (s[0] == ' ') || (s[0] == '\t') || 93 (s[0] == '\n')) 94 continue; 95 (void) sscanf(s, "%s", name); 96 if (EQUALS(name, prev)) 97 continue; 98 puts(name); 99 (void) strcpy(prev, name); 100 } 101 exit(0); 102 103 /* NOTREACHED */ 104 } 105 106 /* small, private copies of assert(), logent(), */ 107 /* cleanup() so we can use routines in sysfiles.c */ 108 109 /*ARGSUSED*/ 110 void 111 assert(s1, s2, i1, file, line) 112 char *s1, *s2, *file; int i1, line; 113 { 114 (void)fprintf(stderr, "uuname: %s %s\n", s2, s1); 115 return; 116 } 117 118 /*ARGSUSED*/ 119 void logent(s1, s2) 120 char *s1, *s2; 121 {} 122 123 void cleanup(code) { exit(code); } 124