⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 http_server.lst

📁 cs8900 c51应用
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   HTTP_SERVER                                                           11/26/2004 11:32:46 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE HTTP_SERVER
OBJECT MODULE PLACED IN .\8052-obj\http_server.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\http\http_server.c LARGE OPTIMIZE(SIZE) BROWSE INTVECTOR(0X2000) INCDIR(
                    -D:\Work\opentcp\1-0-2\src\include\) DEFINE(MONITOR,CS8900) DEBUG OBJECTEXTEND CODE SYMBOLS PRINT(.\8052-lst\http_server.
                    -lst) PREPRINT(.\8052-lst\http_server.i) OBJECT(.\8052-obj\http_server.obj)

stmt level    source

   1          /*
   2           *Copyright (c) 2000-2002 Viola Systems Ltd.
   3           *All rights reserved.
   4           *
   5           *Redistribution and use in source and binary forms, with or without 
   6           *modification, are permitted provided that the following conditions 
   7           *are met:
   8           *
   9           *1. Redistributions of source code must retain the above copyright 
  10           *notice, this list of conditions and the following disclaimer.
  11           *
  12           *2. Redistributions in binary form must reproduce the above copyright 
  13           *notice, this list of conditions and the following disclaimer in the 
  14           *documentation and/or other materials provided with the distribution.
  15           *
  16           *3. The end-user documentation included with the redistribution, if 
  17           *any, must include the following acknowledgment:
  18           *      "This product includes software developed by Viola 
  19           *      Systems (http://www.violasystems.com/)."
  20           *
  21           *Alternately, this acknowledgment may appear in the software itself, 
  22           *if and wherever such third-party acknowledgments normally appear.
  23           *
  24           *4. The names "OpenTCP" and "Viola Systems" must not be used to 
  25           *endorse or promote products derived from this software without prior 
  26           *written permission. For written permission, please contact 
  27           *opentcp@opentcp.org.
  28           *
  29           *5. Products derived from this software may not be called "OpenTCP", 
  30           *nor may "OpenTCP" appear in their name, without prior written 
  31           *permission of the Viola Systems Ltd.
  32           *
  33           *THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 
  34           *WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  35           *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
  36           *IN NO EVENT SHALL VIOLA SYSTEMS LTD. OR ITS CONTRIBUTORS BE LIABLE 
  37           *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
  38           *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
  39           *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
  40           *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  41           *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
  42           *OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
  43           *EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44           *====================================================================
  45           *
  46           *OpenTCP is the unified open source TCP/IP stack available on a series 
  47           *of 8/16-bit microcontrollers, please see <http://www.opentcp.org>.
  48           *
  49           *For more information on how to network-enable your devices, or how to 
  50           *obtain commercial technical support for OpenTCP, please see 
  51           *<http://www.violasystems.com/>.
  52           */
  53           
C51 COMPILER V7.06   HTTP_SERVER                                                           11/26/2004 11:32:46 PAGE 2   

  54          /** \file http_server.c
  55           *      \brief Simple HTTP server
  56           *      \author 
  57           *              \li Jari Lahti (jari.lahti@violasystems.com)
  58           *      \version 1.0
  59           *      \date 9.10.2002
  60           *  \bug
  61           *      \warning
  62           *      \todo
  63           *
  64           *      This file implements a simple http 1.0 server that can manage several
  65           *      simultaneous HTTP connections.
  66           */
  67          #include<inet/datatypes.h>
*** WARNING C318 IN LINE 67 OF ..\http\http_server.c: can't open file 'inet/datatypes.h'
  68          #include<inet/globalvariables.h>
*** WARNING C318 IN LINE 68 OF ..\http\http_server.c: can't open file 'inet/globalvariables.h'
  69          #include<inet/debug.h>
*** WARNING C318 IN LINE 69 OF ..\http\http_server.c: can't open file 'inet/debug.h'
  70          #include<inet/system.h>
*** WARNING C318 IN LINE 70 OF ..\http\http_server.c: can't open file 'inet/system.h'
  71          #include<inet/tcp_ip.h>
*** WARNING C318 IN LINE 71 OF ..\http\http_server.c: can't open file 'inet/tcp_ip.h'
  72          #include<inet/http/http_server.h>
*** WARNING C318 IN LINE 72 OF ..\http\http_server.c: can't open file 'inet/http/http_server.h'
  73          
  74          
  75          UINT8 https_enabled = 0; /**< Defines whether https_init has already been invoked or not */
*** ERROR C129 IN LINE 75 OF ..\HTTP\HTTP_SERVER.C: missing ';' before 'https_enabled'
  76          
  77          /** \brief Used for storing state information about different HTTP sessions
  78           *
  79           *      This is an array of http_server_state structures holding various state 
  80           *      information about the HTTP sessions. HTTP server uses this information
  81           *      to determine actions that need to be taken on sockets.
  82           */
  83          struct http_server_state https[NO_OF_HTTP_SESSIONS];
  84          
  85          /** \brief Initialize HTTP server variables
  86           *      \author 
  87           *              \li Jari Lahti (jari.lahti@violasysems.com)
  88           *      \date 13.10.2002
  89           *
  90           *      This function should be called before the HTTP Server application
  91           *      is used to set the operating parameters of it   
  92           */
  93          INT8 https_init(void)
  94          {
  95                  UINT8 i;
  96                  INT8 soch;
  97          
  98          
  99                  for( i=0; i<NO_OF_HTTP_SESSIONS; i++)
 100                  {
 101                          https[i].state = HTTPS_STATE_FREE;
 102                          https[i].ownersocket = 0;
 103                          https[i].fstart = 0;
 104                          https[i].fpoint = 0;
 105                          https[i].flen  = 0;
 106                          https[i].funacked = 0;
 107                          
 108                          soch =  tcp_getsocket(TCP_TYPE_SERVER, TCP_TOS_NORMAL, TCP_DEF_TOUT, https_eventlistener);
C51 COMPILER V7.06   HTTP_SERVER                                                           11/26/2004 11:32:46 PAGE 3   

 109                          
 110                          if(soch < 0)
 111                          {
 112                                  DEBUGOUT("HTTP Server uncapable of getting socket\r\n");
 113                                  RESET_SYSTEM();
 114                                  /*return(-1);*/
 115                          }
 116                          
 117                          https[i].ownersocket = soch;
 118                          
 119                          kick_WD();
 120                          
 121                          soch = tcp_listen(https[i].ownersocket, HTTPS_SERVERPORT);
 122                          
 123                          if(soch < 0)
 124                          {
 125                                  DEBUGOUT("HTTP Server uncapable of setting socket to listening mode\r\n");
 126                                  RESET_SYSTEM();
 127                                  /*return(-1);*/
 128                          }               
 129                          
 130                  
 131                  } 
 132                  
 133                  https_enabled  = 1;
 134                  
 135                  return(i);      
 136                  
 137          }
 138          
 139          
 140          /********************************************************************************
 141          Function:               https_run
 142          
 143          Parameters:             void    
 144                                          
 145          Return val:             void
 146                                          
 147          Date:                   13.10.2002
 148          
 149          Desc:                   This function is main 'thread' of HTTP server program
 150                                          and should be called periodically from main loop.
 151          *********************************************************************************/
 152          
 153          void https_run (void)
 154          {
 155                  UINT8 i;
 156                  INT16 len;
 157                  static UINT8 ses = 0;
 158                  
 159                  if( https_enabled == 0)
 160                          return;
 161                          
 162                  /* Walk thru all sessions untill we found something to send or so       */
 163                  
 164                  for(i=0; i<NO_OF_HTTP_SESSIONS; i++)
 165                  {
 166                          kick_WD();
 167                          
 168                          if(ses >= NO_OF_HTTP_SESSIONS)
 169                                  ses = 0;
 170          
C51 COMPILER V7.06   HTTP_SERVER                                                           11/26/2004 11:32:46 PAGE 4   

 171                          /* Keep sockets listening       */
 172                          
 173                          if(tcp_getstate(https[ses].ownersocket) < TCP_STATE_LISTENING)
 174                          {
 175                                  tcp_listen(https[ses].ownersocket, HTTPS_SERVERPORT);
 176                                  ses++;
 177                                  continue;       
 178                          }
 179          
 180                          if(https[ses].state != HTTPS_STATE_ACTIVE)
 181                          {
 182                                  ses++;
 183                                  continue;
 184                          }
 185                          
 186                          if(https[ses].funacked != 0)
 187                          {
 188                                  ses++;
 189                                  continue;               
 190                          }
 191                          
 192                          if(https[ses].fstart == 0)
 193                          {
 194                                  ses++;
 195                                  continue;               
 196                          }               
 197                          
 198                          /* End of data? */
 199                          
 200                          if( https[ses].fpoint >= https[ses].flen)
 201                          {
 202                                  tcp_close(https[ses].ownersocket);
 203                                  tcp_abort(https[ses].ownersocket);
 204                                  https_deletesession(ses);
 205                                  
 206                                  ses++;
 207                                  
 208                                  return;                 
 209                          
 210                          }
 211                          
 212                          /* More data to send    */
 213                          
 214                          len = https_loadbuffer(ses, &net_buf[TCP_APP_OFFSET], NETWORK_TX_BUFFER_SIZE - TCP_APP_OFFSET);
 215                                  
 216                          if(len<0)
 217                                  return;
 218                                  
 219                          len = tcp_send(https[ses].ownersocket, &net_buf[TCP_APP_OFFSET], NETWORK_TX_BUFFER_SIZE - TCP_APP_OFFSET
             -, len);        
 220                          
 221                          if(len<0)
 222                          {
 223                                  tcp_close(https[ses].ownersocket);
 224                                  https_deletesession(ses);
 225                                  
 226                                  ses++;
 227          
 228                                  return;                 
 229                          
 230                          }
 231                          
C51 COMPILER V7.06   HTTP_SERVER                                                           11/26/2004 11:32:46 PAGE 5   

 232                          https[ses].funacked = len;
 233                          
 234                          
 235                          /* Serve another session on next run    */
 236                          
 237                          ses++;
 238                          
 239                          return;         
 240                          
 241                  
 242                  }       
 243                  
 244                  
 245          
 246          
 247          }
 248          
 249          /********************************************************************************
 250          Function:               https_eventlistener
 251          
 252          Parameters:             INT8 cbhandle - handle to TCP socket where event is coming from 
 253                                          UINT8 event - type of event
 254                                          UINT32 par1 - parameter the meaning of depends on event
 255                                          UINT32 par2 - parameter the meaning of depends on event

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -