1993-08-04 23:33:45 +04:00
|
|
|
|
/* uuname.c
|
|
|
|
|
List the names of known remote UUCP sites.
|
|
|
|
|
|
1994-10-25 01:27:43 +03:00
|
|
|
|
Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor
|
1993-08-04 23:33:45 +04:00
|
|
|
|
|
|
|
|
|
This file is part of the Taylor UUCP package.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
|
|
The author of the program may be contacted at ian@airs.com or
|
1994-10-25 01:27:43 +03:00
|
|
|
|
c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
|
1993-08-04 23:33:45 +04:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "uucp.h"
|
|
|
|
|
|
|
|
|
|
#if USE_RCS_ID
|
1994-10-25 01:27:43 +03:00
|
|
|
|
const char uuname_rcsid[] = "$Id: uuname.c,v 1.2 1994/10/24 22:29:11 jtc Exp $";
|
1993-08-04 23:33:45 +04:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "getopt.h"
|
|
|
|
|
|
|
|
|
|
#include "uudefs.h"
|
|
|
|
|
#include "uuconf.h"
|
|
|
|
|
#include "system.h"
|
|
|
|
|
|
|
|
|
|
/* Local functions. */
|
|
|
|
|
|
|
|
|
|
static void unusage P((void));
|
1994-10-25 01:27:43 +03:00
|
|
|
|
static void unhelp P((void));
|
1993-08-04 23:33:45 +04:00
|
|
|
|
|
|
|
|
|
/* Long getopt options. */
|
1994-10-25 01:27:43 +03:00
|
|
|
|
static const struct option asNlongopts[] =
|
|
|
|
|
{
|
|
|
|
|
{ "aliases", no_argument, NULL, 'a' },
|
|
|
|
|
{ "local", no_argument, NULL, 'l' },
|
|
|
|
|
{ "config", required_argument, NULL, 'I' },
|
|
|
|
|
{ "debug", required_argument, NULL, 'x' },
|
|
|
|
|
{ "version", no_argument, NULL, 'v' },
|
|
|
|
|
{ "help", no_argument, NULL, 1 },
|
|
|
|
|
{ NULL, 0, NULL, 0 }
|
|
|
|
|
};
|
1993-08-04 23:33:45 +04:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main (argc, argv)
|
|
|
|
|
int argc;
|
|
|
|
|
char **argv;
|
|
|
|
|
{
|
|
|
|
|
/* -a: display aliases. */
|
|
|
|
|
boolean falias = FALSE;
|
|
|
|
|
/* -l: if true, output local node name. */
|
|
|
|
|
boolean flocal = FALSE;
|
|
|
|
|
/* -I: configuration file name. */
|
|
|
|
|
const char *zconfig = NULL;
|
|
|
|
|
int iopt;
|
|
|
|
|
pointer puuconf;
|
|
|
|
|
int iuuconf;
|
|
|
|
|
|
1994-10-25 01:27:43 +03:00
|
|
|
|
zProgram = argv[0];
|
|
|
|
|
|
|
|
|
|
while ((iopt = getopt_long (argc, argv, "alI:vx:", asNlongopts,
|
1993-08-04 23:33:45 +04:00
|
|
|
|
(int *) NULL)) != EOF)
|
|
|
|
|
{
|
|
|
|
|
switch (iopt)
|
|
|
|
|
{
|
|
|
|
|
case 'a':
|
|
|
|
|
/* Display aliases. */
|
|
|
|
|
falias = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'l':
|
|
|
|
|
/* Output local node name. */
|
|
|
|
|
flocal = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'I':
|
|
|
|
|
/* Configuration file name. */
|
|
|
|
|
if (fsysdep_other_config (optarg))
|
|
|
|
|
zconfig = optarg;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'x':
|
|
|
|
|
#if DEBUG > 1
|
|
|
|
|
/* Set debugging level. */
|
|
|
|
|
iDebug |= idebug_parse (optarg);
|
|
|
|
|
#endif
|
|
|
|
|
break;
|
|
|
|
|
|
1994-10-25 01:27:43 +03:00
|
|
|
|
case 'v':
|
|
|
|
|
/* Print version and exit. */
|
|
|
|
|
printf ("%s: Taylor UUCP %s, copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor\n",
|
|
|
|
|
zProgram, VERSION);
|
|
|
|
|
exit (EXIT_SUCCESS);
|
|
|
|
|
/*NOTREACHED*/
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
/* --help. */
|
|
|
|
|
unhelp ();
|
|
|
|
|
exit (EXIT_SUCCESS);
|
|
|
|
|
/*NOTREACHED*/
|
|
|
|
|
|
1993-08-04 23:33:45 +04:00
|
|
|
|
case 0:
|
|
|
|
|
/* Long option found and flag set. */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
unusage ();
|
1994-10-25 01:27:43 +03:00
|
|
|
|
/*NOTREACHED*/
|
1993-08-04 23:33:45 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (optind != argc)
|
|
|
|
|
unusage ();
|
|
|
|
|
|
|
|
|
|
iuuconf = uuconf_init (&puuconf, (const char *) NULL, zconfig);
|
|
|
|
|
if (iuuconf != UUCONF_SUCCESS)
|
1994-10-25 01:27:43 +03:00
|
|
|
|
ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
|
1993-08-04 23:33:45 +04:00
|
|
|
|
|
|
|
|
|
#if DEBUG > 1
|
|
|
|
|
{
|
|
|
|
|
const char *zdebug;
|
|
|
|
|
|
|
|
|
|
iuuconf = uuconf_debuglevel (puuconf, &zdebug);
|
|
|
|
|
if (iuuconf != UUCONF_SUCCESS)
|
|
|
|
|
ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
|
|
|
|
|
if (zdebug != NULL)
|
|
|
|
|
iDebug |= idebug_parse (zdebug);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
1994-10-25 01:27:43 +03:00
|
|
|
|
usysdep_initialize (puuconf, INIT_SUID | INIT_NOCHDIR);
|
1993-08-04 23:33:45 +04:00
|
|
|
|
|
|
|
|
|
if (flocal)
|
|
|
|
|
{
|
|
|
|
|
const char *zlocalname;
|
|
|
|
|
|
|
|
|
|
iuuconf = uuconf_localname (puuconf, &zlocalname);
|
|
|
|
|
if (iuuconf == UUCONF_NOT_FOUND)
|
|
|
|
|
{
|
|
|
|
|
zlocalname = zsysdep_localname ();
|
|
|
|
|
if (zlocalname == NULL)
|
|
|
|
|
usysdep_exit (FALSE);
|
|
|
|
|
}
|
|
|
|
|
else if (iuuconf != UUCONF_SUCCESS)
|
1994-10-25 01:27:43 +03:00
|
|
|
|
ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
|
1993-08-04 23:33:45 +04:00
|
|
|
|
printf ("%s\n", zlocalname);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char **pznames, **pz;
|
|
|
|
|
|
|
|
|
|
iuuconf = uuconf_system_names (puuconf, &pznames, falias);
|
|
|
|
|
if (iuuconf != UUCONF_SUCCESS)
|
1994-10-25 01:27:43 +03:00
|
|
|
|
ulog_uuconf (LOG_FATAL, puuconf, iuuconf);
|
1993-08-04 23:33:45 +04:00
|
|
|
|
|
|
|
|
|
for (pz = pznames; *pz != NULL; pz++)
|
|
|
|
|
printf ("%s\n", *pz);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
usysdep_exit (TRUE);
|
|
|
|
|
|
|
|
|
|
/* Avoid warnings about not returning a value. */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print a usage message and die. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
unusage ()
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr,
|
1994-10-25 01:27:43 +03:00
|
|
|
|
"Usage: %s [-a] [-l] [-I file]\n", zProgram);
|
|
|
|
|
fprintf (stderr, "Use %s --help for help\n", zProgram);
|
1993-08-04 23:33:45 +04:00
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
1994-10-25 01:27:43 +03:00
|
|
|
|
/* Print a help message. */
|
1993-08-04 23:33:45 +04:00
|
|
|
|
|
1994-10-25 01:27:43 +03:00
|
|
|
|
static void unhelp ()
|
1993-08-04 23:33:45 +04:00
|
|
|
|
{
|
1994-10-25 01:27:43 +03:00
|
|
|
|
printf ("Taylor UUCP %s, copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor\n",
|
|
|
|
|
VERSION);
|
|
|
|
|
printf ("Usage: %s [-a] [-l] [-I file]\n", zProgram);
|
|
|
|
|
printf (" -a,--aliases: display aliases\n");
|
|
|
|
|
printf (" -l,--local: print local name\n");
|
|
|
|
|
#if HAVE_TAYLOR_CONFIG
|
|
|
|
|
printf (" -I,--config file: Set configuration file to use\n");
|
|
|
|
|
#endif /* HAVE_TAYLOR_CONFIG */
|
|
|
|
|
printf (" -v,--version: Print version and exit\n");
|
|
|
|
|
printf (" --help: Print help and exit\n");
|
1993-08-04 23:33:45 +04:00
|
|
|
|
}
|