=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ftp/util.c,v retrieving revision 1.12 retrieving revision 1.13 diff -c -r1.12 -r1.13 *** src/usr.bin/ftp/util.c 1997/08/25 21:41:55 1.12 --- src/usr.bin/ftp/util.c 1997/09/04 04:37:17 1.13 *************** *** 1,5 **** ! /* $OpenBSD: util.c,v 1.12 1997/08/25 21:41:55 jkatz Exp $ */ ! /* $NetBSD: util.c,v 1.11 1997/07/21 14:03:49 lukem Exp $ */ /* * Copyright (c) 1985, 1989, 1993, 1994 --- 1,5 ---- ! /* $OpenBSD: util.c,v 1.13 1997/09/04 04:37:17 millert Exp $ */ ! /* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */ /* * Copyright (c) 1985, 1989, 1993, 1994 *************** *** 35,41 **** */ #ifndef lint ! static char rcsid[] = "$OpenBSD: util.c,v 1.12 1997/08/25 21:41:55 jkatz Exp $"; #endif /* not lint */ /* --- 35,41 ---- */ #ifndef lint ! static char rcsid[] = "$OpenBSD: util.c,v 1.13 1997/09/04 04:37:17 millert Exp $"; #endif /* not lint */ /* *************** *** 87,99 **** code = -1; return; } ! port = ftpport; if (argc > 2) { char *ep; long nport; nport = strtol(argv[2], &ep, 10); ! if (nport < 1 || nport > 0xffff || *ep != '\0') { fprintf(ttyout, "%s: bad port number '%s'.\n", argv[1], argv[2]); fprintf(ttyout, "usage: %s host-name [port]\n", --- 87,102 ---- code = -1; return; } ! if (gatemode) ! port = gateport; ! else ! port = ftpport; if (argc > 2) { char *ep; long nport; nport = strtol(argv[2], &ep, 10); ! if (nport < 1 || nport > USHRT_MAX || *ep != '\0') { fprintf(ttyout, "%s: bad port number '%s'.\n", argv[1], argv[2]); fprintf(ttyout, "usage: %s host-name [port]\n", *************** *** 103,112 **** } port = htons((in_port_t)nport); } ! host = hookup(argv[1], port); if (host) { int overbose; connected = 1; /* * Set up defaults for FTP. --- 106,131 ---- } port = htons((in_port_t)nport); } ! ! if (gatemode) { ! if (gateserver == NULL || *gateserver == '\0') ! errx(1, "gateserver not defined (shouldn't happen)"); ! host = hookup(gateserver, port); ! } else ! host = hookup(argv[1], port); ! if (host) { int overbose; + if (gatemode) { + if (command("PASSERVE %s", argv[1]) != COMPLETE) + return; + if (verbose) + fprintf(ttyout, + "Connected via pass-through server %s\n", + gateserver); + } + connected = 1; /* * Set up defaults for FTP. *************** *** 384,390 **** if (doswitch) pswitch(!proxy); for (mode = "w"; *++argv != NULL; mode = "a") ! recvrequest("NLST", temp, *argv, mode, 0); if ((code / 100) != COMPLETE) { if (errbuf != NULL) *errbuf = reply_string; --- 403,409 ---- 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; *************** *** 475,481 **** globfree(&gl); return (0); } ! *cpp = strdup(gl.gl_pathv[0]); /* XXX - wasted memory */ globfree(&gl); return (1); } --- 494,503 ---- globfree(&gl); return (0); } ! /* XXX: caller should check if *cpp changed, and ! * free(*cpp) if that is the case ! */ ! *cpp = strdup(gl.gl_pathv[0]); globfree(&gl); return (1); }