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 /*TU* 00032 00033 TombUPnP - a library for developing UPnP applications. 00034 00035 Copyright (C) 2006-2010 Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc> 00036 00037 This library is free software; you can redistribute it and/or 00038 modify it under the terms of the GNU Lesser General Public 00039 License version 2.1 as published by the Free Software Foundation. 00040 00041 This library is distributed in the hope that it will be useful, 00042 but WITHOUT ANY WARRANTY; without even the implied warranty of 00043 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00044 Lesser General Public License for more details. 00045 00046 You should have received a copy of the GNU Lesser General Public 00047 License along with this library; if not, write to the Free Software 00048 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 00049 00050 $Id: webserver.h 2081 2010-03-23 20:18:00Z lww $ 00051 */ 00052 00053 #ifndef GENLIB_NET_HTTP_WEBSERVER_H 00054 #define GENLIB_NET_HTTP_WEBSERVER_H 00055 00056 #include <time.h> 00057 #include "sock.h" 00058 #include "httpparser.h" 00059 00060 #ifdef __cplusplus 00061 extern "C" { 00062 #endif 00063 00064 00065 struct SendInstruction 00066 { 00067 int IsVirtualFile; 00068 int IsChunkActive; 00069 int IsRangeActive; 00070 int IsTrailers; 00071 char RangeHeader[200]; 00072 off_t RangeOffset; 00073 off_t ReadSendSize; // Read from local source and send on the network. 00074 off_t RecvWriteSize; // Recv from the network and write into local file. 00075 00076 //Later few more member could be added depending on the requirement. 00077 }; 00078 00079 /************************************************************************ 00080 * Function: web_server_init 00081 * 00082 * Parameters: 00083 * none 00084 * 00085 * Description: Initilialize the different documents. Initialize the 00086 * memory for root directory for web server. Call to initialize global 00087 * XML document. Sets bWebServerState to WEB_SERVER_ENABLED 00088 * 00089 * Returns: 00090 * 0 - OK 00091 * UPNP_E_OUTOF_MEMORY: note: alias_content is not freed here 00092 ************************************************************************/ 00093 int web_server_init( void ); 00094 00095 /************************************************************************ 00096 * Function: web_server_destroy 00097 * 00098 * Parameters: 00099 * none 00100 * 00101 * Description: Release memory allocated for the global web server root 00102 * directory and the global XML document 00103 * Resets the flag bWebServerState to WEB_SERVER_DISABLED 00104 * 00105 * Returns: 00106 * void 00107 ************************************************************************/ 00108 void web_server_destroy( void ); 00109 00110 /************************************************************************ 00111 * Function: web_server_set_alias 00112 * 00113 * Parameters: 00114 * alias_name: webserver name of alias; created by caller and freed by 00115 * caller (doesn't even have to be malloc()d .) 00116 * alias_content: the xml doc; this is allocated by the caller; and 00117 * freed by the web server 00118 * alias_content_length: length of alias body in bytes 00119 * last_modified: time when the contents of alias were last 00120 * changed (local time) 00121 * 00122 * Description: Replaces current alias with the given alias. To remove 00123 * the current alias, set alias_name to NULL. 00124 * 00125 * Returns: 00126 * 0 - OK 00127 * UPNP_E_OUTOF_MEMORY: note: alias_content is not freed here 00128 ************************************************************************/ 00129 int web_server_set_alias( IN const char* alias_name, 00130 IN const char* alias_content, IN size_t alias_content_length, 00131 IN time_t last_modified ); 00132 00133 /************************************************************************ 00134 * Function: web_server_set_root_dir 00135 * 00136 * Parameters: 00137 * IN const char* root_dir ; String having the root directory for the 00138 * document 00139 * 00140 * Description: Assign the path specfied by the IN const char* root_dir 00141 * parameter to the global Document root directory. Also check for 00142 * path names ending in '/' 00143 * 00144 * Returns: 00145 * int 00146 ************************************************************************/ 00147 int web_server_set_root_dir( IN const char* root_dir ); 00148 00149 /************************************************************************ 00150 * Function: web_server_callback * 00151 * * 00152 * Parameters: * 00153 * IN http_parser_t *parser, * 00154 * INOUT http_message_t* req, * 00155 * IN SOCKINFO *info * 00156 * * 00157 * Description: main entry point into web server; * 00158 * handles HTTP GET and HEAD requests * 00159 * * 00160 * Returns: * 00161 * void * 00162 ************************************************************************/ 00163 void web_server_callback( IN http_parser_t *parser, IN http_message_t* req, INOUT SOCKINFO *info ); 00164 00165 00166 #ifdef __cplusplus 00167 } // extern C 00168 #endif 00169 00170 00171 #endif // GENLIB_NET_HTTP_WEBSERVER_H
1.6.1