lib/cgi/cgi-base.h
changeset 0 6f7a81934006
child 2 b3afb9f1e801
equal deleted inserted replaced
-1:000000000000 0:6f7a81934006
       
     1 #ifndef CHECKVPW__CGI_BASE__H__
       
     2 #define CHECKVPW__CGI_BASE__H__
       
     3 
       
     4 #include "mystring/mystring.h"
       
     5 #include "cgi/cgi-args.h"
       
     6 
       
     7 extern void content_type(mystring ct);
       
     8 
       
     9 class CGI
       
    10 {
       
    11 protected:
       
    12   const CGIArgs& args;
       
    13 
       
    14   const mystring redirect_url, error_redirect_url;
       
    15   const mystring vdomain, password;
       
    16   
       
    17   void error(mystring);
       
    18   void success(mystring);
       
    19 
       
    20   void must_be_defined(mystring);
       
    21   
       
    22 public:
       
    23   CGI(const CGIArgs& a);
       
    24   
       
    25   void main();
       
    26 };
       
    27 
       
    28 #define CGI_MAIN void CGI::main()
       
    29 
       
    30 #define CGI_INPUT(VAR) \
       
    31   const mystring VAR##__name__ = #VAR; \
       
    32   must_be_defined(VAR##__name__); \
       
    33   mystring VAR = args[VAR##__name__];
       
    34 
       
    35 #define CGI_OPTINPUT(VAR) \
       
    36   const mystring VAR##__name__ = #VAR; \
       
    37   mystring VAR = args[VAR##__name__];
       
    38 
       
    39 #endif