[comp.os.minix] Stdio V2 - Part 2 of 6

cechew@bruce.OZ (Earl Chew) (09/29/89)

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 6)."
# Contents:  0_minix.txt _allocbu.c _iowrite.c _rename.c _vsscanf.c
#   atexit.c exit.c fclose.c fdopen.c fopen.c fprintf.c fputs.c
#   freopen.c fscanf.c fseek.c ftell.c perror.c puts.c setbuf.c
#   sprintf.c sscanf.c stdarg.h tmpfile.c ungetc.c vsprintf.c
# Wrapped by cechew@bruce on Fri Sep 29 16:23:36 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f '0_minix.txt' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'0_minix.txt'\"
else
echo shar: Extracting \"'0_minix.txt'\" \(764 characters\)
sed "s/^X//" >'0_minix.txt' <<'END_OF_FILE'
X			Installation Notes for Minix
X			============================
X
XMinix users need not run the yinstall.sh script. Instead, you can simply copy
Xstdio.g to stdio.h and compile. Look at makefile.unx to see which bits need
Xto go together to make stdio.a. When you lorder and tsort to put the modules
Xinto libc.a, remember to put exit.s and _fakfls.s last otherwise programs that
Xdon't use stdio will link in the kitchen sink. Look in makefile.unx to see how
Xit's done there.
X
XThose cross compiling under DOS, look in makefile.dos. The library is split into
Xtwo sections. exit.obj and _fakfls.obj live in a separate library. In the link
Xcommand, two libraries are specified. The main library is specified first,
Xfollowed by the library containing exit.obj and _fakfls.
END_OF_FILE
if test 764 -ne `wc -c <'0_minix.txt'`; then
    echo shar: \"'0_minix.txt'\" unpacked with wrong size!
fi
# end of '0_minix.txt'
fi
if test -f '_allocbu.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'_allocbu.c'\"
else
echo shar: Extracting \"'_allocbu.c'\" \(1227 characters\)
sed "s/^X//" >'_allocbu.c' <<'END_OF_FILE'
X/*			_ a l l o c b u f
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Allocate a buffer to a stream. This routine is designed to
X * be called from _flsbuf or _filbuf and hence has some hooks
X * in it for these routines.
X *
X * The routine initialises _bufsiz, _base, _ptr and _ctr. No
X * buffer is allocated if _IONBF is in effect. Line buffering
X * is engaged if the stream is attached to a terminal and the
X * stream is not opened for input.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
Xint _allocbuf(T(FILE *fp, fp))
X
XD(FILE *fp)				/* stream */
X
X{
X  if (! TESTFLAG(fp, _IONBF)) {
X    fp->_bufsiz = BUFSIZ;
X
X    if (isatty(fileno(fp))) {
X      fp->_bufsiz = TTYBUFSIZ;
X      if (TESTFLAG(fp, _IOWRITE))
X	SETFLAG(fp, _IOLBF);
X    }
X
X    if ((fp->_base = (_stdiobuf_t *) malloc(BUFSIZ)) != NULL)
X      SETFLAG(fp, _IOMYBUF);
X    else {
X      CLEARFLAG(fp, (_IOFBF | _IOLBF));
X      SETFLAG(fp, _IONBF);
X    }
X  }
X
X  if (TESTFLAG(fp, _IONBF)) {
X    fp->_base   = &fp->_buf;
X    fp->_bufsiz = sizeof(fp->_buf);
X  }
X
X  return fp->_bufsiz;
X}
END_OF_FILE
if test 1227 -ne `wc -c <'_allocbu.c'`; then
    echo shar: \"'_allocbu.c'\" unpacked with wrong size!
fi
# end of '_allocbu.c'
fi
if test -f '_iowrite.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'_iowrite.c'\"
else
echo shar: Extracting \"'_iowrite.c'\" \(849 characters\)
sed "s/^X//" >'_iowrite.c' <<'END_OF_FILE'
X/*			_ i o w r i t e
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Call write(2) repeatedly until all data written or an error occurs. Return
X * -1 if an error occurs and no data has been written, otherwise returns the
X * number of bytes written.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include <stdiolib.h>
X
X/*LINTLIBRARY*/
X
Xint _iowrite(T(int fd, fd), T(char *p, p), T(int n, n))
X
XD(int fd)				/* file */
XD(char *p)				/* buffer */
XD(int n)				/* bytes */
X
X{
X  int wrote;				/* bytes written by write call */
X  int w;				/* bytes written */
X
X  for (w = 0; 
X       (wrote = write(fd, p, n)) != -1 &&
X       (w += wrote, p += wrote, n -= wrote) > 0;
X      )
X    ;
X  return !w && n ? -1 : w;
X}
END_OF_FILE
if test 849 -ne `wc -c <'_iowrite.c'`; then
    echo shar: \"'_iowrite.c'\" unpacked with wrong size!
fi
# end of '_iowrite.c'
fi
if test -f '_rename.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'_rename.c'\"
else
echo shar: Extracting \"'_rename.c'\" \(687 characters\)
sed "s/^X//" >'_rename.c' <<'END_OF_FILE'
X/*			r e n a m e
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Rename a file. The file named in the from part is given the
X * name in the to part. Return EOF if something goes wrong,
X * otherwise return 0.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
X#ifndef		RENAME
X
Xint rename(T(const char *from, from), T(const char *to, to))
X
XD(char *from)			/* original name */
XD(char *to)			/* new name */
X
X{
X  return unlink(to) != 0 || link(from, to) != 0 || unlink(from) != 0
X         ? EOF : 0;
X}
X
X#endif
END_OF_FILE
if test 687 -ne `wc -c <'_rename.c'`; then
    echo shar: \"'_rename.c'\" unpacked with wrong size!
fi
# end of '_rename.c'
fi
if test -f '_vsscanf.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'_vsscanf.c'\"
else
echo shar: Extracting \"'_vsscanf.c'\" \(949 characters\)
sed "s/^X//" >'_vsscanf.c' <<'END_OF_FILE'
X/*				v s s c a n f
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * This function provides the same functionality as sscanf except
X * that it uses varargs.h.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
Xint _vsscanf(T(const char *buf, buf),
X             T(const char *fmt, fmt), T(VA_LIST args, args))
X
XD(char *buf)				/* output buffer */
XD(char *fmt)				/* format */
XD(VA_LIST args)				/* argument list */
X
X{
X  FILE f;				/* temporary file */
X
X  f._flag   = _IOREAD | _IOSTRING;
X  f._base   = (_stdiobuf_t *) buf;
X  f._bufsiz = strlen(buf);
X
X  f._filbuf = (int (*) P((FILE *)))      _bfail;
X  f._flsbuf = (int (*) P((int, FILE *))) _bfail;
X  f._flush  = (int (*) P((FILE *)))      _bfail;
X
X  INITREADBUFFER(&f, f._bufsiz);
X
X  return _vfscanf(&f, fmt, args);
X}
END_OF_FILE
if test 949 -ne `wc -c <'_vsscanf.c'`; then
    echo shar: \"'_vsscanf.c'\" unpacked with wrong size!
fi
# end of '_vsscanf.c'
fi
if test -f 'atexit.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'atexit.c'\"
else
echo shar: Extracting \"'atexit.c'\" \(718 characters\)
sed "s/^X//" >'atexit.c' <<'END_OF_FILE'
X/*				a t e x i t
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Lodge an exit handler. The handler is lodged within a list of exit
X * handlers to be called by exit prior to calling _exit. The list
X * is of finite length. exit will call the exits handlers in fifo
X * order. The routine returns non-zero on failure (list overflow) and
X * zero on success.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
Xint atexit(T(atexit_t fp, fp))
X
XD(atexit_t fp)				/* exit handler */
X
X{
X  return (*_exit_hp != 0) ? -1 : (*_exit_hp-- = fp, 0);
X}
END_OF_FILE
if test 718 -ne `wc -c <'atexit.c'`; then
    echo shar: \"'atexit.c'\" unpacked with wrong size!
fi
# end of 'atexit.c'
fi
if test -f 'exit.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'exit.c'\"
else
echo shar: Extracting \"'exit.c'\" \(1077 characters\)
sed "s/^X//" >'exit.c' <<'END_OF_FILE'
X/*				e x i t
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Exit with stdio wrap up. A scan is made of the exit handler list.
X * All non-null pointers will be used to call the named functions.
X * Finally the stdio exit handler, _ioflush(), is called, followed by an
X * _exit().
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
X#define MAX_HANDLERS	33		/* maximum number of handlers */
X
Xvoid exit	P((int));		/* exit coming up */
X
X/* Exit handler list */
Xstatic void (*_exit_list[MAX_HANDLERS+1]) P((void)) = {
X  _ioflush,
X  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
X  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
X  _ioflush
X};
X
X/* Exit handler list pointer */
Xvoid (**_exit_hp) P(()) = &_exit_list[MAX_HANDLERS-1];
X
Xvoid exit(T(int status, status))
X
XD(int status)				/* exit status */
X
X{
X  for ( ; _exit_hp < &_exit_list[MAX_HANDLERS]; )
X    (*(*++_exit_hp))();
X  _exit(status);
X}
END_OF_FILE
if test 1077 -ne `wc -c <'exit.c'`; then
    echo shar: \"'exit.c'\" unpacked with wrong size!
fi
# end of 'exit.c'
fi
if test -f 'fclose.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fclose.c'\"
else
echo shar: Extracting \"'fclose.c'\" \(1377 characters\)
sed "s/^X//" >'fclose.c' <<'END_OF_FILE'
X/*				f c l o s e
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * This function will flush any buffered data for the specified
X * stream, then close it. Buffers that have been allocated
X * to the stream by the stdio library will be freed. Buffers
X * that have been allocated explicitly by the user will not
X * be freed. It is the user's responsibility to free these
X * if so required. This function is called automagically from
X * exit().
X *
X * The function returns 0 on success and EOF if an error was
X * detected.
X *
X * This function must leave the _file field alone so that _file()
X * can later reuse old stream descriptors.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
Xint fclose(T(FILE *fp, fp))
X
XD(FILE *fp)				/* stream */
X
X{
X  FILE **sp;				/* slot */
X
X/* Find the file descriptor */
X  for (sp = &_iop; *sp != 0 && *sp != fp; sp = &(*sp)->_next)
X    ;
X
X/* Shutdown */
X  if (*sp == 0 || FFLUSH(fp) || close(fileno(fp)))
X    return EOF;
X
X/* Unlink from list or indicate that it's unused */
X  if (TESTFLAG(fp, _IOSTATIC))
X    fp->_flag = _IOSTATIC;
X  else
X    *sp = (*sp)->_next;
X
X/* Free allocated buffer */
X  if (TESTFLAG(fp, _IOMYBUF))
X    free((void *) fp->_base);
X
X  return 0;
X}
END_OF_FILE
if test 1377 -ne `wc -c <'fclose.c'`; then
    echo shar: \"'fclose.c'\" unpacked with wrong size!
fi
# end of 'fclose.c'
fi
if test -f 'fdopen.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fdopen.c'\"
else
echo shar: Extracting \"'fdopen.c'\" \(920 characters\)
sed "s/^X//" >'fdopen.c' <<'END_OF_FILE'
X/*				f d o p e n
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Open a stream and associate it with a file descriptor. The
X * file descriptor would typically have been obtained from either
X * a call to open(), dup(), creat() or pipe(). The type of stream
X * (read, write or append) must agree with the mode of the open
X * file.
X *
X * The function returns a pointer to the stream on success and
X * NULL on failure.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
XFILE *fdopen(T(int fd, fd), T(const char *mode, mode))
X
XD(int fd)				/* channel */
XD(char *mode)				/* mode to open */
X
X{
X  short flags;				/* flag settings */
X
X  return fd != _fopen((char *) NULL, mode, fd, &flags)
X	 ? NULL
X         : _file((FILE *) NULL, fd, flags);
X}
END_OF_FILE
if test 920 -ne `wc -c <'fdopen.c'`; then
    echo shar: \"'fdopen.c'\" unpacked with wrong size!
fi
# end of 'fdopen.c'
fi
if test -f 'fopen.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fopen.c'\"
else
echo shar: Extracting \"'fopen.c'\" \(955 characters\)
sed "s/^X//" >'fopen.c' <<'END_OF_FILE'
X/*			f o p e n
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Open a stream and associate it with the named file. The name
X * of the file is passed as a character string. The type of
X * stream is passed as a string with the first character indicating
X * the mode with which the file is to be opened.
X *
X * The function returns a pointer to the stream if successful
X * otherwise it returns NULL.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
XFILE *fopen(T(const char *name, name), T(const char *mode, mode))
X
XD(char *name)				/* name of file */
XD(char *mode)				/* mode to open */
X
X{
X  int fd;				/* opened file descriptor */
X  short flags;				/* flag settings */
X
X  return (fd = _fopen(name, mode, -1, &flags)) < 0
X    ? NULL
X    : _file((FILE *) NULL, fd, flags);
X}
END_OF_FILE
if test 955 -ne `wc -c <'fopen.c'`; then
    echo shar: \"'fopen.c'\" unpacked with wrong size!
fi
# end of 'fopen.c'
fi
if test -f 'fprintf.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fprintf.c'\"
else
echo shar: Extracting \"'fprintf.c'\" \(850 characters\)
sed "s/^X//" >'fprintf.c' <<'END_OF_FILE'
X/*				f p r i n t f
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Formatted output to a named stream. A pointer to the required
X * stream is passed to the function and the output will be directed
X * to that stream.
X *
X * The function returns the number of bytes output on success, and
X * EOF on failure.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X/*VARARGS2*/
X/*ARGSUSED*/
X
Xint fprintf(T(FILE *fp, fp), T(const char *fmt, fmt), VA_ALIST)
X
XD(FILE *fp)				/* stream */
XD(char *fmt)				/* format */
XVA_DCL
X
X{
X  VA_LIST arg;				/* argument vector */
X  int v;				/* return value */
X
X  VA_START(arg, fmt);
X  v = vfprintf(fp, fmt, arg);
X  VA_END(arg);
X  return v;
X}
END_OF_FILE
if test 850 -ne `wc -c <'fprintf.c'`; then
    echo shar: \"'fprintf.c'\" unpacked with wrong size!
fi
# end of 'fprintf.c'
fi
if test -f 'fputs.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fputs.c'\"
else
echo shar: Extracting \"'fputs.c'\" \(1282 characters\)
sed "s/^X//" >'fputs.c' <<'END_OF_FILE'
X/*				f p u t s
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Write a string onto the specified stream. The terminating null
X * character in the string is not written.
X *
X * The function returns EOF on error, otherwise it will return the
X * last character written.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
Xint fputs(T(const char *s, s), T(FILE *fp, fp))
X
XD(char *s)				/* string */
XD(FILE *fp)				/* stream */
X
X{
X  unsigned int length;			/* length of buffer available */
X  int c;				/* next character */
X  _stdiobuf_t *p;			/* string pointer */
X  _stdiobuf_t *q;			/* buffer pointer */
X
X  if (CHECKWRITE(fp))
X    return EOF;
X
X  SETSCAN(fp);
X  for (p = (_stdiobuf_t *) s; ; ) {
X    if (TESTFLAG(fp, _IONBF) || (length = UNUSEDINWRITEBUFFER(fp)) == 0)
X      c = *p++;
X    else {
X      q = GETWRITEPTR(fp);
X      UNROLL_DO(fputswrite, length, if ((*q++ = *p++) == 0) break);
X      c = length ? (q--, 0) : *p++;
X      SETWRITEPTR(fp, q);
X    }
X    if (c == 0)
X      return (TESTFLAG(fp, _IOLBF) && FLUSHSCAN(fp)) ? EOF : s[0] ? p[-2] : 0;
X    if (NPUTC(c, fp) == EOF)
X      return EOF;
X  }
X}
END_OF_FILE
if test 1282 -ne `wc -c <'fputs.c'`; then
    echo shar: \"'fputs.c'\" unpacked with wrong size!
fi
# end of 'fputs.c'
fi
if test -f 'freopen.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'freopen.c'\"
else
echo shar: Extracting \"'freopen.c'\" \(1215 characters\)
sed "s/^X//" >'freopen.c' <<'END_OF_FILE'
X/*				f r e o p e n
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Open the named file and associate it with the stream indicated.
X * The type of the stream is interpreted in the same manner as
X * for fopen(). The original stream is closed using fclose()
X * regardless of whether the open succeeds or not.
X *
X * The function returns a pointer to the stream on success, otherwise
X * it returns NULL.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
XFILE *freopen(T(const char *name, name),
X              T(const char *mode, mode), T(FILE *fp, fp))
X
XD(char *name)				/* name to open */
XD(char *mode)				/* mode to open with */
XD(FILE *fp)				/* stream */
X
X{
X  int fd;				/* opened file descriptor */
X  short flags;				/* flag settings */
X
X/* Close this stream */
X  (void) FFLUSH(fp);
X  (void) close(fileno(fp));
X
X/* Free any buffers */
X  if (TESTFLAG(fp, _IOMYBUF))
X    free((void *) fp->_base);
X
X/* Open according to the specified mode */
X  return (fd = _fopen(name, mode, -1, &flags)) < 0
X    ? NULL
X    : _file(fp, fd, flags);
X}
END_OF_FILE
if test 1215 -ne `wc -c <'freopen.c'`; then
    echo shar: \"'freopen.c'\" unpacked with wrong size!
fi
# end of 'freopen.c'
fi
if test -f 'fscanf.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fscanf.c'\"
else
echo shar: Extracting \"'fscanf.c'\" \(842 characters\)
sed "s/^X//" >'fscanf.c' <<'END_OF_FILE'
X/*				f s c a n f
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Formatted input from a named stream. A pointer to the required
X * stream is passed to the function and items will be scanned from
X * that stream.
X *
X * The function returns the number items scanned on success, and
X * EOF on failure.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X/*VARARGS2*/
X/*ARGSUSED*/
X
Xint fscanf(T(FILE *fp, fp), T(const char *fmt, fmt), VA_ALIST)
X
XD(FILE *fp)				/* stream */
XD(char *fmt)				/* format */
XVA_DCL
X
X{
X  VA_LIST arg;				/* argument vector */
X  int v;				/* return value */
X
X  VA_START(arg, fmt);
X  v = _vfscanf(fp, fmt, arg);
X  VA_END(arg);
X  return v;
X}
END_OF_FILE
if test 842 -ne `wc -c <'fscanf.c'`; then
    echo shar: \"'fscanf.c'\" unpacked with wrong size!
fi
# end of 'fscanf.c'
fi
if test -f 'fseek.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fseek.c'\"
else
echo shar: Extracting \"'fseek.c'\" \(1104 characters\)
sed "s/^X//" >'fseek.c' <<'END_OF_FILE'
X/*				f s e e k
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Set the position of a stream. The new position is at the signed
X * distance offset bytes from either the beginning, current position
X * of end of the file. Any effects of ungetc() are undone.
X *
X * The function returns EOF for improper seeks, otherwise zero.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
Xint fseek(T(FILE *fp, fp), T(long offset, offset), T(int ptr, ptr))
X
XD(FILE *fp)				/* stream */
XD(long offset)				/* offset */
XD(int ptr)				/* reference */
X
X{
X  long lseek();				/* seek on file */
X
X  if (FFLUSH(fp) || lseek(fileno(fp), offset, ptr) == EOF)
X    return EOF;
X
X  CLEARFLAG(fp, _IOEOF);
X
X  if (TESTFLAG(fp, _IORW)) {
X    SETFLSBUF(fp, _bwrupdate);
X    SETFLUSH(fp, (int (*) P((FILE *))) _bsucceed);
X    SETFILBUF(fp, _brdupdate);
X    CLEARFLAG(fp, (_IOREAD | _IOWRITE));
X  }
X
X  CHECKNEXTREAD(fp);
X  CHECKNEXTWRITE(fp);
X
X  return 0;
X}
END_OF_FILE
if test 1104 -ne `wc -c <'fseek.c'`; then
    echo shar: \"'fseek.c'\" unpacked with wrong size!
fi
# end of 'fseek.c'
fi
if test -f 'ftell.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ftell.c'\"
else
echo shar: Extracting \"'ftell.c'\" \(778 characters\)
sed "s/^X//" >'ftell.c' <<'END_OF_FILE'
X/*				f t e l l
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Report the position within a stream. The function returns
X * the offset of the current byte relative to the beginning
X * of the file associated with the named stream.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
Xlong ftell(T(FILE *fp, fp))
X
XD(FILE *fp)				/* stream */
X
X{
X  long pos;				/* current location */
X
X  if ((pos = lseek(fileno(fp), 0L, SEEK_CUR)) == -1L || TESTFLAG(fp, _IONBF))
X    return pos;
X
X  if (TESTFLAG(fp, _IOWRITE))
X    return pos + BYTESINWRITEBUFFER(fp);
X  else
X    return pos - BYTESINREADBUFFER(fp);
X}
END_OF_FILE
if test 778 -ne `wc -c <'ftell.c'`; then
    echo shar: \"'ftell.c'\" unpacked with wrong size!
fi
# end of 'ftell.c'
fi
if test -f 'perror.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'perror.c'\"
else
echo shar: Extracting \"'perror.c'\" \(740 characters\)
sed "s/^X//" >'perror.c' <<'END_OF_FILE'
X/*			p e r r o r
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Write an error message describing the most recent error to
X * stderr. The string is printed, followed by a colon, then
X * the system error message.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
Xvoid perror(T(const char *s, s))
X
XD(char *s)				/* error string */
X
X{
X  if (s != NULL && *s != 0)
X    (void) fprintf(stderr, "%s: ", s);
X  (void) fprintf(stderr, "%s\n",
X                 errno > 0 && errno < sys_nerr
X                 ? sys_errlist[errno]
X                 : "Unknown error");
X}
END_OF_FILE
if test 740 -ne `wc -c <'perror.c'`; then
    echo shar: \"'perror.c'\" unpacked with wrong size!
fi
# end of 'perror.c'
fi
if test -f 'puts.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'puts.c'\"
else
echo shar: Extracting \"'puts.c'\" \(1187 characters\)
sed "s/^X//" >'puts.c' <<'END_OF_FILE'
X/*				p u t s
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Write a string followed by a newline character onto stdout. The
X * null character terminating the string is not written.
X *
X * The function returns the last character written (the newline)
X * on success and EOF on error.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
Xint puts(T(const char *s, s))
X
XD(char *s)				/* string */
X
X{
X  unsigned int length;			/* length of buffer available */
X  int c;				/* next character */
X  _stdiobuf_t *q;			/* buffer pointer */
X
X  if (CHECKWRITE(stdout))
X    return EOF;
X
X  for (;;) {
X    if (TESTFLAG(stdout, _IONBF) || (length = UNUSEDINWRITEBUFFER(stdout)) == 0)
X      c = *s++;
X    else {
X      q = GETWRITEPTR(stdout);
X      UNROLL_DO(putswrite, length,
X		if ((*q++ = (_stdiobuf_t) (*s++)) == 0) break);
X      c = length ? (q--, 0) : *s++;
X      SETWRITEPTR(stdout, q);
X    }
X    if (c == 0)
X      return putc('\n',stdout) == EOF ? EOF : '\n';
X    if (NPUTC(c, stdout) == EOF)
X      return EOF;
X  }
X}
END_OF_FILE
if test 1187 -ne `wc -c <'puts.c'`; then
    echo shar: \"'puts.c'\" unpacked with wrong size!
fi
# end of 'puts.c'
fi
if test -f 'setbuf.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'setbuf.c'\"
else
echo shar: Extracting \"'setbuf.c'\" \(1071 characters\)
sed "s/^X//" >'setbuf.c' <<'END_OF_FILE'
X/*				s e t b u f
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * This function causes the specified buffer to be used for IO buffering
X * instead of an automatically allocated buffer. It is called immediately
X * after the stream has been opened, but before it is read from or
X * written to. It is legal to call setbuf after making the stream
X * unbuffered.
X *
X * If buf if NULL, IO will be unbuffered, otherwise it will be fully
X * buffered. The manifest constant BUFSIZ in <stdio.h> tells how
X * big an array is needed. Line buffering will be initiated if the
X * output stream is directed to a terminal.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
Xvoid setbuf(T(FILE *fp, fp), T(char *buf, buf))
X
XD(FILE *fp)				/* stream */
XD(char *buf)				/* buffer */
X
X{
X  if (buf != NULL)
X    (void) setvbuf(fp, buf, _IOFBF, BUFSIZ);
X  else
X    (void) setvbuf(fp, (char *) NULL, _IONBF, 0);
X}
END_OF_FILE
if test 1071 -ne `wc -c <'setbuf.c'`; then
    echo shar: \"'setbuf.c'\" unpacked with wrong size!
fi
# end of 'setbuf.c'
fi
if test -f 'sprintf.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sprintf.c'\"
else
echo shar: Extracting \"'sprintf.c'\" \(833 characters\)
sed "s/^X//" >'sprintf.c' <<'END_OF_FILE'
X/*				s p r i n t f
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Formatted output to a string. A null character will be appended
X * to the string to mark the end of string. The function returns
X * the number of bytes written to the string (excluding the null
X * character).
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X/*VARARGS2*/
X/*ARGSUSED*/
X
Xint sprintf(T(char *buf, buf), T(const char *fmt, fmt), VA_ALIST)
X
XD(char *buf)				/* output buffer */
XD(char *fmt)				/* format */
XVA_DCL
X
X{
X  VA_LIST arg;				/* argument vector */
X  int v;				/* return value */
X
X  VA_START(arg, fmt);
X  v = vsprintf(buf, fmt, arg);
X  VA_END(arg);
X
X  return v;
X}
END_OF_FILE
if test 833 -ne `wc -c <'sprintf.c'`; then
    echo shar: \"'sprintf.c'\" unpacked with wrong size!
fi
# end of 'sprintf.c'
fi
if test -f 'sscanf.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sscanf.c'\"
else
echo shar: Extracting \"'sscanf.c'\" \(743 characters\)
sed "s/^X//" >'sscanf.c' <<'END_OF_FILE'
X/*				s s c a n f
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Formatted input from a string. The function returns the number
X * items scanned from the string and EOF on failure.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X/*VARARGS2*/
X/*ARGSUSED*/
X
Xint sscanf(T(const char *buf, buf), T(const char *fmt, fmt), VA_ALIST)
X
XD(char *buf)				/* output buffer */
XD(char *fmt)				/* format */
XVA_DCL
X
X{
X  VA_LIST arg;				/* argument vector */
X  int v;				/* return value */
X
X  VA_START(arg, fmt);
X  v = _vsscanf(buf, fmt, arg);
X  VA_END(arg);
X
X  return v;
X}
END_OF_FILE
if test 743 -ne `wc -c <'sscanf.c'`; then
    echo shar: \"'sscanf.c'\" unpacked with wrong size!
fi
# end of 'sscanf.c'
fi
if test -f 'stdarg.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'stdarg.h'\"
else
echo shar: Extracting \"'stdarg.h'\" \(1176 characters\)
sed "s/^X//" >'stdarg.h' <<'END_OF_FILE'
X#ifndef _STDARG_H
X#define _STDARG_H
X
X/*			s t d a r g
X *
X * This file is based on stdarg.h as posted by Steve Summit.
X * It has been reworked to use char * for the argument list
X * pointer to make it easier to use with old varargs code.
X *
X * stdarg implementation for "conventional" architectures with
X * downward-growing stacks.  The stack is assumed to be aligned
X * to word, i.e. int, sized boundaries, with smaller arguments
X * widened when passed and larger arguments equal to (or rounded
X * up to) a multiple of the word size.
X *
X * The stack word size can be changed by adjusting the
X * _va_stackalign define.
X *
X * Bug: doesn't know that float arguments are widened to double
X * when passed.  Don't, therefore, call va_arg(..., float).
X *
X * Steve Summit  4/15/89
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#define _va_stackalign	int
Xtypedef char *va_list;
X#define _va_arg(t) (((sizeof(t) + (sizeof(_va_stackalign) - 1)) \
X                     / sizeof(_va_stackalign)) \
X                    * sizeof(_va_stackalign))
X#define va_start(v,l) (v = (char *) &(l) + _va_arg(l))
X#define va_arg(v,t)  (*((t *)(((v) += _va_arg(t)) - _va_arg(t))))
X#define va_end(v)
X#endif
END_OF_FILE
if test 1176 -ne `wc -c <'stdarg.h'`; then
    echo shar: \"'stdarg.h'\" unpacked with wrong size!
fi
# end of 'stdarg.h'
fi
if test -f 'tmpfile.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tmpfile.c'\"
else
echo shar: Extracting \"'tmpfile.c'\" \(802 characters\)
sed "s/^X//" >'tmpfile.c' <<'END_OF_FILE'
X/*			t m p f i l e
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * Create a temporary file that will be deleted when the process
X * exits. This is done without signals by actually deleting the
X * directory entry immediately after creating the file. The
X * file is opened with mode w+.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
XFILE *tmpfile(T(void,))
X
X{
X  char *name;				/* name of file */
X  int i;				/* retry count */
X  FILE *fp;				/* temporary file */
X
X  for (i = TMP_MAX;
X       i-- && (fp = fopen(name = tmpnam((char *) 0), "w+")) == NULL;
X      )
X    ;
X  return fp == NULL ? NULL : (remove(name), fp);
X}
END_OF_FILE
if test 802 -ne `wc -c <'tmpfile.c'`; then
    echo shar: \"'tmpfile.c'\" unpacked with wrong size!
fi
# end of 'tmpfile.c'
fi
if test -f 'ungetc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ungetc.c'\"
else
echo shar: Extracting \"'ungetc.c'\" \(1092 characters\)
sed "s/^X//" >'ungetc.c' <<'END_OF_FILE'
X/*				u n g e t c
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * This function pushes a character back into an input stream. The
X * character will be returned by the next getc call on the stream.
X * One character of pushback is guaranteed provided something
X * is read from the stream.
X *
X * Attempts to pushback EOF will fail and the function will return
X * EOF, otherwise the character pushed back will be returned. EOF
X * will also be returned if the attempt to pushback fails.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
Xint ungetc(T(int ch, ch), T(FILE *fp, fp))
X
XD(int ch)				/* character to push back */
XD(FILE *fp)				/* stream */
X
X{
X  if (ch == EOF  || TESTFLAG(fp, _IOREAD) == 0 ||
X      fp->_base == NULL || (fp->_rptr == fp->_base && ! TESTFLAG(fp, _IONBF)))
X    return EOF;
X
X  if (TESTFLAG(fp, _IONBF) != 0)
X    fp->_rptr = fp->_rend = fp->_base + 1;
X
X  return UCHAR(*--fp->_rptr = ch);
X}
END_OF_FILE
if test 1092 -ne `wc -c <'ungetc.c'`; then
    echo shar: \"'ungetc.c'\" unpacked with wrong size!
fi
# end of 'ungetc.c'
fi
if test -f 'vsprintf.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'vsprintf.c'\"
else
echo shar: Extracting \"'vsprintf.c'\" \(996 characters\)
sed "s/^X//" >'vsprintf.c' <<'END_OF_FILE'
X/*				v s p r i n t f
X *
X * (C) Copyright C E Chew
X *
X * Feel free to copy, use and distribute this software provided:
X *
X *	1. you do not pretend that you wrote it
X *	2. you leave this copyright notice intact.
X *
X * This function provides the same functionality as sprintf except
X * that it uses varargs.h.
X *
X * Patchlevel 2.0
X *
X * Edit History:
X */
X
X#include "stdiolib.h"
X
X/*LINTLIBRARY*/
X
Xint vsprintf(T(char *buf, buf), T(const char *fmt, fmt), T(VA_LIST args, args))
X
XD(char *buf)				/* output buffer */
XD(char *fmt)				/* format */
XD(VA_LIST args)				/* argument list */
X
X{
X  int v;				/* return value */
X  FILE f;				/* temporary file */
X
X  f._flag   = _IOWRITE | _IOSTRING;
X  f._base   = (_stdiobuf_t *) buf;
X  f._bufsiz = (char *) (~0) - buf;
X
X  f._filbuf = (int (*) P((FILE *)))      _bfail;
X  f._flsbuf = (int (*) P((int, FILE *))) _bfail;
X  f._flush  = (int (*) P((FILE *)))      _bfail;
X
X  INITWRITEBUFFER(&f);
X
X  v = vfprintf(&f, fmt, args);
X  (void) FPUTC(0, &f);
X
X  return v;
X}
END_OF_FILE
if test 996 -ne `wc -c <'vsprintf.c'`; then
    echo shar: \"'vsprintf.c'\" unpacked with wrong size!
fi
# end of 'vsprintf.c'
fi
echo shar: End of archive 2 \(of 6\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 5 6 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 6 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Earl Chew, Dept of Computer Science, Monash University, Australia 3168
ARPA: cechew%bruce.cs.monash.oz.au@uunet.uu.net  ACS : cechew@bruce.oz