libdap++  Updated for version 3.11.7
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 
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 string read_multipart_boundary(FILE *in, const string &boundary = "");
77 void parse_mime_header(const string &header, string &name, string &value);
78 string name_path(const string &path);
79 
80 // All of these are deprecated
81 bool do_version(const string &script_ver, const string &dataset_ver);
82 void ErrMsgT(const string &Msgt);
83 ObjectType get_type(const string &value); // deprecated
84 bool remove_mime_header(FILE *in);
85 string get_next_mime_header(FILE *in);
86 #if 0
87 bool found_override(string name, string &doc);
88 #endif
89 
90 
103 void set_mime_text(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_text(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_html(FILE *out, ObjectType type = unknown_type,
111  const string &version = "", EncodingType enc = x_plain,
112  const time_t last_modified = 0);
113 void set_mime_html(ostream &out, ObjectType type = unknown_type,
114  const string &version = "", EncodingType enc = x_plain,
115  const time_t last_modified = 0);
116 
117 void set_mime_binary(FILE *out, ObjectType type = unknown_type,
118  const string &version = "", EncodingType enc = x_plain,
119  const time_t last_modified = 0);
120 void set_mime_binary(ostream &out, ObjectType type = unknown_type,
121  const string &version = "", EncodingType enc = x_plain,
122  const time_t last_modified = 0);
123 
124 void set_mime_multipart(ostream &out, const string &boundary,
125  const string &start, ObjectType type = unknown_type,
126  const string &version = "", EncodingType enc = x_plain,
127  const time_t last_modified = 0);
128 
129 void set_mime_ddx_boundary(ostream &out, const string &boundary,
130  const string &start, ObjectType type = unknown_type,
131  EncodingType enc = x_plain);
132 
133 void set_mime_data_boundary(ostream &out, const string &boundary,
134  const string &cid, ObjectType type = unknown_type,
135  EncodingType enc = x_plain);
136 
137 void read_multipart_headers(FILE *in, const string &content_type,
138  const ObjectType object_type, const string &cid = "");
139 
140 void set_mime_error(FILE *out, int code = 404,
141  const string &reason = "Dataset not found",
142  const string &version = "");
143 void set_mime_error(ostream &out, int code = 404,
144  const string &reason = "Dataset not found",
145  const string &version = "");
146 
147 void set_mime_not_modified(FILE *out);
148 void set_mime_not_modified(ostream &out);
149 
150 
152 
153 } // namespace libdap
154 
155 #endif // _mime_util_h
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:708
time_t last_modified_time(const string &name)
Definition: mime_util.cc:98
void read_multipart_headers(FILE *in, const string &content_type, const ObjectType object_type, const string &cid)
Definition: mime_util.cc:844
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:885
void set_mime_text(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:376
void parse_mime_header(const string &header, string &name, string &value)
Definition: mime_util.cc:765
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:1034
void set_mime_ddx_boundary(ostream &strm, const string &boundary, const string &cid, ObjectType type, EncodingType enc)
Definition: mime_util.cc:695
ObjectType get_type(const string &value)
Definition: mime_util.cc:301
string get_next_mime_header(FILE *in)
Definition: mime_util.cc:737
void set_mime_binary(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:583
string read_multipart_boundary(FILE *in, const string &boundary)
Definition: mime_util.cc:810
void set_mime_error(FILE *out, int code, const string &reason, const string &version)
Definition: mime_util.cc:909
string rfc822_date(const time_t t)
Definition: mime_util.cc:159
void set_mime_not_modified(FILE *out)
Send a `Not Modified' response.
Definition: mime_util.cc:968
string name_path(const string &path)
Returns the filename portion of a pathname.
Definition: mime_util.cc:259
bool is_boundary(const char *line, const string &boundary)
Definition: mime_util.cc:792
void set_mime_html(FILE *out, ObjectType type, const string &ver, EncodingType enc, const time_t last_modified)
Definition: mime_util.cc:484
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:661
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