home *** CD-ROM | disk | FTP | other *** search
- From: mgleason@cse.unl.edu (Mike Gleason)
- Newsgroups: comp.sources.misc
- Subject: v42i018: ncftp - Alternative User Interface for FTP, Patch01
- Date: 29 Mar 1994 14:59:05 -0600
- Organization: NCEMRSoft
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <2na4qp$3c1@sparky.sterling.com>
- X-Md4-Signature: c5834125dc32c0ed11e7c6b0816f9e53
-
- Submitted-by: mgleason@cse.unl.edu (Mike Gleason)
- Posting-number: Volume 42, Issue 18
- Archive-name: ncftp/patch01
- Environment: UNIX, ANSI-C, !SVR4
- Patch-To: ncftp: Volume 40, Issue 76-81
-
- This is the first official patch to ncftp 1.6. This patch is a low
- priority patch, unless you use the syslog()'ing. There was a bug which
- could cause some transfers not to be logged. There are a bunch of
- minor fixes, and a couple of medium-sized bugs that were fixed; really,
- you could probably live without upgrading if you don't feel like going
- to the trouble.
-
- You need to have the ncftp 1.6.0 sources to apply this patch.
- NOTE: this patch includes all the unofficial patches, i.e. everything
- between 1.6.1 and 1.6.9. So after applying this patch you will get
- 1.7.0, and NOT 1.6 PL 1, nor 1.6.1. As a result, this patch won't work
- if you try to patch one of the unofficial versions. In that case, just
- ftp the whole 1.7.0 package.
-
- There are supposed to be tabs in this patch. Make sure your newsreader isn't
- converting them to spaces; if you have problems you may want to check to see
- if your 'patch' program can handle munged tabs (like patch -l, perhaps).
-
- I'll put up the whole 1.7.0 distribution up for ftp as:
- cse.unl.edu:/pub/mgleason/ncftp/ncftp.tgz
- PLEASE don't ftp it during business hours, though.
-
- * v1.6.1 - November 5, 1993.
- * Checking if we have permission to write over a file to fetch.
- * A few very minor changes. BSD no longer trying to use strchr :-)
- *
- * v1.6.2 - December 10, 1993.
- * Term hack no longer depends on the PASV command (!). The BROKEN_MEMCPY
- * problem worked-around. More wary of symbolic-link recursion.
- * Fixed local path expander. Fixed inadvertant flushing of the typeahead
- * buffer. Debug mode won't print your password. Progress meters
- * no longer goof up when the file is huge. Added time-remaining to the
- * Philbar.
- *
- * v1.6.3 - December 28, 1993. Added a new diagnostic command, memchk,
- * to print stats from a special malloc library if you used one.
- * Using SIZE and MDTM when the remote site supports it. Using a new
- * set of routines for term (again).
- *
- * v1.6.4 - December 30, 1993. Fixed rare problem with GetDateAndTime.
- * confirm() will return true if you're running the init macro.
- *
- * v1.6.5 - January 6, 1994. Fixed error with an #ifndef/#endif block having
- * whitespace before the #. No longer confirming "ls >file" actions.
- * Changed echo() to Echo(). AIX 3 uses TERMIOS.
- *
- * v1.6.6 - February 15, 1994. Prevented scenario of fclosing a NULL FILE *.
- * Edited term ftp's hookup() a little. More defs for linux in sys.h.
- * Not updating a recent entry unless you were fully logged in.
- *
- * v1.6.7 - February 20, 1994. Using getpwnam() instead of getpwuid().
- * Supporting WWW paths (i.e. ftp://host.name/path/name).
- *
- * v1.6.8 - March 4, 1994. Ensuring that tmp files are not public.
- * Trying harder to get the real hostname, and fixed problem with
- * disappearing progress meters (both due to T. Lindgren).
- *
- * v1.6.9 - March 11, 1994. Added DOMAIN_NAME and Solaris CPP symbols.
- * Better handling of getting the domain name, specifically with SunOS.
- * BSDi support added.
- *
- * v1.7.0 - March 14, 1994. More verbose when logging to the system log,
- * and making sure that syslog() itself is called with a total of 5
- * or less parameters. Official patch posted which incorporates all
- * the fixes to 1.6.0 (i.e. 1.6.1, 1.6.2, ... 1.6.9).
- */
- diff -c ./Blurb ../ncftp170/Blurb
- *** ./Blurb Wed Mar 16 18:24:56 1994
- --- ../ncftp170/Blurb Wed Mar 16 19:16:03 1994
- ***************
- *** 14,24 ****
- man page.
-
- 1.6.0 is an "evolutionary" upgrade, which consolidates all the previous
- ! patches and adds a little. 1.6, like 1.5 are "interim" versions between
- 2.0 which has been suspended indefinitely due to time constraints.
-
- Major changes since 1.5.6:
- - -------------------------
-
- * Built-in support for the "term" package, used by Linux, etc.
-
- --- 14,23 ----
- man page.
-
- 1.6.0 is an "evolutionary" upgrade, which consolidates all the previous
- ! patches and adds a little. 1.6 and 1.5 are "interim" versions between
- 2.0 which has been suspended indefinitely due to time constraints.
-
- Major changes since 1.5.6:
-
- * Built-in support for the "term" package, used by Linux, etc.
-
- ***************
- *** 30,36 ****
-
-
- Major changes since 1.0.2:
- - -------------------------
-
- * Supports the Getline (input-edit) and GNU Readline command-line
- editing and history libraries.
- --- 29,34 ----
- diff -c ./README ../ncftp170/README
- *** ./README Wed Mar 16 18:24:47 1994
- --- ../ncftp170/README Wed Mar 16 20:29:09 1994
- ***************
- *** 78,88 ****
- 'make' (but proceed to part C):
-
- Silicon Graphics IRIX
- ! AIX
- SINIX
- ! Ultrix
- NeXT
- Pyramid OSx
-
- Otherwise you will have to configure ncftp manually.
-
- --- 78,89 ----
- 'make' (but proceed to part C):
-
- Silicon Graphics IRIX
- ! IBM's AIX
- SINIX
- ! DEC's Ultrix (well, might need to use -lcursesX instead of -lcurses)
- NeXT
- Pyramid OSx
- + Berkley Software Design, Inc.'s BSDi
-
- Otherwise you will have to configure ncftp manually.
-
- ***************
- *** 104,110 ****
- The regular 'cc' is not an ANSI compiler. You could also run
- something like 'ansi2knr' on the sources and hope it works.
- You will probably need to link both the curses and termcap
- ! libraries if you use -DCURSES (see below).
-
- Hewlett-Packard HP-UX: If you have 7.0, you'll need to find
- a copy of <ftp.h> from somewhere (8.0 has it though). Then
- --- 105,113 ----
- The regular 'cc' is not an ANSI compiler. You could also run
- something like 'ansi2knr' on the sources and hope it works.
- You will probably need to link both the curses and termcap
- ! libraries if you use -DCURSES (see below). If you're running
- ! Solaris (SunOS 5.x or greater) add -DSolaris to SDEFS.
- ! I also needed to add -lnsl -lsocket to LIBS.
-
- Hewlett-Packard HP-UX: If you have 7.0, you'll need to find
- a copy of <ftp.h> from somewhere (8.0 has it though). Then
- ***************
- *** 117,124 ****
-
- Linux: For 'term' support, from what I can tell just add
- the path of 'client.a' to LIBS, and add -DTERM_FTP to SDEFS,
- ! to turn on the term specific ftp code. srivasta@pilgrim.umass.edu
- ! supplied the term patch.
-
- SCO Unix: Add -DSCO324 or -DSCO322 (as appropriate) to SDEFS,
- and -lsocket to LIBS.
- --- 120,127 ----
-
- Linux: For 'term' support, from what I can tell just add
- the path of 'client.a' to LIBS, and add -DTERM_FTP to SDEFS,
- ! to turn on the term specific ftp code. May need to link
- ! -lcurses and -ltermcap.
-
- SCO Unix: Add -DSCO324 or -DSCO322 (as appropriate) to SDEFS,
- and -lsocket to LIBS.
- ***************
- *** 230,237 ****
- re-compile it with HOSTNAME set to your machine's address, in the
- form of 'machine.xxx.yyy.'
-
- * (Optional) Add -DSTRICT_PROTOS if your compiler wants function prototypes
- ! for all functions, not just non-int-returning ones.
-
-
- Part C. Program Options:
- --- 233,253 ----
- re-compile it with HOSTNAME set to your machine's address, in the
- form of 'machine.xxx.yyy.'
-
- + * (Optional) Add -DHAS_DOMAINNAME if you have the getdomainname()
- + function.
- +
- + * (Optional) If you're having problems with your hostname not being
- + full (i.e you have 'yourlogin@machine') all is not lost. First of all,
- + define HAS_DOMAINNAME if you can. But sometimes getdomainname() doesn't
- + work -- instead of giving you the domain name, it returns an empty
- + string. So you can hardcode the domain name by defining DOMAIN_NAME to
- + be the domain (i.e. add -DDOMAIN_NAME=\"domain.nam\"). That way, if
- + getdomainname doesn't work, the program will have something to fall back
- + on. This problem is common on SunOS/Solaris.
- +
- * (Optional) Add -DSTRICT_PROTOS if your compiler wants function prototypes
- ! for all functions, not just non-int-returning ones. This is really just
- ! handy for debugging during development, so this is not recommended.
-
-
- Part C. Program Options:
- diff -c ./cmds.c ../ncftp170/cmds.c
- *** ./cmds.c Wed Mar 16 18:24:47 1994
- --- ../ncftp170/cmds.c Wed Mar 16 19:16:02 1994
- ***************
- *** 48,53 ****
- --- 48,54 ----
- int creating = 0;
- struct macel macros[MAXMACROS];
- char *macbuf; /* holds ALL macros */
- + int doingInitMacro = 0; /* TRUE if executing "init" macro. */
- jmp_buf jabort;
- char *mname; /* name of current m* command */
- int activemcmd; /* flag: if != 0, then active multi command */
- ***************
- *** 77,82 ****
- --- 78,84 ----
- extern char *altarg, *line, *margv[];
- extern char *globchars;
- extern Hostname hostname;
- + extern RemoteSiteInfo gRmtInfo;
- extern string progname, pager, anon_password;
- extern string prompt, version, indataline;
- extern longstring logfname;
- ***************
- *** 107,121 ****
-
-
-
- ! long GetDateAndSize(char *fName, unsigned long *mod_time)
- {
- char *cp, *np;
- string lsline;
- ! long size = 0L;
- int n, v;
- struct lslist *savedh, *savedt;
- !
- ! *mod_time = 0;
- v = verbose; verbose = V_QUIET;
- is_ls = 1;
- buffer_only = 1;
- --- 109,125 ----
-
-
-
- ! long GetDateSizeFromLSLine(char *fName, unsigned long *mod_time)
- {
- char *cp, *np;
- string lsline;
- ! long size = SIZE_UNKNOWN;
- int n, v;
- struct lslist *savedh, *savedt;
- ! static int depth = 0;
- !
- ! depth++; /* Try to prevent infinite recursion. */
- ! *mod_time = MDTM_UNKNOWN;
- v = verbose; verbose = V_QUIET;
- is_ls = 1;
- buffer_only = 1;
- ***************
- *** 173,189 ****
- /* May be the size of a link to the file, instead of the file. */
- if ((cp = strstr(lsline, " -> ")) != NULL) {
- /* Yes, it was a link. */
- ! size = GetDateAndSize(cp + 4, mod_time); /* Try the file. */
- }
- }
- }
- aa:
- return (size);
- } /* GetDateAndSize */
-
-
-
-
- int _settype(char *typename)
- {
- register struct types *p;
- --- 177,272 ----
- /* May be the size of a link to the file, instead of the file. */
- if ((cp = strstr(lsline, " -> ")) != NULL) {
- /* Yes, it was a link. */
- ! size = (depth>4) ? SIZE_UNKNOWN :
- ! GetDateAndSize(cp + 4, mod_time);
- ! /* Try the file. */
- }
- }
- }
- aa:
- + --depth;
- return (size);
- + } /* GetDateSizeFromLSLine */
- +
- +
- +
- +
- + /* The caller wanted to know the modification date and size of the remote
- + * file given to us. We try to get this information by using the SIZE
- + * and MDTM ftp commands, and if that didn't work we try sending the site
- + * a "ls -l <fName>" and try to get that information from the line it
- + * sends us back. It is possible that we won't be able to determine
- + * either of these, though.
- + */
- + long GetDateAndSize(char *fName, unsigned long *mod_time)
- + {
- + unsigned long mdtm, ls_mdtm;
- + long size, ls_size;
- + int have_mdtm, have_size;
- + string cmd;
- +
- + size = SIZE_UNKNOWN;
- + mdtm = MDTM_UNKNOWN;
- + if (fName != NULL) {
- + have_mdtm = have_size = 0;
- + if (gRmtInfo.hasSIZE) {
- + (void) Strncpy(cmd, "SIZE ");
- + (void) Strncat(cmd, fName);
- + if (quiet_command(cmd) == 2) {
- + if (sscanf(reply_string, "%*d %ld", &size) == 1)
- + have_size = 1;
- + } else if (strncmp(reply_string, "550", (size_t)3) != 0)
- + gRmtInfo.hasSIZE = 0;
- + }
- +
- + #ifndef NO_MKTIME
- + /* We'll need mktime() to un-mangle this. */
- + if (gRmtInfo.hasMDTM) {
- + (void) Strncpy(cmd, "MDTM ");
- + (void) Strncat(cmd, fName);
- + if (quiet_command(cmd) == 2) {
- + /* Result should look like "213 19930602204445\n" */
- + mdtm = UnSIZEDate(reply_string);
- + if (mdtm != MDTM_UNKNOWN)
- + have_mdtm = 1;
- + } else if (strncmp(reply_string, "550", (size_t)3) != 0)
- + gRmtInfo.hasMDTM = 0;
- + }
- + #endif /* NO_MKTIME */
- +
- + if (!have_mdtm || !have_size)
- + ls_size = GetDateSizeFromLSLine(fName, &ls_mdtm);
- +
- + /* Try to use the information from the real SIZE/MDTM commands if
- + * we could, since some maverick ftp server may be using a non-standard
- + * ls command, and we could parse it wrong.
- + */
- +
- + if (!have_mdtm)
- + mdtm = ls_mdtm;
- + if (!have_size)
- + size = ls_size;
- +
- + dbprintf("Used SIZE: %s; Used MDTM: %s\n",
- + have_size ? "yes" : "no",
- + have_mdtm ? "yes" : "no"
- + );
- +
- + if (debug > 0) {
- + if (size != SIZE_UNKNOWN)
- + dbprintf("Size: %ld\n", size);
- + if (mdtm != MDTM_UNKNOWN)
- + dbprintf("Mdtm: %s\n", ctime((time_t *) &mdtm));
- + }
- + }
- + *mod_time = mdtm;
- + return size;
- } /* GetDateAndSize */
-
-
-
-
- +
- int _settype(char *typename)
- {
- register struct types *p;
- ***************
- *** 225,231 ****
- case TYPE_L: c = 't';
- }
- *tp = c;
- ! return (_settype(tp));
- } /* SetTypeByNumber */
-
-
- --- 308,314 ----
- case TYPE_L: c = 't';
- }
- *tp = c;
- ! return (c == 0 ? -1 : _settype(tp));
- } /* SetTypeByNumber */
-
-
- ***************
- *** 368,373 ****
- --- 451,457 ----
- (void) recvrequest ("NLST", tname, pattern, "w");
- verbose = oldverbose;
- ftemp = fopen(tname, "r");
- + (void) chmod(tname, 0600);
- if (ftemp == NULL || FGets(str, ftemp) == NULL) {
- if (NOT_VQUIET)
- (void) printf("%s: no match.\n", pattern);
- ***************
- *** 563,568 ****
- --- 647,654 ----
- errs = 0;
- for (mode = "w", i=1; argv[i] != NULL; i++, mode = "a") {
- result = recvrequest ("NLST", tmpname, argv[i], mode);
- + if (i == 1)
- + (void) chmod(tmpname, 0600);
- if (result < 0) {
- fprintf(stderr, "%s: %s.\n",
- argv[i],
- ***************
- *** 572,583 ****
- errs++;
- }
- }
- if (errs == (i - 1)) {
- /* Every pattern was in error, so we can't try anything. */
- (void) unlink(tmpname); /* Shouldn't be there anyway. */
- return NULL;
- }
- - verbose = oldverbose;
- ftemp = fopen(tmpname, "r");
- if (ftemp == NULL) {
- PERROR("remglob", tmpname);
- --- 658,669 ----
- errs++;
- }
- }
- + verbose = oldverbose;
- if (errs == (i - 1)) {
- /* Every pattern was in error, so we can't try anything. */
- (void) unlink(tmpname); /* Shouldn't be there anyway. */
- return NULL;
- }
- ftemp = fopen(tmpname, "r");
- if (ftemp == NULL) {
- PERROR("remglob", tmpname);
- ***************
- *** 736,748 ****
- */
- int lcd(int argc, char **argv)
- {
- if (argc < 2)
- argc++, argv[1] = home;
- if (argc != 2) {
- return USAGE;
- }
- ! if (chdir(LocalDotPath(argv[1])) < 0) {
- ! PERROR("lcd", argv[1]);
- return CMDERR;
- }
- (void) get_cwd(lcwd, (int) sizeof(lcwd));
- --- 822,837 ----
- */
- int lcd(int argc, char **argv)
- {
- + longstring ldir;
- +
- if (argc < 2)
- argc++, argv[1] = home;
- if (argc != 2) {
- return USAGE;
- }
- ! (void) Strncpy(ldir, argv[1]);
- ! if (chdir(LocalDotPath(ldir)) < 0) {
- ! PERROR("lcd", ldir);
- return CMDERR;
- }
- (void) get_cwd(lcwd, (int) sizeof(lcwd));
- ***************
- *** 952,961 ****
- }
- }
-
- ! aa: if ((strcmp(local, "-") != 0) && (local[0] != '|')) {
- ! if (!confirm("Output to local-file: ", local))
- ! return CMDERR;
- ! }
- is_ls = 1; /* tells getreply() to start saving input to a buffer. */
- (void) Strncpy(str, remote);
- if (lsflags[0] && remote[0])
- --- 1041,1047 ----
- }
- }
-
- ! aa:
- is_ls = 1; /* tells getreply() to start saving input to a buffer. */
- (void) Strncpy(str, remote);
- if (lsflags[0] && remote[0])
- ***************
- *** 987,992 ****
- --- 1073,1081 ----
-
- old1 = signal (SIGINT, SIG_IGN);
- old2 = signal (SIGQUIT, SIG_IGN);
- + /* This will prevent <defunct> zombie processes. */
- + /* (void) signal(SIGCHLD, SIG_IGN); */
- +
- if ((pid = fork()) == 0) {
- for (pid = 3; pid < 20; pid++)
- (void) close(pid);
- ***************
- *** 1224,1230 ****
-
- (void) command("QUIT");
- close_streams(0);
- ! UpdateRecentSitesList(hostname, cwd);
- hostname[0] = cwd[0] = 0;
- logged_in = connected = 0;
- data = -1;
- --- 1313,1320 ----
-
- (void) command("QUIT");
- close_streams(0);
- ! if (logged_in)
- ! UpdateRecentSitesList(hostname, cwd);
- hostname[0] = cwd[0] = 0;
- logged_in = connected = 0;
- data = -1;
- ***************
- *** 1437,1442 ****
- --- 1527,1533 ----
- (void) printf("'%s' macro not found.\n", argv[1]);
- return USAGE;
- }
- + doingInitMacro = (strcmp(macros[i].mac_name, "init") == 0);
- (void) Strncpy(str, line);
- TOP:
- cp1 = macros[i].mac_start;
- ***************
- *** 1507,1512 ****
- --- 1598,1604 ----
- if (loopflg && ++count < argc) {
- goto TOP;
- }
- + doingInitMacro = 0;
- return NOERR;
- } /* domacro */
-
- ***************
- *** 1554,1561 ****
- (void) sprintf(str, "MDTM %s", argv[1]);
- if (command(str) == COMPLETE) {
- int yy, mo, day, hour, min, sec;
- ! (void) sscanf(reply_string, "%*s %04d%02d%02d%02d%02d%02d", &yy, &mo,
- ! &day, &hour, &min, &sec);
- /* might want to print this in local time */
- (void) printf("%s\t%02d/%02d/%04d %02d:%02d:%02d GMT\n", argv[1],
- mo, day, yy, hour, min, sec);
- --- 1646,1653 ----
- (void) sprintf(str, "MDTM %s", argv[1]);
- if (command(str) == COMPLETE) {
- int yy, mo, day, hour, min, sec;
- ! (void) sscanf(reply_string, "%*s %04d%02d%02d%02d%02d%02d",
- ! &yy, &mo, &day, &hour, &min, &sec);
- /* might want to print this in local time */
- (void) printf("%s\t%02d/%02d/%04d %02d:%02d:%02d GMT\n", argv[1],
- mo, day, yy, hour, min, sec);
- ***************
- *** 1623,1628 ****
- --- 1715,1726 ----
- } else {
- if (*host->h_name)
- (void) Strncpy(lasthostname, host->h_name);
- + for (j=0; host->h_aliases[j] != NULL; j++) {
- + if (strlen(host->h_aliases[j]) >
- + strlen(host->h_name) &&
- + strstr(host->h_aliases[j],host->h_name) != NULL)
- + (void) Strncpy(lasthostname,host->h_aliases[j]);
- + }
- if (NOT_VQUIET) {
- (void) printf("%-32s ", *host->h_name ? host->h_name : "???");
- if (*host->h_addr_list) {
- ***************
- *** 1649,1664 ****
- {
- int oldv, r;
- char *argv[2];
- - #ifdef HAS_DOMAINNAME
- char domain[64];
- - #endif
-
- #ifdef HOSTNAME
- (void) strncpy(host, HOSTNAME, size);
- return NOERR;
- #else
- ! *host = 0;
- if ((r = gethostname(host, size)) == 0) {
- oldv = verbose;
- verbose = V_QUIET;
- argv[0] = "lookup";
- --- 1747,1766 ----
- {
- int oldv, r;
- char *argv[2];
- char domain[64];
-
- #ifdef HOSTNAME
- (void) strncpy(host, HOSTNAME, size);
- return NOERR;
- #else
- ! host[0] = '\0';
- if ((r = gethostname(host, size)) == 0) {
- + if (host[0] == '\0') {
- + (void) fprintf(stderr,
- + "Could not determine the hostname. Re-compile with HOSTNAME defined\n\
- + to be the full name of your hostname.\n");
- + exit(1);
- + }
- oldv = verbose;
- verbose = V_QUIET;
- argv[0] = "lookup";
- ***************
- *** 1666,1679 ****
- (void) makeargv();
- if (lookup(margc, margv) == 0 && lasthostname[0]) {
- (void) _Strncpy(host, lasthostname, size);
- #ifdef HAS_DOMAINNAME
- if (index(host, '.') == NULL) {
- ! if (getdomainname(domain + 1, sizeof(domain) - 1) == 0) {
- ! domain[0] = '.';
- (void) _Strncat(host, domain, size);
- }
- }
- - #endif
- }
- verbose = oldv;
- }
- --- 1768,1807 ----
- (void) makeargv();
- if (lookup(margc, margv) == 0 && lasthostname[0]) {
- (void) _Strncpy(host, lasthostname, size);
- + domain[0] = '\0';
- #ifdef HAS_DOMAINNAME
- + /* getdomainname() returns just the domain name, without a
- + * preceding period. For example, on "cse.unl.edu", it would
- + * return "unl.edu".
- + *
- + * SunOS note: getdomainname will return an empty string if
- + * this machine isn't on NIS.
- + */
- + (void) getdomainname(domain, sizeof(domain) - 1);
- + #endif
- + #ifdef DOMAIN_NAME
- + if (domain[0] == '\0')
- + (void) Strncpy(domain, DOMAIN_NAME);
- + #endif
- if (index(host, '.') == NULL) {
- ! /* If the hostname has periods we'll assume that the
- ! * it includes the domain name already. Some gethostname()s
- ! * return the whole host name, others just the machine name.
- ! * If we have just the machine name and we successfully
- ! * found out the domain name (from above), we'll append
- ! * the domain to the machine to get a full hostname.
- ! */
- ! if (domain[0]) {
- ! (void) _Strncat(host, ".", size);
- (void) _Strncat(host, domain, size);
- + } else {
- + fprintf(stderr,
- + "WARNING: could not determine full host name (have: '%s').\n\
- + The program should be re-compiled with DOMAIN_NAME defined to be the\n\
- + domain name, i.e. -DDOMAIN_NAME=\\\"unl.edu\\\"\n\n",
- + host);
- }
- }
- }
- verbose = oldv;
- }
- ***************
- *** 1797,1802 ****
- --- 1925,1936 ----
- #ifdef HAS_DOMAINNAME
- DStrs[nDStrs++] = "HAS_DOMAINNAME";
- #endif
- + #ifdef DOMAIN_NAME
- + DStrs[nDStrs++] = "DOMAIN_NAME";
- + #endif
- + #ifdef Solaris
- + DStrs[nDStrs++] = "Solaris";
- + #endif
- #ifdef HOSTNAME
- DStrs[nDStrs++] = "HOSTNAME";
- #endif
- ***************
- *** 1985,1990 ****
- --- 2119,2172 ----
- (void) Signal(SIGPIPE, oldintp);
- return NOERR;
- } /* ShowLineBuffer */
- +
- +
- +
- +
- + #if LIBMALLOC != LIBC_MALLOC
- + /*ARGSUSED*/
- + int MallocStatusCmd(int argc, char **argv)
- + {
- + #if (LIBMALLOC == FAST_MALLOC)
- + struct mallinfo mi;
- +
- + mi = mallinfo();
- + printf("\
- + total space in arena: %d\n\
- + number of ordinary blocks: %d\n\
- + number of small blocks: %d\n\
- + number of holding blocks: %d\n\
- + space in holding block headers: %d\n\
- + space in small blocks in use: %d\n\
- + space in free small blocks: %d\n\
- + space in ordinary blocks in use: %d\n\
- + space in free ordinary blocks: %d\n\
- + cost of enabling keep option: %d\n",
- + mi.arena,
- + mi.ordblks,
- + mi.smblks,
- + mi.hblks,
- + mi.hblkhd,
- + mi.usmblks,
- + mi.fsmblks,
- + mi.uordblks,
- + mi.fordblks,
- + mi.keepcost
- + );
- + #else
- + #if (LIBMALLOC == DEBUG_MALLOC)
- + printf("malloc_chain_check: %d\n\n", malloc_chain_check(0));
- + if (argc > 1)
- + malloc_dump(1);
- + printf("malloc_inuse: %lu\n", malloc_inuse(NULL));
- + #else
- + printf("Nothing to report.\n");
- + #endif /* (LIBMALLOC == DEBUG_MALLOC) */
- + #endif /* (LIBMALLOC == FAST_MALLOC) */
- +
- + return (0);
- + } /* MallocStatusCmd */
- + #endif /* LIBMALLOC */
-
-
-
- diff -c ./cmds.h ../ncftp170/cmds.h
- *** ./cmds.h Wed Mar 16 18:24:56 1994
- --- ../ncftp170/cmds.h Wed Mar 16 19:16:02 1994
- ***************
- *** 26,31 ****
- --- 26,35 ----
-
- #define LS_FLAGS_AND_FILE '\1'
-
- + /* Possible values returned by GetDateAndTime. */
- + #define SIZE_UNKNOWN (-1L)
- + #define MDTM_UNKNOWN (0L)
- +
- /* Command result codes. */
- #define USAGE (88)
- #define NOERR (0)
- ***************
- *** 112,118 ****
- --- 116,124 ----
- int show_version(int argc, char **argv);
- void PurgeLineBuffer(void);
- int ShowLineBuffer(int argc, char **argv);
- + int MallocStatusCmd(int argc, char **argv);
- int unimpl(int argc, char **argv);
- + long GetDateSizeFromLSLine(char *fName, unsigned long *mod_time);
- long GetDateAndSize(char *fName, unsigned long *mod_time);
- int SetTypeByNumber(int i);
-
- diff -c ./cmdtab.c ../ncftp170/cmdtab.c
- *** ./cmdtab.c Wed Mar 16 18:24:57 1994
- --- ../ncftp170/cmdtab.c Wed Mar 16 19:16:02 1994
- ***************
- *** 84,90 ****
- -r : \"Redial\" until connected.\n\
- -d N : Redial, pausing N seconds between tries.\n\
- -g N : Redial, giving up after N tries.\n\
- ! :path : Open site, then retrieve file \"path.\""
-
- #define PAGEHELP "view a file on the remote host with your $PAGER"
- #define PAGEUSAGE REMOTEFILE
- --- 84,91 ----
- -r : \"Redial\" until connected.\n\
- -d N : Redial, pausing N seconds between tries.\n\
- -g N : Redial, giving up after N tries.\n\
- ! :path : Open site, then retrieve file \"path.\" WWW-style paths are\n\
- ! also acceptable, i.e. 'ftp://cse.unl.edu/mgleason/README.'"
-
- #define PAGEHELP "view a file on the remote host with your $PAGER"
- #define PAGEUSAGE REMOTEFILE
- ***************
- *** 161,166 ****
- --- 162,171 ----
- { "mdelete", 1, 0, mdelete,
- "deletes multiple files on the remote host", REMOTEFILES },
- { "mdir", 1, 1, ls, LSHELP, LSUSAGE },
- + #if LIBMALLOC != LIBC_MALLOC
- + { "memchk", 0, 0, MallocStatusCmd,
- + "show debugging information about memory usage.", EMPTYSTR },
- + #endif
- { "mget", 1, 0, mget,
- "fetches multiple files from the remote host", REMOTEFILES },
- { "mkdir", 1, 0, makedir,
- diff -c ./ftp.c ../ncftp170/ftp.c
- *** ./ftp.c Wed Mar 16 18:24:49 1994
- --- ../ncftp170/ftp.c Wed Mar 16 19:16:02 1994
- ***************
- *** 54,63 ****
- #include "defaults.h"
- #include "copyright.h"
-
- - #ifdef TERM_FTP
- - extern int compress_toggle;
- - #endif
- -
- /* ftp.c globals */
- struct sockaddr_in hisctladdr;
- struct sockaddr_in data_addr;
- --- 54,59 ----
- ***************
- *** 87,93 ****
-
- /* ftp.c externs */
- extern FILE *logf;
- ! extern string cwd, anon_password;
- extern Hostname hostname;
- extern int verbose, debug, macnum, margc;
- extern int curtype, creating, toatty;
- --- 83,90 ----
-
- /* ftp.c externs */
- extern FILE *logf;
- ! extern string anon_password;
- ! extern longstring cwd, lcwd;
- extern Hostname hostname;
- extern int verbose, debug, macnum, margc;
- extern int curtype, creating, toatty;
- ***************
- *** 107,115 ****
- #endif
-
- #ifdef TERM_FTP
- ! #include "client.h"
- extern int lcompression, rcompression;
- int compress_toggle = 0;
- #endif
-
-
- --- 104,113 ----
- #endif
-
- #ifdef TERM_FTP
- ! #include <term/client.h>
- extern int lcompression, rcompression;
- int compress_toggle = 0;
- + extern int compress_toggle;
- #endif
-
-
- ***************
- *** 117,162 ****
-
- int hookup(char *host, unsigned int port)
- {
- ! int s;
-
- ! lcompression = rcompression = compress_toggle;
-
- ! if ((s = connect_server(0)) < 0) {
- ! perror("ftp: connect to term server");
- ! return -1;
- ! }
- ! send_command(s, C_PORT, 0, "%s:%d", host, ntohs(port));
- ! send_command(s, C_DUMB, 1, 0);
-
- ! cin = fdopen(s, "r");
- ! cout = fdopen(s, "w");
- ! if (cin == NULL || cout == NULL) {
- ! fprintf(stderr, "ftp: fdopen failed.\n");
- ! if (cin)
- ! fclose(cin);
- ! if (cout)
- ! fclose(cout);
- ! code = -1;
- ! goto bad;
- ! }
- ! Strncpy(hostname, host);
- ! if (verbose)
- ! printf("Connected to %s.\n", hostname);
- ! if (getreply(0) > 2) { /* read startup message from server */
- ! if (cin)
- ! fclose(cin);
- ! if (cout)
- ! fclose(cout);
- ! code = -1;
- ! goto bad;
- ! }
- ! return 0;
- bad:
- ! (void) close(s);
- ! return code;
- ! }
- ! #else
-
- int hookup(char *host, unsigned int port)
- {
- register struct hostent *hp = 0;
- --- 115,160 ----
-
- int hookup(char *host, unsigned int port)
- {
- ! int s;
- ! int result = -1;
-
- ! lcompression = rcompression = compress_toggle;
-
- ! if ((s = connect_server(0)) < 0) {
- ! perror("ftp: connect to term server");
- ! goto ret;
- ! }
- ! send_command(s, C_PORT, 0, "%s:%d", host, ntohs(port));
- ! send_command(s, C_DUMB, 1, 0);
-
- ! cin = fdopen(s, "r");
- ! cout = fdopen(dup(s), "w");
- ! if (cin == NULL || cout == NULL) {
- ! fprintf(stderr, "ftp: fdopen failed.\n");
- ! goto bad;
- ! }
- ! Strncpy(hostname, host);
- ! if (verbose)
- ! printf("Connected to %s.\n", hostname);
- ! if (getreply(0) > 2) { /* read startup message from server */
- ! goto bad;
- ! }
- ! result = 0;
- ! goto ret;
- !
- bad:
- ! (void) close(s);
- ! if (cin != NULL)
- ! (void) fclose(cin);
- ! if (cout != NULL)
- ! (void) fclose(cout);
- ! cin = cout = NULL;
-
- + ret:
- + return (result);
- + } /* hookup_term */
- + #else /* Not TERM_FTP, i.e. most of us. */
- +
- int hookup(char *host, unsigned int port)
- {
- register struct hostent *hp = 0;
- ***************
- *** 238,244 ****
- goto bad;
- }
- cin = fdopen(s, "r");
- ! cout = fdopen(s, "w");
- if (cin == NULL || cout == NULL) {
- (void) fprintf(stderr, "ftp: fdopen failed.\n");
- close_streams(0);
- --- 236,242 ----
- goto bad;
- }
- cin = fdopen(s, "r");
- ! cout = fdopen(dup(s), "w");
- if (cin == NULL || cout == NULL) {
- (void) fprintf(stderr, "ftp: fdopen failed.\n");
- close_streams(0);
- ***************
- *** 268,273 ****
- --- 266,275 ----
-
- bad:
- (void) close(s);
- + if (cin != NULL)
- + (void) fclose(cin);
- + if (cout != NULL)
- + (void) fclose(cout);
- done:
- return (hErr);
- } /* hookup */
- ***************
- *** 430,437 ****
- Sig_t oldintr;
- string str;
-
- abrtflag = 0;
- ! dbprintf("cmd: \"%s\" (length %d)\n", cmd, (int) strlen(cmd));
- if (cout == NULL) {
- (void) sprintf(str, "%s: No control connection for command", cmd);
- PERROR("command", str);
- --- 432,449 ----
- Sig_t oldintr;
- string str;
-
- + if (cmd == NULL) {
- + /* Should never happen; bug if it does. */
- + PERROR("command", "NULL command");
- + return (-1);
- + }
- abrtflag = 0;
- ! if (debug) {
- ! if (strncmp(cmd, "PASS", (size_t)4) == 0)
- ! dbprintf("cmd: \"PASS ********\"\n");
- ! else
- ! dbprintf("cmd: \"%s\" (length %d)\n", cmd, (int) strlen(cmd));
- ! }
- if (cout == NULL) {
- (void) sprintf(str, "%s: No control connection for command", cmd);
- PERROR("command", str);
- ***************
- *** 438,460 ****
- return (0);
- }
- oldintr = Signal(SIGINT, /* cmdabort */ SIG_IGN);
- ! #ifndef BROKEN_MEMCPY
- if (cout != NULL)
- (void) fprintf(cout, "%s\r\n", cmd);
- - #else
- - {
- - /*
- - * The fprintf() above gives me a core-dump in memcpy()...
- - * This does the trick though...
- - */
-
- - char *p = cmd;
- - while (*p)
- - fputc(*p++, cout);
- - fputc('\r', cout);
- - fputc('\n', cout);
- - }
- - #endif /* !SCO324 */
- (void) fflush(cout);
- cpend = 1;
- r = (flags == WAIT_FOR_REPLY) ?
- --- 450,460 ----
- return (0);
- }
- oldintr = Signal(SIGINT, /* cmdabort */ SIG_IGN);
- !
- ! /* Used to have BROKEN_MEMCPY tested here. */
- if (cout != NULL)
- (void) fprintf(cout, "%s\r\n", cmd);
-
- (void) fflush(cout);
- cpend = 1;
- r = (flags == WAIT_FOR_REPLY) ?
- ***************
- *** 490,496 ****
- register int oldverbose, result;
-
- oldverbose = verbose;
- ! verbose = V_QUIET;
- result = command(cmd);
- verbose = oldverbose;
- return (result);
- --- 490,496 ----
- register int oldverbose, result;
-
- oldverbose = verbose;
- ! verbose = debug ? V_VERBOSE : V_QUIET;
- result = command(cmd);
- verbose = oldverbose;
- return (result);
- ***************
- *** 694,700 ****
- int start_progress(int sending, char *local)
- {
- long s;
- ! str32 spec;
-
- cur_progress_meter = toatty ? progress_meter : 0;
- if ((cur_progress_meter > pr_last) || (cur_progress_meter < 0))
- --- 694,700 ----
- int start_progress(int sending, char *local)
- {
- long s;
- ! char spec[64];
-
- cur_progress_meter = toatty ? progress_meter : 0;
- if ((cur_progress_meter > pr_last) || (cur_progress_meter < 0))
- ***************
- *** 723,731 ****
- local,
- tcap_normal
- );
- ! barlen = 63;
- for (s = file_size; s > 0; s /= 10L) barlen--;
- ! (void) sprintf(spec, " 0 %%%ds %%ld bytes.\r", barlen);
- (void) printf(spec, " ", file_size);
- goto zz;
- case pr_dots:
- --- 723,732 ----
- local,
- tcap_normal
- );
- ! barlen = 52;
- for (s = file_size; s > 0; s /= 10L) barlen--;
- ! (void) sprintf(spec, " 0 %%%ds %%ld bytes. ETA: --:--\r",
- ! barlen);
- (void) printf(spec, " ", file_size);
- goto zz;
- case pr_dots:
- ***************
- *** 734,740 ****
- (void) printf("%s: ", local);
- zz:
- (void) fflush(stdout);
- ! echo(stdin, 0);
- } /* end switch */
- return (cur_progress_meter);
- } /* start_progress */
- --- 735,741 ----
- (void) printf("%s: ", local);
- zz:
- (void) fflush(stdout);
- ! Echo(stdin, 0);
- } /* end switch */
- return (cur_progress_meter);
- } /* start_progress */
- ***************
- *** 745,752 ****
- int progress_report(int finish_up)
- {
- int size;
- ! long perc;
- ! str32 spec;
-
- next_report += xferbufsize;
- (void) Gettimeofday(&stop);
- --- 746,757 ----
- int progress_report(int finish_up)
- {
- int size;
- ! int perc;
- ! float frac;
- ! char spec[64];
- ! float secsElap;
- ! int secsLeft, minLeft;
- ! struct timeval td;
-
- next_report += xferbufsize;
- (void) Gettimeofday(&stop);
- ***************
- *** 755,775 ****
- case pr_none:
- break;
- case pr_percent:
- ! perc = 100L * bytes / file_size;
- ! if (perc > 100L) perc = 100L;
- ! (void) printf("\b\b\b\b%3ld%%", perc);
- (void) fflush(stdout);
- break;
- case pr_philbar:
- ! size = (int) ((float)barlen * ((float) (bytes > file_size ?
- ! file_size : bytes)/file_size));
- ! (void) sprintf(spec, "%%3ld%%%% 0 %%s%%%ds%%s\r", size);
- (void) printf(
- spec,
- ! 100L * (bytes > file_size ? file_size : bytes) / file_size,
- tcap_reverse,
- ! " ",
- ! tcap_normal
- );
- (void) fflush(stdout);
- break;
- --- 760,795 ----
- case pr_none:
- break;
- case pr_percent:
- ! perc = (int) (100.0 * (float)bytes / (float)file_size);
- ! if (perc > 100) perc = 100;
- ! (void) printf("\b\b\b\b%3d%%", perc);
- (void) fflush(stdout);
- break;
- case pr_philbar:
- ! frac = (float)bytes / (float)file_size;
- ! if (frac > 1.0)
- ! frac = 1.0;
- ! size = (int) ((float)barlen * frac);
- ! (void) sprintf(spec,
- ! "%%3d%%%% 0 %%s%%%ds%%s%%%ds %%ld bytes. ETA:%%3d:%%02d\r",
- ! size, barlen - size);
- ! perc = (long) (100.0 * frac);
- ! tvsub(&td, &stop, &start);
- ! secsElap = td.tv_sec + (td.tv_usec / 1000000.0);
- ! secsLeft = (int) ((float)file_size / ((float)bytes/secsElap) -
- ! secsElap + 0.5);
- ! minLeft = secsLeft / 60;
- ! secsLeft = secsLeft - (minLeft * 60);
- (void) printf(
- spec,
- ! perc,
- tcap_reverse,
- ! "",
- ! tcap_normal,
- ! "",
- ! file_size,
- ! minLeft,
- ! secsLeft
- );
- (void) fflush(stdout);
- break;
- ***************
- *** 795,867 ****
-
-
-
- void end_progress(char *direction, char *local, char *remote)
- {
- ! struct timeval td;
- ! float s, bs = 0.0;
- ! char *cp, *bsstr;
- ! string str;
-
- ! if (bytes <= 0)
- ! return;
- ! (void) progress_report(1); /* tell progress proc to cleanup. */
-
- ! tvsub(&td, &stop, &start);
- ! s = td.tv_sec + (td.tv_usec / 1000000.0);
- ! if (s != 0.0)
- ! bs = bytes / s;
- ! if (bs > 1024.0) {
- ! bs /= 1024.0;
- ! bsstr = "K/s.\n";
- ! } else
- ! bsstr = "Bytes/s.\n";
-
- ! if (NOT_VQUIET) switch(cur_progress_meter) {
- ! case pr_none:
- ! zz:
- ! (void) printf("%s: %ld bytes %s in %.2f seconds, %.2f %s", local, bytes, direction, s, bs, bsstr);
- break;
- ! case pr_kbytes:
- ! case pr_percent:
- ! (void) printf("%s%ld bytes %s in %.2f seconds, %.2f %s",
- ! cur_progress_meter == pr_kbytes ? "\b\b\b\b\b\b" : "\b\b\b\b",
- ! bytes, direction, s, bs, bsstr);
- ! echo(stdin, 1);
- break;
- ! case pr_philbar:
- ! (void) printf("\n");
- ! echo(stdin, 1);
- ! goto zz;
- ! case pr_dots:
- ! for (; dots < 10; dots++)
- ! (void) fputc('.', stdout);
- ! (void) fputc('\n', stdout);
- ! echo(stdin, 1);
- ! goto zz;
- }
- !
- ! /* Save transfers to the logfile. */
- ! /* if a simple path is given, try to log the full path */
- ! if (rindex(remote, '/') == NULL && cwd != NULL) {
- ! (void) sprintf(str, "%s/%s", cwd, remote);
- ! cp = str;
- ! } else
- ! cp = remote;
- if (logf != NULL) {
- ! (void) fprintf(logf, "\t-> \"%s\" %s, %.2f %s", cp, direction, bs, bsstr);
- ! }
- #ifdef SYSLOG
- ! if (direction[0] == 'r')
- ! syslog (LOG_INFO, "%s received %s as %s from %s (%ld bytes).",
- ! uinfo.username, cp, local, hostname, bytes);
- ! else
- ! syslog (LOG_INFO, "%s sent %s as %s to %s (%ld bytes).",
- ! uinfo.username, local, cp, hostname, bytes);
- ! #endif
- ! } /* end_progress */
-
-
-
- void close_file(FILE **fin, int filetype)
- {
- if (*fin != NULL) {
- --- 815,934 ----
-
-
-
- +
- void end_progress(char *direction, char *local, char *remote)
- {
- ! struct timeval td;
- ! float s, bs = 0.0;
- ! str32 bsstr;
- ! int doLastReport;
- ! int receiving;
- ! longstring fullRemote, fullLocal;
-
- ! doLastReport = ((UserLoggedIn()) && (cur_progress_meter != pr_none) &&
- ! (NOT_VQUIET) && (bytes > 0));
-
- ! receiving = (direction[0] == 'r');
-
- ! switch(FileType(local)) {
- ! case IS_FILE:
- ! (void) Strncpy(fullLocal, lcwd);
- ! (void) Strncat(fullLocal, "/");
- ! (void) Strncat(fullLocal, local);
- break;
- ! case IS_PIPE:
- ! doLastReport = 0;
- ! local = Strncpy(fullLocal, local);
- break;
- ! case IS_STREAM:
- ! default:
- ! doLastReport = 0;
- ! local = Strncpy(fullLocal, receiving ? "stdout" : "stdin");
- }
- !
- ! if (doLastReport)
- ! (void) progress_report(1); /* tell progress proc to cleanup. */
- !
- ! tvsub(&td, &stop, &start);
- ! s = td.tv_sec + (td.tv_usec / 1000000.0);
- !
- ! bsstr[0] = '\0';
- ! if (s != 0.0) {
- ! bs = (float)bytes / s;
- ! if (bs > 1024.0)
- ! sprintf(bsstr, "%.2f K/s", bs / 1024.0);
- ! else
- ! sprintf(bsstr, "%.2f Bytes/sec", bs / 1024.0);
- ! }
- !
- ! if (doLastReport) switch(cur_progress_meter) {
- ! case pr_none:
- ! zz:
- ! (void) printf("%s: %ld bytes %s in %.2f seconds, %s.\n",
- ! local, bytes, direction, s, bsstr);
- ! break;
- ! case pr_kbytes:
- ! case pr_percent:
- ! (void) printf("%s%ld bytes %s in %.2f seconds, %s.\n",
- ! cur_progress_meter == pr_kbytes ? "\b\b\b\b\b\b" : "\b\b\b\b",
- ! bytes, direction, s, bsstr);
- ! Echo(stdin, 1);
- ! break;
- ! case pr_philbar:
- ! (void) printf("\n");
- ! Echo(stdin, 1);
- ! goto zz;
- ! case pr_dots:
- ! for (; dots < 10; dots++)
- ! (void) fputc('.', stdout);
- ! (void) fputc('\n', stdout);
- ! Echo(stdin, 1);
- ! goto zz;
- ! }
- !
- ! /* Save transfers to the logfile. */
- ! /* if a simple path is given, try to log the full path */
- ! if (*remote != '/') {
- ! (void) Strncpy(fullRemote, cwd);
- ! (void) Strncat(fullRemote, "/");
- ! (void) Strncat(fullRemote, remote);
- ! } else
- ! (void) Strncpy(fullRemote, remote);
- !
- if (logf != NULL) {
- ! (void) fprintf(logf, "\t-> \"%s\" %s, %s\n",
- ! fullRemote, direction, bsstr);
- ! }
- #ifdef SYSLOG
- ! {
- ! longstring infoPart1;
-
- + /* Some syslog()'s can't take an unlimited number of arguments,
- + * so shorten our call to syslog to 5 arguments total.
- + */
- + Strncpy(infoPart1, uinfo.username);
- + if (receiving) {
- + Strncat(infoPart1, " received ");
- + Strncpy(infoPart1, fullRemote);
- + Strncat(infoPart1, " as ");
- + Strncat(infoPart1, fullLocal);
- + Strncat(infoPart1, " from ");
- + } else {
- + Strncat(infoPart1, " sent ");
- + Strncat(infoPart1, fullLocal);
- + Strncat(infoPart1, " as ");
- + Strncat(infoPart1, fullRemote);
- + Strncat(infoPart1, " to ");
- + }
- + Strncat(infoPart1, hostname);
- + syslog (LOG_INFO, "%s (%ld bytes, %s).", infoPart1, bytes, bsstr);
- + }
- + #endif /* SYSLOG */
- + } /* end_progress */
-
-
- +
- +
- void close_file(FILE **fin, int filetype)
- {
- if (*fin != NULL) {
- ***************
- *** 884,890 ****
- activemcmd = 0;
- abrtflag = 0;
- (void) fprintf(stderr, "\nSend aborted.\n");
- ! echo(stdin, 1);
- longjmp(sendabort, 1);
- } /* abortsend */
-
- --- 951,957 ----
- activemcmd = 0;
- abrtflag = 0;
- (void) fprintf(stderr, "\nSend aborted.\n");
- ! Echo(stdin, 1);
- longjmp(sendabort, 1);
- } /* abortsend */
-
- ***************
- *** 902,908 ****
- char *mode;
- register char *bufp;
-
- ! dbprintf("cmd: %s; rmt: %s; loc: %s.\n", cmd, remote, local);
- oldintr = NULL;
- oldintp = NULL;
- mode = "w";
- --- 969,980 ----
- char *mode;
- register char *bufp;
-
- ! dbprintf("cmd: %s; rmt: %s; loc: %s.\n",
- ! cmd,
- ! remote == NULL ? "(null)" : remote,
- ! local == NULL ? "(null)" : local
- ! );
- !
- oldintr = NULL;
- oldintp = NULL;
- mode = "w";
- ***************
- *** 1075,1082 ****
- (void) Signal(SIGINT, oldintr);
- if (oldintp)
- (void) Signal(SIGPIPE, oldintp);
- ! if (do_reports)
- ! end_progress("sent", local, remote);
- xx:
- return (result);
- Abort:
- --- 1147,1153 ----
- (void) Signal(SIGINT, oldintr);
- if (oldintp)
- (void) Signal(SIGPIPE, oldintp);
- ! end_progress("sent", local, remote);
- xx:
- return (result);
- Abort:
- ***************
- *** 1105,1111 ****
- "\nAborting, please wait...");
- #endif
- (void) fflush(stderr);
- ! echo(stdin, 1);
- longjmp(recvabort, 1);
- } /* abortrecv */
-
- --- 1176,1182 ----
- "\nAborting, please wait...");
- #endif
- (void) fflush(stderr);
- ! Echo(stdin, 1);
- longjmp(recvabort, 1);
- } /* abortrecv */
-
- ***************
- *** 1141,1146 ****
- --- 1212,1221 ----
- int AdjustLocalFileName(char *local)
- {
- char *dir;
- +
- + /* See if the file exists, and if we can overwrite it. */
- + if ((access(local, 0) == 0) && (access(local, 2) < 0))
- + goto noaccess;
-
- /*
- * Make sure we are writing to a valid local path.
- ***************
- *** 1473,1479 ****
- {
- FILE *fout = NULL, *din = NULL;
- Sig_t oldintr = NULL, oldintp = NULL;
- ! int oldtype = 0, is_retr;
- int nfnd;
- char msg;
- struct fd_set mask;
- --- 1548,1554 ----
- {
- FILE *fout = NULL, *din = NULL;
- Sig_t oldintr = NULL, oldintp = NULL;
- ! int oldtype = -1, is_retr;
- int nfnd;
- char msg;
- struct fd_set mask;
- ***************
- *** 1483,1489 ****
- int result = -1;
-
- dbprintf("---> cmd: %s; rmt: %s; loc: %s; mode: %s.\n",
- ! cmd, remote, local, mode);
- is_retr = strcmp(cmd, "RETR") == 0;
-
- GetLSRemoteDir(remote, remote_dir);
- --- 1558,1569 ----
- int result = -1;
-
- dbprintf("---> cmd: %s; rmt: %s; loc: %s; mode: %s.\n",
- ! cmd,
- ! remote == NULL ? "(null)" : remote,
- ! local == NULL ? "(null)" : local,
- ! mode
- ! );
- !
- is_retr = strcmp(cmd, "RETR") == 0;
-
- GetLSRemoteDir(remote, remote_dir);
- ***************
- *** 1595,1601 ****
- dbprintf("outfile closed.\n");
- if (din)
- (void) fclose(din);
- ! if (do_reports)
- end_progress("received", local, remote);
- if (oldintr)
- (void) Signal(SIGINT, oldintr);
- --- 1675,1681 ----
- dbprintf("outfile closed.\n");
- if (din)
- (void) fclose(din);
- ! if (is_retr)
- end_progress("received", local, remote);
- if (oldintr)
- (void) Signal(SIGINT, oldintr);
- ***************
- *** 1602,1608 ****
- if (oldintp)
- (void) Signal(SIGPIPE, oldintp);
- dbprintf("recvrequest result = %d.\n", result);
- ! ResetOldType(oldtype);
- return (result);
- } /* recvrequest */
-
- --- 1682,1689 ----
- if (oldintp)
- (void) Signal(SIGPIPE, oldintp);
- dbprintf("recvrequest result = %d.\n", result);
- ! if (oldtype >= 0)
- ! ResetOldType(oldtype);
- return (result);
- } /* recvrequest */
-
- ***************
- *** 1617,1666 ****
-
- #ifdef TERM_FTP
-
- /*
- ! * Need to request that the server go into passive mode and
- ! * then get the address and port for the term server to connect to.
- */
- int initconn(void)
- {
- ! int result;
- ! int n[6];
- ! int s;
-
- ! if (data != -1)
- ! (void) close(data);
- ! result = command("PASV");
- ! if (result == COMPLETE) {
- ! if (sscanf(reply_string, "%*[^(](%d,%d,%d,%d,%d,%d)",
- ! &n[0], &n[1], &n[2], &n[3], &n[4], &n[5]) != 6) {
- ! fprintf(stderr, "Cannot parse PASV response: %s\n",
- ! reply_string);
- ! return 1;
- ! }
- ! close(data);
- ! lcompression = rcompression = compress_toggle;
- ! if ((s = connect_server(0)) < 0) {
- ! perror("ftp: connect to term server");
- ! data = -1;
- ! return 1;
- ! }
- ! data = s;
- ! send_command(s, C_PORT, 0, "%d.%d.%d.%d:%d",
- ! n[0], n[1], n[2], n[3], 256*n[4] + n[5]);
- ! send_command(s, C_COMPRESS, 1, "n");
- ! send_command(s, C_DUMB, 1, 0);
- ! return 0;
- ! }
- ! return 1;
- ! }
-
- ! FILE *
- ! dataconn(lmode)
- ! char *lmode;
- {
- ! return (fdopen(data, lmode));
- ! }
- ! #else /* TERM_FTP */
-
-
- int initconn(void)
- --- 1698,1749 ----
-
- #ifdef TERM_FTP
-
- +
- /*
- ! * Need to request that the server go into passive mode and then get the
- ! * address and port for the term server to connect to.
- */
- int initconn(void)
- {
- ! int result;
- ! int n[6];
- ! int s;
-
- ! if (data != -1)
- ! (void) close(data);
- ! result = command("PASV");
- ! if (result == COMPLETE) {
- ! if (sscanf(reply_string, "%*[^(](%d,%d,%d,%d,%d,%d)",
- ! &n[0], &n[1], &n[2], &n[3], &n[4], &n[5]) != 6) {
- ! printf("Cannot parse PASV response: %s\n",
- ! reply_string);
- ! return 1;
- ! }
- ! close(data);
- ! lcompression = rcompression = compress_toggle;
- ! if ((s = connect_server(0)) < 0) {
- ! perror("ftp: connect to term server");
- ! data = -1;
- ! return 1;
- ! }
- ! data = s;
- ! send_command(s, C_PORT, 0, "%d.%d.%d.%d:%d",
- ! n[0], n[1], n[2], n[3], 256 * n[4] + n[5]);
- ! send_command(s, C_COMPRESS, 1, "n");
- ! send_command(s, C_DUMB, 1, 0);
- ! return 0;
- ! }
- ! return 1;
- ! } /* initconn_term */
-
- !
- !
- !
- ! FILE *dataconn(char *lmode)
- {
- ! return (fdopen(data, lmode));
- ! } /* dataconn_term */
- ! #else /* not TERM_FTP */
-
-
- int initconn(void)
- diff -c ./ftprc.c ../ncftp170/ftprc.c
- *** ./ftprc.c Wed Mar 16 18:24:53 1994
- --- ../ncftp170/ftprc.c Wed Mar 16 19:16:02 1994
- ***************
- *** 155,164 ****
- static siteptr FindNetrcSite(char *host)
- {
- register siteptr s, s2;
-
- /* see if 'host' is in our list of favorite sites (in NETRC). */
- for (s = firstsite; s != NULL; s2=s->next, s=s2) {
- ! if (strstr(s->name, host) != NULL) {
- return s;
- }
- }
- --- 155,170 ----
- static siteptr FindNetrcSite(char *host)
- {
- register siteptr s, s2;
- + string str, host2;
-
- + (void) Strncpy(host2, host);
- + StrLCase(host2);
- +
- /* see if 'host' is in our list of favorite sites (in NETRC). */
- for (s = firstsite; s != NULL; s2=s->next, s=s2) {
- ! (void) Strncpy(str, s->name);
- ! StrLCase(str);
- ! if (strstr(str, host2) != NULL) {
- return s;
- }
- }
- ***************
- *** 172,182 ****
- {
- register recentsite *r;
- register int i;
-
- /* see if 'host' is in our list of favorite sites (in recent-log). */
- for (i=0; i<nRecents; i++) {
- r = &recents[i];
- ! if (strstr(r->name, host) != NULL) {
- return r;
- }
- }
- --- 178,194 ----
- {
- register recentsite *r;
- register int i;
- + string str, host2;
-
- + (void) Strncpy(host2, host);
- + StrLCase(host2);
- +
- /* see if 'host' is in our list of favorite sites (in recent-log). */
- for (i=0; i<nRecents; i++) {
- r = &recents[i];
- ! (void) Strncpy(str, r->name);
- ! StrLCase(str);
- ! if (strstr(str, host2) != NULL) {
- return r;
- }
- }
- ***************
- *** 203,208 ****
- --- 215,222 ----
- if (FGets(str, rfp) == NULL)
- break;
- (void) RemoveTrailingNewline(str, NULL);
- + name[0] = 0;
- + offset = 45;
- if (sscanf(str, "%s %lu %n",
- name,
- (unsigned long *) &r->lastcall,
- ***************
- *** 212,218 ****
- r->dir = NewString(str + offset);
- if (r->dir != NULL)
- nRecents++;
- ! else free(r->name);
- }
- }
- }
- --- 226,235 ----
- r->dir = NewString(str + offset);
- if (r->dir != NULL)
- nRecents++;
- ! else {
- ! free(r->name);
- ! r->name = r->dir = NULL;
- ! }
- }
- }
- }
- ***************
- *** 474,480 ****
- cp++;
- } else
- continue;
- - /* if (strstr(cp, host) != NULL) { */
- if (strncmp(host, cp, strlen(host)) == 0) {
- site_found = 1;
- while (!isspace(*cp))
- --- 491,496 ----
- diff -c ./getpass.c ../ncftp170/getpass.c
- *** ./getpass.c Wed Mar 16 18:24:58 1994
- --- ../ncftp170/getpass.c Wed Mar 16 19:16:02 1994
- ***************
- *** 39,45 ****
-
-
-
- ! void echo(FILE *fp, int on)
- {
- #ifndef GETPASS /* Otherwise just do nothing which is ok. */
-
- --- 39,45 ----
-
-
-
- ! void Echo(FILE *fp, int on)
- {
- #ifndef GETPASS /* Otherwise just do nothing which is ok. */
-
- ***************
- *** 91,97 ****
- }
- if (tp != NULL) {
- #ifdef TERMIOS
- ! if (tcsetattr(fd, TCSAFLUSH, tp) < 0)
- PERROR("echo", "tcsetattr");
- #else
- # ifdef SGTTYB
- --- 91,97 ----
- }
- if (tp != NULL) {
- #ifdef TERMIOS
- ! if (tcsetattr(fd, TCSANOW, tp) < 0)
- PERROR("echo", "tcsetattr");
- #else
- # ifdef SGTTYB
- ***************
- *** 105,111 ****
- }
-
- #endif /* GETPASS */
- ! } /* echo */
-
-
-
- --- 105,111 ----
- }
-
- #endif /* GETPASS */
- ! } /* Echo */
-
-
-
- ***************
- *** 136,142 ****
- outfp = stderr;
- #endif
- oldintr = Signal(SIGINT, SIG_IGN);
- ! echo(fp, 0); /* Turn echoing off. */
- (void) fputs(promptstr, outfp);
- (void) rewind(outfp); /* implied flush */
- for (p = buf; (ch = getc(fp)) != EOF && ch != '\n';)
- --- 136,142 ----
- outfp = stderr;
- #endif
- oldintr = Signal(SIGINT, SIG_IGN);
- ! Echo(fp, 0); /* Turn echoing off. */
- (void) fputs(promptstr, outfp);
- (void) rewind(outfp); /* implied flush */
- for (p = buf; (ch = getc(fp)) != EOF && ch != '\n';)
- ***************
- *** 144,150 ****
- *p++ = ch;
- *p = '\0';
- (void)write(fileno(outfp), "\n", 1);
- ! echo(fp, 1);
- (void) Signal(SIGINT, oldintr);
- if (fp != stdin)
- (void)fclose(fp);
- --- 144,150 ----
- *p++ = ch;
- *p = '\0';
- (void)write(fileno(outfp), "\n", 1);
- ! Echo(fp, 1);
- (void) Signal(SIGINT, oldintr);
- if (fp != stdin)
- (void)fclose(fp);
- diff -c ./getpass.h ../ncftp170/getpass.h
- *** ./getpass.h Wed Mar 16 18:24:51 1994
- --- ../ncftp170/getpass.h Wed Mar 16 19:16:03 1994
- ***************
- *** 10,17 ****
-
- #define kMaxPassLen 127
-
- char *Getpass(char *prompt);
- ! void echo(FILE *fp, int on);
-
- #endif /* _getpass_h_ */
-
- --- 10,22 ----
-
- #define kMaxPassLen 127
-
- + #ifdef GETPASS
- + extern char *getpass(); /* Use the system supplied getpass. */
- + #else
- char *Getpass(char *prompt);
- ! #endif
- !
- ! void Echo(FILE *fp, int on);
-
- #endif /* _getpass_h_ */
-
- diff -c ./main.c ../ncftp170/main.c
- *** ./main.c Wed Mar 16 18:24:54 1994
- --- ../ncftp170/main.c Wed Mar 16 19:16:02 1994
- ***************
- *** 7,13 ****
-
- #define _main_c_
-
- ! #define FTP_VERSION "1.6.0 (October 31, 1993)"
-
- /* #define BETA 1 */ /* If defined, it prints a little warning message. */
-
- --- 7,13 ----
-
- #define _main_c_
-
- ! #define FTP_VERSION "1.7.0 (St. Patrick's Day, 1994)"
-
- /* #define BETA 1 */ /* If defined, it prints a little warning message. */
-
- ***************
- *** 404,414 ****
- extern char *home; /* for glob.c */
-
- home = uinfo.homedir; /* for glob.c */
- ! pw = getpwuid(uinfo.uid = getuid());
- if (pw != NULL) {
- (void) Strncpy(uinfo.username, pw->pw_name);
- (void) Strncpy(uinfo.shell, pw->pw_shell);
- ! (void) Strncpy(uinfo.homedir, pw->pw_dir);
- cp = getenv("MAIL");
- if (cp == NULL)
- cp = getenv("mail");
- --- 404,430 ----
- extern char *home; /* for glob.c */
-
- home = uinfo.homedir; /* for glob.c */
- ! pw = NULL;
- ! #ifdef USE_GETPWUID
- ! pw = getpwuid(getuid());
- ! #else
- ! cp = getlogin();
- ! if (cp == NULL) {
- ! cp = getenv("LOGNAME");
- ! if (cp == NULL)
- ! cp = getenv("USER");
- ! }
- ! if (cp != NULL)
- ! pw = getpwnam(cp);
- ! #endif
- if (pw != NULL) {
- + uinfo.uid = pw->pw_uid;
- (void) Strncpy(uinfo.username, pw->pw_name);
- (void) Strncpy(uinfo.shell, pw->pw_shell);
- ! if ((cp = getenv("HOME")) != NULL)
- ! (void) Strncpy(uinfo.homedir, cp);
- ! else
- ! (void) Strncpy(uinfo.homedir, pw->pw_dir);
- cp = getenv("MAIL");
- if (cp == NULL)
- cp = getenv("mail");
- ***************
- *** 432,437 ****
- --- 448,454 ----
- PERROR("getuserinfo", "Could not get your passwd entry!");
- (void) Strncpy(uinfo.shell, "/bin/sh");
- (void) Strncpy(uinfo.homedir, "."); /* current directory */
- + uinfo.uid = 999;
- if ((cp = getenv("HOME")) != NULL)
- (void) Strncpy(uinfo.homedir, cp);
- mail_path[0] = 0;
- diff -c ./ncftp.1 ../ncftp170/ncftp.1
- *** ./ncftp.1 Wed Mar 16 18:24:52 1994
- --- ../ncftp170/ncftp.1 Wed Mar 16 19:16:03 1994
- ***************
- *** 181,187 ****
- o w
- .De
- .PP
- ! might match a site named bowser.nintendo.jp if that site appeared before
- your entry for wuarchive.wustl.edu.
- .PP
- Most of the time we open remote sites anonymously, but
- --- 181,187 ----
- o w
- .De
- .PP
- ! might match a site named bowser.nintendo.co.jp if that site appeared before
- your entry for wuarchive.wustl.edu.
- .PP
- Most of the time we open remote sites anonymously, but
- ***************
- *** 1375,1381 ****
- Termcap padding is not correctly displayed.
- .PP
- There are no such sites named
- ! .I bowser.nintendo.jp
- or
- .IR sphygmomanometer.unl.edu .
- .\"-------
- --- 1375,1381 ----
- Termcap padding is not correctly displayed.
- .PP
- There are no such sites named
- ! .I bowser.nintendo.co.jp
- or
- .IR sphygmomanometer.unl.edu .
- .\"-------
- diff -c ./open.c ../ncftp170/open.c
- *** ./open.c Wed Mar 16 18:24:53 1994
- --- ../ncftp170/open.c Wed Mar 16 19:16:02 1994
- ***************
- *** 30,35 ****
- --- 30,36 ----
- int connected = 0; /* TRUE if connected to server */
- /* If TRUE, set binary each connection. */
- Hostname hostname; /* Name of current host */
- + RemoteSiteInfo gRmtInfo;
- #ifdef GATEWAY
- string gateway; /* node name of firewall gateway */
- string gate_login; /* login at firewall gateway */
- ***************
- *** 106,113 ****
-
- int GetOpenOptions(int argc, char **argv, OpenOptions *openopt)
- {
- ! int opt;
- ! char *cp;
-
- /* First setup the openopt variables. */
- InitOpenOptions(openopt);
- --- 107,114 ----
-
- int GetOpenOptions(int argc, char **argv, OpenOptions *openopt)
- {
- ! int opt, www;
- ! char *cp, *hostp, *cpath;
-
- /* First setup the openopt variables. */
- InitOpenOptions(openopt);
- ***************
- *** 180,186 ****
- Try 'ncftp -m wuarchive.wustl.edu:/README'\n");
- goto usage;
- }
- ! break;
-
- case 'c':
- /* ftpcat mode is only available from your shell command-line,
- --- 181,187 ----
- Try 'ncftp -m wuarchive.wustl.edu:/README'\n");
- goto usage;
- }
- ! /* break; */
-
- case 'c':
- /* ftpcat mode is only available from your shell command-line,
- ***************
- *** 198,204 ****
- Try 'ncftp -c wuarchive.wustl.edu:/README > file.'\n");
- goto usage;
- }
- ! break;
-
- default:
- usage:
- --- 199,205 ----
- Try 'ncftp -c wuarchive.wustl.edu:/README > file.'\n");
- goto usage;
- }
- ! /* break; */
-
- default:
- usage:
- ***************
- *** 221,233 ****
- /* The user gave us a host to open.
- *
- * First, check to see if they gave us a colon-mode path
- ! * along with the hostname.
- */
- ! if ((cp = index(argv[Optind], ':')) != NULL) {
- ! *cp++ = 0;
- ! (void) Strncpy(openopt->colonmodepath, cp);
- }
- ! (void) Strncpy(openopt->hostname, argv[Optind]);
- }
- return NOERR;
- } /* GetOpenOptions */
- --- 222,267 ----
- /* The user gave us a host to open.
- *
- * First, check to see if they gave us a colon-mode path
- ! * along with the hostname. We also understand a WWW path,
- ! * like "ftp://bang.nta.no/pub/fm2html.v.0.8.4.tar.Z".
- */
- ! hostp = argv[Optind];
- ! cpath = NULL;
- ! if ((cp = index(hostp, ':')) != NULL) {
- ! *cp++ = '\0';
- ! cpath = cp;
- ! www = 0; /* Is 0 or 1, depending on the type of path. */
- ! if ((*cp == '/') && (cp[1] == '/')) {
- ! /* First make sure the path was intended to be used
- ! * with ftp and not one of the other URLs.
- ! */
- ! if (strcmp(argv[Optind], "ftp")) {
- ! fprintf(
- ! stderr,
- ! "Bad URL '%s' -- WWW paths must be prefixed by 'ftp://'.\n",
- ! argv[Optind]
- ! );
- ! goto usage;
- ! }
- !
- ! cp += 2;
- ! hostp = cp;
- ! cpath = NULL; /* It could have been ftp://hostname only. */
- !
- ! if ((cp = index(hostp, '/')) != NULL) {
- ! *cp++ = '\0';
- ! cpath = cp;
- ! }
- ! www = 1;
- ! }
- ! if (cpath != NULL) {
- ! (void) Strncpy(openopt->colonmodepath, www ? "/" : "");
- ! (void) Strncat(openopt->colonmodepath, cpath);
- ! dbprintf("Colon-Mode Path = '%s'\n", openopt->colonmodepath);
- ! }
- }
- ! (void) Strncpy(openopt->hostname, hostp);
- ! dbprintf("Host = '%s'\n", hostp);
- }
- return NOERR;
- } /* GetOpenOptions */
- ***************
- *** 586,591 ****
- --- 620,631 ----
- (void) printf("Closing %s...\n", hostname);
- (void) disconnect(0, NULL);
- }
- +
- + /* Reset the remote info structure for the new site we want to open.
- + * Assume we have these properties until we discover otherwise.
- + */
- + gRmtInfo.hasSIZE = 1;
- + gRmtInfo.hasMDTM = 1;
-
- if ((GetOpenOptions(argc, argv, &openopt) == USAGE) ||
- (Open(&openopt) == USAGE))
- diff -c ./open.h ../ncftp170/open.h
- *** ./open.h Wed Mar 16 18:25:04 1994
- --- ../ncftp170/open.h Wed Mar 16 19:16:03 1994
- ***************
- *** 16,21 ****
- --- 16,26 ----
- longstring colonmodepath;
- } OpenOptions;
-
- + typedef struct RemoteSiteInfo {
- + int hasSIZE;
- + int hasMDTM;
- + } RemoteSiteInfo;
- +
- /* Open modes. */
- #define openImplicitAnon 1
- #define openImplicitUser 4
- diff -c ./patchlevel.h ../ncftp170/patchlevel.h
- *** ./patchlevel.h Wed Mar 16 18:24:55 1994
- --- ../ncftp170/patchlevel.h Wed Mar 16 19:16:03 1994
- ***************
- *** 178,181 ****
- --- 178,225 ----
- * since it wasn't always stripping \n's. Recent file can now read dir
- * names with whitespace. Opening msg uses a larger buffer, because of
- * escape codes. Philbar now prints K/sec stats.
- + *
- + * v1.6.1 - November 5, 1993.
- + * Checking if we have permission to write over a file to fetch.
- + * A few very minor changes. BSD no longer trying to use strchr :-)
- + *
- + * v1.6.2 - December 10, 1993.
- + * Term hack no longer depends on the PASV command (!). The BROKEN_MEMCPY
- + * problem worked-around. More wary of symbolic-link recursion.
- + * Fixed local path expander. Fixed inadvertant flushing of the typeahead
- + * buffer. Debug mode won't print your password. Progress meters
- + * no longer goof up when the file is huge. Added time-remaining to the
- + * Philbar.
- + *
- + * v1.6.3 - December 28, 1993. Added a new diagnostic command, memchk,
- + * to print stats from a special malloc library if you used one.
- + * Using SIZE and MDTM when the remote site supports it. Using a new
- + * set of routines for term (again).
- + *
- + * v1.6.4 - December 30, 1993. Fixed rare problem with GetDateAndTime.
- + * confirm() will return true if you're running the init macro.
- + *
- + * v1.6.5 - January 6, 1994. Fixed error with an #ifndef/#endif block having
- + * whitespace before the #. No longer confirming "ls >file" actions.
- + * Changed echo() to Echo(). AIX 3 uses TERMIOS.
- + *
- + * v1.6.6 - February 15, 1994. Prevented scenario of fclosing a NULL FILE *.
- + * Edited term ftp's hookup() a little. More defs for linux in sys.h.
- + * Not updating a recent entry unless you were fully logged in.
- + *
- + * v1.6.7 - February 20, 1994. Using getpwnam() instead of getpwuid().
- + * Supporting WWW paths (i.e. ftp://host.name/path/name).
- + *
- + * v1.6.8 - March 4, 1994. Ensuring that tmp files are not public.
- + * Trying harder to get the real hostname, and fixed problem with
- + * disappearing progress meters (both due to T. Lindgren).
- + *
- + * v1.6.9 - March 11, 1994. Added DOMAIN_NAME and Solaris CPP symbols.
- + * Better handling of getting the domain name, specifically with SunOS.
- + * BSDi support added.
- + *
- + * v1.7.0 - March 14, 1994. More verbose when logging to the system log,
- + * and making sure that syslog() itself is called with a total of 5
- + * or less parameters. Official patch posted which incorporates all
- + * the fixes to 1.6.0 (i.e. 1.6.1, 1.6.2, ... 1.6.9).
- */
- diff -c ./sys.h ../ncftp170/sys.h
- *** ./sys.h Wed Mar 16 18:24:59 1994
- --- ../ncftp170/sys.h Wed Mar 16 19:16:03 1994
- ***************
- *** 32,41 ****
- # if !defined(__GNUC__) && !defined(__STDC__) && !defined(SunOverride)
- ^^^ "You need to use an ANSI C compiler. Try using gcc or acc." ^^^
- # endif
- ! # define System "SunOS"
- ! # ifndef RINDEX
- ! # define RINDEX 1
- ! # endif
- # ifndef TERMIOS
- # define TERMIOS 1
- # endif
- --- 32,46 ----
- # if !defined(__GNUC__) && !defined(__STDC__) && !defined(SunOverride)
- ^^^ "You need to use an ANSI C compiler. Try using gcc or acc." ^^^
- # endif
- ! # ifdef Solaris /* not predefined. */
- ! # define SYSV 1
- ! # define System "Solaris"
- ! # else
- ! # define System "SunOS"
- ! # ifndef RINDEX
- ! # define RINDEX 1
- ! # endif
- ! # endif /* not Solaris */
- # ifndef TERMIOS
- # define TERMIOS 1
- # endif
- ***************
- *** 83,88 ****
- --- 88,94 ----
- #ifdef _AIX
- # define System "AIX 3.x"
- # define SYSSELECTH 1
- + # define TERMIOS 1
- #endif /* _AIX */
-
- #ifdef SCOXNX
- ***************
- *** 117,123 ****
-
- #ifdef linux
- # define System "Linux"
- ! /* Anyone want to fill the rest in? */
- #endif
-
- #ifdef ISC
- --- 123,140 ----
-
- #ifdef linux
- # define System "Linux"
- ! # ifndef HAS_DOMAINNAME
- ! # define HAS_DOMAINNAME 1
- ! # endif
- ! # ifndef TERMIOS
- ! # define TERMIOS 1
- ! # endif
- ! # ifndef TERMH
- ! # define TERMH 1
- ! # endif
- ! # ifndef SYSV
- ! # define SYSV 1
- ! # endif
- #endif
-
- #ifdef ISC
- ***************
- *** 173,179 ****
- extern int errno;
- #endif /* pyr */
-
- ! #ifdef DYNIXPTX
- # define System "Dynix/PTX"
- # ifndef SYSV
- # define SYSV 1
- --- 190,202 ----
- extern int errno;
- #endif /* pyr */
-
- ! #ifdef _SEQUENT_
- ! # if !defined(DYNIXPTX) && !defined(DYNIX)
- ! # define DYNIXPTX 1
- ! # endif
- ! #endif
- !
- ! #if DYNIXPTX
- # define System "Dynix/PTX"
- # ifndef SYSV
- # define SYSV 1
- ***************
- *** 321,331 ****
- # endif
- #endif
-
- ! #ifdef __386BSD__
- ! # define TERMIOS
- # ifndef BSD
- ! # define BSD
- # endif
- #endif
-
- #ifdef BSD
- --- 344,368 ----
- # endif
- #endif
-
- ! #ifdef __bsdi__
- ! # define System "BSDi"
- # ifndef BSD
- ! # define BSD 1
- # endif
- + # ifndef SYSSELECTH
- + # define SYSSELECTH 1
- + # endif
- + # ifndef GETCWDSIZET
- + # define GETCWDSIZET 1
- + # endif
- + # ifndef HERROR
- + # define HERROR 1
- + # endif
- + #endif /* BSDi */
- +
- + #ifdef __386BSD__
- + # define TERMIOS 1
- + # define NO_CONST 1 /* avoid prototype conflict */
- #endif
-
- #ifdef BSD
- ***************
- *** 340,348 ****
- # ifndef SGTTYB
- # define SGTTYB
- # endif
- - # ifndef RINDEX
- - # define RINDEX 1
- - # endif
- #endif
-
- /*
- --- 377,382 ----
- ***************
- *** 507,511 ****
- --- 541,560 ----
- extern int shutdown(int, int);
- extern int socket(int, int, int);
- #endif /* NO_STD_PROTOS */
- +
- + /* This malloc stuff is mostly for our own use. */
- + #define LIBC_MALLOC 0
- + #define FAST_MALLOC 1
- + #define DEBUG_MALLOC 2
- +
- + #ifdef LIBMALLOC
- + # if LIBMALLOC != LIBC_MALLOC
- + /* Make sure you use -I to use the malloc.h of choice. */
- + # include <malloc.h>
- + # endif
- + #else
- + # define LIBMALLOC LIBC_MALLOC
- + #endif
- + /* End of personal malloc junk. */
-
- /* eof sys.h */
- diff -c ./tips.c ../ncftp170/tips.c
- *** ./tips.c Wed Mar 16 18:25:00 1994
- --- ../ncftp170/tips.c Wed Mar 16 19:16:02 1994
- ***************
- *** 76,83 ****
-
- "This program is pronounced Nik-F-T-P. NCEMRSoft is Nik'-mer-soft.",
-
- - "Never pick Nebraska to win a big game.",
- -
- #ifdef GETLINE
- "NcFTP was compiled with the Getline command-line/history editor! (by\n\
- Chris Thewalt <thewalt@ce.berkeley.edu>). To activate it, use the up\n\
- --- 76,81 ----
- ***************
- *** 92,98 ****
- #endif
-
- "You can get the newest version of NcFTP from cse.unl.edu, in the\n\
- ! /pub/mgleason directory.",
-
- "The type of progress-meter that will be used depends if the remote host\n\
- supports the SIZE command, and whether your terminal is capable of ANSI\n\
- --- 90,96 ----
- #endif
-
- "You can get the newest version of NcFTP from cse.unl.edu, in the\n\
- ! /pub/mgleason/ncftp directory, AFTER business hours.",
-
- "The type of progress-meter that will be used depends if the remote host\n\
- supports the SIZE command, and whether your terminal is capable of ANSI\n\
- ***************
- *** 105,110 ****
- --- 103,112 ----
- "Don't put a site in your .ncftprc unless you want an 'init' macro. The \n\
- recent-file saves sites with the last directory you were in, unlike \n\
- the rc file, while still letting you use sitename abbreviations.",
- +
- + "You can use World Wide Web style paths instead of colon-mode paths.\n\
- + For example, if the colon-mode path was 'cse.unl.edu:pub/mgleason/ncftp,'\n\
- + the WWW-style path would be 'ftp://cse.unl.edu/pub/mgleason/ncftp.'",
-
- "Sick and tired of these tips? Put '#unset tips' in your .ncftprc."
- };
- diff -c ./util.c ../ncftp170/util.c
- *** ./util.c Wed Mar 16 18:24:50 1994
- --- ../ncftp170/util.c Wed Mar 16 19:16:02 1994
- ***************
- *** 40,46 ****
-
- /* Util.c externs */
- extern int toatty, fromatty;
- ! extern int verbose;
- extern string prompt2;
- extern char *line, *margv[];
- extern int margc;
- --- 40,46 ----
-
- /* Util.c externs */
- extern int toatty, fromatty;
- ! extern int verbose, doingInitMacro;
- extern string prompt2;
- extern char *line, *margv[];
- extern int margc;
- ***************
- *** 50,55 ****
- --- 50,56 ----
- extern struct userinfo uinfo;
-
- #ifndef NO_VARARGS
- + /*VARARGS*/
- void dbprintf(char *fmt, ...)
- {
- va_list ap;
- ***************
- *** 143,149 ****
- --- 144,164 ----
-
-
-
- + /* Converts any uppercase characters in the string to lowercase.
- + * Never would have guessed that, huh?
- + */
- + void StrLCase(char *dst)
- + {
- + register char *cp;
-
- + for (cp=dst; *cp != '\0'; cp++)
- + if (isupper((int) *cp))
- + *cp = (char) tolower(*cp);
- + }
- +
- +
- +
- +
- char *Strpcpy(char *dst, char *src)
- {
- while ((*dst++ = *src++) != '\0')
- ***************
- *** 229,234 ****
- --- 244,250 ----
-
-
-
- +
- /*
- * Converts an ls date, in either the "Feb 4 1992" or "Jan 16 13:42"
- * format to a time_t.
- ***************
- *** 236,246 ****
- unsigned long UnLSDate(char *dstr)
- {
- #ifdef NO_MKTIME
- ! return (0);
- #else
- char *cp = dstr;
- ! int long mon, day, year, hr, min;
- ! time_t now;
- struct tm ut, *t;
-
- switch (*cp++) {
- --- 252,263 ----
- unsigned long UnLSDate(char *dstr)
- {
- #ifdef NO_MKTIME
- ! return (MDTM_UNKNOWN);
- #else
- char *cp = dstr;
- ! int mon, day, year, hr, min;
- ! time_t now, mt;
- ! unsigned long result = MDTM_UNKNOWN;
- struct tm ut, *t;
-
- switch (*cp++) {
- ***************
- *** 286,292 ****
- if (*++cp != ' ') {
- /* It's a time, XX:YY, not a year. */
- cp[2] = ' ';
- ! (void) sscanf(cp, "%ld %ld", &hr, &min);
- cp[2] = ':';
- year = t->tm_year;
- if (mon > t->tm_mon)
- --- 303,309 ----
- if (*++cp != ' ') {
- /* It's a time, XX:YY, not a year. */
- cp[2] = ' ';
- ! (void) sscanf(cp, "%d %d", &hr, &min);
- cp[2] = ':';
- year = t->tm_year;
- if (mon > t->tm_mon)
- ***************
- *** 293,299 ****
- --year;
- } else {
- hr = min = 0;
- ! (void) sscanf(cp, "%ld", &year);
- year -= 1900;
- }
- ut.tm_sec = 1;
- --- 310,316 ----
- --year;
- } else {
- hr = min = 0;
- ! (void) sscanf(cp, "%d", &year);
- year -= 1900;
- }
- ut.tm_sec = 1;
- ***************
- *** 304,316 ****
- ut.tm_year = year;
- ut.tm_isdst = t->tm_isdst;
- ut.tm_wday = ut.tm_yday = 0;
- ! return ((unsigned long) mktime(&ut));
- #endif /* NO_MKTIME */
- } /* UnLSDate */
-
-
-
-
- void Perror(
- #ifdef DB_ERRS
- char *fromProc
- --- 321,371 ----
- ut.tm_year = year;
- ut.tm_isdst = t->tm_isdst;
- ut.tm_wday = ut.tm_yday = 0;
- ! mt = mktime(&ut);
- ! if (mt != (time_t) -1)
- ! result = (unsigned long) mt;
- ! return (result);
- #endif /* NO_MKTIME */
- } /* UnLSDate */
-
-
-
- + /*
- + * Converts a SIZE date, like "213 19930602204445\n"
- + * format to a time_t.
- + */
- + unsigned long UnSIZEDate(char *dstr)
- + {
- + #ifdef NO_MKTIME
- + return (MDTM_UNKNOWN);
- + #else
- + struct tm ut;
- + time_t mt;
- + unsigned long result = MDTM_UNKNOWN;
-
- + if (sscanf(dstr, "%*s %04d%02d%02d%02d%02d%02d",
- + &ut.tm_year,
- + &ut.tm_mon,
- + &ut.tm_mday,
- + &ut.tm_hour,
- + &ut.tm_min,
- + &ut.tm_sec) == 6)
- + {
- + --ut.tm_mon;
- + ut.tm_year -= 1900;
- +
- + ut.tm_isdst = 0; /* Hmmm.... */
- + ut.tm_wday = ut.tm_yday = 0;
- + mt = mktime(&ut);
- + if (mt != (time_t) -1)
- + result = (unsigned long) mt;
- + }
- + return result;
- + #endif /* NO_MKTIME */
- + } /* UnSIZEDate */
- +
- +
- +
- void Perror(
- #ifdef DB_ERRS
- char *fromProc
- ***************
- *** 415,420 ****
- --- 470,476 ----
- #endif
- }
- sline[0] = 0;
- + (void) fflush(stdout); /* for svr4 */
- cp = fgets(sline, (int)(size - 2), stdin);
- (void) RemoveTrailingNewline(sline, NULL);
- return cp;
- ***************
- *** 597,603 ****
- {
- string str, pr;
-
- ! if (!fromatty || (activemcmd && !mprompt))
- return 1;
- (void) sprintf(pr, "%s %s? ", cmd, file);
- (void) Gets(pr, str, sizeof(str));
- --- 653,659 ----
- {
- string str, pr;
-
- ! if (!fromatty || (activemcmd && !mprompt) || (doingInitMacro))
- return 1;
- (void) sprintf(pr, "%s %s? ", cmd, file);
- (void) Gets(pr, str, sizeof(str));
- ***************
- *** 702,734 ****
- {
- longstring orig;
- struct passwd *pw;
- ! char *firstent = NULL;
- char *cp, *dp, *rest;
-
- (void) Strncpy(orig, path);
- ! if (((cp = index(orig, '/')) != NULL) && (cp != orig)) {
- *cp = 0;
- rest = cp + 1;
- ! if (orig[0] == '~') {
- ! if (orig[1] == 0) {
- ! firstent = uinfo.homedir;
- ! } else {
- ! pw = getpwnam(orig + 1);
- ! if (pw != NULL)
- ! firstent = pw->pw_dir;
- ! }
- ! } else if (orig[0] == '$') {
- ! cp = orig + 1;
- ! dp = orig + strlen(orig) - 1;
- ! if ((*cp == '(' && *dp == ')') || (*cp == '{' && *dp == '}')) {
- ! cp++;
- ! *dp = 0;
- ! }
- ! firstent = getenv(cp);
- }
- ! if (firstent != NULL)
- ! (void) sprintf(path, "%s/%s", firstent, rest);
- }
- return (path);
- } /* LocalPath */
-
- --- 758,814 ----
- {
- longstring orig;
- struct passwd *pw;
- ! char *firstent;
- char *cp, *dp, *rest;
-
- (void) Strncpy(orig, path);
- ! firstent = orig;
- ! if ((cp = index(orig, '/')) != NULL) {
- ! if (cp == orig) {
- ! /* If we got here, the path is actually a full path name,
- ! * with the first character as a slash, so just leave it
- ! * alone.
- ! */
- ! return (path);
- ! }
- ! /* Otherwise we can look at the first word of the path, and
- ! * try to expand it, like $HOME/ or ~/, or it is a relative path,
- ! * which is okay since we won't really do anything with it.
- ! */
- *cp = 0;
- rest = cp + 1;
- ! /* 'firstent' now contains the first 'word' in the path. */
- ! } else {
- ! /* Path was just a single word, or it is a full path, like:
- ! * /usr/tmp/zz, so firstent is just the entire given "path."
- ! */
- ! rest = NULL;
- ! }
- ! if (orig[0] == '~') {
- ! if (orig[1] == 0) {
- ! firstent = uinfo.homedir;
- ! } else {
- ! pw = getpwnam(orig + 1);
- ! if (pw != NULL)
- ! firstent = pw->pw_dir;
- }
- ! } else if (orig[0] == '$') {
- ! cp = orig + 1;
- ! dp = orig + strlen(orig) - 1;
- ! if ((*cp == '(' && *dp == ')') || (*cp == '{' && *dp == '}')) {
- ! cp++;
- ! *dp = 0;
- ! }
- ! firstent = getenv(cp);
- ! if (firstent == NULL) {
- ! (void) fprintf(stderr, "%s: no such environment variable.\n", cp);
- ! firstent = "badEnvVar";
- ! }
- }
- + if (rest == NULL)
- + (void) strcpy(path, firstent);
- + else
- + (void) sprintf(path, "%s/%s", firstent, rest);
- return (path);
- } /* LocalPath */
-
- diff -c ./util.h ../ncftp170/util.h
- *** ./util.h Wed Mar 16 18:25:00 1994
- --- ../ncftp170/util.h Wed Mar 16 19:16:03 1994
- ***************
- *** 72,77 ****
- --- 72,78 ----
- /* Protos. */
- char *_Strncat(char *dst, char *src, register size_t n);
- char *_Strncpy(char *dst, char *src, register size_t n);
- + void StrLCase(char *dst);
- char *NewString(char *oldstr);
- char **re_makeargv(char *promptstr, int *argc);
- char *onoff(int);
- ***************
- *** 85,90 ****
- --- 86,92 ----
- char *Gets(char *promptstr, char *sline, size_t size);
- size_t RemoveTrailingNewline(char *cp, int *stripped);
- unsigned long UnLSDate(char *dstr);
- + unsigned long UnSIZEDate(char *dstr);
- char *Strpcpy(char *dst, char *src);
- int UserLoggedIn(void);
- char *LocalPath(char *path);
- diff -c ./v2_Note ../ncftp170/v2_Note
- *** ./v2_Note Wed Mar 16 18:25:01 1994
- --- ../ncftp170/v2_Note Wed Mar 16 19:16:03 1994
- ***************
- *** 1,10 ****
- ! Version 1.6 of NcFTP is an interim release. Version 2.0 is much cooler,
- ! but it wasn't ready to go by my self-imposed deadline of September 1, 1993.
- ! The reason for that deadline is that my senior year will be getting under
- ! way, and I don't want to work on the program during that period. Last year
- ! I spent too much time on NcFTP and other projects, and not enough time on
- ! studies. As a result, my grades slipped a bit. Therefore I will be
- ! studying more and programming, reading news, and reading email less. If
- you send me email, I _will_ read it, but it may take me awhile to get to it,
- and I may not answer. Please don't be offended. I really regret having
- to release code that is such a mess. I should have wrote the code from
- --- 1,7 ----
- ! Versions numbered between 1.5.0 and 1.9.9 are interim releases. No major
- ! features are planned for these; only tweaks and fixes.
- !
- ! Version 2.0 is much cooler, but I haven't had time to work on it. If
- you send me email, I _will_ read it, but it may take me awhile to get to it,
- and I may not answer. Please don't be offended. I really regret having
- to release code that is such a mess. I should have wrote the code from
- ***************
- *** 11,26 ****
- scratch, rather than built it upon the original BSD code (which is a mess
- itself!).
-
- - This version is based on 1.5, which in turn was based on the betas of 1.4.
- - 1.4 was almost finished when I decided to add some significant features, and
- - clean up the code so it is better organized and easier to read. That version
- - is called 2.0, and isn't finished yet. The innards are totally different
- - from the 1.4 family, so patches to 1.6 won't work at all on 2.0. During the
- - process of adding stuff and cleaning up, a couple of bugs creeped in that
- - will take time to resolve. Maybe I can work on it during Christmas break.
- -
- I apologize in advance for bugs I fixed in 2.0 but forgot to re-fix
- ! in 1.6 (I think I got'em all, though).
-
- Here is a list of things that are in the 2.0 code but not this version:
-
- --- 8,15 ----
- scratch, rather than built it upon the original BSD code (which is a mess
- itself!).
-
- I apologize in advance for bugs I fixed in 2.0 but forgot to re-fix
- ! in these interim releases (I think I got'em all, though).
-
- Here is a list of things that are in the 2.0 code but not this version:
-
- ***************
- *** 41,46 ****
-
- Keep that in mind if you want to make a feature enhancement. I'm telling
- you this now so you don't spend your time programming something that is
- ! already done for the 2.0 release. Also note that patches for 1.6 will
- have to be re-coded for 2.0. (The gist is that you should wait until
- 2.0 is done before doing anything major).
- --- 30,35 ----
-
- Keep that in mind if you want to make a feature enhancement. I'm telling
- you this now so you don't spend your time programming something that is
- ! already done for the 2.0 release. Also note that patches would
- have to be re-coded for 2.0. (The gist is that you should wait until
- 2.0 is done before doing anything major).
- --
- --mg Mike Gleason <mgleason@cse.unl.edu>
-
- exit 0 # Just in case...
-