stdio.h defines BUFSIZ
[unix-history] / usr / src / usr.bin / f77 / libU77 / mkindx.c
CommitLineData
161423a6
RE
1/*
2 * Copyright (c) 1980 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
2dc69f72
DW
7/*
8 * mkindx.c - utility to format a nice index to source files, etc.
9 *
10 * usage: mkindx "title string" [file_name] [filename] .....
11 */
12
13# include <stdio.h>
14
161423a6 15char id_mkindx[] = "@(#)mkindx.c 5.1 %G%";
2dc69f72
DW
16
17char list[10000] = "pwd >>index; echo \" \" >>index; ls -l ";
18char *apndx = ">>index";
19char *cp = list;
20extern char *ctime();
21FILE *fopen(), *index;
22
23main (argc, argv)
24char **argv;
25{
26 short i;
27 long time(), t;
28
29 if (index = fopen ("index", "w"))
30 {
31 fprintf (index, "\n\n\n\n\n\n\n\n\n");
32 center (argv[1]); /* center title on page */
33 t = time(0);
34 center (ctime(&t)); /* center date & time */
35 fprintf (index, "\n");
36 fclose (index);
37 while (*cp) cp++; /* find end of shell command */
38 for (i = 2; i < argc; i++)
39 {
40 while (*argv[i]) *cp++ = *(argv[i]++);
41 *cp++ = ' ';
42 }
43 while (*apndx) *cp++ = *apndx++;
44 *cp = '\0';
45 system (list);
46 }
47 else fprintf (stderr, "mkindx: can't open index\n");
48}
49
50center (string)
51char *string;
52{
53 short pad;
54
55 pad = (72 - strlen(string)) >> 1;
56 while (pad-- > 0) fputc(' ', index);
57 fprintf (index, "%s\n", string);
58}