/* htmlindex.c */
#include
#include
#include
#include
#include
#ifdef VMS
#include
#include
#endif
#define BIG 255
/******************************************************************************/
/* FUNCTION PROTOTYPES */
int main ( int argc, char **argv );
void handle ( FILE *fin );
/* GLOBAL DATA */
char date_string[30];
/******************************************************************************/
int main ( int argc, char **argv ) {
/******************************************************************************/
/*
Purpose:
HTMLINDEX makes a skeleton HTML page, listing lines beginning with "!!".
Discussion:
HTMLINDEX writes a skeleton HTML page to standard output, including
stubs for the software name, description, copying option, an
unnumbered list of the double exclamation lines (typically reporting
the routines contained in the program), and some clean up lines
at the end.
In my FORTRAN files, each function and subroutine includes a single
line that lists its name and purpose. This line always has the form:
!! NAME purpose
and HTMLINDEX makes an HTML page suitable for describing the file,
including a list of functions and subroutines compiled from these
lines.
Modified:
08 March 2002
Author:
John Burkardt
Usage:
htmlindex program.f90 > program.html
*/
FILE *fd;
int i;
char* ipoint;
time_t seconds;
struct tm *time_struct;
/*
Retrieve the date.
(This was surprisingly unpleasant!)
*/
time ( &seconds );
time_struct = localtime ( &seconds );
ipoint = asctime ( time_struct );
strcpy ( date_string, ipoint );
/*
If no filename was specified, split up standard input.
*/
if ( argc <= 1 ) {
handle ( stdin );
}
/*
Otherwise, open each target file, split it and close it.
*/
else {
for ( i = 1 ; i < argc ; ++i ) {
fd = fopen ( argv[i], "r" );
if ( fd == NULL) {
fprintf ( stderr, "\n" );
fprintf ( stderr, "HTMLINDEX: Error!\n" );
fprintf ( stderr, " Cannot open %s\n", argv[i] );
return ( EXIT_FAILURE );
}
handle ( fd );
fclose ( fd );
}
}
return ( EXIT_SUCCESS );
}
/******************************************************************************/
void handle ( FILE *fin ) {
/******************************************************************************/
/*
Purpose:
HANDLE processes a single file.
Author:
John Burkardt
Modified:
21 September 2001
*/
char in[BIG];
int inc;
/*
Write the header.
*/
fputs ( "\n", stdout );
fputs ( "\n", stdout );
fputs ( " \n", stdout );
fputs ( " \n", stdout );
fputs ( " BLAH title goes here.\n", stdout );
fputs ( " \n", stdout );
fputs ( " \n", stdout );
fputs ( "\n", stdout );
fputs ( " \n", stdout );
fputs ( "\n", stdout );
fputs ( " \n", stdout );
fputs ( " BLAH heading goes here.\n", stdout );
fputs ( "
\n", stdout );
fputs ( "\n", stdout );
fputs ( " \n", stdout );
fputs ( " BLAH description goes here.\n", stdout );
fputs ( "
\n", stdout );
fputs ( "\n", stdout );
fputs ( " \n", stdout );
fputs ( " Files you may copy include:\n", stdout );
fputs ( "
\n", stdout );
fputs ( " - \n", stdout );
fputs ( " blah.f90, the source code.\n", stdout );
fputs ( "
\n", stdout );
fputs ( " - \n", stdout );
fputs ( " blah_prb.f90, a sample problem.\n", stdout );
fputs ( "
\n", stdout );
fputs ( " - \n", stdout );
fputs ( " blah_prb.out, sample problem output.\n", stdout );
fputs ( "
\n", stdout );
fputs ( "
\n", stdout );
fputs ( "
\n", stdout );
fputs ( "\n", stdout );
/*
Start the HTML Paragraph, and "Unnumbered List".
*/
fputs ( " \n", stdout );
fputs ( " The list of routines includes:\n", stdout );
fputs ( "
\n", stdout );
/*
Get another line of text.
*/
while ( fgets ( in, BIG, fin ) ) {
/*
If the text begins with "!!" then we want to print it,
but skipping the first three characters.
*/
if ( in[0] == '!' && in[1] == '!' ) {
/*
Begin the HTML List Item, and go into Bold face.
*/
fputs ( " - \n", stdout );
fputs ( " ", stdout );
/*
Print out all the characters, until you see a space.
*/
inc = 3;
while ( in[inc] != ' ' && in[inc] != NULL && in[inc] != '\n' ) {
fputc ( in[inc], stdout );
inc = inc + 1;
}
/*
Terminate Bold face, then print the rest of the characters,
and end the List Item.
*/
fputs ( "", stdout );
fputs ( in+inc, stdout );
fputs ( "
\n", stdout );
}
}
/*
End the HTML "Unnumbered List" and Paragraph.
*/
fputs ( "
\n", stdout );
fputs ( " \n", stdout );
fputs ( "\n", stdout );
fputs ( " \n", stdout );
fputs ( " Return to the FORTRAN software page.\n", stdout );
fputs ( "
\n", stdout );
fputs ( "\n", stdout );
fputs ( "
\n", stdout );
fputs ( "\n", stdout );
fputs ( " \n", stdout );
fputs ( " Last revised on ", stdout );
fputs ( date_string, stdout );
fputs ( " \n", stdout );
fputs ( "\n", stdout );
fputs ( " \n", stdout );
fputs ( "\n", stdout );
fputs ( " \n", stdout );
fputs ( "\n", stdout );
fputs ( "\n", stdout );
return;
}