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; }
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; }