Category : C Source Code
Archive   : FTPTST.ZIP
Filename : FTPTST.C

 
Output of file : FTPTST.C contained in archive : FTPTST.ZIP
#include
#include
#include
#include
#include

#define HOST_NAME_SIZE (32*sizeof(char))
#define USER_NAME_SIZE (32*sizeof(char))
#define ACCOUNT_NAME_SIZE (32*sizeof(char))
#define PASSWORD_SIZE (16*sizeof(char))


ftpcon *StartFtpConnection(host, username, password, account)
in_name host;
char *username;
char *password;
char *account;

{
ftpcon *ftp;

if( (ftp = ftp_open (host, 256, 512)) == NULL)
{
printf("\nCan't Open FTP Connection\n");
exit(1);
}

switch (ftp_user(ftp, username) ) {

case FTP_ERROR:
printf("\n Server rejected username: %s\n", ftp_msgbuf(ftp));
return NULL;
break;

case FTP_GOAHEAD:
printf("\n The Server Accepted userid %s without a password\n",
username);

case FTP_NEED_PASSWORD:
printf("\n Sending Password ...\n");
switch ( ftp_pass(ftp, password)) {
case FTP_ERROR:
printf("\n Server rejected password: %s\n",
ftp_msgbuf(ftp));
return NULL;

case FTP_GOAHEAD:
printf("\n Server accepted password; all done\n");
return ftp;

case FTP_NEED_ACCOUNT:
printf("\n Sending Account \n");
switch (ftp_acct(ftp, account)) {
case FTP_ERROR:
printf("\n Server rejected account: %s\n",
ftp_msgbuf(ftp));
return NULL;

case FTP_GOAHEAD:
printf("\nserver accepted account!\n");
return ftp;
default:
printf("\nInvalid return from fpt_acct");
return NULL;
}
default:
printf("\nInvalid return from fpt_pass");
return NULL;
}
default:
printf("\nInvalid return from fpt_user");
return NULL;
}

printf("\n How'd we get here!");
return NULL;

}

main (argc, argv)
int argc;
char **argv;
{
int i;
ftpcon *ftp_port;
char *Hostname, *Username, *Account, *Password;
in_name host;

if ( (Hostname = malloc ( HOST_NAME_SIZE )) == NULL)
{
perror("NOMEMAVAIL");
exit(2);
}

if ( (Username = malloc ( USER_NAME_SIZE )) == NULL)
{
perror("NOMEMAVAIL");
exit(2);
}

if ( (Account = malloc ( ACCOUNT_NAME_SIZE )) == NULL)
{
perror("NOMEMAVAIL");
exit(2);
}

if ( (Password = malloc ( PASSWORD_SIZE )) == NULL)
{
perror("NOMEMAVAIL");
exit(2);
}


for(i=0;i<25;i++)
printf("\n");

printf("\nTesting the PC/TCP FTP System Calls...");

printf("\n Give the following information:\n");
printf("\n Hostname, Username, Password, Account");

printf("\nHostname ?");
scanf("%s", Hostname);

printf("\nUsername ?");
scanf("%s", Username);

printf("\nPassword ?");
scanf("%s", Password);

printf("\nAccount ?");
scanf("%s", Account);

printf("\n Starting FTP Process...");
printf("\n Resolving Hostname ...");

if (! (host = nm_res_name ( Hostname, (char *) NULL)))
{
pneterror ("can't resolve hostname");
exit(1);
}

printf("\n Calling StartFtpConnect ...");

if( (ftp_port = StartFtpConnection(host, Username, Password, Account))==NULL)
{
printf("\n ftpcon * structure returned NULL ... aborting \n");
exit(-1);
}

ftp_close( ftp_port );

}


  3 Responses to “Category : C Source Code
Archive   : FTPTST.ZIP
Filename : FTPTST.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/