[comp.os.os9] OS9Lib Part 02/05

ocker@lan.informatik.tu-muenchen.dbp.de (Wolfgang Ocker) (10/11/88)

#! /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 5)."
# Contents:  gethname.c infomod.h MAN/Findmod.prf MAN/Shell.prf
#   isatty.c ttynam.c rename.c getpass.c varargs.h makefile cuserid.c
#   findmod.c MAN/Popen.prf getwd.c pipe.c regsub.c MAN/Bootdrive.prf
#   getlog.c bootdrv.c atime.c utmp.h getargs.c MAN/Stat.prf stat.c
#   MAN/Strings.prf
# Wrapped by weo@recsys on Tue Oct 11 14:22:34 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'gethname.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'gethname.c'\"
else
echo shar: Extracting \"'gethname.c'\" \(1385 characters\)
sed "s/^X//" >'gethname.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  gethostname()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <hostname.h>
X
Xextern char *info_str();
X
X/*
X * g e t h o s t n a m e
X *
X * gets the name of the host from SYSINFO (fairly simple, isn't it?)
X */
Xchar *gethostname(hostname, len)
X  char *hostname;
X  int  len;	
X{
X  return(info_str("hostname", hostname, len));
X}
X
END_OF_FILE
if test 1385 -ne `wc -c <'gethname.c'`; then
    echo shar: \"'gethname.c'\" unpacked with wrong size!
fi
# end of 'gethname.c'
fi
if test -f 'infomod.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'infomod.h'\"
else
echo shar: Extracting \"'infomod.h'\" \(1409 characters\)
sed "s/^X//" >'infomod.h' <<'END_OF_FILE'
Xtypedef struct {
X  int status;     /* Status (locked/unlocked) */
X  int flags;      /* Flags */
X  int timestamp;  /* Wann wurde gelocked */
X  int pid;        /* Prozessid */
X  int signal;     /* Signal zu killen */
X  int datbeg;     /* Startzeit des Prozesses */
X  int timbeg;
X  int future[4];
X} LOCK;
X
Xtypedef struct {
X  char *name;     /* Name des Eintrags */
X  char *data;     /* Zeiger auf Daten */
X  int  type;      /* Typ, noch nicht benutzt */
X  int  datasize;  /* Groesse des Datenbereichs */
X  int  future[4];
X} ENTRY;
X
Xtypedef struct {
X  int   num;      /* Anzahl Eintraege */
X  int   size;     /* Gesamtgroesse, unbenutzt */
X  int   rev;      /* Revision */
X  int   future[8];
X  LOCK  ev_lock;  /* Lock-Info fuer das Event, unbenutzt */
X  ENTRY entry[1]; /* Eintraege */
X} INFO;
X
X#define INFO_MODULE_NAME "SysInfo"        /* Name des Daten-Moduls */
X#define INFO_EVENT_NAME "SysInfo"         /* Name des Events */
X#define INFO_FILE_NAME "/dd/SYS/sysinfo"  /* Default-Path der sysinfo-Datei */
X
X#define TRUE  1
X#define FALSE 0
X
X#define OK      0
X#define FAILED -1
X
X#define T_UNKNOWN 0   /* ??? */
X#define T_STRING 1    /* String (s) */
X#define T_NUM 2       /* Zahl (n), unbenutzt */
X#define T_DATA 3      /* Daten (allgemein) */
X#define T_LOCK 4      /* Lock-Info */
X
X#define ST_LOCKED 1   /* Device ist gelocked */
X#define ST_FREE 0     /* Device ist frei */
X
X#define REVISION 1    /* Revision */
END_OF_FILE
if test 1409 -ne `wc -c <'infomod.h'`; then
    echo shar: \"'infomod.h'\" unpacked with wrong size!
fi
# end of 'infomod.h'
fi
if test -f 'MAN/Findmod.prf' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MAN/Findmod.prf'\"
else
echo shar: Extracting \"'MAN/Findmod.prf'\" \(1398 characters\)
sed "s/^X//" >'MAN/Findmod.prf' <<'END_OF_FILE'
X.fill
X.justify
X.offset 5
X.rightmargin 55
X.pagesize 48
X.m1 2
X.m2 1
X.m3 2
X.m4 3
X.ec \
X.header /Findmod/OS9Lib/Findmod
X.footer /Page #//Printed (%)/
X.in +5
X.define topic
X.bold
X.in -5
X$1 $2 $3 $4 $5
X.in +5
X.en
X.define endtopic
X
X
X.en
X.define noform
X.nojustify
X.nofill
X.en
X.define noformend
X.justify
X.fill
X.en
X.! Manual created with MWB
X.! END-OF-MACRO
X.topic NAME
XFindmod - Find an executable file
X.endtopic
X.topic SYNOPSIS
X.noform
Xchar	*findmod (modname, infoname)
Xchar	*modname;
Xchar	*infoname;
X
X.noformend
X.endtopic
X.topic DESCRIPTION
X.bold
XFindmod
Xlooks for an executable file. The first argument is an assumed filename of
X.ul
Xmodname
Xwhich may be complete pathname or only a modulename. The second entry
X.ul
Xinfoname
Xis used to determinate the path by looking in the Sysinfo module.
XFindmod first looks into the memory if the module is yet loaded and
Xthen returns only the modulename. If it is not found findmod will return
Xthe entry in sysinfo (if found) or the given pathname.
X.endtopic
X.topic RETURN VALUE
XFindmod always returns a pointer to a regular string.
X.endtopic
X.topic SYSINFO
X.noform
XOnly if the searched module is in the Sysinfo module.
X.noformend
X.endtopic
X.topic EXAMPLES
X.noform
Xos9exec (os9forkc, findmod (arg[0],arg[0]),arg,environ,0,0,3);
X.noformend
X.endtopic
X.topic SEE ALSO
X.noform
Xos9exec ()
Xin the C-Compiler User's Manual and
XSysinfo
Xin the TOP Release
X.noformend
X.endtopic
END_OF_FILE
if test 1398 -ne `wc -c <'MAN/Findmod.prf'`; then
    echo shar: \"'MAN/Findmod.prf'\" unpacked with wrong size!
fi
# end of 'MAN/Findmod.prf'
fi
if test -f 'MAN/Shell.prf' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MAN/Shell.prf'\"
else
echo shar: Extracting \"'MAN/Shell.prf'\" \(1512 characters\)
sed "s/^X//" >'MAN/Shell.prf' <<'END_OF_FILE'
X.fill
X.justify
X.offset 5
X.rightmargin 55
X.pagesize 48
X.m1 2
X.m2 1
X.m3 2
X.m4 3
X.ec \
X.header /Shell/OS9Lib/Shell
X.footer /Page #//Printed (%)/
X.in +5
X.define topic
X.bold
X.in -5
X$1 $2 $3 $4 $5
X.in +5
X.en
X.define endtopic
X
X
X.en
X.define noform
X.nojustify
X.nofill
X.en
X.define noformend
X.justify
X.fill
X.en
X.! Manual created with MWB
X.! END-OF-MACRO
X.topic NAME
XShell - Execute a shell command
X.endtopic
X.topic SYNOPSIS
X.noform
Xint	shell (name)
Xchar	*name;
X
Xint	xshell (name)
Xchar	*name;
X
X.noformend
X.endtopic
X.topic DESCRIPTION
X.bold
XShell()
Xand
X.bold
Xxshell()
Xare provideing a simple method of executing programs. The argument
X.ul
Xname
Xis the command with arguments as a string. Shell() uses the OS9 `shell` to
Xexecute commands (including wildcard expansion, I/O redirection etc.),
Xxshell() doesn't use a shell, so it is saver and faster.
X.endtopic
X.topic CAVEATS
X.ul
XXshell
Xcan't expand wild cards etc. because no shell will be forked to execute
Xthe command. If you need a shell feature, use
X.ul
Xshell
Xor
X.ul
Xsystem
Xor gove `shell` as the desired command.
X.endtopic
X.topic RETURN VALUE
XShell() and xshell() return 0 on success and -1 on failure.  On failure
Xerrno is set to the returnvalue of the program if it has been executed.
X.endtopic
X.topic SYSINFO
X.noform
XSYSTEM.SHELL,s=shell
X.in +5
XThis shell is used when using shell().
X.in -5
X.noformend
X.endtopic
X.topic EXAMPLES
X.noform
X(void) shell ("echo *.c");
X.noformend
X.endtopic
X.topic SEE ALSO
X.noform
XSystem()
Xin the C Compiler User's Manual
X.noformend
X.endtopic
END_OF_FILE
if test 1512 -ne `wc -c <'MAN/Shell.prf'`; then
    echo shar: \"'MAN/Shell.prf'\" unpacked with wrong size!
fi
# end of 'MAN/Shell.prf'
fi
if test -f 'isatty.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'isatty.c'\"
else
echo shar: Extracting \"'isatty.c'\" \(1542 characters\)
sed "s/^X//" >'isatty.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  isatty(), isapipe()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <sgstat.h>
X
X/*
X * i s w h a t
X */
Xstatic int iswhat(p)
X  int p;
X{
X  struct  _sgs  opt;
X
X  if (_gs_opt(p, &opt) < 0)
X    return(-1);
X  return(opt._sgs_class);
X}
X
X/*
X * i s a t t y
X */
Xint isatty(f)
X  int f;
X{
X  int t;
X  
X  if ((t = iswhat(f)) < 0)
X    return(0);
X
X  return(t == 0);
X}
X
X
X/*
X * i s a p i p e
X */
Xint isapipe(f)
X  int f;
X{
X  int t;
X  
X  if ((t = iswhat(f)) < 0)
X    return(0);
X
X  return(t == 1);
X}
X
END_OF_FILE
if test 1542 -ne `wc -c <'isatty.c'`; then
    echo shar: \"'isatty.c'\" unpacked with wrong size!
fi
# end of 'isatty.c'
fi
if test -f 'ttynam.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ttynam.c'\"
else
echo shar: Extracting \"'ttynam.c'\" \(1587 characters\)
sed "s/^X//" >'ttynam.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  ttynam()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <stdio.h>
X#include <sgstat.h>
X
Xstatic char line[80];
X
X/*
X * t t y n a m e
X */
Xchar *ttyname(path)
X  int path;
X{
X  struct _sgs OptBuf;
X
X  /*
X   * Devicenamen holen. Wenn die Device-Class nicht 0 (SCF) ist,
X   * dann auch Fehler
X   */
X  if (_gs_devn(path, line) < 0)
X    return(NULL);
X  else
X    if (_gs_opt(path, &OptBuf) < 0)
X      return(NULL);
X    else
X      if (OptBuf._sgs_class != 0)   /* SCF-Device?? */
X        return(NULL);
X      else
X        return(line);
X}
END_OF_FILE
if test 1587 -ne `wc -c <'ttynam.c'`; then
    echo shar: \"'ttynam.c'\" unpacked with wrong size!
fi
# end of 'ttynam.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'\" \(1644 characters\)
sed "s/^X//" >'rename.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  rename(), copy()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <stdio.h>
X#include <strings.h>
X
Xextern int xshell();
X
X
X/*
X * r e n a m e
X */
Xint rename(old, new)
X  register char *old, *new;
X{
X  char          tmp[300];
X  register char *cp;
X  
X  if ((cp = rindex(new, '/')) != NULL)
X    new = cp + 1;
X
X  sprintf(tmp, "rename %s %s", old, new);
X  return(xshell(tmp));
X}
X
X/*
X * c o p y
X */
Xint copy(src, dest, over)
X  register char *src, *dest;
X  register int  over;
X{
X  char          tmp[300];
X
X  sprintf(tmp, "copy %s %s%s", src, dest, over ? " -r" : "");
X  return(xshell(tmp));
X}
X
END_OF_FILE
if test 1644 -ne `wc -c <'rename.c'`; then
    echo shar: \"'rename.c'\" unpacked with wrong size!
fi
# end of 'rename.c'
fi
if test -f 'getpass.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'getpass.c'\"
else
echo shar: Extracting \"'getpass.c'\" \(1649 characters\)
sed "s/^X//" >'getpass.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  getpass()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <sgstat.h>
X
Xstatic char pwline[81];
X
X/*
X * g e t p a s s
X */
Xchar *getpass(prompt)
X  char *prompt;
X
X{
X  struct sgbuf optbuf;
X  int          echo, Count;
X	
X  _gs_opt(0, &optbuf);
X  echo           = optbuf.sg_echo;
X  optbuf.sg_echo = 0;
X  _ss_opt(0, &optbuf);
X  
X  write (1, prompt, strlen(prompt));
X  Count = readln(0, pwline, 80);
X  if (!Count)
X    *pwline = '\0';
X  else
X    if (pwline[Count-1] == '\n')
X      pwline[Count-1] = '\0';
X
X  optbuf.sg_echo = echo;
X  _ss_opt(0, &optbuf);
X  writeln(1, "\n", 1);
X  return(pwline);
X}
X
END_OF_FILE
if test 1649 -ne `wc -c <'getpass.c'`; then
    echo shar: \"'getpass.c'\" unpacked with wrong size!
fi
# end of 'getpass.c'
fi
if test -f 'varargs.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'varargs.h'\"
else
echo shar: Extracting \"'varargs.h'\" \(1657 characters\)
sed "s/^X//" >'varargs.h' <<'END_OF_FILE'
X/* varargs.h for os9/68k by Robert A. Larson	*/
X/* version 0 for os9/68k C 2.0 04/20/86		*/
X/* varargs is a "portable" way to write a routine that takes a variable */
X/* number of arguements.  This implemination agrees with both the 4.2bsd*/
X/* and Sys V documentation of varargs.  Note that just because varargs.h*/
X/* is used does not mean that it is used properly.			*/
X/* Ignore the "expression with little effect" warnings.  (Seems to be a */
X/* compiler bug.)							*/
X
X#define va_alist	_va_arg1, _va_arg2, _va_arg3
X
X#define va_dcl		unsigned _va_arg1, _va_arg2, _va_arg3;
X
Xtypedef	struct {
X	  unsigned _va_at;  /* number of arguments used, 0, 1, or more  */
X                            /* (double as first arg counts as 2)        */
X	  union {
X	    struct {
X	      unsigned _va_uns1, _va_uns2;
X	    } _va_uuns;
X	    double _va_udouble;
X	  } _va_union;
X	  char *_va_pointer;
X        } va_list;
X
X#define	va_start(pvar)	( (pvar)._va_at = 0,				\
X			  (pvar)._va_union._va_uuns._va_uns1 = _va_arg1,\
X			  (pvar)._va_union._va_uuns._va_uns2 = _va_arg2,\
X			  (pvar)._va_pointer = (char *) &_va_arg3	\
X			)
X
X#define va_arg(pvar, type)	(				\
X	((pvar)._va_at++) ? (					\
X		((pvar)._va_at == 2) ? (			\
X			(sizeof(type) == 8) ? (			\
X				*(((type *)((pvar)._va_pointer))++)	\
X			) : (type)(				\
X				(pvar)._va_union._va_uuns._va_uns2	\
X			)					\
X		) : (						\
X			*(((type *)((pvar)._va_pointer))++)	\
X		)						\
X	) : (							\
X		(sizeof(type) == 8) ? (type)(			\
X			(pvar)._va_at++,			\
X			(pvar)._va_union._va_udouble		\
X		) : (type)(					\
X			(pvar)._va_union._va_uuns._va_uns1	\
X		)						\
X	)							\
X)
X
X#define va_end(pvar)				/* va_end is simple */
X
END_OF_FILE
if test 1657 -ne `wc -c <'varargs.h'`; then
    echo shar: \"'varargs.h'\" unpacked with wrong size!
fi
# end of 'varargs.h'
fi
if test -f 'makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'makefile'\"
else
echo shar: Extracting \"'makefile'\" \(1677 characters\)
sed "s/^X//" >'makefile' <<'END_OF_FILE'
X* 
X* Makefile for OS9LIB
X*
X
XRDIR      = RELS
XLDIR      = /h0/LIB
XODIR      = /h0/ETC/CMDS
XUDIR      = /h0/USR/CMDS
X
XCFLAGS    = -qt=/dd/TMP
XCC        = cc
XLINTFLAGS = -DLINT
XDDIR      = /dd/DEFS
X
Xall: $(LDIR)/os9lib.l $(ODIR)/setup $(ODIR)/getinfo $(UDIR)/man
X     touch all
X
XOBJS = rename.r shell.r getwd.r popen.r findmod.r getlog.r \
X       cuserid.r chpass.r chgrppass.r grp.r pw.r perror.r signal.r pipe.r \
X       isatty.r atime.r getmuid.r utime.r stat.r ttynam.r regexp.r regsub.r \
X       regerror.r utmp.r mdir.r getpass.r rndsalt.r crypt.r rnd.r \
X       gethname.r info.r getargs.r bootdrv.r umask.r strings.r bsearch.r
X
XSRCS = rename.c shell.c getwd.c popen.c findmod.c getlog.c \
X       cuserid.c chpass.c chgrppass.c grp.c pw.c perror.c pipe.c \
X       isatty.c atime.c getmuid.c utime.c stat.c ttynam.c regexp.c regsub.c \
X       regerror.c utmp.c mdir.c getpass.c rndsalt.c crypt.c rnd.c \
X       gethname.c info.c getargs.c bootdrv.c umask.c strings.c bsearch.c
X
X$(LDIR)/os9lib.l: $(OBJS)
X  chd $(RDIR); merge $(OBJS) >-$(LDIR)/os9lib.l
X  attr $(LDIR)/os9lib.l -npwpr
X
X$(ODIR)/setup: setup.r
X               chd $(RDIR); $(CC) $(CFLAGS) setup.r -f=$(ODIR)/setup
X               attr $(ODIR)/setup -npenpwnpr
X
X$(ODIR)/getinfo: getinfo.r
X                 chd $(RDIR); $(CC) $(CFLAGS) getinfo.r -l=$(LDIR)/os9lib.l \
X                                    -f=$(ODIR)/getinfo
X                 attr $(ODIR)/getinfo -npwnprpe
X
X$(UDIR)/man: man.r
X             chd $(RDIR); $(CC) $(CFLAGS) man.r -l=$(LDIR)/os9lib.l \
X                                -f=$(UDIR)/man
X             attr $(UDIR)/man -npwnprpe
X
Xos9lib.lint: $(SRCS)
X  lint $(LINTFLAGS) $(SRCS) >>>-os9lib.lint
X
END_OF_FILE
if test 1677 -ne `wc -c <'makefile'`; then
    echo shar: \"'makefile'\" unpacked with wrong size!
fi
# end of 'makefile'
fi
if test -f 'cuserid.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'cuserid.c'\"
else
echo shar: Extracting \"'cuserid.c'\" \(1695 characters\)
sed "s/^X//" >'cuserid.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  cuserid(), chome()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <stdio.h>
X#include <pwd.h>
X
Xextern char *getenv();
X
X/*
X * c u s e r i d
X */
Xchar *cuserid()
X{
X  static                 char username[40];
X  register struct passwd *pw;
X  
X  if (pw = getpwuid(getuid() & 0x0ffff)) {
X    strcpy(username, pw->pw_name);
X    return(username);
X  }
X  else
X    return(NULL);   /* Fehler */
X}
X
X
X/*
X * c h o m e
X */
Xchar *chome()
X{
X  static                 char home[200];
X  register struct passwd *pw;
X
X  if (pw = getpwuid(getuid() & 0x0ffff)) {
X    strcpy(home, pw->pw_dir);
X    return(home);
X  }
X  else
X    return(NULL);   /* Fehler */
X}
X
END_OF_FILE
if test 1695 -ne `wc -c <'cuserid.c'`; then
    echo shar: \"'cuserid.c'\" unpacked with wrong size!
fi
# end of 'cuserid.c'
fi
if test -f 'findmod.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'findmod.c'\"
else
echo shar: Extracting \"'findmod.c'\" \(1768 characters\)
sed "s/^X//" >'findmod.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  findmod()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <stdio.h>
X#include <strings.h>
X#include <module.h>
X
Xextern char *info_str();
X
X/*
X * f i n d m o d
X */
Xchar *findmod(modname, infoname)
X  register char *modname;
X  char          *infoname;
X{
X  static char   path[200];
X  register char *mod, *cp;
X
X  if ((cp = rindex(infoname, '/')) != NULL)
X    infoname = cp + 1;
X
X  if (info_str(infoname, path, sizeof(path)) != NULL)
X    modname = path;
X
X  if (cp = rindex(modname, '/'))
X    cp++;
X  else
X    cp = modname;
X
X  if ((mod = (char *) modlink(cp, mktypelang(MT_PROGRAM, ML_ANY))) ==
X      (char *) -1)
X    strcpy(path, modname);
X  else {
X    strcpy(path, cp);
X    munlink(mod);
X  }
X  
X  return(path);
X}
END_OF_FILE
if test 1768 -ne `wc -c <'findmod.c'`; then
    echo shar: \"'findmod.c'\" unpacked with wrong size!
fi
# end of 'findmod.c'
fi
if test -f 'MAN/Popen.prf' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MAN/Popen.prf'\"
else
echo shar: Extracting \"'MAN/Popen.prf'\" \(1833 characters\)
sed "s/^X//" >'MAN/Popen.prf' <<'END_OF_FILE'
X.fill
X.justify
X.offset 5
X.rightmargin 55
X.pagesize 48
X.m1 2
X.m2 1
X.m3 2
X.m4 3
X.ec \
X.header /Popen/OS9Lib/Popen
X.footer /Page #//Printed (%)/
X.in +5
X.define topic
X.bold
X.in -5
X$1 $2 $3 $4 $5
X.in +5
X.en
X.define endtopic
X
X
X.en
X.define noform
X.nojustify
X.nofill
X.en
X.define noformend
X.justify
X.fill
X.en
X.! Manual created with MWB
X.! END-OF-MACRO
X.topic NAME
XPopen - Controls I/O of a process
X.endtopic
X.topic SYNOPSIS
X.noform
XFILE	*popen (name, mode)
Xchar	*name, *mode;
X
XFILE	*xpopen(name, mode)
Xchar	*name, *mode;
X
Xunsigned int	pclose(fp)
XFILE 		*fp;
X
X.noformend
X.endtopic
X.topic DESCRIPTION
X.bold
XPopen
Xrequires two arguments, the first is a commandstring and the second is
Xthe type of I/O handling. Popen starts the command given to the function
Xand redirects the input of the program (if the type is "w") or the
Xoutput of the program (if the type is "r"). The current process can then write
Xto the program which will interpret this as his input or read the
Xoutput of the program. After completion you should call
X.bold
Xpclose
Xwith the file pointer returned by popen.
X.bold
XXpopen
Xis like popen but no shell will be forked to execute the command.
X.endtopic
X.topic CAVEATS
XWhen using
X.ul
Xxpopen
Xno wild card expansion etc. would take place, because no shell is
Xforked. If you need such shell features use
X.ul
Xpopen
Xor give `shell` as the command.
X.endtopic
X.topic RETURN VALUE
XPopen and xpopen return a valid file pointer on success, NULL on
Xfailure. Pclose returns -1 on failure or the return status of the
Xprogram.
X.endtopic
X.topic SYSINFO
X.noform
XSYSTEM.SHELL,s=shell
X.in +5
X.ju
X.fi
Xwill be the shell which is used by popen, default is `shell`.
X.nj
X.nf
X.in -5
X.noformend
X.endtopic
X.topic EXAMPLES
X.noform
X# include	<stdio.h>
X
XFILE *fp;
Xchar wd[1024];
X
Xfp = popen ("pd","r");
Xfgets (wd, 1024, fp);
Xpclose (fp);
X.noformend
X.endtopic
END_OF_FILE
if test 1833 -ne `wc -c <'MAN/Popen.prf'`; then
    echo shar: \"'MAN/Popen.prf'\" unpacked with wrong size!
fi
# end of 'MAN/Popen.prf'
fi
if test -f 'getwd.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'getwd.c'\"
else
echo shar: Extracting \"'getwd.c'\" \(1857 characters\)
sed "s/^X//" >'getwd.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  getwd(), getx()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <stdio.h>
X#include <strings.h>
X
XFILE *xpopen();
X
X/*
X * g e t w x d
X */
Xstatic char *getwxd(wd, opt)
X  register char *wd;
X  register char *opt;
X{
X  register FILE *fp;
X  char          tmp[40];
X  register char *cp;
X  
X  wd[0] = '\0';
X
X  (void) strcpy(tmp, "/h0/CMDS/pd");
X  if (opt != NULL)
X    (void) strcat(tmp, opt);
X
X  if ((fp = xpopen(tmp, "r")) == NULL)
X    return(NULL);
X
X  if (fgets(wd, 200, fp) == NULL)
X    return(NULL);
X
X  if ((cp = index(wd, '\n')) != NULL)
X    *cp = '\0';
X
X  while (fgets(tmp, sizeof(tmp)-1, fp) != NULL) ;
X  
X  pclose(fp);
X  return(wd);
X}
X
X/*
X * g e t w d
X */
Xchar *getwd(wd)
X  char *wd;
X{
X  return(getwxd(wd, NULL));
X}
X
X/*
X * g e t x d
X */
Xchar *getxd(wd)
X  char *wd;
X{
X  return(getwxd(wd, " -x"));
X}
END_OF_FILE
if test 1857 -ne `wc -c <'getwd.c'`; then
    echo shar: \"'getwd.c'\" unpacked with wrong size!
fi
# end of 'getwd.c'
fi
if test -f 'pipe.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pipe.c'\"
else
echo shar: Extracting \"'pipe.c'\" \(1876 characters\)
sed "s/^X//" >'pipe.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  pipe(), dup2()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <modes.h>
X
X/*
X * p i p e
X *
X * simulate the pipe() function of UN*X for OS9
X * very simple here ....
X */
Xint pipe(pv)
X  register int *pv;
X{
X  if ((pv[0] = creat("/pipe", S_IREAD+S_IWRITE)) < 0)
X    return(-1);
X
X  if ((pv[1] = dup(pv[0])) < 0) {
X    close(pv[0]);
X    return(-1);
X  }
X
X  return(0);
X}
X
X/*
X * d u p 2
X *
X * simulate the dup2() function of UN*X for OS9
X * the following should do it ...
X */
Xint dup2(src, dest)
X  register int src, dest;
X{
X  register int i, newfd;
X  int          p[32];
X
X  close(dest);
X
X  for(i = 0; i < 32; p[i++] = 0);
X
X  do {
X    i = dup(src);
X    p[i] = 1;
X  } while(i != dest && i < 32);
X
X  p[i]  = 0;
X  newfd = dup(src);
X
X  for(i = 0; i < 32; i++)
X    if (p[i])
X      close(i);
X
X  return(dest == newfd ? 0 : -1);
X}
X
END_OF_FILE
if test 1876 -ne `wc -c <'pipe.c'`; then
    echo shar: \"'pipe.c'\" unpacked with wrong size!
fi
# end of 'pipe.c'
fi
if test -f 'regsub.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'regsub.c'\"
else
echo shar: Extracting \"'regsub.c'\" \(1889 characters\)
sed "s/^X//" >'regsub.c' <<'END_OF_FILE'
X/*
X * regsub
X *
X *	Copyright (c) 1986 by University of Toronto.
X *	Written by Henry Spencer.  Not derived from licensed software.
X *
X *	Permission is granted to anyone to use this software for any
X *	purpose on any computer system, and to redistribute it freely,
X *	subject to the following restrictions:
X *
X *	1. The author is not responsible for the consequences of use of
X *		this software, no matter how awful, even if they arise
X *		from defects in it.
X *
X *	2. The origin of this software must not be misrepresented, either
X *		by explicit claim or by omission.
X *
X *	3. Altered versions must be plainly marked as such, and must not
X *		be misrepresented as being the original software.
X */
X
X#include <stdio.h>
X#include "regexp.h"
X#include "regmagic.h"
X
X#ifndef CHARBITS
X#define	UCHARAT(p)	((int)*(unsigned char *)(p))
X#else
X#define	UCHARAT(p)	((int)*(p)&CHARBITS)
X#endif
X
X/*
X - regsub - perform substitutions after a regexp match
X */
Xvoid
Xregsub(prog, source, dest)
Xregexp *prog;
Xchar *source;
Xchar *dest;
X{
X	register char *src;
X	register char *dst;
X	register char c;
X	register int no;
X	register int len;
X	extern char *strncpy();
X
X	if (prog == NULL || source == NULL || dest == NULL) {
X		regerror("NULL parm to regsub");
X		return;
X	}
X	if (UCHARAT(prog->program) != MAGIC) {
X		regerror("damaged regexp fed to regsub");
X		return;
X	}
X
X	src = source;
X	dst = dest;
X	while ((c = *src++) != '\0') {
X		if (c == '&')
X			no = 0;
X		else if (c == '\\' && '0' <= *src && *src <= '9')
X			no = *src++ - '0';
X		else
X			no = -1;
X
X		if (no < 0)	/* Ordinary character. */
X			*dst++ = c;
X		else if (prog->startp[no] != NULL && prog->endp[no] != NULL) {
X			len = prog->endp[no] - prog->startp[no];
X			(void) strncpy(dst, prog->startp[no], len);
X			dst += len;
X			if (len != 0 && *(dst-1) == '\0') {		/* strncpy hit NUL. */
X				regerror("damaged match string");
X				return;
X			}
X		}
X	}
X	*dst++ = '\0';
X}
END_OF_FILE
if test 1889 -ne `wc -c <'regsub.c'`; then
    echo shar: \"'regsub.c'\" unpacked with wrong size!
fi
# end of 'regsub.c'
fi
if test -f 'MAN/Bootdrive.prf' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MAN/Bootdrive.prf'\"
else
echo shar: Extracting \"'MAN/Bootdrive.prf'\" \(1879 characters\)
sed "s/^X//" >'MAN/Bootdrive.prf' <<'END_OF_FILE'
X.fill
X.justify
X.offset 5
X.rightmargin 55
X.pagesize 48
X.m1 2
X.m2 1
X.m3 2
X.m4 3
X.ec \
X.header /Bootdrive/OS9Lib/Bootdrive
X.footer /Page #//Printed (%)/
X.in +5
X.define topic
X.bold
X.in -5
X$1 $2 $3 $4 $5
X.in +5
X.en
X.define endtopic
X
X
X.en
X.define noform
X.nojustify
X.nofill
X.en
X.define noformend
X.justify
X.fill
X.en
X.! Manual created with MWB
X.! END-OF-MACRO
X.topic NAME
XBootdrive - Determine the boot device
X.endtopic
X.topic SYNOPSIS
X.noform
X# include	<stdio.h>
X
Xchar	*_bootdrive ()
X
XFILE*	ddfopen (fn, fname, mode, boot)
Xchar	*fn;
Xchar	*fname;
Xchar	*mode;
Xint	boot;
X.noformend
X.endtopic
X.topic DESCRIPTION
X.bold
X_bootdrive
Xdetermines the device from which the system was booted.
X
X.bold
XDdfopen
Xtries to open a file first on the default device /dd, then on failure it
Xtries to open the file on the bootdevice.
X.bold
XDdfopen
Xexpects a filename
X.ul
Xfn
Xwhich contains the absolute path of a file without the device,
Xthe resulting filename will be copied to
X.ul
Xfname
X, the mode of fopen will be given in
X.ul
Xmode
X(for details see fopen) and if
X.ul
Xboot
Xis true, ddfopen only examines the bootdevice.
X.endtopic
X.topic CAVEATS
X_bootdrive returns a pointer to static data which will be overwritten by
Xeach call of this function.
X.endtopic
X.topic RETURN VALUE
X	On success _bootdrive returns a pointer to the bootdrive.  On
Xfailure it returns NULL. 
X
X	On success ddfopen returns a pointer to FILE (defined in
Xstdio.h), on failure it returns a NULL pointer.
X
X.endtopic
X.topic EXAMPLES
X.noform
Xextern char	*_bootdrive ();
Xchar	*drive;
X
Xdrive = _bootdrive ();
X
X
X# include	<stdio.h>
X# define LEN	128
X# define FALSE	0
X   .
X   .
XFILE	*fp;
Xchar	fn[LEN],
X	fname[LEN + 33];	/* including the device */
X
Xstrcpy (fn, "/SYS/password");
Xif ((fp = ddfopen (fn,fname,"r",FALSE)) == NULL)
X	return (-1);
X
X.noformend
X.endtopic
X.topic SEE ALSO
X.noform
Xfopen ()
Xin the C-Compiler User's Manual
X.noformend
X.endtopic
END_OF_FILE
if test 1879 -ne `wc -c <'MAN/Bootdrive.prf'`; then
    echo shar: \"'MAN/Bootdrive.prf'\" unpacked with wrong size!
fi
# end of 'MAN/Bootdrive.prf'
fi
if test -f 'getlog.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'getlog.c'\"
else
echo shar: Extracting \"'getlog.c'\" \(2035 characters\)
sed "s/^X//" >'getlog.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  getlogin()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <stdio.h>
X#include <time.h>
X#include <strings.h>
X#include <utmp.h>
X#include <pwd.h>
X
Xstatic char *chkpw();
X
X/*
X * g e t l o g i n
X */
Xchar *getlogin()
X{
X  register char        *cp;
X  static char          user[33];
X  char                 line[33];
X  register int         res;
X  register struct utmp *utmp;
X	
X  if (_gs_devn(0, line+1) < 0)
X    return (NULL);
X
X  line[0] = '/';
X  setwhoent();
X  res = 0;
X
X  while ((!res) && (utmp = getwhoent()) != NULL)
X    res = !strcmp(line, utmp->ut_line);
X
X  if (res) {
X    strcpy(user, utmp->ut_user);
X    cp = user;
X  }
X  else
X    cp = NULL;
X  endwhoent ();
X
X  if (cp == NULL && (cp = chkpw()) != NULL) {
X    strcpy(user, cp);
X    cp = user;
X  }
X
X  return(cp);
X}
X
X/*
X * c h k p w
X */
Xstatic char *chkpw()
X{
X  register struct passwd *pw;
X	
X  if (pw = getpwuid(getuid() & 0x0ffff)) {
X    endpwent();
X    return(pw->pw_name);
X  }
X  else {
X    endpwent();
X    return(NULL);
X  }
X}
END_OF_FILE
if test 2035 -ne `wc -c <'getlog.c'`; then
    echo shar: \"'getlog.c'\" unpacked with wrong size!
fi
# end of 'getlog.c'
fi
if test -f 'bootdrv.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bootdrv.c'\"
else
echo shar: Extracting \"'bootdrv.c'\" \(2090 characters\)
sed "s/^X//" >'bootdrv.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  _bootdrive(), ddfopen()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <stdio.h>
X#include <strings.h>
X#include <module.h>
X
X/*
X * _ b o o t d r i v e
X */
Xchar *_bootdrive()
X{
X  static char    drv[33];
X  register short *init_mod;
X  register char  *drive;
X	
X  if ((init_mod = (short *) modlink("init", mktypelang(MT_SYSTEM, ML_ANY))) ==
X      (short *) -1)
X    return(NULL);
X
X  if (drive = (char *) init_mod + *(init_mod + 0x20))
X    strcpy(drv, drive);
X  else {
X    munlink(init_mod);
X    return(NULL);
X  }
X
X  munlink(init_mod);
X  return(drv);
X}
X
X/*
X * d d f o p e n
X */
XFILE *ddfopen(fn, fname, mode, boot)
X  register char *fn;
X  register char *fname;
X  register char *mode;
X  int           boot;
X{
X  register FILE *fp;
X  register char *drv;
X
X  if (!boot) {
X    strcpy(fname, "/dd/");
X    strcat(fname, fn);
X
X    if (fp = fopen(fname, mode))
X      return(fp);
X  }
X
X  if (drv = _bootdrive()) {
X    strcpy(fname, drv);
X    strcat(fname, "/");
X    strcat(fname, fn);
X    return(fopen(fname, mode));
X  }
X  else
X    return(NULL);
X}
END_OF_FILE
if test 2090 -ne `wc -c <'bootdrv.c'`; then
    echo shar: \"'bootdrv.c'\" unpacked with wrong size!
fi
# end of 'bootdrv.c'
fi
if test -f 'atime.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'atime.c'\"
else
echo shar: Extracting \"'atime.c'\" \(2164 characters\)
sed "s/^X//" >'atime.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  atime()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim and
X |                           Ulli Dessauer, Germering
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X
X#define PATCHLEVEL 1
X
X#include <stdio.h>
X#include <time.h>
X#include <strings.h>
X
Xextern char *getenv();
X
Xstatic char timestr[40];
Xstatic char *month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
X                        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"} ;
Xstatic char *day[]   = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
X
X/*
X * g e t t z
X */
Xstatic char *gettz(tm)
X  register struct tm *tm;
X{
X  char          *tz;
X  static char   tzbuf[20];
X
X  tzbuf[0] = '\0';
X  
X  if ((tz = getenv("TZ")) == NULL)
X    return(tzbuf);
X  
X  strncpy(tzbuf, tz, 3);
X  tzbuf[3] = '\0';
X
X  if (tm->tm_isdst == 1)
X    (void) strcpy(tzbuf, " DST");
X
X  return(tzbuf);
X}
X  
X/*
X * a t i m e
X */
Xchar *atime(tp)
X  time_t *tp;
X{
X  struct tm *tm;
X   
X  tm = localtime(tp);
X  
X  (void) sprintf(timestr, "%3.3s %3.3s %2d, %4d %02d:%02d:%02d %s",
X                          day[tm->tm_wday], month[tm->tm_mon], 
X                          tm->tm_mday, tm->tm_year+1900, 
X                          tm->tm_hour, tm->tm_min, tm->tm_sec,
X                          gettz(tm));
X
X  return(timestr);
X}
END_OF_FILE
if test 2164 -ne `wc -c <'atime.c'`; then
    echo shar: \"'atime.c'\" unpacked with wrong size!
fi
# end of 'atime.c'
fi
if test -f 'utmp.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'utmp.h'\"
else
echo shar: Extracting \"'utmp.h'\" \(2256 characters\)
sed "s/^X//" >'utmp.h' <<'END_OF_FILE'
X#define	UTMP_FILE "/dd/SYS/utmp"
X#define	WTMP_FILE "/dd/SYS/wtmp"
X
X#define	ut_name	ut_user
X
Xstruct utmp {
X  char   ut_user[33];           /* User login name                */
X  char   ut_id[4];              /* /etc/lines id (usually line #) */
X  char   ut_line[33];           /* device name (console, lnxx)    */
X  short  ut_pid;                /* process id                     */
X  short  ut_uid, ut_gid;        /* User ID, Group ID              */
X
X#ifdef notdef
X  struct exit_status {
X    short e_termination;        /* Process termination status     */
X    short e_exit;		/* Process exit status            */
X  } ut_exit;			/* The exit status of a process
X                                 * marked as DEAD_PROCESS.
X                                 */
X#endif
X
X  int    ut_baud;               /* Baud rate                      */
X  short  ut_type;               /* type of entry                  */
X  time_t ut_time;               /* time entry was made            */
X  char   ut_status[10];         /* Flags                          */
X} ;
X
X/*
X * Definitions for ut_type
X */
X#define	EMPTY         0
X#define LOGOFF        0
X#define	BOOT_TIME     1
X#define	USER_PROCESS  2
X#define	OLD_TIME      3
X#define	NEW_TIME      4
X#define	INIT_PROCESS  5         /* Process spawned by "init"           */
X#define	LOGIN_PROCESS 6         /* A "getty" process waiting for login */
X#define	RUN_LVL       7         /* A user process                      */
X#define	DEAD_PROCESS  8
X#define	ACCOUNTING    9
X
X#define	UTMAXTYPE     ACCOUNTING  /* Largest legal value of ut_type */
X
X/*
X * Special strings or formats used in the "ut_line" field when
X * accounting for something other than a process.
X * No string for the ut_line field can be more than 32 chars +
X * a NULL in length.
X */
X#define	RUNLVL_MSG  "run-level %c"
X#define	BOOT_MSG    "system boot"
X#define	OTIME_MSG   "old time"
X#define	NTIME_MSG   "new time"
X
Xextern int         _utmp_write();
Xextern int         setwhoent();
Xextern int         endwhoent();
Xextern struct utmp *getwhoent();
X
Xextern struct utmp *getutent();
Xextern struct utmp *getutid();
Xextern struct utmp *getutline();
Xextern int         pututline();
Xextern int         setutent();
Xextern int         endutent();
Xextern int         utmpname();
X
END_OF_FILE
if test 2256 -ne `wc -c <'utmp.h'`; then
    echo shar: \"'utmp.h'\" unpacked with wrong size!
fi
# end of 'utmp.h'
fi
if test -f 'getargs.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'getargs.c'\"
else
echo shar: Extracting \"'getargs.c'\" \(2296 characters\)
sed "s/^X//" >'getargs.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  getargs()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <stdio.h>
X
X#define sp _sp
X
X#define TRUE  1
X#define FALSE 0
X
X/*
X * g e t a r g s
X */
Xgetargs(s, args)
X  register char *s;
X  char     ***args;
X{
X  register int  i;
X  register char *sp;
X  register char qchar;
X  int           argsnum;
X  
X  i = 0;
X  argsnum = 40;
X
X  if ((*args = (char **) malloc(argsnum * sizeof(char *))) == NULL)
X    return(-1);
X
X  while (TRUE) {
X    if (i >= argsnum-1) {
X      argsnum += 40;
X      if ((*args = (char **) realloc(*args, argsnum * sizeof(char *))) == NULL)
X        return(-1);
X    }
X
X    while (*s == ' ' || *s == '\t')
X      ++s;
X    if (*s == '\n' || *s == '\0')
X      break;
X
X    (*args)[i++] = sp = s;
X
X    qchar = 0;
X    while (*s != '\0' && *s != '\n') {
X      if (qchar == 0 && (*s == ' ' || *s == '\t')) {
X        ++s;
X        break;
X      }
X
X      switch (*s) {
X        case '"':
X        case '\'':
X          if (qchar == *s) {
X            qchar = 0;
X            ++s;
X            break;
X          }
X
X          if (qchar)
X            *sp++ = *s++;
X          else
X            qchar = *s++;
X          break;
X
X        default:
X          *sp++ = *s++;
X          break;
X      }
X    }
X    *sp++ = 0;
X  }
X
X  (*args)[i] = NULL;
X  return(i);
X}
END_OF_FILE
if test 2296 -ne `wc -c <'getargs.c'`; then
    echo shar: \"'getargs.c'\" unpacked with wrong size!
fi
# end of 'getargs.c'
fi
if test -f 'MAN/Stat.prf' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MAN/Stat.prf'\"
else
echo shar: Extracting \"'MAN/Stat.prf'\" \(2301 characters\)
sed "s/^X//" >'MAN/Stat.prf' <<'END_OF_FILE'
X.fill
X.justify
X.offset 5
X.rightmargin 55
X.pagesize 48
X.m1 2
X.m2 1
X.m3 2
X.m4 3
X.ec \
X.header /Stat/OS9Lib/Stat
X.footer /Page #//Printed (%)/
X.in +5
X.define topic
X.bold
X.in -5
X$1 $2 $3 $4 $5
X.in +5
X.en
X.define endtopic
X
X
X.en
X.define noform
X.nojustify
X.nofill
X.en
X.define noformend
X.justify
X.fill
X.en
X.! Manual created with MWB
X.! END-OF-MACRO
X.topic NAME
XStat - Get the properties of a file
X.endtopic
X.topic SYNOPSIS
X.noform
Xint	fstat (fd, buff)
Xint		fd;
Xstruct stat 	*buff;
X
Xint	stat (filename, buff)
Xchar		*filename;
Xstruct stat	*buff;
X
X.noformend
X.endtopic
X.topic DESCRIPTION
X.bold
XStat()
Xand
X.bold
Xfstat()
Xare using a struct defined in
X.ul
Xstat.h
Xstruct stat:
X.nj
X.nf
X.in +5
Xstruct stat {
X  int             st_dev;
X  long            st_ino;
X  unsigned short  st_mode;
X  unsigned short  st_nlink;
X  unsigned short  st_uid;
X  unsigned short  st_gid;
X  int             st_rdev;
X  long            st_size;
X  time_t          st_atime;
X  time_t          st_mtime;
X  time_t          st_ctime;
X};
X.in -5
X.justify
X.fill
X
X	These function are used to determine all properties like
Xowner, size etc. of a filename (stat) or an open path (fstat). The
Xsecond argument is a pointer to a buffer which will be filled with
Xinformation defined with struct stat.
X.ul
Xst_dev
Xholds the information of the kind of the device where the stat call took
Xplace (it's the address of the device table entry).
X.ul
Xst_ino
Xis for compatibility and holds in OS9 the file descriptor PSN.
X.ul
Xst_mode
Xare the access attributes of the file,
X.ul
Xst_nlink
Xis the link count,
X.ul
Xst_uid
Xis the uid of the owner and
X.ul
Xst_gid
Xis the group id of the fileowner.
X.ul
Xst_rdev
Xisn't used but exist for compatibility with UNIX(tm). In
X.ul
Xst_size
Xone can find the size of the file, the modification time is stored in
X.ul
Xst_mtime
Xand is in OS9 the same as
X.ul
Xst_atime
Xthe access time.
X.ul
Xst_ctime
Xholds the creation time of the file (Caveats: no hour:minute information)
X
X.endtopic
X.topic RETURN VALUE
XOn error stat() and fstat() are returning -1, else 0.
X.endtopic
X.topic EXAMPLES
X.noform
X# include	<stat.h>
X
Xstruct stat	buf;
Xint		err_code;
X
Xerr_code = stat ("/dd/SYS/password", &buf);
X.noformend
X.endtopic
X.topic SEE ALSO
X.noform
XSetstat(), getstat() and all _ss..() and _gs..() functions
Xin the C Compiler User's Manual
X.noformend
X.endtopic
END_OF_FILE
if test 2301 -ne `wc -c <'MAN/Stat.prf'`; then
    echo shar: \"'MAN/Stat.prf'\" unpacked with wrong size!
fi
# end of 'MAN/Stat.prf'
fi
if test -f 'stat.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'stat.c'\"
else
echo shar: Extracting \"'stat.c'\" \(2588 characters\)
sed "s/^X//" >'stat.c' <<'END_OF_FILE'
X/* ------------------------------------------------------------------- *
X |
X | OS9Lib:  stat(), fstat()
X |
X |
X |     Copyright (c) 1988 by Wolfgang Ocker, Puchheim,
X |                           Ulli Dessauer, Germering and
X |                           Reimer Mellin, Muenchen
X |                           (W-Germany)
X |
X |  This  programm can  be  copied and  distributed freely  for any
X |  non-commercial  purposes.   It can only  be  incorporated  into
X |  commercial software with the written permission of the authors.
X |
X |  If you should modify this program, the authors would appreciate
X |  a notice about the changes. Please send a (context) diff or the
X |  complete source to:
X |
X |  address:     Wolfgang Ocker
X |               Lochhauserstrasse 35a
X |               D-8039 Puchheim
X |               West Germany
X |
X |  e-mail:      weo@altger.UUCP, ud@altger.UUCP, ram@altger.UUCP
X |               pyramid!tmpmbx!recco!weo
X |               pyramid!tmpmbx!nitmar!ud
X |               pyramid!tmpmbx!ramsys!ram
X |
X * ----------------------------------------------------------------- */
X
X#define PATCHLEVEL 1
X
X#include <stdio.h>
X#include <direct.h>
X#include <stat.h>
X#include <modes.h>
X#include <sgstat.h>
X
X/*
X * f s t a t
X */
Xint fstat(fd, buff)
X  int         fd;
X  struct stat *buff;
X{
X  struct fildes ftmp;
X  struct tm     ttmp;
X  struct _sgr   fopt;
X
X  if (_gs_gfd(fd, &ftmp, sizeof(struct fildes)) < 0)
X    return(-1);
X
X  if (_gs_opt(fd, &fopt) < 0)
X    return(-1);
X
X  ttmp.tm_year  = (int) ftmp.fd_date[0];
X  ttmp.tm_mon   = (int) ftmp.fd_date[1] - 1;
X  ttmp.tm_mday  = (int) ftmp.fd_date[2];	
X  ttmp.tm_hour  = (int) ftmp.fd_date[3];
X  ttmp.tm_min   = (int) ftmp.fd_date[4];
X  ttmp.tm_sec   = 0;
X  ttmp.tm_isdst = -1;
X
X  buff->st_atime = buff->st_mtime = mktime(&ttmp);
X
X  ttmp.tm_year  = (int) ftmp.fd_dcr[0];
X  ttmp.tm_mon   = (int) ftmp.fd_dcr[1] - 1;
X  ttmp.tm_mday  = (int) ftmp.fd_dcr[2];	
X  ttmp.tm_hour  = ttmp.tm_min = ttmp.tm_sec = 0;
X  ttmp.tm_isdst = -1;
X  
X  buff->st_ctime = mktime(&ttmp);
X
X  memcpy(&(buff->st_size), ftmp.fd_fsize, sizeof(long));  /* misalignment! */
X  buff->st_uid   = ftmp.fd_own[1];
X  buff->st_gid   = ftmp.fd_own[0];
X  buff->st_mode  = ftmp.fd_att;
X  buff->st_nlink = ftmp.fd_link;
X
X  buff->st_ino   = fopt._sgr_fdpsn;
X  buff->st_dev   = fopt._sgr_dvt;
X
X  return(0);
X}
X
X/*
X * s t a t
X */	
Xint stat(filename, buff)
X  char        *filename;
X  struct stat *buff;
X{
X  register int i, ret;
X
X  if ((i = open(filename, 0)) < 0)
X    if ((i = open(filename, S_IFDIR)) < 0)
X      return(-1);
X
X  ret = fstat(i, buff);
X  close(i);
X
X  return(ret);
X}
END_OF_FILE
if test 2588 -ne `wc -c <'stat.c'`; then
    echo shar: \"'stat.c'\" unpacked with wrong size!
fi
# end of 'stat.c'
fi
if test -f 'MAN/Strings.prf' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MAN/Strings.prf'\"
else
echo shar: Extracting \"'MAN/Strings.prf'\" \(2659 characters\)
sed "s/^X//" >'MAN/Strings.prf' <<'END_OF_FILE'
X.fill
X.justify
X.offset 5
X.rightmargin 55
X.pagesize 48
X.m1 2
X.m2 1
X.m3 2
X.m4 3
X.ec \
X.header /Atime/OS9Lib/Strings
X.footer /Page #//Printed (%)/
X.in +5
X.define topic
X.bold
X.in -5
X$1 $2 $3 $4 $5
X.in +5
X.en
X.define endtopic
X
X
X.en
X.define noform
X.nojustify
X.nofill
X.en
X.define noformend
X.justify
X.fill
X.en
X.! Manual created with MWB
X.! END-OF-MACRO
X.topic NAME
X.nofill
Xstrpbrk - find one of a set of characters a string
Xstrspn - look for a span of a set of characters in a string
Xstrstr - find a substring in a string
Xstrtok - scan for a token in a string
X.fill
X.endtopic
X.topic SYNOPSIS
X.noform
X#include <string.h>
X
Xchar *strpbrk (string, char_set)
Xchar *string;
Xchar *char_set;
X
Xint strspn (string, char_set)
Xchar *string;
Xchar *char_set;
X
Xint strcspn(string, char_set)
Xchar *string;
Xchar *char_set;
X
Xchar *strstr (string, substr)
Xchar *string;
Xchar *substr;
X
Xchar *strtok (string, char_set)
Xchar *string;
Xchar *char_set;
X
Xchar *strtok (NULL, char_set)
Xchar *char_set;
X.noformend
X.endtopic
X.topic DESCRIPTION
X.bold
XStrpbrk
Xscans
X.ul
Xstring
Xfor the first occurrence of a character from the string 
X.ul
Xchar_set.
X
X.bold
XStrspn
Xand
X.bold
XStrnspn
Xare used to determine the length of a span of
Xcharacters at the beginning of
X.ul
Xstring.
X.bold
XStrspn
Xfinds a span
Xcontaining only characters specified in
X.ul
Xchar_set.
X.bold
XStrcspn
Xfinds the span containing no characters from
X.ul
Xchar_set.
X
X.bold
XStrstr
Xfinds the first occurrence of a substring, pointed to by
X.ul
Xsubstr,
Xwithin a string pointed to by
X.ul
Xstring.
X
XIf the substring is found then a pointer to it within
X.ul
Xstring
Xis returned, otherwise NULL is returned.
X
X.bold
XStrtok
Xis used to divide up a string into tokens.
X.bold
XStrtok
Xis called with
X.ul
Xstring
Xpointing to the string to be scanned and
X.ul
Xchar_set
Xpointing to a string which
Xconsists of the set of separator characters. Tokens are
Xsubstrings bordered by separator characters. A pointer to
Xthe first token encountered is returned.
X
XSubsequent scans of the same
X.ul
Xstring
Xuse the second call format.
X
X.endtopic
X.topic RETURN VALUES
XIf a character from the
X.ul
Xchar_set
Xwas found then a pointer to it within
X.ul
Xstring
Xis returned by
X.bold
XStrpbrk,
Xotherwise NULL is returned.
X
X.bold
XStrspn
Xand
X.bold
XStrnspn
Xreturn the length of the span.
X
XIf the substring is found then a pointer to it within
X.ul
Xstring
Xis returned by
X.bold
XStrstr,
Xotherwise NULL is returned.
X
X.bold
XStrtok
Xreturns a pointer to the next token. Each token is terminated by
Xa '\0'. If there are no tokens remaining in the string
Xthen NULL is returned.
X
X
X
X
X.noformend
X.endtopic
X.topic SEE ALSO
X.noform
Xthe string functions
Xin the C-Compiler User's Manual
X.noformend
X.endtopic
X
END_OF_FILE
if test 2659 -ne `wc -c <'MAN/Strings.prf'`; then
    echo shar: \"'MAN/Strings.prf'\" unpacked with wrong size!
fi
# end of 'MAN/Strings.prf'
fi
echo shar: End of archive 2 \(of 5\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 5 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 5 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
-- 
  |  Wolfgang Ocker          |  ocker@lan.informatik.tu-muenchen.dbp.de  |
  |  Lochhauserstr. 35a      |      pyramid!tmpmbx!recco!weo (home)      |
  |  D-8039 Puchheim         |     Technische Universitaet Muenchen      |
  |  Voice: +49 89 80 77 02  |          Huh, What? Where am I?           |