00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef _mime_util_h
00038 #define _mime_util_h
00039
00040 #ifndef _dds_h
00041 #include "DDS.h"
00042 #endif
00043
00044 #ifndef _object_type_h
00045 #include "ObjectType.h"
00046 #endif
00047
00048 #ifndef _encoding_type_h
00049 #include "EncodingType.h"
00050 #endif
00051
00052 namespace libdap
00053 {
00054
00066
00067 bool do_version(const string &script_ver, const string &dataset_ver);
00068
00069 void ErrMsgT(const string &Msgt);
00070
00071 string name_path(const string &path);
00072
00073 string rfc822_date(const time_t t);
00074
00075 time_t last_modified_time(const string &name);
00077
00089 void set_mime_text(FILE *out, ObjectType type = unknown_type,
00090 const string &version = "", EncodingType enc = x_plain,
00091 const time_t last_modified = 0);
00092 void set_mime_text(ostream &out, ObjectType type = unknown_type,
00093 const string &version = "", EncodingType enc = x_plain,
00094 const time_t last_modified = 0);
00095
00096 void set_mime_html(FILE *out, ObjectType type = unknown_type,
00097 const string &version = "", EncodingType enc = x_plain,
00098 const time_t last_modified = 0);
00099 void set_mime_html(ostream &out, ObjectType type = unknown_type,
00100 const string &version = "", EncodingType enc = x_plain,
00101 const time_t last_modified = 0);
00102
00103 void set_mime_binary(FILE *out, ObjectType type = unknown_type,
00104 const string &version = "", EncodingType enc = x_plain,
00105 const time_t last_modified = 0);
00106 void set_mime_binary(ostream &out, ObjectType type = unknown_type,
00107 const string &version = "", EncodingType enc = x_plain,
00108 const time_t last_modified = 0);
00109
00110 void set_mime_multipart(ostream &out, const string &boundary,
00111 const string &start, ObjectType type = unknown_type,
00112 const string &version = "", EncodingType enc = x_plain,
00113 const time_t last_modified = 0);
00114
00115 void set_mime_ddx_boundary(ostream &out, const string &boundary,
00116 const string &start, ObjectType type = unknown_type,
00117 EncodingType enc = x_plain);
00118
00119 void set_mime_data_boundary(ostream &out, const string &boundary,
00120 const string &cid, ObjectType type = unknown_type,
00121 EncodingType enc = x_plain);
00122
00123 void read_multipart_headers(FILE *in, const string &content_type,
00124 const ObjectType object_type, const string &cid = "");
00125
00126 void set_mime_error(FILE *out, int code = 404,
00127 const string &reason = "Dataset not found",
00128 const string &version = "");
00129 void set_mime_error(ostream &out, int code = 404,
00130 const string &reason = "Dataset not found",
00131 const string &version = "");
00132
00133 void set_mime_not_modified(FILE *out);
00134 void set_mime_not_modified(ostream &out);
00135
00136
00138
00139 ObjectType get_type(const string &value);
00140 ObjectType get_description_type(const string &value);
00141
00142 bool is_boundary(const char *line, const string &boundary);
00143 string cid_to_header_value(const string &cid);
00144 string read_multipart_boundary(FILE *in, const string &boundary = "");
00145 bool remove_mime_header(FILE *in);
00146 string get_next_mime_header(FILE *in);
00147 void parse_mime_header(const string &header, string &name, string &value);
00148
00149 bool found_override(string name, string &doc);
00150
00151 }
00152
00153 #endif // _mime_util_h