# include # include # include # include # include # include using namespace std; int main ( int argc, char *argv[] ); char ch_cap ( char c ); int ch_index_first ( string s, char c ); int get_file_type ( string file_name ); void handle_c ( string file_name, string s1, string s2 ); void handle_cc ( string file_name, string s1, string s2 ); void handle_f77 ( string file_name, string s1, string s2 ); void handle_f90 ( string file_name, string s1, string s2 ); void handle_m ( string file_name, string s1, string s2 ); int i4_min ( int i1, int i2 ); bool s_begin ( string s1, string s2 ); string s_cap ( string s ); string s_last_ch ( string s, char ch ); void timestamp ( ); // // GLOBAL DATA // char date_string[30]; //****************************************************************************80 int main ( int argc, char *argv[] ) //****************************************************************************80 // // Purpose: // // MAIN is the main program for HTMLINDEX. // // Discussion: // // HTMLINDEX makes a skeleton HTML page from a marked up source code file. // // 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. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 12 September 2010 // // Author: // // John Burkardt // // Usage: // // htmlindex program.f90 > program.html // { int C = 1; int CC = 2; int F77 = 3; int F90 = 4; string file_name; int file_type; string head; string head_cap; int i; char* ipoint; int j; int M = 5; time_t seconds; struct tm *time_struct; int UNKNOWN = -1; bool VERBOSE = false; if ( VERBOSE ) { timestamp ( ); cout << "\n"; cout << "HTMLINDEX:\n"; cout << " C++ version\n"; cout << "\n"; cout << " Compiled on " << __DATE__ << " at " << __TIME__ << ".\n"; cout << "\n"; cout << " Produce a skeleton HTML page for a marked up file.\n"; } // // Retrieve the date. // (This was surprisingly unpleasant!) // time ( &seconds ); time_struct = localtime ( &seconds ); ipoint = asctime ( time_struct ); strcpy ( date_string, ipoint ); // // If the input file was not specified, get it now. // if ( argc <= 1 ) { cout << "\n"; cout << "HTLMINDEX:\n"; cout << " Please enter the name of a file to be indexed.\n"; cin >> file_name; j = ch_index_first ( file_name, '.' ); head = file_name.substr ( 0, j ); head_cap = s_cap ( head ); file_type = get_file_type ( file_name ); if ( file_type == C ) { handle_c ( file_name, head, head_cap ); } else if ( file_type == CC ) { handle_cc ( file_name, head, head_cap ); } else if ( file_type == F77 ) { handle_f77 ( file_name, head, head_cap ); } else if ( file_type == F90 ) { handle_f90 ( file_name, head, head_cap ); } else if ( file_type == M ) { handle_m ( file_name, head, head_cap ); } else if ( file_type == UNKNOWN ) { cerr << "\n"; cerr << "HTMLINDEXINDEX - Error!\n" ; cerr << " The file type of \"" << file_name << "\" could not be determined.\n"; } } // // Otherwise, open each target file, split it and close it. // else { for ( i = 1; i < argc; i++ ) { file_name = argv[i]; j = ch_index_first ( file_name, '.' ); head = file_name.substr ( 0, j ); head_cap = s_cap ( head ); file_type = get_file_type ( file_name ); if ( file_type == C ) { handle_c ( file_name, head, head_cap ); } else if ( file_type == CC ) { handle_cc ( file_name, head, head_cap ); } else if ( file_type == F77 ) { handle_f77 ( file_name, head, head_cap ); } else if ( file_type == F90 ) { handle_f90 ( file_name, head, head_cap ); } else if ( file_type == M ) { handle_m ( file_name, head, head_cap ); } else if ( file_type == UNKNOWN ) { cerr << "\n"; cerr << "HTMLINDEX - Error!\n" ; cerr << " The file type of \"" << file_name << "\" could not be determined.\n"; } } } // // Terminate. // if ( VERBOSE ) { cout << "\n"; cout << "HTMLINDEX:\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ) ; } return 0; } //****************************************************************************80 char ch_cap ( char c ) //****************************************************************************80 // // Purpose: // // CH_CAP capitalizes a single character. // // Discussion: // // This routine should be equivalent to the library "toupper" function. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 19 July 1998 // // Author: // // John Burkardt // // Parameters: // // Input, char C, the character to capitalize. // // Output, char CH_CAP, the capitalized character. // { if ( 97 <= c && c <= 122 ) { c = c - 32; } return c; } //****************************************************************************80 int ch_index_first ( string s, char c ) //****************************************************************************80 // // Purpose: // // CH_INDEX_FIRST finds the first occurrence of a character in a string. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 12 September 2010 // // Author: // // John Burkardt // // Parameters: // // Input, string S, a string to be searched. // // Input, char C, the character to be searched for. // // Output, int CH_INDEX_FIRST, the index of the first occurrence // of the character, or -1 if it does not occur. // { int i; int nchar; nchar = s.length ( ); for ( i = 0; i < nchar; i++ ) { if ( s[i] == c ) { return i; } } return -1; } //****************************************************************************80 int get_file_type ( string file_name ) //****************************************************************************80 // // Purpose: // // GET_FILE_TYPE determines the type of a file. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 12 September 2010 // // Author: // // John Burkardt // // Parameters: // // Input, string FILE_NAME, the name of the file. // // Output, int FILE_TYPE, is C, CC, F, or UNKNOWN. // { int C = 1; int CC = 2; string ext; int F77 = 3; int F90 = 4; int file_type; int M = 5; int UNKNOWN = -1; ext = s_last_ch ( file_name, '.' ); if ( ext.empty ( ) ) { file_type = UNKNOWN; } else if ( ext.compare ( ".f" ) == 0 ) { file_type = F77; } else if ( ext.compare ( ".f77" ) == 0 ) { file_type = F77; } else if ( ext.compare ( ".f90" ) == 0 ) { file_type = F90; } else if ( ext.compare ( ".f95" ) == 0 ) { file_type = F90; } else if ( ext.compare ( ".for" ) == 0 ) { file_type = F77; } else if ( ext.compare ( ".c" ) == 0 ) { file_type = C; } else if ( ext.compare ( ".cc" ) == 0 ) { file_type = CC; } else if ( ext.compare ( ".C" ) == 0 ) { file_type = CC; } else if ( ext.compare ( ".cxx" ) == 0 ) { file_type = CC; } else if ( ext.compare ( ".cpp" ) == 0 ) { file_type = CC; } else if ( ext.compare ( ".m" ) == 0 ) { file_type = M; } else { file_type = UNKNOWN; } return file_type; } //****************************************************************************80 void handle_c ( string file_name, string s1, string s2 ) //****************************************************************************80 // // Purpose: // // HANDLE_C processes a single C file. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 12 September 2010 // // Author: // // John Burkardt // // Parameters: // // Input, string FILE_NAME, the name of the file to be processed. // // Input, string S1, the name of the file, minus extension. // // Input, string S2, the same as S1, but capitalized. // { ifstream file_in; int i0 = 0; int i1 = 0; int i2 = 0; string line; int line_length; int inc; // // Open the file. // file_in.open ( file_name.c_str ( ) ); if ( !file_in ) { cerr << "\n"; cerr << "HANDLE_C - Fatal error!\n"; cerr << " Cannot open \"" << file_name << "\".\n"; return; } // // Write the header. // cout << "\n"; cout << "\n"; cout << " \n"; cout << " \n"; cout << " "; cout << s2; cout << " - title goes here.\n"; cout << " \n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << "

\n"; cout << " "; cout << s2; cout << "
heading goes here.\n"; cout << "

\n"; cout << "\n"; cout << "
\n"; cout << "\n"; cout << "

\n"; cout << " " << s2 << "\n"; cout << " is a C (program/library) which\n"; cout << " (description goes here).\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Licensing:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " I don't care what you do with this code.\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Languages:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " " << s2 << " is available in\n"; cout << " a C version.\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Related Software and Data:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Reference:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

    \n"; cout << "
  1. \n"; cout << " \n"; cout << "
  2. \n"; cout << "
\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Source Code:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Examples and Tests:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

\n"; cout << "

\n"; cout << "\n"; // // Start the HTML Paragraph, and "Unnumbered List". // cout << "

\n"; cout << " List of Routines:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

    \n"; // // Get another line of text. // while ( true ) { getline ( file_in, line ); line_length = line.length ( ); if ( file_in.eof ( ) ) { break; } i0 = i1; i1 = i2; // // If we find the marker, then the text we want is two lines later. // if ( s_begin ( line, " Purpose:" ) ) { i2 = 1; } else { i2 = 0; } if ( i0 == 1 ) { // // Begin the HTML List Item, and go into Bold face. // cout << "
  • \n"; cout << " "; // // Print out all the characters, until you see a space. // inc = 4; while ( line[inc] != ' ' && line[inc] && inc < line_length ) { cout << line[inc]; inc = inc + 1; } // // Terminate Bold face, then print the rest of the characters, // and end the List Item. // cout << ""; while ( inc < line_length ) { cout << line[inc]; inc = inc + 1; } cout << "\n"; cout << "
  • \n"; } } // // End the HTML "Unnumbered List" and Paragraph. // cout << "
\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " You can go up one level to \n"; cout << " the C source codes.\n"; cout << "

\n"; cout << "\n"; cout << "
\n"; cout << "\n"; cout << " \n"; cout << " Last revised on " << date_string; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << "\n"; // // Close the file. // file_in.close ( ); return; } //****************************************************************************80 void handle_cc ( string file_name, string s1, string s2 ) //****************************************************************************80 // // Purpose: // // HANDLE_CC processes a single C++ file. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 12 September 2010 // // Author: // // John Burkardt // // Parameters: // // Input, string FILE_NAME, the name of the file to be processed. // // Input, string S1, the name of the file, minus extension. // // Input, string S2, the same as S1, but capitalized. // { ifstream file_in; int i0 = 0; int i1 = 0; int i2 = 0; string line; int line_length; int inc; // // Open the file. // file_in.open ( file_name.c_str ( ) ); if ( !file_in ) { cerr << "\n"; cerr << "HANDLE_CC - Fatal error!\n"; cerr << " Cannot open \"" << file_name << "\".\n"; return; } // // Write the header. // cout << "\n"; cout << "\n"; cout << " \n"; cout << " \n"; cout << " "; cout << s2; cout << " - title goes here.\n"; cout << " \n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << "

\n"; cout << " "; cout << s2; cout << "
heading goes here.\n"; cout << "

\n"; cout << "\n"; cout << "
\n"; cout << "\n"; cout << "

\n"; cout << " " << s2 << "\n"; cout << " is a C++ (program/library) which\n"; cout << " (description goes here).\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Licensing:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " I don't care what you do with this code.\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Languages:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " " << s2 << " is available in\n"; cout << " a C++ version.\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Related Software and Data:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Reference:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

    \n"; cout << "
  1. \n"; cout << " \n"; cout << "
  2. \n"; cout << "
\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Source Code:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Examples and Tests:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

\n"; cout << "

\n"; cout << "\n"; // // Start the HTML Paragraph, and "Unnumbered List". // cout << "

\n"; cout << " List of Routines:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

    \n"; // // Get another line of text. // while ( true ) { getline ( file_in, line ); line_length = line.length ( ); if ( file_in.eof ( ) ) { break; } i0 = i1; i1 = i2; // // If we find the marker, then the text we want is two lines later. // if ( s_begin ( line, "// Purpose:" ) ) { i2 = 1; } else { i2 = 0; } if ( i0 == 1 ) { // // Begin the HTML List Item, and go into Bold face. // cout << "
  • \n"; cout << " "; // // Print out all the characters, until you see a space. // inc = 6; while ( line[inc] != ' ' && line[inc] && inc < line_length ) { cout << line[inc]; inc = inc + 1; } // // Terminate Bold face, then print the rest of the characters, // and end the List Item. // cout << ""; while ( inc < line_length ) { cout << line[inc]; inc = inc + 1; } cout << "\n"; cout << "
  • \n"; } } // // End the HTML "Unnumbered List" and Paragraph. // cout << "
\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " You can go up one level to \n"; cout << " the C++ source codes.\n"; cout << "

\n"; cout << "\n"; cout << "
\n"; cout << "\n"; cout << " \n"; cout << " Last revised on " << date_string; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << "\n"; // // Close the file. // file_in.close ( ); return; } //****************************************************************************80 void handle_f77 ( string file_name, string s1, string s2 ) //****************************************************************************80 // // Purpose: // // HANDLE_F77 processes a single FORTRAN77 file. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 12 September 2010 // // Author: // // John Burkardt // // Parameters: // // Input, string FILE_NAME, the name of the file to be processed. // // Input, string S1, the name of the file, minus extension. // // Input, string S2, the same as S1, but capitalized. // { ifstream file_in; string line; int line_length; int inc; // // Open the file. // file_in.open ( file_name.c_str ( ) ); if ( !file_in ) { cerr << "\n"; cerr << "HANDLE_F77 - Fatal error!\n"; cerr << " Cannot open \"" << file_name << "\".\n"; return; } // // Write the header. // cout << "\n"; cout << "\n"; cout << " \n"; cout << " \n"; cout << " " << s2 << " - title goes here.\n"; cout << " \n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << "

\n"; cout << " "; cout << s2; cout << "
heading goes here.\n"; cout << "

\n"; cout << "\n"; cout << "
\n"; cout << "\n"; cout << "

\n"; cout << " " << s2 << "\n"; cout << " is a FORTRAN77 (program/library) which\n"; cout << " (description goes here).\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Licensing:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " I don't care what you do with this code.\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Languages:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " " << s2 << " is available in\n"; cout << " a FORTRAN77 version.\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Related Software and Data:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Reference:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

    \n"; cout << "
  1. \n"; cout << " \n"; cout << "
  2. \n"; cout << "
\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Source Code:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Examples and Tests:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

\n"; cout << "

\n"; cout << "\n"; // // Start the HTML Paragraph, and "Unnumbered List". // cout << "

\n"; cout << " List of Routines:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

    \n"; // // Get another line of text. // while ( true ) { getline ( file_in, line ); line_length = line.length ( ); if ( file_in.eof ( ) ) { break; } // // If the text begins with "!!" then we want to print it, // but skipping the first three characters. // if ( s_begin ( line, "!!" ) || s_begin ( line, "cc" ) || s_begin ( line, "CC" ) ) { // // Begin the HTML List Item, and go into Bold face. // cout << "
  • \n"; cout << " "; // // Print out all the characters, until you see a space. // inc = 3; while ( line[inc] != ' ' && line[inc] && inc < line_length ) { cout << line[inc]; inc = inc + 1; } // // Terminate Bold face, then print the rest of the characters, // and end the List Item. // cout << ""; while ( inc < line_length ) { cout << line[inc]; inc = inc + 1; } cout << "\n"; cout << "
  • \n"; } } // // End the HTML "Unnumbered List" and Paragraph. // cout << "
\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " You can go up one level to \n"; cout << " the FORTRAN77 source codes.\n"; cout << "

\n"; cout << "\n"; cout << "
\n"; cout << "\n"; cout << " \n"; cout << " Last revised on " << date_string; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << "\n"; // // Close the file. // file_in.close ( ); return; } //****************************************************************************80 void handle_f90 ( string file_name, string s1, string s2 ) //****************************************************************************80 // // Purpose: // // HANDLE_F90 processes a single FORTRAN90 file. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 12 September 2010 // // Author: // // John Burkardt // // Parameters: // // Input, string FILE_NAME, the name of the file to be processed. // // Input, string S1, the name of the file, minus extension. // // Input, string S2, the same as S1, but capitalized. // { ifstream file_in; string line; int line_length; int inc; // // Open the file. // file_in.open ( file_name.c_str ( ) ); if ( !file_in ) { cerr << "\n"; cerr << "HANDLE_F90 - Fatal error!\n"; cerr << " Cannot open \"" << file_name << "\".\n"; return; } // // Write the header. // cout << "\n"; cout << "\n"; cout << " \n"; cout << " \n"; cout << " " << s2 << " - title goes here.\n"; cout << " \n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << "

\n"; cout << " "; cout << s2; cout << "
heading goes here.\n"; cout << "

\n"; cout << "\n"; cout << "
\n"; cout << "\n"; cout << "

\n"; cout << " " << s2 << "\n"; cout << " is a FORTRAN90 (program/library) which\n"; cout << " (description goes here).\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Licensing:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " I don't care what you do with this code.\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Languages:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " " << s2 << " is available in\n"; cout << " a FORTRAN90 version.\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Related Software and Data:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Reference:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

    \n"; cout << "
  1. \n"; cout << " \n"; cout << "
  2. \n"; cout << "
\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Source Code:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Examples and Tests:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

\n"; cout << "

\n"; cout << "\n"; // // Start the HTML Paragraph, and "Unnumbered List". // cout << "

\n"; cout << " List of Routines:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

    \n"; // // Get another line of text. // while ( true ) { getline ( file_in, line ); line_length = line.length ( ); if ( file_in.eof ( ) ) { break; } // // If the text begins with "!!" then we want to print it, // but skipping the first three characters. // if ( s_begin ( line, "!!" ) || s_begin ( line, "cc" ) || s_begin ( line, "CC" ) ) { // // Begin the HTML List Item, and go into Bold face. // cout << "
  • \n"; cout << " "; // // Print out all the characters, until you see a space. // inc = 3; while ( line[inc] != ' ' && line[inc] && inc < line_length ) { cout << line[inc]; inc = inc + 1; } // // Terminate Bold face, then print the rest of the characters, // and end the List Item. // cout << ""; while ( inc < line_length ) { cout << line[inc]; inc = inc + 1; } cout << "\n"; cout << "
  • \n"; } } // // End the HTML "Unnumbered List" and Paragraph. // cout << "
\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " You can go up one level to \n"; cout << " the FORTRAN90 source codes.\n"; cout << "

\n"; cout << "\n"; cout << "
\n"; cout << "\n"; cout << " \n"; cout << " Last revised on " << date_string; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << "\n"; // // Close the file. // file_in.close ( ); return; } //****************************************************************************80 void handle_m ( string file_name, string s1, string s2 ) //****************************************************************************80 // // Purpose: // // HANDLE_M processes a single MATLAB file. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 13 September 2010 // // Author: // // John Burkardt // // Parameters: // // Input, string FILE_NAME, the name of the file to be processed. // // Input, string S1, the name of the file, minus extension. // // Input, string S2, the same as S1, but capitalized. // { ifstream file_in; string line; int line_length; int inc; // // Open the file. // file_in.open ( file_name.c_str ( ) ); if ( !file_in ) { cerr << "\n"; cerr << "HANDLE_M - Fatal error!\n"; cerr << " Cannot open \"" << file_name << "\".\n"; return; } // // Write the header. // cout << "\n"; cout << "\n"; cout << " \n"; cout << " \n"; cout << " " << s2 << " - title goes here.\n"; cout << " \n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << "

\n"; cout << " "; cout << s2; cout << "
heading goes here.\n"; cout << "

\n"; cout << "\n"; cout << "
\n"; cout << "\n"; cout << "

\n"; cout << " " << s2 << "\n"; cout << " is a MATLAB (program/library) which\n"; cout << " (description goes here).\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Licensing:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " I don't care what you do with this code.\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Languages:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " " << s2 << " is available in\n"; cout << " a Matlab version.\n"; cout << "\n"; cout << "

\n"; cout << " Related Software and Data:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Reference:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

    \n"; cout << "
  1. \n"; cout << " \n"; cout << "
  2. \n"; cout << "
\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Source Code:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " Examples and Tests:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

\n"; cout << "

\n"; cout << "\n"; // // Start the HTML Paragraph, and "Unnumbered List". // cout << "

\n"; cout << " List of Routines:\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << "

    \n"; // // Get another line of text. // while ( true ) { getline ( file_in, line ); line_length = line.length ( ); if ( file_in.eof ( ) ) { break; } // // If the text begins with "%%" then we want to print it, // but skipping the first three characters. // if ( s_begin ( line, "%%" ) ) { // // Begin the HTML List Item, and go into Bold face. // cout << "
  • \n"; cout << " "; // // Print out all the characters, until you see a space. // inc = 3; while ( line[inc] != ' ' && line[inc] && inc < line_length ) { cout << line[inc]; inc = inc + 1; } // // Terminate Bold face, then print the rest of the characters, // and end the List Item. // cout << ""; while ( inc < line_length ) { cout << line[inc]; inc = inc + 1; } cout << "\n"; cout << "
  • \n"; } } // // End the HTML "Unnumbered List" and Paragraph. // cout << "
\n"; cout << "

\n"; cout << "\n"; cout << "

\n"; cout << " You can go up one level to \n"; cout << " the MATLAB source codes.\n"; cout << "

\n"; cout << "\n"; cout << "
\n"; cout << "\n"; cout << " \n"; cout << " Last revised on " << date_string; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << " \n"; cout << "\n"; cout << "\n"; // // Close the file. // file_in.close ( ); return; } //****************************************************************************80 int i4_min ( int i1, int i2 ) //****************************************************************************80 // // Purpose: // // I4_MIN returns the minimum of two I4's. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 13 October 1998 // // Author: // // John Burkardt // // Parameters: // // Input, int I1, I2, two integers to be compared. // // Output, int I4_MIN, the smaller of I1 and I2. // { int value; if ( i1 < i2 ) { value = i1; } else { value = i2; } return value; } //****************************************************************************80 bool s_begin ( string s1, string s2 ) //****************************************************************************80 // // Purpose: // // S_BEGIN reports whether string 1 begins with string 2. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 12 September 2010 // // Author: // // John Burkardt // // Parameters: // // Input, string S1, string S2, two strings. // // Output, bool S_BEGIN, is true if S1 is the same as S2 up to // the end of S2, and false otherwise. // { int i; int n1; int n2; n1 = s1.length ( ); n2 = s2.length ( ); if ( n1 < n2 ) { return false; } for ( i = 0; i < n2; i++ ) { if ( s1[i] != s2[i] ) { return false; } } return true; } //****************************************************************************80 string s_cap ( string s ) //****************************************************************************80 // // Purpose: // // S_CAP capitalizes all the characters in a string. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 29 August 2009 // // Author: // // John Burkardt // // Parameters: // // Input, string S, the string to be capitalized. // // Output, string S_CAP, the capitalized string. // { int i; int s_length; string s2; s_length = s.length ( ); s2 = s; for ( i = 0; i < s_length; i++ ) { s2[i] = ch_cap ( s2[i] ); } return s2; } //****************************************************************************80 string s_last_ch ( string s, char ch ) //****************************************************************************80 // // Purpose: // // S_LAST_CH points to the last occurrence of a character in a string. // // Licensing: // // I don't care what you do with this code. // // Modified: // // 06 January 2003 // // Author: // // John Burkardt // // Parameters: // // Input, string S, a string. // // Input, char CH, a character. // // Output, string S_LAST_CH, the substring beginning with the last occurrence // of the given character. // { int position; int s_length; string t; int t_length; s_length = s.length ( ); // // Find the last occurrence. // for ( position = s_length - 1; 0 <= position; position-- ) { if ( s[position] == ch ) { t_length = s_length - position; t = s.substr ( position, t_length ); return t; } } t.clear ( ); return t; } //****************************************************************************80 void timestamp ( ) //****************************************************************************80 // // Purpose: // // TIMESTAMP prints the current YMDHMS date as a time stamp. // // Example: // // May 31 2001 09:45:54 AM // // Licensing: // // I don't care what you do with this code. // // Modified: // // 02 October 2003 // // Author: // // John Burkardt // // Parameters: // // None // { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct tm *tm; time_t now; now = time ( NULL ); tm = localtime ( &now ); strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); cout << time_buffer << "\n"; return; # undef TIME_SIZE }