148668Sbostic /*-
2*62401Sbostic * Copyright (c) 1983, 1988, 1993
3*62401Sbostic * The Regents of the University of California. All rights reserved.
448668Sbostic *
548668Sbostic * %sccs.include.proprietary.c%
648668Sbostic */
748668Sbostic
813687Ssam #ifndef lint
9*62401Sbostic static char copyright[] =
10*62401Sbostic "@(#) Copyright (c) 1983, 1988, 1993\n\
11*62401Sbostic The Regents of the University of California. All rights reserved.\n";
1248668Sbostic #endif /* not lint */
1313687Ssam
1448668Sbostic #ifndef lint
15*62401Sbostic static char sccsid[] = "@(#)uuname.c 8.1 (Berkeley) 06/06/93";
1648668Sbostic #endif /* not lint */
1748668Sbostic
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
main(argc,argv)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
cleanup(code)7217844Sralph cleanup(code)
7317844Sralph int code;
7417844Sralph {
7517844Sralph exit(code);
7617844Sralph }
77