libdap  Updated for version 3.20.6
libdap4 is an implementation of OPeNDAP's DAP protocol.
mime_util.h
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 #include <string>
51 
52 namespace libdap
53 {
54 
71 std::string rfc822_date(const time_t t);
72 time_t last_modified_time(const std::string &name);
73 ObjectType get_description_type(const std::string &value);
74 bool is_boundary(const char *line, const std::string &boundary);
75 std::string cid_to_header_value(const std::string &cid);
76 
77 std::string read_multipart_boundary(std::istream &in, const std::string &boundary = "");
78 
79 void parse_mime_header(const std::string &header, std::string &name, std::string &value);
80 std::string name_path(const std::string &path);
81 std::string get_next_mime_header(std::istream &in);
82 
83 void read_multipart_headers(std::istream &in, const std::string &content_type,
84  const ObjectType object_type, const std::string &cid = "");
85 
86 // For testing only
87 void remove_mime_header(std::istream &in);
88 
89 // All of these are deprecated
90 std::string read_multipart_boundary(FILE *in, const std::string &boundary = "");
91 void read_multipart_headers(FILE *in, const std::string &content_type,
92  const ObjectType object_type, const std::string &cid = "");
93 bool do_version(const std::string &script_ver, const std::string &dataset_ver);
94 void ErrMsgT(const std::string &Msgt);
95 ObjectType get_type(const std::string &value);
96 std::string get_next_mime_header(FILE *in);
97 bool remove_mime_header(FILE *in);
98 
99 #if 0
100 bool found_override(std::string name, std::string &doc);
101 #endif
102 
103 
116 void set_mime_text(FILE *out, ObjectType type = unknown_type,
117  const std::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  const std::string &version = "", EncodingType enc = x_plain,
121  const time_t last_modified = 0);
122 void set_mime_text(std::ostream &out, ObjectType type = unknown_type,
123  EncodingType enc = x_plain,
124  const time_t last_modified = 0,
125  const std::string &protocol = "");
126 
127 void set_mime_html(FILE *out, ObjectType type = unknown_type,
128  const std::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  const std::string &version = "", EncodingType enc = x_plain,
132  const time_t last_modified = 0);
133 void set_mime_html(std::ostream &out, ObjectType type = unknown_type,
134  EncodingType enc = x_plain,
135  const time_t last_modified = 0,
136  const std::string &protocol = "");
137 
138 void set_mime_binary(FILE *out, ObjectType type = unknown_type,
139  const std::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  const std::string &version = "", EncodingType enc = x_plain,
143  const time_t last_modified = 0);
144 void set_mime_binary(std::ostream &out, ObjectType type = unknown_type,
145  EncodingType enc = x_plain,
146  const time_t last_modified = 0,
147  const std::string &protocol = "");
148 
149 void set_mime_multipart(std::ostream &out, const std::string &boundary,
150  const std::string &start, ObjectType type = unknown_type,
151  const std::string &version = "", EncodingType enc = x_plain,
152  const time_t last_modified = 0);
153 
154 void set_mime_multipart(std::ostream &out, const std::string &boundary,
155  const std::string &start, ObjectType type = unknown_type, EncodingType enc = x_plain,
156  const time_t last_modified = 0, const std::string &protocol = "",
157  const std::string &url = "");
158 
159 void set_mime_ddx_boundary(std::ostream &out, const std::string &boundary,
160  const std::string &start, ObjectType type = unknown_type,
161  EncodingType enc = x_plain);
162 
163 void set_mime_data_boundary(std::ostream &out, const std::string &boundary,
164  const std::string &cid, ObjectType type = unknown_type,
165  EncodingType enc = x_plain);
166 
167 void set_mime_error(FILE *out, int code = 404,
168  const std::string &reason = "Dataset not found",
169  const std::string &version = "");
170 void set_mime_error(std::ostream &out, int code = 404,
171  const std::string &reason = "Dataset not found",
172  const std::string &version = "");
173 
174 void set_mime_not_modified(FILE *out);
175 void set_mime_not_modified(std::ostream &out);
176 
177 
179 
180 } // namespace libdap
181 
182 #endif // _mime_util_h
string get_next_mime_header(FILE *in)
Definition: mime_util.cc:838
void ErrMsgT(const string &Msgt)
Logs an error message.
Definition: mime_util.cc:222
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:1005
string name_path(const string &path)
Returns the filename portion of a pathname.
Definition: mime_util.cc:268
string read_multipart_boundary(FILE *in, const string &boundary)
Definition: mime_util.cc:959
ObjectType
The type of object in the stream coming from the data server.
Definition: ObjectType.h:58
void set_mime_text(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:381
top level DAP object to house generic methods
Definition: AISConnect.cc:30
void parse_mime_header(const string &header, string &name, string &value)
Definition: mime_util.cc:912
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:1212
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
void set_mime_error(FILE *out, int code, const string &reason, const string &version)
Definition: mime_util.cc:1100
string cid_to_header_value(const string &cid)
Definition: mime_util.cc:1077
void set_mime_not_modified(FILE *out)
Send a `Not Modified&#39; response.
Definition: mime_util.cc:1145
bool is_boundary(const char *line, const string &boundary)
Definition: mime_util.cc:941
void set_mime_html(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:509
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