1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * cgiutils.h -- general cgi utilities
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
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.
|
---|
9 | *
|
---|
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 | *
|
---|
24 | *********************************************************************/
|
---|
25 |
|
---|
26 |
|
---|
27 | #ifndef CGIUTILS_H
|
---|
28 | #define CGIUTILS_H
|
---|
29 |
|
---|
30 | #include "gsdlconf.h"
|
---|
31 | #include "text_t.h"
|
---|
32 | #include "cgiargs.h"
|
---|
33 |
|
---|
34 |
|
---|
35 | // convert %xx and + to their appropriate equivalents
|
---|
36 | void decode_cgi_arg (text_t &argstr);
|
---|
37 |
|
---|
38 | // split up the cgi arguments
|
---|
39 | void split_cgi_args (const cgiargsinfoclass &argsinfo, text_t argstr,
|
---|
40 | cgiargsclass &args);
|
---|
41 |
|
---|
42 | // turns any '-' in a cgi argument into "(-)"
|
---|
43 | text_t minus_safe (const text_t &intext);
|
---|
44 |
|
---|
45 | // returns the encoded version of a cgi argument
|
---|
46 | text_t cgi_safe (const text_t &intext);
|
---|
47 |
|
---|
48 | // check_save_conf_str checks the configuration string for
|
---|
49 | // the saved args and makes sure it does not conflict with
|
---|
50 | // the information about the arguments. If an error is encountered
|
---|
51 | // it will return false and the program should not produce any
|
---|
52 | // output.
|
---|
53 | bool check_save_conf_str (const text_t &saveconf,
|
---|
54 | const cgiargsinfoclass &argsinfo,
|
---|
55 | ostream &logout);
|
---|
56 |
|
---|
57 | // create_save_conf_str will create a configuration string
|
---|
58 | // based on the information in argsinfo. This method of configuration
|
---|
59 | // is not recomended as small changes can produce large changes in
|
---|
60 | // the resulting configuration string (for instance a totally different
|
---|
61 | // ordering). Only arguments which "must" be saved are included in
|
---|
62 | // the resulting string.
|
---|
63 | text_t create_save_conf_str (const cgiargsinfoclass &argsinfo,
|
---|
64 | ostream &logout);
|
---|
65 |
|
---|
66 | // expand_compress_args will expand the compressed arguments based
|
---|
67 | // on compressconf placing the results in args if they are not
|
---|
68 | // already defined. If it encounters an error it will return false
|
---|
69 | // and output more information to logout.
|
---|
70 | bool expand_save_args (const cgiargsinfoclass &argsinfo,
|
---|
71 | const text_t &saveconf,
|
---|
72 | cgiargsclass &args,
|
---|
73 | ostream &logout);
|
---|
74 |
|
---|
75 | // adds the default values for those arguments which have not
|
---|
76 | // been specified
|
---|
77 | void add_default_args (const cgiargsinfoclass &argsinfo,
|
---|
78 | cgiargsclass &args,
|
---|
79 | ostream &logout);
|
---|
80 |
|
---|
81 | // compress_save_args will compress the arguments and return
|
---|
82 | // them in compressed_args. If an error was encountered
|
---|
83 | // compressed_args will be set to to "", an error will be
|
---|
84 | // written to logout, and the function will return false.
|
---|
85 | bool compress_save_args (const cgiargsinfoclass &argsinfo,
|
---|
86 | const text_t &saveconf,
|
---|
87 | cgiargsclass &args,
|
---|
88 | text_t &compressed_args,
|
---|
89 | outconvertclass &outconvert,
|
---|
90 | ostream &logout);
|
---|
91 |
|
---|
92 | // args_tounicode converts any arguments which are not in unicode
|
---|
93 | // to unicode using inconvert
|
---|
94 | void args_tounicode (cgiargsclass &args, inconvertclass &inconvert);
|
---|
95 |
|
---|
96 | text_t gsdl_getenv (const text_t &name, text_tmap &fcgienv);
|
---|
97 |
|
---|
98 | #endif
|
---|