[108] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * cgiutils.h -- general cgi utilities
|
---|
| 4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 5 | *
|
---|
[533] | 6 | * A component of the Greenstone digital library software
|
---|
| 7 | * from the New Zealand Digital Library Project at the
|
---|
| 8 | * University of Waikato, New Zealand.
|
---|
[108] | 9 | *
|
---|
[533] | 10 | * This program is free software; you can redistribute it and/or modify
|
---|
| 11 | * it under the terms of the GNU General Public License as published by
|
---|
| 12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | * (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * This program 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
|
---|
| 18 | * GNU General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU General Public License
|
---|
| 21 | * along with this program; if not, write to the Free Software
|
---|
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | *
|
---|
[108] | 24 | *********************************************************************/
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | #ifndef CGIUTILS_H
|
---|
| 28 | #define CGIUTILS_H
|
---|
| 29 |
|
---|
[154] | 30 | #include "gsdlconf.h"
|
---|
[108] | 31 | #include "text_t.h"
|
---|
| 32 | #include "cgiargs.h"
|
---|
| 33 |
|
---|
[12513] | 34 | // parse data obtained through a CGI POST request
|
---|
| 35 | text_t parse_post_data (text_t &content_type, text_t &raw_post_data,
|
---|
| 36 | fileupload_tmap &fileuploads, const text_t &gsdlhome);
|
---|
[154] | 37 |
|
---|
[108] | 38 | // convert %xx and + to their appropriate equivalents
|
---|
| 39 | void decode_cgi_arg (text_t &argstr);
|
---|
| 40 |
|
---|
| 41 | // split up the cgi arguments
|
---|
[776] | 42 | void split_cgi_args (const cgiargsinfoclass &argsinfo, text_t argstr,
|
---|
| 43 | cgiargsclass &args);
|
---|
[108] | 44 |
|
---|
[28841] | 45 | // url-decode selected chars of a given string
|
---|
| 46 | void unsafe_cgi_arg(const text_t &chars_to_decode, text_t &str);
|
---|
| 47 |
|
---|
[2426] | 48 | text_t encode_commas (const text_t &intext);
|
---|
| 49 | text_t decode_commas (const text_t &intext);
|
---|
| 50 |
|
---|
[607] | 51 | // turns any '-' in a cgi argument into "(-)"
|
---|
[13456] | 52 | // set utf8 to true if input is in utf-8, otherwise expects input in unicode
|
---|
| 53 | text_t minus_safe (const text_t &intext, bool utf8);
|
---|
[607] | 54 |
|
---|
[108] | 55 | // returns the encoded version of a cgi argument
|
---|
[13456] | 56 | // the original text should be in utf8
|
---|
| 57 | text_t cgi_safe_utf8 (const text_t &intext);
|
---|
| 58 | // the original text should be in unicode
|
---|
| 59 | text_t cgi_safe_unicode (const text_t &intext);
|
---|
[108] | 60 |
|
---|
[154] | 61 | // check_save_conf_str checks the configuration string for
|
---|
| 62 | // the saved args and makes sure it does not conflict with
|
---|
| 63 | // the information about the arguments. If an error is encountered
|
---|
| 64 | // it will return false and the program should not produce any
|
---|
| 65 | // output.
|
---|
| 66 | bool check_save_conf_str (const text_t &saveconf,
|
---|
| 67 | const cgiargsinfoclass &argsinfo,
|
---|
| 68 | ostream &logout);
|
---|
| 69 |
|
---|
| 70 | // create_save_conf_str will create a configuration string
|
---|
| 71 | // based on the information in argsinfo. This method of configuration
|
---|
| 72 | // is not recomended as small changes can produce large changes in
|
---|
| 73 | // the resulting configuration string (for instance a totally different
|
---|
| 74 | // ordering). Only arguments which "must" be saved are included in
|
---|
| 75 | // the resulting string.
|
---|
| 76 | text_t create_save_conf_str (const cgiargsinfoclass &argsinfo,
|
---|
| 77 | ostream &logout);
|
---|
| 78 |
|
---|
| 79 | // expand_compress_args will expand the compressed arguments based
|
---|
| 80 | // on compressconf placing the results in args if they are not
|
---|
| 81 | // already defined. If it encounters an error it will return false
|
---|
| 82 | // and output more information to logout.
|
---|
| 83 | bool expand_save_args (const cgiargsinfoclass &argsinfo,
|
---|
| 84 | const text_t &saveconf,
|
---|
| 85 | cgiargsclass &args,
|
---|
| 86 | ostream &logout);
|
---|
| 87 |
|
---|
| 88 | // adds the default values for those arguments which have not
|
---|
| 89 | // been specified
|
---|
| 90 | void add_default_args (const cgiargsinfoclass &argsinfo,
|
---|
| 91 | cgiargsclass &args,
|
---|
| 92 | ostream &logout);
|
---|
| 93 |
|
---|
[12513] | 94 | void add_fileupload_args (const cgiargsinfoclass &argsinfo,
|
---|
| 95 | cgiargsclass &args,
|
---|
| 96 | fileupload_tmap &fileuploads,
|
---|
| 97 | ostream &logout);
|
---|
| 98 |
|
---|
[154] | 99 | // compress_save_args will compress the arguments and return
|
---|
| 100 | // them in compressed_args. If an error was encountered
|
---|
| 101 | // compressed_args will be set to to "", an error will be
|
---|
| 102 | // written to logout, and the function will return false.
|
---|
| 103 | bool compress_save_args (const cgiargsinfoclass &argsinfo,
|
---|
| 104 | const text_t &saveconf,
|
---|
| 105 | cgiargsclass &args,
|
---|
| 106 | text_t &compressed_args,
|
---|
[294] | 107 | outconvertclass &outconvert,
|
---|
[154] | 108 | ostream &logout);
|
---|
| 109 |
|
---|
| 110 | // args_tounicode converts any arguments which are not in unicode
|
---|
| 111 | // to unicode using inconvert
|
---|
| 112 | void args_tounicode (cgiargsclass &args, inconvertclass &inconvert);
|
---|
| 113 |
|
---|
[873] | 114 | text_t gsdl_getenv (const text_t &name, text_tmap &fcgienv);
|
---|
| 115 |
|
---|
[108] | 116 | #endif
|
---|