00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00021 #include <stdio.h>
00022 #include <afxinet.h> 
00023 #include <Win32ftp.h>
00024 
00025 vmd_ftpclient(const char * site, 
00026             const char * remotefile, 
00027             const char * localfile) {
00028   CInternetSession S("Eagle FTP"); 
00029   CFtpConnection *f; 
00030 
00031   try { 
00032     f = S.GetFtpConnection(site,
00033                            "anonymous",
00034                            "anonymous@anonymous.org",
00035                            21,
00036                            FALSE); 
00037     f->SetCurrentDirectory("/"); 
00038     f->GetFile(remotefile, localfile,
00039                FALSE,
00040                FILE_ATTRIBUTE_NORMAL,
00041                FTP_TRANSFER_TYPE_BINARY,
00042                1);
00043     
00044     delete f; 
00045     S.Close(); 
00046   
00047     return FTP_SUCCESS;
00048   } 
00049 
00050   catch (CInternetException) { 
00051     printf("FTP Error!\n"); 
00052     return FTP_FAILURE;
00053   } 
00054 
00055   return FTP_SUCCESS;
00056 } 
00057 
00058 #if defined(FTPMAIN)
00059 int main(int argc, char **argv) {
00060   int rc;
00061   printf("VMD Win32 FTP Client\n");
00062   if (argc != 4) {
00063     printf("usage: %s ftp.rcsb.org /pub/README README.txt\n", argv[0]);
00064     return FTP_FAILURE;
00065   }
00066 
00067   printf("%s:%s:%s\n",argv[1], argv[2], argv[3]);
00068 
00069   rc=vmd_ftpclient(argv[1], argv[2], argv[3]);   
00070 
00071   if (rc != FTP_SUCCESS) {
00072     printf("FTP failed.\n"); 
00073   }
00074   return rc;
00075 }
00076 #endif
00077