ast@cs.vu.nl (Andy Tanenbaum) (10/06/88)
: This is a shar archive. Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
: --------------------------- cut here --------------------------
PATH=/bin:/usr/bin:/usr/ucb
echo Extracting 'amoeba:makefi'
sed 's/^X//' > 'amoeba:makefi' << '+ END-OF-FILE ''amoeba:makefi'
Xall:
X cd kernel; make
X cd fs; make
X cd mm; make
X cd ../tools; make net
X
+ END-OF-FILE amoeba:makefi
chmod 'u=rw,g=r,o=r' 'amoeba:makefi'
set `wc -c 'amoeba:makefi'`
count=$1
case $count in
77) :;;
*) echo 'Bad character count in ''amoeba:makefi' >&2
echo 'Count should be 77' >&2
esac
echo Extracting 'getc.c'
sed 's/^X//' > 'getc.c' << '+ END-OF-FILE ''getc.c'
X#include <stdio.h>
X
X
X
Xgetc(iop)
XFILE *iop;
X{
X int ch;
X
X if ( testflag(iop, (_EOF | _ERR )))
X return (EOF);
X
X if ( !testflag(iop, READMODE) )
X return (EOF);
X
X if (iop->_count <= 0){
X
X if ( testflag(iop, UNBUFF) )
X iop->_count = read(iop->_fd,&ch,1);
X else
X iop->_count = read(iop->_fd,iop->_buf,BUFSIZ);
X
X if (iop->_count <= 0){
X if (iop->_count == 0)
X iop->_flags |= _EOF;
X else
X iop->_flags |= _ERR;
X
X return (EOF);
X }
X else
X iop->_ptr = iop->_buf;
X }
X
X iop->_count--; /* account one char */
X if (testflag(iop,UNBUFF))
X return (ch & CMASK);
X else
X return (*iop->_ptr++ & CMASK);
X}
X
+ END-OF-FILE getc.c
chmod 'u=rw,g=r,o=r' 'getc.c'
set `wc -c 'getc.c'`
count=$1
case $count in
616) :;;
*) echo 'Bad character count in ''getc.c' >&2
echo 'Count should be 616' >&2
esac
echo Extracting 'install'
sed 's/^X//' > 'install' << '+ END-OF-FILE ''install'
X# This shell script copies the few files required for amoeba transactions
X# to the appropriate directories.
X#
Xcp h/amoeba.h /usr/include
Xcp h/host_os.h /usr/include
Xcp h/amparam.h /usr/include
+ END-OF-FILE install
chmod 'u=rwx,g=rx,o=rx' 'install'
set `wc -c 'install'`
count=$1
case $count in
193) :;;
*) echo 'Bad character count in ''install' >&2
echo 'Count should be 193' >&2
esac
echo Extracting 'mined:makefile'
sed 's/^X//' > 'mined:makefile' << '+ END-OF-FILE ''mined:makefile'
XCFLAGS=-F -Di8088
Xl=/lib
X
Xmined: mined1.s mined2.s mined.h
X @cc -i -o mined mined1.s mined2.s
X
+ END-OF-FILE mined:makefile
chmod 'u=rw,g=r,o=r' 'mined:makefile'
set `wc -c 'mined:makefile'`
count=$1
case $count in
96) :;;
*) echo 'Bad character count in ''mined:makefile' >&2
echo 'Count should be 96' >&2
esac
echo Extracting 'putc.c'
sed 's/^X//' > 'putc.c' << '+ END-OF-FILE ''putc.c'
X#include <stdio.h>
X
Xextern int (*__cleanup)();
Xextern int _cleanup();
X
Xputc(ch, iop)
Xchar ch;
XFILE *iop;
X{
X int n,
X didwrite = 0;
X
X if (testflag(iop, (_ERR | _EOF)))
X return (EOF);
X
X if ( !testflag(iop,WRITEMODE))
X return(EOF);
X
X if ( testflag(iop,UNBUFF)){
X n = write(iop->_fd,&ch,1);
X iop->_count = 1;
X didwrite++;
X }
X else{
X __cleanup = _cleanup;
X *iop->_ptr++ = ch;
X if ((++iop->_count) >= BUFSIZ && !testflag(iop,STRINGS) ){
X n = write(iop->_fd,iop->_buf,iop->_count);
X iop->_ptr = iop->_buf;
X didwrite++;
X }
X }
X
X if (didwrite){
X if (n<=0 || iop->_count != n){
X if (n < 0)
X iop->_flags |= _ERR;
X else
X iop->_flags |= _EOF;
X return (EOF);
X }
X iop->_count=0;
X }
X return(ch & CMASK);
X}
X
+ END-OF-FILE putc.c
chmod 'u=rw,g=r,o=r' 'putc.c'
set `wc -c 'putc.c'`
count=$1
case $count in
720) :;;
*) echo 'Bad character count in ''putc.c' >&2
echo 'Count should be 720' >&2
esac
echo Extracting 'termcap.c'
sed 's/^X//' > 'termcap.c' << '+ END-OF-FILE ''termcap.c'
X/* termcap - print termcap settings Author: Terrence Holm */
X
X#include <stdio.h>
X
X#define TC_BUFFER 1024 /* Size of termcap(3) buffer */
X
Xchar *getenv();
Xchar *tgetstr();
X
X/****************************************************************/
X/* */
X/* termcap [ type ] */
X/* */
X/* Prints out all of the termcap capabilities as described */
X/* in termcap(4). If "type" is not supplied then $TERM is */
X/* used. */
X/* */
X/****************************************************************/
X
X
Xmain( argc, argv )
X int argc;
X char *argv[];
X
X {
X char *term;
X char buffer[ TC_BUFFER ];
X
X
X /* Check for an argument */
X
X if ( argc > 2 )
X Error( "Usage: %s [ type ]\n", argv[0] );
X
X if ( argc == 2 )
X term = argv[1];
X else
X term = getenv( "TERM" );
X
X if ( term == NULL )
X Error( "termcap: $TERM is not defined\n", "" );
X
X
X /* Read in the termcap entry */
X
X if ( tgetent( buffer, term ) != 1 )
X Error( "termcap: No termcap entry for %s\n", term );
X
X
X /* Print out the entry's contents */
X
X printf( "TERM = %s\n\n", term );
X
X if ( tgetflag( "am" ) == 1 )
X printf( "End of line wraps to next line (am)\n" );
X
X if ( tgetflag( "bs" ) == 1 )
X printf( "Ctrl/H performs a backspace (bs)\n" );
X
X printf( "Number of columns (co) = %d\n", tgetnum( "co" ) );
X printf( "Number of lines (li) = %d\n", tgetnum( "li" ) );
X
X Print( "Clear to end of line", "ce" );
X Print( "Clear to end of screen", "cd" );
X Print( "Clear the whole screen", "cl" );
X
X Print( "Start \"stand out\" mode", "so" );
X Print( "End \"stand out\" mode", "se" );
X Print( "Start underscore mode", "us" );
X Print( "End underscore mode", "ue" );
X Print( "Start blinking mode", "mb" );
X Print( "Start bold mode", "md" );
X Print( "Start reverse mode", "mr" );
X Print( "Return to normal mode", "me" );
X
X Print( "Scroll backwards", "sr" );
X Print( "Cursor motion", "cm" );
X
X Print( "Up one line", "up" );
X Print( "Down one line", "do" );
X Print( "Left one space", "le" );
X Print( "Right one space", "nd" );
X Print( "Move to top left corner", "ho" );
X
X Print( "Generated by \"UP\"", "ku" );
X Print( "Generated by \"DOWN\"", "kd" );
X Print( "Generated by \"LEFT\"", "kl" );
X Print( "Generated by \"RIGHT\"", "kr" );
X Print( "Generated by \"HOME\"", "kh" );
X Print( "Generated by \"END\"", "k0" );
X Print( "Generated by \"PGUP\"", "k1" );
X Print( "Generated by \"PGDN\"", "k2" );
X Print( "Generated by numeric \"+\"", "k3" );
X Print( "Generated by numeric \"-\"", "k4" );
X Print( "Generated by numeric \"5\"", "k5" );
X
X exit( 0 );
X }
X
X
X
X
X
X
X/****************************************************************/
X/* */
X/* Print( comment, name ) */
X/* */
X/* If a termcap entry exists for "name", then */
X/* print out "comment" and the entry. Control */
X/* characters are printed as ^x. */
X/* */
X/****************************************************************/
X
X
XPrint( comment, name )
X char *comment;
X char *name;
X
X {
X char entry[ 50 ];
X char *p = entry;
X
X if ( tgetstr( name, &p ) == NULL )
X return;
X
X printf( "%-32s (%s) = ", comment, name );
X
X for ( p = entry; *p != '\0'; ++p )
X if ( *p < ' ' )
X printf( "^%c", *p + '@' );
X else if ( *p == '\177' )
X printf( "^?" );
X else
X putchar( *p );
X
X putchar( '\n' );
X }
X
X
X
X
X
X
X/****************************************************************/
X/* */
X/* Error( message, arg ) */
X/* */
X/* Printf the "message" and abort. */
X/* */
X/****************************************************************/
X
X
XError( message, arg )
X char *message;
X char *arg;
X
X {
X fprintf( stderr, message, arg );
X exit( 1 );
X }
+ END-OF-FILE termcap.c
chmod 'u=rw,g=r,o=r' 'termcap.c'
set `wc -c 'termcap.c'`
count=$1
case $count in
3832) :;;
*) echo 'Bad character count in ''termcap.c' >&2
echo 'Count should be 3832' >&2
esac
echo Extracting 'who.c'
sed 's/^X//' > 'who.c' << '+ END-OF-FILE ''who.c'
X/* who - tell who is currently logged in Author: Andy Tanenbaum */
X
X/* Who reads the file /usr/adm/wtmp and prints a list of who is curently
X * logged in. The format of this file is a sequence of 20-character records,
X * as defined by struct wtmprec below. There is an implicit assumption that
X * all terminal names are of the form ttyn, where n is a single decimal digit.
X */
X
X#define SLOTS 10
X#define WTMPSIZE 8
X#define DIGIT 3
X
Xchar *wtmpfile = "/usr/adm/wtmp";
X
Xstruct wtmprec {
X char wt_line[WTMPSIZE]; /* tty name */
X char wt_name[WTMPSIZE]; /* user id */
X long wt_time; /* time */
X} wtmp;
X
Xstruct wtmprec user[SLOTS];
Xextern char *ctime();
X
Xmain()
X{
X int fd;
X
X fd = open(wtmpfile, 0);
X if (fd < 0) {
X printf("The file %s cannot be opened.\n", wtmpfile);
X printf("To enable login accounting (required by who),");
X printf("create an empty file with this name.\n");
X exit(1);
X }
X
X readwtmp(fd);
X printwtmp();
X}
X
X
Xreadwtmp(fd)
Xint fd;
X{
X/* Read the /usr/adm/wtmp file and build up a log of current users. */
X
X int i, ttynr;
X
X while (read(fd, &wtmp, sizeof(wtmp)) == sizeof(wtmp)) {
X if (strcmp(wtmp.wt_line, "~") == 0) {
X /* This line means that the system was rebooted. */
X for (i = 0; i < SLOTS; i++) user[i].wt_line[0] = 0;
X continue;
X }
X ttynr = wtmp.wt_line[DIGIT] - '0';
X if (ttynr < 0 || ttynr >= SLOTS) continue;
X if (wtmp.wt_name[0] == 0) {
X user[ttynr].wt_line[0] = 0 ;
X continue;
X }
X user[ttynr] = wtmp;
X }
X}
X
Xprintwtmp()
X{
X struct wtmprec *w;
X char *p;
X
X for (w = &user[0]; w < &user[SLOTS]; w++) {
X if (w->wt_line[0] == 0) continue;
X printf("%s %s ", w->wt_name, w->wt_line);
X p = ctime(&w->wt_time);
X *(p+16) = 0;
X printf("%s\n", p);
X }
X}
+ END-OF-FILE who.c
chmod 'u=rw,g=r,o=r' 'who.c'
set `wc -c 'who.c'`
count=$1
case $count in
1686) :;;
*) echo 'Bad character count in ''who.c' >&2
echo 'Count should be 1686' >&2
esac
echo Extracting 'whoami.c'
sed 's/^X//' > 'whoami.c' << '+ END-OF-FILE ''whoami.c'
X/* whoami - print the current user name Author: Terrence W. Holm */
X
X#include <stdio.h>
X#include <pwd.h>
X
Xstruct passwd *getpwuid();
X
Xmain()
X{
X struct passwd *pw_entry;
X
X pw_entry = getpwuid(geteuid());
X if (pw_entry == NULL) exit(1);
X puts(pw_entry->pw_name);
X exit(0);
X}
+ END-OF-FILE whoami.c
chmod 'u=rw,g=r,o=r' 'whoami.c'
set `wc -c 'whoami.c'`
count=$1
case $count in
279) :;;
*) echo 'Bad character count in ''whoami.c' >&2
echo 'Count should be 279' >&2
esac
exit 0