libUPnP  1.8.0
webserver.h
1 //
3 // Copyright (c) 2000-2003 Intel Corporation
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 //
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 // * Neither name of Intel Corporation nor the names of its contributors
15 // may be used to endorse or promote products derived from this software
16 // without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
22 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
31 
32 #ifndef GENLIB_NET_HTTP_WEBSERVER_H
33 #define GENLIB_NET_HTTP_WEBSERVER_H
34 
35 #include <time.h>
36 #include "sock.h"
37 #include "httpparser.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 
45 {
46  int IsVirtualFile;
47  int IsChunkActive;
48  int IsRangeActive;
49  int IsTrailers;
50  char RangeHeader[200];
51  off_t RangeOffset;
52  off_t ReadSendSize; // Read from local source and send on the network.
53  long RecvWriteSize; // Recv from the network and write into local file.
54 
55  //Later few more member could be added depending on the requirement.
56 };
57 
58 /************************************************************************
59  * Function: web_server_init
60  *
61  * Parameters:
62  * none
63  *
64  * Description: Initilialize the different documents. Initialize the
65  * memory for root directory for web server. Call to initialize global
66  * XML document. Sets bWebServerState to WEB_SERVER_ENABLED
67  *
68  * Returns:
69  * 0 - OK
70  * UPNP_E_OUTOF_MEMORY: note: alias_content is not freed here
71  ************************************************************************/
72 int web_server_init();
73 
74 /************************************************************************
75  * Function: web_server_destroy
76  *
77  * Parameters:
78  * none
79  *
80  * Description: Release memory allocated for the global web server root
81  * directory and the global XML document
82  * Resets the flag bWebServerState to WEB_SERVER_DISABLED
83  *
84  * Returns:
85  * void
86  ************************************************************************/
87 void web_server_destroy();
88 
89 /************************************************************************
90  * Function: web_server_set_alias
91  *
92  * Parameters:
93  * alias_name: webserver name of alias; created by caller and freed by
94  * caller (doesn't even have to be malloc()d .)
95  * alias_content: the xml doc; this is allocated by the caller; and
96  * freed by the web server
97  * alias_content_length: length of alias body in bytes
98  * last_modified: time when the contents of alias were last
99  * changed (local time)
100  *
101  * Description: Replaces current alias with the given alias. To remove
102  * the current alias, set alias_name to NULL.
103  *
104  * Returns:
105  * 0 - OK
106  * UPNP_E_OUTOF_MEMORY: note: alias_content is not freed here
107  ************************************************************************/
108 int web_server_set_alias(
109  IN const char* alias_name,
110  IN const char* alias_content, IN size_t alias_content_length,
111  IN time_t last_modified);
112 
113 /************************************************************************
114  * Function: web_server_set_root_dir
115  *
116  * Parameters:
117  * IN const char* root_dir ; String having the root directory for the
118  * document
119  *
120  * Description: Assign the path specfied by the IN const char* root_dir
121  * parameter to the global Document root directory. Also check for
122  * path names ending in '/'
123  *
124  * Returns:
125  * int
126  ************************************************************************/
127 int web_server_set_root_dir(IN const char* root_dir);
128 
129 /************************************************************************
130  * Function: web_server_callback
131  *
132  * Parameters:
133  * IN http_parser_t *parser,
134  * INOUT http_message_t* req,
135  * IN SOCKINFO *info
136  *
137  * Description: main entry point into web server;
138  * handles HTTP GET and HEAD requests
139  *
140  * Returns:
141  * void
142  ************************************************************************/
143 void web_server_callback(IN http_parser_t *parser, IN http_message_t *req, INOUT SOCKINFO *info);
144 
145 
146 #ifdef __cplusplus
147 } // extern C
148 #endif
149 
150 
151 #endif // GENLIB_NET_HTTP_WEBSERVER_H
152 
Definition: httpparser.h:178
Definition: sock.h:55
Definition: httpparser.h:206
Definition: webserver.h:44