Changeset 154
- Timestamp:
- 1999-02-08T14:28:01+13:00 (25 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/cgiargs.cpp
r150 r154 12 12 /* 13 13 $Log$ 14 Revision 1.5 1999/02/08 01:28:00 rjmcnab 15 Got the receptionist producing something using the statusaction. 16 14 17 Revision 1.4 1999/02/05 10:42:41 rjmcnab 15 18 … … 134 137 // processing with the arguments should be done if this happens 135 138 // as the results will be meaningless. 136 bool cgiargsinfoclass::addarginfo (ostream &logout, const cgiarginfo &info) {139 bool cgiargsinfoclass::addarginfo (ostream *logout, const cgiarginfo &info) { 137 140 outconvertclass text_t2ascii; 138 141 … … 144 147 145 148 if (orginfo->longname != info.longname) { 146 logout << text_t2ascii << "Error: cgi argument name clash for argument \"" 147 << info.shortname << "\".\nOne long name was\n \"" << orginfo->longname 148 << "\"\nand the other was\n \"" << info.longname << "\".\n\n"; 149 if (logout != NULL) { 150 (*logout) << text_t2ascii << "Error: cgi argument name clash for argument \"" 151 << info.shortname << "\".\nOne long name was\n \"" << orginfo->longname 152 << "\"\nand the other was\n \"" << info.longname << "\".\n\n"; 153 } 149 154 return false; // found a clash 150 155 } 151 156 152 157 if (orginfo->multiplechar != info.multiplechar) { 153 logout << text_t2ascii << "Error: cgi argument \"" << info.shortname 154 << "\" was given as being a single character option\n" 155 << "and a multiple character option.\n\n"; 158 if (logout != NULL) { 159 (*logout) << text_t2ascii << "Error: cgi argument \"" << info.shortname 160 << "\" was given as being a single character option\n" 161 << "and a multiple character option.\n\n"; 162 } 156 163 return false; // found a clash 157 164 } 158 165 159 166 if (!info.multiplechar && info.argdefault.size() > 1) { 160 logout << text_t2ascii << "Error: cgi argument \"" << info.shortname 161 << "\" was defined as being a single character option\n" 162 << "but a multiple character default was given.\n\n"; 167 if (logout != NULL) { 168 (*logout) << text_t2ascii << "Error: cgi argument \"" << info.shortname 169 << "\" was defined as being a single character option\n" 170 << "but a multiple character default was given.\n\n"; 171 } 163 172 return false; // found a problem 164 173 } … … 169 178 (orginfo->savedarginfo==cgiarginfo::must && 170 179 info.savedarginfo==cgiarginfo::mustnot)) { 171 logout << text_t2ascii << "Error: it was specified that cgi argument \"" 172 << info.shortname << "\" should be saved in the state\n" 173 << "information and that it should not be save in the state information.\n\n"; 180 if (logout != NULL) { 181 (*logout) << text_t2ascii << "Error: it was specified that cgi argument \"" 182 << info.shortname << "\" should be saved in the state\n" 183 << "information and that it should not be save in the state information.\n\n"; 184 } 174 185 return false; // found a clash 175 186 } … … 189 200 } 190 201 191 bool cgiargsinfoclass::addarginfo (ostream &logout, const cgiargsinfoclass &info) {202 bool cgiargsinfoclass::addarginfo (ostream *logout, const cgiargsinfoclass &info) { 192 203 const_iterator here = info.begin (); 193 204 const_iterator end = info.end (); … … 217 228 218 229 219 // utilities related to cgi arguments220 221 222 static text_t::const_iterator get_next_save_arg (text_t::const_iterator first,223 text_t::const_iterator last,224 text_t &argname) {225 first = getdelimitstr (first, last, '-', argname);226 return first;227 }228 229 230 231 232 233 // check_save_conf_str checks the configuration string for234 // the saved args and makes sure it does not conflict with235 // the information about the arguments. If an error is encountered236 // it will return false and the program should not produce any237 // output.238 bool check_save_conf_str (const text_t &saveconf,239 const cgiargsinfoclass &argsinfo,240 ostream &logout) {241 outconvertclass text_t2ascii;242 243 text_tset argsset;244 text_t::const_iterator saveconfhere = saveconf.begin ();245 text_t::const_iterator saveconfend = saveconf.end ();246 text_t argname;247 const cgiarginfo *info;248 249 // first check to make sure all saved arguments can be saved250 251 while (saveconfhere != saveconfend) {252 saveconfhere = get_next_save_arg (saveconfhere, saveconfend, argname);253 254 if (!argname.empty()) {255 // save the argument name for later256 argsset.insert (argname);257 258 // check the argument259 info = argsinfo.getarginfo (argname);260 if (info == NULL) {261 logout << text_t2ascii << "Error: the cgi argument \"" << argname262 << "\" is used in the configuration string for the\n"263 << "saved arguments but does not exist as a valid argument.\n\n";264 return false;265 }266 if (info->savedarginfo == cgiarginfo::mustnot) {267 logout << text_t2ascii << "Error: the cgi argument \"" << argname268 << "\" is used in the configuration string for the\n"269 << "saved arguments but has been specified as an argument whose\n"270 << "state must not be saved.\n\n";271 return false;272 }273 }274 }275 276 277 // next check that all saved arguments that should be saved278 // are saved279 cgiargsinfoclass::const_iterator argsinfohere = argsinfo.begin ();280 cgiargsinfoclass::const_iterator argsinfoend = argsinfo.end ();281 282 while (argsinfohere != argsinfoend) {283 if (((*argsinfohere).second.savedarginfo == cgiarginfo::must) &&284 (argsset.find((*argsinfohere).second.shortname) == argsset.end())) {285 logout << text_t2ascii << "Error: the cgi argument \""286 << (*argsinfohere).second.shortname << "\" was specified as needing to\n"287 << "be save but was not listed in the saved arguments.\n\n";288 return false;289 }290 291 argsinfohere++;292 }293 294 return true; // made it, no clashes295 }296 297 298 299 // create_save_conf_str will create a configuration string300 // based on the information in argsinfo. This method of configuration301 // is not recomended as small changes can produce large changes in302 // the resulting configuration string (for instance a totally different303 // ordering)304 text_t create_save_conf_str (const cgiargsinfoclass &argsinfo,305 ostream &logout);306 307 // expand_save_args will expand the saved arguments based308 // on saveconf placing the results in args if they are not309 // already defined. If it encounters an error it will return false310 // and output more information to logout.311 bool expand_save_args (const text_t &saveconf,312 cgiargsclass &args,313 ostream &logout);314 315 // adds the default values for those arguments which have not316 // been specified317 void add_default_args (const cgiargsinfoclass &argsinfo,318 cgiargsclass &args,319 ostream &logout);320 -
trunk/gsdl/src/recpt/cgiargs.h
r150 r154 33 33 #endif 34 34 35 36 // response_t is used to define what type of cgi header 37 // should be produced 38 enum response_t {location, content}; 35 39 36 40 … … 77 81 // setdefaultarg, setdefaultintarg, and setdefaultcarg will 78 82 // only set the argument if it is not already set 79 // getargs NULLsif there isn't an entry with83 // getargs returns NULL if there isn't an entry with 80 84 // 'key' already defined, getintarg returns 0 if there wasn't an 81 85 // entry with 'key' defined and operator[] returns "" if … … 114 118 115 119 // defaultstatus_t indicates how good the default is when different 116 // defaults are given for one argument. "weak" is a basic guess that doesn't 117 // hold much weight, "good" is a better guess, "config" was a default 120 // defaults are given for one argument. "none" means there is no default 121 // (a default might be given elsewhere). "weak" is a basic guess that 122 // doesn't hold much weight, "good" is a better guess, "config" was a default 118 123 // given in a configuration file, and "imperative" means it must not 119 124 // be overriden at any costs (unless there is another "imperative"...) 120 // Note: I assume that the comparison weak < good < config < imperative125 // Note: I assume that the comparison none < weak < good < config < imperative 121 126 // holds :-/ 122 enum defaultstatus_t { weak, good, config, imperative};127 enum defaultstatus_t {none, weak, good, config, imperative}; 123 128 124 129 defaultstatus_t defaultstatus; … … 178 183 // processing with the arguments should be done if this happens 179 184 // as the results will be meaningless. 180 bool addarginfo (ostream &logout, const cgiarginfo &info);181 bool addarginfo (ostream &logout, const cgiargsinfoclass &info);185 bool addarginfo (ostream *logout, const cgiarginfo &info); 186 bool addarginfo (ostream *logout, const cgiargsinfoclass &info); 182 187 183 188 cgiarginfo *getarginfo (const text_t &key); … … 187 192 188 193 189 190 // utilities related to cgi arguments191 192 // check_compress_conf_str checks the configuration string for193 // the compressed args and makes sure it does not conflict with194 // the information about the arguments. If an error is encountered195 // it will return false and the program should not produce any196 // output.197 bool check_compress_conf_str (const text_t &compressconf,198 const cgiargsinfoclass &argsinfo,199 ostream &logout);200 201 // create_compress_conf_str will create a configuration string202 // based on the information in argsinfo. This method of configuration203 // is not recomended as small changes can produce large changes in204 // the resulting configuration string (for instance a totally different205 // ordering)206 text_t create_compress_conf_str (const cgiargsinfoclass &argsinfo,207 ostream &logout);208 209 // expand_compress_args will expand the compressed arguments based210 // on compressconf placing the results in args if they are not211 // already defined. If it encounters an error it will return false212 // and output more information to logout.213 bool expand_compress_args (const text_t &compressconf,214 cgiargsclass &args,215 ostream &logout);216 217 // adds the default values for those arguments which have not218 // been specified219 void add_default_args (const cgiargsinfoclass &argsinfo,220 cgiargsclass &args,221 ostream &logout);222 223 224 194 #endif -
trunk/gsdl/src/recpt/cgiutils.h
r108 r154 14 14 #define CGIUTILS_H 15 15 16 #include "gsdlconf.h" 16 17 #include "text_t.h" 17 18 #include "cgiargs.h" 19 18 20 19 21 // convert %xx and + to their appropriate equivalents … … 21 23 22 24 // split up the cgi arguments 23 void parse_cgi_args (text_t argstr, cgiargsclass &args);25 void split_cgi_args (text_t argstr, cgiargsclass &args); 24 26 25 27 // returns the encoded version of a cgi argument 26 28 text_t cgi_safe (const text_t &intext); 27 29 30 // check_save_conf_str checks the configuration string for 31 // the saved args and makes sure it does not conflict with 32 // the information about the arguments. If an error is encountered 33 // it will return false and the program should not produce any 34 // output. 35 bool check_save_conf_str (const text_t &saveconf, 36 const cgiargsinfoclass &argsinfo, 37 ostream &logout); 38 39 // create_save_conf_str will create a configuration string 40 // based on the information in argsinfo. This method of configuration 41 // is not recomended as small changes can produce large changes in 42 // the resulting configuration string (for instance a totally different 43 // ordering). Only arguments which "must" be saved are included in 44 // the resulting string. 45 text_t create_save_conf_str (const cgiargsinfoclass &argsinfo, 46 ostream &logout); 47 48 // expand_compress_args will expand the compressed arguments based 49 // on compressconf placing the results in args if they are not 50 // already defined. If it encounters an error it will return false 51 // and output more information to logout. 52 bool expand_save_args (const cgiargsinfoclass &argsinfo, 53 const text_t &saveconf, 54 cgiargsclass &args, 55 ostream &logout); 56 57 // adds the default values for those arguments which have not 58 // been specified 59 void add_default_args (const cgiargsinfoclass &argsinfo, 60 cgiargsclass &args, 61 ostream &logout); 62 63 // compress_save_args will compress the arguments and return 64 // them in compressed_args. If an error was encountered 65 // compressed_args will be set to to "", an error will be 66 // written to logout, and the function will return false. 67 bool compress_save_args (const cgiargsinfoclass &argsinfo, 68 const text_t &saveconf, 69 cgiargsclass &args, 70 text_t &compressed_args, 71 ostream &logout); 72 73 // args_tounicode converts any arguments which are not in unicode 74 // to unicode using inconvert 75 void args_tounicode (cgiargsclass &args, inconvertclass &inconvert); 76 28 77 #endif
Note:
See TracChangeset
for help on using the changeset viewer.