libdap++  Updated for version 3.14.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 #include "media_types.h" // Remove when the deprecated stuff comes out of the library. 11/12/13 jhrg
41 
42 #ifndef _object_type_h
43 #include "ObjectType.h"
44 #endif
45 
46 #ifndef _encoding_type_h
47 #include "EncodingType.h"
48 #endif
49 
50 namespace libdap
51 {
52 
69 std::string rfc822_date(const time_t t);
70 time_t last_modified_time(const std::string &name);
71 ObjectType get_description_type(const std::string &value);
72 bool is_boundary(const char *line, const std::string &boundary);
73 std::string cid_to_header_value(const std::string &cid);
74 
75 std::string read_multipart_boundary(std::istream &in, const std::string &boundary = "");
76 
77 void parse_mime_header(const std::string &header, std::string &name, std::string &value);
78 std::string name_path(const std::string &path);
79 std::string get_next_mime_header(std::istream &in);
80 
81 void read_multipart_headers(std::istream &in, const std::string &content_type,
82  const ObjectType object_type, const std::string &cid = "");
83 
84 // For testing only
85 void remove_mime_header(std::istream &in);
86 
87 // All of these are deprecated
88 std::string read_multipart_boundary(FILE *in, const std::string &boundary = "");
89 void read_multipart_headers(FILE *in, const std::string &content_type,
90  const ObjectType object_type, const std::string &cid = "");
91 bool do_version(const std::string &script_ver, const std::string &dataset_ver);
92 void ErrMsgT(const std::string &Msgt);
93 ObjectType get_type(const std::string &value);
94 std::string get_next_mime_header(FILE *in);
95 bool remove_mime_header(FILE *in);
96 
97 #if 0
98 bool found_override(std::string name, std::string &doc);
99 #endif
100 
101 
114 void set_mime_text(FILE *out, ObjectType type = unknown_type,
115  const std::string &version = "", EncodingType enc = x_plain,
116  const time_t last_modified = 0);
117 void set_mime_text(std::ostream &out, ObjectType type = unknown_type,
118  const std::string &version = "", EncodingType enc = x_plain,
119  const time_t last_modified = 0);
120 void set_mime_text(std::ostream &out, ObjectType type = unknown_type,
121  EncodingType enc = x_plain,
122  const time_t last_modified = 0,
123  const std::string &protocol = "");
124 
125 void set_mime_html(FILE *out, ObjectType type = unknown_type,
126  const std::string &version = "", EncodingType enc = x_plain,
127  const time_t last_modified = 0);
128 void set_mime_html(std::ostream &out, ObjectType type = unknown_type,
129  const std::string &version = "", EncodingType enc = x_plain,
130  const time_t last_modified = 0);
131 void set_mime_html(std::ostream &out, ObjectType type = unknown_type,
132  EncodingType enc = x_plain,
133  const time_t last_modified = 0,
134  const std::string &protocol = "");
135 
136 void set_mime_binary(FILE *out, ObjectType type = unknown_type,
137  const std::string &version = "", EncodingType enc = x_plain,
138  const time_t last_modified = 0);
139 void set_mime_binary(std::ostream &out, ObjectType type = unknown_type,
140  const std::string &version = "", EncodingType enc = x_plain,
141  const time_t last_modified = 0);
142 void set_mime_binary(std::ostream &out, ObjectType type = unknown_type,
143  EncodingType enc = x_plain,
144  const time_t last_modified = 0,
145  const std::string &protocol = "");
146 
147 void set_mime_multipart(std::ostream &out, const std::string &boundary,
148  const std::string &start, ObjectType type = unknown_type,
149  const std::string &version = "", EncodingType enc = x_plain,
150  const time_t last_modified = 0);
151 
152 void set_mime_multipart(std::ostream &out, const std::string &boundary,
153  const std::string &start, ObjectType type = unknown_type, EncodingType enc = x_plain,
154  const time_t last_modified = 0, const std::string &protocol = "",
155  const std::string &url = "");
156 
157 void set_mime_ddx_boundary(std::ostream &out, const std::string &boundary,
158  const std::string &start, ObjectType type = unknown_type,
159  EncodingType enc = x_plain);
160 
161 void set_mime_data_boundary(std::ostream &out, const std::string &boundary,
162  const std::string &cid, ObjectType type = unknown_type,
163  EncodingType enc = x_plain);
164 
165 void set_mime_error(FILE *out, int code = 404,
166  const std::string &reason = "Dataset not found",
167  const std::string &version = "");
168 void set_mime_error(std::ostream &out, int code = 404,
169  const std::string &reason = "Dataset not found",
170  const std::string &version = "");
171 
172 void set_mime_not_modified(FILE *out);
173 void set_mime_not_modified(std::ostream &out);
174 
175 
177 
178 } // namespace libdap
179 
180 #endif // _mime_util_h
string get_next_mime_header(FILE *in)
Definition: mime_util.cc:836
void ErrMsgT(const string &Msgt)
Logs an error message.
Definition: mime_util.cc:222
void set_mime_data_boundary(ostream &strm, const string &boundary, const string &cid, ObjectType type, EncodingType enc)
Definition: mime_util.cc:807
time_t last_modified_time(const string &name)
Definition: mime_util.cc:95
string rfc822_date(const time_t t)
Definition: mime_util.cc:156
void read_multipart_headers(FILE *in, const string &content_type, const ObjectType object_type, const string &cid)
Definition: mime_util.cc:993
ObjectType
The type of object in the stream coming from the data server.
Definition: ObjectType.h:58
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:381
void parse_mime_header(const string &header, string &name, string &value)
Definition: mime_util.cc:898
const char * version
Definition: getdap.cc:60
ObjectType get_description_type(const string &value)
Definition: mime_util.cc:339
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:794
ObjectType get_type(const string &value)
Definition: mime_util.cc:326
void set_mime_binary(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:623
string read_multipart_boundary(FILE *in, const string &boundary)
Definition: mime_util.cc:945
void set_mime_error(FILE *out, int code, const string &reason, const string &version)
Definition: mime_util.cc:1087
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:268
bool is_boundary(const char *line, const string &boundary)
Definition: mime_util.cc:927
void set_mime_html(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:509
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:720
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:189