libdap  Updated for version 3.17.0
mime_util.h
00001 
00002 // -*- mode: c++; c-basic-offset:4 -*-
00003 
00004 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
00005 // Access Protocol.
00006 
00007 // Copyright (c) 2002,2003 OPeNDAP, Inc.
00008 // Author: James Gallagher <jgallagher@opendap.org>
00009 //
00010 // This library is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU Lesser General Public
00012 // License as published by the Free Software Foundation; either
00013 // version 2.1 of the License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023 //
00024 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
00025 
00026 // (c) COPYRIGHT URI/MIT 1995-1999
00027 // Please read the full copyright statement in the file COPYRIGHT_URI.
00028 //
00029 // Authors:
00030 //      jhrg,jimg       James Gallagher <jgallagher@gso.uri.edu>
00031 //      reza            Reza Nekovei <reza@intcomm.net>
00032 
00033 // External definitions for utility functions used by servers.
00034 //
00035 // 2/22/95 jhrg
00036 
00037 #ifndef _mime_util_h
00038 #define _mime_util_h
00039 
00040 #include "media_types.h"        // Remove when the deprecated stuff comes out of the library. 11/12/13 jhrg
00041 
00042 #ifndef _object_type_h
00043 #include "ObjectType.h"
00044 #endif
00045 
00046 #ifndef _encoding_type_h
00047 #include "EncodingType.h"
00048 #endif
00049 
00050 #include <string>
00051 
00052 namespace libdap
00053 {
00054 
00071 std::string rfc822_date(const time_t t);
00072 time_t last_modified_time(const std::string &name);
00073 ObjectType get_description_type(const std::string &value);
00074 bool is_boundary(const char *line, const std::string &boundary);
00075 std::string cid_to_header_value(const std::string &cid);
00076 
00077 std::string read_multipart_boundary(std::istream &in, const std::string &boundary = "");
00078 
00079 void parse_mime_header(const std::string &header, std::string &name, std::string &value);
00080 std::string name_path(const std::string &path);
00081 std::string get_next_mime_header(std::istream &in);
00082 
00083 void read_multipart_headers(std::istream &in, const std::string &content_type,
00084         const ObjectType object_type, const std::string &cid = "");
00085 
00086 // For testing only
00087 void remove_mime_header(std::istream &in);
00088 
00089 // All of these are deprecated
00090 std::string read_multipart_boundary(FILE *in, const std::string &boundary = "");
00091 void read_multipart_headers(FILE *in, const std::string &content_type,
00092         const ObjectType object_type, const std::string &cid = "");
00093 bool do_version(const std::string &script_ver, const std::string &dataset_ver);
00094 void ErrMsgT(const std::string &Msgt);
00095 ObjectType get_type(const std::string &value);
00096 std::string get_next_mime_header(FILE *in);
00097 bool remove_mime_header(FILE *in);
00098 
00099 #if 0
00100 bool found_override(std::string name, std::string &doc);
00101 #endif
00102 
00103 
00116 void set_mime_text(FILE *out, ObjectType type = unknown_type,
00117                    const std::string &version = "", EncodingType enc = x_plain,
00118                    const time_t last_modified = 0);
00119 void set_mime_text(std::ostream &out, ObjectType type = unknown_type,
00120                    const std::string &version = "", EncodingType enc = x_plain,
00121                    const time_t last_modified = 0);
00122 void set_mime_text(std::ostream &out, ObjectType type = unknown_type,
00123                    EncodingType enc = x_plain,
00124                    const time_t last_modified = 0,
00125                    const std::string &protocol = "");
00126 
00127 void set_mime_html(FILE *out, ObjectType type = unknown_type,
00128                    const std::string &version = "", EncodingType enc = x_plain,
00129                    const time_t last_modified = 0);
00130 void set_mime_html(std::ostream &out, ObjectType type = unknown_type,
00131                    const std::string &version = "", EncodingType enc = x_plain,
00132                    const time_t last_modified = 0);
00133 void set_mime_html(std::ostream &out, ObjectType type = unknown_type,
00134                    EncodingType enc = x_plain,
00135                    const time_t last_modified = 0,
00136                    const std::string &protocol = "");
00137 
00138 void set_mime_binary(FILE *out, ObjectType type = unknown_type,
00139                      const std::string &version = "", EncodingType enc = x_plain,
00140                      const time_t last_modified = 0);
00141 void set_mime_binary(std::ostream &out, ObjectType type = unknown_type,
00142                      const std::string &version = "", EncodingType enc = x_plain,
00143                      const time_t last_modified = 0);
00144 void set_mime_binary(std::ostream &out, ObjectType type = unknown_type,
00145                      EncodingType enc = x_plain,
00146                      const time_t last_modified = 0,
00147                      const std::string &protocol = "");
00148 
00149 void set_mime_multipart(std::ostream &out, const std::string &boundary,
00150         const std::string &start, ObjectType type = unknown_type,
00151         const std::string &version = "", EncodingType enc = x_plain,
00152         const time_t last_modified = 0);
00153 
00154 void set_mime_multipart(std::ostream &out, const std::string &boundary,
00155         const std::string &start, ObjectType type = unknown_type, EncodingType enc = x_plain,
00156         const time_t last_modified = 0, const std::string &protocol = "",
00157         const std::string &url = "");
00158 
00159 void set_mime_ddx_boundary(std::ostream &out, const std::string &boundary,
00160         const std::string &start, ObjectType type = unknown_type,
00161         EncodingType enc = x_plain);
00162 
00163 void set_mime_data_boundary(std::ostream &out, const std::string &boundary,
00164         const std::string &cid, ObjectType type = unknown_type,
00165         EncodingType enc = x_plain);
00166 
00167 void set_mime_error(FILE *out, int code = 404,
00168                     const std::string &reason = "Dataset not found",
00169                     const std::string &version = "");
00170 void set_mime_error(std::ostream &out, int code = 404,
00171                     const std::string &reason = "Dataset not found",
00172                     const std::string &version = "");
00173 
00174 void set_mime_not_modified(FILE *out);
00175 void set_mime_not_modified(std::ostream &out);
00176 
00177 
00179 
00180 } // namespace libdap
00181 
00182 #endif // _mime_util_h