Ejemplo n.º 1
0
Archivo: main.c Proyecto: no-ox/IMAR-C
int main(int argc, char* argv[]){
  
  /*
  char* user = argv[1];
  char* host = argv[2];
  char* pass = argv[3];
  */

  char* user = "******";
  char* host = "157.159.124.129";
  char* pass = "******";

  netbuf* nControl = NULL;

  if(FtpConnect(host, &nControl) != 1){
    perror("Impossible to connect to the ftp server!\n");
    return EXIT_FAILURE;
  }
  if(FtpLogin(user,pass,nControl) != 1){
    perror("Impossible to log to the ftp server!\n");
    return EXIT_FAILURE;
  }
  FtpDir(NULL,".",nControl);  
  FtpQuit(nControl);
  
  return EXIT_SUCCESS;   
}
Ejemplo n.º 2
0
void ftp_connect(void)
{
    if (conn)
        return;
    if (host == NULL)
    {
	fprintf(stderr,"Host name not specified\n");
	usage();
	exit(EX_SYNTAX);
    }
    if (!logged_in)
    {
    	if (user == NULL)
    	{
	    user = "******";
	    if (pass == NULL)
	    {
	    	char *u,h[64];
	    	u = getenv("USER");
	    	if (gethostname(h,64) < 0)
	    	{
		    perror("gethostname");
		    exit(EX_NETDB);
	    	}
	    	if ((u != NULL) && (h != NULL))
	    	{
		    static char xxx[256];
		    sprintf(xxx,"%s@%s",u,h);
		    pass = xxx;
	    	}
	    }
    	}
	else if (pass == NULL)
#if defined(_WIN32) || defined(VMS)
	    exit(EX_LOGIN);
#else
	    if ((pass = getpass("Password: "******"Unable to connect to node %s\n",host);
	    exit(EX_CONNECT);
    	}
    	if (!FtpLogin(user,pass,conn))
    	{
	    fprintf(stderr,"Login failure\n%s",FtpLastResponse(conn));
	    exit(EX_LOGIN);
    	}
	logged_in++;
    }
}
Ejemplo n.º 3
0
int FTPLogin(const CKBehaviorContext& behcontext)
{
	CKBehavior* beh = behcontext.Behavior;
  	CKContext* ctx = behcontext.Context;

		if( beh->IsInputActive(0)){
			beh->ActivateInput(0,FALSE);
	
			HWND win = (HWND)ctx->GetMainWindow();
			FtpInit(win);
			//HFILE hLogFile =  _lcreat (LOG_FILE, 0);
			//FtpLogTo (hLogFile);
			
			
	
			FtpSetDefaultTimeOut (30);
			FtpSetPassiveMode(TRUE);
			FtpSetAsynchronousMode();
	
			int Port;
			beh->GetInputParameterValue(3,&Port);
			


			XString Host((CKSTRING) beh->GetInputParameterReadDataPtr(0));
			XString User((CKSTRING) beh->GetInputParameterReadDataPtr(1));
			XString Pw((CKSTRING) beh->GetInputParameterReadDataPtr(2));
			
			int Login = FtpLogin(Host.Str(),User.Str(),Pw.Str(),win,0);
			beh->SetOutputParameterValue(0,&Login);
			

			if (Login == 0)beh->ActivateOutput(0);
				else{
					beh->ActivateOutput(2);
					return CKBR_OK;
				}
				return CKBR_ACTIVATENEXTFRAME;
			}

		if( beh->IsInputActive(1)){
			beh->ActivateInput(1,FALSE);

			FtpCloseConnection();
			FtpRelease ();
			beh->ActivateOutput(1);
			return CKBR_OK;
		}
	return CKBR_ACTIVATENEXTFRAME;
}
Ejemplo n.º 4
0
char FTPLibFTPTransport::assureLoggedIn() {
    char retVal = 0;
    if (ftpConnection == 0) {
        SWLog::getSystemLog()->logDebug("connecting to host %s\n", host.c_str());
        if (FtpConnect(host, &ftpConnection))
            if (FtpLogin(u.c_str(), p.c_str(), ftpConnection)) {
                retVal = 0;
            }
            else {
                SWLog::getSystemLog()->logError("Failed to login to %s\n", host.c_str());
                retVal = -2;
            }
        else {
            SWLog::getSystemLog()->logError("Failed to connect to %s\n", host.c_str());
            retVal = -1;
        }
    }
    return retVal;
}