Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Win32ftp.C

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2011 The Board of Trustees of the
00004  *cr                        University of Illinois
00005  *cr                         All Rights Reserved
00006  *cr
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: Win32ftp.C,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.12 $      $Date: 2010/12/16 04:08:52 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *   Very simple Windows FTP client code used for past implementations
00019  *   of webpdb/mol pdbload 
00020  ***************************************************************************/
00021 
00022 #include <stdio.h>
00023 #include <afxinet.h> 
00024 #include <Win32ftp.h>
00025 
00026 vmd_ftpclient(const char * site, 
00027             const char * remotefile, 
00028             const char * localfile) {
00029   CInternetSession S("Eagle FTP"); 
00030   CFtpConnection *f; 
00031 
00032   try { 
00033     f = S.GetFtpConnection(site,
00034                            "anonymous",
00035                            "anonymous@anonymous.org",
00036                            21,
00037                            FALSE); 
00038     f->SetCurrentDirectory("/"); 
00039     f->GetFile(remotefile, localfile,
00040                FALSE,
00041                FILE_ATTRIBUTE_NORMAL,
00042                FTP_TRANSFER_TYPE_BINARY,
00043                1);
00044     
00045     delete f; 
00046     S.Close(); 
00047   
00048     return FTP_SUCCESS;
00049   } 
00050 
00051   catch (CInternetException) { 
00052     printf("FTP Error!\n"); 
00053     return FTP_FAILURE;
00054   } 
00055 
00056   return FTP_SUCCESS;
00057 } 
00058 
00059 #if defined(FTPMAIN)
00060 int main(int argc, char **argv) {
00061   int rc;
00062   printf("VMD Win32 FTP Client\n");
00063   if (argc != 4) {
00064     printf("usage: %s ftp.rcsb.org /pub/README README.txt\n", argv[0]);
00065     return FTP_FAILURE;
00066   }
00067 
00068   printf("%s:%s:%s\n",argv[1], argv[2], argv[3]);
00069 
00070   rc=vmd_ftpclient(argv[1], argv[2], argv[3]);   
00071 
00072   if (rc != FTP_SUCCESS) {
00073     printf("FTP failed.\n"); 
00074   }
00075   return rc;
00076 }
00077 #endif
00078 

Generated on Wed May 23 01:50:36 2012 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002