httpd.h

Go to the documentation of this file.
00001 #ifndef _PRO_HTTPD_H_
00002 #define _PRO_HTTPD_H_
00003 
00004 /*
00005  * Copyright (C) 2001-2007 by egnite Software GmbH. All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. Neither the name of the copyright holders nor the names of
00017  *    contributors may be used to endorse or promote products derived
00018  *    from this software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00027  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00028  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00029  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00030  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  *
00033  * For additional information see http://www.ethernut.de/
00034  */
00035 
00080 #include <stdint.h>
00081 
00082 #include <stdio.h>
00083 #include <time.h>
00084 
00085 #include <compiler.h> // For NUT_DEPRECATED
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 };
00124 
00125 typedef struct _MIMETYPES MIMETYPES;
00126 
00127 struct _MIMETYPES {
00128     char *mtyp_ext;
00129     char *mtyp_type;
00130     void (*mtyp_handler)(FILE *stream, int fd, int file_len, char *http_root, REQUEST *req);
00131 };
00132 
00133 __BEGIN_DECLS
00134 
00135 extern void NutHttpProcessRequest(FILE * stream);
00136 extern void NutHttpProcessQueryString(REQUEST * req);
00137 extern void NutHttpSendHeaderTop(FILE * stream, REQUEST * req, int status, char *title);
00138 extern void NutHttpSendHeaderBottom(FILE * stream, REQUEST * req, char *mime_type, long bytes);
00139 extern void NutHttpSendHeaderBot(FILE * stream, char *mime_type, long bytes) NUT_DEPRECATED;
00140 extern void NutHttpSendError(FILE * stream, REQUEST * req, int status);
00141 extern char *NutGetMimeType(char *name);
00142 extern void *NutGetMimeHandler(char *name);
00143 extern uint8_t NutSetMimeHandler(char *extension, void (*handler)(FILE *stream, int fd, int file_len, char *http_root, REQUEST *req));
00144 
00145 __END_DECLS
00146 
00147 /*
00148  * Authorization
00149  */
00150 typedef struct _AUTHINFO AUTHINFO;
00151 
00156 struct _AUTHINFO {
00157     AUTHINFO *auth_next;    
00158     char *auth_dirname;     
00159     char *auth_login;       
00160 };
00161 
00162 __BEGIN_DECLS
00163 
00164 extern int NutHttpAuthValidate(REQUEST * req);
00165 extern int NutRegisterAuth(CONST char *dirname, CONST char *login);
00166 extern void NutClearAuth(void);
00167 
00168 __END_DECLS
00169 
00170 /*
00171  * CGI
00172  */
00173 typedef struct _CGIFUNCTION CGIFUNCTION;
00174 
00179 struct _CGIFUNCTION {
00180     CGIFUNCTION *cgi_next;      
00181     char *cgi_name;             
00182     int (*cgi_func) (FILE *, REQUEST *);        
00183 };
00184 
00187 __BEGIN_DECLS
00188 
00189 /* Function prototypes. */
00190 extern void NutHttpSetOptionFlags(uint32_t flags);
00191 extern uint32_t NutHttpGetOptionFlags(void);
00192 extern int NutRegisterHttpRoot(char *path);
00193 extern void NutRegisterCgiBinPath(char *path);
00194 extern int NutRegisterCgi(char *name, int (*func) (FILE *, REQUEST *));
00195 extern int NutCgiCheckRequest(FILE * stream, REQUEST * req);
00196 extern void NutCgiProcessRequest(FILE * stream, REQUEST * req, int name_pos);
00197 extern void NutHttpProcessPostQuery(FILE *stream, REQUEST * req);
00198 extern char *NutHttpURLEncode(char *str);
00199 extern void NutHttpURLDecode(char *str);
00200 extern char *NutHttpGetParameter(REQUEST * req, char *name);
00201 extern int NutHttpGetParameterCount(REQUEST * req);
00202 extern char *NutHttpGetParameterName(REQUEST * req, int index);
00203 extern char *NutHttpGetParameterValue(REQUEST * req, int index);
00204 
00205 
00206 __END_DECLS
00207 /* */
00208 #endif

© 2000-2010 by contributors - visit http://www.ethernut.de/