diff options
Diffstat (limited to 'lib/libftp/utils')
-rw-r--r-- | lib/libftp/utils/Makefile | 6 | ||||
-rw-r--r-- | lib/libftp/utils/ftptry.c | 120 | ||||
-rw-r--r-- | lib/libftp/utils/glob.c | 46 | ||||
-rw-r--r-- | lib/libftp/utils/glob.h | 2 | ||||
-rw-r--r-- | lib/libftp/utils/mirror.c | 8 | ||||
-rw-r--r-- | lib/libftp/utils/readline.c | 42 | ||||
-rw-r--r-- | lib/libftp/utils/uftp.c | 232 | ||||
-rw-r--r-- | lib/libftp/utils/uftpcmd.c | 346 |
8 files changed, 401 insertions, 401 deletions
diff --git a/lib/libftp/utils/Makefile b/lib/libftp/utils/Makefile index d750ca7..bae516b 100644 --- a/lib/libftp/utils/Makefile +++ b/lib/libftp/utils/Makefile @@ -25,10 +25,10 @@ uftp: uftp.o uftpcmd.o libetc.a mirror: mirror.o $(CC) $(CFLAGS) -o mirror mirror.o ${LDADD} -lftp -clean: +clean: rm -f ftptry mirror uftp *~ *.o *.a -LIBOBJS= readline.o glob.o -libetc.a: $(LIBOBJS) +LIBOBJS= readline.o glob.o +libetc.a: $(LIBOBJS) ar qc libetc.a $(LIBOBJS) ranlib libetc.a diff --git a/lib/libftp/utils/ftptry.c b/lib/libftp/utils/ftptry.c index 623d0da..7dfb130 100644 --- a/lib/libftp/utils/ftptry.c +++ b/lib/libftp/utils/ftptry.c @@ -2,9 +2,9 @@ Library for ftpd clients.(libftp) Copyright by Oleg Orel All rights reserved. - -This library is desined for free, non-commercial software creation. -It is changeable and can be improved. The author would greatly appreciate + +This library is desined for free, non-commercial software creation. +It is changeable and can be improved. The author would greatly appreciate any advises, new components and patches of the existing programs. Commercial usage is also possible with participation of it's author. @@ -27,7 +27,7 @@ will be described in usage, if the program is started without them.\n\ \n\ The libftp you may transfer from host lpuds.oea.ihep.su via ftp-anonymous.\n\ All question are sent to author via e-mail (orel@oea.ihep.su)\n\ - "; + "; #include <FtpLibrary.h> #include <sys/types.h> @@ -95,7 +95,7 @@ main(int argc,char **argv) if (setjmp(trap)!=0) exit(1); - + signal(SIGHUP,sighup); signal(SIGTRAP,done); signal(SIGINT,done); @@ -106,13 +106,13 @@ main(int argc,char **argv) gethost()); progname=argv[0]; - + FtpDebug(&FtpInit); FtpSetErrorHandler(&FtpInit,my_abort); FtpSetIOHandler(&FtpInit,my_IO); FtpSetFlag(&FtpInit,FTP_REST); FtpSetTimeout(&FtpInit,DEFAULT_TIMEOUT); - + setoptions(); optind=1; options(argc,argv); @@ -122,7 +122,7 @@ main(int argc,char **argv) { case lm_file: - + if (fork()) quit("Deattaching....."); close(0);close(1);close(2); @@ -133,7 +133,7 @@ main(int argc,char **argv) } else strcpy(tmp,logfile); - + open(tmp,O_TRUNC|O_CREAT|O_WRONLY,0600); dup(0); dup(0); @@ -142,23 +142,23 @@ main(int argc,char **argv) case lm_mail: - + if (fork()) quit("Deattaching....."); - + close(0);close(1);close(2); if (popen("/usr/lib/sendmail -t","w")==NULL) perror("sendmail"), quit(""); - + dup(0); dup(0); - + printf("From: %s@%s\n",USERNAME,gethost()); printf("To: %s@%s\n",USERNAME,gethost()); - printf("Subject: ftptry session log\n\n"); - + printf("Subject: ftptry session log\n\n"); + fflush(stdout); - + break; } @@ -174,12 +174,12 @@ main(int argc,char **argv) INLINE noargs(int argc, char **argv, int optind) { int i; - + for (i=optind;i<argc;i++) if (argv[i]!=NULL) return 0; return 1; } - + /* Main loop */ @@ -192,15 +192,15 @@ loop(int argc, char **argv, int optind /* First args as filename */ ) String filename; String localfilename; char *p1; - + for(i=optind;;(i==argc-1)?i=optind, sprintf(tmp,"Sleeping %d secs",sleeptime),log(tmp),sleep(sleeptime): i++) { if (noargs(argc,argv,optind)) quit("Nothing doing"); - - if (strchr(argv[i],':')==NULL) + + if (strchr(argv[i],':')==NULL) { if (find_archie(argv[i],machine,filename,localfilename)==0) argv[i]=NULL; @@ -226,19 +226,19 @@ transfer(char *machine, char *file, char *localfile) { int r; String tmp; - + if ((r=setjmp(stack))!=0) return r; - + sprintf(tmp,"Start transfer, machine is %s, remote file is %s, local file is %s", machine, file, localfile); DEBUG(tmp); - + FtpLogin(&ftp,machine,user,password,NULL); if (type==binary) FtpBinary(ftp); - + switch (mode) { @@ -260,11 +260,11 @@ transfer(char *machine, char *file, char *localfile) case multiget: domultiget(file); break; - + } - + FtpBye(ftp); - + DEBUG("Transfer complete"); return OK_; } @@ -288,11 +288,11 @@ quit(char *s) log(s); longjmp(trap,1); } - + my_IO(FTP *ftp, int n, char *s ) { - + DEBUG(s); leave(BREAK_); } @@ -312,7 +312,7 @@ domultiget(char *file) { String list,localname,tmp_name; char *p1; - + sprintf(list,"/tmp/ftptry-%s-multiget.XXXXXX",USERNAME); mktemp(list); @@ -405,7 +405,7 @@ void done(sig) options(int argc,char **argv) { char c; - + while((c=getopt(argc,argv,"GOIBDru:p:Pdbs:o:l:t:cm"))!=EOF) { switch(c) @@ -414,16 +414,16 @@ options(int argc,char **argv) case 'G': mode=multiget; break; - + case 'c': if (localfile==NULL) localfile="*STDOUT*"; break; - + case 'I': fprintf(stderr,intro); exit(0); - + case 'r': mode=put; @@ -444,12 +444,12 @@ options(int argc,char **argv) localfile=optarg; break; - + case 'D': debug=true; break; - + case 'u': user=optarg; @@ -464,7 +464,7 @@ options(int argc,char **argv) password=(char *)getpass("Password:"); break; - + case 'b': type=binary; @@ -480,14 +480,14 @@ options(int argc,char **argv) logmode=lm_file; logfile=optarg; break; - + case 'm': logmode=lm_mail; break; - + case 'B': - + logmode=lm_file; logfile=NULL; break; @@ -495,8 +495,8 @@ options(int argc,char **argv) default: usage(); - - } + + } } } @@ -510,14 +510,14 @@ setoptions() - + if ((p=(char *)getenv(FTPTRY))!=NULL && *p!=0) strcpy(x,p); else return; - - + + for (argv[0]="",p=x,sp=x,argc=1; *p!=0 ; p++) { if (*p==' ') @@ -529,7 +529,7 @@ setoptions() } argv[argc++]=sp; - + options(argc,argv); } @@ -562,7 +562,7 @@ find_archie(char *what,char *machine, char *filename, char *localfilename) static String oldwhat={'\0'}; char *p1; int i; - + if (!init || strcmp(oldwhat,what)!=0 || last==0) { String cmd; @@ -571,10 +571,10 @@ find_archie(char *what,char *machine, char *filename, char *localfilename) for (i=0;i<MAXHOPS;i++) result[i][0]=0; sprintf(cmd,"archie -l -m %d %s",MAXHOPS,what); DEBUG(cmd); - + if ((archie = popen(cmd,"r"))==NULL) quit("Archie can't execute"); - + for(i=0;i<MAXHOPS;i++) { if (fgets(result[i],sizeof (result[i]), archie)==NULL) @@ -582,17 +582,17 @@ find_archie(char *what,char *machine, char *filename, char *localfilename) result[i][strlen(result[i])-1]=0; DEBUG(result[i]); } - - + + last=i; - if ( last==0 ) + if ( last==0 ) { DEBUG("archie not found need file"); return(0); } - - + + init=1; first=0; strcpy(oldwhat,what); @@ -606,23 +606,23 @@ find_archie(char *what,char *machine, char *filename, char *localfilename) first=i+1; break; } - + DEBUG("Archie select is ... (see next line)"); DEBUG(result[i]); - + if (sscanf ( result[i] , "%*[^ ] %*[^ ] %[^ ] %s", machine, filename )!=2) { DEBUG("Bad archie output format"); last=0; return(0); } - - + + if ( (p1=strrchr(filename,'/'))!= NULL) strcpy(localfilename,p1+1); else strcpy(localfilename,filename); - + return(1); } diff --git a/lib/libftp/utils/glob.c b/lib/libftp/utils/glob.c index d80b146..efaeaa6 100644 --- a/lib/libftp/utils/glob.c +++ b/lib/libftp/utils/glob.c @@ -58,7 +58,7 @@ static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; * GLOB_TILDE: * expand ~user/foo to the /home/dir/of/user/foo * GLOB_BRACE: - * expand {1,2}{a,b} to 1a 1b 2a 2b + * expand {1,2}{a,b} to 1a 1b 2a 2b * gl_matchc: * Number of matches in the current invocation of glob. */ @@ -173,7 +173,7 @@ glob(pattern, flags, errfunc, pglob) bufend = bufnext + MAXPATHLEN; if (flags & GLOB_QUOTE) { /* Protect the quoted characters. */ - while (bufnext < bufend && (c = *patnext++) != EOS) + while (bufnext < bufend && (c = *patnext++) != EOS) if (c == QUOTE) { if ((c = *patnext++) == EOS) { c = QUOTE; @@ -184,8 +184,8 @@ glob(pattern, flags, errfunc, pglob) else *bufnext++ = c; } - else - while (bufnext < bufend && (c = *patnext++) != EOS) + else + while (bufnext < bufend && (c = *patnext++) != EOS) *bufnext++ = c; *bufnext = EOS; @@ -246,7 +246,7 @@ static int globexp2(ptr, pattern, pglob, rv) for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++) continue; if (*pe == EOS) { - /* + /* * We could not find a matching RBRACKET. * Ignore and just look for RBRACE */ @@ -274,7 +274,7 @@ static int globexp2(ptr, pattern, pglob, rv) for (pl = pm++; *pm != RBRACKET && *pm != EOS; pm++) continue; if (*pm == EOS) { - /* + /* * We could not find a matching RBRACKET. * Ignore and just look for RBRACE */ @@ -299,7 +299,7 @@ static int globexp2(ptr, pattern, pglob, rv) /* Append the current string */ for (lm = ls; (pl < pm); *lm++ = *pl++) continue; - /* + /* * Append the rest of the pattern after the * closing brace */ @@ -344,15 +344,15 @@ globtilde(pattern, patbuf, pglob) return pattern; /* Copy up to the end of the string or / */ - for (p = pattern + 1, h = (char *) patbuf; *p && *p != SLASH; + for (p = pattern + 1, h = (char *) patbuf; *p && *p != SLASH; *h++ = *p++) continue; *h = EOS; if (((char *) patbuf)[0] == EOS) { - /* - * handle a plain ~ or ~/ by expanding $HOME + /* + * handle a plain ~ or ~/ by expanding $HOME * first and then trying the password file */ if ((h = getenv("HOME")) == NULL) { @@ -375,14 +375,14 @@ globtilde(pattern, patbuf, pglob) /* Copy the home directory */ for (b = patbuf; *h; *b++ = *h++) continue; - + /* Append the rest of the pattern */ while ((*b++ = *p++) != EOS) continue; return patbuf; } - + /* * The main glob() routine: compiles the pattern (optionally processing @@ -440,7 +440,7 @@ glob0(pattern, pglob) break; case STAR: pglob->gl_flags |= GLOB_MAGCHAR; - /* collapse adjacent stars to one, + /* collapse adjacent stars to one, * to avoid exponential behavior */ if (bufnext == patbuf || bufnext[-1] != M_ALL) @@ -460,17 +460,17 @@ glob0(pattern, pglob) return(err); /* - * If there was no match we are going to append the pattern + * If there was no match we are going to append the pattern * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified * and the pattern did not contain any magic characters * GLOB_NOMAGIC is there just for compatibility with csh. */ - if (pglob->gl_pathc == oldpathc && - ((pglob->gl_flags & GLOB_NOCHECK) || + if (pglob->gl_pathc == oldpathc && + ((pglob->gl_flags & GLOB_NOCHECK) || ((pglob->gl_flags & GLOB_NOMAGIC) && !(pglob->gl_flags & GLOB_MAGCHAR)))) return(globextend(pattern, pglob)); - else if (!(pglob->gl_flags & GLOB_NOSORT)) + else if (!(pglob->gl_flags & GLOB_NOSORT)) qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc, pglob->gl_pathc - oldpathc, sizeof(char *), compare); return(0); @@ -519,7 +519,7 @@ glob2(pathbuf, pathend, pattern, pglob) *pathend = EOS; if (g_lstat(pathbuf, &sb, pglob)) return(0); - + if (((pglob->gl_flags & GLOB_MARK) && pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) #ifdef S_ISLNK @@ -576,7 +576,7 @@ glob3(pathbuf, pathend, pattern, restpattern, pglob) *pathend = EOS; errno = 0; - + if ((dirp = g_opendir(pathbuf, pglob)) == NULL) { /* TODO: don't call for ENOENT or ENOTDIR? */ if (pglob->gl_errfunc) { @@ -602,7 +602,7 @@ glob3(pathbuf, pathend, pattern, restpattern, pglob) /* Initial DOT must be matched literally. */ if (dp->d_name[0] == DOT && *pattern != DOT) continue; - for (sc = (u_char *) dp->d_name, dc = pathend; + for (sc = (u_char *) dp->d_name, dc = pathend; (*dc++ = *sc++) != EOS;) continue; if (!match(pathend, pattern, restpattern)) { @@ -648,7 +648,7 @@ globextend(path, pglob) const Char *p; newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs); - pathv = pglob->gl_pathv ? + pathv = pglob->gl_pathv ? realloc((char *)pglob->gl_pathv, newsize) : malloc(newsize); if (pathv == NULL) @@ -690,7 +690,7 @@ match(name, pat, patend) case M_ALL: if (pat == patend) return(1); - do + do if (match(name, pat, patend)) return(1); while (*name++ != EOS); @@ -829,7 +829,7 @@ g_Ctoc(str, buf) } #ifdef DEBUG -static void +static void qprintf(str, s) const char *str; register Char *s; diff --git a/lib/libftp/utils/glob.h b/lib/libftp/utils/glob.h index bffb28c..b0432b7 100644 --- a/lib/libftp/utils/glob.h +++ b/lib/libftp/utils/glob.h @@ -58,7 +58,7 @@ typedef struct { * and lstat(2). */ void (*gl_closedir) __P((void *)); - struct dirent *(*gl_readdir) __P((void *)); + struct dirent *(*gl_readdir) __P((void *)); void *(*gl_opendir) __P((const char *)); int (*gl_lstat) __P((const char *, struct stat *)); int (*gl_stat) __P((const char *, struct stat *)); diff --git a/lib/libftp/utils/mirror.c b/lib/libftp/utils/mirror.c index babd840..a0d329c 100644 --- a/lib/libftp/utils/mirror.c +++ b/lib/libftp/utils/mirror.c @@ -9,7 +9,7 @@ #include <syslog.h> #include <FtpLibrary.h> -/* Usage: mirror <local_dir> <host> <user> <passwd> <remote_dir> */ +/* Usage: mirror <local_dir> <host> <user> <passwd> <remote_dir> */ FTP *ftp; main(int a,char **b) @@ -24,7 +24,7 @@ main(int a,char **b) if ( a < 5 ) quit("Usage: mirror <local_dir> <host> <user> <passwd> <remote_dir>"); - + FtplibDebug(yes); FtpLogin(&ftp,HOST,USER,PASSWD,NULL); FtpChdir(ftp,REMOTE_DIR); @@ -53,7 +53,7 @@ doit(char *dirname) continue; sprintf(fn,"%s/%s",dirname,de->d_name); - + if ( stat(fn,&st) != 0 ) { log(fn); continue; @@ -72,7 +72,7 @@ doit(char *dirname) } closedir(dp); - + } diff --git a/lib/libftp/utils/readline.c b/lib/libftp/utils/readline.c index 34612ba..e019bc1 100644 --- a/lib/libftp/utils/readline.c +++ b/lib/libftp/utils/readline.c @@ -1,5 +1,5 @@ #ifndef lint -static char *RCSid = "$Id: readline.c%v 3.50.1.9 1993/08/05 05:38:59 woo Exp $"; +static char *RCSid = "$Id: readline.c,v 1.1.1.1 1995/04/25 15:05:09 jkh Exp $"; #endif @@ -8,17 +8,17 @@ static char *RCSid = "$Id: readline.c%v 3.50.1.9 1993/08/05 05:38:59 woo Exp $"; * Copyright (C) 1986 - 1993 Thomas Williams, Colin Kelley * * Permission to use, copy, and distribute this software and its - * documentation for any purpose with or without fee is hereby granted, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear + * documentation for any purpose with or without fee is hereby granted, + * provided that the above copyright notice appear in all copies and + * that both that copyright notice and this permission notice appear * in supporting documentation. * * Permission to modify the software is granted, but not the right to - * distribute the modified code. Modifications are to be distributed + * distribute the modified code. Modifications are to be distributed * as patches to released version. - * + * * This software is provided "as is" without express or implied warranty. - * + * * * AUTHORS * @@ -27,10 +27,10 @@ static char *RCSid = "$Id: readline.c%v 3.50.1.9 1993/08/05 05:38:59 woo Exp $"; * * Msdos port and some enhancements: * Gershon Elber and many others. - * + * * There is a mailing list for gnuplot users. Note, however, that the - * newsgroup - * comp.graphics.gnuplot + * newsgroup + * comp.graphics.gnuplot * is identical to the mailing list (they * both carry the same set of messages). We prefer that you read the * messages through that newsgroup, to subscribing to the mailing list. @@ -40,9 +40,9 @@ static char *RCSid = "$Id: readline.c%v 3.50.1.9 1993/08/05 05:38:59 woo Exp $"; * * The address for mailing to list members is * info-gnuplot@dartmouth.edu - * and for mailing administrative requests is + * and for mailing administrative requests is * info-gnuplot-request@dartmouth.edu - * The mailing list for bug reports is + * The mailing list for bug reports is * bug-gnuplot@dartmouth.edu * The list of those interested in beta-test versions is * info-gnuplot-beta@dartmouth.edu @@ -57,7 +57,7 @@ static char *RCSid = "$Id: readline.c%v 3.50.1.9 1993/08/05 05:38:59 woo Exp $"; #endif /* a small portable version of GNU's readline */ -/* this is not the BASH or GNU EMACS version of READLINE due to Copyleft +/* this is not the BASH or GNU EMACS version of READLINE due to Copyleft restrictions */ /* do not need any terminal capabilities except backspace, */ /* and space overwrites a character */ @@ -123,7 +123,7 @@ static struct ltchars s_ltchars; #ifdef ISC22 #ifndef ONOCR /* taken from sys/termio.h */ #define ONOCR 0000020 /* true at least for ISC 2.2 */ -#endif +#endif #ifndef IUCLC #define IUCLC 0001000 #endif @@ -226,7 +226,7 @@ void reset_termio(); /* user_putc and user_puts should be used in the place of * fputc(ch,stderr) and fputs(str,stderr) for all output - * of user typed characters. This allows MS-Windows to + * of user typed characters. This allows MS-Windows to * display user input in a different color. */ int user_putc(ch) @@ -265,7 +265,7 @@ backspace() { user_putc(BACKSPACE); } - + char * readline(prompt) char *prompt; @@ -322,7 +322,7 @@ char *prompt; } } #endif /*OS2*/ - if((isprint(cur_char) + if((isprint(cur_char) #if defined(ATARI) || defined(_Windows) || defined(MSDOS) || defined(DOS386) /* this should be used for all 8bit ASCII machines, I guess */ || ((unsigned char)cur_char > 0x7f) @@ -455,7 +455,7 @@ char *prompt; if(cur_entry != NULL) { cur_entry = cur_entry->next; clear_line(prompt); - if(cur_entry != NULL) + if(cur_entry != NULL) copy_line(cur_entry->line); else cur_pos = max_pos = 0; @@ -714,12 +714,12 @@ msdos_getch() /* Convert Arrow keystrokes to Control characters: TOS version */ -/* the volatile could be necessary to keep gcc from reordering +/* the volatile could be necessary to keep gcc from reordering the two Super calls */ #define CONTERM ((/*volatile*/ char *)0x484L) -static void +static void remove_conterm() { void *ssp=(void*)Super(0L); @@ -929,7 +929,7 @@ set_termio() } #endif /* !MSDOS && !ATARI && !defined(_Windows) */ } - + void reset_termio() { diff --git a/lib/libftp/utils/uftp.c b/lib/libftp/utils/uftp.c index fe64ffd..4c8961f 100644 --- a/lib/libftp/utils/uftp.c +++ b/lib/libftp/utils/uftp.c @@ -37,25 +37,25 @@ main(int argc, char **argv) register char *p1; FILE *fp; String tmp; - - if (setjmp(start)!=0) + + if (setjmp(start)!=0) goto main_loop; - + setsignals(); - - + + FtpSetErrorHandler(&FtpInit,my_error); FtpSetIOHandler(&FtpInit,my_error); - + strcpy(defaultuser,getpwuid(getuid())->pw_name); - + memset(ftp,0,sizeof(FTP*)*NFRAMES); memset(iftp,0,sizeof(LINKINFO)*NFRAMES); - - + + batch(SYSTEMRC); if (access(getrcname(),F_OK)) @@ -69,16 +69,16 @@ main(int argc, char **argv) else { - + fprintf(out,"set timeout 120\nset hash\nset debug\nset bin\n"); fprintf(out,"set prompt \"%%T %%u@%%h:%%d\\> \"\n"); fprintf(out,"alias a alias\na ed ! emacs\nalias tn ! telnet\n"); - + fclose(out); } } - + batch(getrcname()); batch(getaliasrcname()); @@ -88,7 +88,7 @@ main(int argc, char **argv) strcat(tmp,argv[i]); if (i+1!=argc) strcat(tmp," "); } - + if (tmp[0]!=0) { String new; @@ -99,8 +99,8 @@ main(int argc, char **argv) else */ strcpy(new,"open "); - - if (ifalias(tmp)) + + if (ifalias(tmp)) execute (tmp); else strcat(new,tmp), @@ -111,25 +111,25 @@ main(int argc, char **argv) main_loop: setsignals(); - + while (1) { - + setjmp(start); if (lastcmd) exit(0); - + if (isatty(fileno(stdin))) p1=readline(getprompt()); else p1=gets(cmd); - - if (p1==NULL) + + if (p1==NULL) { putchar('\n'); exit(0); } - + strcpy(cmd,p1); if (cmd[0]) add_history(cmd); @@ -144,15 +144,15 @@ INLINE char *findspace(char *str) } - + char *word(char *str, int n) { String new; register char *p1, *p2; register int i; - + strcpy(new,str); - + p1=new; while (isspace(*p1)) p1++; @@ -160,7 +160,7 @@ char *word(char *str, int n) if (n>1 ) for (i=0;i<n-1;i++) /* Skip n-1 words */ { - if ((*p1=='"')||(*p1=='\'')) + if ((*p1=='"')||(*p1=='\'')) { p1=strchr(p1+1,*p1); if (p1==NULL) return ""; @@ -181,7 +181,7 @@ char *word(char *str, int n) *p2=0; return p1+1; } - + if ((p2=findspace(p1)) != NULL ) { *p2=0; @@ -191,8 +191,8 @@ char *word(char *str, int n) } -/* Exacute few command separated by ';' . The character ' must use for mark complex - works*/ +/* Exacute few command separated by ';' . The character ' must use for mark complex + works*/ execute (char *cmd) { @@ -208,13 +208,13 @@ execute (char *cmd) { *p++=*cmd++; while ( *cmd != '\'' && *cmd != 0 ) *p++=*cmd++; - if ( *cmd == 0 ) + if ( *cmd == 0 ) return puts("Unbalanced \', please corrected!\n"); *p++=*cmd; continue; } - - if ( *cmd == ';' ) + + if ( *cmd == ';' ) { *p=0; execute(newcmd); @@ -224,11 +224,11 @@ execute (char *cmd) *p++=*cmd; } - + *p=0; cmd=newcmd; - - if ( *cmd=='\\' ) + + if ( *cmd=='\\' ) cmd++; else { @@ -238,17 +238,17 @@ execute (char *cmd) return execute(new); } - if ( *cmd == '!' ) + if ( *cmd == '!' ) { int pid,_pid; int status; - + if (!(pid=fork())) { execlp((getenv("SHELL")==NULL)?"/bin/sh":(char *)getenv("SHELL"), "shell","-c",cmd+1,NULL); } - + while(1) { _pid=wait(&status); @@ -256,8 +256,8 @@ execute (char *cmd) return; } } - - + + redir(cmd); if (cmd[strlen(cmd)-1]=='&') @@ -271,14 +271,14 @@ execute (char *cmd) strcpy(cmd,tmp); } - + strcpy(w1,word(cmd,1)); strcpy(w2,word(cmd,2)); strcpy(w3,word(cmd,3)); strcpy(w4,word(cmd,4)); strcpy(w5,word(cmd,5)); strcpy(w6,word(cmd,6)); - + return executev(w1,w2,w3,w4,w5,w6); } @@ -286,18 +286,18 @@ executev(ARGS) { CMDS *xcmd=&cmds[0]; String tmp; - + if (isdigit(*w1)) - return + return atoi(w1)<NFRAMES?frame=atoi(w1):0, executev(w2,w3,w4,w5,w6,""); - + while ( xcmd -> cmd != NULL ) { if ( !strcmp(xcmd->cmd,w1) && (xcmd -> func != NULL) ) { int status; - + if ( xcmd -> need && LINK == NULL) return puts("Need connection to server"); iftp[frame].lock=1; unsetsignals(); @@ -308,11 +308,11 @@ executev(ARGS) } xcmd++; } - - + + if (LINK!=NULL && glassmode) return FtpCommand(LINK,cmd,"",0,EOF); - + printf("%s: unknown command\n",w1); fflush(stdout); return -1; @@ -332,7 +332,7 @@ void intr(int sig) newframe(int connecteble) { register int i; - + if (connecteble) for (i=0; i<NFRAMES; i++) if (ftp[i]!=NULL) return frame=i; for (i=0; i<NFRAMES; i++) if (ftp[i]==NULL) return frame=i; @@ -345,7 +345,7 @@ STATUS my_error(FTP *ftp, int code, char *msg) if (code==LQUIT||(ftp==NULL)) log(msg); else FtpLog(ftp->title,msg); - + if ( abs(code) == 530 && (strstr(msg,"anonymous")!=NULL)) { Ftp_reopen(); @@ -358,7 +358,7 @@ char *getrcname() { static String rcpath; struct passwd *pwd=getpwuid(getuid()); - + sprintf(rcpath,"%s/.uftprc",pwd->pw_dir); return rcpath; } @@ -367,7 +367,7 @@ char *getaliasrcname() { static String rcpath; struct passwd *pwd=getpwuid(getuid()); - + sprintf(rcpath,"%s/.uftp_aliases",pwd->pw_dir); return rcpath; } @@ -378,14 +378,14 @@ char *makestr(va_alist) char *p1; va_list args; String new={0}; - + va_start(args); while(1) { p1=va_arg(args,char *); if (p1==NULL) break; - if (*p1!=0) + if (*p1!=0) { if (new[0]!=0) strcat(new," "); strcat(new,p1); @@ -395,7 +395,7 @@ char *makestr(va_alist) return new; } - + #define ADD(str,chr) (*str++=chr,*str=0) INLINE ADDSTR(char **str, char *str1) @@ -409,59 +409,59 @@ char *expandalias(char *str) String new={0},w1={0}; char *p,*p1=new,*args; int dollar=0; - + strcpy(w1,word(str,1)); if ( (p=strchr(str,' '))!=NULL ) args=p+1; else args=""; - - while (a) + + while (a) { if (!strcmp(a->name,w1)) break; a=a->next; } - - if (!a) + + if (!a) return str; - + for ( p=a->str; *p; p++) { - if ( *p != '$' ) + if ( *p != '$' ) { ADD(p1,*p); continue; } - + dollar=1; p++; - - if (isdigit(*p)) + + if (isdigit(*p)) { ADDSTR(&p1,word(str,(*p)-'0'+1)); continue; } - switch (*p) - { - + switch (*p) + { + case '\0': case '$': ADD(p1,'$');continue; case '*': ADDSTR(&p1,args);continue; default: ADD(p1,'$');ADD(p1,*p);continue; } } - - if (!dollar) + + if (!dollar) { ADD(p1,' '); ADDSTR(&p1,args); } *p=0; - + return new; } @@ -481,12 +481,12 @@ ifalias(char *cmd) } return 0; } - + char *getprompt() { - + static String _prompt; String tmp; char *s; @@ -499,22 +499,22 @@ char *getprompt() case '%': switch (*++s) { - - case 'H': + + case 'H': strcat(_prompt,iftp[frame].host); break; - + case 'h': strcpy(tmp,iftp[frame].host); if (strchr(tmp,'.')!=NULL) *(char *)strchr(tmp,'.')=0; strcat(_prompt,tmp); break; - case 'M': + case 'M': gethostname(tmp, sizeof tmp); strcat(_prompt,gethostbyname(tmp)->h_name); break; - + case 'm': gethostname(tmp, sizeof tmp); strcpy(tmp,gethostbyname(tmp)->h_name); @@ -525,7 +525,7 @@ char *getprompt() case 'u': strcat(_prompt,iftp[frame].user); break; - + case 'd': strcat(_prompt,iftp[frame].pwd); break; @@ -543,16 +543,16 @@ char *getprompt() sprintf(tmp,"%d",(LINK==NULL)?0:LINK->port); strcat(_prompt,tmp); break; - + case 't': - + sprintf(tmp,"%d",(LINK==NULL)?0:LINK->timeout.tv_sec); strcat(_prompt,tmp); break; - + case 'T': - + { time_t t=time((time_t *)0); struct tm *lt=localtime(&t); @@ -567,7 +567,7 @@ char *getprompt() sprintf(tmp,"%d",getpid()); strcat(_prompt,tmp); break; - + default: sprintf(tmp,"%%%c",*s); strcat(_prompt,tmp); @@ -576,7 +576,7 @@ char *getprompt() break; case '^': - + ++s; if (isalpha(*s)) { @@ -584,17 +584,17 @@ char *getprompt() strcat(_prompt,tmp); } break; - + default: - + sprintf(tmp,"%c",*s); strcat(_prompt,tmp); break; } return _prompt; } - - + + void noop() { int i; @@ -603,26 +603,26 @@ void noop() if (noopinterval==0) return; - + curtime = time((time_t *)0); - + signal(SIGALRM,noop); - - if (prevtime==0) + + if (prevtime==0) { prevtime=curtime; alarm(noopinterval); return; } - - if (curtime-prevtime < noopinterval) + + if (curtime-prevtime < noopinterval) { alarm(prevtime+noopinterval-curtime); return; } - + printf("Waiting...");fflush(stdout); - + for (i=0;i<NFRAMES;i++) { if ( ftp[i]==NULL || FTPCMD(ftp[i]) == NULL || iftp[i].lock ) @@ -633,7 +633,7 @@ void noop() func3=ftp[i]->IO; ftp[i]->IO=NULL; save = ftp[i]->timeout.tv_sec; ftp[i]->timeout.tv_sec = nooptimeout; - + FtpCommand(ftp[i],"NOOP","",0,EOF); ftp[i]->timeout.tv_sec = save; @@ -642,10 +642,10 @@ void noop() ftp[i]->IO=func1; } - + alarm(noopinterval); prevtime=curtime; - + for (i=0;i<10;i++) putchar(8),putchar(' '),putchar(8); fflush(stdout); } @@ -667,7 +667,7 @@ unsetsignals() int myhash(FTP *ftp,unsigned int chars) { - + if (hashmode) { if (chars==0) return ftp -> counter=0; @@ -676,7 +676,7 @@ int myhash(FTP *ftp,unsigned int chars) fflush(stdout); } - if (!lastcmd) + if (!lastcmd) { noop(); alarm(0); @@ -688,7 +688,7 @@ int myhash(FTP *ftp,unsigned int chars) char *makefilename(char *f1, char *f2) { char *p; - + if (*f2!=0) return f2; @@ -702,21 +702,21 @@ redir(char *cmdline) char *p=cmdline; String result; char *r=result; - + for ( ; *p ; p++ , r++ ) { - if ( *p == '\\' ) + if ( *p == '\\' ) { *r = * ++ p ; continue; } - + if ( *p == '>' || *p == '<' ) { String filename; char *q=filename; char c=*p; - + for (p++;isspace(*p)&&*p!=0;p++); if (*p=='"') { @@ -725,10 +725,10 @@ redir(char *cmdline) } else for (; !isspace(*p) && *p!=0 ; p++,q++) *q=*p; - + *q=0; - - if ( c == '>' ) + + if ( c == '>' ) output(filename); else input(filename); @@ -745,7 +745,7 @@ FILE *is=NULL,*os=NULL; input(char *filename) { - + if ((is=Ftpfopen(filename,"r"))==NULL) { perror(filename); @@ -761,13 +761,13 @@ input(char *filename) output(char *filename) { - + if ((os=Ftpfopen(filename,"w"))==NULL) { perror(filename); return; } - + fflush(stdout); otty=dup(1); close(1); @@ -803,10 +803,10 @@ batch(char *filename) { FILE *fp; String tmp; - + if ((fp=fopen(filename,"r"))!=NULL) { - + while ( fgets(tmp, sizeof tmp, fp) != NULL) { tmp[strlen(tmp)-1]=0; @@ -816,7 +816,7 @@ batch(char *filename) fclose(fp); } } - + diff --git a/lib/libftp/utils/uftpcmd.c b/lib/libftp/utils/uftpcmd.c index 959de40..2eb3cb2 100644 --- a/lib/libftp/utils/uftpcmd.c +++ b/lib/libftp/utils/uftpcmd.c @@ -10,61 +10,61 @@ Ftp_connect_hook(FTP *ftp,int code, char *msg) { FtpLog(ftp->title,msg); longjmp(connectstack,1); - + } - -Ftp_connect(ARGS) + +Ftp_connect(ARGS) { STATUS (*func1)(),(*func2)(); if (*w2==0) w2=readline("Host:"); - if (FtpGetHost(w2)==NULL && FtpInit.IO != NULL) + if (FtpGetHost(w2)==NULL && FtpInit.IO != NULL) { char *msg; extern int h_errno; - + switch(h_errno) { case HOST_NOT_FOUND: msg = "Host unknown"; break; case TRY_AGAIN: msg = "Hostname lookup failure";break; - default: msg = "gethostbyname failure"; + default: msg = "gethostbyname failure"; } return (*FtpInit.IO)(LINK,QUIT,msg); } - + newframe(0); - + func1 = FtpInit.error; func2 = FtpInit.IO; - - if (trymode) + + if (trymode) { FtpSetErrorHandler(&FtpInit,Ftp_connect_hook); FtpSetIOHandler(&FtpInit,Ftp_connect_hook); setjmp(connectstack); } - + FtpConnect(&LINK,w2); strcpy(iftp[frame].host,FtpGetHost(w2)->h_name); - + FtpSetErrorHandler(LINK,func1); FtpSetErrorHandler(&FtpInit,func1); FtpSetIOHandler(LINK,func2); FtpSetIOHandler(&FtpInit,func2); - + return; } Ftp_user(ARGS) { - + if (*w2==0) { sprintf(tmp,"login (default %s):",defaultuser); w2=readline(tmp); - if (*w2==0) + if (*w2==0) w2=defaultuser; } strcpy(iftp[frame].user,w2); @@ -74,11 +74,11 @@ Ftp_user(ARGS) Ftp_pass(ARGS) { - if (*w2==0) + if (*w2==0) { String pass; String host; - + gethostname(host, sizeof host); strcpy(host,FtpGetHost(host)->h_name); sprintf(pass,"%s@%s",getpwuid(getuid())->pw_name,host); @@ -86,7 +86,7 @@ Ftp_pass(ARGS) w2=getpass(tmp); if (*w2==0) w2=pass; } - + strcpy(iftp[frame].pass,w2); FtpPassword(LINK,w2); strcpy(iftp[frame].pwd,FtpPwd(LINK)); @@ -96,11 +96,11 @@ Ftp_open(ARGS) { register char *p1; STATUS (*err)(); - + Ftp_connect("",w2,"","","",""); Ftp_user("",w3,w4,"","","" ); if (ifalias("autologin")) execute("autologin"); - if (*w5) + if (*w5) Ftp_cd("cd",w5,"","","",""); } @@ -121,11 +121,11 @@ Ftp_ftp(ARGS) { String pass; String host; - + gethostname(host, sizeof host); strcpy(host,FtpGetHost(host)->h_name); sprintf(pass,"%s@%s",getpwuid(getuid())->pw_name,host); - + Ftp_open("",w2,"anonymous",pass,w3,""); return; } @@ -147,14 +147,14 @@ Ftp_lcd(ARGS) glob_t gl; bzero(&gl,sizeof gl); - + glob(w2,GLOB_BRACE|GLOB_TILDE|GLOB_QUOTE, Ftp_mput_handler, &gl); - - + + if (gl.gl_matchc<1 || chdir(*gl.gl_pathv)) perror(w2); - + printf("Local directory is \"%s\"\n",getwd(tmp)); } @@ -163,35 +163,35 @@ Ftp_dir(ARGS) char *cmd1; String cmd; char mode=LINK->mode; - - if ( !strcmp(w1,"dir") ) + + if ( !strcmp(w1,"dir") ) cmd1="LIST"; else cmd1="NLST"; - + strcpy(cmd,makestr(cmd1,w2,w3,w4,w5,w6,NULL)); if ( LINK->mode != 'A' ) FtpAscii(LINK); FtpRetr(LINK,cmd,"","-"); if ( LINK->mode != mode ) FtpType(LINK,mode); - + } Ftp_close(ARGS) { register int i; - - if (isdigit(*w2)) + + if (isdigit(*w2)) { i=atoi(w2); } - else + else { i=frame; } - + FtpQuickBye(ftp[i]); - + iftp[i].host[0]=0; iftp[i].pwd[0]=0; ftp[i]=NULL; @@ -203,19 +203,19 @@ INLINE SetLogicalVar(char arg, int * var, char *msg) { switch(arg) { - + case 'y': - + *var=1; break; - + case 'n': - + *var=0; break; - + default: - + (*var)?(*var=0):(*var=1); break; } @@ -227,7 +227,7 @@ Ftp_set(ARGS) { if (!strcmp("frame",w2)) return atoi(w3)<NFRAMES?frame=atoi(w3):0; - + if (!strcmp("timeout",w2)) { FtpSetTimeout(&FtpInit,atoi(w3)); @@ -235,17 +235,17 @@ Ftp_set(ARGS) FtpSetTimeout(LINK,atoi(w3)); return; } - + if (!strcmp("sleep",w2)) { sleeptime=atoi(w3); return; } - + if (!strcmp("debug",w2)) { - if ( *w3=='y' || *w3==0) - { + if ( *w3=='y' || *w3==0) + { if (LINK!=NULL) FtpSetDebugHandler(LINK,FtpDebugDebug); FtpSetDebugHandler(&FtpInit,FtpDebugDebug); return puts("Debuging on for current and next session"); @@ -257,11 +257,11 @@ Ftp_set(ARGS) return puts("Debuging off for current and next session"); } } - + if (!strcmp("bin",w2)) { - if ( *w3=='y' || *w3==0) - { + if ( *w3=='y' || *w3==0) + { FtpInit.mode='I'; return puts("Binary mode enable"); } @@ -271,7 +271,7 @@ Ftp_set(ARGS) return puts("Binary mode disable"); } } - + if (!strcmp("try",w2)) return SetLogicalVar(*w3,&trymode,"Try mode"); if (!strcmp("hash",w2)) @@ -280,16 +280,16 @@ Ftp_set(ARGS) return SetLogicalVar(*w3,&glassmode,"Glass mode"); if (!strcmp("rest",w2)||!strcmp(w2,"restore")) return SetLogicalVar(*w3,&restmode,"Restore mode"); - + if (!strcmp("prompt",w2)) { strcpy(prompt,w3); return; } - + if (!strcmp("port",w2)) { - if ( isdigit(*w3)) + if ( isdigit(*w3)) return FtpSetPort(&FtpInit,atoi(w3)); puts("Port must be number"); fflush(stdout); @@ -298,7 +298,7 @@ Ftp_set(ARGS) if (!strcmp("noopinterval",w2)||!strcmp("noop",w2)) { - if ( isdigit(*w3)) + if ( isdigit(*w3)) return noopinterval=(time_t)atoi(w3); puts("Time must be number"); fflush(stdout); @@ -307,21 +307,21 @@ Ftp_set(ARGS) if (!strcmp("nooptimeout",w2)) { - if ( isdigit(*w3)) + if ( isdigit(*w3)) return nooptimeout=(time_t)atoi(w3); puts("Time must be number"); fflush(stdout); return; } - + if (!strcmp("user",w2)||!strcmp("login",w2)) { strcpy(defaultuser,w3); return; } - + if (!strcmp("",w2)) { @@ -342,8 +342,8 @@ Ftp_set(ARGS) fflush(stdout); return; } - return puts("arg 2 unknown"); - + return puts("arg 2 unknown"); + } jmp_buf getstack; @@ -351,13 +351,13 @@ jmp_buf getstack; Ftp_get_hook(FTP *con,int code, char *msg) { - if ( abs(code)==550 && FtpBadReply550(msg) ) + if ( abs(code)==550 && FtpBadReply550(msg) ) { FtpLog(con->title,msg); log("Transfer cancel"); longjmp(getstack,2); } - + if ( code == LQUIT ) { log(msg); @@ -366,7 +366,7 @@ Ftp_get_hook(FTP *con,int code, char *msg) } - + FtpLog(con->title,msg); FtpQuickBye(LINK); LINK=NULL; @@ -374,11 +374,11 @@ Ftp_get_hook(FTP *con,int code, char *msg) log("sleeping......"); sleep(sleeptime); log("try again..."); - + longjmp(getstack,1); - + } - + void Ftp_get_intr(int sig) { signal(SIGINT,intr); @@ -393,19 +393,19 @@ Ftp_get(ARGS) int back=0; int code; int status=0; - + OldInit=FtpInit; - + if (strstr(w1,"put")!=NULL) back=1; - - + + if (restmode || ((*w1=='r')&&(*(w1+1)=='e')) ) FtpSetFlag(LINK,FTP_REST); else - FtpClearFlag(LINK,FTP_REST); - - - + FtpClearFlag(LINK,FTP_REST); + + + if (trymode) { FtpSetErrorHandler(LINK,Ftp_get_hook); @@ -414,28 +414,28 @@ Ftp_get(ARGS) FTPCMD(&FtpInit)=FTPCMD(&OldInit); FTPDATA(&FtpInit)=FTPDATA(&OldInit); } - + signal(SIGINT,Ftp_get_intr); FtpSetHashHandler(LINK,NULL); - - - if ((status=setjmp(getstack))==2||status==3) + + + if ((status=setjmp(getstack))==2||status==3) goto done; - + if ((LINK==NULL)||(LINK->sock==FtpInit.sock)) { FtpLogin(&LINK,iftp[frame].host,iftp[frame].user, - iftp[frame].pass,NULL); + iftp[frame].pass,NULL); FtpChdir(LINK,iftp[frame].pwd); } - + if (hashmode && isatty(fileno(stdout))) FtpSetHashHandler(LINK,myhash); else FtpSetHashHandler(LINK,NULL); - + myhash(LINK,0); - + if (!back) FtpGet(LINK,w2,makefilename(w2,w3)); else @@ -443,15 +443,15 @@ Ftp_get(ARGS) log("Transfer compliete"); - - + + done: - - + + FtpSetHashHandler(LINK,NULL); FtpSetErrorHandler(LINK,my_error); FtpSetIOHandler(LINK,my_error); - FtpClearFlag(LINK,FTP_REST); + FtpClearFlag(LINK,FTP_REST); FtpInit=OldInit; } @@ -459,7 +459,7 @@ Ftp_mget(ARGS) { FILE *list; char mode=LINK->mode; - + sprintf(tmp,"/tmp/uftplist-%s.XXXXXX",getpwuid(getuid())->pw_name); mktemp(tmp); @@ -487,10 +487,10 @@ Ftp_mget(ARGS) Ftp_mput(ARGS) { glob_t gl; - + glob(w2,GLOB_BRACE|GLOB_TILDE|GLOB_QUOTE, Ftp_mput_handler, &gl); - + while(gl.gl_matchc--) { Ftp_get("put",*gl.gl_pathv,"","","",""); @@ -501,51 +501,51 @@ Ftp_mput(ARGS) Ftp_bget(ARGS) { - + String fn,lfn; char *p; newframe(0); - + if (!FtpFullSyntax(w2,iftp[frame].host,iftp[frame].user, iftp[frame].pass,fn)) return puts("Filename syntax error"); - + strcpy(iftp[frame].pwd,"/"); - - if ((p=strrchr(fn,'/'))!=NULL) + + if ((p=strrchr(fn,'/'))!=NULL) strcpy(lfn,p+1); else strcpy(lfn,fn); - + FtpQuickBye(LINK); LINK=FtpCreateObject(); LINK->sock=NULL; - + Ftp_get("get",fn,(*w3==0)?lfn:w3,"","",""); } Ftp_bput(ARGS) { - + String fn,lfn; char *p; if (!FtpFullSyntax((*w3==0)?w2:w3,iftp[frame].host,iftp[frame].user, iftp[frame].pass,fn)) return puts("Filename syntax error"); - + strcpy(iftp[frame].pwd,"/"); - - if ((p=strrchr(fn,'/'))!=NULL) + + if ((p=strrchr(fn,'/'))!=NULL) strcpy(lfn,p+1); else strcpy(lfn,fn); - + FtpQuickBye(LINK); LINK=FtpCreateObject(); LINK->sock=NULL; - + Ftp_get("put",(*w3==0)?lfn:w2,fn,"","",""); } @@ -553,10 +553,10 @@ Ftp_copy(ARGS) { char *p; int in,out; - + if ( !*w2 || !*w3 ) return puts("Must pass two args"); - - if ((p=strchr(w2,'!'))!=NULL) + + if ((p=strchr(w2,'!'))!=NULL) { *p=0; in=atoi(w2); @@ -565,7 +565,7 @@ Ftp_copy(ARGS) else in=frame; - if ((p=strchr(w3,'!'))!=NULL) + if ((p=strchr(w3,'!'))!=NULL) { *p=0; out=atoi(w3); @@ -573,9 +573,9 @@ Ftp_copy(ARGS) } else in=frame; - + if (in==out) return puts("Files must been from different frames"); - + FtpCopy(ftp[in],ftp[out],w2,w3); } @@ -583,10 +583,10 @@ Ftp_ccopy(ARGS) { char *p; int in,out; - + if ( !*w2 || !*w3 ) return puts("Must pass two args"); - - if ((p=strchr(w2,'!'))!=NULL) + + if ((p=strchr(w2,'!'))!=NULL) { *p=0; in=atoi(w2); @@ -595,7 +595,7 @@ Ftp_ccopy(ARGS) else in=frame; - if ((p=strchr(w3,'!'))!=NULL) + if ((p=strchr(w3,'!'))!=NULL) { *p=0; out=atoi(w3); @@ -603,9 +603,9 @@ Ftp_ccopy(ARGS) } else in=frame; - + if (in==out) return puts("Files must been from different frames"); - + FtpPassiveTransfer(ftp[in],ftp[out],w2,w3); } @@ -628,17 +628,17 @@ Ftp_cd(ARGS) Ftp_dup(ARGS) -{ +{ LINKINFO oldinfo; FTP oldftp; - + oldinfo=iftp[frame]; oldftp=*LINK; - + newframe(0); puts("Make alternative connection..."); Ftp_open("",oldinfo.host,oldinfo.user,oldinfo.pass,"",""); - if (strcmp(oldinfo.pwd,iftp[frame].pwd)) + if (strcmp(oldinfo.pwd,iftp[frame].pwd)) Ftp_cd("",oldinfo.pwd,"","","",""); if (LINK->mode!=oldftp.mode) FtpType(LINK,oldftp.mode); @@ -649,23 +649,23 @@ Ftp_dup(ARGS) FtpSetIOHandler(LINK,oldftp.IO); FtpSetHashHandler(LINK,oldftp.hash); } - - + + Ftp_bg(ARGS) { if (fork()) { - + log("Backgrounding..."); return; } else { int i=frame; - + lastcmd=1; - + /* Ignoring keypad */ alarm (0); @@ -680,7 +680,7 @@ Ftp_bg(ARGS) /* Droping output */ - + sprintf(tmp,"/tmp/uftp-%s.XXXXXX",getpwuid(getuid())->pw_name); mktemp(tmp); close(0);close(1);close(2); @@ -693,21 +693,21 @@ Ftp_bg(ARGS) free(ftp[i]); ftp[i]=NULL; } - + return executev(w2,w3,w4,w5,w6,""); } } - + Ftp_list() { register int i; - -#define _FMT "%-5s %-15s %-10s %-25s %-7s %-4s\n" -#define FMT "%-5d %-15s %-10s %-25s %-7d %-4d\n" - + +#define _FMT "%-5s %-15s %-10s %-25s %-7s %-4s\n" +#define FMT "%-5d %-15s %-10s %-25s %-7d %-4d\n" + printf(_FMT,"Frame","Host name","User's name","Working directory","Timeout","Port"); - + for ( i = 0 ; i < NFRAMES ; i++ ) if (ftp[i]!=NULL) printf(FMT,i,iftp[i].host,iftp[i].user,iftp[i].pwd, @@ -739,10 +739,10 @@ Ftp_page(ARGS) { register char *pager; String out={'|',0}; - - if ((pager=(char *)getenv("PAGER"))==NULL) + + if ((pager=(char *)getenv("PAGER"))==NULL) pager="more"; - + strcat(out,pager); FtpGet(LINK,w2,out); } @@ -759,24 +759,24 @@ Ftp_rm(ARGS) sprintf(tmp,"/tmp/uftplist-%s.XXXXXX",getpwuid(getuid())->pw_name); mktemp(tmp); - - if (*w2==0) + + if (*w2==0) { log("Filename specification must present"); return; } - + FtpRetr(LINK,"NLST %s",w2,tmp); - + if ((list=fopen(tmp,"r"))==NULL) return FtpLog(tmp,sys_errlist[errno]); - + while ( fgets(tmp,sizeof tmp,list)!=NULL) { tmp[strlen(tmp)-1]=0; FtpCommand(LINK,"DELE %s",tmp,0,EOF); } - + fclose(list); } @@ -791,7 +791,7 @@ Ftp_move(ARGS) Ftp_help(ARGS) { register int i,ii; - + if ( !*w2 ) { puts("Warrning!!!! \nPlease read general information using command \"help etc\"\n\n"); @@ -806,7 +806,7 @@ Ftp_help(ARGS) putchar ('\n'); } } - + for ( i = 0 ; 1; i++) { @@ -817,13 +817,13 @@ Ftp_help(ARGS) } puts(cmds[i].help); - + } Ftp_quote(ARGS) { String new; - + new[0]=0; if (*w2!=0) strcpy(new,w2); @@ -838,8 +838,8 @@ Ftp_quote(ARGS) Ftp_alias(ARGS) { ALIAS *a=firstalias; - - + + if ( *w2==0 ) { while (a!=NULL) @@ -851,20 +851,20 @@ Ftp_alias(ARGS) } - while (1) + while (1) { if ( a == NULL ) - { + { firstalias = a = (ALIAS *) malloc(sizeof(ALIAS)); memset(a,0,sizeof(ALIAS)); a -> next = NULL; break; } - + if (!strcmp(a->name,w2)) break; - + if ( a->next == NULL) { a -> next = (ALIAS *) malloc(sizeof(ALIAS)); @@ -875,7 +875,7 @@ Ftp_alias(ARGS) } a=a->next; } - + strcpy(a -> name,w2); strcpy(a -> str,makestr(w3,w4,w5,w6,NULL)); } @@ -889,7 +889,7 @@ Ftp_mkalias(ARGS) sprintf(new,"open \"%s\" \"%s\" \"%s\" \"%s\"", iftp[frame].host,iftp[frame].user, iftp[frame].pass,iftp[frame].pwd); - + Ftp_alias("alias",w2,new,"","",""); } @@ -947,31 +947,31 @@ Ftp_acd(ARGS) static int targets=0; static String what={0}; static ARCHIE result[ARCHIE_MAX_TARGETS]; - + int i, selected_target; String tmp; char *p; - + if ( (what[0] == 0 || strcmp(w2,what) != 0) && *w2!=0 ) { - if ((targets=FtpArchie(w2,result,ARCHIE_MAX_TARGETS))<1) + if ((targets=FtpArchie(w2,result,ARCHIE_MAX_TARGETS))<1) return puts("Archie failure or target not found"); strcpy(what,w2); } - + for (i=0;i<targets;i++) printf("%2d %s:%s\n",i,result[i].host,result[i].file); - + if (strcmp(w1,"archie")==0) return; - - + + p = readline("Your selection? "); if (p==NULL) return; - + selected_target = atoi(p); - + if ( result[selected_target].file[strlen(result[selected_target].file)-1] == '/' ) { @@ -989,25 +989,25 @@ Ftp_acd(ARGS) CMDS cmds[]={ - + "connect", Ftp_connect, 0, "connect <hostname> - make new ftp connection", "open", Ftp_open, 0, "open <hostname> <user> <pass> <directory> - login to server", - + "reopen", Ftp_reopen, 1, "Open again connection with existing frame information", - + "ftp", Ftp_ftp, 0, "ftp <hostname> - anonymously login to server", - + "close", Ftp_close, 1, "Close connection", - + "quit", Ftp_quit, 0, "Exit from uftp", - + "set", Ftp_set, 0, "Set variables: (Without args print current settings)\n\ frame <number> - select another session(frame)\n\ @@ -1028,7 +1028,7 @@ CMDS cmds[]={ "prompt", NULL, 0, "\ -prompt is a string, which may be contains %<char> +prompt is a string, which may be contains %<char> or ^<char> combitanion, which have next interprets: %H, %h - full and short remote host names @@ -1038,8 +1038,8 @@ or ^<char> combitanion, which have next interprets: %D - local current directory %f - number of current frame %p - the ftp's port number -%t - timeout -%T - current time +%t - timeout +%T - current time %P - uftp process id %% - character % ^<char>- control character @@ -1114,7 +1114,7 @@ or ^<char> combitanion, which have next interprets: "bput", Ftp_bput, 0, "bput [<localfile>] <libftp_file> - full session procedure (See \"help etc\")", - + "copy", Ftp_copy, 1, "copy [<frame>!]file [<frame>!]file - copy file via client cache", @@ -1123,7 +1123,7 @@ or ^<char> combitanion, which have next interprets: "cat", Ftp_type, 1, "cat <file> - print body of remote file to screen", - + "page", Ftp_page, 1, "page <file> - print body of remote file to screen via pager", |