Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages   Examples  

/opentcp/http/https_callbacks.c

Go to the documentation of this file.
00001 /*
00002  *Copyright (c) 2000-2002 Viola Systems Ltd.
00003  *All rights reserved.
00004  *
00005  *Redistribution and use in source and binary forms, with or without 
00006  *modification, are permitted provided that the following conditions 
00007  *are met:
00008  *
00009  *1. Redistributions of source code must retain the above copyright 
00010  *notice, this list of conditions and the following disclaimer.
00011  *
00012  *2. Redistributions in binary form must reproduce the above copyright 
00013  *notice, this list of conditions and the following disclaimer in the 
00014  *documentation and/or other materials provided with the distribution.
00015  *
00016  *3. The end-user documentation included with the redistribution, if 
00017  *any, must include the following acknowledgment:
00018  *      "This product includes software developed by Viola 
00019  *      Systems (http://www.violasystems.com/)."
00020  *
00021  *Alternately, this acknowledgment may appear in the software itself, 
00022  *if and wherever such third-party acknowledgments normally appear.
00023  *
00024  *4. The names "OpenTCP" and "Viola Systems" must not be used to 
00025  *endorse or promote products derived from this software without prior 
00026  *written permission. For written permission, please contact 
00027  *opentcp@opentcp.org.
00028  *
00029  *5. Products derived from this software may not be called "OpenTCP", 
00030  *nor may "OpenTCP" appear in their name, without prior written 
00031  *permission of the Viola Systems Ltd.
00032  *
00033  *THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 
00034  *WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00035  *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
00036  *IN NO EVENT SHALL VIOLA SYSTEMS LTD. OR ITS CONTRIBUTORS BE LIABLE 
00037  *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00038  *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
00039  *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
00040  *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
00041  *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
00042  *OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
00043  *EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00044  *====================================================================
00045  *
00046  *OpenTCP is the unified open source TCP/IP stack available on a series 
00047  *of 8/16-bit microcontrollers, please see <http://www.opentcp.org>.
00048  *
00049  *For more information on how to network-enable your devices, or how to 
00050  *obtain commercial technical support for OpenTCP, please see 
00051  *<http://www.violasystems.com/>.
00052  */
00053 
00069 #include<inet/datatypes.h>
00070 #include<inet/debug.h>
00071 #include<inet/globalvariables.h>
00072 #include<inet/system.h>
00073 #include<inet/http/http_server.h>
00074 
00075 
00081 const char https_not_found_page[] = "HTTP/1.0 200 OK\r\n
00082 Last-modified: Fri, 18 Oct 2002 12:04:32 GMT\r\n
00083 Server: ESERV-10/1.0\nContent-type: text/html\r\n
00084 Content-length: 400\r\n
00085 \r\n
00086 <HEAD>
00087 <TITLE>Viola Systems Embedded WEB Server</TITLE></HEAD>
00088 <BODY>
00089 <H2>HTTP 1.0 404 Error. File Not Found</H2>
00090 The requested URL was not found on this server.
00091 <HR>
00092 <BR>
00093 <I>
00094 Viola Systems Embedded WEB Server 2.0, 2002
00095 <BR>
00096 Web Server for Embedded Applications
00097 </I>
00098 <BR>
00099 <A HREF=http://www.violasystems.com>
00100 www.violasystems.com - Embedding The Internet</A>
00101 </BODY>";
00102 
00124 INT16 https_findfile (UINT8 hash, UINT8 ses)
00125 {
00126         /* Access the File table on FLASH with given hash key   */
00127         /* and modify session File parametera                                   */
00128         
00129         
00130         /* 
00131         if( file_not_found )
00132         {
00133                 File not found, initialize return message
00134                                         
00135                 https[ses].fstart = 0xFFFFFFFF;
00136                 https[ses].funacked  = 0;
00137                 https[ses].flen = strlen(&https_not_found_page[0], 1000);
00138                 https[ses].fpoint = 0;
00139                 
00140                 return(-1);
00141         }
00142         */
00143         
00144         /* OK, file found. */   
00145         /* Modify structure     
00146         https[ses].fstart = file start address;
00147         https[ses].flen = file length;
00148         https[ses].fpoint = current pointer within the file
00149         https[ses].funacked = 0;        no unacked data for now
00150         */
00151         return(1);  
00152         
00153 }
00154 
00173 INT16 https_loadbuffer (UINT8 ses, UINT8* buf, UINT16 buflen) {
00174         UINT16 i;
00175         
00176         if( https[ses].fstart == 0xFFFFFFFF )
00177         {
00178                 /* Error site asked     */
00179                 
00180                 kick_WD();
00181                 
00182                 for(i=0; i < (https[ses].flen - https[ses].fpoint); i++)
00183                 {
00184                         if(i >= buflen)
00185                                 break;
00186                 
00187                         *buf++ = https_not_found_page[https[ses].fpoint + i];
00188                 
00189                 }
00190                 
00191                 return(i);
00192         
00193         }
00194         
00195         /* Access some storage media (internal/external flash...)*/
00196         
00197         for(i=0; i < (https[ses].flen - https[ses].fpoint); i++)
00198         {
00199                 if(i >= buflen)
00200                         break;  
00201                 
00202                 kick_WD();
00203                 /*
00204                 
00205                 *buf++ = next_data_byte(...);
00206                 
00207                 */
00208                 
00209         
00210         }
00211         
00212         return(i);
00213         
00214 
00215 
00216 }

Generated on Sun Aug 3 20:32:59 2003 for OpenTCP by doxygen1.2.18