1*48668Sbostic /*- 2*48668Sbostic * Copyright (c) 1983, 1988 The Regents of the University of California. 3*48668Sbostic * All rights reserved. 4*48668Sbostic * 5*48668Sbostic * %sccs.include.proprietary.c% 6*48668Sbostic */ 7*48668Sbostic 813687Ssam #ifndef lint 9*48668Sbostic char copyright[] = 10*48668Sbostic "@(#) Copyright (c) 1983, 1988 The Regents of the University of California.\n\ 11*48668Sbostic All rights reserved.\n"; 12*48668Sbostic #endif /* not lint */ 1313687Ssam 14*48668Sbostic #ifndef lint 15*48668Sbostic static char sccsid[] = "@(#)uuname.c 5.5 (Berkeley) 04/24/91"; 16*48668Sbostic #endif /* not lint */ 17*48668Sbostic 1813687Ssam #include "uucp.h" 1913687Ssam 2025143Sbloom /* 2133962Srick * return list of all remote systems recognized by uucp, or (with -l) the 2233962Srick * local uucp name. 2313687Ssam * 2433962Srick * return codes: 0 | 1 (can't read) 2513687Ssam */ 2625143Sbloom 2725143Sbloom struct timeb Now; 2833962Srick 2933962Srick main(argc, argv) 3013687Ssam char *argv[]; 3113687Ssam int argc; 3213687Ssam { 3333962Srick register FILE *np; 3433962Srick register char *buf; 3533962Srick char s[BUFSIZ]; 3633962Srick char prev[BUFSIZ]; 3713687Ssam 3813687Ssam strcpy(Progname, "uuname"); 3913687Ssam 4033962Srick if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'l') { 4113687Ssam uucpname(s); 4233962Srick puts(s); 4313687Ssam exit(0); 4413687Ssam } 4533962Srick if (argc != 1) { 4633962Srick fprintf(stderr, "Usage: uuname [-l]\n"); 4713687Ssam exit(1); 4813687Ssam } 4933962Srick if ((np = fopen(SYSFILE, "r")) == NULL) { 5033962Srick syslog(LOG_WARNING, "fopen(%s) failed: %m", SYSFILE); 5133962Srick exit(1); 5233962Srick } 5333962Srick buf = s; 5433962Srick while (cfgets(buf, sizeof(s), np) != NULL) { 5533962Srick register char *cp; 5633962Srick cp = strpbrk(buf, " \t"); 5733962Srick if (cp) 5833962Srick *cp = '\0'; 5913687Ssam if (strcmp(s, prev) == SAME) 6013687Ssam continue; 6133962Srick if (*buf == 'x' && buf[1] == 'x' && buf[2] == 'x') 6213687Ssam continue; 6333962Srick puts(buf); 6433962Srick if (buf == s) 6533962Srick buf = prev; 6633962Srick else 6733962Srick buf = s; 6813687Ssam } 6913687Ssam exit(0); 7013687Ssam } 7117844Sralph 7217844Sralph cleanup(code) 7317844Sralph int code; 7417844Sralph { 7517844Sralph exit(code); 7617844Sralph } 77