/* bug: head -1 not recognised */ #ifdef ournix #include "ournix.h" #endif char sccsID[] = "@(#) head.c V1.0 Copyright Julian H. Stacey 1988\n" ; #include int ARGC ; char **ARGV; main(argc, argv) int argc; char **argv; { FILE *fp, *fopen(); ARGC = argc; ARGV = argv; #ifdef VSL /* { */ #include "../../include/vsl.h" #endif /* } */ if (argc == 1) /* no args; copy standard input */ filecopy(stdin); else while (--argc > 0) if ((fp = fopen(*++argv, "r")) == NULL) fprintf(stderr, "%s: can't open %s\n",*ARGV, *argv); else { if (ARGC > 2) printf("-------- %s --------\n",*argv); filecopy(fp); (void) fclose(fp); if (ARGC > 2) putchar('\n'); } exit(0); } filecopy(fp) /* copy file fp to standard output */ FILE *fp; { int c; int count = 0 ; while ((c = getc(fp)) != EOF) { putc(c, stdout); if ((c == '\n') && (count++ > 6)) return ; } }