date and time created 83/01/21 15:03:33 by dlw
[unix-history] / usr / src / usr.bin / f77 / libU77 / mkindx.c
CommitLineData
2dc69f72
DW
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
9char id_mkindx[] = "@(#)mkindx.c 1.1";
10
11char list[10000] = "pwd >>index; echo \" \" >>index; ls -l ";
12char *apndx = ">>index";
13char *cp = list;
14extern char *ctime();
15FILE *fopen(), *index;
16
17main (argc, argv)
18char **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
44center (string)
45char *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}