Back to index

courier  0.68.2
cgi.h
Go to the documentation of this file.
00001 /*
00002 */
00003 #ifndef       cgi_h
00004 #define       cgi_h
00005 
00006 #if    HAVE_CONFIG_H
00007 #include      "cgi/cgi_config.h"
00008 #endif
00009 #include "../unicode/unicode.h"
00010 
00011 #ifdef __cplusplus
00012 
00013 extern "C" {
00014 
00015 #endif
00016 
00017 #include <string.h>
00018 
00019 /*
00020 ** Copyright 1998 - 2007 Double Precision, Inc.
00021 ** See COPYING for distribution information.
00022 */
00023 
00024 extern void fake_exit(int);
00025 
00026 void cgi_setup();
00027 void cgi_cleanup();
00028 const char *cgi(const char *);
00029 char *cgi_multiple(const char *, const char *);
00030 
00031 char   *cgi_cookie(const char *);
00032 void   cgi_setcookie(const char *, const char *);
00033 
00034 int    cgi_useragent(const char *);
00035 
00036 struct cgi_arglist {
00037        struct cgi_arglist *next;
00038        struct cgi_arglist *prev;   /* Used by cgi_multiple */
00039        const char *argname;
00040        const char *argvalue;
00041        } ;
00042 
00043 extern struct cgi_arglist *cgi_arglist;
00044 
00045 extern void cgiurldecode(char *);
00046 extern void cgi_put(const char *, const char *);
00047 
00048 extern char *cgiurlencode(const char *);
00049 extern char *cgiurlencode_noamp(const char *);
00050 extern char *cgiurlencode_noeq(const char *);
00051 
00052 #if    HAVE_UNISTD_H
00053 #include      <unistd.h>
00054 #endif
00055 
00056 int cgi_getfiles( int (*)(const char *, const char *, void *),
00057               int (*)(const char *, size_t, void *),
00058               void (*)(void *), size_t, void *);
00059 
00060 extern const char *cgihttpscriptptr();
00061 extern const char *cgihttpsscriptptr();
00062 extern const char *cgiextrapath();
00063 
00064 extern void cgihttpscriptptr_init();
00065 extern void cgihttpsscriptptr_init();
00066 
00067 extern const char *cgirelscriptptr();
00068 extern void cginocache();
00069 extern void cgiredirect(const char *);
00070 extern void cgiversion(unsigned *, unsigned *);
00071 extern int cgihasversion(unsigned, unsigned);
00072 
00073 struct cgi_set_cookie_info {
00074        const char *name;
00075        const char *value;
00076 
00077        char *domain;
00078        char *path;
00079        int age;
00080        int secure;
00081 };
00082 
00083 #define cgi_set_cookie_info_init(i) (memset((i), 0, sizeof(*(i))), (i)->age=-1)
00084 #define cgi_set_cookie_info_free(i) do { if ((i)->path) \
00085                      free((i)->path);            \
00086               if ((i)->domain)                   \
00087                      free((i)->domain);          \
00088        } while(0)
00089 
00090 #define cgi_set_cookie_session(c,n,v) ( ((c)->name=(n)), ((c)->value)=(v))
00091 #define cgi_set_cookie_expired(c,n) ( ((c)->name=(n)), ((c)->value)="",\
00092                                   (c)->age=0)
00093 
00094 extern int cgi_set_cookie_url(struct cgi_set_cookie_info *i,
00095                            const char *url);
00096 
00097 #define cgi_set_cookie_secure(c) ((c)->secure=1)
00098 
00099 extern void cgi_set_cookies(struct cgi_set_cookie_info *cookies,
00100                          size_t n_cookies);
00101 
00102 extern char *cgi_get_cookie(const char *cookie_name);
00103 
00104 extern char *cgi_select(const char *name,
00105                      const char *optvalues,
00106                      const char *optlabels,
00107                      const char *default_value,
00108                      size_t list_size,
00109                      const char *flags); /* "m" - multiple, "d" -disabled */
00110 extern char *cgi_checkbox(const char *name,
00111                        const char *value,
00112                        const char *flags);
00113 extern char *cgi_input(const char *name,
00114                      const unicode_char *value,
00115                      int size,
00116                      int maxlength,
00117                      const char *opts);
00118 
00119 extern char *cgi_textarea(const char *name,
00120                        int rows,
00121                        int cols,
00122                        const unicode_char *value,
00123                        const char *wrap,
00124                        const char *opts);
00125 
00126 extern void cgiformdatatempdir(const char *);
00127               /* Specify directory for formdata temp file */
00128 
00129 extern void cgi_daemon(int nprocs, const char *lockfile,
00130                      void (*postinit)(void *),
00131                      void (*handler)(void *),
00132                      void *dummy);
00133 extern void cgi_connectdaemon(const char *sockfilename, int pass_fd);
00134 
00135 #define SOCKENVIRONLEN 8192
00136 
00137 #define VALIDCGIVAR(p) \
00138                   (strncmp((p), "DOCUMENT_", 9) == 0 || \
00139                    strncmp((p), "GATEWAY_", 8) == 0 || \
00140                    strncmp((p), "HTTP_", 5) == 0 || \
00141                    strncmp((p), "HTTPS=", 6) == 0 || \
00142                    strncmp((p), "SSL_", 4) == 0 || \
00143                    strncmp((p), "QUERY_STRING=", 13) == 0 || \
00144                    strncmp((p), "SQWEBMAIL_", 10) == 0 || \
00145                    strncmp((p), "REMOTE_", 7) == 0 || \
00146                    strncmp((p), "REQUEST_", 8) == 0 || \
00147                    strncmp((p), "SCRIPT_", 7) == 0 || \
00148                    strncmp((p), "SERVER_", 7) == 0 || \
00149                    strncmp((p), "CONTENT_", 8) == 0 || \
00150                    strncmp((p), "PATH_INFO=", 10) == 0)
00151 
00152 #define CGI_PASSFD 0
00153 
00154 #if CGI_PASSFD_MSGACCRIGHTS
00155 #undef CGI_PASSFD
00156 #define CGI_PASSFD 1
00157 #endif
00158 
00159 #if CGI_PASSFD_MSGCONTROL
00160 #undef CGI_PASSFD
00161 #define CGI_PASSFD 1
00162 #endif
00163 
00164 #ifdef __cplusplus
00165 
00166 }
00167 
00168 #endif
00169 
00170 #endif