Kinetis SDK v.1.2 Demo Applications User's Guide  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
httpd.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Adam Dunkels <adam@sics.se>
30  *
31  * This version of the file has been modified by Texas Instruments to offer
32  * simple server-side-include (SSI) and Common Gateway Interface (CGI)
33  * capability.
34  */
35 
36 #ifndef __HTTPD_H__
37 #define __HTTPD_H__
38 
40 // Includes
42 
43 #include "lwip/opt.h"
44 #include "lwip/err.h"
45 #include "lwip/pbuf.h"
46 
48 // Definitions
50 
51 // Set this to 1 to support CGI
52 #ifndef LWIP_HTTPD_CGI
53 #define LWIP_HTTPD_CGI 0
54 #endif
55 
56 // Set this to 1 to support SSI (Server-Side-Includes)
57 #ifndef LWIP_HTTPD_SSI
58 #define LWIP_HTTPD_SSI 0
59 #endif
60 
61 // Set this to 1 to support HTTP POST
62 #ifndef LWIP_HTTPD_SUPPORT_POST
63 #define LWIP_HTTPD_SUPPORT_POST 0
64 #endif
65 
66 #if LWIP_HTTPD_CGI
67 
97 typedef const char *(*tCGIHandler)(int iIndex, int iNumParams, char *pcParam[],
98  char *pcValue[]);
99 
104 typedef struct
105 {
106  const char *pcCGIName;
107  tCGIHandler pfnCGIHandler;
108 } tCGI;
109 
110 void http_set_cgi_handlers(const tCGI *pCGIs, int iNumHandlers);
111 
112 // The maximum number of parameters that the CGI handler can be sent.
113 #ifndef LWIP_HTTPD_MAX_CGI_PARAMETERS
114 #define LWIP_HTTPD_MAX_CGI_PARAMETERS 16
115 #endif
116 
117 #endif // LWIP_HTTPD_CGI
118 
119 #if LWIP_HTTPD_SSI
120 
127 #ifndef LWIP_HTTPD_SSI_MULTIPART
128 #define LWIP_HTTPD_SSI_MULTIPART 0
129 #endif
130 
160 typedef u16_t (*tSSIHandler)(int iIndex, char *pcInsert, int iInsertLen
161 #if LWIP_HTTPD_SSI_MULTIPART
162  , u16_t current_tag_part, u16_t *next_tag_part
163 #endif // LWIP_HTTPD_SSI_MULTIPART
164 #if LWIP_HTTPD_FILE_STATE
165  , void *connection_state
166 #endif // LWIP_HTTPD_FILE_STATE
167  );
168 
169 void http_set_ssi_handler(tSSIHandler pfnSSIHandler,
170  const char **ppcTags, int iNumTags);
171 
172 // The maximum length of the string comprising the tag name
173 #ifndef LWIP_HTTPD_MAX_TAG_NAME_LEN
174 #define LWIP_HTTPD_MAX_TAG_NAME_LEN 8
175 #endif
176 
177 // The maximum length of string that can be returned to replace any given tag
178 #ifndef LWIP_HTTPD_MAX_TAG_INSERT_LEN
179 #define LWIP_HTTPD_MAX_TAG_INSERT_LEN 192
180 #endif
181 
182 #endif // LWIP_HTTPD_SSI
183 
184 #if LWIP_HTTPD_SUPPORT_POST
185 
186 /* These functions must be implemented by the application */
187 
207 err_t httpd_post_begin(void *connection, const char *uri, const char *http_request,
208  u16_t http_request_len, int content_len, char *response_uri,
209  u16_t response_uri_len, u8_t *post_auto_wnd);
210 
220 err_t httpd_post_receive_data(void *connection, struct pbuf *p);
221 
232 void httpd_post_finished(void *connection, char *response_uri, u16_t response_uri_len);
233 
234 #ifndef LWIP_HTTPD_POST_MANUAL_WND
235 #define LWIP_HTTPD_POST_MANUAL_WND 0
236 #endif
237 
238 #if LWIP_HTTPD_POST_MANUAL_WND
239 void httpd_post_data_recved(void *connection, u16_t recved_len);
240 #endif // LWIP_HTTPD_POST_MANUAL_WND
241 
242 #endif // LWIP_HTTPD_SUPPORT_POST
243 
244 void httpd_init(void);
245 
246 #endif // __HTTPD_H__
void httpd_init(void)