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