Changeset 154


Ignore:
Timestamp:
1999-02-08T14:28:01+13:00 (25 years ago)
Author:
rjmcnab
Message:

Got the receptionist producing something using the statusaction.

Location:
trunk/gsdl/src/recpt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/cgiargs.cpp

    r150 r154  
    1212/*
    1313   $Log$
     14   Revision 1.5  1999/02/08 01:28:00  rjmcnab
     15   Got the receptionist producing something using the statusaction.
     16
    1417   Revision 1.4  1999/02/05 10:42:41  rjmcnab
    1518
     
    134137// processing with the arguments should be done if this happens
    135138// as the results will be meaningless.
    136 bool cgiargsinfoclass::addarginfo (ostream &logout, const cgiarginfo &info) {
     139bool cgiargsinfoclass::addarginfo (ostream *logout, const cgiarginfo &info) {
    137140  outconvertclass text_t2ascii;
    138141
     
    144147
    145148  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    }
    149154    return false; // found a clash
    150155  }
    151156
    152157  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    }
    156163    return false; // found a clash
    157164  }
    158 
     165 
    159166  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    }
    163172    return false;  // found a problem
    164173  }
     
    169178      (orginfo->savedarginfo==cgiarginfo::must &&
    170179       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    }
    174185    return false; // found a clash
    175186  }
     
    189200}
    190201
    191 bool cgiargsinfoclass::addarginfo (ostream &logout, const cgiargsinfoclass &info) {
     202bool cgiargsinfoclass::addarginfo (ostream *logout, const cgiargsinfoclass &info) {
    192203  const_iterator here = info.begin ();
    193204  const_iterator end = info.end ();
     
    217228
    218229
    219 // utilities related to cgi arguments
    220 
    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 for
    234 // the saved args and makes sure it does not conflict with
    235 // the information about the arguments. If an error is encountered
    236 // it will return false and the program should not produce any
    237 // 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 saved
    250  
    251   while (saveconfhere != saveconfend) {
    252     saveconfhere = get_next_save_arg (saveconfhere, saveconfend, argname);
    253 
    254     if (!argname.empty()) {
    255       // save the argument name for later
    256       argsset.insert (argname);
    257 
    258       // check the argument
    259       info =  argsinfo.getarginfo (argname);
    260       if (info == NULL) {
    261     logout << text_t2ascii << "Error: the cgi argument \"" << argname
    262            << "\" 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 \"" << argname
    268            << "\" 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 saved
    278   // are saved
    279   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 clashes
    295 }
    296 
    297 
    298 
    299 // create_save_conf_str will create a configuration string
    300 // based on the information in argsinfo. This method of configuration
    301 // is not recomended as small changes can produce large changes in
    302 // the resulting configuration string (for instance a totally different
    303 // ordering)
    304 text_t create_save_conf_str (const cgiargsinfoclass &argsinfo,
    305                  ostream &logout);
    306 
    307 // expand_save_args will expand the saved arguments based
    308 // on saveconf placing the results in args if they are not
    309 // already defined. If it encounters an error it will return false
    310 // 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 not
    316 // been specified
    317 void add_default_args (const cgiargsinfoclass &argsinfo,
    318                cgiargsclass &args,
    319                ostream &logout);
    320 
  • trunk/gsdl/src/recpt/cgiargs.h

    r150 r154  
    3333#endif
    3434
     35
     36// response_t is used to define what type of cgi header
     37// should be produced
     38enum response_t {location, content};
    3539
    3640
     
    7781  // setdefaultarg, setdefaultintarg, and setdefaultcarg will
    7882  // only set the argument if it is not already set
    79   // getargs NULLs if there isn't an entry with
     83  // getargs returns NULL if there isn't an entry with
    8084  // 'key' already defined, getintarg returns 0 if there wasn't an
    8185  // entry with 'key' defined and operator[] returns "" if
     
    114118
    115119  // 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
    118123  // given in a configuration file, and "imperative" means it must not
    119124  // be overriden at any costs (unless there is another "imperative"...)
    120   // Note: I assume that the comparison weak < good < config < imperative
     125  // Note: I assume that the comparison none < weak < good < config < imperative
    121126  // holds :-/
    122   enum defaultstatus_t {weak, good, config, imperative};
     127  enum defaultstatus_t {none, weak, good, config, imperative};
    123128
    124129  defaultstatus_t defaultstatus;
     
    178183  // processing with the arguments should be done if this happens
    179184  // 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);
    182187
    183188  cgiarginfo *getarginfo (const text_t &key);
     
    187192
    188193
    189 
    190 // utilities related to cgi arguments
    191 
    192 // check_compress_conf_str checks the configuration string for
    193 // the compressed args and makes sure it does not conflict with
    194 // the information about the arguments. If an error is encountered
    195 // it will return false and the program should not produce any
    196 // 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 string
    202 // based on the information in argsinfo. This method of configuration
    203 // is not recomended as small changes can produce large changes in
    204 // the resulting configuration string (for instance a totally different
    205 // ordering)
    206 text_t create_compress_conf_str (const cgiargsinfoclass &argsinfo,
    207                  ostream &logout);
    208 
    209 // expand_compress_args will expand the compressed arguments based
    210 // on compressconf placing the results in args if they are not
    211 // already defined. If it encounters an error it will return false
    212 // 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 not
    218 // been specified
    219 void add_default_args (const cgiargsinfoclass &argsinfo,
    220                cgiargsclass &args,
    221                ostream &logout);
    222 
    223 
    224194#endif
  • trunk/gsdl/src/recpt/cgiutils.h

    r108 r154  
    1414#define CGIUTILS_H
    1515
     16#include "gsdlconf.h"
    1617#include "text_t.h"
    1718#include "cgiargs.h"
     19
    1820
    1921// convert %xx and + to their appropriate equivalents
     
    2123
    2224// split up the cgi arguments
    23 void parse_cgi_args (text_t argstr, cgiargsclass &args);
     25void split_cgi_args (text_t argstr, cgiargsclass &args);
    2426
    2527// returns the encoded version of a cgi argument
    2628text_t cgi_safe (const text_t &intext);
    2729
     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.
     35bool 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.
     45text_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.
     52bool 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
     59void 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.
     67bool 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
     75void args_tounicode (cgiargsclass &args, inconvertclass &inconvert);
     76
    2877#endif
Note: See TracChangeset for help on using the changeset viewer.