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-2004 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 EGNITE SOFTWARE GMBH 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 EGNITE
00024  * SOFTWARE GMBH 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 
00036 /*
00037  * $Log: httpd.h,v $
00038  * Revision 1.8  2006/10/08 16:43:53  haraldkipp
00039  * Authentication info depended on static memory kept by the caller. Now a
00040  * local copy is held and NutClearAuth (which should have been named
00041  * NutHttpAuthClear, btw.) works correctly.
00042  *
00043  * Revision 1.7  2006/08/25 13:42:16  olereinhardt
00044  * added NutClearAuth(void); Thanks to Peter Sondermanns
00045  *
00046  * Revision 1.6  2006/03/16 15:25:34  haraldkipp
00047  * Changed human readable strings from u_char to char to stop GCC 4 from
00048  * nagging about signedness.
00049  *
00050  * Revision 1.5  2005/08/26 14:12:39  olereinhardt
00051  * Added NutHttpProcessPostQuery(FILE *stream, REQUEST * req)
00052  *
00053  * Revision 1.4  2005/08/05 11:23:11  olereinhardt
00054  * Added support to register a custom handler for mime types.
00055  * Added Server side include support and ASP support.
00056  *
00057  * Revision 1.3  2005/06/26 13:35:26  chaac
00058  * Added forgotten prototype for NutRegisterHttpRoot, fixes bug #1215853. Also fixed some prototypes when compiling with C++.
00059  *
00060  * Revision 1.2  2004/12/16 10:17:18  haraldkipp
00061  * Added Mikael Adolfsson's excellent parameter parsing routines.
00062  *
00063  */
00064 
00065 #include <stdio.h>
00066 
00076 
00077 #define METHOD_GET  1
00078 #define METHOD_POST 2
00079 #define METHOD_HEAD 3
00080 
00081 typedef struct _REQUEST REQUEST;
00086 struct _REQUEST {
00087     int req_method;             
00088     int req_version;            
00089     int req_length;             
00090     char *req_url;              
00091     char *req_query;            
00092     char *req_type;             
00093     char *req_cookie;           
00094     char *req_auth;             
00095     char *req_agent;            
00096     char **req_qptrs;           
00097     int req_numqptrs;           
00098 };
00099 
00100 __BEGIN_DECLS
00101 
00102 extern void NutHttpProcessRequest(FILE * stream);
00103 extern void NutHttpProcessQueryString(REQUEST * req);
00104 extern void NutHttpSendHeaderTop(FILE * stream, REQUEST * req, int status, char *title);
00105 extern void NutHttpSendHeaderBot(FILE * stream, char *mime_type, long bytes);
00106 extern void NutHttpSendError(FILE * stream, REQUEST * req, int status);
00107 extern char *NutGetMimeType(char *name);
00108 extern void *NutGetMimeHandler(char *name);
00109 extern u_char NutSetMimeHandler(char *extension, void (*handler)(FILE *stream, int fd, int file_len, char *http_root, REQUEST *req));
00110 
00111 __END_DECLS
00112 
00113 /*
00114  * Authorization
00115  */
00116 typedef struct _AUTHINFO AUTHINFO;
00117 
00122 struct _AUTHINFO {
00123     AUTHINFO *auth_next;    
00124     char *auth_dirname;     
00125     char *auth_login;       
00126 };
00127 
00128 __BEGIN_DECLS
00129 
00130 extern int NutHttpAuthValidate(REQUEST * req);
00131 extern int NutRegisterAuth(CONST char *dirname, CONST char *login);
00132 extern void NutClearAuth(void);
00133 
00134 __END_DECLS
00135 
00136 /*
00137  * CGI
00138  */
00139 typedef struct _CGIFUNCTION CGIFUNCTION;
00140 
00145 struct _CGIFUNCTION {
00146     CGIFUNCTION *cgi_next;      
00147     CONST char *cgi_name;       
00148     int (*cgi_func) (FILE *, REQUEST *);        
00149 };
00150 
00153 __BEGIN_DECLS
00154 
00155 /* Function prototypes. */
00156 extern int NutRegisterHttpRoot(char *path);
00157 extern int NutRegisterCgi(char *name, int (*func) (FILE *, REQUEST *));
00158 extern void NutCgiProcessRequest(FILE * stream, REQUEST * req);
00159 extern void NutHttpProcessPostQuery(FILE *stream, REQUEST * req);
00160 extern char *NutHttpURLEncode(char *str);
00161 extern void NutHttpURLDecode(char *str);
00162 extern char *NutHttpGetParameter(REQUEST * req, char *name);
00163 extern int NutHttpGetParameterCount(REQUEST * req);
00164 extern char *NutHttpGetParameterName(REQUEST * req, int index);
00165 extern char *NutHttpGetParameterValue(REQUEST * req, int index);
00166 
00167 
00168 __END_DECLS
00169 /* */
00170 #endif

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/