lib/cgi/cgi-base.h
changeset 0 6f7a81934006
child 2 b3afb9f1e801
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/cgi/cgi-base.h	Wed Jan 16 22:39:43 2008 +0100
@@ -0,0 +1,39 @@
+#ifndef CHECKVPW__CGI_BASE__H__
+#define CHECKVPW__CGI_BASE__H__
+
+#include "mystring/mystring.h"
+#include "cgi/cgi-args.h"
+
+extern void content_type(mystring ct);
+
+class CGI
+{
+protected:
+  const CGIArgs& args;
+
+  const mystring redirect_url, error_redirect_url;
+  const mystring vdomain, password;
+  
+  void error(mystring);
+  void success(mystring);
+
+  void must_be_defined(mystring);
+  
+public:
+  CGI(const CGIArgs& a);
+  
+  void main();
+};
+
+#define CGI_MAIN void CGI::main()
+
+#define CGI_INPUT(VAR) \
+  const mystring VAR##__name__ = #VAR; \
+  must_be_defined(VAR##__name__); \
+  mystring VAR = args[VAR##__name__];
+
+#define CGI_OPTINPUT(VAR) \
+  const mystring VAR##__name__ = #VAR; \
+  mystring VAR = args[VAR##__name__];
+
+#endif