xref: /csrg-svn/usr.bin/f77/libF77/mkindx.c (revision 47940)
1*47940Sbostic /*-
2*47940Sbostic  * Copyright (c) 1980 The Regents of the University of California.
3*47940Sbostic  * All rights reserved.
4*47940Sbostic  *
5*47940Sbostic  * %sccs.include.proprietary.c%
623852Sjerry  */
723852Sjerry 
8*47940Sbostic #ifndef lint
9*47940Sbostic char copyright[] =
10*47940Sbostic "@(#) Copyright (c) 1980 The Regents of the University of California.\n\
11*47940Sbostic  All rights reserved.\n";
12*47940Sbostic #endif /* not lint */
13*47940Sbostic 
14*47940Sbostic #ifndef lint
15*47940Sbostic static char sccsid[] = "@(#)mkindx.c	1.2 (Berkeley) 04/12/91";
16*47940Sbostic #endif /* not lint */
17*47940Sbostic 
1823852Sjerry /*
1923852Sjerry  *  mkindx.c - utility to format a nice index to source files, etc.
2023852Sjerry  *
2123852Sjerry  *  usage:  mkindx "title string" [file_name] [filename] .....
2223852Sjerry  */
2323852Sjerry 
2423852Sjerry # include	<stdio.h>
2523852Sjerry 
26*47940Sbostic char id_mkindx[] = "@(#)mkindx.c	1.2 04/12/91";
2723852Sjerry 
2823852Sjerry char list[10000] = "pwd >>index; echo \" \" >>index; ls -l ";
2923852Sjerry char *apndx = ">>index";
3023852Sjerry char *cp = list;
3123852Sjerry extern char *ctime();
3223852Sjerry FILE *fopen(), *index;
3323852Sjerry 
main(argc,argv)3423852Sjerry main (argc, argv)
3523852Sjerry char **argv;
3623852Sjerry {
3723852Sjerry 	short i;
3823852Sjerry 	long time(), t;
3923852Sjerry 
4023852Sjerry 	if (index = fopen ("index", "w"))
4123852Sjerry 	{
4223852Sjerry 		fprintf (index, "\n\n\n\n\n\n\n\n\n");
4323852Sjerry 		center (argv[1]);   /* center title on page */
4423852Sjerry 		t = time(0);
4523852Sjerry 		center (ctime(&t));   /* center date & time */
4623852Sjerry 		fprintf (index, "\n");
4723852Sjerry 		fclose (index);
4823852Sjerry 		while (*cp) cp++;   /* find end of shell command */
4923852Sjerry 		for (i = 2; i < argc; i++)
5023852Sjerry 		{
5123852Sjerry 			while (*argv[i]) *cp++ = *(argv[i]++);
5223852Sjerry 			*cp++ = ' ';
5323852Sjerry 		}
5423852Sjerry 		while (*apndx) *cp++ = *apndx++;
5523852Sjerry 		*cp = '\0';
5623852Sjerry 		system (list);
5723852Sjerry 	}
5823852Sjerry 	else fprintf (stderr, "mkindx: can't open index\n");
5923852Sjerry }
6023852Sjerry 
center(string)6123852Sjerry center (string)
6223852Sjerry char *string;
6323852Sjerry {
6423852Sjerry 	short pad;
6523852Sjerry 
6623852Sjerry 	pad = (72 - strlen(string)) >> 1;
6723852Sjerry 	while (pad-- > 0) fputc(' ', index);
6823852Sjerry 	fprintf (index, "%s\n", string);
6923852Sjerry }
70