Trivial patch to tnftp (lukemftp) for Cygwin

I’m trying to make my PC as robust and usable as possible. Using Cygwin as a base, it’s possible; even trivial at times to port my much-loved utilities to work under Windows.

The FTP command line client bundled with Cygwin is quite dated, and I find NcFTP to be a boon – ncftpput/ncftpget are nice, but the curses client? No thank you.

Anyhow, I’ve made a trivial patch to the libnetbsd library to compile tnftp-2.0beta1 (formerly known as lukemftp), and disabled a setsockopt() function that doesn’t work under Cygwin. It’s unnecessary.

Note that this was configured with the GNU configure ala:

./configure—prefix=/usr—enable-completion—disable-ipv6

I don’t run IPV6 in-house; the default cygwin IPV6 support is currently lacking (basically, nonexistant). I do not suggest attempting to use the current IPV6 beta patches current cygwin – they will break IPV4!

Here’s my patch:

diff -u -r tnftp-2.0-beta1/libnetbsd/ftpglob.h tnftp-2.0-beta1-Cygwin/libnetbsd/ftpglob.h—- tnftp-2.0-beta1/libnetbsd/ftpglob.h 2001-04-13 08:23:17.000000000 -0700 +++ tnftp-2.0-beta1-Cygwin/libnetbsd/ftpglob.h 2003-05-10 19:14:31.000000000 -0700 @ -86,6 +86,11 @ #define GLOB_ABEND GLOB_ABORTED /* source compatibility /

+/ FIXME: Probably shouldn’t be here, and should do more testing… */
+#if defined(__CYGWIN__) && ! defined(ARG_MAX)
+#define ARG_MAX _POSIX_ARG_MAX
+#endif
+ int glob(const char , int, int ()(const char *, int), glob_t *); void globfree(glob_t *);

diff -u -r tnftp-2.0-beta1/src/ftp.c tnftp-2.0-beta1-Cygwin/src/ftp.c—- tnftp-2.0-beta1/src/ftp.c 2003-02-28 02:44:53.000000000 -0800
+++ tnftp-2.0-beta1-Cygwin/src/ftp.c 2003-05-10 19:17:01.000000000 -0700
@ -244,7 +244,7 @ } myctladdr.su_len = len;

-#ifdef IPTOS_LOWDELAY
+#if defined(IPTOS_LOWDELAY) && ! defined(__CYGWIN__) if (hisctladdr.su_family AF_INET) { int tos = IPTOS_LOWDELAY; if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)x%x%tos,
@ -275,11 +275,12 @ } { int on = 1;
-
+#if defined(IPTOS_LOWDELAY) x%x%x%x% ! defined(__CYGWIN__) if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char *)x%x%on, sizeof(on)) < 0 x%x%x%x% debug) { warn("setsockopt"); }
+#endif }

return (hostname); @ -1530,7 +1531,7 @ warn("connect"); goto bad; } -#ifdef IPTOS_THROUGHPUT +#if defined(IPTOS_THROUGHPUT) x%x%x%x% ! defined(__CYGWIN__) if (data_addr.su_family AF_INET) { on = IPTOS_THROUGHPUT; if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on,

Apply with ‘patch -p1’ within the source heirarchy.

This was tested rather rigerously for filename completion, using the enormous ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/ directory, and it didn’t break. ;)

Of course, there’s still a few minor bugs with the Makefiles. ‘make install’ is broken after build from the root directory, but no worries; just execute ’(cd src; make install)’ and you’ve got tnftp!

If you just want a functional binary; an elder port of lukemftp 1.6-beta2 is available here. It works with current 1.3.x cygwin1.dll libraries, but doesn’t do directory globbing.

As for the FTP daemons, well, tnftpd is not being so nice. I’ve already created a few shims, but bison under Cygwin is wholly broken; I need yacc, and cygwin doesn’t have madvise() – this makes many of the advantages of tnftpd less-adventerous. ProFTPd currently assumes different functions from the current Cygwin layout (password authentication is broken), and I have yet to be interested in PureFTPd. Then again, the defauly FTP server is fairly functional, so, we’ll see. :)