home *** CD-ROM | disk | FTP | other *** search
- /*
- * UUHOSTS -- List all UUCP sites connected to our system
- *
- * Copyright 1988 by William Loftus. All rights reserved.
- * Copyright 1993 by Michael B. Smith. All rights reserved.
- *
- * Performs a subfunction of UUNAME -- use it instead.
- */
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include "version.h"
- #include "protos.h"
-
- IDENT (".03");
-
- void listsites (void);
-
- int
- main (int argc, char **argv)
- {
- if (argc != 1) {
- fprintf (stderr, "usage: %s\n", argv [0]);
- exit (30);
- }
-
- listsites ();
-
- exit (0);
- }
-
- void
- listsites (void)
- {
- /*
- ** listsites
- **
- ** Read UULib:L.Sys and print out the unique sites listed there.
- */
- char
- *p,
- buf [256];
- struct Node
- *n;
- struct List
- list;
- FILE
- *fd;
- int
- unique;
-
- if (!(fd = fopen (MakeConfigPath (UULIB, "L.sys"), "r"))) {
- fprintf (stderr, "Couldn't open L.sys file\n");
- exit (30);
- }
-
- NewList (&list);
-
- while (fgets (buf, sizeof buf, fd)) {
- if (buf [0] == '#' || buf [0] == '\n')
- continue;
-
- if (p = strchr (buf, ' '))
- *p = '\0';
- else
- buf [79] = '\0';
-
- unique = 1;
- for (n = list.lh_Head; n->ln_Succ; n = n->ln_Succ) {
- if (stricmp (buf, n->ln_Name) == 0) {
- unique = 0;
- break;
- }
- }
-
- if (unique) {
- n = malloc (sizeof (struct Node) + strlen (buf) + 2);
- n->ln_Name = ((char *) n) + sizeof (struct Node);
- strcpy (n->ln_Name, buf);
- AddTail (&list, n);
- }
- }
-
- fclose (fd);
-
- while (n = RemHead (&list)) {
- printf ("%s\n", n->ln_Name);
- free (n);
- }
-
- return;
- }
-