Enhanced SYSV Getty, v1.1, part 4 of 4

Paul Sutcliffe Jr. paul at devon.lns.pa.us
Wed Jan 17 19:16:50 AEST 1990


#! /bin/sh

# Make a new directory for the getty sources, cd to it, and run kits 1
# thru 4 through sh.  When all 4 kits have been run, read README.

echo "This is getty 1.1 kit 4 (of 4).  If kit 4 is complete, the line"
echo '"'"End of kit 4 (of 4)"'" will echo at the end.'
echo ""
export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
mkdir man 2>/dev/null
echo Extracting Makefile.SH
sed >Makefile.SH <<'!STUFFY!FUNK!' -e 's/X//'
X:
X# $Id: Makefile.SH,v 1.1 90/01/16 16:12:10 paul Exp Locker: paul $
X#
X# Creates Makefile for getty distribution
X#
X# $Log:	Makefile.SH,v $
X# Revision 1.1  90/01/16  16:12:10  paul
X# Initial revision
X# 
X# 
X
Xcase $CONFIG in
X'')
X    if test ! -f config.sh; then
X	ln ../config.sh . || \
X	ln ../../config.sh . || \
X	ln ../../../config.sh . || \
X	(echo "Can't find config.sh."; exit 1)
X    fi
X    . config.sh
X    ;;
Xesac
Xcase "$0" in
X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
Xesac
X
X: add necessary modules based on config.sh
Xcase "$d_getutent" in
X"$define")
X    src=""
X    obj=""
X    ;;
X"$undef")
X    src="getutent.c"
X    obj="getutent.o"
X    ;;
Xesac
Xcase "$d_strdup" in
X"$undef")
X    src="$src strdup.c"
X    obj="$obj strdup.o"
X    ;;
Xesac
Xcase "$d_putenv" in
X"$undef")
X    src="$src putenv.c"
X    obj="$obj putenv.o"
X    ;;
Xesac
X
Xecho "Extracting Makefile (with variable substitutions)"
X$spitshell >Makefile <<!GROK!THIS!
X#
X# Makefile for getty distribution
X#
X# To recreate this file, make any changes in config.sh and then
X# say "sh Makefile.SH"
X#
X
XSHELL=	/bin/sh
X
X# compiler stuff -- check these
XCC=	$cc
XCFLAGS=	-O $ccflags $small
XLFLAGS=	$ldflags $split
XLINT=	lint -abchuvx
XLLIB=	$llib_termlib
X
X# where things go
XBIN=	$bin
XUUBIN=	$bin
X
X# what libraries are needed for termcap/terminfo routines?
XTLIB=	$termlib
X
X# what are we making
XSH=	Makefile.SH config.h.SH makedep.SH
XHDRS=	config.h defaults.h extern.h funcs.h getty.h patchlevel.h \\
X	table.h tune.h
XSRC=	main.c funcs.c defaults.c table.c $src
XOBJ=	main.o funcs.o defaults.o table.o $obj
XUUSRC=	umain.c funcs.c defaults.c table.c $src
XUUOBJ=	umain.o funcs.o defaults.o table.o $obj
X
X# rules
X
Xall:	getty uugetty manpages
X
Xclist:
X	@echo $(SRC) $(UUSRC) | $tr ' ' '\012' | $sort | $uniq > .clist
X
Xhlist:
X	@echo $(HDRS) | $tr ' ' '\012' > .hlist
X
Xshlist:
X	@echo $(SH) | $tr ' ' '\012' > .shlist
X!GROK!THIS!
X$spitshell >>Makefile <<'!NO!SUBS!'
X
Xgetty:	$(OBJ)
X	$(CC) $(LFLAGS) -o $@ $(OBJ) $(TLIB) 
X
Xuugetty: $(UUOBJ)
X	$(CC) $(LFLAGS) -o $@ $(UUOBJ) $(TLIB) 
X
Xmanpages:
X	cd man; make
X
Xinstall: getty uugetty
X	-mv $(BIN)/getty $(BIN)/getty-
X	-mv $(UUBIN)/uugetty $(UUBIN)/uugetty-
X	cp getty $(BIN)
X	cp uugetty $(UUBIN)
X	chmod 700 $(BIN)/getty $(UUBIN)/uugetty
X	strip $(BIN)/getty $(UUBIN)/uugetty
X	cd man; make install
X
Xlint:	$(SRC) umain.c
X	@echo "linting getty sources..."
X	echo "GETTY" >lint.out
X	$(LINT) $(SRC) $(LLIB) >>lint.out
X	@echo "linting uugetty sources..."
X	@echo '' >>lint.out
X	echo 'UUGETTY' >>lint.out
X	$(LINT) -DUUGETTY $(UUSRC) $(LLIB) >>lint.out
X	@echo "lint output is in lint.out"
X
Xclean:
X	rm -f umain.c *.o core *.out .*list Makefile.old
X	cd man; make clean
X
Xclobber: clean
X	rm -f getty uugetty
X	cd man; make clobber
X
Xrealclean: clobber
X
Xdepend:	makedep umain.c tune.h
X	chmod +x makedep
X	./makedep
X
X# special dependancies follow
X
Xumain.c: main.c
X	-ln main.c umain.c
X
Xumain.o:
X	$(CC) $(CFLAGS) -DUUGETTY -c umain.c
X
Xtune.h:	tune.H
X	@echo "Making a tune.h from the tune.H prototype file."
X	@echo "You may wish to edit tune.h before continuing."
X	-cp tune.H tune.h
X
X# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
X!NO!SUBS!
Xchmod 644 Makefile
X$eunicefix Makefile
!STUFFY!FUNK!
echo Extracting man/getutent.m4
sed >man/getutent.m4 <<'!STUFFY!FUNK!' -e 's/X//'
X.\" +----------
X.\" |	$Id: getutent.m4,v 1.1 90/01/16 16:02:41 paul Exp Locker: paul $
X.\" |
X.\" |	GETUTENT man page.
X.\" |
X.\" |	Copyright 1989,1990 by Paul Sutcliffe Jr.
X.\" |
X.\" |	Permission is hereby granted to copy, reproduce, redistribute,
X.\" |	or otherwise use this software as long as: there is no monetary
X.\" |	profit gained specifically from the use or reproduction or this
X.\" |	software, it is not sold, rented, traded or otherwise marketed,
X.\" |	and this copyright notice is included prominently in any copy
X.\" |	made.
X.\" |
X.\" |	The author make no claims as to the fitness or correctness of
X.\" |	this software for any use whatsoever, and it is provided as is. 
X.\" |	Any use of this software is at the user's own risk.
X.\" |
X.\"
X.\" +----------
X.\" |	$Log:	getutent.m4,v $
X.\" |	Revision 1.1  90/01/16  16:02:41  paul
X.\" |	Initial revision
X.\" |	
X.\" |	
X.\" 
X.\" +----------
X.\" | M4 configuration
X.\"
Xinclude(config.m4).\"
X.\"
X.\" +----------
X.\" | Manpage source follows:
X.\"
X.TH GETUTENT _library_section_
X.SH NAME
Xgetutent, getutline, setutent, endutent,
Xutmpname \- access utmp file entry
X.SH SYNOPSIS
X.B \#include <utmp.h>
X
X.B struct utmp *getutent();
X
X.B struct utmp *getutline(\fIline\fB)\fR;
X.br
X.B struct utmp *\fIline\fR;
X
X.B void setutent();
X
X.B void endutent();
X
X.B void utmpname(\fIfile\fB)\fR;
X.br
X.B char *\fIfile\fR;
X.SH DESCRIPTION
X.I Getutent
Xand
X.I getutline
Xeach return a pointer to a structure of the following type:
X.nf
X
X    struct utmp {
X	    char	ut_line[8];		/* tty name */
X	    char	ut_name[8];		/* user id */
X	    long	ut_time;			/* time on */
X    };
X
X.fi
X.I Getutent
Xreads in the next entry from a \fIutmp\fR\-like file.  If the file is
Xnot already open, it opens it.  If it reaches the end of file, it
Xfails.
X.PP
X.I Getutline
Xsearches forward from the current point in the
X.I utmp
Xfile until it finds an entry which has a
X.I ut_line
Xstring matching the
X.I line\->ut_line
Xstring.  If the end of file is reached without a match, it fails.
X.PP
X.I Setutent
Xresets the input stream to the beginning of the file.  This should be
Xdone before each search for a new entry if it is desired that the
Xentire file be examined.
X.PP
X.I Endutent
Xcloses the currently open file.
X.PP
X.I Utmpname
Xallows the user to change the name of the file examined, from
X.B _utmp_
Xto any other file.  It is most often expected that this other file
Xwill be
X.B _wtmp_\fR.
XIf the file does not exist, this will not be apparent until the first
Xattempt to reference the file is made.
X.I Utmpname
Xdoes not open the file.  It just closes the old file if it is
Xcurrently open and saves the new file name.
X.SH FILES
X_utmp_
X.br
X_wtmp_
X.SH BUGS
XThe most current entry is saved in a static structure.  Multiple
Xaccesses require that it be copied before further accesses are made.
X.PP
XThese routines use buffered standard I/O for input.
X.SH "SEE ALSO"
Xutmp(_file_section_)
X.SH AUTHOR
X.nf
XPaul Sutcliffe, Jr.  <paul at devon.lns.pa.us>
XUUCP: ...!rutgers!devon!paul
!STUFFY!FUNK!
echo Extracting man/makeconfig
sed >man/makeconfig <<'!STUFFY!FUNK!' -e 's/X//'
X:
X#
X# $Id: makeconfig,v 1.1 90/01/16 16:03:33 paul Exp Locker: paul $
X#
X# $Log:	makeconfig,v $
X# Revision 1.1  90/01/16  16:03:33  paul
X# Initial revision
X# 
X#
X
Xcase $CONFIG in
X'')
X    if test ! -f config.sh; then
X	ln ../config.sh . || \
X	ln ../../config.sh . || \
X	ln ../../../config.sh . || \
X	(echo "Can't find config.sh."; exit 1)
X    fi
X    . config.sh
X    ;;
Xesac
Xcase "$0" in
X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
Xesac
X
Xtmp=/tmp/mc$$
Xrmlist="$tmp"
Xtrap 'echo " "; $rm -f $rmlist; exit 1' 1 2 3
X
X: where is the source
Xsrc=..
Xtune=$src/tune.h
Xpatchlevel=$src/patchlevel.h
X
X: is package complete
Xif $test ! -f $tune; then
X    echo "Can't find tune.h."
X    exit 1
Xfi
X
X: things we can tell from tune.h
Xcppout=".cppout"
Xtuneout=".tune"
Xrmlist="$cppout $tuneout $rmlist"
X$cppstdin -I$src -I. $cppminus <<EOS >$cppout
X#include <$tune>
X#include <$patchlevel>
Xconsole=CONSOLE
Xdefaults=DEFAULTS
Xissue=ISSUE
Xlogin=LOGIN
X#ifdef	LOGUTMP
Xlogutmp="$define"
X#endif
X#ifdef	TRS16
Xtrs16="$define"
X#endif
X#ifdef	TRYMAIL
Xtrymail="$define"
Xnotify=NOTIFY
X#endif
X#ifdef	WARNCASE
Xwarncase="$define"
X#endif
Xrelease=RELEASE
Xdate=DATE
XEOS
X$sed 's/[ 	]//' <$cppout >$tuneout
Xchmod +x $tuneout
X. $tuneout
X
Xdefaults=`$echo $defaults | $sed 's;/\%s;;'`
X
X: things we cannot tell from tune.h
Xif $test ! -d /usr/lib/terminfo; then
X	termcap="$define"
Xfi
Xgtab=`basename $gettytab`
X
X: name the man pages
Xcase "$xenix" in
X"$define")
X    cmd=C; mcmd=M; system=S; library=S; file=F; misc=M
X    ;;
X"$undef")
X    cmd=1; mcmd=1m; system=2; library=3; file=4; misc=7
X    ;;
Xesac
X
X$cat <<EOC >config.m4
X.\" +----------
X.\" | local GETTY configurations
X.\"
X.\" define(\`_cmd_section_', $cmd)
X.\" define(\`_mcmd_section_', $mcmd)
X.\" define(\`_system_section_', $system)
X.\" define(\`_library_section_', $library)
X.\" define(\`_file_section_', $file)
X.\" define(\`_misc_section_', $misc)
X.\" define(\`_console_', $console)
X.\" define(\`_defaults_', $defaults)
X.\" define(\`_gettytab_', $gettytab)
X.\" define(\`_gtab_', $gtab)
X.\" define(\`_issue_', $issue)
X.\" define(\`_login_', $login)
X.\" define(\`_utmp_', $utmp)
X.\" define(\`_wtmp_', $wtmp)
X.\" define(\`RELEASE', $release)
X.\" define(\`DATE', $date)
X.\"
XEOC
X
Xcase "$logutmp" in
X"$define") $cat <<EOC >>config.m4
X.\" define(\`logutmp')
XEOC
X;;
Xesac
Xcase "$termcap" in
X"$define") $cat <<EOC >>config.m4
X.\" define(\`termcap')
XEOC
X;;
Xesac
Xcase "$trs16" in
X"$define") $cat <<EOC >>config.m4
X.\" define(\`trs16')
XEOC
X;;
Xesac
Xcase "$trymail" in
X"$define") $cat <<EOC >>config.m4
X.\" define(\`trymail')
X.\" define(\`_notify_', $notify)
XEOC
X;;
Xesac
Xcase "$ttytype" in
X"/*") $cat <<EOC >>config.m4
X.\" define(\`ttytype', $ttytype)
XEOC
X;;
Xesac
Xcase "$warncase" in
X"$define") $cat <<EOC >>config.m4
X.\" define(\`warncase')
XEOC
X;;
Xesac
X
X$rm -f $rmlist
X# grrr, don't ask
X$rm -f $cppout
X$rm -f $tuneout
!STUFFY!FUNK!
echo Extracting man/putenv.m4
sed >man/putenv.m4 <<'!STUFFY!FUNK!' -e 's/X//'
X.\" +----------
X.\" |	$Id: putenv.m4,v 1.1 90/01/16 16:03:53 paul Exp Locker: paul $
X.\" |
X.\" |	PUTENV man page.
X.\" |
X.\" |	Copyright 1989,1990 by Paul Sutcliffe Jr.
X.\" |
X.\" |	Permission is hereby granted to copy, reproduce, redistribute,
X.\" |	or otherwise use this software as long as: there is no monetary
X.\" |	profit gained specifically from the use or reproduction or this
X.\" |	software, it is not sold, rented, traded or otherwise marketed,
X.\" |	and this copyright notice is included prominently in any copy
X.\" |	made.
X.\" |
X.\" |	The author make no claims as to the fitness or correctness of
X.\" |	this software for any use whatsoever, and it is provided as is. 
X.\" |	Any use of this software is at the user's own risk.
X.\" |
X.\"
X.\" +----------
X.\" |	$Log:	putenv.m4,v $
X.\" |	Revision 1.1  90/01/16  16:03:53  paul
X.\" |	Initial revision
X.\" |	
X.\" |	
X.\" 
X.\" +----------
X.\" | M4 configuration
X.\"
Xinclude(config.m4).\"
X.\"
X.\" +----------
X.\" | Manpage source follows:
X.\"
X.TH PUTENV _library_section_
X.SH NAME
Xputenv \- change or add value to environment
X.SH SYNOPSIS
X.B int putenv(\fIstring\fB)\fR;
X.br
X.B char *\fIstring\fR;
X.SH DESCRIPTION
X.I String
Xpoints to a string of the form
X.I name=value.
X.I Putenv
Xmakes the value of the environment variable
X.I name
Xequal to
X.I value
Xby altering an existing variable or creating a new one.  In either
Xcase, the string pointed to by
X.I string
Xbecomes part of the environment, so altering the string changes
Xthe environment.  The space used by
X.I string
Xis no longer used once a new string\-defining
X.I name
Xis passed to
X.I putenv.
X.SH "RETURN VALUE"
X.I Putenv
Xreturns non\-zero if it was unable to obtain enough space via
X.I malloc
Xfor an expanded environment, otherwise zero.
X.SH "SEE ALSO"
Xexec(_system_section_),
Xgetenv(_library_section_),
Xmalloc(_library_section_),
Xenviron(_file_section_)
X.SH WARNINGS
X.I Putenv
Xmanipulates the environment pointed to by
X.I environ,
Xand can be used in conjunction with
X.I getenv.
XHowever,
X.I envp
X(the third argument to
X.I main\fR)
Xis not changed.
X.PP
XThis routine uses
X.I malloc(_library_section_)
Xto enlarge the environment.
X.PP
XAfter
X.I putenv
Xis called, environmental variables are not in alphabetical order.
X.PP
XA potential error is to call
X.I putenv
Xwith an automatic variable as the argument, then exit the calling
Xfunction while
X.I string
Xis still part of the environment.
X.SH AUTHOR
X.nf
XPaul Sutcliffe, Jr.  <paul at devon.lns.pa.us>
XUUCP: ...!rutgers!devon!paul
!STUFFY!FUNK!
echo Extracting getty.h
sed >getty.h <<'!STUFFY!FUNK!' -e 's/X//'
X/*
X**	$Id: getty.h,v 1.1 90/01/16 16:15:30 paul Exp Locker: paul $
X**
X**	Included by all getty modules
X*/
X
X/*
X**	Copyright 1989,1990 by Paul Sutcliffe Jr.
X**
X**	Permission is hereby granted to copy, reproduce, redistribute,
X**	or otherwise use this software as long as: there is no monetary
X**	profit gained specifically from the use or reproduction or this
X**	software, it is not sold, rented, traded or otherwise marketed,
X**	and this copyright notice is included prominently in any copy
X**	made.
X**
X**	The author make no claims as to the fitness or correctness of
X**	this software for any use whatsoever, and it is provided as is. 
X**	Any use of this software is at the user's own risk.
X*/
X
X/*
X**	$Log:	getty.h,v $
X**	Revision 1.1  90/01/16  16:15:30  paul
X**	Initial revision
X**	
X*/
X
X
X#include <stdio.h>
X#include <string.h>
X#include <sys/types.h>
X#include <termio.h>
X#ifndef	TCGETA
X#include <sys/ioctl.h>
X#endif	/* TCGETA */
X#include <utmp.h>
X
X#include "config.h"
X#include "extern.h"
X#include "funcs.h"
X
X
X/*	General purpose defines
X */
X
X#ifndef	FALSE
X#define	FALSE	(0)
X#endif	/* FALSE */
X#ifndef	TRUE
X#define	TRUE	(1)
X#endif	/* TRUE */
X
X#define OK	(0)
X
X#define SUCCESS	(0)		/* normal return */
X#define FAIL	(-1)		/* error return */
X
X#define	STDIN	fileno(stdin)
X#define	STDOUT	fileno(stdout)
X
X#define strequal(s1, s2)	(strcmp(s1, s2) == 0)
X#define strnequal(s1, s2, n)	(strncmp(s1, s2, n) == 0)
X#define	strncopy(s1, s2)	(strncpy(s1, s2, sizeof(s1)))
X
Xtypedef	struct termio	TERMIO;
X
X
X#ifdef	DEBUG
X
X/* debug levels
X */
X#define	D_OPT	0001		/* option settings */
X#define	D_DEF	0002		/* defaults file processing */
X#define	D_UTMP	0004		/* utmp/wtmp processing */
X#define	D_INIT	0010		/* line initialization (INIT) */
X#define	D_GTAB	0020		/* gettytab file processing */
X#define	D_GETL	0040		/* get login name routine */
X#define	D_RUN	0100		/* other runtime diagnostics */
X
X#ifdef	UUGETTY
X#define	D_LOCK	0200		/* uugetty lockfile processing */
X#endif	/* UUGETTY */
X
X/* debug defs
X */
X#define	debug1(a,b)		dprint(a,b)
X#define	debug2(a,b)		debug(a,b)
X#define	debug3(a,b,c)		debug(a,b,c)
X#define	debug4(a,b,c,d)		debug(a,b,c,d)
X#define	debug5(a,b,c,d,e)	debug(a,b,c,d,e)
X#define	debug6(a,b,c,d,e,f)	debug(a,b,c,d,e,f)
X
X#else	/* DEBUG */
X
X#define	debug1(a,b)		/* define to nothing, disables debugging */
X#define	debug2(a,b)
X#define	debug3(a,b,c)
X#define	debug4(a,b,c,d)
X#define	debug5(a,b,c,d,e)
X#define	debug6(a,b,c,d,e,f)
X
X#endif	/* DEBUG */
X
X
X/* end of getty.h */
!STUFFY!FUNK!
echo Extracting extern.h
sed >extern.h <<'!STUFFY!FUNK!' -e 's/X//'
X/*
X**	$Id: extern.h,v 1.1 90/01/16 16:14:05 paul Exp Locker: paul $
X**
X**	Defines all external values.
X*/
X
X/*
X**	Copyright 1989,1990 by Paul Sutcliffe Jr.
X**
X**	Permission is hereby granted to copy, reproduce, redistribute,
X**	or otherwise use this software as long as: there is no monetary
X**	profit gained specifically from the use or reproduction or this
X**	software, it is not sold, rented, traded or otherwise marketed,
X**	and this copyright notice is included prominently in any copy
X**	made.
X**
X**	The author make no claims as to the fitness or correctness of
X**	this software for any use whatsoever, and it is provided as is. 
X**	Any use of this software is at the user's own risk.
X*/
X
X/*
X**	$Log:	extern.h,v $
X**	Revision 1.1  90/01/16  16:14:05  paul
X**	Initial revision
X**	
X*/
X
X
X#ifdef	MAIN			/* define as "extern", except for MAIN,	*/
X#define EXTERN			/* which is defined only in main.c	*/
X#else
X#define EXTERN	extern
X#endif	/* MAIN */
X
X
X/*	Global variables
X */
X
X#ifdef	MAIN
XEXTERN	STDCHAR	MsgBuf[80];	/* message buffer */
X#else
XEXTERN	STDCHAR	MsgBuf[];
X#endif	/* MAIN */
X
XEXTERN	boolean	Check;		/* check a gettytab file? */
XEXTERN	char	*CheckFile;	/* gettytab-like file to check */
XEXTERN	char	*Device;	/* controlling line (minus "/dev/") */
XEXTERN	char	*GtabId;	/* current gettytab id */
XEXTERN	boolean	NoHangUp;	/* don't hangup line before setting speed */
XEXTERN	char	*LineD;		/* line discipline */
XEXTERN	char	*MyName;	/* this program name */
XEXTERN	int	Nusers;		/* number of users currently logged in */
XEXTERN	char	*Speed;		/* current baud rate (string literal) */
XEXTERN	char	*SysName;	/* nodename of system */
XEXTERN	int	TimeOut;	/* timeout value from command line */
XEXTERN	char	*Version;	/* value of VERSION */
X
X#ifdef	WARNCASE
XEXTERN	boolean	WarnCase;	/* controls display of bad case message */
X#endif	/* WARNCASE */
X
X#ifdef	DEBUG
XEXTERN	int	Debug;		/* debug value from command line */
XEXTERN	FILE	*Dfp;		/* debug output file pointer */
X#endif	/* DEBUG */
X
X
X/*	System routines
X */
X
Xextern	int	fputc();
Xextern	char	*malloc(), *ttyname();
Xextern	unsigned alarm(), sleep();
Xextern	time_t	time();
X
X#ifndef	STRDUP			/* Is There In Truth No Strdup() ? */
Xextern	char	*strdup();
X#endif	/* STRDUP */
X
X#ifndef	GETUTENT		/* How about getutent() ? */
Xextern	struct utmp	*getutent();
Xextern	void		setutent(), endutent();
X#endif	/* GETUTENT */
X
X#ifndef	PUTENV			/* putenv() ? */
Xextern	int	putenv();
X#endif	/* PUTENV */
X
X
X/* end of extern.h */
!STUFFY!FUNK!
echo Extracting sample.files
sed >sample.files <<'!STUFFY!FUNK!' -e 's/X//'
XThese examples are from the author's system.
X
XSample `/etc/issue' file:
X+---------
X| Devon Computer Services, Lancaster, PA  (@S)
X| Tandy XENIX/68000 Version @V
X+---------
X
XSample `/etc/default/getty' file:
X+---------
X| ISSUE=/etc/issue
X| VERSION=/etc/version
X+---------
X
XSample `/etc/default/uugetty' file:
X+---------
X| CLEAR=NO
X| ISSUE=Devon Computer Services - Tandy 6000  (@S)\n[@L, @B bps]\n
X| INIT=A\pA\pA\pAT\r OK\r\n-ATZ\r-OK\r\n ATZ\r OK\r\n
X| WAITCHAR=YES
X| DELAY=15
X| TIMEOUT=60
X+---------
X
XSample `/etc/gettydefs' file:
X+---------
X| #
X| # Sample /etc/gettydefs file; use at your own risk!
X| #
X| # default entry:
X| 0# B9600 CS8 # B9600 CLOCAL TAB3 ECHO SANE #login: #0
X| 
X| # to toggle between 300 and 1200 baud on a modem line:
X| #
X| 1# B300 ISTRIP CS8 CR1 # B300 HUPCL CS8 TAB3 SANE CR1 #login: #2
X| 
X| 2# B1200 ISTRIP CS8 # B1200 HUPCL CS8 TAB3 SANE #login: #1
X| 
X| # to toggle between 300, 1200 and 2400 baud on a modem line:
X| #
X| 3# B300 ISTRIP CS8 CR1 # B300 HUPCL CS8 TAB3 SANE CR1 #login: #4
X| 
X| 4# B1200 ISTRIP CS8 # B1200 HUPCL CS8 TAB3 SANE #login: #5
X| 
X| 5# B2400 ISTRIP CS8 # B2400 HUPCL CS8 TAB3 SANE #login: #3
X| 
X| # a telebit tb plus:
X| #
X| 6# B9600 ISTRIP CS8 # B9600 HUPCL CS8 TAB3 SANE #FAST login: #7
X| 
X| 7# B2400 ISTRIP CS8 # B2400 HUPCL CS8 TAB3 SANE #login: #8
X| 
X| 8# B1200 ISTRIP CS8 # B1200 HUPCL CS8 TAB3 SANE #login: #6
X| 
X| # various hard-wired speeds
X| a# B50 ISTRIP CS8 NL1 CR3 TAB2 # B50 CS8 CLOCAL SANE NL1 CR3 TAB2 #login: #a
X| 
X| b# B75 ISTRIP CS8 NL1 CR2 TAB2 # B75 CS8 CLOCAL SANE NL1 CR2 TAB2 #login: #b
X| 
X| c# B110 ISTRIP CS8 NL1 CR1 TAB1 # B110 CS8 CLOCAL SANE NL1 CR1 TAB1 #login: #c
X| 
X| d# B134 ISTRIP CS8 NL1 CR1 TAB1 # B134 CS8 CLOCAL SANE NL1 CR1 TAB1 #login: #d
X| 
X| e# B150 ISTRIP CS8 NL1 CR1 # B150 CS8 CLOCAL TAB3 SANE NL1 CR1 #login: #e
X| 
X| f# B200 ISTRIP CS8 NL1 CR1 # B200 CS8 CLOCAL TAB3 SANE NL1 CR1 #login: #f
X| 
X| g# B300 ISTRIP CS8 CR1 # B300 CS8 CLOCAL TAB3 SANE CR1 #login: #g
X| 
X| h# B600 ISTRIP CS8 # B600 CS8 CLOCAL TAB3 SANE #login: #h
X| 
X| i# B1200 ISTRIP CS8 # B1200 CS8 CLOCAL TAB3 SANE #login: #i
X| 
X| j# B1800 ISTRIP CS8 # B1800 CS8 CLOCAL TAB3 SANE #login: #j
X| 
X| k# B2400 ISTRIP CS8 # B2400 CS8 CLOCAL TAB3 SANE #login: #k
X| 
X| l# B4800 ISTRIP CS8 # B4800 CS8 CLOCAL TAB3 SANE #login: #l
X| 
X| m# B9600 ISTRIP CS8 # B9600 CS8 CLOCAL TAB3 SANE #login: #m
X| 
X+---------
!STUFFY!FUNK!
echo Extracting tune.H
sed >tune.H <<'!STUFFY!FUNK!' -e 's/X//'
X/*
X**	$Id: tune.H,v 1.1 90/01/16 16:20:41 paul Exp Locker: paul $
X**
X**	Getty tuneable parameters.
X*/
X
X/*
X**	Copyright 1989,1990 by Paul Sutcliffe Jr.
X**
X**	Permission is hereby granted to copy, reproduce, redistribute,
X**	or otherwise use this software as long as: there is no monetary
X**	profit gained specifically from the use or reproduction or this
X**	software, it is not sold, rented, traded or otherwise marketed,
X**	and this copyright notice is included prominently in any copy
X**	made.
X**
X**	The author make no claims as to the fitness or correctness of
X**	this software for any use whatsoever, and it is provided as is. 
X**	Any use of this software is at the user's own risk.
X*/
X
X/*
X**	$Log:	tune.H,v $
X**	Revision 1.1  90/01/16  16:20:41  paul
X**	Initial revision
X**	
X*/
X
X
X#define	boolean	 int			/* does your cc know about boolean? */
X
X#define	DEF_CFL	 (CS7 | PARENB)		/* default word-len/parity */
X
X
X/*  Feature selection
X */
X
X#undef	DEBUG				/* include debugging code */
X#define	LOGUTMP				/* need to update utmp/wtmp files */
X#define	MY_CANON			/* use my own ERASE and KILL chars */
X#define	RCSID				/* include RCS ID info in objects */
X#define	SETTERM				/* need to set TERM in environment */
X#define	TRYMAIL				/* mail errors if CONSOLE unavailable */
X#define	WARNCASE			/* warn user if login is UPPER case */
X
X/*  define your ERASE and KILL characters here
X */
X#ifdef	MY_CANON
X#define	MY_ERASE '\010'			/* 010 = ^H, backspace */
X#define	MY_KILL	 '\025'			/* 025 = ^U, nak */
X#endif
X
X/*  who should be notified of errors?
X */
X#ifdef	TRYMAIL
X#define	NOTIFY	 "root"
X#endif
X
X
X/*  Where to find things
X */
X
X#define	CONSOLE	 "/dev/console"		/* place to log errors */
X#define	DEFAULTS "/etc/default/%s"	/* name of defaults file */
X#define	ISSUE	 "/etc/issue"		/* name of the issue file;
X					   say "#undef ISSUE" to turn off
X					   the issue feature */
X#define	LOGIN	 "/bin/login"		/* name of login program */
X
X
X/*  Special cases
X */
X
X#undef	TRS16				/* you are a Tandy 6000 or equivilent */
X
X
X/*  You probably shouldn't fool with these
X */
X
X#define	MAXDEF	 100			/* max # lines in defaults file */
X#define	MAXLINE	 256			/* max # chars in a line */
X#define	MAXID	 12			/* max # chars in Gtab Id */
X#define	MAXLOGIN 80			/* max # chars in Gtab Login */
X
X
X/* end of tune.h */
!STUFFY!FUNK!
echo Extracting getutent.c
sed >getutent.c <<'!STUFFY!FUNK!' -e 's/X//'
X/*
X**	$Id: getutent.c,v 1.1 90/01/16 16:15:51 paul Exp Locker: paul $
X**
X**	Implements getutent(3).
X*/
X
X/*
X**	Copyright 1989,1990 by Paul Sutcliffe Jr.
X**
X**	Permission is hereby granted to copy, reproduce, redistribute,
X**	or otherwise use this software as long as: there is no monetary
X**	profit gained specifically from the use or reproduction or this
X**	software, it is not sold, rented, traded or otherwise marketed,
X**	and this copyright notice is included prominently in any copy
X**	made.
X**
X**	The author make no claims as to the fitness or correctness of
X**	this software for any use whatsoever, and it is provided as is. 
X**	Any use of this software is at the user's own risk.
X*/
X
X/*
X**	$Log:	getutent.c,v $
X**	Revision 1.1  90/01/16  16:15:51  paul
X**	Initial revision
X**	
X*/
X
X
X#include "getty.h"
X
X#if defined(RCSID) && !defined(lint)
Xstatic char *RcsId =
X"@(#)$Id: getutent.c,v 1.1 90/01/16 16:15:51 paul Exp Locker: paul $";
X#endif
X
Xtypedef	struct utmp	UTMP;
X
Xstatic	char	*utmpfil = UTMP_FILE;	/* default utmp file */
Xstatic	FILE	*ufp = (FILE *) NULL;	/* file pointer to utmp file */
X					/* NULL = no utmp file open  */
Xstatic	UTMP	ut;			/* buffer for utmp record */
X
X
X/*
X**	getutent() - get next valid utmp entry
X**
X**	Returns (UTMP*)NULL if no vaild entry found.
X*/
X
XUTMP *
Xgetutent()
X{
X	if (ufp == (FILE *) NULL)
X		if ((ufp = fopen(utmpfil, "r+")) == (FILE *) NULL)
X			return((UTMP *) NULL);
X
X	do {
X		if (fread((char *)&ut, sizeof(ut), 1, ufp) != 1)
X			return((UTMP *) NULL);
X
X	} while (ut.ut_name[0] == '\0');	/* valid entry? */
X
X	return(&ut);
X}
X
X
X/*
X**	getutline() - get utmp entry that matches line.
X**
X**	Returns (UTMP*)NULL if no match found.
X*/
X
XUTMP *
Xgetutline(line)
XReg1 UTMP *line;
X{
X	do {
X		if (strequal(ut.ut_line, line->ut_line))
X			return(&ut);	/* match! */
X
X	} while (getutent() != NULL);
X
X	return((UTMP *) NULL);
X}
X
X
X/*
X**	setutent() - rewind utmp back to beginning
X*/
X
Xvoid
Xsetutent()
X{
X	if (ufp != (FILE *) NULL)
X		rewind(ufp);
X}
X	
X
X/*
X**	endutent() - close utmp file
X*/
X
Xvoid
Xendutent()
X{
X	if (ufp != (FILE *) NULL) {
X		(void) fclose(ufp);
X		ufp = (FILE *) NULL;
X	}
X}
X
X
X/*
X**	utmpname() - change utmp file name to "file"
X*/
X
Xvoid
Xutmpname(file)
XReg1 char *file;
X{
X	endutent();
X	utmpfil = strdup(file);
X}
X
X
X/* end of getutent.c */
!STUFFY!FUNK!
echo Extracting man/Makefile.SH
sed >man/Makefile.SH <<'!STUFFY!FUNK!' -e 's/X//'
X:
X# $Id: Makefile.SH,v 1.1 90/01/16 16:01:02 paul Exp Locker: paul $
X#
X# Creates man/Makefile for getty distribution
X#
X# $Log:	Makefile.SH,v $
X# Revision 1.1  90/01/16  16:01:02  paul
X# Initial revision
X# 
X# 
X
Xcase $CONFIG in
X'')
X    if test ! -f config.sh; then
X	ln ../config.sh . || \
X	ln ../../config.sh . || \
X	ln ../../../config.sh . || \
X	(echo "Can't find config.sh."; exit 1)
X    fi
X    . config.sh
X    ;;
Xesac
Xcase "$0" in
X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
Xesac
X
Xgtab=`basename $gettytab`
Xman="getty.man $gtab.man issue.man"
Xcase "$d_getutent" in
X"$undef")
X    man="$man getutent.man"
X    ;;
Xesac
Xcase "$d_strdup" in
X"$undef")
X    man="$man strdup.man"
X    ;;
Xesac
Xcase "$d_putenv" in
X"$undef")
X    man="$man putenv.man"
X    ;;
Xesac
X
Xecho "Extracting man/Makefile (with variable substitutions)"
X$spitshell >Makefile <<!GROK!THIS!
X#
X# Makefile for getty man pages
X#
X
XSHELL=	/bin/sh
XROFF=	nroff -man
X
XSRC=	..
XTUNE=	$(SRC)/tune.h
XPATLVL=	$(SRC)/patchlevel.h
X
X# what to make
Xall:	$man
X
Xinstall:
X	@echo "Installation must be done manually, Sorry."
X
X# how to make it
X.SUFFIXES: .m4 .3 .man
X
X.m4.3:
X	m4 \$*.m4 > \$*.3
X
X.3.man:
X	$(ROFF) \$*.3 > \$*.man
X
X# dependencies
Xconfig.m4:	$(SRC)/config.sh $(TUNE) $(PATLVL)
X	chmod +x makeconfig
X	./makeconfig
X
Xgetty.1m:	getty.m4 config.m4
X	m4 getty.m4 > getty.1m
X
Xgetty.man:	getty.1m
X	$(ROFF) getty.1m > getty.man
X
X$gtab.4:	gettytab.m4 config.m4
X	m4 gettytab.m4 > $gtab.4
X
X$gtab.man:	$gtab.4
X	$(ROFF) $gtab.4 > $gtab.man
X
Xissue.4:	issue.m4 config.m4
X	m4 issue.m4 > issue.4
X
Xissue.man:	issue.4
X	$(ROFF) issue.4 > issue.man
X
Xgetutent.3:	getutent.m4 config.m4
X
Xgetutent.man:	getutent.3
X
Xstrdup.3:	strdup.m4 config.m4
X
Xstrdup.man:	strdup.3
X
Xputenv.3:	putenv.m4 config.m4
X
Xputenv.man:	putenv.3
X
Xclean:
X	rm -f *.out config.m4 config.sh core
X
Xclobber: clean
X	rm -f *.1m *.[34] *.man
X
X!GROK!THIS!
Xchmod 644 Makefile
X$eunicefix Makefile
!STUFFY!FUNK!
echo Extracting man/issue.m4
sed >man/issue.m4 <<'!STUFFY!FUNK!' -e 's/X//'
X.\" +----------
X.\" |	$Id: issue.m4,v 1.1 90/01/16 16:03:09 paul Exp Locker: paul $
X.\" |
X.\" |	ISSUE man page.
X.\" |
X.\" |	Copyright 1989,1990 by Paul Sutcliffe Jr.
X.\" |
X.\" |	Permission is hereby granted to copy, reproduce, redistribute,
X.\" |	or otherwise use this software as long as: there is no monetary
X.\" |	profit gained specifically from the use or reproduction or this
X.\" |	software, it is not sold, rented, traded or otherwise marketed,
X.\" |	and this copyright notice is included prominently in any copy
X.\" |	made.
X.\" |
X.\" |	The author make no claims as to the fitness or correctness of
X.\" |	this software for any use whatsoever, and it is provided as is. 
X.\" |	Any use of this software is at the user's own risk.
X.\" |
X.\"
X.\" +----------
X.\" |	$Log:	issue.m4,v $
X.\" |	Revision 1.1  90/01/16  16:03:09  paul
X.\" |	Initial revision
X.\" |	
X.\" |	
X.\" 
X.\" +----------
X.\" | M4 configuration
X.\"
Xinclude(config.m4).\"
X.\"
X.\" +----------
X.\" | Manpage source follows:
X.\"
X.TH ISSUE _file_section_
X.SH NAME
Xissue \- issue identification file
X.SH DESCRIPTION
XThe file
X.B _issue_
Xcontains the
X.I issue
Xor project identification to be printed as a login prompt.  This
Xis an ASCII file which is read by the program
X.I getty
Xand then written to the terminal just prior to printing the
X.I login:
Xprompt.
X.PP
XThe line(s) may contain various
X.B @\fIchar\fR
Xand
X.B \\\\\fIchar\fR
Xparameters.  These are described in full in the
X.I getty(_mcmd_section_)
Xsection PROMPT SUBSTITUTIONS.
X.SH FILES
X_issue_
X.SH "SEE ALSO"
Xgetty(_mcmd_section_)
!STUFFY!FUNK!
echo Extracting table.h
sed >table.h <<'!STUFFY!FUNK!' -e 's/X//'
X/*
X**	$Id: table.h,v 1.1 90/01/16 16:19:26 paul Exp Locker: paul $
X**
X**	Defines the structures and functions used to parse the
X**	gettytab file.
X*/
X
X/*
X**	Copyright 1989,1990 by Paul Sutcliffe Jr.
X**
X**	Permission is hereby granted to copy, reproduce, redistribute,
X**	or otherwise use this software as long as: there is no monetary
X**	profit gained specifically from the use or reproduction or this
X**	software, it is not sold, rented, traded or otherwise marketed,
X**	and this copyright notice is included prominently in any copy
X**	made.
X**
X**	The author make no claims as to the fitness or correctness of
X**	this software for any use whatsoever, and it is provided as is. 
X**	Any use of this software is at the user's own risk.
X*/
X
X/*
X**	$Log:	table.h,v $
X**	Revision 1.1  90/01/16  16:19:26  paul
X**	Initial revision
X**	
X*/
X
X
X#ifndef	LDISC0
X#define	LDISC0	0			/* default line discipline */
X#endif	/* LDISC0 */
X
X#ifndef	GETTYTAB
X#define	GETTYTAB  "/etc/gettydefs"	/* default name of the gettytab file */
X#endif	/* GETTYTAB */
X
Xtypedef	struct Gettytab {
X	char	*cur_id;		/* current label */
X	TERMIO	itermio;		/* initial termio flags */
X	TERMIO	ftermio;		/* final termio flags */
X	char	*login;			/* login prompt */
X	char	*next_id;		/* next label */
X} GTAB;
X
Xtypedef	struct SymTab {
X	char	*symbol;		/* symbolic name */
X	ushort	value;			/* actual value */
X} SYMTAB;
X
XGTAB	*gtabvalue();
X
X
X/* end of table.h */
!STUFFY!FUNK!
echo Extracting strdup.c
sed >strdup.c <<'!STUFFY!FUNK!' -e 's/X//'
X/*
X**	$Id: strdup.c,v 1.1 90/01/16 16:18:37 paul Exp Locker: paul $
X**
X**	Implements strdup(3c) [strdup(S) for you Xenix-types].
X*/
X
X/*
X**	Copyright 1989,1990 by Paul Sutcliffe Jr.
X**
X**	Permission is hereby granted to copy, reproduce, redistribute,
X**	or otherwise use this software as long as: there is no monetary
X**	profit gained specifically from the use or reproduction or this
X**	software, it is not sold, rented, traded or otherwise marketed,
X**	and this copyright notice is included prominently in any copy
X**	made.
X**
X**	The author make no claims as to the fitness or correctness of
X**	this software for any use whatsoever, and it is provided as is. 
X**	Any use of this software is at the user's own risk.
X*/
X
X/*
X**	$Log:	strdup.c,v $
X**	Revision 1.1  90/01/16  16:18:37  paul
X**	Initial revision
X**	
X*/
X
X
X#include "getty.h"
X
X#if defined(RCSID) && !defined(lint)
Xstatic char *RcsId =
X"@(#)$Id: strdup.c,v 1.1 90/01/16 16:18:37 paul Exp Locker: paul $";
X#endif
X
X/*
X**	strdup() - duplicates string s in memory.
X**
X**	Returns a pointer to the new string, or NULL if an error occurrs.
X*/
X
Xchar *
Xstrdup(s)
XReg1 char *s;
X{
X	Reg2 char *p = (char *) NULL;
X
X	if (s != (char *) NULL)
X		if ((p = malloc((unsigned) (strlen(s)+1))) != (char *) NULL)
X			(void) strcpy(p, s);
X
X	return(p);
X}
X
X
X/* end of strdup.c */
!STUFFY!FUNK!
echo Extracting MANIFEST
sed >MANIFEST <<'!STUFFY!FUNK!' -e 's/X//'
XAfter all the getty kits are run you should have the following files:
X
XFilename		Kit Description
X--------		--- -----------
XConfigure                2 Determines system configuration.
XMANIFEST                 4 Packing list.
XMakefile.SH              4 Creates Makefile file.
XREADME                   1 The Instructions.
Xconfig.h.SH              3 Creates config.h file.
Xdefaults.c               3 Routines to access the runtime defaults file.
Xdefaults.h               4 Defines the defaults file structures.
Xextern.h                 4 Defines all external values.
Xfuncs.c                  1 Miscellaneous routines.
Xfuncs.h                  4 Definitions for miscellaneous routines.
Xgetty.h                  4 Common header for all modules.
Xgetutent.c               4 Implements getutent(3).
Xmain.c                   1 Main body of program.
Xmakedep.SH               2 Creates makedep file.
Xman/Makefile.SH          4 Creates man/Makefile file.
Xman/README               1 Notes about the manual pages.
Xman/getty.m4             3 M4 source to getty manpage.
Xman/gettytab.m4          3 M4 source to gettytab manpage.
Xman/getutent.m4          4 M4 source to getutent manpage.
Xman/issue.m4             4 M4 source to issue manpage.
Xman/makeconfig           4 Creates config.m4 file.
Xman/putenv.m4            4 M4 source to putenv manpage.
Xman/strdup.m4            1 M4 source to strdup manpage.
Xpatchlevel.h             2 Getty release/patchlevel.
Xputenv.c                 3 Implements putenv(3c).
Xsample.files             4 Sample ancillary files.
Xstrdup.c                 4 Implements strdup(3c).
Xtable.c                  3 Routines to process the gettytab file.
Xtable.h                  4 Defines the gettytab structures.
Xtune.H                   4 Sample tune.h file.
!STUFFY!FUNK!
echo Extracting defaults.h
sed >defaults.h <<'!STUFFY!FUNK!' -e 's/X//'
X/*
X**	$Id: defaults.h,v 1.1 90/01/16 16:13:44 paul Exp Locker: paul $
X**
X**	Defines the structures and functions used to read runtime
X**	defaults.
X*/
X
X/*
X**	Copyright 1989,1990 by Paul Sutcliffe Jr.
X**
X**	Permission is hereby granted to copy, reproduce, redistribute,
X**	or otherwise use this software as long as: there is no monetary
X**	profit gained specifically from the use or reproduction or this
X**	software, it is not sold, rented, traded or otherwise marketed,
X**	and this copyright notice is included prominently in any copy
X**	made.
X**
X**	The author make no claims as to the fitness or correctness of
X**	this software for any use whatsoever, and it is provided as is. 
X**	Any use of this software is at the user's own risk.
X*/
X
X/*
X**	$Log:	defaults.h,v $
X**	Revision 1.1  90/01/16  16:13:44  paul
X**	Initial revision
X**	
X*/
X
X
X/* lines in defaults file are in the form "NAME=value"
X */
X
Xtypedef struct Default {
X	char	*name;		/* name of the default */
X	char	*value;		/* value of the default */
X} DEF;
X
X
XDEF	**defbuild();		/* user-level routines */
Xchar	*defvalue();
X
XFILE	*defopen();		/* low-level routines */
XDEF	*defread();
Xint	defclose();
X
X
X/* end of defaults.h */
!STUFFY!FUNK!
echo Extracting funcs.h
sed >funcs.h <<'!STUFFY!FUNK!' -e 's/X//'
X/*
X**	$Id: funcs.h,v 1.1 90/01/16 16:14:53 paul Exp Locker: paul $
X**
X**	Defines the miscellaneous functions.
X*/
X
X/*
X**	Copyright 1989,1990 by Paul Sutcliffe Jr.
X**
X**	Permission is hereby granted to copy, reproduce, redistribute,
X**	or otherwise use this software as long as: there is no monetary
X**	profit gained specifically from the use or reproduction or this
X**	software, it is not sold, rented, traded or otherwise marketed,
X**	and this copyright notice is included prominently in any copy
X**	made.
X**
X**	The author make no claims as to the fitness or correctness of
X**	this software for any use whatsoever, and it is provided as is. 
X**	Any use of this software is at the user's own risk.
X*/
X
X/*
X**	$Log:	funcs.h,v $
X**	Revision 1.1  90/01/16  16:14:53  paul
X**	Initial revision
X**	
X*/
X
X
X/*	States for settermio()
X */
X#define	INITIAL	 0
X#define	FINAL	 1
X
X/*	Return values for getlogname()
X */
X#define	BADSPEED 1
X#define	BADCASE	 2
X#define	NONAME	 3
X
X
Xint	Fputs(), initialize(), getlogname();
Xchar	*getuname();
Xvoid	settermio(), logerr();
X
X#ifdef	DEBUG
Xvoid	debug(), dprint();
X#endif	/* DEBUG */
X
X
X/* end of funcs.h */
!STUFFY!FUNK!
echo ""
echo "End of kit 4 (of 4)"
cat /dev/null >kit4isdone
run=''
config=''
for iskit in 1 2 3 4; do
    if test -f kit${iskit}isdone; then
	run="$run $iskit"
    else
	todo="$todo $iskit"
    fi
done
case $todo in
    '')
	echo "You have run all your kits.  Please read README and then type Configure."
	chmod 755 Configure
	;;
    *)  echo "You have run$run."
	echo "You still need to run$todo."
	;;
esac
: Someone might mail this, so...
exit

INTERNET:  paul at devon.lns.pa.us        |      If life's a bitch, then
UUCP:      ...!rutgers!devon!paul      |      we must be her puppies.



More information about the Alt.sources mailing list