diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c index 49bf3aa14e1a..f5d9be974749 100644 --- a/usr.bin/ftp/util.c +++ b/usr.bin/ftp/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.125 2005/05/19 03:05:04 lukem Exp $ */ +/* $NetBSD: util.c,v 1.126 2005/05/19 03:14:52 lukem Exp $ */ /*- * Copyright (c) 1997-2005 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ #include #ifndef lint -__RCSID("$NetBSD: util.c,v 1.125 2005/05/19 03:05:04 lukem Exp $"); +__RCSID("$NetBSD: util.c,v 1.126 2005/05/19 03:14:52 lukem Exp $"); #endif /* not lint */ /* @@ -532,64 +532,64 @@ another(int *pargc, char ***pargv, const char *prompt) char * remglob(char *argv[], int doswitch, const char **errbuf) { - static char buf[MAXPATHLEN]; - static FILE *ftemp = NULL; - static char **args; - char temp[MAXPATHLEN]; - int oldverbose, oldhash, oldprogress, fd; - char *cp, *mode; + static char buf[MAXPATHLEN]; + static FILE *ftemp = NULL; + static char **args; + char temp[MAXPATHLEN]; + int oldverbose, oldhash, oldprogress, fd; + char *cp, *mode; size_t len; - if (!mflag || !connected) { - if (!doglob) - args = NULL; - else { - if (ftemp) { - (void)fclose(ftemp); - ftemp = NULL; - } - } - return (NULL); - } - if (!doglob) { - if (args == NULL) - args = argv; - if ((cp = *++args) == NULL) - args = NULL; - return (cp); - } - if (ftemp == NULL) { + if (!mflag || !connected) { + if (!doglob) + args = NULL; + else { + if (ftemp) { + (void)fclose(ftemp); + ftemp = NULL; + } + } + return (NULL); + } + if (!doglob) { + if (args == NULL) + args = argv; + if ((cp = *++args) == NULL) + args = NULL; + return (cp); + } + if (ftemp == NULL) { len = strlcpy(temp, tmpdir, sizeof(temp)); if (temp[len - 1] != '/') (void)strlcat(temp, "/", sizeof(temp)); (void)strlcat(temp, TMPFILE, sizeof(temp)); - if ((fd = mkstemp(temp)) < 0) { - warn("unable to create temporary file %s", temp); - return (NULL); - } - close(fd); - oldverbose = verbose; + if ((fd = mkstemp(temp)) < 0) { + warn("unable to create temporary file %s", temp); + return (NULL); + } + close(fd); + oldverbose = verbose; verbose = (errbuf != NULL) ? -1 : 0; - oldhash = hash; + oldhash = hash; oldprogress = progress; - hash = 0; + hash = 0; progress = 0; - if (doswitch) - pswitch(!proxy); - for (mode = "w"; *++argv != NULL; mode = "a") - recvrequest("NLST", temp, *argv, mode, 0, 0); + if (doswitch) + pswitch(!proxy); + for (mode = "w"; *++argv != NULL; mode = "a") + recvrequest("NLST", temp, *argv, mode, 0, 0); if ((code / 100) != COMPLETE) { if (errbuf != NULL) *errbuf = reply_string; } - if (doswitch) - pswitch(!proxy); - verbose = oldverbose; + if (doswitch) + pswitch(!proxy); + verbose = oldverbose; hash = oldhash; progress = oldprogress; - ftemp = fopen(temp, "r"); - (void)unlink(temp); - if (ftemp == NULL) { + ftemp = fopen(temp, "r"); + (void)unlink(temp); + if (ftemp == NULL) { if (errbuf == NULL) fputs( "can't find list of remote files, oops.\n", @@ -597,17 +597,17 @@ remglob(char *argv[], int doswitch, const char **errbuf) else *errbuf = "can't find list of remote files, oops."; - return (NULL); - } - } - if (fgets(buf, sizeof(buf), ftemp) == NULL) { - (void)fclose(ftemp); + return (NULL); + } + } + if (fgets(buf, sizeof(buf), ftemp) == NULL) { + (void)fclose(ftemp); ftemp = NULL; - return (NULL); - } - if ((cp = strchr(buf, '\n')) != NULL) - *cp = '\0'; - return (buf); + return (NULL); + } + if ((cp = strchr(buf, '\n')) != NULL) + *cp = '\0'; + return (buf); } /*