Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

UUname - List UUCP names with description. Part 01/01

0 views
Skip to first unread message

Jan-Piet Mens

unread,
Aug 15, 1991, 1:19:19 PM8/15/91
to
Submitted-by: j...@logixwi.UUCP
Archive-name: UUname/part01


UUname is like uuname(1) but it can not only show the UUCP system names, but
also a short description of each. The description is kept in a clever place,
being as comment in the Systems/L.sys file.

$ UUname
tom Our major backbone, don't tell jerry
jerry Connected to `tweety' daily
sylvester -

Enjoy!

---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is UUname, a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 08/15/1991 17:18 UTC by j...@logixwi.UUCP
# Source directory /u/tools/etc/uu/UUname
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 2989 -rw-r--r-- UUname.c
# 1512 -r--r--r-- myname.c
# 2856 -rw-r--r-- defs.h
# 3280 -r--r--r-- UUname.1
# 1367 -rw-r--r-- INSTALL
# 1155 -rw-r--r-- README
# 369 -rw-r--r-- Copyright
# 1136 -rw-r--r-- Makefile
# 289 -rw-r--r-- MANIFEST
#
# ============= UUname.c ==============
if test -f 'UUname.c' -a X"$1" != X"-c"; then
echo 'x - skipping UUname.c (File already exists)'
else
echo 'x - extracting UUname.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'UUname.c' &&
/*
X * UUname, Copyright 1991, Jan-Piet Mens
X * License to freely use and distribute this software is hereby granted
X * by the author, subject to the condition that this copyright notice
X * remains intact. The author retains the exclusive right to publish
X * derivative works based on this work, including, but not limited
X * to, revised versions of this work
X */
X
/*
X * $Header: /u/tools/etc/uu/UUname/RCS/UUname.c,v 1.1 1991/08/15 16:48:26 jpm Exp jpm $
X *
X * $Log: UUname.c,v $
X * Revision 1.1 1991/08/15 16:48:26 jpm
X * Initial revision
X *
X */
X
static char rcs_id[] = "$Id: UUname.c,v 1.1 1991/08/15 16:48:26 jpm Exp jpm $";
X
#include "defs.h"
X
#define USAGE(p) fprintf(stderr,"Usage: %s [-l]\n", (p))
#define EOS '\0'
#define STRLEN 256
X
static struct {
X char *name; /* System name */
X char *desc; /* Description or "-" */
X } sys[MAX_ENTRIES];
static long count = 0L; /* Keep count in sys[] array. */
X
#define SEPARATOR ':' /* Enters description line */
X
main(argc,argv)
int argc;
char **argv;
{
X int c;
X
X while ((c = getopt(argc,argv,"l")) != EOF)
X {
X switch (c)
X {
X case 'l':
X return (myname());
X default:
X return (USAGE(*argv));
X }
X }
X
X /* SVR4 mutters something about "not reached". Ignore */
X
X if (readSystems() == 0)
X showSystems();
X return (0);
}
X
/*
X * Fill the `sys[]' array with nodename/description pairs
X */
X
int readSystems()
{
X extern int errno;
X extern char *sys_errlist[];
X char buf[STRLEN], buf1[STRLEN];
X FILE *fp;
X
X if ((fp = fopen(SYSTEMS, "r")) == (FILE *)0)
X return (fprintf(stderr, "Can't open %s: %s\n",
X SYSTEMS, sys_errlist[errno]));
X
X while (fgets(buf, STRLEN, fp) != (char *)0)
X {
X buf[strlen(buf) - 1] = EOS;
X
X /*
X * Skip empty lines...
X */
X
X if ((buf[0] == EOS) || (buf[0] == '\n'))
X continue;
X
X /*
X * Node without previous description line ?
X */
X
X if (buf[0] != '#')
X {
X install(buf, "-");
X continue;
X }
X
X /*
X * Ah! Description line; nodename line must follow ...
X */
X
X if ((buf[0] == '#') && (buf[1] == SEPARATOR))
X {
X if (fgets(buf1, STRLEN, fp) == (char *)0)
X break;
X
X install(buf1, buf + 2);
X }
X }
X
X fclose(fp);
X return (0);
}
X
/*
X * Print out list ...
X */
X
int showSystems()
{
X extern long count;
X long i;
X
X for (i = 0; i < count; i++)
X printf("%-8.8s %s\n", sys[i].name,
X (sys[i].desc == (char *)0) ? "-" : sys[i].desc);
}
X
/*
X * Insert both `node' and `desc' into sys[]
X */
X
int install(node, desc)
char *node, *desc;
{
X char *s;
X
X if (count >= MAX_ENTRIES)
X return (fprintf(stderr,"Warning: too many entries in %s\n",
X SYSTEMS));
X
X if ((s = strtok(node, " \t")) == (char *)0)
X return (fprintf(stderr,"Warning: SYSTEMS format\n"));
X sys[count].name = strsave(s);
X sys[count].desc = strsave(desc);
X
X ++count;
}
X
/*
X * Return a pointer to a safe place
X */
X
char *strsave(s)
char *s;
{
X extern char *malloc();
X static char *save;
X
X if ((save = malloc((unsigned)strlen(s) + 1)) == (char *)0)
X exit(fprintf(stderr,"No memory\n"));
X strcpy(save, s);
X return (save);
}
SHAR_EOF
chmod 0644 UUname.c ||
echo 'restore of UUname.c failed'
Wc_c="`wc -c < 'UUname.c'`"
test 2989 -eq "$Wc_c" ||
echo 'UUname.c: original size 2989, current size' "$Wc_c"
fi
# ============= myname.c ==============
if test -f 'myname.c' -a X"$1" != X"-c"; then
echo 'x - skipping myname.c (File already exists)'
else
echo 'x - extracting myname.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'myname.c' &&
/*
X * UUname, Copyright 1991, Jan-Piet Mens
X * License to freely use and distribute this software is hereby granted
X * by the author, subject to the condition that this copyright notice
X * remains intact. The author retains the exclusive right to publish
X * derivative works based on this work, including, but not limited
X * to, revised versions of this work
X */
X
/*
X * $Header: /u/tools/etc/uu/UUname/RCS/myname.c,v 1.1 1991/08/15 16:48:26 jpm Exp $
X *
X * $Log: myname.c,v $
X * Revision 1.1 1991/08/15 16:48:26 jpm
X * Initial revision
X *
X */
X
static char rcs_id[] = "$Id: myname.c,v 1.1 1991/08/15 16:48:26 jpm Exp $";
X
#include "defs.h"
#ifdef UNAME
# include <sys/utsname.h>
#endif
X
int myname()
{
X char nodename[100];
#if defined(SYSTEMID) || defined(UUPIPE)
X FILE *fp;
X
#ifdef UUPIPE
X if ((fp = popen(UUPIPE,"r")) == (FILE *)0)
#endif
#ifdef SYSTEMID
X if ((fp = fopen(SYSTEMID,"r")) == (FILE *)0)
#endif
X {
X fprintf(stderr, "Can't open %s [%s]\n",
#ifdef SYSTEMID
X "file", SYSTEMID );
#endif
#ifdef UUPIPE
X "pipe", UUPIPE );
#endif
X exit(2);
X }
X
X if (fgets(nodename, 100, fp) == (char *)0)
X strcpy(nodename, "Can't read nodename\n");
#ifdef SYSTEMID
X fclose(fp);
#endif
#ifdef UUPIPE
X pclose(fp);
#endif
#endif /* defined(SYSTEMID || UUPIPE) */
X
X
#ifdef UNAME
X struct utsname ut;
X
X if (uname(&ut) == -1)
X (void)perror("uname()");
X else
X sprintf(nodename, "%s\n", ut.nodename);
#endif
X
#ifdef HOSTNAME
X sprintf(nodename,"%s\n", HOSTNAME);
#endif
X
X printf("%s", nodename);
X return (0);
}
SHAR_EOF
chmod 0444 myname.c ||
echo 'restore of myname.c failed'
Wc_c="`wc -c < 'myname.c'`"
test 1512 -eq "$Wc_c" ||
echo 'myname.c: original size 1512, current size' "$Wc_c"
fi
# ============= defs.h ==============
if test -f 'defs.h' -a X"$1" != X"-c"; then
echo 'x - skipping defs.h (File already exists)'
else
echo 'x - extracting defs.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'defs.h' &&
/*
X * UUname, Copyright 1991, Jan-Piet Mens
X * License to freely use and distribute this software is hereby granted
X * by the author, subject to the condition that this copyright notice
X * remains intact. The author retains the exclusive right to publish
X * derivative works based on this work, including, but not limited
X * to, revised versions of this work
X */
X
/*
X * $Header: /u/tools/etc/uu/UUname/RCS/defs.h,v 1.1 1991/08/15 16:48:26 jpm Exp jpm $
X *
X * $Log: defs.h,v $
X * Revision 1.1 1991/08/15 16:48:26 jpm
X * Initial revision
X *
X */
X
#include <stdio.h>
X
/*----------------------------------------------------------------------------
X |SYSTEMS Choose one of these. 'Systems' for HDB, and
X | L.sys for Version-2 UUCP
X +---------------------------------------------------------------------------*/
#define SYSTEMS "/usr/lib/uucp/Systems" /* */
/* #define SYSTEMS "/usr/lib/uucp/L.sys" /* */
/* #define SYSTEMS "/etc/uucp/Systems" /* SVR4 */
X
/*----------------------------------------------------------------------------
X | MAX_ENTRIES Indicates the number of lines in your SYSTEMS
X | file. (Well, not lines but nodes ;-)
X +---------------------------------------------------------------------------*/
#define MAX_ENTRIES 200
X
X
/*----------------------------------------------------------------------------
X | UNAME define this if you have uname(2) and
X | /usr/include/sys/utsname.h. I need them to find
X | The name of your local host.
X | I prefer this: it is faster.
X | SCO UNIX: if the command `uname -n' outputs nil,
X | you can set the value of nodename by
X | a `uname -S sysname' as Superuser, or
X | configure it into the kernel.
X |
X | SYSTEMID Use this, if you have a XENIX-like /etc/systemid
X | The file has your hostname on the first line.
X | If you have a xenix box: Try the command
X | $ uname -n
X | If you get no output (or null), your nodename
X | has not been compiled into the kernel. You can
X | do that first and use UNAME, or take any of
X | the others if you prefer.
X |
X | UUPIPE Define this if I should read the name of your
X | host via popen("uuname -l").
X | [Try not to use this...]
X |
X | HOSTNAME Define this to be the name of your host, if
X | all else fails.
X +---------------------------------------------------------------------------*/
#define UNAME /* */
/*#define HOSTNAME "myhost" /* */
/*#define UUPIPE "/usr/bin/uuname -l" /* */
/*#define SYSTEMID "/etc/systemid" /* */
X
#if defined(__STDC__) || defined(__cplusplus)
# define P_(s) s
#else
# define P_(s) ()
#endif
X
int main P_((int argc, char **argv));
int readSystems P_((void));
int showSystems P_((void));
int install P_((char *node, char *desc));
char *strsave P_((char *s));
char *strtok P_((char *s1, char *s2));
int myname P_((void));
X
#undef P_
SHAR_EOF
chmod 0644 defs.h ||
echo 'restore of defs.h failed'
Wc_c="`wc -c < 'defs.h'`"
test 2856 -eq "$Wc_c" ||
echo 'defs.h: original size 2856, current size' "$Wc_c"
fi
# ============= UUname.1 ==============
if test -f 'UUname.1' -a X"$1" != X"-c"; then
echo 'x - skipping UUname.1 (File already exists)'
else
echo 'x - extracting UUname.1 (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'UUname.1' &&
.\" UUname, Copyright 1991, Jan-Piet Mens
.\" License to freely use and distribute this software is hereby granted
.\" by the author, subject to the condition that this copyright notice
.\" remains intact. The author retains the exclusive right to publish
.\" derivative works based on this work, including, but not limited
.\" to, revised versions of this work
.\"
.\"
.\"
.\" $Header: /u/tools/etc/uu/UUname/RCS/UUname.1,v 1.3 1991/08/15 16:59:52 jpm Exp $
.\"
.\" $Log: UUname.1,v $
.\" Revision 1.3 1991/08/15 16:59:52 jpm
.\" Shorten example line
.\"
.\" Revision 1.2 1991/08/15 16:45:57 jpm
.\" Check.
.\"
.\" Revision 1.1 1991/08/15 16:45:29 jpm
.\" Initial revision
.\"
.\"
.TH UUNAME 1c "" "Local UUCP Commands"
.SH NAME
UUname - List UUCP names with description
.SH SYNOPSIS
.B UUname
[
.B -l
]
.SH DESCRIPTION
.B UUname
reads the
.I UUCP
Systems file and prints out system names of all systems that are accessible via
.I UUCP
with a short description of each.
.PP
If the
.B -l
option was given,
.B UUname
only prints the name of this system.
.PP
The description is taken from the
.B SYSTEMS
file, which looks like this:
.PP
.in 1i
.nf
# /usr/lib/uucp/Systems
#
#:Our major backbone, don't tell jerry
tom Any Hayes 2400 1234 "" \er\en in:-\er\en-in: nuup word: secret
#
#:Connected to `tweety' daily
jerry Any Hayes 2400 4321 ogin:-BREAK-ogin: auucp sword: none
sylvester None 19200 111 ogin: nogo
.fi
.in
.PP
A description for a node is made in a comment line which must be placed
directly prior to the actual system line. The description must
have a colon (:) directly after the hash symbol. The rest is used as
description for that system.
.br
In our example above,
.B UUname
would show
.PP
.in 1i
.nf
tom Our major backbone, don't tell jerry
jerry Connected to `tweety' daily
sylvester -
.in
.fi
.PP
where `sylvester' has no description.
.PP
Note that some
.B SYSTEMS
files do not allow comments, in which case, this program is not for you ;-)
.SH FILES
.IP "\fBSYSTEMS\fR"
.B UUname
reads this the file
"\fB/usr/lib/uucp/Systems\fR"
or similar.
to find system names and descriptions. This file could also
be called \fB/usr/lib/uucp/L.sys\fR on older
.I UUCP
versions.
.IP "\fB/etc/systemid\fR"
contains the host name of this system, if
.B UUname
was compiled with \fB-DSYSTEMID=\fR\fI/etc/systemid\fR. This will probably be
the case on
.I Xenix
systems.
.IP "\fB/usr/bin/uuname\fR"
a program to find the local hostname in a system independent manner. This
is used if
.B UUname
was compiled with \fB-DUUPIPE=\fR\fI/usr/bin/uuname -l\fR.
.SH DIAGNOSTICS
.IP "Usage: UUname [-l]"
if an illegal option was used
.IP "Can't open \fBSYSTEMS\fR: \fIreason\fR"
if the
.I /usr/lib/uucp/Systems
file could not be opened. Note this file is probably read-only to
.I uucp
.IP "Warning: too many entries in \fBSYSTEMS\fR"
.B UUname
was compiled with a
.B MAX_ENTRIES
value that is too small for the amount of system descriptions in the
.B SYSTEMS
file. Increase the value, and rebuild.
.SH NOTES
If
.B UUname
was compiled with \fB-DHOSTNAME\fR=\fImyhost\fR, and the host name of your
system is changed,
.B UUname
must be rebuilt.
.SH SEE ALSO
.I defs.h
in the
.B UUname
distribution
.br
uucp(1m)
.SH AUTHOR
Jan-Piet Mens - j...@logixwi.uucp
SHAR_EOF
chmod 0444 UUname.1 ||
echo 'restore of UUname.1 failed'
Wc_c="`wc -c < 'UUname.1'`"
test 3280 -eq "$Wc_c" ||
echo 'UUname.1: original size 3280, current size' "$Wc_c"
fi
# ============= INSTALL ==============
if test -f 'INSTALL' -a X"$1" != X"-c"; then
echo 'x - skipping INSTALL (File already exists)'
else
echo 'x - extracting INSTALL (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'INSTALL' &&
Installation Guide for UUname
-----------------------------
X
1. Unpack the sources into a new directory. Change into that directory
X and edit defs.h and Makefile. In defs.h, make the necessary
X adjustments to the configurable variables; they are explained there.
X Check the Makefile for BINDIR, and adjust accordingly.
X
2. Do a `make'. This will create an executable `UUname' in the
X current directory.
X
3. Test UUname, by reading the local hostname
X
X ./UUname -l
X
X This should give you the current name of your system.
X
4. Do an `su root' followed by a `make install', which will
X do the following:
X
X # cp UUname BINDIR
X # chown uucp BINDIR/UUname
X # chgrp uucp BINDIR/UUname
X # chmod 4111 BINDIR/UUname
X
X Note the 4111 permissions. This will set SUID on UUname, so it will
X be able to open the SYSTEMS file for reading it.
X
X $ ls -lg BINDIR/UUname
X ---s--x--x 1 uucp 20112 Aug 15 17:58 /u/local/bin/UUname
X
X
X Please install the manual page `UUname.1' manually. There are sooooo
X many different places. Put it in /usr/local/man or whatever.
X
5. Move away from the current directory, and do a
X
X $ UUname -l
X
X which should give you your current system name, followed by a
X
X $ UUname
X
X which should show you the accessible systems in your SYSTEMS file.
X
6. Start editing the descriptions for the SYSTEMS file ( see UUname.1)
X
7. Whew! finished ;-)
SHAR_EOF
chmod 0644 INSTALL ||
echo 'restore of INSTALL failed'
Wc_c="`wc -c < 'INSTALL'`"
test 1367 -eq "$Wc_c" ||
echo 'INSTALL: original size 1367, current size' "$Wc_c"
fi
# ============= README ==============
if test -f 'README' -a X"$1" != X"-c"; then
echo 'x - skipping README (File already exists)'
else
echo 'x - extracting README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'README' &&
UUname
------
X
A program like uuname(1) which can not only show the UUCP system names, but
also a short description of each. The description is kept in a clever place,
being as comment in the Systems/L.sys file.
X
X $ UUname
X tom Our major backbone, don't tell jerry
X jerry Connected to `tweety' daily
X sylvester -
X
Prerequisites:
X UUCP, preferably HDB (because I tested with HDB ;-) Should work
X with version 2 though.
X
I have tested this sofware succesfully on the following systems:
X
X SCO Xenix 2.3.x
X SCO UNIX 3.2.2
X ATT SYS 5 R4.0
X
See the file INSTALL for installation instructions.
X
X
Please send bugs, extensions, patches, flames, flowers and money to
X
X Jan-Piet Mens
X j...@logixwi.uucp
X
-------------------------------------------------------------------------------
X
/*
X * UUname, Copyright 1991, Jan-Piet Mens
X * License to freely use and distribute this software is hereby granted
X * by the author, subject to the condition that this copyright notice
X * remains intact. The author retains the exclusive right to publish
X * derivative works based on this work, including, but not limited
X * to, revised versions of this work
X */
SHAR_EOF
chmod 0644 README ||
echo 'restore of README failed'
Wc_c="`wc -c < 'README'`"
test 1155 -eq "$Wc_c" ||
echo 'README: original size 1155, current size' "$Wc_c"
fi
# ============= Copyright ==============
if test -f 'Copyright' -a X"$1" != X"-c"; then
echo 'x - skipping Copyright (File already exists)'
else
echo 'x - extracting Copyright (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'Copyright' &&
/*
X * UUname, Copyright 1991, Jan-Piet Mens
X * License to freely use and distribute this software is hereby granted
X * by the author, subject to the condition that this copyright notice
X * remains intact. The author retains the exclusive right to publish
X * derivative works based on this work, including, but not limited
X * to, revised versions of this work
X */
SHAR_EOF
chmod 0644 Copyright ||
echo 'restore of Copyright failed'
Wc_c="`wc -c < 'Copyright'`"
test 369 -eq "$Wc_c" ||
echo 'Copyright: original size 369, current size' "$Wc_c"
fi
# ============= Makefile ==============
if test -f 'Makefile' -a X"$1" != X"-c"; then
echo 'x - skipping Makefile (File already exists)'
else
echo 'x - extracting Makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
#
# UUname, Copyright 1991, Jan-Piet Mens
# License to freely use and distribute this software is hereby granted
# by the author, subject to the condition that this copyright notice
# remains intact. The author retains the exclusive right to publish
# derivative works based on this work, including, but not limited
# to, revised versions of this work
#
X
CC=gcc
#CC=cc
CFLAGS=-O -s -ansi
#CFLAGS= -g
X
BINDIR=/u/local/bin
X
X
# OWNER/GROUP is the owner of the files in /usr/lib/uucp
OWNER= uucp
GROUP= uucp
X
PROG=UUname
X
X
OBJ = UUname.o myname.o
SFILES= UUname.c myname.c
HFILES= defs.h
MANPAGE=UUname.1
SHARFILES= INSTALL README Copyright Makefile MANIFEST
X
$(PROG): $(OBJ)
X $(CC) $(CFLAGS) -o $(PROG) $(OBJ)
X
$(OBJ): Makefile
X
install: $(PROG)
X strip $(PROG)
X cp $(PROG) $(BINDIR)
X chown $(OWNER) $(BINDIR)/$(PROG)
X chgrp $(GROUP) $(BINDIR)/$(PROG)
X chmod 4111 $(BINDIR)/$(PROG)
X
$(OBJ): $(HFILES)
X
clean:
X rm -f *.o a.out core Part.0?
clobber: clean
X rm -f $(PROG)
X
dist: $(SFILES) $(HFILES) $(MANPAGE) $(SHARFILES)
X shar49 -n UUname -a -s 'j...@logixwi.UUCP' -o Part -l 50 -c \
X $(SFILES) $(HFILES) $(MANPAGE) $(SHARFILES)
SHAR_EOF
chmod 0644 Makefile ||
echo 'restore of Makefile failed'
Wc_c="`wc -c < 'Makefile'`"
test 1136 -eq "$Wc_c" ||
echo 'Makefile: original size 1136, current size' "$Wc_c"
fi
# ============= MANIFEST ==============
if test -f 'MANIFEST' -a X"$1" != X"-c"; then
echo 'x - skipping MANIFEST (File already exists)'
else
echo 'x - extracting MANIFEST (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'MANIFEST' &&
File Description
----------------------------------------------------------------------
Copyright Blabla
defs.h Configuration
INSTALL Installation guide
Makefile Instructions
myname.c Get hostname
README Read me 1st
UUname.c main()
UUname.1 Manual
MANIFEST This packing list
SHAR_EOF
chmod 0644 MANIFEST ||
echo 'restore of MANIFEST failed'
Wc_c="`wc -c < 'MANIFEST'`"
test 289 -eq "$Wc_c" ||
echo 'MANIFEST: original size 289, current size' "$Wc_c"
fi
exit 0
--
Jan-Piet Mens, Logix GmbH j...@logixwi.UUCP
Moritzstr. 50, D-6200 Wiesbaden ...!uunet!mcsun!unido!logixwi!jpm

0 new messages