Ejemplo n.º 1
0
static int ftpdir(char *host, char *user, char *pass, char *root, char *fspec)
{
    if (!ftpOpen(host))
    {
	fprintf(stderr,"Unable to connect to node %s\n%s",host,ftplib_lastresp);
	return 0;
    }
    if (!ftpLogin(user,pass))
    {
	fprintf(stderr,"Login failure\n%s",ftplib_lastresp);
	return 0;
    }
    if (root != NULL)
    {
	if (!ftpChdir(root))
	{
	    fprintf(stderr,"Change directory failed\n%s",ftplib_lastresp);
	    return 0;
	}
    }
    if (!ftpNlst(NULL,fspec))
    {
	fprintf(stderr,"Directory failure\n%s",ftplib_lastresp);
	return 0;
    }
    ftpQuit();
    return 1;
}
Ejemplo n.º 2
0
int ftpget(char *host, char *user, char *pass, char *root, char mode)
{
    char fnm[256];

    if (!ftpOpen(host))
    {
	fprintf(stderr,"Unable to connect to node %s\n%s",host,ftplib_lastresp);
	return 0;
    }
    if (!ftpLogin(user,pass))
    {
	fprintf(stderr,"Login failure\n%s",ftplib_lastresp);
	return 0;
    }
    if (root)
	if (!ftpChdir(root))
	{
	    fprintf(stderr,"Change directory to %s failed\n%s",
		    root,ftplib_lastresp);
	    return 0;
	}
    while (gets(fnm) != NULL)
    {
	if (!ftpGet(fnm,fnm,mode))
	{
	fprintf(stderr,"Get of %s failed\n%s",fnm,ftplib_lastresp);
	}
	else
	{
	if (ftplib_debug > 1)
		fprintf(stderr,"File %s received\n",fnm);
	}
    }
    ftpQuit();
    return 1;
}