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

📄 main.lst

📁 tini的http-slientC程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.07   MAIN                                                                  06/25/2004 10:50:38 PAGE 1   


C51 COMPILER V7.07, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN c:\keil\projects\libraries_samples\ftpclient\main.obj
COMPILER INVOKED BY: c:\keil\C51\bin\C51.EXE c:\keil\projects\libraries_samples\ftpclient\main.c LARGE OMF2 ROM(D16M) OP
                    -TIMIZE(9,SPEED) BROWSE NOINTVECTOR MODDP2 MODDA VARBANKING DEBUG INCDIR(C:\Keil\C51\INC\Dallas;c:\keil\projects\librarie
                    -s_samples\ftpclient) OBJECT(c:\keil\projects\libraries_samples\ftpclient\main.obj)

stmt level    source

   1          /* ---------------------------------------------------------------------------
   2           *  Copyright (C) 2003 Dallas Semiconductor Corporation, All Rights Reserved.
   3           * 
   4           *  Permission is hereby granted, free of charge, to any person obtaining a
   5           *  copy of this software and associated documentation files (the "Software"),
   6           *  to deal in the Software without restriction, including without limitation
   7           *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
   8           *  and/or sell copies of the Software, and to permit persons to whom the
   9           *  Software is furnished to do so, subject to the following conditions:
  10           * 
  11           *  The above copyright notice and this permission notice shall be included
  12           *  in all copies or substantial portions of the Software.
  13           * 
  14           *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15           *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16           *  MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  17           *  IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
  18           *  OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19           *  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20           *  OTHER DEALINGS IN THE SOFTWARE.
  21           * 
  22           *  Except as contained in this notice, the name of Dallas Semiconductor
  23           *  shall not be used except as stated in the Dallas Semiconductor
  24           *  Branding Policy.
  25           * ---------------------------------------------------------------------------
  26           */
  27          
  28          /*****************************************************************************
  29           *      Module Name : TINI FTP Client Library Test Application
  30           *      Description : This application tests FTPClient library functionality
  31           *         Filename : main.c
  32           *         Compiler : keil C51 Compiler V7.06
  33           ****************************************************************************/
  34          
  35          //include files
  36          #include <reg400.h>
  37          #include "stdio.h"
  38          #include <string.h>
  39          #include <rom400_init.h>
  40          #include <rom400_task.h>
  41          #include <rom400_sock.h>
  42          #include <rom400_kmem.h>
  43          #include <rom400_mem.h>
  44          #include <tini400_dns.h>
  45          #include <rom400_xnetstack.h>
  46          #include "tini400_ftpclient.h"
  47          
  48          //leave 4000h bytes for function parameters
  49          #define RAM_START             0x16000
  50          #define RAM_END               0x6F000
  51          
  52          //file system memory location
  53          #define FS_START              0x70000
C51 COMPILER V7.07   MAIN                                                                  06/25/2004 10:50:38 PAGE 2   

  54          #define FS_BLOCKS             256
  55          
  56          //Static IP Address (used if you are selecting a static IP)
  57          #define STATIC_IP_MSB             180
  58          #define STATIC_IP_2                 0
  59          #define STATIC_IP_3                54
  60          #define STATIC_IP_LSB              94
  61          
  62          //Static Subnet Mask (used if you are selecting a static IP)
  63          #define STATIC_SUBNETMASK_MSB     255
  64          #define STATIC_SUBNETMASK_2       255
  65          #define STATIC_SUBNETMASK_3         0
  66          #define STATIC_SUBNETMASK_LSB       0
  67          
  68          #define STATIC_IPV4_PREFIX         16
  69          
  70          //Static Gateway (used if you are selecting a static IP)
  71          #define STATIC_GATEWAY_MSB        180
  72          #define STATIC_GATEWAY_2            0  
  73          #define STATIC_GATEWAY_3          110
  74          #define STATIC_GATEWAY_LSB         24
  75          
  76          //function declarations
  77          void printfile(char *filename);
  78          void store_files_in_filesystem(void);
  79          
  80          /******************************************************************************
  81           *   Function Name : do_static
  82           *     Description : configures IP address of TINI
  83           *        Input(s) : nothing
  84           *       Output(s) : nothing
  85           *       Destroyed :
  86           *               Notes :
  87           ******************************************************************************/
  88          void do_static()
  89          {
  90   1          unsigned int result;
  91   1          unsigned char xdata config[56];
  92   1          unsigned int i;
  93   1          for (i=0;i<56;i++)
  94   1              config[i] = 0;
  95   1      
  96   1          //set the ip address
  97   1          config[12] = STATIC_IP_MSB;
  98   1          config[13] = STATIC_IP_2;
  99   1          config[14] = STATIC_IP_3;
 100   1          config[15] = STATIC_IP_LSB;
 101   1      
 102   1          //set the subnet mask
 103   1          config[16] = STATIC_SUBNETMASK_MSB;
 104   1          config[17] = STATIC_SUBNETMASK_2;
 105   1          config[18] = STATIC_SUBNETMASK_3;
 106   1          config[19] = STATIC_SUBNETMASK_LSB;
 107   1      
 108   1          //set the iP4 prefix
 109   1          config[20] = STATIC_IPV4_PREFIX;
 110   1      
 111   1          //set the gateway
 112   1          config[33] = STATIC_GATEWAY_MSB;
 113   1          config[34] = STATIC_GATEWAY_2;
 114   1          config[35] = STATIC_GATEWAY_3;
 115   1          config[36] = STATIC_GATEWAY_LSB;
C51 COMPILER V7.07   MAIN                                                                  06/25/2004 10:50:38 PAGE 3   

 116   1      
 117   1          result = setnetworkparams(config);
 118   1      }
 119          
 120          //main function of tini test application
 121          void main(void)
 122          {
 123   1              int status, count, cmd;
 124   1          unsigned int temp;
 125   1              struct sockaddr_in ftp_serv_addr, dns_serv_addr;
 126   1              char inputstr[100], temp1[25], temp2[25],dir_str[1000],*tempptr;
 127   1              struct hostent *phostent;
 128   1              unsigned long ftp_ip,uc0, uc1, uc2, uc3;
 129   1          
 130   1              //for file system.
 131   1              FILE *file;
 132   1          void *start;
 133   1      
 134   1              //print the version number of ftpclient library
 135   1              printf("\n the version information of ftpclient library is : %d",
 136   1                              ftpclient_version());
 137   1      
 138   1              //install extended stack module
 139   1          xnetstack_install();
 140   1                      
 141   1          //install kernel memory manager
 142   1          kmem_install(ROM400_KMEM_MODEL_SMALLEST + 2);
 143   1      
 144   1              //initialize ROM
 145   1              init_rom(RAM_START, RAM_END);
 146   1      
 147   1              //clears socket library parameters
 148   1              clear_param_buffers();
 149   1      
 150   1              //configure IP address
 151   1          do_static();
 152   1      
 153   1              //configure filesystem library
 154   1          start = (void*)FS_START;
*** WARNING C196 IN LINE 154 OF C:\KEIL\PROJECTS\LIBRARIES_SAMPLES\FTPCLIENT\MAIN.C: mspace probably invalid
 155   1          temp = finit(FOPEN_MAX, FS_BLOCKS, start);
 156   1              printf("Result of FS init: %d \r\n", temp);
 157   1      
 158   1              //configure dns library
 159   1              dns_init();
 160   1              dns_settimeout(1000);
 161   1          dns_serv_addr.sin_family = AF_INET;
 162   1          dns_serv_addr.sin_port = htons(53);
 163   1          dns_serv_addr.sin_addr.s_addr=inet_addr("180.0.34.2");
 164   1          memset(&(dns_serv_addr.sin_zero), 0, 12);
 165   1          dns_setprimary((struct sockaddr*)&dns_serv_addr);
 166   1          dns_setsecondary((struct sockaddr*)&dns_serv_addr);
 167   1      
 168   1              //initialize ftp client library with 10 seconds timeout
 169   1              ftpclient_init(10000);
 170   1      
 171   1              //store some datafiles in local file system
 172   1              store_files_in_filesystem();
 173   1      
 174   1              //print ftpclient test application banner
 175   1              printf("\n\n\nDallas Semiconductor TINI FTP v 1.0");
 176   1              printf("\nType \"help\" to get list of ftp commands");
C51 COMPILER V7.07   MAIN                                                                  06/25/2004 10:50:38 PAGE 4   

 177   1      
 178   1              //now, we are ready to accept commands from user
 179   1              while(1)
 180   1              {
 181   2                      printf("\n>>");
 182   2                      gets(inputstr,50);
 183   2      
 184   2                      if(strcmp(inputstr,"help")==0)
 185   2                      {
 186   3                              printf("\nCommand Summary:");
 187   3                              printf("\n----------------");
 188   3                              printf("\nopen  - connect with ftp server, SYNTAX: open server IP address"); 
 189   3                              printf("\nget   - download file from server, SYNTAX: get <<server filename>> <<tini");
 190   3                              printf("\nput   - upload  file to server, SYNTAX: put filename");
 191   3                              printf("\nclose - disconnects from ftp server");
 192   3                              printf("\ncddir  - change directory SYNTAX cddir <<new directory name>>");
 193   3                              printf("\npwd   - display current directory SYNTAX pwd");
 194   3                              printf("\ndir   - displays file name with detailed information SYNTAX: dir or dir filename");
 195   3                              printf("\nmode  - sets file transfer mode, SYNTAX: mode a for ascii, mode b for binary");
 196   3                  printf("\ndataconnectionmode - sets data connection mode, SYNTAX:dataconnectionmode \"a\" for 
             -active,\"p\" for passive");
 197   3                              printf("\ndumpfile -displays tini file content, SYNTAX: dumpfile <<filename>>\n");
 198   3                              continue;
 199   3                      }
 200   2      
 201   2                      if(strncmp(inputstr,"open",4)==0)
 202   2                      {
 203   3                              strcpy(inputstr,strchr(inputstr,' ')+1); //it will store server name
 204   3                                                                                                               //to inputstr
 205   3                              //find out IP address of ftp server
 206   3      
 207   3                          if((ftp_ip = inet_addr(inputstr))==0)
 208   3                  {
 209   4                      phostent= gethostbyname(inputstr);
 210   4          
 211   4                      if((phostent!=NULL)&&(phostent->h_addr_list!=NULL))

⌨️ 快捷键说明

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