🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #2622

re:FTP with Indy Components

#2622
From: adelacu
Date: Fri, 17 Mar 2006 00:03
124 lines
5222 bytes
To start an Indy FTP uploading function do the following:
1.- Insert Indy FTP component in the main Form
2.- Press F1 (help) to learn about it, you may see below some examples
working asyncronous (events).

void ftp_indy_connect( void )
{
glob_ftp.tocc = 0;
Form1->IdFTP1->Host = glob_genconfig.ftp;
Form1->IdFTP1->Port = 21;
Form1->IdFTP1->User = glob_genconfig.ftpusr;
Form1->IdFTP1->Password = glob_genconfig.ftppsw;
Form1->IdFTP1->Connect(4000);
}

void ftp_indy_oper( void )
{
char st1[MAXSTRING];

switch ( glob_ftpstat )
       {
       case FTP_NC:     // Sin conexi�n
            Form1->FTP_Status->Font->Color = clBlack;
            Form1->FTP_Status->Caption =
glob_ftpmsg[0*2+glob_leng];
            if ( (glob_popstat != POP_NC) || (glob_smstat != SM_NC) )
               break;
            if ( (glob_xxfptrin != glob_xxfptrout) &&
(glob_ftp.send != 0) )
               {
               glob_ftpstat = FTP_IC;
               glob_ftp.tocc = 0;
               ftp_indy_connect();
               }
            break;

       case FTP_IC:     // Espera conexi�n
            glob_ftp.tocc++;
            sprintf( st1, "%s: ",
glob_ftpmsg[2*2+glob_leng], glob_ftp.tocc);
            Form1->FTP_Status->Font->Color = clRed;
            Form1->FTP_Status->Caption = st1;
            if ( glob_ftp.tocc >= (glob_ftp.tomax * TTIMERD))
               {
               kprint( glob_ftpmsg[34*2+glob_leng] );
               glob_ftpstat = FTP_NC;
               glob_ftp.send = 0;
               }
            break;

       case FTP_RCON:   // Reci�n conectado
            Form1->FTP_Status->Font->Color = clGreen;
            Form1->FTP_Status->Caption = "Inicia
estabilizaci�n";
            glob_ftpstat = FTP_WSD;
            glob_ftp.tocc = 0;
            break;

       case FTP_WSD:    // Espera que conexi�n se estabilice
            glob_ftp.tocc++;
            Form1->FTP_Status->Font->Color = clGreen;
            Form1->FTP_Status->Caption = "Espera conexi�n
estable";
            if ( glob_ftp.tocc >= 20)
               {
               glob_ftpstat = FTP_001;
               Form1->IdFTP1->ChangeDir(glob_ftp2[
glob_xxfptrout ].dir);
               glob_ftp.tocc = 0;
               }
            if ( glob_ftp.connect == 0 )
               glob_ftpstat = FTP_NC;
            break;

       case FTP_001:    // Espera cambio de directorio
            Form1->FTP_Status->Font->Color = clGreen;
            Form1->FTP_Status->Caption = "Espera cambio
directorio";
            glob_ftp.tocc++;
            if ( glob_ftp.tocc >= 10)
               {
               glob_ftpstat = FTP_002;
               }
            break;

       case FTP_002:    // Cambio de directorio bien
            Form1->FTP_Status->Font->Color = clGreen;
            Form1->FTP_Status->Caption = "Inicia
upload";
            glob_ftpstat = FTP_003;
            Form1->IdFTP1->Put(glob_ftp2[ glob_xxfptrout
].file_local, glob_ftp2[ glob_xxfptrout ].file_remote, false);
            glob_ftp.tocc = 0;
            break;

       case FTP_003:    // Espera upload de archivo
            Form1->FTP_Status->Font->Color = clGreen;
            Form1->FTP_Status->Caption = "Espera
upload";
            glob_ftp.tocc++;
            if ( glob_ftp.tocc >= 1000)
               {
               Form1->IdFTP1->Abort();
               ftp_indy_end();
               }
            break;

       case FTP_IDE:    // Espera desconexi�n
            Form1->FTP_Status->Font->Color = clRed;
            Form1->FTP_Status->Caption = "Espera
desconexi�n";
            if ( glob_ftp.connect == 0 )
               glob_ftpstat = FTP_NC;
            break;

       case FTP_DES:    // Inicia desconexi�n
            glob_xxfptrout++;
            if ( glob_xxfptrout == EQTOT )
               glob_xxfptrout = 0;
            glob_fdaysent++;
            ftp_indy_end();
            break;
       }
}
Technical Details
Message-ID: <I8adnRD-ha5PYYTZRVn-og@giganews.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
References: <441546a6$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,2b63822f8c0bc1f6
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 16 Mar 2006 18:03:30 -0600
Subject: re:FTP with Indy Components
From: andres@adelacu-dot-com.no-spam.invalid (adelacu)
Newsgroups: borland.public.cppbuilder.internet.socket
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
User-Agent: newsSync (BorlandTalk.com) 504619
References: <441546a6$1@newsgroups.borland.com>
Message-ID: <I8adnRD-ha5PYYTZRVn-og@giganews.com>
Date: Thu, 16 Mar 2006 18:03:30 -0600
Lines: 1
X-Trace: sv3-z2z+fyoaHjhGGomzYQw/ht7gogjRlKiD6lJ6b0yzKjfOdw3rxb6x81J/bd4yh0BRGdN0Uf4I/SkQ1rz!Maf1H42QeSzNTHIaCKALOm5DPC4AssQ02c83weJxXGOA8k6TSimkTUTzQXqKoA==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32