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