home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 15
/
CD_ASCQ_15_070894.iso
/
vrac
/
wsftp2.zip
/
LOGIN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-06-03
|
3KB
|
126 lines
// larry kahn addition to ws_ftp32 to support the default
// ws_ftp32 host:directory/file format to automaticall logon and retrieve the
// file
//----------------------
#include "ws_glob.h"
#include "WS_ftp.H"
#include "version.h"
#include <process.h>
extern void set_busy(BOOLEAN);
char hostname[150];
char pathname[256];
void login_retrieve(remotename)
char *remotename;
{
char shortname[80];
char tmp[80];
char localname[220];
int nRC = 0;
char *lastslash;
char rname2[220];
// lgk before calling makelocalname we need to strip only the name
// off of the remotepath/name so keep looking for / until we don't find
// one
lastslash = strrchr(remotename,'/');
strcpy(rname2,lastslash+1);
MakeLocalName(localname,shortname,rname2);
DoPrintf("receiving %s as %s",remotename,localname);
wsprintf(tmp,"RETR %s",remotename);
nRC=RetrieveFile((SOCKET)ctrl_socket,(LPSTR)tmp,
(LPSTR)localname,(LPSTR)shortname,fType);
if(nRC==2)
SendMessage(hLbxLFiles,LB_ADDSTRING,0,(LONG)remotename);
// GetLocalDirForWnd(hWnd);
}
DWORD login_connect()
{
strcpy(szRemoteHost,hostname);
DoPrintf("sz remote hostname = %s \n",szRemoteHost);
use_gateway = 0;
lstrcpy(szUserID,"anonymous");
lstrcpy(szPassWord,szMailAddress);
ctrl_socket=(SOCKET)DoConnect(szRemoteHost);
if(ctrl_socket!=INVALID_SOCKET)
{
// no need to change directory got connected just get file
login_retrieve(pathname);
}
set_busy(FALSE);
// only exit if download suceeded
if (globalsucceed == TRUE)
{
exit(0);
}
return 0;
}
int check_command_line()
{
// char filename[256];
LPSTR commandline = NULL;
char *sptr = NULL;
char *colon = NULL;
commandline = GetCommandLine();
if (commandline == NULL)
DoPrintf("Error getting command line\n");
// see if we have :
else
{
// lgk need to find colon after first space so we don't find colons
// in the executable name
{
// now that we have the command line skip over to the execut. name
sptr = strstr(commandline," ");
if (sptr == NULL)
{
return 0;
}
else
{
colon = strstr(sptr,":");
if (colon == NULL)
{
return 0;
}
else
{
/* ok we have a colon now pull of the host name */
strncpy(hostname,sptr+1,colon-(sptr+1));
/* now get the file name */
strcpy(pathname,(LPSTR)colon+1);
// print out for debugging
// DoPrintf("Host name is %s path name is %s \n",hostname,pathname);
set_busy(TRUE);
threadhandle = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)login_connect,NULL,0,&threadid);
return 1;
}
}
}
}
}