STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
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 LWIP_HDR_APPS_HTTPD_H
37 #define LWIP_HDR_APPS_HTTPD_H
38 
39 #include "httpd_opts.h"
40 #include "lwip/err.h"
41 #include "lwip/pbuf.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #if LWIP_HTTPD_CGI
48 
49 /*
50  * Function pointer for a CGI script handler.
51  *
52  * This function is called each time the HTTPD server is asked for a file
53  * whose name was previously registered as a CGI function using a call to
54  * http_set_cgi_handler. The iIndex parameter provides the index of the
55  * CGI within the ppcURLs array passed to http_set_cgi_handler. Parameters
56  * pcParam and pcValue provide access to the parameters provided along with
57  * the URI. iNumParams provides a count of the entries in the pcParam and
58  * pcValue arrays. Each entry in the pcParam array contains the name of a
59  * parameter with the corresponding entry in the pcValue array containing the
60  * value for that parameter. Note that pcParam may contain multiple elements
61  * with the same name if, for example, a multi-selection list control is used
62  * in the form generating the data.
63  *
64  * The function should return a pointer to a character string which is the
65  * path and filename of the response that is to be sent to the connected
66  * browser, for example "/thanks.htm" or "/response/error.ssi".
67  *
68  * The maximum number of parameters that will be passed to this function via
69  * iNumParams is defined by LWIP_HTTPD_MAX_CGI_PARAMETERS. Any parameters in the incoming
70  * HTTP request above this number will be discarded.
71  *
72  * Requests intended for use by this CGI mechanism must be sent using the GET
73  * method (which encodes all parameters within the URI rather than in a block
74  * later in the request). Attempts to use the POST method will result in the
75  * request being ignored.
76  *
77  */
78 typedef const char *(*tCGIHandler)(int iIndex, int iNumParams, char *pcParam[],
79  char *pcValue[]);
80 
81 /*
82  * Structure defining the base filename (URL) of a CGI and the associated
83  * function which is to be called when that URL is requested.
84  */
85 typedef struct
86 {
87  const char *pcCGIName;
88  tCGIHandler pfnCGIHandler;
89 } tCGI;
90 
91 void http_set_cgi_handlers(const tCGI *pCGIs, int iNumHandlers);
92 
93 #endif /* LWIP_HTTPD_CGI */
94 
95 #if LWIP_HTTPD_SSI
96 
97 /*
98  * Function pointer for the SSI tag handler callback.
99  *
100  * This function will be called each time the HTTPD server detects a tag of the
101  * form <!--#name--> in a .shtml, .ssi or .shtm file where "name" appears as
102  * one of the tags supplied to http_set_ssi_handler in the ppcTags array. The
103  * returned insert string, which will be appended after the the string
104  * "<!--#name-->" in file sent back to the client,should be written to pointer
105  * pcInsert. iInsertLen contains the size of the buffer pointed to by
106  * pcInsert. The iIndex parameter provides the zero-based index of the tag as
107  * found in the ppcTags array and identifies the tag that is to be processed.
108  *
109  * The handler returns the number of characters written to pcInsert excluding
110  * any terminating NULL or a negative number to indicate a failure (tag not
111  * recognized, for example).
112  *
113  * Note that the behavior of this SSI mechanism is somewhat different from the
114  * "normal" SSI processing as found in, for example, the Apache web server. In
115  * this case, the inserted text is appended following the SSI tag rather than
116  * replacing the tag entirely. This allows for an implementation that does not
117  * require significant additional buffering of output data yet which will still
118  * offer usable SSI functionality. One downside to this approach is when
119  * attempting to use SSI within JavaScript. The SSI tag is structured to
120  * resemble an HTML comment but this syntax does not constitute a comment
121  * within JavaScript and, hence, leaving the tag in place will result in
122  * problems in these cases. To work around this, any SSI tag which needs to
123  * output JavaScript code must do so in an encapsulated way, sending the whole
124  * HTML <script>...</script> section as a single include.
125  */
126 typedef u16_t (*tSSIHandler)(int iIndex, char *pcInsert, int iInsertLen
127 #if LWIP_HTTPD_SSI_MULTIPART
128  , u16_t current_tag_part, u16_t *next_tag_part
129 #endif /* LWIP_HTTPD_SSI_MULTIPART */
130 #if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
131  , void *connection_state
132 #endif /* LWIP_HTTPD_FILE_STATE */
133  );
134 
135 void http_set_ssi_handler(tSSIHandler pfnSSIHandler,
136  const char **ppcTags, int iNumTags);
137 
138 #endif /* LWIP_HTTPD_SSI */
139 
140 #if LWIP_HTTPD_SUPPORT_POST
141 
142 /* These functions must be implemented by the application */
143 
162 err_t httpd_post_begin(void *connection, const char *uri, const char *http_request,
163  u16_t http_request_len, int content_len, char *response_uri,
164  u16_t response_uri_len, u8_t *post_auto_wnd);
165 
174 err_t httpd_post_receive_data(void *connection, struct pbuf *p);
175 
185 void httpd_post_finished(void *connection, char *response_uri, u16_t response_uri_len);
186 
187 #if LWIP_HTTPD_POST_MANUAL_WND
188 void httpd_post_data_recved(void *connection, u16_t recved_len);
189 #endif /* LWIP_HTTPD_POST_MANUAL_WND */
190 
191 #endif /* LWIP_HTTPD_SUPPORT_POST */
192 
193 void httpd_init(void);
194 
195 #ifdef __cplusplus
196 }
197 #endif
198 
199 #endif /* LWIP_HDR_APPS_HTTPD_H */
void httpd_init(void)
Definition: pbuf.h:108
s8_t err_t
Definition: err.h:47
unsigned char u8_t
Definition: cc.h:38
unsigned short u16_t
Definition: cc.h:40