|
|
1.1 ! root 1: /* ! 2: * mkindx.c - utility to format a nice index to source files, etc. ! 3: * ! 4: * usage: mkindx "title string" [file_name] [filename] ..... ! 5: */ ! 6: ! 7: # include <stdio.h> ! 8: ! 9: char id_mkindx[] = "@(#)mkindx.c 1.1"; ! 10: ! 11: char list[10000] = "pwd >>index; echo \" \" >>index; ls -l "; ! 12: char *apndx = ">>index"; ! 13: char *cp = list; ! 14: extern char *ctime(); ! 15: FILE *fopen(), *index; ! 16: ! 17: main (argc, argv) ! 18: char **argv; ! 19: { ! 20: short i; ! 21: long time(), t; ! 22: ! 23: if (index = fopen ("index", "w")) ! 24: { ! 25: fprintf (index, "\n\n\n\n\n\n\n\n\n"); ! 26: center (argv[1]); /* center title on page */ ! 27: t = time(0); ! 28: center (ctime(&t)); /* center date & time */ ! 29: fprintf (index, "\n"); ! 30: fclose (index); ! 31: while (*cp) cp++; /* find end of shell command */ ! 32: for (i = 2; i < argc; i++) ! 33: { ! 34: while (*argv[i]) *cp++ = *(argv[i]++); ! 35: *cp++ = ' '; ! 36: } ! 37: while (*apndx) *cp++ = *apndx++; ! 38: *cp = '\0'; ! 39: system (list); ! 40: } ! 41: else fprintf (stderr, "mkindx: can't open index\n"); ! 42: } ! 43: ! 44: center (string) ! 45: char *string; ! 46: { ! 47: short pad; ! 48: ! 49: pad = (72 - strlen(string)) >> 1; ! 50: while (pad-- > 0) fputc(' ', index); ! 51: fprintf (index, "%s\n", string); ! 52: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.