ast@cs.vu.nl (Andy Tanenbaum) (09/28/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 'LISTING' sed 's/^X//' > 'LISTING' << '+ END-OF-FILE ''LISTING' Xtotal 417 X-rw-r--r-- 1 ast 6207 Sep 26 22:28 animals.c.new X-rw-r--r-- 1 ast 6631 Sep 26 22:28 ast.c.cdif X-rw-r--r-- 1 ast 9395 Sep 26 22:28 at.c.cdif X-rw-r--r-- 1 ast 6370 Sep 26 22:28 banner.c.new X-rw-r--r-- 1 ast 7822 Sep 26 22:29 cc.c.cdif X-rw-r--r-- 1 ast 1360 Sep 26 22:29 cdiff.c.cdif X-rw-r--r-- 1 ast 270 Sep 26 22:29 chgrp.c.cdif X-rw-r--r-- 1 ast 8525 Sep 26 22:29 chmod.c.cdif X-rw-r--r-- 1 ast 385 Sep 26 22:29 chown.c.cdif X-rw-r--r-- 1 ast 1140 Sep 26 22:29 clr.c.cdif X-rw-r--r-- 1 ast 241152 Sep 26 22:29 commands.a.Z.new X-rw-r--r-- 1 ast 1737 Sep 26 22:29 cp.c.cdif X-rw-r--r-- 1 ast 4265 Sep 26 22:29 cpdir.c.cdif X-rw-r--r-- 1 ast 5528 Sep 26 22:29 date.c.cdif X-rw-r--r-- 1 ast 487 Sep 26 22:30 df.c.cdif X-rw-r--r-- 1 ast 956 Sep 26 22:30 diskcheck.c.cdif X-rw-r--r-- 1 ast 23988 Sep 26 22:30 dosread.c.cdif X-rw-r--r-- 1 ast 282 Sep 26 22:30 factor.c.cdif X-rw-r--r-- 1 ast 457 Sep 26 22:30 fgrep.c.cdif X-rw-r--r-- 1 ast 1189 Sep 26 22:30 file.c.cdif X-rw-r--r-- 1 ast 255 Sep 26 22:30 getlf.c.cdif X-rw-r--r-- 1 ast 4249 Sep 26 22:30 help.c.new X-rw-r--r-- 1 ast 267 Sep 26 22:30 libupack.c.cdif X-rw-r--r-- 1 ast 6360 Sep 26 22:30 login.c.cdif X-rw-r--r-- 1 ast 5992 Sep 26 22:31 ls.c.cdif X-rw-r--r-- 1 ast 5467 Sep 26 22:31 more.c.cdif X-rw-r--r-- 1 ast 602 Sep 26 22:31 mount.c.cdif X-rw-r--r-- 1 ast 4523 Sep 26 22:31 mv.c.cdif X-rw-r--r-- 1 ast 2777 Sep 26 22:31 nm.c.cdif X-rw-r--r-- 1 ast 274 Sep 26 22:31 paste.c.cdif X-rw-r--r-- 1 ast 6596 Sep 26 22:31 pr.c.cdif X-rw-r--r-- 1 ast 260 Sep 26 22:31 readall.c.cdif X-rw-r--r-- 1 ast 4113 Sep 26 22:31 readclock.c.new X-rw-r--r-- 1 ast 561 Sep 26 22:31 readfs.c.cdif X-rw-r--r-- 1 ast 337 Sep 26 22:32 sed.c.cdif X-rw-r--r-- 1 ast 1129 Sep 26 22:32 strip.c.cdif X-rw-r--r-- 1 ast 778 Sep 26 22:32 stty.c.cdif X-rw-r--r-- 1 ast 448 Sep 26 22:32 su.c.cdif X-rw-r--r-- 1 ast 561 Sep 26 22:32 tar.c.cdif X-rw-r--r-- 1 ast 606 Sep 26 22:32 term.c.cdif X-rw-r--r-- 1 ast 2431 Sep 26 22:32 tset.c.new X-rw-r--r-- 1 ast 435 Sep 26 22:32 tty.c.cdif X-rw-r--r-- 1 ast 361 Sep 26 22:32 vol.c.cdif X-rw-r--r-- 1 ast 4209 Sep 26 22:32 x.new X-rw-r--r-- 1 ast 4209 Sep 26 22:32 y.new + END-OF-FILE LISTING chmod 'u=rw,g=r,o=r' 'LISTING' set `wc -c 'LISTING'` count=$1 case $count in 2579) :;; *) echo 'Bad character count in ''LISTING' >&2 echo 'Count should be 2579' >&2 esac echo Extracting 'animals.c.new' sed 's/^X//' > 'animals.c.new' << '+ END-OF-FILE ''animals.c.new' X/* animals - guessing game Authors: Terrence W. Holm & Edwin L. Froese */ X X#include <stdio.h> X#include <string.h> X#include <signal.h> X#include <sgtty.h> X#include <ctype.h> X#include <unistd.h> X X#define ANIMALS "/usr/lib/animals" X#define DEFAULT_ANIMAL "beaver" X#define MAX_NODES 999 /* Enough for 500 animals */ X#define MAX_LINE 90 X Xint Abort(); Xchar *Get_Animal(); Xchar *Get_Question(); Xchar *A_or_An(); Xchar *Alloc(); X Xstruct node X { X int question; X char *text; X int yes; X int no; X } animals[ MAX_NODES ]; X Xint count = 0; Xstruct sgttyb old_tty_mode; X X Xmain( argc, argv ) X int argc; X char *argv[]; X X { X char *animal_file = ANIMALS; X X if ( argc > 2 ) X { X fprintf( stderr, "Usage: %s [ data_base ]\n", argv[0] ); X exit( 1 ); X } X X if ( argc == 2 ) X animal_file = argv[1]; X X ioctl( 0, TIOCGETP, &old_tty_mode ); X X signal( SIGINT, Abort ); X signal( SIGQUIT, Abort ); X X if ( access( animal_file, R_OK ) == 0 ) X Read_Animals( animal_file ); X else X { X animals[0].question = 0; X animals[0].text = DEFAULT_ANIMAL; X count = 1; X } X X while ( Ask( "\nAre you thinking of an animal?" ) ) X { X int i = 0; X X while ( 1 ) X { X if ( animals[i].question ) X { X if ( Ask( animals[i].text ) ) X i = animals[i].yes; X else X i = animals[i].no; X } X else X { X printf( "Were you thinking of %s %s", X A_or_An( animals[i].text ), animals[i].text ); X X if ( Ask( "?" ) ) X printf( "I knew it!\n" ); X X else X { X /* Insert a new question and animal name */ X X if ( count + 2 > MAX_NODES ) X Error( "Too many animal names" ); X X animals[count].question = 0; X animals[count].text = animals[i].text; X ++count; X X animals[count].question = 0; X printf( "What animal were you thinking of? " ); X animals[count].text = Get_Animal(); X ++count; X X animals[i].question = 1; X printf( "What question would distinguish %s %s from\n%s %s? ", X A_or_An( animals[count-2].text ), animals[count-2].text, X A_or_An( animals[count-1].text ), animals[count-1].text ); X X animals[i].text = Get_Question(); X X printf( "For %s %s, the answer would be", X A_or_An( animals[count-1].text ), animals[count-1].text ); X X if ( Ask( "?" ) ) X { X animals[i].yes = count - 1; X animals[i].no = count - 2; X } X else X { X animals[i].yes = count - 2; X animals[i].no = count - 1; X } X } X X break; X } X } /* End while ( 1 ) */ X X } X X X ioctl( 0, TIOCSETP, &old_tty_mode ); X X printf( "\nThank you for playing \"animals\".\n" ); X printf( "The animal data base is now being updated.\n" ); X X Write_Animals( animal_file ); X X sleep( 1 ); X printf( "\nBye.\n" ); X X exit( 0 ); X } X X X/* X * Reading and writing the animal data base X */ X X XRead_Animals( animal_file ) X char *animal_file; X X { X FILE *f; X char buffer[ MAX_LINE ]; X X if ( (f = fopen( animal_file, "r" )) == NULL ) X Error( "Can not open animal data base" ); X X while ( fgets( buffer, MAX_LINE, f ) != NULL ) X { X int string_length; X char *string; X X buffer[ strlen(buffer) - 1 ] = '\0'; X X swab( buffer, buffer, strlen(buffer) ); X X if ( buffer[ 0 ] == 'q' ) X { X char *end = strchr( buffer, '?' ); X string_length = end - buffer; X animals[ count ].question = 1; X sscanf( end + 1, "%d:%d", &animals[ count ].yes, &animals[ count ].no ); X } X else X { X animals[ count ].question = 0; X string_length = strlen( buffer ) - 1; X } X X string = Alloc( string_length + 1 ); X X string[ 0 ] = '\0'; X strncat( string, buffer+1, string_length ); X X animals[ count ].text = string; X X count++; X } X X fclose( f ); X } X X XWrite_Animals( animal_file ) X char *animal_file; X X { X FILE *f; X int i; X char buffer[ MAX_LINE ]; X X if ( (f = fopen( animal_file, "w" )) == NULL ) X Error( "Can not write animal data base" ); X X for ( i = 0; i < count; ++i ) X { X if ( animals[i].question ) X sprintf( buffer, "q%s%d:%d", animals[i].text, X animals[i].yes, animals[i].no ); X else X sprintf( buffer, "a%s", animals[i].text ); X X /* Make the data base a bit difficult to read */ X X swab( buffer, buffer, strlen(buffer) ); X X fprintf( f, "%s\n", buffer ); X } X X fclose( f ); X X chmod( animal_file, 0666 ); X } X X X/* X * Reading data from the user X */ X X Xint Ask( question ) X char *question; X X { X struct sgttyb new_tty_mode; X int response; X X new_tty_mode = old_tty_mode; X new_tty_mode.sg_flags |= CBREAK; X ioctl( 0, TIOCSETP, &new_tty_mode ); X X printf( "%s ", question ); X X while ( (response = getchar()) != 'y' && response != 'n' ) X printf( "\n%s [yn]?", question ); X X putchar( '\n' ); X X ioctl( 0, TIOCSETP, &old_tty_mode ); X X if ( response == 'y' ) X return( 1 ); X else X return( 0 ); X } X X Xchar *Get_Animal() X { X char s[ MAX_LINE ]; X char *text; X int text_length; X X fgets( s, MAX_LINE, stdin ); X X text_length = strlen(s); X X text = Alloc( text_length ); X X text[ 0 ] = '\0'; X strncat( text, s, text_length - 1 ); X X return( text ); X } X X Xchar *Get_Question() X { X char s[ MAX_LINE ]; X char *end; X char *text; X X fgets( s, MAX_LINE, stdin ); X X /* Capitalize the first letter */ X X if ( islower( s[0] ) ) X s[0] = toupper( s[0] ); X X /* Make sure the question ends with a '?' */ X X if ( (end = strchr( s, '?' )) == NULL ) X s[ strlen(s) - 1 ] = '?'; X else X end[1] = '\0'; X X text = Alloc( strlen(s) + 1 ); X X strcpy( text, s ); X X return( text ); X } X X X/* X * Utility routines X */ X X Xchar *A_or_An( word ) X char *word; X X { X if ( strchr( "aeiouAEIOU", word[0] ) == NULL ) X return( "a" ); X else X return( "an" ); X } X X Xchar *Alloc( size ) X int size; X X { X char *malloc(); X char *memory; X X if ( (memory = malloc( size )) == NULL ) X Error( "No room in memory for all the animals" ); X X return( memory ); X } X X XAbort() X { X ioctl( 0, TIOCSETP, &old_tty_mode ); X X printf( "\nThank you for playing \"animals\".\n" ); X printf( "Since you aborted, the animal data base will not be updated.\n" ); X X sleep( 1 ); X printf( "\nBye.\n" ); X X exit( 1 ); X } X X XError( message ) X char *message; X X { X ioctl( 0, TIOCSETP, &old_tty_mode ); X X fprintf( stderr, "Error: %s\n", message ); X X exit( 1 ); X } + END-OF-FILE animals.c.new chmod 'u=rw,g=r,o=r' 'animals.c.new' set `wc -c 'animals.c.new'` count=$1 case $count in 6207) :;; *) echo 'Bad character count in ''animals.c.new' >&2 echo 'Count should be 6207' >&2 esac echo Extracting 'ast.c.cdif' sed 's/^X//' > 'ast.c.cdif' << '+ END-OF-FILE ''ast.c.cdif' X*** /local/ast/minix/tape3b/commands/ast.c Wed Jul 13 13:10:40 1988 X--- ast.c Sun Sep 25 15:24:42 1988 X*************** X*** 1,12 **** X! /* ast - add symbol table. Author: Dick van Veen, veench@cs.vu.nl */ X X #include <a.out.h> X #include <stdio.h> X X /* X * Since the a.out file in MINIX does not contain any symbol table, X! * we use the symbol table produced with the -s option of asld, e.g. X! * cc -s file.c >symbol.out X * X * Read symbol table in memory, remove compiler generated labels, X * sort the labels and add it to the a.out file. X--- 1,11 ---- X! /* ast - add symbol table. Author: Dick van Veen */ X X #include <a.out.h> X #include <stdio.h> X X /* X * Since the a.out file in MINIX does not contain any symbol table, X! * we use the symbol table produced with the -s option of asld. X * X * Read symbol table in memory, remove compiler generated labels, X * sort the labels and add it to the a.out file. X*************** X*** 17,28 **** X */ X X /* X! * Usage: ast [flags] [file] [symbolfile] X * X * flags: X * -x do not preserve local symbols X * -X preserve local symbols except for those whose name begin X! * with 'I' or 'L', these are compiler generated. X * X * - when no symbol file is present, symbol.out is assumed. X * - when no file is present, a.out is assumed. X--- 16,27 ---- X */ X X /* X! * ast [flags] [file] [symbolfile] X * X * flags: X * -x do not preserve local symbols X * -X preserve local symbols except for those whose name begin X! * with 'I', these are compiler generated. X * X * - when no symbol file is present, symbol.out is assumed. X * - when no file is present, a.out is assumed. X*************** X*** 65,71 **** X else if (**argv == 'X') X_flag = 1; X else { X fprintf(stderr, "illegal flag: -%c\n", **argv); X! Exit(-1); X } X argv++; X } X--- 64,70 ---- X else if (**argv == 'X') X_flag = 1; X else { X fprintf(stderr, "illegal flag: -%c\n", **argv); X! exit(-1); X } X argv++; X } X*************** X*** 78,110 **** X argv++; X } X if (*argv != NULL) { X! fprintf(stderr, "Usage: ast [-xX] [file] [symbolfile]\n"); X! Exit(-1); X } X if (o_file == NULL) o_file = A_OUT; X o_fd = fopen(o_file, "a"); X if (o_fd == NULL) { X fprintf(stderr, "can't open %s\n", o_file); X! Exit(-1); X } X if (s_file == NULL) s_file = SYMBOL_FILE; X s_fd = fopen(s_file, "r"); X if (s_fd == NULL) { X fprintf(stderr, "can't open %s\n", s_file); X! Exit(-1); X } X setbuf(s_fd, io_buf); X ast(s_fd, o_fd); X! Exit(0); X } X X- Exit(val) X- int val; X- { X- _cleanup(); X- exit(val); X- } X- X ast(s_fd, o_fd) X FILE *s_fd, *o_fd; X { X--- 77,102 ---- X argv++; X } X if (*argv != NULL) { X! fprintf(stderr, "Usage: ast [-{x,X}] [file] [symbolfile]\n"); X! exit(-1); X } X if (o_file == NULL) o_file = A_OUT; X o_fd = fopen(o_file, "a"); X if (o_fd == NULL) { X fprintf(stderr, "can't open %s\n", o_file); X! exit(-1); X } X if (s_file == NULL) s_file = SYMBOL_FILE; X s_fd = fopen(s_file, "r"); X if (s_fd == NULL) { X fprintf(stderr, "can't open %s\n", s_file); X! exit(-1); X } X setbuf(s_fd, io_buf); X ast(s_fd, o_fd); X! exit(0); X } X X ast(s_fd, o_fd) X FILE *s_fd, *o_fd; X { X*************** X*** 126,132 **** X FILE *fd; X char *buffer; X { X! char ch; X char *buf1; X X buf1 = buffer; X--- 118,124 ---- X FILE *fd; X char *buffer; X { X! int ch; X char *buf1; X X buf1 = buffer; X*************** X*** 185,197 **** X X if (buffer[1] != ' ') { X fprintf(stderr, "illegal file format\n"); X! Exit(-1); X } X symbol->n_value = get_value(buffer + 2); X X if (buffer[6] != ' ') { X fprintf(stderr, "illegal file format\n"); X! Exit(-1); X } X get_name(buffer + 7, symbol->n_name); X return(0); /* yeah, found a symbol */ X--- 177,189 ---- X X if (buffer[1] != ' ') { X fprintf(stderr, "illegal file format\n"); X! exit(-1); X } X symbol->n_value = get_value(buffer + 2); X X if (buffer[6] != ' ') { X fprintf(stderr, "illegal file format\n"); X! exit(-1); X } X get_name(buffer + 7, symbol->n_name); X return(0); /* yeah, found a symbol */ X*************** X*** 203,214 **** X { X if (!(symbol->n_sclass & C_EXT)) { /* local symbol */ X if (x_flag) return; X! if (X_flag && (symbol->n_name[0] == 'I' || X! symbol->n_name[0] == 'L')) return; X } X if (fwrite(symbol, sizeof(struct nlist), 1, fd) != 1) { X fprintf(stderr, "can't write %s\n", o_file); X! Exit(-1); X } X nr_symbols++; X } X--- 195,206 ---- X { X if (!(symbol->n_sclass & C_EXT)) { /* local symbol */ X if (x_flag) return; X! if (X_flag && symbol->n_name[0] == 'I') return; X! if (X_flag && symbol->n_name[0] == 'L') return; X } X if (fwrite(symbol, sizeof(struct nlist), 1, fd) != 1) { X fprintf(stderr, "can't write %s\n", o_file); X! exit(-1); X } X nr_symbols++; X } X*************** X*** 238,244 **** X if (ch >= 'a' && ch <= 'f') X return (ch - 'a' + 10); X fprintf(stderr, "illegal file format\n"); X! Exit(-1); X } X X get_name(str1, str2) X--- 230,236 ---- X if (ch >= 'a' && ch <= 'f') X return (ch - 'a' + 10); X fprintf(stderr, "illegal file format\n"); X! exit(-1); X } X X get_name(str1, str2) X*************** X*** 263,277 **** X fd = open(o_file, 0); X if (read(fd, &header, sizeof(struct exec)) != sizeof(struct exec)) { X fprintf(stderr, "%s: no executable file\n", o_file); X! Exit(-1); X } X if (BADMAG(header)) { X fprintf(stderr, "%s: bad header\n", o_file); X! Exit(-1); X } X if (header.a_syms != 0L) { X fprintf(stderr, "%s: symbol table is installed\n", o_file); X! Exit(-1); X } X fseek(o_fd, A_SYMPOS(header), 0); X nr_symbols = 0; X--- 255,269 ---- X fd = open(o_file, 0); X if (read(fd, &header, sizeof(struct exec)) != sizeof(struct exec)) { X fprintf(stderr, "%s: no executable file\n", o_file); X! exit(-1); X } X if (BADMAG(header)) { X fprintf(stderr, "%s: bad header\n", o_file); X! exit(-1); X } X if (header.a_syms != 0L) { X fprintf(stderr, "%s: symbol table is installed\n", o_file); X! exit(-1); X } X fseek(o_fd, A_SYMPOS(header), 0); X nr_symbols = 0; X*************** X*** 281,291 **** X redo_header(fd) X FILE *fd; X { X! header.a_syms = nr_symbols * sizeof(struct nlist); X fseek(fd, 0L, 0); X if (fwrite(&header, sizeof(header), 1, fd) != 1) { X fprintf(stderr, "%s: can't write\n", o_file); X! Exit(-1); X } X } X X--- 273,283 ---- X redo_header(fd) X FILE *fd; X { X! header.a_syms = (long) (nr_symbols * sizeof(struct nlist)); X fseek(fd, 0L, 0); X if (fwrite(&header, sizeof(header), 1, fd) != 1) { X fprintf(stderr, "%s: can't write\n", o_file); X! exit(-1); X } X } X + END-OF-FILE ast.c.cdif chmod 'u=rw,g=r,o=r' 'ast.c.cdif' set `wc -c 'ast.c.cdif'` count=$1 case $count in 6631) :;; *) echo 'Bad character count in ''ast.c.cdif' >&2 echo 'Count should be 6631' >&2 esac echo Extracting 'at.c' sed 's/^X//' > 'at.c' << '+ END-OF-FILE ''at.c' X/* at - run a command at a specified time Author: Jan Looyen */ X X X#define DIR "/usr/spool/at/ X#define STARTDAY 0 /* see ctime(3) */ X#define LEAPDAY STARTDAY+59 X#define MAXDAYNR STARTDAY+365 X#define NODAY -2 X X#include <stdio.h> X#include <sys/types.h> X#include <time.h> X Xmain(argc, argv, envp) Xint argc; Xchar **argv, **envp; X{ X int i, count, ltim, year, getltim(), getlday(), lday = NODAY; X char c, buf[10], job[30], *dp, *sp; X struct tm *p, *localtime(); X long clock; X FILE *fp, *pin, *popen(); X X/*-------------------------------------------------------------------------* X * check arguments & pipe to "pwd" * X *-------------------------------------------------------------------------*/ X if (argc < 2 || argc > 5) { X fprintf(stderr, "Usage: %s time [month day] [file]\n", argv[0]); X exit(1); X } X if ((ltim = getltim(argv[1])) == -1) { X fprintf(stderr, "%s: wrong time specification\n", argv[0]); X exit(1); X } X if ((argc==4 || argc==5) && (lday = getlday(argv[2], argv[3]))==-1) { X fprintf(stderr, "%s: wrong date specification\n", argv[0]); X exit(1); X } X if ((argc==3 || argc==5) && open(argv[argc-1], 0) == -1) { X fprintf(stderr, "%s: cannot find: %s\n", argv[0], argv[argc-1]); X exit(1); X } X if ((pin = popen("pwd", "r")) == NULL) { X fprintf(stderr, "%s: cannot open pipe to cmd 'pwd'\n", argv[0]); X exit(1); X } X/*-------------------------------------------------------------------------* X * determine execution time and create 'at' job file * X *-------------------------------------------------------------------------*/ X time(&clock); X p = localtime(&clock); X year = p->tm_year; X if (lday==NODAY) { /* no [month day] given */ X lday = p->tm_yday; X if (ltim <= (p->tm_hour*100 + p->tm_min)) { X lday++; X if (lday==MAXDAYNR && (year%4) || lday==MAXDAYNR+1) { X lday = STARTDAY; X year++; X } X } X } X else X switch (year%4) { X case 0: if (lday < p->tm_yday || lday == p->tm_yday && X ltim <= (p->tm_hour*100 + p->tm_min) ) { X year++; X if (lday > LEAPDAY) lday-- ; X } X break; X case 1: X case 2: if (lday > LEAPDAY) lday-- ; X if (lday < p->tm_yday || lday == p->tm_yday && X ltim <= (p->tm_hour*100 + p->tm_min) ) X year++; X break; X case 3: if (lday < ((lday > LEAPDAY) ? p->tm_yday+1 : p->tm_yday) || X lday== ((lday > LEAPDAY) ? p->tm_yday+1 : p->tm_yday) && X ltim <= (p->tm_hour*100 + p->tm_min) ) X year++; X else if (lday > LEAPDAY) lday--; X break; X } X sprintf(job, DIR%02d.%03d.%04d.%02d", year%100, lday, ltim, getpid()%100); X if ((fp = fopen(job, "w")) == NULL) { X fprintf(stderr, "%s: cannot create %s\n", argv[0], job); X exit(1); X } X/*-------------------------------------------------------------------------* X * write environment and command(s) to 'at'job file * X *-------------------------------------------------------------------------*/ X while (envp[i] != NULL) { X count = 1; X dp = buf; X sp = envp[i]; X while ((*dp++ = *sp++) != '=') X count++; X *--dp = '\0'; X fprintf(fp, "export %s; %s='%s'\n", buf, buf, &envp[i++][count]); X } X fprintf(fp, "cd "); X while ((c = getc(pin)) != EOF) X putc(c, fp); X fprintf(fp, "umask %o\n", umask()); X if (argc==3 || argc==5) X fprintf(fp, "%s\n", argv[argc-1]); X else /* read from stdinput */ X while ((c = getchar()) != EOF) X putc(c, fp); X X printf("%s: %s created\n", argv[0], job); X exit(0); X} X X/*-------------------------------------------------------------------------* X * getltim() return((time OK) ? daytime : -1) * X *-------------------------------------------------------------------------*/ Xgetltim(t) Xchar *t; X{ X if (t[4] == '\0' && t[3] >= '0' && t[3] <= '9' && X t[2] >= '0' && t[2] <= '5' && t[1] >= '0' && t[1] <= '9' && X (t[0] == '0' || t[0] == '1' || t[1] <= '3' && t[0] == '2') ) X return(atoi(t)); X else X return(-1); X} X X/*-------------------------------------------------------------------------* X * getlday() return ((date OK) ? yearday : -1) * X *-------------------------------------------------------------------------*/ Xgetlday(m, d) Xchar *m, *d; X{ X int i, month, day, im; X static int cumday[] = { 0, 0, 31, 60, 91, 121, 152, X 182, 213, 244, 274, 305, 335 }; X static struct date { X char *mon; X int dcnt; X } *pc, X kal[] = { "Jan", 31, "Feb", 29, "Mar", 31, "Apr", 30, X "May", 31, "Jun", 30, "Jul", 31, "Aug", 31, X "Sep", 30, "Oct", 31, "Nov", 30, "Dec", 31 X }; X X pc = kal; X im = (digitstring(m)) ? atoi(m) : 0; X m[0] &= 0337; X for (i = 1; i < 13 && strcmp(m, pc->mon) && im != i; i++, pc++) X ; X if (i < 13 && (day=(digitstring(d)) ? atoi(d) : 0) && day <= pc->dcnt) { X if (!STARTDAY) day--; X return(day + cumday[i]); X } X else X return(-1); X} X X X Xdigitstring(s) Xchar *s; X{ X while (*s >= '0' && *s <= '9') X s++; X return((*s=='\0') ? 1 : 0); X} X + END-OF-FILE at.c chmod 'u=rw,g=r,o=r' 'at.c' set `wc -c 'at.c'` count=$1 case $count in 4941) :;; *) echo 'Bad character count in ''at.c' >&2 echo 'Count should be 4941' >&2 esac echo Extracting 'banner.c.new' sed 's/^X//' > 'banner.c.new' << '+ END-OF-FILE ''banner.c.new' X/* banner - print a banner Author: Brian Wallis */ X X/***************************************************************** X * X * SYSVbanner.c X * X * This is a PD version of the SYS V banner program (at least I think X * it is compatible to SYS V) which I wrote to use with the clock X * program written by: X ** DCF, Inc. X ** 14623 North 49th Place X ** Scottsdale, AZ 85254 X * and published in the net comp.sources.misc newsgroup in early July X * since the BSD banner program works quite differently. X * X * There is no copyright or responsibility accepted for the use X * of this software. X * X * Brian Wallis, brw@jim.odr.oz, 4 July 1988 X * X *****************************************************************/ X X#include <stdio.h> X Xchar *glyphs[] = { X" @@@ @@@ @@@ @ @ @@@@@ @@@ @ @@ @@@ ", X" @@@ @@@ @@@ @ @ @ @ @@ @ @ @ @ @@@ ", X" @@@ @ @ @@@@@@@@ @ @@@ @ @@ @ ", X" @ @ @ @@@@@ @ @@@ @ ", X" @@@@@@@ @ @ @ @@@@ @ @ ", X" @@@ @ @ @ @ @ @ @ @@ @ ", X" @@@ @ @ @@@@@ @ @@@ @@@@ @ ", X X" @@ @@ @", X" @ @ @ @ @ @ ", X" @ @ @ @ @ @ ", X" @ @ @@@ @@@ @@@@@ @@@ @@@@@ @ ", X" @ @ @ @ @ @@@ @@@ @ ", X" @ @ @ @ @ @ @@@ @ ", X" @@ @@ @ @@@ @ ", X X" @@@ @ @@@@@ @@@@@ @ @@@@@@@ @@@@@ @@@@@@@", X" @ @ @@ @ @@ @@ @ @ @ @@ @ ", X"@ @ @ @ @ @ @@ @ @ @ @ ", X"@ @ @ @ @@@@@ @@@@@ @@@@@@@ @@@@@ @@@@@@ @ ", X"@ @ @ @ @ @ @ @@ @ @ ", X" @ @ @ @ @ @ @ @ @@ @ @ ", X" @@@ @@@@@ @@@@@@@ @@@@@ @ @@@@@ @@@@@ @ ", X X" @@@@@ @@@@@ @ @@@ @ @ @@@@@ ", X"@ @@ @ @ @ @@@ @ @ @ @", X"@ @@ @ @ @ @@@@@ @ @", X" @@@@@ @@@@@@ @@@ @ @ @@ ", X"@ @ @ @ @@@ @ @@@@@ @ @ ", X"@ @@ @ @ @ @ @ @ ", X" @@@@@ @@@@@ @ @ @ @ @ ", X X" @@@@@ @ @@@@@@ @@@@@ @@@@@@ @@@@@@@@@@@@@@ @@@@@ ", X"@ @ @ @ @ @@ @@ @@ @ @ @", X"@ @@@ @ @ @ @ @@ @ @@ @ @ ", X"@ @ @ @@ @@@@@@@ @ @ @@@@@@ @@@@@ @ @@@@", X"@ @@@@ @@@@@@@@ @@ @ @@ @ @ @", X"@ @@ @@ @@ @@ @@ @ @ @", X" @@@@@ @ @@@@@@@ @@@@@ @@@@@@ @@@@@@@@ @@@@@ ", X X"@ @ @*@ @@ @ @ @ @@ @@@@@@@@", X"@ @ @ @@ @ @ @@ @@@@ @@ @", X"@ @ @ @@ @ @ @ @ @ @@ @ @@ @", X"@@@@@@@ @ @@@@ @ @ @ @@ @ @@ @", X"@ @ @ @ @@ @ @ @ @@ @ @@ @", X"@ @ @ @ @@ @ @ @ @@ @@@ @", X"@ @ @@@ @@@@@ @ @ @@@@@@@@ @@ @@@@@@@@", X X"@@@@@@ @@@@@ @@@@@@ @@@@@ @@@@@@@@ @@ @@ @", X"@ @@ @@ @@ @ @ @ @@ @@ @ @", X"@ @@ @@ @@ @ @ @@ @@ @ @", X"@@@@@@ @ @@@@@@@ @@@@@ @ @ @@ @@ @ @", X"@ @ @ @@ @ @ @ @ @ @ @ @ @ @", X"@ @ @ @ @ @ @ @ @ @ @ @ @ @ @", X"@ @@@@ @@ @ @@@@@ @ @@@@@ @ @@ @@ ", X X"@ @@ @@@@@@@@ @@@@@ @ @@@@@ @ ", X" @ @ @ @ @ @ @ @ @ @ ", X" @ @ @ @ @ @ @ @ @ @ ", X" @ @ @ @ @ @ ", X" @ @ @ @ @ @ @ ", X" @ @ @ @ @ @ @ ", X"@ @ @ @@@@@@@ @@@@@ @ @@@@@ @@@@@@@", X X" @@@ ", X" @@@ @@ @@@@@ @@@@ @@@@@ @@@@@@ @@@@@@ @@@@ ", X" @ @ @ @ @ @ @ @ @ @ @ @ @", X" @ @ @ @@@@@ @ @ @ @@@@@ @@@@@ @ ", X" @@@@@@ @ @ @ @ @ @ @ @ @@@", X" @ @ @ @ @ @ @ @ @ @ @ @", X" @ @ @@@@@ @@@@ @@@@@ @@@@@@ @ @@@@ ", X X" ", X" @ @ @ @ @ @ @ @ @ @ @ @@@@ ", X" @ @ @ @ @ @ @ @@ @@ @@ @ @ @", X" @@@@@@ @ @ @@@@ @ @ @@ @ @ @ @ @ @", X" @ @ @ @ @ @ @ @ @ @ @ @ @ @", X" @ @ @ @ @ @ @ @ @ @ @ @@ @ @", X" @ @ @ @@@@ @ @ @@@@@@ @ @ @ @ @@@@ ", X X" ", X" @@@@@ @@@@ @@@@@ @@@@ @@@@@ @ @ @ @ @ @", X" @ @ @ @ @ @ @ @ @ @ @ @ @ @", X" @ @ @ @ @ @ @@@@ @ @ @ @ @ @ @", X" @@@@@ @ @ @ @@@@@ @ @ @ @ @ @ @ @@ @", X" @ @ @ @ @ @ @ @ @ @ @ @ @@ @@", X" @ @@@ @ @ @ @@@@ @ @@@@ @@ @ @", X X" @@@ @ @@@ @@ @ @ @ @", X" @ @ @ @ @@@@@@ @ @ @ @ @ @ @ @ @ ", X" @ @ @ @ @ @ @ @ @@ @ @ @ @", X" @@ @ @ @@ @@ @ @ @ ", X" @@ @ @ @ @ @ @ @ @ @", X" @ @ @ @ @ @ @ @ @ @ ", X" @ @ @ @@@@@@ @@@ @ @@@ @ @ @ @"}; X X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X int a,b,c,len,ind; X char line[80]; X X for(argv++;--argc;argv++){ X len=strlen(*argv); X if(len>10) X len=10; X for(a=0;a<7;a++){ X for(b=0;b<len;b++){ X if((ind=(*argv)[b]-' ')<0) X ind=0; X for(c=0;c<7;c++){ X line[b*8+c] = glyphs[(ind/8*7)+a][(ind%8*7)+c]; X } X line[b*8+7] = ' '; X } X for(b=len*8-1;b>=0;b--){ X if(line[b]!=' ') X break; X line[b]='\0'; X } X printf("%s\n", line); X } X printf("\n"); X } X} + END-OF-FILE banner.c.new chmod 'u=rw,g=r,o=r' 'banner.c.new' set `wc -c 'banner.c.new'` count=$1 case $count in 6370) :;; *) echo 'Bad character count in ''banner.c.new' >&2 echo 'Count should be 6370' >&2 esac echo Extracting 'cc.c.cdif' sed 's/^X//' > 'cc.c.cdif' << '+ END-OF-FILE ''cc.c.cdif' X*** /local/ast/minix/tape3b/commands/cc.c Wed Jul 13 13:10:43 1988 X--- cc.c Sun Sep 25 15:24:45 1988 X*************** X*** 1,23 **** X! /* X! Driver for the CEMCOM compiler. X! Derived from: "cem.c,v 1.5 86/01/20 11:10:29 erikb Exp" X! Author: Erik Baalbergen X X! Log: X! Date written: Dec 4, 1985 X! Adapted for PC/IX on Jan 20, 1986 X! Strongly reduced (May 14, 1986) X! Piping output from cpp into cem (Jul 30, 1986) X! Create temporary files in TMP directory (Aug 6, 1986) X! Pass hint for optimization to cg (Aug 15, 1986) X! Throw away intermediate files on interrupts (Aug 15, 1986) X! Print file name if there are more than one source files (Sep 22, 1986) X! Various minor corrections for MINIX (Mar 18, 1987) X! */ X! X #include <errno.h> X #include <signal.h> X X #define MAXARGC 64 /* maximum number of arguments allowed in a list */ X #define USTR_SIZE 64 /* maximum length of string variable */ X X--- 1,31 ---- X! /* cc - call the C compiler Author: Erik Baalbergen */ X X! #ifndef MEM640K X! #ifndef MEM512K X! #ifndef RAMDISK X! #error !!! AH HA! I HAVE YOUR ATTENTION! X! /* This is not an error. It is a dirty trick to force the user to read this X! * comment. The program cc calls the various passes of the compiler. To call X! * them, it must know where they are. On the 640K PC MINIX, cpp and cem are X! * kept in /lib, on the root device. Thus the symbol PP is defined as X! * /lib/cpp, etc. On the 512K AT, there is no room on the root device, so cpp X! * and cem are kept in /usr/lib, which means that PP must be /usr/lib/cpp, X! * etc. One of the following two definitions must be uncommented, to X! * generate the right paths. For 640K machines (PCs or ATs), MEM640K should X! * be defined. For 512K machines, MEM512K should be defined. On ATs with a X! * large RAM disk in extended memory, put the whole compiler on the RAM disk X! * and define RAMDISK. X! */ X! #endif X! #endif X! #endif X! X! X #include <errno.h> X #include <signal.h> X X+ #define SYMBOL_FILE "symbol.out" /* symbol table for prof */ X+ X #define MAXARGC 64 /* maximum number of arguments allowed in a list */ X #define USTR_SIZE 64 /* maximum length of string variable */ X X*************** X*** 28,48 **** X char *al_argv[MAXARGC]; X }; X X- !!! AH HA! I HAVE YOUR ATTENTION! X- /* This is not an error. It is a dirty trick to force the user to read this X- * comment. The program cc calls the various passes of the compiler. To call X- * them, it must know where they are. On the 640K PC MINIX, cpp and cem are X- * kept in /lib, on the root device. Thus the symbol PP is defined as X- * /lib/cpp, etc. On the 512K AT, there is no room on the root device, so cpp X- * and cem are kept in /usr/lib, which means that PP must be /usr/lib/cpp, X- * etc. One of the following two definitions must be uncommented, to X- * generate the right paths. For 640K machines (PCs or Ats), MEM640K should X- * be defined. For 512K machines, MEM512K should be defined. X- */ X X- /* #define MEM640K */ X- /* #define MEM512K */ X- X #ifdef MEM640K X /* MINIX paths for 640K PC (not 512K AT) */ X char *PP = "/lib/cpp"; X--- 36,42 ---- X*************** X*** 50,55 **** X--- 44,50 ---- X char *OPT = "/usr/lib/opt"; X char *CG = "/usr/lib/cg"; X char *ASLD = "/usr/bin/asld"; X+ char *AST = "/usr/bin/ast"; X char *SHELL = "/bin/sh"; X char *LIBDIR = "/usr/lib"; X #endif X*************** X*** 61,88 **** X char *OPT = "/usr/lib/opt"; X char *CG = "/usr/lib/cg"; X char *ASLD = "/usr/bin/asld"; X char *SHELL = "/bin/sh"; X char *LIBDIR = "/usr/lib"; X #endif X X! struct arglist LD_HEAD = { X! 1, X! { X! "/usr/lib/crtso.s", X! } X! }; X X! struct arglist LD_TAIL = { X! 2, X! { X! "/usr/lib/libc.a", X! "/usr/lib/end.s" X! } X! }; X X X char *o_FILE = "a.out"; /* default name for executable file */ X X #define remove(str) (unlink(str), (str)[0] = '\0') X #define cleanup(str) (str && remove(str)) X #define init(al) (al)->al_argc = 1 X--- 56,95 ---- X char *OPT = "/usr/lib/opt"; X char *CG = "/usr/lib/cg"; X char *ASLD = "/usr/bin/asld"; X+ char *AST = "/usr/bin/ast"; X char *SHELL = "/bin/sh"; X char *LIBDIR = "/usr/lib"; X #endif X X! #ifdef RAMDISK X! /* MINIX paths for RAM disk (mostly PC/ATs with large extended memory */ X! char *PP = "/lib/cpp"; X! char *CEM = "/lib/cem"; X! char *OPT = "/lib/opt"; X! char *CG = "/lib/cg"; X! char *ASLD = "/bin/asld"; X! char *AST = "/bin/ast"; X! char *SHELL = "/bin/sh"; X! char *LIBDIR = "/lib"; X! #endif X X! #ifdef RAMDISK X! struct arglist LD_HEAD = {1, { "/lib/crtso.s" } }; X! struct arglist M_LD_HEAD = {1, { "/lib/mrtso.s" } }; X! struct arglist LD_TAIL = {2, { "/lib/libc.a", "/lib/end.s" } }; X! #else X! struct arglist LD_HEAD = {1, { "/usr/lib/crtso.s" } }; X! struct arglist M_LD_HEAD = {1, { "/usr/lib/mrtso.s" } }; X! struct arglist LD_TAIL = {2, { "/usr/lib/libc.a", "/usr/lib/end.s" } }; X! #endif X X X+ X char *o_FILE = "a.out"; /* default name for executable file */ X X+ #define AST_FLAGS "-X" X+ #define AST_TAIL "symbol.out" X+ X #define remove(str) (unlink(str), (str)[0] = '\0') X #define cleanup(str) (str && remove(str)) X #define init(al) (al)->al_argc = 1 X*************** X*** 112,117 **** X--- 119,126 ---- X int S_flag = 0; X int v_flag = 0; X int F_flag = 0; /* use pipes by default */ X+ int s_flag = 0; X+ int p_flag = 0; /* profil flag */ X X char *mkstr(); X char *alloc(); X*************** X*** 141,146 **** X--- 150,156 ---- X main(argc, argv) X char *argv[]; X { X+ register char *f; X char *str; X char **argvec; X int count; X*************** X*** 199,208 **** X append(&ASLD_FLAGS, str); X /*FALLTHROUGH*/ X case 'R': X- case 'p': X case 'w': X append(&CEM_FLAGS, str); X break; X case 'L': X if (strcmp(&str[1], "LIB") == 0) { X append(&OPT_FLAGS, "-L"); X--- 209,224 ---- X append(&ASLD_FLAGS, str); X /*FALLTHROUGH*/ X case 'R': X case 'w': X append(&CEM_FLAGS, str); X break; X+ case 's': X+ s_flag = 1; X+ break; X+ case 'p': X+ p_flag = 1; X+ s_flag = 1; X+ break; X case 'L': X if (strcmp(&str[1], "LIB") == 0) { X append(&OPT_FLAGS, "-L"); X*************** X*** 221,230 **** X argvec = &(SRCFILES.al_argv[0]); X X while (count-- > 0) { X- register char *f; X basename(file = *argvec++, BASE); X X! if (SRCFILES.al_argc > 1) { X write(1, file, strlen(file)); X write(1, ":\n", 2); X } X--- 237,245 ---- X argvec = &(SRCFILES.al_argv[0]); X X while (count-- > 0) { X basename(file = *argvec++, BASE); X X! if (v_flag && SRCFILES.al_argc > 1) { X write(1, file, strlen(file)); X write(1, ":\n", 2); X } X*************** X*** 333,350 **** X init(call); X append(call, ASLD); X concat(call, &ASLD_FLAGS); X append(call, "-o"); X append(call, o_FILE); X! concat(call, &LD_HEAD); X concat(call, &LDFILES); X concat(call, &LD_TAIL); X! if (runvec(call, (char *)0)) { X register i = GEN_LDFILES.al_argc; X X while (i-- > 0) X remove(GEN_LDFILES.al_argv[i]); X X } X } X return(RET_CODE); X } X--- 348,380 ---- X init(call); X append(call, ASLD); X concat(call, &ASLD_FLAGS); X+ if (s_flag) append(call, "-s"); X append(call, "-o"); X append(call, o_FILE); X! if (p_flag) X! concat(call, &M_LD_HEAD); X! else concat(call, &LD_HEAD); X concat(call, &LDFILES); X concat(call, &LD_TAIL); X! if (s_flag) X! f = SYMBOL_FILE; X! else f = (char *) 0; X! if (runvec(call, f)) { X register i = GEN_LDFILES.al_argc; X X while (i-- > 0) X remove(GEN_LDFILES.al_argv[i]); X X } X+ } X+ /* add symbol table when p_flag is set */ X+ if (s_flag) { X+ init(call); X+ append(call, AST); X+ append(call, AST_FLAGS); X+ append(call, o_FILE); X+ append(call, AST_TAIL); X+ (void) runvec(call, (char *) 0); X } X return(RET_CODE); X } + END-OF-FILE cc.c.cdif chmod 'u=rw,g=r,o=r' 'cc.c.cdif' set `wc -c 'cc.c.cdif'` count=$1 case $count in 7822) :;; *) echo 'Bad character count in ''cc.c.cdif' >&2 echo 'Count should be 7822' >&2 esac echo Extracting 'cdiff.c.cdif' sed 's/^X//' > 'cdiff.c.cdif' << '+ END-OF-FILE ''cdiff.c.cdif' X*** /local/ast/minix/tape3b/commands/cdiff.c Wed Jul 13 13:10:45 1988 X--- cdiff.c Mon Sep 26 21:51:52 1988 X*************** X*** 3,21 **** X /* cdiff - turns a regular diff into a new-style context diff X * X * Usage: cdiff file1 file2 X- * X- * $Log: cdiff.c,v $ X- * Revision 1.1.1.2 87/06/04 11:21:43 lwall X- * Didn't do diffs with less than 3 lines of leading context. X- * X- * Revision 1.1.1.1 87/06/03 11:52:25 lwall X- * Wasn't concatenating overlapping hunks right. X- * X- * Revision 1.1 87/06/01 16:05:57 lwall X- * Initial revision X- * X */ X- static char rcsid[] = "$Header: cdiff.c,v 1.1.1.2 87/06/04 11:21:43 lwall Exp $"; X X #define PATCHLEVEL 2 X X--- 3,9 ---- X*************** X*** 27,32 **** X--- 15,21 ---- X char buff[512]; X X FILE *inputfp, *oldfp, *newfp; X+ char *ctime(); X X int oldmin, oldmax, newmin, newmax; X int oldbeg, oldend, newbeg, newend; X*************** X*** 70,79 **** X for (argc--,argv++; argc; argc--,argv++) { X if (argv[0][0] != '-') X break; X! if (argv[0][1] == 'v') { X! printf("%s\n Patch level: %d\n",rcsid,PATCHLEVEL); X! exit(0); X! } X if (argv[0][1] == 'c') X context = atoi(argv[0]+2); X } X--- 59,65 ---- X for (argc--,argv++; argc; argc--,argv++) { X if (argv[0][0] != '-') X break; X! X if (argv[0][1] == 'c') X context = atoi(argv[0]+2); X } + END-OF-FILE cdiff.c.cdif chmod 'u=rw,g=r,o=r' 'cdiff.c.cdif' set `wc -c 'cdiff.c.cdif'` count=$1 case $count in 1360) :;; *) echo 'Bad character count in ''cdiff.c.cdif' >&2 echo 'Count should be 1360' >&2 esac echo Extracting 'chgrp.c.cdif' sed 's/^X//' > 'chgrp.c.cdif' << '+ END-OF-FILE ''chgrp.c.cdif' X*** /local/ast/minix/tape3b/commands/chgrp.c Wed Jul 13 13:10:45 1988 X--- chgrp.c Sun Sep 25 15:24:46 1988 X*************** X*** 5,12 **** X #include <sys/stat.h> X #include <stdio.h> X X- extern lseek(); X- X main (argc, argv) X int argc; X char *argv[]; X--- 5,10 ---- + END-OF-FILE chgrp.c.cdif chmod 'u=rw,g=r,o=r' 'chgrp.c.cdif' set `wc -c 'chgrp.c.cdif'` count=$1 case $count in 270) :;; *) echo 'Bad character count in ''chgrp.c.cdif' >&2 echo 'Count should be 270' >&2 esac echo Extracting 'chmod.c' sed 's/^X//' > 'chmod.c' << '+ END-OF-FILE ''chmod.c' X/* X * chmod.c Author: James da Silva X * (ihnp4!killer!jaime) X * X * a (hopefully) 7th Edition Unix compatible chmod for Minix. X */ X X#include <sys/types.h> X#include <sys/stat.h> X X#define isop(c) ((c=='+')||(c=='-')||(c=='=')) X#define isperm(c) ((c=='r')||(c=='w')||(c=='x')||(c=='s')||(c=='t')||\ X (c=='u')||(c=='g')||(c=='o')) X X/* the bits associated with user, group, other */ X X#define U_MSK (0700 | S_ISUID) X#define G_MSK (0070 | S_ISGID) X#define O_MSK 0007 X Xtypedef unsigned short bitset; /* type used for modes */ X Xstruct stat st; /* structure returned by stat() */ Xchar *pname, *arg; Xbitset newmode, absolute(), symbolic(); Xint isabsolute; X Xmain(argc, argv) Xint argc; Xchar **argv; X{ X int i; X X pname = *(argv++); X if(argc < 3) usage(); X X arg = *argv; /* save pointer to mode arg */ X X /* check for octal mode */ X X if( isabsolute = ((*arg>='0') && (*arg<='7')) ) X newmode = absolute(); X X /* apply the mode to all files listed */ X X for(i=2; i<argc; i++) X { X argv++; X if(stat(*argv, &st)) /* get current file mode */ X { X printf("%s: cannot find `%s'\n", pname, *argv); X exit(1); X } X X /* calculate new mode for this file */ X X if( !isabsolute ) X newmode = symbolic(st.st_mode); X X if(chmod(*argv, newmode)) /* change the mode */ X { X printf("%s: cannot chmod `%s'\n", pname, *argv); X exit(1); X } X } X} X X X/* X * absolute X * X * Interprets an octal mode. X * The file modes will be set to this value. X */ Xbitset absolute() X{ X bitset m; X char *s; X X m = 0; X s = arg; X X /* convert octal string to integer */ X X while((*s>='0') && (*s<='7')) X m = m * 8 + (*(s++) - '0'); X X /* if something else is there, choke */ X X if(*s) badmode(s); X X return m; X} X X X/* X * symbolic X * X * Processes symbolic mode of the form (in EBNF): X * <symbolic> ::= <pgroup> { ',' <pgroup> }. X * <pgroup> ::= [ <who> ] <op> <permissions> { <op> <permissions> }. X * X * <who> ::= <whoch> { <whoch> }. X * <whoch> ::= 'a' | 'u' | 'g' | 'o'. X * X * <op> ::= '+' | '-' | '='. X * X * <permissions> ::= <permch> { <permch> }. X * <permch> ::= 'r' | 'w' | 'x' | 's' | 't' | 'u' | 'g' | 'o'. X * X * If <who> is omitted, 'a' is assumed, BUT umask()ed bits are uneffected. X * If <op> is '=', all unspecified permissions are turned off for this <who>. X * For permissions 'u', 'g', and 'o', the permissions are taken from the X * specified set. i.e. o=g sets the permissions for other the same as for X * group. X * X * Pain in the duff, isn't it? X */ Xbitset symbolic(mode) Xbitset mode; X{ X int g,o,u, haswho, haspcopy; X bitset u_mask, emask, partial, other, applyop(); X char *s, c, op; X X s = arg; X u_mask = umask(0); /* get the umasked bits */ X X do /* pgroup */ X { X haswho = u = g = o = 0; X X while(!isop(*s)) X { X /* we must have a 'who' then */ X haswho = 1; X switch(*s) X { X case 'a': u=g=o=1; break; X case 'u': u = 1; break; X case 'g': g = 1; break; X case 'o': o = 1; break; X X default: badmode(s); X } X s++; X } X X if(!haswho) X { X u=g=o=1; /* assume all */ X emask = ~u_mask; /* effective umask */ X } X else emask = ~0; X X X /* process each given operator */ X X while(isop(*s)) X { X op = *(s++); X other = partial = haspcopy = 0; X X /* collect the specified permissions */ X X while(isperm(*s)) X { X X /* Berkeley only allows one of 'u' 'g' or 'o' as permissions */ X X if((*s=='u')||(*s=='g')||(*s=='o')) X if( haspcopy ) badmode(s); X else haspcopy = 1; X X switch(*s) X { X case 'r': partial |= 4; break; X case 'w': partial |= 2; break; X case 'x': partial |= 1; break; X X case 'u': partial |= (mode & U_MSK &~S_ISUID) >> 6; X other |= mode & S_ISUID; X break; X case 'g': partial |= (mode & G_MSK &~S_ISGID) >> 3; X other |= mode & S_ISGID; X break; X case 'o': partial |= (mode & O_MSK); X break; X X X case 't': other |= S_ISVTX; break; X X case 's': if(u) other |= S_ISUID; X if(g) other |= S_ISGID; X break; X X default: badmode(s); X } X s++; X } X X /* apply the op using the affected bits and masks */ X X if(u) X mode = applyop(mode,op,(other | (partial << 6)),emask,U_MSK); X if(g) X mode = applyop(mode,op,(other | (partial << 3)),emask,G_MSK); X if(o) X mode = applyop(mode,op,(other | partial),emask,O_MSK); X } X X } while(*(s++) == ','); X X /* not at end - choke */ X X if(*(--s)) badmode(s); X X return mode; X} X X X/* X * applyop X * X * applies the operator to the current mode using the specified bitset X * and mask. 'bits' will contain 1's in every bit affected by the X * operator '+', '-', or '='. In the case of '=', msk is used to X * determine which bits will be forced off. 'emask' is the effective X * umask. X */ Xbitset applyop(mode, op, bits, emask, msk) Xchar op; Xbitset mode, bits, emask, msk; X{ X switch(op) X { X case '+': mode |= bits & emask; /* turn these bits on */ X break; X case '-': mode &= ~(bits & emask); /* turn these off */ X break; X case '=': mode |= bits & emask; /* turn these bits on */ X mode &= ~(~bits & msk & emask); /* others off */ X break; X default: /* should never get here (famous last words) */ X printf("%s: panic: bad op `%c' passed\n", pname, op); X } X return mode; X} X X X/* X * usage X * X * Prints a terse usage message and exits. X */ Xusage() X{ X printf("Usage: %s [absolute-mode | symbolic-mode] files\n", pname); X exit(1); X} X X X/* X * badmode X * X * Called when the parser chokes on the given mode. X * Prints a message showing the offending character and exits. X */ Xbadmode(s) Xchar *s; X{ X int i,sp; X char buffer[80], *bp; X X sp = s - arg + strlen(pname) + 21; X sp = sp > 79 ? 79 : sp; /* check for buffer overflow */ X X for(i=0, bp = buffer; i<sp; i++, bp++) *bp = ' '; X *bp = '\0'; X X printf("%s: badly formed mode `%s'\n", pname, arg); X printf("%s^\n", buffer); X exit(1); X} X + END-OF-FILE chmod.c chmod 'u=rw,g=r,o=r' 'chmod.c' set `wc -c 'chmod.c'` count=$1 case $count in 6964) :;; *) echo 'Bad character count in ''chmod.c' >&2 echo 'Count should be 6964' >&2 esac echo Extracting 'chown.c.cdif' sed 's/^X//' > 'chown.c.cdif' << '+ END-OF-FILE ''chown.c.cdif' X*** /local/ast/minix/tape3b/commands/chown.c Wed Jul 13 13:10:46 1988 X--- chown.c Sun Sep 25 15:24:46 1988 X*************** X*** 1,9 **** X! /* X! * chown username file ... X! * X! * By Patrick van Kleef X! * X! */ X X #include <pwd.h> X #include <sys/types.h> X--- 1,4 ---- X! /* chown - change file ownership Author: Patrick van Kleef */ X X #include <pwd.h> X #include <sys/types.h> + END-OF-FILE chown.c.cdif chmod 'u=rw,g=r,o=r' 'chown.c.cdif' set `wc -c 'chown.c.cdif'` count=$1 case $count in 385) :;; *) echo 'Bad character count in ''chown.c.cdif' >&2 echo 'Count should be 385' >&2 esac echo Extracting 'clr.c.cdif' sed 's/^X//' > 'clr.c.cdif' << '+ END-OF-FILE ''clr.c.cdif' X*** /local/ast/minix/tape3b/commands/clr.c Wed Jul 13 13:10:46 1988 X--- clr.c Sun Sep 25 15:24:47 1988 X*************** X*** 1,9 **** X /* clr - clear the screen Author: Andy Tanenbaum */ X X main() X! { X! /* Clear the screen. */ X X! prints("\033[H\033[J"); X exit(0); X! } X--- 1,46 ---- X /* clr - clear the screen Author: Andy Tanenbaum */ X X+ /* Changed for termcap. 1988-Apr-2 efth */ X+ X+ X+ #include <stdio.h> X+ X+ #define TC_BUFFER 1024 /* Size of termcap(3) buffer */ X+ X+ extern char *getenv(); X+ extern char *tgetstr(); X+ X+ char buffer[ TC_BUFFER ]; X+ X+ X main() X! { X! char *term; X! char clear[ 30 ]; X! char *p = &clear[0]; X X! if ( (term = getenv( "TERM" )) == NULL ) X! Error( "$TERM not defined" ); X! X! if ( tgetent( buffer, term ) != 1 ) X! Error( "No termcap definition for $TERM" ); X! X! if ( (tgetstr( "cl", &p )) == NULL ) X! Error( "No clear (cl) entry for $TERM" ); X! X! /* Clear the screen */ X! X! printf( "%s", clear ); X! X exit(0); X! } X! X! X! X! Error( str ) X! char *str; X! X! { X! fprintf( stderr, "clr: %s\n", str ); X! exit( 1 ); X! } + END-OF-FILE clr.c.cdif chmod 'u=rw,g=r,o=r' 'clr.c.cdif' set `wc -c 'clr.c.cdif'` count=$1 case $count in 1140) :;; *) echo 'Bad character count in ''clr.c.cdif' >&2 echo 'Count should be 1140' >&2 esac echo Extracting 'cp.c.cdif' sed 's/^X//' > 'cp.c.cdif' << '+ END-OF-FILE ''cp.c.cdif' X*** /local/ast/minix/tape3b/commands/cp.c Wed Jul 13 13:10:49 1988 X--- cp.c Sun Sep 25 15:24:49 1988 X*************** X*** 99,105 **** X int fd1, fd2; X char *name; X { X! int n, m; X X do { X n = read(fd1, cpbuf, TRANSFER_UNIT); X--- 99,106 ---- X int fd1, fd2; X char *name; X { X! int n, m, mode; X! struct stat sbuf; X X do { X n = read(fd1, cpbuf, TRANSFER_UNIT); X*************** X*** 107,114 **** X if (n > 0) { X m = write(fd2, cpbuf, n); X if (m != n) { X perror("cp"); X! unlink(name); /* don't leave truncated file around */ X exit(1); X } X if (isfloppy) sync(); /* purge the cache all at once */ X--- 108,118 ---- X if (n > 0) { X m = write(fd2, cpbuf, n); X if (m != n) { X+ /* Write failed. Don't keep truncated regular file. */ X perror("cp"); X! fstat(fd2, &sbuf); /* check for special files */ X! mode = sbuf.st_mode & S_IFMT; X! if (mode == S_IFREG) unlink(name); X exit(1); X } X if (isfloppy) sync(); /* purge the cache all at once */ X*************** X*** 124,132 **** X--- 128,146 ---- X exit(-1); X } X X+ typedef char *cptr; X+ X int equal(s1, s2) X char *s1, *s2; X { X+ struct stat sb1, sb2; X+ X+ /* same file, different name? */ X+ stat(s1, &sb1); X+ stat(s2, &sb2); X+ if (memcmp((cptr)&sb1, (cptr)&sb2, sizeof(struct stat)) == 0) X+ return(1); X+ /* same file, same name? */ X while (1) { X if (*s1 == 0 && *s2 == 0) return(1); X if (*s1 != *s2) return(0); X*************** X*** 154,157 **** X--- 168,185 ---- X std_err(s1); X std_err(s2); X std_err(s3); X+ } X+ X+ X+ int memcmp(b1, b2, n) X+ cptr b1, b2; X+ int n; X+ { X+ while (n--) { X+ if (*b1 != *b2) X+ return ((int) (*b1 - *b2)); X+ ++b1; X+ ++b2; X+ } X+ return (0); X } + END-OF-FILE cp.c.cdif chmod 'u=rw,g=r,o=r' 'cp.c.cdif' set `wc -c 'cp.c.cdif'` count=$1 case $count in 1737) :;; *) echo 'Bad character count in ''cp.c.cdif' >&2 echo 'Count should be 1737' >&2 esac echo Extracting 'cpdir.c.cdif' sed 's/^X//' > 'cpdir.c.cdif' << '+ END-OF-FILE ''cpdir.c.cdif' X*** /local/ast/minix/tape3b/commands/cpdir.c Wed Jul 13 13:10:50 1988 X--- cpdir.c Sun Sep 25 15:24:50 1988 X*************** X*** 3,19 **** X /* Use "cpdir [-v] src dst" to make a copy dst of directory src. X Cpdir should behave like the UNIX shell command X (cd src; tar cf - .) | (mkdir dst; cd dst; tar xf -) X! but the linking structure of the tree is not yet preserved. X! (See the work-yet-to-be-done list below.) X The -m "merge" flag enables you to copy into an existing directory. X The -s "similar" flag preserves the full mode, uid, gid and times. X The -v "verbose" flag enables you to see what's going on when running cpdir. X X Work yet to be done: X! - preserve link structure X - link checks, i.e. am I not overwriting a file/directory by itself? X- - handle character and block special files X- * they're simply not copied X X Please report bugs and suggestions to erikb@cs.vu.nl X */ X--- 3,16 ---- X /* Use "cpdir [-v] src dst" to make a copy dst of directory src. X Cpdir should behave like the UNIX shell command X (cd src; tar cf - .) | (mkdir dst; cd dst; tar xf -) X! X The -m "merge" flag enables you to copy into an existing directory. X The -s "similar" flag preserves the full mode, uid, gid and times. X The -v "verbose" flag enables you to see what's going on when running cpdir. X X Work yet to be done: X! X - link checks, i.e. am I not overwriting a file/directory by itself? X X Please report bugs and suggestions to erikb@cs.vu.nl X */ X*************** X*** 29,39 **** X--- 26,46 ---- X #define PLEN 256 X #define DIRSIZ 16 X X+ #define MAXLINKS 512 X+ X+ struct { X+ unsigned short ino; X+ unsigned short dev; X+ char *path; X+ } links[MAXLINKS]; X+ int nlinks = 0; X+ X char *prog; X int vflag = 0; /* verbose */ X int mflag = 0; /* force */ X int sflag = 0; /* similar */ X char *strcpy(); X+ char *malloc(); X X main(argc, argv) X char *argv[]; X*************** X*** 125,130 **** X--- 132,139 ---- X strcpy(dend, ent + 2); X if (stat(spath, &st) < 0) X fatal("can't get file status of %s", spath); X+ if ((st.st_mode & S_IFMT)!=S_IFDIR && st.st_nlink>1) X+ if (cplink(st,spath,dpath)==1) continue; X switch (st.st_mode & S_IFMT) { X case S_IFDIR: X cpdir(&st, spath, dpath); X*************** X*** 133,139 **** X cp(&st, spath, dpath); X break; X default: X! nonfatal("can't copy special file %s", spath); X } X } X } X--- 142,149 ---- X cp(&st, spath, dpath); X break; X default: X! cpspec(&st, spath, dpath); X! break; X } X } X } X*************** X*** 215,218 **** X--- 225,290 ---- X exit(1); X } X X+ cpspec(sp, s, d) X+ struct stat *sp; X+ char *s, *d; X+ { X+ if (vflag) X+ { X+ printf("copy special file %s to %s.", s, d); X+ printf(" Major/minor = %d/%d.", X+ sp->st_rdev>>8, sp->st_rdev&0177); X+ printf(" Mode = %o.\n", sp->st_mode); X+ } X+ if (mknod(d, sp->st_mode, sp->st_rdev)<0) X+ { X+ perror("mknod"); X+ nonfatal("Cannot create special file %s.\n",d); X+ } X+ if (sflag) X+ similar(sp, d); X+ } X+ X+ cplink(st,spath,dpath) X+ struct stat st; X+ char *spath, *dpath; X+ { X+ /* Handle files that are links. X+ * Returns 0 if file must be copied. X+ * Returns 1 if file has been successfully linked. X+ */ X+ int i; X+ int linkent; X+ X+ linkent = -1; X+ for (i=0; i<nlinks; i++) X+ { X+ if (links[i].dev==st.st_dev X+ && links[i].ino==st.st_ino) X+ linkent=i; X+ } X+ if (linkent>=0) /* It's already in the link table */ X+ { /* we must have copied it earlier. X+ * So just link to the saved dest path. X+ * Don't copy it twice. X+ */ X+ if (vflag) X+ printf("ln %s %s\n", links[linkent].path,dpath); X+ if (link(links[linkent].path,dpath) < 0) X+ fatal("Could not link to %s\n",dpath); X+ return(1); /* Don't try to copy it */ X+ } else { /* Make an entry in the link table */ X+ if (nlinks >= MAXLINKS) X+ fatal("Too many links at %s\n",dpath); X+ links[nlinks].dev = st.st_dev; X+ links[nlinks].ino = st.st_ino; X+ links[nlinks].path = malloc(strlen(dpath)+1); X+ if (links[nlinks].path == NULL) X+ fatal("No more memory at %s\n",dpath); X+ strcpy(links[nlinks].path,dpath); X+ nlinks++; X+ /* Go ahead and copy it the first time */ X+ return(0); X+ } X+ } X + END-OF-FILE cpdir.c.cdif chmod 'u=rw,g=r,o=r' 'cpdir.c.cdif' set `wc -c 'cpdir.c.cdif'` count=$1 case $count in 4265) :;; *) echo 'Bad character count in ''cpdir.c.cdif' >&2 echo 'Count should be 4265' >&2 esac exit 0