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

📄 main.lst

📁 tini的http-slientC程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
 212   4                      {
 213   5      
 214   5                          uc0=(unsigned char)phostent->h_addr_list[0][0];
 215   5                          uc1=(unsigned char)phostent->h_addr_list[0][1];
 216   5                          uc2=(unsigned char)phostent->h_addr_list[0][2];
 217   5                          uc3=(unsigned char)phostent->h_addr_list[0][3];
 218   5      
 219   5          
 220   5                          ftp_ip=((uc0 << 24) | (uc1 << 16) | (uc2 << 8) | uc3);
 221   5      
 222   5                      }
 223   4                      else
 224   4                      {
 225   5                          printf("IP address for %s is not available",inputstr);
 226   5                          continue;
 227   5                      }
 228   4                  }
 229   3          
 230   3                      ftp_serv_addr.sin_addr.s_addr = ftp_ip;
 231   3                  ftp_serv_addr.sin_port=0;
 232   3                          ftp_serv_addr.sin_family = AF_INET;
 233   3                          memset(&(ftp_serv_addr.sin_zero), 0, 12);
 234   3      
 235   3                              printf("\nuser:");
 236   3                              scanf("%s",temp1);
 237   3                              printf("\npassword:");
C51 COMPILER V7.07   MAIN                                                                  06/25/2004 10:50:38 PAGE 5   

 238   3                              scanf("%s",temp2);
 239   3      
 240   3                              if((status=ftpclient_connect(&ftp_serv_addr, temp1, temp2))!=230)
 241   3                                      printf("\nftp error: %d",status);
 242   3                              else
 243   3                                      printf("\n%s logged-in",temp1);
 244   3      
 245   3                              continue;                                       
 246   3                      }
 247   2      
 248   2                      if(strcmp(inputstr,"close")==0)
 249   2                      {
 250   3                              if((status=ftpclient_disconnect())!=FTPSERVER_CLOSE_CTRL_CONNECTION)
 251   3                                      printf("\nftp error: %d",status);
 252   3                              else
 253   3                                      printf("\nOkay! connection closed successfully");
 254   3                              continue;
 255   3                      }
 256   2      
 257   2                      if(strncmp(inputstr,"dir",3)==0)
 258   2                      {
 259   3                              tempptr=strchr(inputstr,' ');
 260   3                              if((status=ftpclient_dir(tempptr,dir_str,1000,           \
 261   3                                      FTPCLIENT_DETAILED_DIRLISTING))!=226)
 262   3                  {
 263   4                                      printf("\nftp error: %d",status);
 264   4                  }
 265   3                              else
 266   3                  {   
 267   4                                      printf("%s",dir_str);           
 268   4                  }
 269   3                              continue;
 270   3                      }
 271   2      
 272   2                      if(strncmp(inputstr,"cddir",5)==0)
 273   2                      {
 274   3                              tempptr=strchr(inputstr,' ');
 275   3                  while(*tempptr==' ') tempptr++;
 276   3                              if((status=ftpclient_cd(tempptr))!=250)
 277   3                                      printf("\nftp error: %d",status);
 278   3                              else
 279   3                                      printf("\ndirectory successfully changed");
 280   3                              continue;
 281   3                      }
 282   2      
 283   2                      if(strncmp(inputstr,"pwd",3)==0)
 284   2                      {
 285   3                              if((status=ftpclient_pwd(dir_str,1000))!=257)
 286   3                                      printf("\nftp error: %d",status);
 287   3                              else
 288   3                                      printf("%s",dir_str);           
 289   3                              continue;
 290   3                      }
 291   2      
 292   2                      if(strncmp(inputstr,"get",3)==0)
 293   2                      {
 294   3                              printf("enter server file name:");
 295   3                              scanf("%s",temp1);
 296   3                              printf("enter tini file name:");
 297   3                              scanf("%s",temp2);
 298   3                              if((status=ftpclient_getfile(temp1,temp2))!=226)
 299   3                                      printf("\nftp error: %d",status);
C51 COMPILER V7.07   MAIN                                                                  06/25/2004 10:50:38 PAGE 6   

 300   3                              else
 301   3                                      printf("file was successfully downloaded");             
 302   3                              continue;
 303   3                              
 304   3                      }
 305   2      
 306   2                      if(strncmp(inputstr,"put",3)==0)
 307   2                      {
 308   3                              printf("enter server file name:");
 309   3                              scanf("%s",temp2);
 310   3                              printf("enter tini file name:");
 311   3                              scanf("%s",temp1);
 312   3                              if((status=ftpclient_putfile(temp1,temp2))!=226)
 313   3                                      printf("\nftp error: %d",status);
 314   3                              else
 315   3                                      printf("file was successfully uploaded");               
 316   3                              continue;
 317   3                      }
 318   2                      if(strncmp(inputstr,"mode",4)==0)
 319   2                      {
 320   3                              tempptr=strchr(inputstr,' ');
 321   3                              if(*(tempptr+1)=='a')
 322   3                                      status=ftpclient_settransmissionmode(FTPCLIENT_ASCII);
 323   3                              else
 324   3                                      status=ftpclient_settransmissionmode(FTPCLIENT_BINARY);
 325   3          
 326   3                  printf("\nreturn value: %d",status);
 327   3                      }
 328   2              if(strncmp(inputstr,"dataconnectionmode",18)==0)
 329   2                      {
 330   3                              tempptr=strchr(inputstr,' ');
 331   3                              if(*(tempptr+1)=='p')
 332   3                  {
 333   4                                      ftpclient_setdataconnectionmode(FTPCLIENT_PASSIVE_MODE);
 334   4                      printf("\npassive mode is set");
 335   4                  }
 336   3                              else
 337   3                  {
 338   4                                      ftpclient_setdataconnectionmode(FTPCLIENT_ACTIVE_MODE);
 339   4                      printf("\nactive mode is set");
 340   4      
 341   4                  }
 342   3                      
 343   3                      }
 344   2                      if(strncmp(inputstr,"dumpfile",8)==0)
 345   2                      {
 346   3                              tempptr=strchr(inputstr,' ');
 347   3                              printfile(tempptr+1);
 348   3                      }
 349   2              }
 350   1              while(1)
 351   1              {
 352   2              }
 353   1      }
*** WARNING C280 IN LINE 123 OF C:\KEIL\PROJECTS\LIBRARIES_SAMPLES\FTPCLIENT\MAIN.C: 'count': unreferenced local variabl
             -e
*** WARNING C280 IN LINE 123 OF C:\KEIL\PROJECTS\LIBRARIES_SAMPLES\FTPCLIENT\MAIN.C: 'cmd': unreferenced local variable
*** WARNING C280 IN LINE 131 OF C:\KEIL\PROJECTS\LIBRARIES_SAMPLES\FTPCLIENT\MAIN.C: 'file': unreferenced local variable
 354          
 355          //print file content
 356          void printfile(char *filename)
 357          {
C51 COMPILER V7.07   MAIN                                                                  06/25/2004 10:50:38 PAGE 7   

 358   1          int temp, _eof;
 359   1              FILE *file;
 360   1              file = fopen(filename, "r");
 361   1              if (file==NULL)
 362   1              {
 363   2                      printf("\n file not found");
 364   2                      return;
 365   2              }
 366   1              printf("\nfile contents:");
 367   1          temp = fgetc(file);
 368   1      
 369   1          while (temp != -1)
 370   1          {
 371   2              if(temp==0)
 372   2                  printf("\\0");
 373   2              else
 374   2                  printf("%c", (char)temp);
 375   2      
 376   2              temp = fgetc(file);
 377   2          }
 378   1              printf("\r\n");
 379   1              fclose(file);
 380   1      }
*** WARNING C280 IN LINE 358 OF C:\KEIL\PROJECTS\LIBRARIES_SAMPLES\FTPCLIENT\MAIN.C: '_eof': unreferenced local variable
 381          
 382          //store files in filesystem
 383          void store_files_in_filesystem(void)
 384          {
 385   1              FILE *fp;
 386   1          int temp, _eof;
 387   1      
 388   1              //open the file
 389   1              fp=fopen("test.dat","w");
 390   1              
 391   1              if(fp==NULL)
 392   1              {
 393   2                      printf("\nfile could not be opened");
 394   2                      return;
 395   2              }
 396   1      
 397   1              //write the content to the file
 398   1              fputs("This is test data file",fp);
 399   1              fputs("\n\n\n\nThere is nothing either good or bad but thinking makes it so --William Shakespeare\n\n\n",
             -fp);
 400   1          fwrite("string with embedded zerooo\0\0\0\0\0\0ooooos",1,39,fp);
 401   1      
 402   1              //close the file
 403   1              fclose(fp);
 404   1              return;
 405   1      }
*** WARNING C280 IN LINE 386 OF C:\KEIL\PROJECTS\LIBRARIES_SAMPLES\FTPCLIENT\MAIN.C: 'temp': unreferenced local variable
*** WARNING C280 IN LINE 386 OF C:\KEIL\PROJECTS\LIBRARIES_SAMPLES\FTPCLIENT\MAIN.C: '_eof': unreferenced local variable
 406          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2270    ----
   CONSTANT SIZE    =   1514    ----
   XDATA SIZE       =   ----    1301
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
C51 COMPILER V7.07   MAIN                                                                  06/25/2004 10:50:38 PAGE 8   

   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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