[comp.sources.misc] v09i044: siotools part 1/2

allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (12/05/89)

Posting-number: Volume 9, Issue 44
Submitted-by: wht%n4hgf@gatech.edu (Warren Tucker)
Archive-name: siotools/part01

This shar pair contains two programs, both related to SCO UNIX and XENIX
asynchronous I/O.   Both have been given to various system administrators
on XENIX 286 and 386 and UNIX 386 systems and appear to have no overt
bugs.  There are kernel dependencies, but they may be hackable for
other systems.

SIOMON displays kernel tty structures on ttys 1a-1h and 2a-2h (provided
that's a superset of what you have on your system).  Detailed
status may be displayed on a single line.

UUSNAP displays HDB UUCP connection status.  Detailed status may be
displayed on a single connection.

------ c u t   h e r e ---------
#!/bin/sh
# This is a shell archive built by shar 3.03
# Created Mon Dec  4 18:28:30 EST 1989 by gatech!kd4nc!n4hgf!wht
# Source directory /u4/src/uusnap
#
# existing files WILL be overwriten
#
# This shar contains:
#    README
#    Makefile
#    kmemsio.h
#    wintty.h
#    utoa.h
#    kmemsio.c
#    wintty.c
#    utoa.c
#
touch 2>&1 | fgrep '[-amc]' > /tmp/s3_touch$$
if [ -s /tmp/s3_touch$$ ]
then
	TOUCH=can
else
	TOUCH=cannot
fi
rm -f /tmp/s3_touch$$
echo "x - extracting README (Text)"
sed 's/^X//' << 'SHAR_EOF' > README &&
X
XThis shar contains two programs, both related to SCO UNIX and XENIX
Xasynchronous I/O.   Both have been given to various system administrators
Xon XENIX 286 and 386 and UNIX 386 systems and appear to have no overt
Xbugs.  There are kernel dependencies, but they may be hackable for
Xother systems.
X
XPROGRAMS
X--------
XSIOMON displays kernel tty structures on ttys 1a-1h and 2a-2h (provided
Xthat's a superset of what you have on your system).  Detailed
Xstatus may be displayed on a single line.
X
XUUSNAP displays HDB UUCP connection status.  Detailed status may be
Xdisplayed on a single connection.
X
XThese display hacks are self-documenting.  Just read the following
Xand have fun.
X
XTERMIO HACK
X-----------
XUnder XENIX, termio.h is included twice (once by curses.h/tcap.h and
Xagain by sys/tty.h.  You need to modify termio.h under XENIX to
Xprevent multiple inclusions from resulting in compilation errors.
X
XAdd at the top of /usr/include/sys/termio.h:
X#if !defined(TERMIO_HACK) || (defined(TERMIO_HACK) && !defined(IOCTYPE))
X
XAdd at the bottom:
X#endif
X
XThis will result in termio.h continuing it's "broken" state unless
X#define TERMIO_HACK
Xappears in including source code.  The problem does not exist in UNIX 3.2
X
XHAVE_SELECT
X-----------
XSIOMON will use select(S) if you have it on your system.  It is
Xautomagically turned on when compiled for UNIX targets.  If you have
XXENIX 386 2.3.2 or later, or XENIX 2.3.1 with a fixed select(S),
Xadd a -DHAVE_SELECT to CFLAGS in the Makefile.
X
XMAKING & INSTALLING
X-------------------
XTo make: edit the Makefile to select the CFLAGS for XENIX 286 or other
Xsystem.  Then 'make' or 'make all'.
X
XTo install, edit LBIN in the Makefile to have your favorite local
Xbin directory path, 'su root' and 'make install'.
X
X------------------------------------------------------------------
XBugs and suggestions appreciated.
XWarren Tucker,  Mountain Park, Georgia ...!gatech!kd4nc!n4hgf!wht 
SHAR_EOF
chmod 0644 README || echo "restore of README fails"
if [ $TOUCH = can ]
then
    touch -m 1204181889 README
fi
echo "x - extracting Makefile (Text)"
sed 's/^X//' << 'SHAR_EOF' > Makefile &&
X#  CHK=0xCE2E
X#-----------------------------------
X# Makefile for uusnap & siomon
X# gatech!kd4nc!n4hgf!wht
X#-----------------------------------
X#+:EDITS:
X#:12-04-1989-18:28-wht-release to comp.sources.misc
X#:11-23-1989-20:46-wht-creation
X
X# for XENIX 386 and UNIX
XCFLAGS=-DM_TERMCAP -Ox -s
X
X# for XENIX 286
X#CFLAGS=-DM_TERMCAP -Ox -s -M2me -LARGE -F 2000
X
XLIB=-ltcap -ltermlib -lx
XLBIN=/u3/bin
X
XSIOMON_OBJ = \
X	siomon.o\
X	kmemsio.o \
X	utoa.o \
X	wintty.o
X
XUUSNAP_OBJ = \
X	uusnap.o\
X	kmemsio.o \
X	utoa.o \
X	wintty.o
X
Xall: uusnap siomon
X
Xuusnap: $(UUSNAP_OBJ)
X	cc $(CFLAGS) $(UUSNAP_OBJ) -o $@ $(LIB)
X
Xsiomon: $(SIOMON_OBJ)
X	cc $(CFLAGS) $(SIOMON_OBJ) -o $@ $(LIB)
X
Xinstall: all
X	cp siomon $(LBIN)
X	chown root $(LBIN)/siomon
X	chmod 4111 $(LBIN)/siomon
X	cp uusnap $(LBIN)
X	chown root $(LBIN)/uusnap
X	chmod 4111 $(LBIN)/uusnap
X
Xshar:
X	shar -v README Makefile kmemsio.h wintty.h utoa.h \
X	                        kmemsio.c wintty.c utoa.c > siotools.1.sh
X	shar -v siomon.c uusnap.c > siotools.2.sh
X
SHAR_EOF
chmod 0644 Makefile || echo "restore of Makefile fails"
if [ $TOUCH = can ]
then
    touch -m 1204182889 Makefile
fi
echo "x - extracting kmemsio.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > kmemsio.h &&
X/* CHK=0x230E */
X/*+-----------------------------------------------------------------------
X	kmemsio.h
X------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:12-04-1989-16:49-afterlint-creation */
X
X#define	SIO_NTTY	16
Xextern struct tty sio[SIO_NTTY];
X
X#ifndef BUILDING_LINT_ARGS
X#ifdef LINT_ARGS
X
X/* kmemsio.c */
Xchar *kmem_init_tty(void );
Xchar *kmem_read_tty(int ,int );
X
X#else		/* compiler doesn't know about prototyping */
X
X/* kmemsio.c */
Xchar *kmem_init_tty();
Xchar *kmem_read_tty();
X
X#endif /* LINT_ARGS */
X#endif /* BUILDING_LINT_ARGS */
X
X/* end of kmemsio.h */
SHAR_EOF
chmod 0644 kmemsio.h || echo "restore of kmemsio.h fails"
if [ $TOUCH = can ]
then
    touch -m 1204165989 kmemsio.h
fi
echo "x - extracting wintty.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > wintty.h &&
X/* CHK=0x1F62 */
X/*+-----------------------------------------------------------------------
X	wintty.h
X------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:12-04-1989-16:50-afterlint-creation */
X
X#ifndef BUILDING_LINT_ARGS
X#ifdef LINT_ARGS
X
X/* wintty.c */
Xchar *B_to_baud_rate(int );
Xchar *cflag_to_baud_d_p_s(int );
Xvoid wintty(struct _win_st *,int ,int ,struct tty *);
Xvoid wintty_template(struct _win_st *,int ,int ,int );
X
X#else		/* compiler doesn't know about prototyping */
X
X/* wintty.c */
Xchar *B_to_baud_rate();
Xchar *cflag_to_baud_d_p_s();
Xvoid wintty();
Xvoid wintty_template();
X
X#endif /* LINT_ARGS */
X#endif /* BUILDING_LINT_ARGS */
X
X/* end of wintty.h */
SHAR_EOF
chmod 0644 wintty.h || echo "restore of wintty.h fails"
if [ $TOUCH = can ]
then
    touch -m 1204165089 wintty.h
fi
echo "x - extracting utoa.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > utoa.h &&
X/* CHK=0x3B34 */
X/*+-----------------------------------------------------------------------
X	utoa.h
X------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:12-04-1989-16:50-afterlint-creation */
X
X/* unsigned to decimal ascii w/leading spaces */
X#define utoda(buf,width,n)  utoda_common(buf,width,n,' ')
X
X/* unsigned to decimal ascii w/leading zeroes */
X#define utoda_lz(buf,width,n)  utoda_common(buf,width,n,'0')
X
X/* unsigned to octal ascii w/leading spaces */
X#define utooa(buf,width,n)  utooa_common(buf,width,n,' ')
X
X/* unsigned to octal ascii w/leading zeroes */
X#define utooa_lz(buf,width,n)  utooa_common(buf,width,n,'0')
X
X#ifndef BUILDING_LINT_ARGS
X#ifdef LINT_ARGS
X
X/* utoa.c */
Xvoid utoda_common(char *,int ,unsigned int ,char );
Xvoid utooa_common(char *,int ,unsigned int ,char );
X
X#else		/* compiler doesn't know about prototyping */
X
X/* utoa.c */
Xvoid utoda_common();
Xvoid utooa_common();
X
X#endif /* LINT_ARGS */
X#endif /* BUILDING_LINT_ARGS */
X
X/* end of utoa.h */
SHAR_EOF
chmod 0644 utoa.h || echo "restore of utoa.h fails"
if [ $TOUCH = can ]
then
    touch -m 1204165989 utoa.h
fi
echo "x - extracting kmemsio.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > kmemsio.c &&
X/* CHK=0xF436 */
X/*+-------------------------------------------------------------------------
X	kmemsio.c
X	...!gatech!emory!tridom!wht
X
X  Defined functions:
X	kmem_init_tty()
X	kmem_read_tty(ttfirst,ttcount)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:12-04-1989-16:05-wht-creation */
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#define TERMIO_HACK /* for XENIX termio.h multiple inclusion problem */
X#include <sys/tty.h>
X
X#include "kmemsio.h"
X
X#if defined(M_UNIX)
X#include <nlist.h>
X#define XLIST nlist
X#define XL_name n_name
X#define XL_value n_value
X#define XL_type n_type
X#else
X#include <sys/a.out.h>
X#define XLIST xlist
X#define XL_name xl_name
X#define XL_value xl_value
X#define XL_type xl_type
X#endif
X
X#ifdef M_UNIX
Xchar *kernel_file = "/unix";
X#else
Xchar *kernel_file = "/xenix";
X#endif
Xchar *kmem_file = "/dev/kmem";
X
Xint kmemfd;
X
X#if defined(M_UNIX)
Xstruct XLIST kernel_symbols[] = {
X#define KS_SIO_TTY	0
X	{ "sio_tty" },
X	{ (char *)0 }
X};
X#else
Xstruct XLIST kernel_symbols[] = {
X#define KS_SIO_TTY	0
X	{0,0,0, "_sio_tty" },
X	{0,0,0, (char *)0 }
X};
X#endif
X
X#define	sio_tty_fpos kernel_symbols[KS_SIO_TTY].XL_value
X
Xstruct tty sio[SIO_NTTY];
X
Xstatic char errmsg[80];
X
Xextern int errno;
Xextern char *sys_errlist[];
X
X/*+-------------------------------------------------------------------------
X	kmem_read_tty(ttfirst,ttcount)
X--------------------------------------------------------------------------*/
Xchar *
Xkmem_read_tty(ttfirst,ttcount)
Xint ttfirst;
Xint ttcount;
X{
Xint len = ttcount * sizeof(struct tty);
X
X	if(((unsigned)ttfirst >= SIO_NTTY) ||
X		(((unsigned)ttfirst + (unsigned)ttcount) > SIO_NTTY))
X		return(" illegal tty ");
X
X	if(lseek(kmemfd,sio_tty_fpos + (ttfirst * sizeof(struct tty)),0) == -1)
X	{
X		sprintf(errmsg,
X			" kmem lseek failure: %s ",sys_errlist[errno]);
X		return(errmsg);
X	}
X	errno = 0;
X	if(read(kmemfd,(char *)sio,len) != len)
X	{
X		sprintf(errmsg,
X			" kmem read failure: %s ",sys_errlist[errno]);
X		return(errmsg);
X	}
X
X	return((char *)0);
X
X}	/* end of kmem_read_tty */
X
X/*+-------------------------------------------------------------------------
X	kmem_init_tty()
X--------------------------------------------------------------------------*/
Xchar *
Xkmem_init_tty()
X{
X
X	if((kmemfd = open(kmem_file,0)) < 0)
X	{
X		sprintf(errmsg," %s: %s ",kmem_file,sys_errlist[errno]);
X		return(errmsg);
X	}
X
X	if(XLIST(kernel_file,kernel_symbols))
X	{
X		sprintf(errmsg," xlist/nlist failure: %s ",kernel_file);
X		return(errmsg);
X	}
X
X	return((char *)0);
X
X}	/* end of kmem_init_tty */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of kmemsio.c */
SHAR_EOF
chmod 0644 kmemsio.c || echo "restore of kmemsio.c fails"
if [ $TOUCH = can ]
then
    touch -m 1204170489 kmemsio.c
fi
echo "x - extracting wintty.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > wintty.c &&
X/* CHK=0xED50 */
X/*+-------------------------------------------------------------------------
X	wintty.c
X	...!gatech!emory!tridom!wht
X
XUnder XENIX, termio.h is included twice (once by curses.h/tcap.h andf
Xagain by sys/tty.h.  You need to bracket the termio.h under XENIX with
X  #if !defined(TERMIO_HACK) || (defined(TERMIO_HACK) && !defined(IOCTYPE))
X  ...
X  #endif
X
X  Defined functions:
X	B_to_baud_rate(code)
X	cflag_to_baud_d_p_s(cflag)
X	wintty(win,tly,tlx,tty)
X	wintty_template(win,tly,tlx,show_flag)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:12-04-1989-15:40-wht-creation */
X
X#include <curses.h>
X#include <sys/types.h>
X#define TERMIO_HACK /* for XENIX termio.h multiple inclusion problem */
X#include <sys/tty.h>
X#include "wintty.h"
X
Xtypedef struct slabel
X{
X	int y,x;
X	char *label;
X} SLABEL;
X
XSLABEL tty_slabels[] =
X{
X    {  0,  0, "iflag:" },
X    {  2,  0, "oflag:" },
X    {  3,  0, "cflag:" },
X    {  4,  0, "lflag:" },
X    {  5,  7, "INTR QUIT ERASE KILL EOF/VMIN  EOL/VTIME EOL2 SWTCH" },
X    {  6,  0, "cc:" },
X    {  -1,-1, (char *)0}
X};
X
Xtypedef struct tfield
X{
X	int y,x;
X	char *label;
X	int flag_num;
X	int mask;
X} TFIELD;
X
X#define IFLAG 1
X#define OFLAG 2
X#define LFLAG 3
X#define CFLAG 4
X
XTFIELD tty_tfields[] =
X{
X    {  0,  7, "IGNBRK", IFLAG, IGNBRK },
X    {  0, 15, "BRKINT", IFLAG, BRKINT },
X    {  0, 23, "IGNPAR", IFLAG, IGNPAR },
X    {  0, 31, "PARMRK", IFLAG, PARMRK },
X    {  0, 39, "INPCK",  IFLAG, INPCK },
X    {  0, 46, "ISTRIP", IFLAG, ISTRIP },
X    {  0, 53, "INLCR",  IFLAG, INLCR },
X    {  0, 60, "IGNCR",  IFLAG, IGNCR },
X    {  0, 68, "ICRNL",  IFLAG, ICRNL },
X    {  1,  7, "IUCLC",  IFLAG, IUCLC },
X    {  1, 15, "IXON",   IFLAG, IXON },
X    {  1, 23, "IXOFF",  IFLAG, IXOFF },
X    {  1, 31, "IXANY",  IFLAG, IXANY },
X    {  2,  7, "OPOST",  OFLAG, OPOST },
X    {  2, 15, "OLCUC",  OFLAG, OLCUC },
X    {  2, 23, "ONLCR",  OFLAG, ONLCR },
X    {  2, 31, "OCRNL",  OFLAG, OCRNL },
X    {  2, 39, "ONOCR",  OFLAG, ONOCR },
X    {  2, 46, "ONLRET", OFLAG, ONLRET },
X    {  2, 53, "OFDEL",  OFLAG, OFDEL },
X    {  3, 23, "CREAD",  CFLAG, CREAD },
X    {  3, 31, "HUPCL",  CFLAG, HUPCL },
X    {  3, 39, "CLOCAL", CFLAG, CLOCAL },
X    {  4,  7, "ISIG",   LFLAG, ISIG },
X    {  4, 15, "ICANON", LFLAG, ICANON },
X    {  4, 23, "XCASE",  LFLAG, XCASE },
X    {  4, 31, "ECHO",   LFLAG, ECHO },
X    {  4, 39, "ECHOE",  LFLAG, ECHOE },
X    {  4, 46, "ECHOK",  LFLAG, ECHOK },
X    {  4, 53, "ECHONL", LFLAG, ECHONL },
X    {  4, 60, "NOFLSH", LFLAG, NOFLSH },
X    {  4, 68, "XCLUDE", LFLAG, XCLUDE },
X    {  -1,-1, (char *)0,    -1,    -1 }
X};
X
Xtypedef struct fcursor
X{
X	int y,x;
X} FCURSOR;
X
XFCURSOR tty_fcursors[] =
X{
X#define Fc_intr       0
X	{  6,  8 },
X#define Fcc_quit      1
X	{  6, 13 },
X#define Fcc_erase     2
X	{  6, 18 },
X#define Fcc_kill      3
X	{  6, 24 },
X#define Fcc_eof       4
X	{  6, 30 },
X#define Fcc_eol       5
X	{  6, 40 },
X#define Fcc_eol2      6
X	{  6, 49 },
X#define Fcc_swtch     7
X	{  6, 54 },
X#define Fbaud_b_p_s   8
X	{  3,  7 }
X};
X
Xtypedef struct b_to_br
X{
X	char *baud_rate;
X	int B_code;
X} B_TO_BR;
X
XB_TO_BR speeds[] = 	/* ordered to put less common rates later in table */
X{					/* and the vagaries of baud rates above 9600 "handled" */
X	" 2400",	B2400,
X	" 1200",	B1200,
X	" 9600",	B9600,
X#if defined(B19200)
X	"19200",	B19200,
X#endif
X#if defined(B38400)
X	"38400",	B38400,
X#endif
X	" 4800",	B4800,
X	"  300",	B300,
X	"  110",	B110,
X	"   75",	B75,
X	"   50",	B50,
X	"  HUP",	B0,
X	" EXTA",	EXTA,
X	" EXTB",	EXTB,
X
X	(char *)0,0
X};
X
X/*+-------------------------------------------------------------------------
X	B_to_baud_rate(code) - convert CBAUD B_ code to baud rate string
X--------------------------------------------------------------------------*/
Xchar *
XB_to_baud_rate(code)
X{
Xregister int n;
X
X	for(n=0; speeds[n].baud_rate; n++)
X		if(speeds[n].B_code == code)
X			return(speeds[n].baud_rate);
X	return("-----");
X}	/* end of B_to_baud_rate */
X
X/*+-------------------------------------------------------------------------
X	cflag_to_baud_d_p_s(cflag)
X--------------------------------------------------------------------------*/
Xchar *
Xcflag_to_baud_d_p_s(cflag)
Xint cflag;
X{
Xregister char * cptr;
Xstatic char rtnstr[16];
X
X	strcpy(rtnstr,B_to_baud_rate(cflag & CBAUD));
X	cptr = rtnstr + strlen(rtnstr);
X	*cptr++ = '-';
X	switch(cflag & CSIZE)
X	{
X		case CS5: *cptr++ = '5'; break;
X		case CS6: *cptr++ = '6'; break;
X		case CS7: *cptr++ = '7'; break;
X		case CS8: *cptr++ = '8'; break;
X	}
X	*cptr++ = '-';
X	*cptr++ = (cflag & PARENB) ? ((cflag & PARODD) ? 'O' : 'E') : 'N';
X	*cptr++ = '-';
X	*cptr++ = (cflag & CSTOPB) ? '2' : '1';
X	*cptr = 0;
X	return(rtnstr);
X
X}	/* end of cflag_to_baud_d_p_s */
X
X/*+-----------------------------------------------------------------------
X	wintty(win,tly,tlx,tty)
X
X000000000011111111112222222222333333333344444444445555555555666666666677777
X012345678901234567890123456789012345678901234567890123456789012345678901234
Xiflag: IGNBRK  BRKINT  IGNPAR  PARMRK  INPCK  ISTRIP INLCR  IGNCR   ICRNL
X       IUCLC   IXON    IXOFF   IXANY
Xoflag: OPOST   OLCUC   ONLCR   OCRNL   ONOCR  ONLRET OFDEL
Xcflag: 09600-8-N-1     CREAD   HUPCL   CLOCAL
Xlflag: ISIG    ICANON  XCASE   ECHO    ECHOE  ECHOK  ECHONL NOFLSH  XCLUDE
X       INTR QUIT ERASE KILL EOF/VMIN  EOL/VTIME EOL2 SWTCH 
Xcc:     03   1c   08    15    01        00       00   00   
X
X------------------------------------------------------------------------*/
Xvoid
Xwintty(win,tly,tlx,tty)
XWINDOW *win;
Xint tly;
Xint tlx;
Xstruct tty *tty;
X{
Xregister flag;
Xregister i_cc;
Xregister char *cptr;
XTFIELD *tptr = tty_tfields;
XFCURSOR *fptr = tty_fcursors;
X
X	while(tptr->y >= 0)
X	{
X		switch(tptr->flag_num)
X		{
X			case IFLAG: flag = tty->t_iflag; break;
X			case OFLAG: flag = tty->t_oflag; break;
X			case LFLAG: flag = tty->t_lflag; break;
X			case CFLAG: flag = tty->t_cflag; break;
X		}
X		flag &= tptr->mask;
X		wmove(win,tptr->y + tly,tptr->x + tlx);
X		if(flag)
X			wstandout(win);
X		waddstr(win,tptr->label);
X		if(flag)
X			wstandend(win);
X		tptr++;
X	}
X	for(i_cc = 0; i_cc < NCC; i_cc++)
X	{
X		wmove(win,fptr->y + tly,fptr->x + tlx);
X		wprintw(win,"%02x",tty->t_cc[i_cc]);
X		fptr++;
X	}
X
X	fptr = &tty_fcursors[Fbaud_b_p_s];
X	wmove(win,fptr->y + tly,fptr->x + tlx);
X	waddstr(win,"           ");
X	wmove(win,fptr->y + tly,fptr->x + tlx);
X	waddstr(win,cflag_to_baud_d_p_s(tty->t_cflag));
X
X}	/* end of wintty */
X
X/*+-------------------------------------------------------------------------
X	wintty_template(win,tly,tlx,show_flag)
X--------------------------------------------------------------------------*/
Xvoid
Xwintty_template(win,tly,tlx,show_flag)
XWINDOW *win;
Xint tly;
Xint tlx;
Xint show_flag;
X{
Xregister y;
XSLABEL *sptr = tty_slabels;
X
X	for(y = 0; y < 7; y++)
X	{
X		wmove(win,tly + y,0);
X		wclrtoeol(win);
X	}
X	if(show_flag)
X	{
X		while(sptr->y >= 0)
X		{
X			wmove(win,sptr->y + tly,sptr->x + tlx);
X			waddstr(win,sptr->label);
X			sptr++;
X		}
X	}
X
X}	/* end of wintty_template */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of wintty.c */
SHAR_EOF
chmod 0644 wintty.c || echo "restore of wintty.c fails"
if [ $TOUCH = can ]
then
    touch -m 1204182889 wintty.c
fi
echo "x - extracting utoa.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > utoa.c &&
X/* CHK=0xDD15 */
X/*+-------------------------------------------------------------------------
X	utoa.c - fast substitutes for most sprintf needs
X	...!gatech!emory!tridom!wht
X
X  Defined functions:
X	utoda_common(buf,width,n,leading)
X	utooa_common(buf,width,n,leading)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:11-29-1989-03:32-wht-creation */
X
X#include "utoa.h"
X
X/*+-------------------------------------------------------------------------
X	utoda_common(buf,width,n,leading) unsigned to decimal ascii
X--------------------------------------------------------------------------*/
Xvoid
Xutoda_common(buf,width,n,leading)
Xchar *buf;
Xint width;
Xunsigned n;
Xchar leading;
X{
X	register unsigned div;
X	register char *ep = &buf[width];
X
X	*ep = '\0';
X	if(n == 0)
X		*--ep = '0';
X	while(ep-- > buf)
X	{
X		if(n <= 0)
X			*ep = leading;
X		else
X		{
X			div = n / 10;
X			*ep = n - 10*div + '0';
X			n = div;
X		}
X	}
X}	/* end of utoda_common */
X
X/*+-------------------------------------------------------------------------
X	utooa_common(buf,width,n,leading) unsigned to octal ascii
X--------------------------------------------------------------------------*/
Xvoid
Xutooa_common(buf,width,n,leading)
Xchar *buf;
Xint width;
Xunsigned n;
Xchar leading;
X{
Xregister unsigned div;
Xregister char *ep = &buf[width];
X
X	*ep = '\0';
X	if(n == 0)
X		*--ep = '0';
X	while(ep-- > buf)
X	{
X		if(n <= 0)
X			*ep = leading;
X		else
X		{
X			div = n >> 3;
X			*ep = n - (div << 3) + '0';
X			n = div;
X		}
X	}
X}	/* end of utooa_common */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of utoa.c */
SHAR_EOF
chmod 0644 utoa.c || echo "restore of utoa.c fails"
if [ $TOUCH = can ]
then
    touch -m 1204170189 utoa.c
fi
exit 0