Go to the documentation of this file.00001 #ifndef _PRO_HTTPD_H_
00002 #define _PRO_HTTPD_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00080 #include <stdint.h>
00081
00082 #include <stdio.h>
00083 #include <time.h>
00084
00085 #include <compiler.h>
00086
00091
00092 #define METHOD_GET 1
00093 #define METHOD_POST 2
00094 #define METHOD_HEAD 3
00095
00096 #define HTTP_CONN_CLOSE 1
00097 #define HTTP_CONN_KEEP_ALIVE 2
00098
00099 #define HTTP_OF_USE_HOST_TIME 0x00000001UL
00100 #define HTTP_OF_USE_FILE_TIME 0x00000002UL
00101
00102 typedef struct _REQUEST REQUEST;
00107 struct _REQUEST {
00108 int req_method;
00109 int req_version;
00110 long req_length;
00111 char *req_url;
00112 char *req_query;
00113 char *req_type;
00114 char *req_cookie;
00115 char *req_auth;
00116 char *req_agent;
00117 char **req_qptrs;
00118 int req_numqptrs;
00119 time_t req_ims;
00120 char *req_referer;
00121 char *req_host;
00122 int req_connection;
00123 char *req_encoding;
00124 };
00125
00126 typedef struct _MIMETYPES MIMETYPES;
00127
00128 struct _MIMETYPES {
00129 char *mtyp_ext;
00130 char *mtyp_type;
00131 void (*mtyp_handler)(FILE *stream, int fd, int file_len, char *http_root, REQUEST *req);
00132 };
00133
00134 __BEGIN_DECLS
00135
00136 extern void NutHttpProcessRequest(FILE * stream);
00137 extern void NutHttpProcessQueryString(REQUEST * req);
00138 extern void NutHttpSendHeaderTop(FILE * stream, REQUEST * req, int status, char *title);
00139 extern void NutHttpSendHeaderBottom(FILE * stream, REQUEST * req, char *mime_type, long bytes);
00140 extern void NutHttpSendHeaderBot(FILE * stream, char *mime_type, long bytes) NUT_DEPRECATED;
00141 extern void NutHttpSendError(FILE * stream, REQUEST * req, int status);
00142 extern char *NutGetMimeType(char *name);
00143 extern void *NutGetMimeHandler(char *name);
00144 extern uint8_t NutSetMimeHandler(char *extension, void (*handler)(FILE *stream, int fd, int file_len, char *http_root, REQUEST *req));
00145
00146 __END_DECLS
00147
00148
00149
00150
00151 typedef struct _AUTHINFO AUTHINFO;
00152
00157 struct _AUTHINFO {
00158 AUTHINFO *auth_next;
00159 char *auth_dirname;
00160 char *auth_login;
00161 };
00162
00163 __BEGIN_DECLS
00164
00165 extern int NutHttpAuthValidate(REQUEST * req);
00166 extern int NutRegisterAuth(CONST char *dirname, CONST char *login);
00167 extern void NutClearAuth(void);
00168
00169 __END_DECLS
00170
00171
00172
00173
00174 typedef struct _CGIFUNCTION CGIFUNCTION;
00175
00180 struct _CGIFUNCTION {
00181 CGIFUNCTION *cgi_next;
00182 char *cgi_name;
00183 int (*cgi_func) (FILE *, REQUEST *);
00184 };
00185
00188 __BEGIN_DECLS
00189
00190
00191 extern void NutHttpSetOptionFlags(uint32_t flags);
00192 extern uint32_t NutHttpGetOptionFlags(void);
00193 extern int NutRegisterHttpRoot(char *path);
00194 extern void NutRegisterCgiBinPath(char *path);
00195 extern int NutRegisterCgi(char *name, int (*func) (FILE *, REQUEST *));
00196 extern int NutCgiCheckRequest(FILE * stream, REQUEST * req);
00197 extern void NutCgiProcessRequest(FILE * stream, REQUEST * req, int name_pos);
00198 extern void NutHttpProcessPostQuery(FILE *stream, REQUEST * req);
00199 extern char *NutHttpURLEncode(char *str);
00200 extern void NutHttpURLDecode(char *str);
00201 extern char *NutHttpGetParameter(REQUEST * req, char *name);
00202 extern int NutHttpGetParameterCount(REQUEST * req);
00203 extern char *NutHttpGetParameterName(REQUEST * req, int index);
00204 extern char *NutHttpGetParameterValue(REQUEST * req, int index);
00205
00206
00207 __END_DECLS
00208
00209 #endif