1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 1995 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate #include "uucp.h" 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate /* 36*7c478bd9Sstevel@tonic-gate * returns a list of remote systems accessible to uucico 37*7c478bd9Sstevel@tonic-gate * option: 38*7c478bd9Sstevel@tonic-gate * -l -> returns only the local system name. 39*7c478bd9Sstevel@tonic-gate * -c -> print remote systems accessible to cu 40*7c478bd9Sstevel@tonic-gate */ 41*7c478bd9Sstevel@tonic-gate main(argc,argv) 42*7c478bd9Sstevel@tonic-gate int argc; 43*7c478bd9Sstevel@tonic-gate char **argv; 44*7c478bd9Sstevel@tonic-gate { 45*7c478bd9Sstevel@tonic-gate int c, lflg = 0, cflg = 0; 46*7c478bd9Sstevel@tonic-gate char s[BUFSIZ], prev[BUFSIZ], name[BUFSIZ]; 47*7c478bd9Sstevel@tonic-gate extern void setservice(); 48*7c478bd9Sstevel@tonic-gate extern int sysaccess(), getsysline(); 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate /* Set locale environment variables local definitions */ 51*7c478bd9Sstevel@tonic-gate (void) setlocale(LC_ALL, ""); 52*7c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ 53*7c478bd9Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */ 54*7c478bd9Sstevel@tonic-gate #endif 55*7c478bd9Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN); 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate while ( (c = getopt(argc, argv, "lc")) != EOF ) 58*7c478bd9Sstevel@tonic-gate switch(c) { 59*7c478bd9Sstevel@tonic-gate case 'c': 60*7c478bd9Sstevel@tonic-gate cflg++; 61*7c478bd9Sstevel@tonic-gate break; 62*7c478bd9Sstevel@tonic-gate case 'l': 63*7c478bd9Sstevel@tonic-gate lflg++; 64*7c478bd9Sstevel@tonic-gate break; 65*7c478bd9Sstevel@tonic-gate default: 66*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext("usage: uuname [-l|-c]\n")); 67*7c478bd9Sstevel@tonic-gate exit(1); 68*7c478bd9Sstevel@tonic-gate } 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate if (lflg) { 71*7c478bd9Sstevel@tonic-gate if ( cflg ) 72*7c478bd9Sstevel@tonic-gate (void) fprintf(stderr, 73*7c478bd9Sstevel@tonic-gate gettext("uuname: -l overrides -c ... -c option ignored\n")); 74*7c478bd9Sstevel@tonic-gate uucpname(name); 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate puts(name); 77*7c478bd9Sstevel@tonic-gate exit(0); 78*7c478bd9Sstevel@tonic-gate } 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate if ( cflg ) 81*7c478bd9Sstevel@tonic-gate setservice("cu"); 82*7c478bd9Sstevel@tonic-gate else 83*7c478bd9Sstevel@tonic-gate setservice("uucico"); 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate if ( sysaccess(EACCESS_SYSTEMS) != 0 ) { 86*7c478bd9Sstevel@tonic-gate (void)fprintf(stderr, gettext( 87*7c478bd9Sstevel@tonic-gate "%s: cannot access Systems files\n"), argv[0]); 88*7c478bd9Sstevel@tonic-gate exit(1); 89*7c478bd9Sstevel@tonic-gate } 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate while ( getsysline(s, sizeof(s)) ) { 92*7c478bd9Sstevel@tonic-gate if((s[0] == '#') || (s[0] == ' ') || (s[0] == '\t') || 93*7c478bd9Sstevel@tonic-gate (s[0] == '\n')) 94*7c478bd9Sstevel@tonic-gate continue; 95*7c478bd9Sstevel@tonic-gate (void) sscanf(s, "%s", name); 96*7c478bd9Sstevel@tonic-gate if (EQUALS(name, prev)) 97*7c478bd9Sstevel@tonic-gate continue; 98*7c478bd9Sstevel@tonic-gate puts(name); 99*7c478bd9Sstevel@tonic-gate (void) strcpy(prev, name); 100*7c478bd9Sstevel@tonic-gate } 101*7c478bd9Sstevel@tonic-gate exit(0); 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate /* NOTREACHED */ 104*7c478bd9Sstevel@tonic-gate } 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate /* small, private copies of assert(), logent(), */ 107*7c478bd9Sstevel@tonic-gate /* cleanup() so we can use routines in sysfiles.c */ 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 110*7c478bd9Sstevel@tonic-gate void 111*7c478bd9Sstevel@tonic-gate assert(s1, s2, i1, file, line) 112*7c478bd9Sstevel@tonic-gate char *s1, *s2, *file; int i1, line; 113*7c478bd9Sstevel@tonic-gate { 114*7c478bd9Sstevel@tonic-gate (void)fprintf(stderr, "uuname: %s %s\n", s2, s1); 115*7c478bd9Sstevel@tonic-gate return; 116*7c478bd9Sstevel@tonic-gate } 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 119*7c478bd9Sstevel@tonic-gate void logent(s1, s2) 120*7c478bd9Sstevel@tonic-gate char *s1, *s2; 121*7c478bd9Sstevel@tonic-gate {} 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate void cleanup(code) { exit(code); } 124