libdap++  Updated for version 3.12.0
mime_util.h
Go to the documentation of this file.
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
5 // Access Protocol.
6 
7 // Copyright (c) 2002,2003 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 // (c) COPYRIGHT URI/MIT 1995-1999
27 // Please read the full copyright statement in the file COPYRIGHT_URI.
28 //
29 // Authors:
30 // jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
31 // reza Reza Nekovei <reza@intcomm.net>
32 
33 // External definitions for utility functions used by servers.
34 //
35 // 2/22/95 jhrg
36 
37 #ifndef _mime_util_h
38 #define _mime_util_h
39 
40 #ifndef _dds_h
41 #include "DDS.h"
42 #endif
43 
44 #ifndef _object_type_h
45 #include "ObjectType.h"
46 #endif
47 
48 #ifndef _encoding_type_h
49 #include "EncodingType.h"
50 #endif
51 
52 namespace libdap
53 {
54 
71 string rfc822_date(const time_t t);
72 time_t last_modified_time(const string &name);
73 ObjectType get_description_type(const string &value);
74 bool is_boundary(const char *line, const string &boundary);
75 string cid_to_header_value(const string &cid);
76 
77 string read_multipart_boundary(istream &in, const string &boundary = "");
78 
79 void parse_mime_header(const string &header, string &name, string &value);
80 string name_path(const string &path);
81 string get_next_mime_header(istream &in);
82 
83 void read_multipart_headers(istream &in, const string &content_type,
84  const ObjectType object_type, const string &cid = "");
85 
86 // All of these are deprecated
87 string read_multipart_boundary(FILE *in, const string &boundary = "");
88 void read_multipart_headers(FILE *in, const string &content_type,
89  const ObjectType object_type, const string &cid = "");
90 bool do_version(const string &script_ver, const string &dataset_ver);
91 void ErrMsgT(const string &Msgt);
92 ObjectType get_type(const string &value);
93 bool remove_mime_header(FILE *in);
94 string get_next_mime_header(FILE *in);
95 
96 #if 0
97 bool found_override(string name, string &doc);
98 #endif
99 
100 
113 void set_mime_text(FILE *out, ObjectType type = unknown_type,
114  const string &version = "", EncodingType enc = x_plain,
115  const time_t last_modified = 0);
116 void set_mime_text(ostream &out, ObjectType type = unknown_type,
117  const string &version = "", EncodingType enc = x_plain,
118  const time_t last_modified = 0);
119 void set_mime_text(std::ostream &out, ObjectType type = unknown_type,
120  EncodingType enc = x_plain,
121  const time_t last_modified = 0,
122  const std::string &protocol = "");
123 
124 void set_mime_html(FILE *out, ObjectType type = unknown_type,
125  const string &version = "", EncodingType enc = x_plain,
126  const time_t last_modified = 0);
127 void set_mime_html(ostream &out, ObjectType type = unknown_type,
128  const string &version = "", EncodingType enc = x_plain,
129  const time_t last_modified = 0);
130 void set_mime_html(std::ostream &out, ObjectType type = unknown_type,
131  EncodingType enc = x_plain,
132  const time_t last_modified = 0,
133  const std::string &protocol = "");
134 
135 void set_mime_binary(FILE *out, ObjectType type = unknown_type,
136  const string &version = "", EncodingType enc = x_plain,
137  const time_t last_modified = 0);
138 void set_mime_binary(ostream &out, ObjectType type = unknown_type,
139  const string &version = "", EncodingType enc = x_plain,
140  const time_t last_modified = 0);
141 void set_mime_binary(std::ostream &out, ObjectType type = unknown_type,
142  EncodingType enc = x_plain,
143  const time_t last_modified = 0,
144  const std::string &protocol = "");
145 
146 void set_mime_multipart(ostream &out, const string &boundary,
147  const string &start, ObjectType type = unknown_type,
148  const string &version = "", EncodingType enc = x_plain,
149  const time_t last_modified = 0);
150 
151 void set_mime_multipart(std::ostream &out, const std::string &boundary,
152  const std::string &start, ObjectType type = unknown_type, EncodingType enc = x_plain,
153  const time_t last_modified = 0, const std::string &protocol = "",
154  const std::string &url = "");
155 
156 void set_mime_ddx_boundary(ostream &out, const string &boundary,
157  const string &start, ObjectType type = unknown_type,
158  EncodingType enc = x_plain);
159 
160 void set_mime_data_boundary(ostream &out, const string &boundary,
161  const string &cid, ObjectType type = unknown_type,
162  EncodingType enc = x_plain);
163 
164 void set_mime_error(FILE *out, int code = 404,
165  const string &reason = "Dataset not found",
166  const string &version = "");
167 void set_mime_error(ostream &out, int code = 404,
168  const string &reason = "Dataset not found",
169  const string &version = "");
170 
171 void set_mime_not_modified(FILE *out);
172 void set_mime_not_modified(ostream &out);
173 
174 
176 
177 } // namespace libdap
178 
179 #endif // _mime_util_h
void ErrMsgT(const string &Msgt)
Logs an error message.
Definition: mime_util.cc:220
void set_mime_data_boundary(ostream &strm, const string &boundary, const string &cid, ObjectType type, EncodingType enc)
Definition: mime_util.cc:808
time_t last_modified_time(const string &name)
Definition: mime_util.cc:93
void read_multipart_headers(FILE *in, const string &content_type, const ObjectType object_type, const string &cid)
Definition: mime_util.cc:992
ObjectType
The type of object in the stream coming from the data server.
Definition: ObjectType.h:57
string cid_to_header_value(const string &cid)
Definition: mime_util.cc:1064
void set_mime_text(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:382
void parse_mime_header(const string &header, string &name, string &value)
Definition: mime_util.cc:899
const char * version
Definition: getdap.cc:60
ObjectType get_description_type(const string &value)
Definition: mime_util.cc:340
bool remove_mime_header(FILE *in)
Read and discard the MIME header of the stream in.
Definition: mime_util.cc:1199
void set_mime_ddx_boundary(ostream &strm, const string &boundary, const string &cid, ObjectType type, EncodingType enc)
Definition: mime_util.cc:795
ObjectType get_type(const string &value)
Definition: mime_util.cc:308
string get_next_mime_header(FILE *in)
Definition: mime_util.cc:837
void set_mime_binary(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:624
string read_multipart_boundary(FILE *in, const string &boundary)
Definition: mime_util.cc:944
void set_mime_error(FILE *out, int code, const string &reason, const string &version)
Definition: mime_util.cc:1087
string rfc822_date(const time_t t)
Definition: mime_util.cc:154
void set_mime_not_modified(FILE *out)
Send a `Not Modified' response.
Definition: mime_util.cc:1132
string name_path(const string &path)
Returns the filename portion of a pathname.
Definition: mime_util.cc:266
bool is_boundary(const char *line, const string &boundary)
Definition: mime_util.cc:926
void set_mime_html(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:510
void set_mime_multipart(ostream &strm, const string &boundary, const string &start, ObjectType type, const string &version, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:721
EncodingType
The type of encoding used on the current stream.
Definition: EncodingType.h:48
bool do_version(const string &script_ver, const string &dataset_ver)
Send a version number.
Definition: mime_util.cc:187