<< Back
// SampleC.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 23, 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 equivalent to the famous "Hello World!" program
// that all C and C++ programmers are supposed to write.  This basic program:
//
//   * creating an FVSDK_Session
//   * settting the required FVSDK_Session members
//   * connecting to the server
//   * disconnecting from the server
//   * freeing the session
//
// After successfully connecting, but before disconnecting operations such as
// downloading and uploading may be performed.
//
//------------------------------------------------------------------------------

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


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

    // create a new session
    if (FVSDK_NewSession(&pSession) == FVSDK_OK) {

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

        // try to connect to the server, display an error message if we were unable to connect
        if (FVSDK_Connect(pSession) == FVSDK_OK) {

            // display a message that we are connected
            printf("Connected to the server: %s\r\n", pSession->pszServer);

            // to download a file in one step use FVSDK_Download(pSession, pszSourcePath, pszDestPath);
            // to upload a file in one step use FVSDK_Upload(pSession, pszSourcePath, pszDestPath);

            // disconnect from the server
            FVSDK_Disconnect(pSession);
        } // if
        else
            printf("Unable to connect to the specified server\r\n");

        // release (deallocate) the session
        FVSDK_FreeSession(pSession);
    } // if
    else
        printf("Unable to create a new session.\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
    return (0);
} // main