libdap++  Updated for version 3.8.2
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 
66 
67 bool do_version(const string &script_ver, const string &dataset_ver);
68 
69 void ErrMsgT(const string &Msgt);
70 
71 string name_path(const string &path);
72 
73 string rfc822_date(const time_t t);
74 
75 time_t last_modified_time(const string &name);
77 
89 void set_mime_text(FILE *out, ObjectType type = unknown_type,
90  const string &version = "", EncodingType enc = x_plain,
91  const time_t last_modified = 0);
92 void set_mime_text(ostream &out, ObjectType type = unknown_type,
93  const string &version = "", EncodingType enc = x_plain,
94  const time_t last_modified = 0);
95 
96 void set_mime_html(FILE *out, ObjectType type = unknown_type,
97  const string &version = "", EncodingType enc = x_plain,
98  const time_t last_modified = 0);
99 void set_mime_html(ostream &out, ObjectType type = unknown_type,
100  const string &version = "", EncodingType enc = x_plain,
101  const time_t last_modified = 0);
102 
103 void set_mime_binary(FILE *out, ObjectType type = unknown_type,
104  const string &version = "", EncodingType enc = x_plain,
105  const time_t last_modified = 0);
106 void set_mime_binary(ostream &out, ObjectType type = unknown_type,
107  const string &version = "", EncodingType enc = x_plain,
108  const time_t last_modified = 0);
109 
110 void set_mime_multipart(ostream &out, const string &boundary,
111  const string &start, ObjectType type = unknown_type,
112  const string &version = "", EncodingType enc = x_plain,
113  const time_t last_modified = 0);
114 
115 void set_mime_ddx_boundary(ostream &out, const string &boundary,
116  const string &start, ObjectType type = unknown_type,
117  EncodingType enc = x_plain);
118 
119 void set_mime_data_boundary(ostream &out, const string &boundary,
120  const string &cid, ObjectType type = unknown_type,
121  EncodingType enc = x_plain);
122 
123 void read_multipart_headers(FILE *in, const string &content_type,
124  const ObjectType object_type, const string &cid = "");
125 
126 void set_mime_error(FILE *out, int code = 404,
127  const string &reason = "Dataset not found",
128  const string &version = "");
129 void set_mime_error(ostream &out, int code = 404,
130  const string &reason = "Dataset not found",
131  const string &version = "");
132 
133 void set_mime_not_modified(FILE *out);
134 void set_mime_not_modified(ostream &out);
135 
136 
138 
139 ObjectType get_type(const string &value); // deprecated
140 ObjectType get_description_type(const string &value);
141 
142 bool is_boundary(const char *line, const string &boundary);
143 string cid_to_header_value(const string &cid);
144 string read_multipart_boundary(FILE *in, const string &boundary = "");
145 bool remove_mime_header(FILE *in);
146 string get_next_mime_header(FILE *in);
147 void parse_mime_header(const string &header, string &name, string &value);
148 
149 bool found_override(string name, string &doc);
150 
151 } // namespace libdap
152 
153 #endif // _mime_util_h
void ErrMsgT(const string &Msgt)
Logs an error message.
Definition: mime_util.cc:141
void set_mime_data_boundary(ostream &strm, const string &boundary, const string &cid, ObjectType type, EncodingType enc)
Definition: mime_util.cc:702
time_t last_modified_time(const string &name)
Definition: mime_util.cc:266
void read_multipart_headers(FILE *in, const string &content_type, const ObjectType object_type, const string &cid)
Definition: mime_util.cc:832
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:872
void set_mime_text(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:375
bool found_override(string name, string &doc)
Definition: mime_util.cc:983
void parse_mime_header(const string &header, string &name, string &value)
Definition: mime_util.cc:758
const char * version
Definition: getdap.cc:64
ObjectType get_description_type(const string &value)
Definition: mime_util.cc:333
bool remove_mime_header(FILE *in)
Read and discard the MIME header of the stream in.
Definition: mime_util.cc:1010
void set_mime_ddx_boundary(ostream &strm, const string &boundary, const string &cid, ObjectType type, EncodingType enc)
Definition: mime_util.cc:689
ObjectType get_type(const string &value)
Definition: mime_util.cc:301
string get_next_mime_header(FILE *in)
Definition: mime_util.cc:730
void set_mime_binary(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:578
string read_multipart_boundary(FILE *in, const string &boundary)
Definition: mime_util.cc:798
void set_mime_error(FILE *out, int code, const string &reason, const string &version)
Definition: mime_util.cc:894
string rfc822_date(const time_t t)
Definition: mime_util.cc:247
void set_mime_not_modified(FILE *out)
Send a `Not Modified&#39; response.
Definition: mime_util.cc:950
string name_path(const string &path)
Returns the filename portion of a pathname.
Definition: mime_util.cc:178
bool is_boundary(const char *line, const string &boundary)
Definition: mime_util.cc:781
void set_mime_html(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:481
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:655
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:109