1 /*-
2 * Copyright (c) 1980 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.proprietary.c%
6 */
7
8 #ifndef lint
9 char copyright[] =
10 "@(#) Copyright (c) 1980 The Regents of the University of California.\n\
11 All rights reserved.\n";
12 #endif /* not lint */
13
14 #ifndef lint
15 static char sccsid[] = "@(#)mkindx.c 5.2 (Berkeley) 04/12/91";
16 #endif /* not lint */
17
18 /*
19 * mkindx.c - utility to format a nice index to source files, etc.
20 *
21 * usage: mkindx "title string" [file_name] [filename] .....
22 */
23
24 # include <stdio.h>
25
26 char id_mkindx[] = "@(#)mkindx.c 5.2 04/12/91";
27
28 char list[10000] = "pwd >>index; echo \" \" >>index; ls -l ";
29 char *apndx = ">>index";
30 char *cp = list;
31 extern char *ctime();
32 FILE *fopen(), *index;
33
main(argc,argv)34 main (argc, argv)
35 char **argv;
36 {
37 short i;
38 long time(), t;
39
40 if (index = fopen ("index", "w"))
41 {
42 fprintf (index, "\n\n\n\n\n\n\n\n\n");
43 center (argv[1]); /* center title on page */
44 t = time(0);
45 center (ctime(&t)); /* center date & time */
46 fprintf (index, "\n");
47 fclose (index);
48 while (*cp) cp++; /* find end of shell command */
49 for (i = 2; i < argc; i++)
50 {
51 while (*argv[i]) *cp++ = *(argv[i]++);
52 *cp++ = ' ';
53 }
54 while (*apndx) *cp++ = *apndx++;
55 *cp = '\0';
56 system (list);
57 }
58 else fprintf (stderr, "mkindx: can't open index\n");
59 }
60
center(string)61 center (string)
62 char *string;
63 {
64 short pad;
65
66 pad = (72 - strlen(string)) >> 1;
67 while (pad-- > 0) fputc(' ', index);
68 fprintf (index, "%s\n", string);
69 }
70