#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/wait.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include "cgi_util.h"
#include "util.h"
#include "debug.h"
Include dependency graph for cgi_util.cc:
Go to the source code of this file.
Defines | |
#define | CRLF "\r\n" |
#define | FILE_DELIMITER '/' |
Functions | |
bool | do_version (const string &script_ver, const string &dataset_ver) |
Send a version number. | |
void | ErrMsgT (const string &Msgt) |
Logs an error message. | |
string | find_ancillary_file (const string &pathname, const string &ext, const string &dir, const string &file) |
Find a file with ancillary data. | |
string | find_group_ancillary_file (const string &name, const string &ext) |
bool | found_override (string name, string &doc) |
string | get_user_supplied_docs (string name, string cgi) |
Look for the user supplied CGI- and dataset-specific HTML* documents. | |
time_t | last_modified_time (const string &name) |
string | name_path (const string &path) |
Returns the filename portion of a pathname. | |
bool | remove_mime_header (FILE *in) |
Read and discard the MIME header of the stream in . | |
string | rfc822_date (const time_t t) |
void | set_mime_binary (FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified) |
void | set_mime_error (FILE *out, int code, const string &reason, const string &version) |
void | set_mime_html (FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified) |
void | set_mime_not_modified (FILE *out) |
Send a `Not Modified' response. | |
void | set_mime_text (FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified) |
|
Definition at line 85 of file cgi_util.cc. Referenced by do_version(), remove_mime_header(), set_mime_binary(), set_mime_error(), set_mime_html(), set_mime_not_modified(), and set_mime_text(). |
|
Definition at line 81 of file cgi_util.cc. Referenced by name_path(). |
|
This sends a formatted block of text to the client, containing version information about various aspects of the server. The arguments allow you to enclose version information about the filter program and the dataset in the message. Either argument (or both) may be omitted, in which case no script or dataset version information will be printed.
Definition at line 106 of file cgi_util.cc. References CRLF, DAP_PROTOCOL_VERSION, and DVR. Referenced by DODSFilter::send_version_info(). |
|
Prints an error message in the Use this instead of the functions in liberrmsg.a in the programs run by the CGIs to report errors so those errors show up in HTTPD's log files.
Definition at line 307 of file cgi_util.cc. Referenced by DODSFilter::print_usage(). |
|
This function accepts a dataset path name, and searches for a matching ancillary data file name with a very specific set of search rules, given here:
directory filename extension same same `.'given given same `.'given same given `.'given given given `.'given Where ``same'' refers to the input dataset pathname, and ``given'' refers to the function arguments.
For example, If you call this function with a dataset name of
/a/data.das /b/data.das /a/ralph.das /b/ralph.das The function will return a string containing the name of the first file in the list that exists, if any.
Definition at line 173 of file cgi_util.cc. References DBG. Referenced by DODSFilter::get_das_last_modified_time(), DODSFilter::get_data_last_modified_time(), DODSFilter::get_dds_last_modified_time(), DODSFilter::read_ancillary_das(), and DODSFilter::read_ancillary_dds(). |
|
Assume that
Definition at line 240 of file cgi_util.cc. References DBG. Referenced by get_user_supplied_docs(). |
|
Look for the override file by taking the dataset name and appending `.ovr' to it. If such a file exists, then read it in and store the contents in
Definition at line 664 of file cgi_util.cc. |
|
Look in the CGI directory (given by
Similarly, to locate the dataset-specific HTML* file it catenates `.html' to
Definition at line 726 of file cgi_util.cc. References find_group_ancillary_file(). |
Here is the call graph for this function:
|
Get the last modified time. Assume
Definition at line 439 of file cgi_util.cc. Referenced by DODSFilter::get_das_last_modified_time(), DODSFilter::get_data_last_modified_time(), DODSFilter::get_dataset_last_modified_time(), and DODSFilter::get_dds_last_modified_time(). |
|
Given a pathname, this function returns just the file name component of the path. That is, given
Definition at line 350 of file cgi_util.cc. References FILE_DELIMITER. |
|
Read the input stream
Definition at line 690 of file cgi_util.cc. References CRLF. |
|
Given a constant pointer to a This function returns the RFC 822 date with the exception that the RFC 1123 modification for four-digit years is implemented.
Definition at line 416 of file cgi_util.cc. Referenced by set_mime_binary(), set_mime_error(), set_mime_html(), set_mime_not_modified(), and set_mime_text(). |
|
Write an HTTP 1.0 response header for our binary response document (i.e., the DataDDS object).
Definition at line 580 of file cgi_util.cc. References CRLF, DAP_PROTOCOL_VERSION, DVR, and rfc822_date(). Referenced by DODSFilter::send_blob(), and DODSFilter::send_data(). |
Here is the call graph for this function:
|
Generate an HTTP 1.0 response header for an Error object.
Definition at line 619 of file cgi_util.cc. References CRLF, DAP_PROTOCOL_VERSION, DVR, rfc822_date(), and version. |
Here is the call graph for this function:
|
Generate an HTTP 1.0 response header for a html document.
Definition at line 531 of file cgi_util.cc. References CRLF, DAP_PROTOCOL_VERSION, DVR, and rfc822_date(). |
Here is the call graph for this function:
|
Use this function to create a response signaling that the target of a conditional get has not been modified relative to the condition given in the request. This will have to be a date until the servers support ETags.
Definition at line 647 of file cgi_util.cc. References CRLF, and rfc822_date(). Referenced by DODSFilter::send_blob(), DODSFilter::send_das(), DODSFilter::send_data(), DODSFilter::send_dds(), and DODSFilter::send_ddx(). |
Here is the call graph for this function:
|
Generate an HTTP 1.0 response header for a text document. This is used when returning a serialized DAS or DDS object.
Definition at line 480 of file cgi_util.cc. References CRLF, DAP_PROTOCOL_VERSION, DVR, and rfc822_date(). Referenced by DODSFilter::send_das(), DODSFilter::send_dds(), and DODSFilter::send_ddx(). |
Here is the call graph for this function: