home *** CD-ROM | disk | FTP | other *** search
- #include <fstream>
- using namespace std;
-
- void displayfile(char *file, ostream *output)
- {
- ifstream inputfile(file);
- char buffer[1024];
-
- if (!inputfile)
- {
- *output << "Error displaying file " << file << endl;
- return;
- }
-
- *output << "<pre>";
- do
- {
- inputfile.read(buffer, 1024);
- output->write(buffer, inputfile.gcount());
- }
- while (!inputfile.eof());
- inputfile.close();
- *output << "</pre><hr>";
- }
-
- void main(int argc, char *argv[])
- {
- // Not enough parameters, return silently
- if (argc < 4) return;
-
- // Set up output
- ofstream output(argv[3]);
- if (!output) return;
-
- // header
- output << "Content-type: text/html\n\n";
-
- // profile
- output << "<h2>Profile:</h2>";
- displayfile(argv[1], &output);
-
- // content
- output << "<h2>Content:</h2>";
- displayfile(argv[2], &output);
-
- // query string
- if (argc >= 5)
- output << "<h2>Query String: " << argv[4] << "</h2>";
- else
- output << "<h2>No Query String</h2>";
-
- // close the file
- output.close();
- }