xref: /csrg-svn/usr.bin/f77/libU77/mkindx.c (revision 47944)
1*47944Sbostic /*-
2*47944Sbostic  * Copyright (c) 1980 The Regents of the University of California.
3*47944Sbostic  * All rights reserved.
4*47944Sbostic  *
5*47944Sbostic  * %sccs.include.proprietary.c%
623040Skre  */
723040Skre 
8*47944Sbostic #ifndef lint
9*47944Sbostic char copyright[] =
10*47944Sbostic "@(#) Copyright (c) 1980 The Regents of the University of California.\n\
11*47944Sbostic  All rights reserved.\n";
12*47944Sbostic #endif /* not lint */
13*47944Sbostic 
14*47944Sbostic #ifndef lint
15*47944Sbostic static char sccsid[] = "@(#)mkindx.c	5.2 (Berkeley) 04/12/91";
16*47944Sbostic #endif /* not lint */
17*47944Sbostic 
1823040Skre /*
1910559Sdlw  *  mkindx.c - utility to format a nice index to source files, etc.
2010559Sdlw  *
2110559Sdlw  *  usage:  mkindx "title string" [file_name] [filename] .....
2210559Sdlw  */
2310559Sdlw 
2410559Sdlw # include	<stdio.h>
2510559Sdlw 
26*47944Sbostic char id_mkindx[] = "@(#)mkindx.c	5.2 04/12/91";
2710559Sdlw 
2810559Sdlw char list[10000] = "pwd >>index; echo \" \" >>index; ls -l ";
2910559Sdlw char *apndx = ">>index";
3010559Sdlw char *cp = list;
3110559Sdlw extern char *ctime();
3210559Sdlw FILE *fopen(), *index;
3310559Sdlw 
main(argc,argv)3410559Sdlw main (argc, argv)
3510559Sdlw char **argv;
3610559Sdlw {
3710559Sdlw 	short i;
3810559Sdlw 	long time(), t;
3910559Sdlw 
4010559Sdlw 	if (index = fopen ("index", "w"))
4110559Sdlw 	{
4210559Sdlw 		fprintf (index, "\n\n\n\n\n\n\n\n\n");
4310559Sdlw 		center (argv[1]);   /* center title on page */
4410559Sdlw 		t = time(0);
4510559Sdlw 		center (ctime(&t));   /* center date & time */
4610559Sdlw 		fprintf (index, "\n");
4710559Sdlw 		fclose (index);
4810559Sdlw 		while (*cp) cp++;   /* find end of shell command */
4910559Sdlw 		for (i = 2; i < argc; i++)
5010559Sdlw 		{
5110559Sdlw 			while (*argv[i]) *cp++ = *(argv[i]++);
5210559Sdlw 			*cp++ = ' ';
5310559Sdlw 		}
5410559Sdlw 		while (*apndx) *cp++ = *apndx++;
5510559Sdlw 		*cp = '\0';
5610559Sdlw 		system (list);
5710559Sdlw 	}
5810559Sdlw 	else fprintf (stderr, "mkindx: can't open index\n");
5910559Sdlw }
6010559Sdlw 
center(string)6110559Sdlw center (string)
6210559Sdlw char *string;
6310559Sdlw {
6410559Sdlw 	short pad;
6510559Sdlw 
6610559Sdlw 	pad = (72 - strlen(string)) >> 1;
6710559Sdlw 	while (pad-- > 0) fputc(' ', index);
6810559Sdlw 	fprintf (index, "%s\n", string);
6910559Sdlw }
70