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

📄 cgi.lst

📁 我修改的可以用串口访问的webserver(51平台)
💻 LST
字号:
C51 COMPILER V7.10   CGI                                                                   09/03/2004 09:33:16 PAGE 1   


C51 COMPILER V7.10, COMPILATION OF MODULE CGI
OBJECT MODULE PLACED IN cgi.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE cgi.c LARGE BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /*
   2           * Copyright (c) 2001, Adam Dunkels.
   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           * 1. Redistributions of source code must retain the above copyright 
   9           *    notice, this list of conditions and the following disclaimer. 
  10           * 2. Redistributions in binary form must reproduce the above copyright 
  11           *    notice, this list of conditions and the following disclaimer in the 
  12           *    documentation and/or other materials provided with the distribution. 
  13           * 3. All advertising materials mentioning features or use of this software
  14           *    must display the following acknowledgement:
  15           *      This product includes software developed by Adam Dunkels.
  16           * 4. The name of the author may not be used to endorse or promote
  17           *    products derived from this software without specific prior
  18           *    written permission.  
  19           *
  20           * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  21           * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22           * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23           * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  24           * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25           * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  26           * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27           * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28           * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  29           * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  30           * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
  31           *
  32           * This file is part of the uIP TCP/IP stack.
  33           *
  34           * $Id: cgi.c,v 1.21 2002/01/13 21:12:40 adam Exp $
  35           *
  36           */
  37          
  38          /*
  39           * This file includes functions that are called by the web server
  40           * scripts. The functions takes no argument, and the return value is
  41           * interpreted as follows. A zero means that the function did not
  42           * complete and should be invoked for the next packet as well. A
  43           * non-zero value indicates that the function has completed and that
  44           * the web server should move along to the next script line.
  45           *
  46           */
  47          
  48          #include "uip.h"
  49          #include "cgi.h"
  50          #include "httpd.h"
  51          #include "fs.h"
  52          
  53          #include <stdio.h>
  54          #include <string.h>
  55          
C51 COMPILER V7.10   CGI                                                                   09/03/2004 09:33:16 PAGE 2   

  56          static u8_t print_stats(void);
  57          static u8_t file_stats(void);
  58          static u8_t tcp_stats(void);
  59          
  60          cgifunction cgitab[] = {
  61            print_stats,   /* CGI function "a" */
  62            file_stats,    /* CGI function "b" */
  63            tcp_stats      /* CGI function "c" */
  64          };
  65          
  66          static code char closed[] =   /*  "CLOSED",*/
  67          {0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
  68          static code char syn_rcvd[] = /*  "SYN-RCVD",*/
  69          {0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, 
  70           0x44,  0};
  71          static code char syn_sent[] = /*  "SYN-SENT",*/
  72          {0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, 
  73           0x54,  0};
  74          static code char established[] = /*  "ESTABLISHED",*/
  75          {0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48, 
  76           0x45, 0x44, 0};
  77          static code char fin_wait_1[] = /*  "FIN-WAIT-1",*/
  78          {0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 
  79           0x54, 0x2d, 0x31, 0};
  80          static code char fin_wait_2[] = /*  "FIN-WAIT-2",*/
  81          {0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 
  82           0x54, 0x2d, 0x32, 0};
  83          static code char closing[] = /*  "CLOSING",*/
  84          {0x43, 0x4c, 0x4f, 0x53, 0x49, 
  85           0x4e, 0x47, 0};
  86          static code char time_wait[] = /*  "TIME-WAIT,"*/
  87          {0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, 
  88           0x49, 0x54, 0};
  89          static code char last_ack[] = /*  "LAST-ACK"*/
  90          {0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, 
  91           0x4b, 0};
  92          
  93          static code char *states[] = {
  94            closed,
  95            syn_rcvd,
  96            syn_sent,
  97            established,
  98            fin_wait_1,
  99            fin_wait_2,
 100            closing,
 101            time_wait,
 102            last_ack};
 103            
 104          
 105          /*-----------------------------------------------------------------------------------*/
 106          /* print_stats:
 107           *
 108           * Prints out a part of the uIP statistics. The statistics data is
 109           * written into the uip_appdata buffer. It overwrites any incoming
 110           * packet.
 111           */
 112          static u8_t
 113          print_stats(void)
 114          {
 115   1      #if UIP_STATISTICS
 116   1        u16_t i, j;
 117   1        u8_t *buf;
C51 COMPILER V7.10   CGI                                                                   09/03/2004 09:33:16 PAGE 3   

 118   1        u16_t *databytes;
 119   1        
 120   1        if(uip_acked()) {
 121   2          /* If our last data has been acknowledged, we move on the next
 122   2             chunk of statistics. */
 123   2          hs->count = hs->count + 4;
 124   2          if(hs->count >= sizeof(struct uip_stats)/sizeof(u16_t)) {
 125   3            /* We have printed out all statistics, so we return 1 to
 126   3               indicate that we are done. */
 127   3            return 1;
 128   3          }
 129   2        }
 130   1      
 131   1        /* Write part of the statistics into the uip_appdata buffer. */
 132   1        databytes = (u16_t *)&uip_stat + hs->count;
 133   1        buf       = (u8_t *)uip_appdata;
 134   1      
 135   1        j = 4 + 1;
 136   1        i = hs->count;
 137   1        while (i < sizeof(struct uip_stats)/sizeof(u16_t) && --j > 0) {
 138   2          sprintf((char *)buf, "%5u\r\n", *databytes);
 139   2          ++databytes;
 140   2          buf += 6;
 141   2          ++i;
 142   2        }
 143   1      
 144   1        /* Send the data. */
 145   1        uip_send(uip_appdata, buf - uip_appdata);
 146   1        
 147   1        return 0;
 148   1      #else
                return 1;
              #endif /* UIP_STATISTICS */
 151   1      }
 152          /*-----------------------------------------------------------------------------------*/
 153          static u8_t
 154          file_stats(void)
 155          {
 156   1        /* We use sprintf() to print the number of file accesses to a
 157   1           particular file (given as an argument to the function in the
 158   1           script). We then use uip_send() to actually send the data. */
 159   1        if(uip_acked()) {
 160   2          return 1;
 161   2        }
 162   1        uip_send(uip_appdata, sprintf((char *)uip_appdata, "%5u", fs_count(&hs->script[4])));  
 163   1        return 0;
 164   1      }
 165          /*-----------------------------------------------------------------------------------*/
 166          static u8_t
 167          tcp_stats(void)
 168          {
 169   1        struct uip_conn *conn;  
 170   1      
 171   1        if(uip_acked()) {
 172   2          /* If the previously sent data has been acknowledged, we move
 173   2             forward one connection. */
 174   2          if(++hs->count == UIP_CONNS) {
 175   3            /* If all connections has been printed out, we are done and
 176   3               return 1. */
 177   3            return 1;
 178   3          }
 179   2        }
C51 COMPILER V7.10   CGI                                                                   09/03/2004 09:33:16 PAGE 4   

 180   1        
 181   1        conn = &uip_conns[hs->count];
 182   1        if((conn->tcpstateflags & TS_MASK) == CLOSED) {
 183   2          uip_send(uip_appdata, sprintf((char *)uip_appdata,
 188   2                                        "<tr align=\"center\"><td>-</td><td>-</td><td>%d</td><td>%d</td><td>%c %c</td></tr>\r\n",
 188   2                                        conn->nrtx,
 188   2                                        conn->timer,
 188   2                                        (conn->tcpstateflags & UIP_OUTSTANDING)? '*':' ',
 188   2                                        (conn->tcpstateflags & UIP_STOPPED)? '!':' '));
 189   2        } else {
 190   2          uip_send(uip_appdata, sprintf((char *)uip_appdata,
 201   2                                        "<tr align=\"center\"><td>%d.%d.%d.%d:%d</td><td>%s</td><td>%d</td><td>%d</td><td>%c %c</td></tr>\r\
             -n",
 201   2                                        ntohs(conn->ripaddr[0]) >> 8,
 201   2                                        ntohs(conn->ripaddr[0]) & 0xff,
 201   2                                        ntohs(conn->ripaddr[1]) >> 8,
 201   2                                        ntohs(conn->ripaddr[1]) & 0xff,
 201   2                                        ntohs(conn->rport),
 201   2                                        states[conn->tcpstateflags & TS_MASK],
 201   2                                        conn->nrtx,
 201   2                                        conn->timer,
 201   2                                        (conn->tcpstateflags & UIP_OUTSTANDING)? '*':' ',
 201   2                                        (conn->tcpstateflags & UIP_STOPPED)? '!':' '));
 202   2        }
 203   1        return 0;
 204   1      }
 205          /*-----------------------------------------------------------------------------------*/


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    864    ----
   CONSTANT SIZE    =    303    ----
   XDATA SIZE       =      9      13
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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