Exemplo n.º 1
0
Arquivo: main.c Projeto: 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;   
}
Exemplo 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++;
    }
}
Exemplo n.º 3
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;
}