libUPnP 1.8.0
|
00001 00002 // 00003 // Copyright (c) 2000-2003 Intel Corporation 00004 // All rights reserved. 00005 // 00006 // Redistribution and use in source and binary forms, with or without 00007 // modification, are permitted provided that the following conditions are met: 00008 // 00009 // * Redistributions of source code must retain the above copyright notice, 00010 // this list of conditions and the following disclaimer. 00011 // * Redistributions in binary form must reproduce the above copyright notice, 00012 // this list of conditions and the following disclaimer in the documentation 00013 // and/or other materials provided with the distribution. 00014 // * Neither name of Intel Corporation nor the names of its contributors 00015 // may be used to endorse or promote products derived from this software 00016 // without specific prior written permission. 00017 // 00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00019 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00020 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00021 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR 00022 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00025 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00026 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00027 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 // 00031 00032 #ifndef GENLIB_NET_HTTP_WEBSERVER_H 00033 #define GENLIB_NET_HTTP_WEBSERVER_H 00034 00035 #include <time.h> 00036 #include "sock.h" 00037 #include "httpparser.h" 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 00043 00044 struct SendInstruction 00045 { 00046 int IsVirtualFile; 00047 int IsChunkActive; 00048 int IsRangeActive; 00049 int IsTrailers; 00050 char RangeHeader[200]; 00051 off_t RangeOffset; 00052 off_t ReadSendSize; // Read from local source and send on the network. 00053 long RecvWriteSize; // Recv from the network and write into local file. 00054 00055 //Later few more member could be added depending on the requirement. 00056 }; 00057 00058 /************************************************************************ 00059 * Function: web_server_init 00060 * 00061 * Parameters: 00062 * none 00063 * 00064 * Description: Initilialize the different documents. Initialize the 00065 * memory for root directory for web server. Call to initialize global 00066 * XML document. Sets bWebServerState to WEB_SERVER_ENABLED 00067 * 00068 * Returns: 00069 * 0 - OK 00070 * UPNP_E_OUTOF_MEMORY: note: alias_content is not freed here 00071 ************************************************************************/ 00072 int web_server_init(); 00073 00074 /************************************************************************ 00075 * Function: web_server_destroy 00076 * 00077 * Parameters: 00078 * none 00079 * 00080 * Description: Release memory allocated for the global web server root 00081 * directory and the global XML document 00082 * Resets the flag bWebServerState to WEB_SERVER_DISABLED 00083 * 00084 * Returns: 00085 * void 00086 ************************************************************************/ 00087 void web_server_destroy(); 00088 00089 /************************************************************************ 00090 * Function: web_server_set_alias 00091 * 00092 * Parameters: 00093 * alias_name: webserver name of alias; created by caller and freed by 00094 * caller (doesn't even have to be malloc()d .) 00095 * alias_content: the xml doc; this is allocated by the caller; and 00096 * freed by the web server 00097 * alias_content_length: length of alias body in bytes 00098 * last_modified: time when the contents of alias were last 00099 * changed (local time) 00100 * 00101 * Description: Replaces current alias with the given alias. To remove 00102 * the current alias, set alias_name to NULL. 00103 * 00104 * Returns: 00105 * 0 - OK 00106 * UPNP_E_OUTOF_MEMORY: note: alias_content is not freed here 00107 ************************************************************************/ 00108 int web_server_set_alias( 00109 IN const char* alias_name, 00110 IN const char* alias_content, IN size_t alias_content_length, 00111 IN time_t last_modified); 00112 00113 /************************************************************************ 00114 * Function: web_server_set_root_dir 00115 * 00116 * Parameters: 00117 * IN const char* root_dir ; String having the root directory for the 00118 * document 00119 * 00120 * Description: Assign the path specfied by the IN const char* root_dir 00121 * parameter to the global Document root directory. Also check for 00122 * path names ending in '/' 00123 * 00124 * Returns: 00125 * int 00126 ************************************************************************/ 00127 int web_server_set_root_dir(IN const char* root_dir); 00128 00129 /************************************************************************ 00130 * Function: web_server_callback 00131 * 00132 * Parameters: 00133 * IN http_parser_t *parser, 00134 * INOUT http_message_t* req, 00135 * IN SOCKINFO *info 00136 * 00137 * Description: main entry point into web server; 00138 * handles HTTP GET and HEAD requests 00139 * 00140 * Returns: 00141 * void 00142 ************************************************************************/ 00143 void web_server_callback(IN http_parser_t *parser, IN http_message_t *req, INOUT SOCKINFO *info); 00144 00145 00146 #ifdef __cplusplus 00147 } // extern C 00148 #endif 00149 00150 00151 #endif // GENLIB_NET_HTTP_WEBSERVER_H 00152