<< Back
// SampleC-XFer-One-Step.c : Sample FTP Voyager SDK Application
//
// Copyright © 1997-2008 - Rhino Software, Inc.
// FTP Voyager® is a registered trademark of Rhino Software, Inc.
// http://www.RhinoSoft.com/
//
// Author:  Mark P. Peterson
// Date:    September 27, 2005
//
// You are free to use/modify this code but leave this header intact.
// This code is public domain so you are free to use it in any of your
// applications (Freeware, Trialware, Commercial, etc.).  FTP Voyager,
// the FTP Voyager Software Development Kit, and FtpTree ActiveX Control
// are not public domain.  Any registration IDs or non-public domain software
// from Rhino Software, Inc. remains copyrighted.  For more information,
// refer to the license agreement distributed with the FTP Voyager SDK.
//
// If you decide to use the FTP Voyager Software Development Kit, or FtpTree
// ActiveX control, you must first purchase a license.  For more information
// visit http://www.RhinoSoft.com/
//------------------------------------------------------------------------------
//
// The following program is a simple C language program designed to help learn
// the following FTP Voyager Software Development Kit concepts:
//
//   * creating an FVSDK_Session
//   * settting the required FVSDK_Session members
//   * connecting to the server
//   * downloading a file in one step using FVSDK_Download()
//   * disconnecting from the server
//   * freeing the session
//
//------------------------------------------------------------------------------

#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include "FVSDK_Funcs.h"

int main(int argc, char* argv[])
{
    int             nRet = 0;
    FVSDK_Session*  pSession;

    // allocate and initialize the session in the SDK
    if (FVSDK_NewSession(&pSession) == FVSDK_OK) {

        // set the server name to connect to
        pSession->pszServer = "ftp.rhinosoft.com";

        // show the pop-up transfer dialog
        pSession->bShowTransferDialogs = TRUE;

        // try to connect to the server
        if (FVSDK_Connect(pSession) == FVSDK_OK) {

            // download the file from the server
            if (FVSDK_Download(pSession, "/rhinosoft/00index.txt", "C:\\Temp\\00index.txt") != FVSDK_OK)
                nRet = 3;

            // disconnect from the server
            FVSDK_Disconnect(pSession);
        } // if
        else
            nRet = 2;

        // close and release the session
        FVSDK_FreeSession(pSession);
    } // if
    else
        nRet = 1;

    // display any error or a success message
    if (nRet)
        printf("error: %d\r\n", nRet);
    else
        printf("File transferred successfully.\r\n");

    // tell the user to press a key on the keyboard
    printf("Press any key --> ");

    // wait for the user to press a key on the keyboard
    getch();

    // exit from our application, 0 == success, otherwise an error
    return (nRet);
} // main