This is a patch to make NcFTP-2.4.2 work on Win32 platforms as a console client. I'll include what I wrote to Chris Szurgot (the fearless maintainer of the *original* NcFTP port for Win32, and the VIRTUN*X site) to save the trouble of explaining what the patch does: ------------------------------------------------------------------- First, thanks for writing the best ftp client I have seen. I use it almost everywhere. I looked at Chris' ncftp-2.3.0 port to win32 (I have used it a lot, thanks Chris!), and saw an opportunity to make a slightly different kind of port, by emulating socket handles as "real" filehandles (which are actually CRT handles on Win32). Therefore, I set about hacking ncftp-2.4.2 and here's the result. The value of this approach is demonstrated by the fact that this same patch will apply over either ncftp-2.3.0 or ncftp-2.4.2 (barring the Makefile, which needs changes in filenames for those files that changed). This should make it possible to maintain win32 support fairly easily. The patch also includes all the misc. changes made by Chris in his 2.3.0 port, and the set of winsock includes (which should probably be distributed under a win32 subdirectory, since they will cause the compile to barf on other platforms). There was a bug in the curses init handling while paging files with the built in pager. I have also made it so that we call initscr() properly after executing shell commands or pagers (BTW, ncftp works famously with less-332 on win32). There is support for building with either Visual C++ 2.x - 5.x or Borland C++ 4.x. Using shell commands now waits properly for the user to hit a key (it didn't before). SIGINTs get delivered properly now (but that fix was in pdcurses not in ncftp). Unfortunately though, hitting Ctrl-C currently causes a coredump (since you can't longjmp() out of signal handlers reliably in the peecee world). We can probably avoid doing longjmp()s at all inside signal handlers in a few places for WIN32, but that fix will have to wait for another day. Also included are a README.w32 and a verbatim manpage (which win32 users will appreciate). ------------------------------------------------------------------- You will need GNU patch 2.1 to apply the patch. There is a port with full source and intel binaries for GNU patch at: http://www-personal.umich.edu/~gsar/patch2_1-win32.tar.gz http://www-personal.umich.edu/~gsar/patch2_1-win32-exe.zip This file and ncftp binaries can also be found at the same location. Apply to ncftp-2.4.2 source with "patch -p1 -N < this_file", and enjoy! - Sarathy. gsar@umich.edu ------------------------------------------------------------------- diff -ur ncftp-2.4.2-dist/Bookmark.c ncftp-2.4.2-win32/Bookmark.c --- ncftp-2.4.2-dist/Bookmark.c Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/Bookmark.c Mon Apr 28 09:39:38 1997 @@ -255,7 +255,7 @@ token = str; if ((token = strtok(token, ".")) == NULL) token = "misc"; - else if (ISTREQ(token, "ftp")) { + else if (ISTREQ(token, "ftp") || ISTREQ(token, "www") ) { if ((token = strtok(NULL, ".")) == NULL) token = "misc"; } diff -ur ncftp-2.4.2-dist/Cmds.c ncftp-2.4.2-win32/Cmds.c --- ncftp-2.4.2-dist/Cmds.c Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/Cmds.c Mon Apr 28 09:39:38 1997 @@ -204,7 +204,7 @@ --errs; goto done; } else { - pager = POpen(pageCmd, "w", 1); + pager = POpen(pageCmd, "w", 0); while (fgets(str, ((int) sizeof(str)) - 1, (FILE *)fp) != NULL) fputs(str, (FILE *) pager); PClose((FILE *) pager); @@ -1219,7 +1219,11 @@ if ((theShell = (char *) getenv("SHELL")) == NULL) theShell = gUserInfo.shell; if (theShell == NULL) +#ifdef WIN32 + theShell = "cmd.exe"; +#else theShell = "/bin/sh"; +#endif SaveScreen(); if (setjmp(gShellJmp) != 0) { diff -ur ncftp-2.4.2-dist/Curses.h ncftp-2.4.2-win32/Curses.h --- ncftp-2.4.2-dist/Curses.h Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/Curses.h Tue Apr 29 20:28:42 1997 @@ -1,5 +1,9 @@ /* Curses.h */ +#ifndef _Curses_h_ +#define _Curses_h_ +#include "Sys.h" + #ifdef HAVE_LIBNCURSES /* The header file that came with ncurses may be named either * ncurses.h or curses.h unfortunately. @@ -19,7 +23,7 @@ # define USE_CURSES 3 # else # ifdef HAVE_LIBCURSES -# include +# include /* beware recursive include */ # define USE_CURSES 1 # ifdef __osf__ # ifndef CURSES_SHELL_BUG @@ -58,3 +62,6 @@ #else # define BEEP(a) #endif + +#endif /* _Curses_h_ */ + diff -ur ncftp-2.4.2-dist/FTP.c ncftp-2.4.2-win32/FTP.c --- ncftp-2.4.2-dist/FTP.c Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/FTP.c Tue Apr 29 21:38:54 1997 @@ -626,10 +626,14 @@ return (kConnectNoErr); fatal: +#ifdef WIN32 + closesocket(sockfd); +#else if (sockfd > 0) close(sockfd); +#endif if (sock2fd > 0) - close(sock2fd); + close(sock2fd); return (result); } /* OpenControlConnection */ @@ -645,7 +649,11 @@ } gDataSocketAccepted = kClosedFileDescriptor; if (gDataSocket != kClosedFileDescriptor) { +#ifdef WIN32 + closesocket(gDataSocket); +#else close(gDataSocket); +#endif gDataSocket = kClosedFileDescriptor; DebugMsg("Closed data connection.\n"); } else { @@ -897,7 +905,11 @@ len = (int) sizeof(gServerDataAddr); newSocket = accept(gDataSocket, (struct sockaddr *) &gServerDataAddr, &len); +#ifdef WIN32 + (void) closesocket(gDataSocket); +#else (void) close(gDataSocket); +#endif if (newSocket < 0) { Error(kDoPerror, "Could not accept a data connection.\n"); gDataSocket = kClosedFileDescriptor; diff -ur ncftp-2.4.2-dist/Get.c ncftp-2.4.2-win32/Get.c --- ncftp-2.4.2-dist/Get.c Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/Get.c Mon Apr 28 09:39:40 1997 @@ -5,7 +5,11 @@ #include #ifdef HAVE_UTIME_H +# ifdef _MSC_VER +# include +# else # include +# endif #else struct utimbuf {time_t actime; time_t modtime;}; #endif @@ -177,6 +181,12 @@ if (gopt->outputMode == kDumpToStdout) { fd = gStdout; +#ifdef WIN32 + /* set mode to binary to ensure redirection won't + * munge the file + */ + setmode(gStdout,O_BINARY); +#endif STRNCPY(local, kLocalFileIsStdout); /* Don't have progress reports going if we're piping or * dumping to the screen. diff -ur ncftp-2.4.2-dist/Glob.c ncftp-2.4.2-win32/Glob.c --- ncftp-2.4.2-dist/Glob.c Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/Glob.c Tue Apr 29 21:39:20 1997 @@ -3,7 +3,9 @@ #include "Sys.h" #include +#ifndef WIN32 #include +#endif #include #include @@ -54,7 +56,9 @@ { string pat; char *cp, *rest, *firstent; +#ifndef WIN32 struct passwd *pw; +#endif if ((pattern[0] == '~') && (isalnum(pattern[1]) || (pattern[1] == '/') || (pattern[1] == '\0'))) { @@ -69,12 +73,14 @@ /* Was just a ~ or ~/rest type. */ firstent = gUserInfo.home; } else { - /* Was just a ~username or ~username/rest type. */ +#ifndef WIN32 + /* Was just a ~username or ~username/rest type. */ pw = getpwnam(pat + 1); if (pw != NULL) firstent = pw->pw_dir; else return; /* Bad user -- leave it alone. */ +#endif } Strncpy(pattern, firstent, siz); @@ -125,6 +131,9 @@ cp = gUserInfo.shell; else ++cp; +#ifdef WIN32 + sprintf(cmd, "%s -d %s", LS, pattern2); +#else if (STREQ(cp, "csh") || STREQ(cp, "tcsh")) { /* Don't want to source .cshrc, which could * change the directory, so use -f. @@ -133,7 +142,7 @@ } else { sprintf(cmd, "%s -c \"%s -d %s\"", gUserInfo.shell, LS, pattern2); } - +#endif fp = NULL; if (setjmp(gLocalGlobJmp) == 0) { fp = POpen(cmd, "r", 0); @@ -144,6 +153,10 @@ sp = SIGNAL(SIGPIPE, LGlobHandler); si = SIGNAL(SIGINT, LGlobHandler); while (FGets(gfile, sizeof(gfile), (FILE *) fp) != NULL) { +#ifdef WIN32 /* I hate to do it, but the '\r' is never removed... */ + if (gfile[strlen(gfile) - 1] == '\r') + gfile[strlen(gfile) - 1] = '\0'; +#endif TraceMsg("Lglob [%s]\n", gfile); AddLine(fileList, gfile); } diff -ur ncftp-2.4.2-dist/Main.c ncftp-2.4.2-win32/Main.c --- ncftp-2.4.2-dist/Main.c Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/Main.c Tue Apr 29 21:52:06 1997 @@ -19,7 +19,9 @@ # include #endif +#ifndef WIN32 #include +#endif #include #include #include @@ -42,6 +44,10 @@ #include "Tips.h" #include "Version.h" +#ifdef WIN32 +WSADATA WSAData; +#endif + /* We need to know our fully qualified hostname. That way we can give * a complete email address as a password for anonymous logins. */ @@ -174,8 +180,9 @@ static struct passwd *GetPwByName(void) { - char *cp; - struct passwd *pw; +#ifndef WIN32 + char *cp; + struct passwd *pw; cp = getlogin(); if (cp == NULL) { @@ -187,6 +194,7 @@ if (cp != NULL) pw = getpwnam(cp); return (pw); +#endif } /* GetPwByName */ @@ -201,6 +209,7 @@ pw = NULL; errno = 0; +#ifndef WIN32 #ifdef USE_GETPWUID /* Try to use getpwuid(), but if we have to, fall back to getpwnam(). */ if ((pw = getpwuid(getuid())) == NULL) @@ -225,16 +234,29 @@ */ Error(kDoPerror, "Could not get your passwd entry!"); sleep(1); +#endif if ((cp = (char *) getenv("LOGNAME")) == NULL) cp = "nobody"; (void) STRNCPY(gUserInfo.userName, cp); +#ifdef WIN32 + gUserInfo.shell = StrDup("cmd.exe"); +#else gUserInfo.shell = StrDup("/bin/sh"); +#endif if ((cp = (char *) getenv("HOME")) == NULL) +#ifdef WIN32 + { + fprintf(stderr, "Must set environment variable home..."); + DoQuit(kExitNoErr); + } +#else cp = "."; +#endif gUserInfo.home = StrDup(cp); gUserInfo.uid = 999; +#ifndef WIN32 } - +#endif cp = (char *) getenv("MAIL"); if (cp == NULL) cp = (char *) getenv("mail"); @@ -558,6 +580,37 @@ close(fd); } #endif /* (LOCK_METHOD == 3) */ +#if (LOCK_METHOD == 4) /* Win32 Lock */ + int err; + + OurDirectoryPath(gLockFileName, sizeof(gLockFileName), kLockFileName); + if ((fd = open(gLockFileName, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR)) < 0) { + Error(kDoPerror, "Could not open lock file %s.\n", gLockFileName); + sleep(5); + + /* Try to save data anyway. */ + gOtherSessionRunning = 0; + } else { +#ifdef __BORLANDC__ + err = lock(fd, 0, 1); +#else +# include + err = _locking(fd,_LK_NBLCK,1); +#endif + if (err == 0) { + /* We now have a lock set on the whole file. */ + gOtherSessionRunning = 0; + time(&now); + sprintf(pidbuf, "%5d %s", (int) getpid(), ctime(&now)); + write(fd, pidbuf, strlen(pidbuf) + 1); + } else { + /* Could not lock; maybe another ncftp process has + * already locked it. + */ + gOtherSessionRunning = 1; + } + } +#endif /* (LOCK_METHOD == 4) */ } /* CheckForOtherSessions */ @@ -595,6 +648,29 @@ # endif #endif +#ifdef WIN32 + { + int err; + WORD wVerReq; + int iSockOpt = SO_SYNCHRONOUS_NONALERT; + + _fmode = O_BINARY; /* This causes an error somewhere. */ + + wVerReq = MAKEWORD(1,1); + + if (err = WSAStartup(wVerReq, &WSAData)) { + fprintf(stderr, "No WinSock found!\n"); + return; + } + /* Enable the use of sockets as filehandles */ + setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, + (char *)&iSockOpt, sizeof(iSockOpt)); + + strcpy(TitleBarLocation, TitleBarNormal); + strcpy(TitleBarFileStatus, TitleBarNormal); + SetConsoleTitle(TitleBarNormal); + } +#endif srand((unsigned int) time(NULL)); GetUserInfo(); @@ -883,8 +961,8 @@ * commands' flags and the program must use mutually exclusive * sets of flags. */ - while ((opt = Getopt(argc, argv, "aiup:rd:g:cmCfGRn:zDLVH")) >= 0) { - if (strchr("aiup:rd:g:cmCfGRn:z", opt) == NULL) { + while ((opt = Getopt(argc, argv, "aiup:rd:g:cmCfGRn:M:zDLVH")) >= 0) { + if (strchr("aiup:rd:g:cmCfGRn:M:z", opt) == NULL) { switch (opt) { case 'D': gDebug = kDebuggingOn; @@ -914,7 +992,8 @@ -f : Force overwrite.\n\ -G : Don't use wildcard matching.\n\ -R : Recursive. Useful for fetching whole directories.\n\ - -n X : Get selected files only if X days old or newer.\n"); + -n X : Get selected files only if X days old or newer.\n\ + -M X : Run X macro on open of site.\n"); Exit(kExitUsageErr); } } diff -ur ncftp-2.4.2-dist/Open.c ncftp-2.4.2-win32/Open.c --- ncftp-2.4.2-dist/Open.c Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/Open.c Tue Apr 29 22:26:40 1997 @@ -76,6 +76,7 @@ extern LineList gRedir; extern void GetRemoteCWD(char *cdstub, ResponsePtr cwdrp); +char macroOption[128]; /* This is used primarily for non-anonymous logins. We'll have to ask * the user some questions, like their username, password, etc. @@ -330,11 +331,11 @@ char *cp, *hostp, *cpath; /* First setup the openopt variables. */ - InitOpenOptions(openopt); + InitOpenOptions(openopt); macroOption[0] = '\0'; /* Tell Getopt() that we want to start over with a new command. */ - GetoptReset(); - while ((opt = Getopt(argc, argv, "aiup:rd:g:cmCfGRn:")) >= 0) { + GetoptReset(); + while ((opt = Getopt(argc, argv, "aiup:rd:g:cmCfGRn:M:")) >= 0) { switch (opt) { case 'a': /* User wants to open anonymously. */ @@ -429,6 +430,9 @@ break; } goto usage; + case 'M': + strcpy(macroOption, gOptArg); + break; default: if (fromMain) @@ -614,7 +618,11 @@ * copy in the current local directory. */ InitGetOutputMode(&openopt->gopt, kSaveToDisk); +#ifdef WIN32 + openopt->gopt.doReports = 1; +#else openopt->gopt.doReports = 0; +#endif openopt->gopt.rName = openopt->colonModePath; result = DoGetWithGlobbingAndRecursion(&openopt->gopt); } @@ -709,7 +717,14 @@ */ (void) RunPrefixedMacro("colon.open.", "any"); (void) RunPrefixedMacro("colon.open.", gRmtInfo.bookmarkName); - } else { + } else if (macroOption[0] != NULL) { + MacroNodePtr mnp; + string macName; + + STRNCPY(macName, macroOption); + mnp = FindMacro(macName); + (void) ExecuteMacro(mnp, 0, NULL); + } else { (void) RunPrefixedMacro("open.", "any"); (void) RunPrefixedMacro("open.", gRmtInfo.bookmarkName); if (gWinInit == 0) diff -ur ncftp-2.4.2-dist/Progress.c ncftp-2.4.2-win32/Progress.c --- ncftp-2.4.2-dist/Progress.c Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/Progress.c Tue Apr 29 22:27:30 1997 @@ -497,6 +497,9 @@ * without looking at function pointers. */ xp->progMeterInUse = progMeterInUse; +#ifdef WIN32 /* We don't care... Update the title bar anyway... */ + DoWin32Console(xp); +#endif return (progMeterInUse); } /* StartProgress */ @@ -604,6 +607,9 @@ /* Won't do reports if the user isn't logged in to see them. */ xp->doReports = UserLoggedIn(); } +#ifdef WIN32 /* We don't care... Update the title bar anyway... */ + DoWin32Console(xp); +#endif } /* ProgressReport */ diff -ur ncftp-2.4.2-dist/Put.c ncftp-2.4.2-win32/Put.c --- ncftp-2.4.2-dist/Put.c Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/Put.c Mon Apr 28 11:30:22 1997 @@ -13,6 +13,10 @@ #include "Glob.h" #include "Put.h" +#ifdef WIN32 +# include +#endif + extern int gTransferType; extern int gOptInd, gXferAbortFlag; diff -ur ncftp-2.4.2-dist/Sys.h ncftp-2.4.2-win32/Sys.h --- ncftp-2.4.2-dist/Sys.h Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/Sys.h Tue Apr 29 22:33:24 1997 @@ -1,5 +1,9 @@ /* Sys.h */ +#ifdef WIN32 +# include "Win32.h" +#endif + #include "Config.h" #ifdef HAVE_UNISTD_H @@ -8,7 +12,9 @@ #include #include +#ifdef WIN32 #include +#endif #ifdef STDC_HEADERS # include @@ -101,6 +107,9 @@ +#ifdef WIN32 +# define LOCK_METHOD 4 +#else #ifdef HAVE_FLOCK # define LOCK_METHOD 2 #else @@ -110,14 +119,16 @@ # define LOCK_METHOD 3 # endif #endif - +#endif #ifdef _POSIX_VERSION # define POSIX_SIGNALS 1 #endif +#ifndef PClose #define PClose pclose +#endif #ifdef SVR4 # ifndef Gettimeofday @@ -125,9 +136,11 @@ # endif #endif /* SVR4 */ +#ifndef WIN32 #ifndef Gettimeofday # define Gettimeofday(a) gettimeofday(a, (struct timezone *)0) #endif /* Gettimeofday */ +#endif /* This malloc stuff is mostly for our own use. */ #define LIBC_MALLOC 0 diff -ur ncftp-2.4.2-dist/Util.c ncftp-2.4.2-win32/Util.c --- ncftp-2.4.2-dist/Util.c Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/Util.c Tue Apr 29 21:41:24 1997 @@ -8,7 +8,9 @@ # endif #else # ifdef HAVE_GETWD +#ifndef WIN32 # include +#endif # ifndef MAXPATHLEN # define MAXPATHLEN 1024 # endif @@ -351,8 +353,15 @@ result = 0; if (access(path, F_OK) < 0) { +#ifdef WIN32 + STRNCPY(mdCmd, "mkdir "); /* -p is nice, but not mandatory. */ + STRNCAT(mdCmd, path); + while (strchr(mdCmd, '/') != NULL) + *strchr(mdCmd, '/') = '\\'; +#else STRNCPY(mdCmd, "mkdir -p "); /* -p is nice, but not mandatory. */ STRNCAT(mdCmd, path); +#endif result = system(mdCmd); } return (result); diff -ur ncftp-2.4.2-dist/WGets.c ncftp-2.4.2-win32/WGets.c --- ncftp-2.4.2-dist/WGets.c Tue Apr 29 18:03:10 1997 +++ ncftp-2.4.2-win32/WGets.c Tue Apr 29 21:41:50 1997 @@ -12,6 +12,7 @@ * termios.h. Example: #define killchar() (__baset.c_cc[VKILL]) */ +#ifndef WIN32 #ifdef HAVE_TERMIOS_H # include #else @@ -24,6 +25,7 @@ # include # endif #endif /* !HAVE_TERMIOS_H */ +#endif #include diff -ur ncftp-2.4.2-dist/Win.c ncftp-2.4.2-win32/Win.c --- ncftp-2.4.2-dist/Win.c Thu May 01 15:13:43 1997 +++ ncftp-2.4.2-win32/Win.c Thu May 01 14:56:44 1997 @@ -122,7 +122,10 @@ */ clear(); refresh(); - endwin(); + + /* close the current console; we'll reopen another later */ + EndWin(); + fflush(stdout); fflush(stderr); } @@ -133,6 +136,10 @@ static void TTYWaitForReturn(void) { +#ifdef WIN32 + cputs("[Hit return]"); + if (!getche()) getche(); +#else int tty; int junk; @@ -142,6 +149,7 @@ read(tty, &junk, 1); close(tty); } +#endif } /* TTYWaitForReturn */ @@ -149,7 +157,7 @@ void RestoreScreen(int pressKey) { #ifdef USE_CURSES - if (gWinInit) { + if (gVisualMode && gIsToTTY && gIsFromTTY) { if (pressKey) { # if (CURSES_SHELL_BUG == 0) TTYWaitForReturn(); @@ -157,6 +165,12 @@ sleep(2); # endif } + + /* we may have closed the private console; reopen one again */ + if (!gWinInit) { + initscr(); + gWinInit = 1; + } refresh(); UpdateScreen(1); } @@ -165,6 +179,7 @@ +#ifndef WIN32 void Beep(int on) { static time_t lastBeepTime = 0; @@ -186,7 +201,7 @@ } lastBeepTime = now; } /* Beep */ - +#endif @@ -474,6 +489,29 @@ string bar; string barTmp; +#ifdef WIN32 + { + /* It may be that there is a better place for this... + In fact, I'm sure of it */ + string pcwd; + MakeStringPrintable(pcwd, (unsigned char *) gRemoteCWD, sizeof(pcwd)); + + if (l != NULL && r != NULL) + sprintf(TitleBarLocation, "%s:%s", l, r); + else + { +/* sprintf(TitleBarLocation, "%s:%s", gRmtInfo.nickName, pcwd);*/ + sprintf(TitleBarLocation, "No Info Possible"); + } + + + if (gConnected) + SetConsoleTitle(TitleBarLocation); + else + SetConsoleTitle(TitleBarNormal); + } + +#endif if (gWinInit) { if (l == NULL) l = gBarLeft; @@ -671,6 +709,15 @@ /* Have to do CRs manually because * some systems don't do 'em. (AIX). */ +#ifdef WIN32 + if (*(endp + 1) == '\n') + { + strcpy(endp, (endp + 1)); + haveNL = 1; + *endp = '\0'; + break; + } +#endif haveCR = 1; *endp = '\0'; break; diff -ur ncftp-2.4.2-dist/Win.h ncftp-2.4.2-win32/Win.h --- ncftp-2.4.2-dist/Win.h Tue Apr 29 18:03:12 1997 +++ ncftp-2.4.2-win32/Win.h Tue Apr 29 21:25:40 1997 @@ -52,7 +52,11 @@ void Exit(int); void SaveScreen(void); void RestoreScreen(int); +#ifdef WIN32 +#define Beep(x) Beep(x,10); +#else void Beep(int); +#endif void UpdateScreen(int); void FlushListWindow(void); char *Gets(char *, size_t); --- /dev/null Thu Jan 11 19:18:08 1996 +++ ncftp-2.3.0-win32/arpa/inet.h Wed Nov 22 16:28:30 1995 @@ -0,0 +1,3 @@ +#ifndef _WINSOCKAPI_ +#include +#endif --- /dev/null Thu Jan 11 19:18:08 1996 +++ ncftp-2.3.0-win32/arpa/telnet.h Wed Nov 22 16:28:30 1995 @@ -0,0 +1,3 @@ +#ifndef _WINSOCKAPI_ +#include +#endif --- /dev/null Thu Jan 11 19:18:08 1996 +++ ncftp-2.3.0-win32/netinet/in.h Wed Nov 22 16:28:50 1995 @@ -0,0 +1,3 @@ +#ifndef _WINSOCKAPI_ +#include +#endif --- /dev/null Thu Jan 11 19:18:08 1996 +++ ncftp-2.3.0-win32/sys/socket.h Wed Nov 22 16:28:40 1995 @@ -0,0 +1,3 @@ +#ifndef _WINSOCKAPI_ +#include +#endif --- /dev/null Thu Jan 11 19:18:08 1996 +++ ncftp-2.3.0-win32/sys/time.h Wed Nov 22 16:28:36 1995 @@ -0,0 +1,3 @@ +#ifndef _WINSOCKAPI_ +#include +#endif --- /dev/null Thu Jan 11 19:18:08 1996 +++ ncftp-2.3.0-win32/netdb.h Wed Nov 22 16:27:54 1995 @@ -0,0 +1,3 @@ +#ifndef _WINSOCKAPI_ +#include +#endif --- /dev/null Thu Jan 11 19:18:08 1996 +++ ncftp-2.4.2-win32/Config.h.w32 Tue Apr 29 21:45:16 1997 @@ -0,0 +1,270 @@ +/* Config.h.in. Generated automatically from configure.in by autoheader. */ + + +/* Don't define HOSTNAME or DOMAINNAME unless you have to. After compiling, + * a test run of the program will tell you if it couldn't determine these + * itself. If the test run looks normal (i.e. doesn't mention this stuff) + * you're okay. + */ + +/* #define HOSTNAME "cse.unl.edu" */ + +/* #define DOMAINNAME "unl.edu" */ + +/* If you're using the program as an FTP program in an enviroment where + * you almost always need to open with a user name and password, you + * might consider turning off anonymous by default. + * + * Note: this won't override whatever is in your ~/.ncftp/prefs. + * When you run the program the first time, that file is created, so + * changing this may not seem to work until you edit your prefs. + */ +#define UOPEN 0 /* No anon ftp by default? */ + +/* After compiling the program, you may decide that the curses stuff + * doesn't perform well. (It works great on some systems, awful on others). + * If visual mode doesn't do a good job, you can have visual mode off + * by default. + * + * Note: this won't override whatever is in your ~/.ncftp/prefs. + * When you run the program the first time, that file is created, so + * changing this may not seem to work until you edit your prefs. + */ +#define VISUAL 1 + +/* Keep user logs by default? */ +#define USERLOG 1 + +/* Default progress meter (0..4) */ +#define PROGRESS 2 + + + + +/* Define to empty if the keyword does not work. */ +#undef const + +/* Define if the `getpgrp' function takes no argument. */ +#undef GETPGRP_VOID + +/* Define if you have the strftime function. */ +#define HAVE_STRFTIME + +/* Define if the setvbuf function takes the buffering type as its second + argument and the buffer pointer as the third, as on System V + before release 3. */ +#undef SETVBUF_REVERSED + +/* Define to `unsigned' if doesn't define. */ +#undef size_t + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +#ifdef WIN32 +#define MORE "more" + +#define ZCAT "zcat" + +#define GZCAT "zcat" + +#define UNAME "Windows95" + +#define LS "ls" +#else +#define MORE "/bin/more" + +#define ZCAT "/bin/zcat" + +#define GZCAT "/bin/zcat" + +#define UNAME "Linux Redwing 1.2.13 #6 Thu Sep 7 22:06:08 CDT 1995 i586" + +#define LS "/bin/ls" +#endif + +#define HAVE_LIBCURSES +#undef HAVE_LIBNCURSES +#undef HAVE_LIBREADLINE +#undef HAVE_LIBTERMCAP + +/* This can be one of kSendPortMode (0), kPassiveMode (1) or + * kFallBackToSendPortMode (2). + * + * Example: #define FTP_DATA_PORT_MODE 2 + */ +#undef FTP_DATA_PORT_MODE + +#undef HAVE_MAXX +#define HAVE__MAXX 1 + +/* Define to 1 if ANSI function prototypes are usable. */ +#define PROTOTYPES 1 + +/* Define if you have the beep function. */ +#define HAVE_BEEP + +/* Define if you have the curs_set function. */ +#define HAVE_CURS_SET 1 + +/* Define if you have the fcntl function. */ +#define HAVE_FCNTL 1 + +/* Define if you have the filename_completion_function function. */ + #define HAVE_FILENAME_COMPLETION_FUNCTION + +/* Define if you have the flock function. */ +#define HAVE_FLOCK 1 + +/* Define if you have the getcwd function. */ +#undef HAVE_GETCWD + +/* Define if you have the getdomainname function. */ +#undef HAVE_GETDOMAINNAME + +/* Define if you have the getmaxyx function. */ +#undef HAVE_GETMAXYX + +/* Define if you have the getwd function. */ +#define HAVE_GETWD 1 + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE 1 + +/* Define if you have the mktime function. */ +#define HAVE_MKTIME 1 + +/* Define if you have the notimeout function. */ +#define HAVE_NOTIMEOUT 1 + +/* Define if you have the remove function. */ +#define HAVE_REMOVE + +/* Define if you have the setlinebuf function. */ +#undef HAVE_SETLINEBUF + +/* Define if you have the strcasecmp function. */ +#undef HAVE_STRCASECMP + +/* Define if you have the strerror function. */ +#define HAVE_STRERROR 1 + +/* Define if you have the symlink function. */ +#undef HAVE_SYMLINK + +/* Define if you have the tcgetpgrp function. */ +#undef HAVE_TCGETPGRP + +/* Define if you have the unlink function. */ +#define HAVE_UNLINK 1 + +/* Define if you have the header file. */ +#define HAVE_CURSES_H 1 + +/* Define if you have the header file. */ +#undef HAVE_CURSESX_H + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H + +/* Define if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define if you have the header file. */ +#undef HAVE_NCURSES_H + +/* Define if you have the header file. */ +#undef HAVE_NET_ERRNO_H + +/* Define if you have the header file. */ +#undef HAVE_READLINE_HISTORY_H + +/* Define if you have the header file. */ +#undef HAVE_SGTTY_H + +/* Define if you have the header file. */ +#define HAVE_STDARG_H 1 + +/* Define if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_BSDTYPES_H + +/* Define if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define if you have the header file. */ +#undef HAVE_TERM_TERMNET_H + +/* Define if you have the header file. */ +#undef HAVE_TERMIO_H + +/* Define if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define if you have the header file. */ +#undef HAVE_TERMNET_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the header file. */ +#define HAVE_UTIME_H + +/* Define if you have the c_s library (-lc_s). */ +#undef HAVE_LIBC_S + +/* Define if you have the com_err library (-lcom_err). */ +#undef HAVE_LIBCOM_ERR + +/* Define if you have the crypto library (-lcrypto). */ +#undef HAVE_LIBCRYPTO + +/* Define if you have the db library (-ldb). */ +#undef HAVE_LIBDB + +/* Define if you have the getline library (-lgetline). */ +#undef HAVE_LIBGETLINE + +/* Define if you have the gssapi_krb5 library (-lgssapi_krb5). */ +#undef HAVE_LIBGSSAPI_KRB5 + +/* Define if you have the inet library (-linet). */ +#undef HAVE_LIBINET + +/* Define if you have the isode library (-lisode). */ +#undef HAVE_LIBISODE + +/* Define if you have the krb5 library (-lkrb5). */ +#undef HAVE_LIBKRB5 + +/* Define if you have the posix library (-lposix). */ +#undef HAVE_LIBPOSIX + +/* Define if you have the resolv library (-lresolv). */ +#undef HAVE_LIBRESOLV + +/* Define if you have the socket library (-lsocket). */ +#undef HAVE_LIBSOCKET + +/* Define if you have the socks library (-lsocks). */ +#undef HAVE_LIBSOCKS + +/* Define if you have the socks5 library (-lsocks5). */ +#undef HAVE_LIBSOCKS5 + +/* Define if you have the termnet library (-ltermnet). */ +#undef HAVE_LIBTERMNET --- /dev/null Thu Jan 11 19:18:08 1996 +++ ncftp-2.4.2-win32/Makefile.bcc Tue Apr 29 21:58:22 1997 @@ -0,0 +1,131 @@ +CC=bcc32 +TLINK=tlink32 +CFLAGS=-w32 -DDOMAINNAME=\"foo.com\" -DWIN32 -v -I. + +LINKFLAGS=-Tpe -ap -c -v -x -LD:\\BC45\\LIB +ENTRYPOINT=D:\\BC45\\LIB\\C0X32.obj + +LIBS=pdcurses.lib \ + bidsf.lib \ + cw32.lib \ + import32.lib \ + +OBJS = bookmark.obj\ + cmdline.obj\ + cmdlist.obj\ + cmds.obj\ + complete.obj\ + cpp.obj\ + datesize.obj\ + ftp.obj\ + get.obj\ + getopt.obj\ + glob.obj\ + hostwin.obj\ + lgets.obj\ + linelist.obj\ + list.obj\ + macro.obj\ + main.obj\ + makeargv.obj\ + open.obj\ + prefs.obj\ + progress.obj\ + put.obj\ + sio.obj\ + rcmd.obj\ + strn.obj\ + tips.obj\ + util.obj\ + wgets.obj\ + win.obj\ + win32.obj\ + xfer.obj + +all: ncftp.exe + +ncftp.exe: $(OBJS) + $(TLINK) @&&! + $(LINKFLAGS) $(ENTRYPOINT) $(OBJS) + ncftp.exe,ncftp.map + $(LIBS) +! + +config.h: Config.h.w32 + copy Config.h.w32 config.h + +sys.h: win32.h Util.h Main.h Cmds.h Open.h Cmdline.h DateSize.h Prefs.h FTP.h Getopt.h Xfer.h Tips.h Version.h config.h + touch sys.h + + +bookmark.obj: bookmark.c sys.h util.h bookmark.h ftp.h + +cmdline.obj: cmdline.c sys.h Util.h Cmdline.h Cmds.h Main.h MakeArgv.h Open.h + +cmdlist.obj: cmdlist.c Curses.h Util.h Main.h Open.h Cmds.h Glob.h List.h Get.h Put.h Hostwin.h Prefs.h Cmdline.h + +cmds.obj: cmds.c sys.h Util.h RCmd.h Cmds.h Cmdline.h List.h MakeArgv.h Macro.h Main.h DateSize.h Open.h Glob.h Getopt.h FTP.h Cpp.h Prefs.h Tips.h Version.h + +complete.obj: complete.c sys.h LineList.h Cmdline.h Complete.h Prefs.h Util.h List.h + +cpp.obj: cpp.c sys.h Curses.h Util.h RCmd.h Cpp.h + +datesize.obj: datesize.c sys.h Util.h RCmd.h Cmds.h Xfer.h List.h DateSize.h + +ftp.obj: ftp.c sys.h Util.h FTP.h RCmd.h + +get.obj: get.c Util.h RCmd.h Xfer.h Cmds.h Glob.h Get.h DateSize.h List.h Getopt.h sys.h + +getopt.obj: getopt.c sys.h util.h getopt.h + +glob.obj: glob.c sys.h Util.h RCmd.h Glob.h Xfer.h List.h Main.h + +hostwin.obj: hostwin.c sys.h curses.h Util.h Cmds.h Open.h Hostwin.h + +lgets.obj: lgets.c sys.h util.h lgets.h + +list.obj: list.c sys.h Util.h RCmd.h Xfer.h Cmds.h List.h Glob.h + +linelist.obj: linelist.c sys.h + +macro.obj: macro.c sys.h Util.h Macro.h Cmds.h Cmdline.h MakeArgv.h + +main.obj: main.c sys.h + +makeargv.obj: makeargv.c sys.h util.h makeargv.h + +open.obj: open.c sys.h Open.h Util.h GetPass.h Cmds.h RCmd.h FTP.h Get.h Getopt.h Macro.h Hostwin.h Main.h + +prefs.obj: prefs.c sys.h curses.h wgets.h Util.h Cmds.h Progress.h Hostwin.h Prefs.h RCmd.h Main.h + +progress.obj: progress.c sys.h Util.h Cmds.h Xfer.h Progress.h GetPass.h Main.h curses.h + +put.obj: put.c sys.h Util.h RCmd.h Xfer.h Cmds.h Get.h Getopt.h Glob.h Put.h + +rcmd.obj: rcmd.c sys.h Util.h RCmd.h Open.h Main.h Xfer.h FTP.h + +sio.obj: sio.c sys.h sio.h + +strn.obj: strn.c sys.h strn.h + +tips.obj: tips.c sys.h util.h tips.h + +util.obj: util.c sys.h Util.h Main.h Curses.h + +wgets.obj: wgets.c sys.h util.h curses.h + +win.obj: win.c sys.h Util.h Main.h Version.h RCmd.h LGets.h GetPass.h + +win32.obj: win32.c win32.h + +xfer.obj: xfer.c sys.h Util.h Main.h Xfer.h RCmd.h FTP.h Progress.h Sio.h + +###### +# Maintainance Targets +###### + +clean: + -del *.obj + -del *.tr2 + -del *.exe + -del *.td2 --- /dev/null Thu Jan 11 19:18:08 1996 +++ ncftp-2.4.2-win32/Makefile.vc Tue Apr 29 21:58:02 1997 @@ -0,0 +1,132 @@ +CC=cl.exe -nologo +LINK=link.exe -nologo + +!ifdef DEBUG +CFLAGS= -Od -Z7 -D_DEBUG -D_CONSOLE -DWIN32 -DDOMAINNAME=\"foo.com\" -I. -Ie:\build\pdcurses +LINKFLAGS= -nologo -debug -pdb:none -subsystem:console +!else +CFLAGS= -Od -DNDEBUG -DWIN32 -DDOMAINNAME=\"foo.com\" -I. -Ie:\build\pdcurses +LINKFLAGS= -nologo -release -subsystem:console +!endif + +ENTRYPOINT= + +LIBS=E:\build\pdcurses\win32\pdcurses.lib user32.lib wsock32.lib + +OBJS = bookmark.obj\ + cmdline.obj\ + cmdlist.obj\ + cmds.obj\ + complete.obj\ + cpp.obj\ + datesize.obj\ + ftp.obj\ + get.obj\ + getopt.obj\ + glob.obj\ + hostwin.obj\ + lgets.obj\ + linelist.obj\ + list.obj\ + macro.obj\ + main.obj\ + makeargv.obj\ + open.obj\ + prefs.obj\ + progress.obj\ + put.obj\ + rcmd.obj\ + sio.obj\ + strn.obj\ + tips.obj\ + util.obj\ + wgets.obj\ + win.obj\ + win32.obj\ + xfer.obj + +all: ncftp.exe + +ncftp.exe: $(OBJS) + $(LINK) $(LINKFLAGS) @<< + $(OBJS) -out:ncftp.exe $(LIBS) +<< + +config.h: Config.h.w32 + copy Config.h.w32 config.h + +sys.h: win32.h Util.h Main.h Cmds.h Open.h Cmdline.h DateSize.h Prefs.h FTP.h Getopt.h Xfer.h Tips.h Version.h config.h + touch sys.h + + +bookmark.obj: bookmark.c sys.h util.h bookmark.h ftp.h + +cmdline.obj: cmdline.c sys.h Util.h Cmdline.h Cmds.h Main.h MakeArgv.h Open.h + +cmdlist.obj: cmdlist.c Curses.h Util.h Main.h Open.h Cmds.h Glob.h List.h Get.h Put.h Hostwin.h Prefs.h Cmdline.h + +cmds.obj: cmds.c sys.h Util.h RCmd.h Cmds.h Cmdline.h List.h MakeArgv.h Macro.h Main.h DateSize.h Open.h Glob.h Getopt.h FTP.h Cpp.h Prefs.h Tips.h Version.h + +complete.obj: complete.c sys.h LineList.h Cmdline.h Complete.h Prefs.h Util.h List.h + +cpp.obj: cpp.c sys.h Curses.h Util.h RCmd.h Cpp.h + +datesize.obj: datesize.c sys.h Util.h RCmd.h Cmds.h Xfer.h List.h DateSize.h + +ftp.obj: ftp.c sys.h Util.h FTP.h RCmd.h + +get.obj: get.c Util.h RCmd.h Xfer.h Cmds.h Glob.h Get.h DateSize.h List.h Getopt.h sys.h + +getopt.obj: getopt.c sys.h util.h getopt.h + +glob.obj: glob.c sys.h Util.h RCmd.h Glob.h Xfer.h List.h Main.h + +hostwin.obj: hostwin.c sys.h curses.h Util.h Cmds.h Open.h Hostwin.h + +lgets.obj: lgets.c sys.h util.h lgets.h + +list.obj: list.c sys.h Util.h RCmd.h Xfer.h Cmds.h List.h Glob.h + +linelist.obj: linelist.c sys.h + +macro.obj: macro.c sys.h Util.h Macro.h Cmds.h Cmdline.h MakeArgv.h + +main.obj: main.c sys.h + +makeargv.obj: makeargv.c sys.h util.h makeargv.h + +open.obj: open.c sys.h Open.h Util.h GetPass.h Cmds.h RCmd.h FTP.h Get.h Getopt.h Macro.h Hostwin.h Main.h + +prefs.obj: prefs.c sys.h curses.h wgets.h Util.h Cmds.h Progress.h Hostwin.h Prefs.h RCmd.h Main.h + +progress.obj: progress.c sys.h Util.h Cmds.h Xfer.h Progress.h GetPass.h Main.h curses.h + +put.obj: put.c sys.h Util.h RCmd.h Xfer.h Cmds.h Get.h Getopt.h Glob.h Put.h + +rcmd.obj: rcmd.c sys.h Util.h RCmd.h Open.h Main.h Xfer.h FTP.h + +sio.obj: sio.c sys.h sio.h + +strn.obj: strn.c sys.h strn.h + +tips.obj: tips.c sys.h util.h tips.h + +util.obj: util.c sys.h Util.h Main.h Curses.h + +wgets.obj: wgets.c sys.h util.h curses.h + +win.obj: win.c sys.h Util.h Main.h Version.h RCmd.h LGets.h GetPass.h + +win32.obj: win32.c win32.h + +xfer.obj: xfer.c sys.h Util.h Main.h Xfer.h RCmd.h FTP.h Progress.h Sio.h + +###### +# Maintainance Targets +###### + +clean: + -del *.obj + -del *.tr2 + -del *.exe + -del *.td2 --- /dev/null Thu Jan 11 19:18:08 1996 +++ ncftp-2.4.2-win32/Win32.c Tue Apr 29 23:08:18 1997 @@ -0,0 +1,292 @@ +#include "Win32.h" +#include +#include +#include +#include +#ifdef __BORLANDC__ +# include +#endif +#include +#include "util.h" + +#include "xfer.h" + + +/* we need the real ones here */ + +#undef socket +#undef accept +#undef bind +#undef send +#undef recv +#undef listen +#undef connect +#undef getsockname +#undef setsockopt +#undef closesocket + + +#ifdef __BORLANDC__ +char *getpass(char *); +#endif + +char TitleBarLocation[128] = ""; +char TitleBarFileStatus[128] = ""; +char TitleBarNormal[128] = "NcFTP 2.4.2b1/Win32"; + +#define MAX_ASCII 100 + +int Gettimeofday(struct timeval *timenow) +{ + time_t t; + + t = clock(); + + timenow->tv_usec = t; + timenow->tv_sec = t / CLK_TCK; + + return 0; +} + +char *getwd(char *cwd) +{ + char *returnValue = getcwd(cwd, 64); + + while (strchr(cwd, '\\') != NULL) + *strchr(cwd, '\\') = '/'; + + return returnValue; +} + +/* Empty Stubs */ + +#undef sleep +int sleep(int timetosleep) +{ + return 0; +} + +void Echo(FILE *fp, int on) +{ +} + +int fork(void) +{ + return 0; +} + +void GetPass(char *promptstr, char *answer, size_t siz) +{ +#ifdef __BORLANDC__ + strcpy(answer, getpass(promptstr)); +#else + size_t i = 0; + cputs(promptstr); + while (siz-- != 0) { + answer[i] = _getch(); /* NOT the curses version! */ + switch (answer[i]) { + case '\0': + answer[i] = _getch(); /* NOT the curses version! */ + default: + cputs("*"); + ++i; + break; + case '\r': + case '\n': + answer[i] = '\0'; + return; + } + } +#endif +} + +int alarm(int variable) +{ + return 0; +} + + +#undef pclose +int PClose(FILE *closeFile) +{ + _pclose(closeFile); + SetConsoleTitle(TitleBarLocation); +} + + +#define STRING_SIZE 10240 + +char *filename_completion_function (char *string, int newSet) +{ +#ifdef __BORLANDC__ + static struct ffblk fileInfo; + + char *ptr; + + char pattern[128]; + + if (newSet == 0) + { + strcpy(pattern, string); + strcat(pattern, "*"); + + if (findfirst(pattern, &fileInfo, FA_DIREC)) + return NULL; + } + else + { + if (findnext(&fileInfo)) + return NULL; + } + ptr = (char *)malloc(strlen(fileInfo.ff_name) + 1); + strcpy(ptr, fileInfo.ff_name); + + if (fileInfo.ff_attrib & FA_DIREC) + { + strcat(ptr, "/"); + } + + strlwr(ptr); + + return ptr; +#else +#ifdef _MSC_VER /* Microsoft compilers */ + static struct _finddata_t fileInfo; + static long find_handle = -1; + char *ptr; + char pattern[128]; + + if (newSet == 0 || find_handle == -1) { + strcpy(pattern, string); + strcat(pattern, "*"); + + if (find_handle != -1) + _findclose(find_handle); + if ((find_handle = _findfirst(pattern, &fileInfo)) == -1) + return NULL; + } + else if (_findnext(find_handle, &fileInfo)) { + _findclose(find_handle); + find_handle = -1; + return NULL; + } + ptr = (char *)malloc(strlen(fileInfo.name) + 2); + strcpy(ptr, fileInfo.name); + + if (fileInfo.attrib & _A_SUBDIR) + strcat(ptr, "/"); + + strlwr(ptr); + return ptr; +#endif +#endif +} + +int DoWin32Console(XferSpecPtr xp) +{ + char buffer[128]; + + sprintf(TitleBarFileStatus, + "%s %s", + NETREADING(xp) ? "Receiving" : "Sending", + xp->remoteFileName); + if (xp->frac != 0.0) + { + /* perc = (int) (100.0 * xp->frac); */ + sprintf(buffer, ":%3d%%",(int) (100 * xp->frac)); + strcat(TitleBarFileStatus, buffer); + } + if (xp->remoteFileName != NULL) + SetConsoleTitle(TitleBarFileStatus); +} + +#ifdef __BORLANDC__ +#define OPEN_SOCK(x) _open_osfhandle(x,O_RDWR|O_BINARY) +#else +#define OPEN_SOCK(x) _open_osfhandle(x,_O_RDWR|_O_BINARY) +#endif +#define TO_SOCK(x) _get_osfhandle(x) +#define SOCK_TEST(x, y) if((x) == (y)) errno = WSAGetLastError() +#define SOCK_TEST_ERROR(x) SOCK_TEST(x, SOCKET_ERROR) + +SOCKET +w32_socket(int af, int type, int protocol) +{ + SOCKET s; + if((s = socket(af, type, protocol)) == INVALID_SOCKET) + errno = WSAGetLastError(); + else + s = OPEN_SOCK(s); + return s; +} + +SOCKET +w32_accept(SOCKET s, struct sockaddr *addr, int *addrlen) +{ + SOCKET r; + SOCK_TEST((r = accept(TO_SOCK(s), addr, addrlen)), INVALID_SOCKET); + return OPEN_SOCK(r); +} + +int +w32_bind(SOCKET s, const struct sockaddr *addr, int addrlen) +{ + int r; + SOCK_TEST_ERROR(r = bind(TO_SOCK(s), addr, addrlen)); + return r; +} + +int +w32_connect(SOCKET s, const struct sockaddr *addr, int addrlen) +{ + int r; + SOCK_TEST_ERROR(r = connect(TO_SOCK(s), addr, addrlen)); + return r; +} + +int +w32_getsockname(SOCKET s, struct sockaddr *addr, int *addrlen) +{ + int r; + SOCK_TEST_ERROR(r = getsockname(TO_SOCK(s), addr, addrlen)); + return r; +} + +int +w32_setsockopt(SOCKET s, int level, int optname, const char *optval, int optlen) +{ + int r; + SOCK_TEST_ERROR(r = setsockopt(TO_SOCK(s), level, optname, optval, optlen)); + return r; +} + +int +w32_send(SOCKET s, const char *buf, int len, int flags) +{ + int r; + SOCK_TEST_ERROR(r = send(TO_SOCK(s), buf, len, flags)); + return r; +} + +int +w32_recv(SOCKET s, char *buf, int len, int flags) +{ + int r; + SOCK_TEST_ERROR(r = recv(TO_SOCK(s), buf, len, flags)); + return r; +} + +int +w32_listen(SOCKET s, int backlog) +{ + int r; + SOCK_TEST_ERROR(r = listen(TO_SOCK(s), backlog)); + return r; +} + +int +w32_closesocket(SOCKET s) +{ + return closesocket(TO_SOCK(s)); +} + --- /dev/null Thu Jan 11 19:18:08 1996 +++ ncftp-2.4.2-win32/Win32.h Tue Apr 29 23:10:08 1997 @@ -0,0 +1,125 @@ +#ifndef __REAL_H +#define __REAL_H + +/* #include */ +#include +#include +#include +#include +#include +#include + +/* #include "Xfer.h" */ + +extern char TitleBarLocation[128]; +extern char TitleBarFileStatus[128]; +extern char TitleBarNormal[128]; + +#define PORT_VERSION "2.4.2 - Win32 Beta1" + + +#ifdef __BORLANDC__ +#define S_IRGRP 0 +#define S_IROTH 0 +#include +#endif + +#ifndef WIN32 +# define WIN32 +#endif + +#define DM 242 +#define IP 244 + +#define WILL 251 +#define WONT 252 +#define DO 253 +#define DONT 254 +#define IAC 255 + +#define ENETDOWN WSAENETDOWN +#define ENETUNREACH WSAENETUNREACH +#define ECONNABORTED WSAECONNABORTED +#define ETIMEDOUT WSAETIMEDOUT +#define ECONNREFUSED WSAECONNREFUSED +#define EHOSTDOWN WSAEHOSTDOWN + +int Gettimeofday(struct timeval *timenow); +int alarm(int time); + +#define bcopy(s,d,l) memcpy((d),(s),(l)) +#define bzero(cp,l) memset((cp),0,(l)) + +#endif + +#ifndef __FAKE_H +#define __FAKE_H +#include +#include + +#ifdef __BORLANDC__ +#include +#endif + +#define GETPASS + +#define System "WIN32" + +#define TYPE_A 'A' +#define TYPE_I 'I' +#define TYPE_E 'E' +#define TYPE_L 'L' + + +#define COMPLETE 2 /* Working */ +#define CONTINUE 3 /* Working */ +#define PRELIM 1 /* Not Sure Yet */ + +#define SIGQUIT 1 +#define SIGPIPE 2 +#define SIGALRM 3 + +#define popen _popen +#define pclose _pclose + +#define TRANSIENT 5 + +int fork(void); + +int Getpass(char *something); + +#define getppid getpid + +int PClose(FILE *closeFile); + +/* Added for Local Command Line Completion */ +char *filename_completion_function (char *string, int newSet); + +/*int DoWin32Console(XferSpecPtr xp);*/ + +SOCKET w32_socket(int af, int type, int protocol); +SOCKET w32_accept(SOCKET s, struct sockaddr *addr, int *addrlen); +int w32_bind(SOCKET s, const struct sockaddr *addr, int addrlen); +int w32_connect(SOCKET s, const struct sockaddr *addr, int addrlen); +int w32_send(SOCKET s, const char *buf, int len, int flags); +int w32_recv(SOCKET s, char *buf, int len, int flags); +int w32_listen(SOCKET s, int backlog); +int w32_getsockname(SOCKET s, struct sockaddr *addr, int *addrlen); +int w32_setsockopt(SOCKET s, int level, int optname, const char *optval, int optlen); +int w32_closesocket(SOCKET s); + +#define socket w32_socket +#define accept w32_accept +#define bind w32_bind +#define send w32_send +#define recv w32_recv +#define listen w32_listen +#define connect w32_connect +#define getsockname w32_getsockname +#define setsockopt w32_setsockopt +#define closesocket w32_closesocket + +#endif + + + --- ncftp-2.4.2-dist/README Wed Apr 30 11:46:45 1997 +++ ncftp-2.4.2-win32/README Wed Apr 30 11:53:14 1997 @@ -38,6 +38,9 @@ ./configure make +WindowsNT/Windows95: Ignore the instructions in Part A, and read the + instructions in README.w32 before proceeding. + ncurses: This is a freeware curses library with source, by zmbenhal@netcom.com. Latest version in: ftp://netcom.com/pub/zm/zmbenhal/ncurses/, or --- /dev/null Wed Apr 30 11:46:45 1997 +++ ncftp-2.4.2-win32/README.w32 Wed Apr 30 12:06:32 1997 @@ -0,0 +1,24 @@ +These are instructions for building ncftp on Win32 platforms (WindowsNT +and Windows95) using Visual C++ 2.0-5.0 or Borland C++ 4.x. + +1. Copy either Makefile.vc or Makefile.bcc to Makefile. + +2. Edit the makefile and change the include paths in CFLAGS and + the location of the pdcurses library. You need to have the pdcurses + main header file available as "pdcurses.h". You may also have to change + compile flags if you did not build the pdcurses library with + static C-runtime libs. + +3. Type: + + nmake (VC++, normal build) + nmake DEBUG= (VC++, debug build) + make (BCC, normal build) + make -DDEBUG (BCC, debug build) + +4. Copy ncftp.exe into someplace in your path. The plaintext + manpage is available in ncftp.man. + +pdcurses versions 2.3 or later are known to work. You can get +pdcurses from "http://www.lighlink.com/hessling". + --- /dev/null Wed Apr 30 19:06:42 1997 +++ ncftp-2.4.2-win32/ncftp.man Wed Apr 30 19:08:57 1997 @@ -0,0 +1,1518 @@ + + + +NcFTP(1) User Commands NcFTP(1) + + + +NAME + NcFTP - Internet file transfer program + +SYNOPSIS + ncftp [program options] [[open options] hostname[:pathname]] + +OPTIONS + Program options: + -D : Turn debug mode and trace mode on. + -L : Don't use visual mode (use line mode). + -V : Use visual mode. + -H : Dump the version information. + + Command-line open options: + -a : Open anonymously. + -u : Open with username and password prompt. + -p X : Use port number X when opening. + -r : Redial until connected. + -d X : Redial, delaying X seconds between tries. + -g X : Give up after X redials without connection. + + Command-line retrieve options: + -C : Force continuation (reget). + -f : Force overwrite. + -G : Don't use wildcard matching. + -R : Recursive. Useful for fetching whole directories. + -n X : Get selected files only if X days old or newer. + +DESCRIPTION + NcFTP is a user interface to the Internet standard File + Transfer Protocol. This program allows a user to transfer + files to and from a remote network site, and offers addi­ + tional features that are not found in the standard inter­ + face, ftp. + + The program runs in one of three modes: visual mode, line + mode, and colon mode. + + If your system is somewhat modern, the default mode should + be visual mode. This is a full-screen interface that uses + the curses library. With visual mode, you edit the pro­ + gram's settings with a nice screen interface instead of typ­ + ing arcane commands. + + If you are not in visual mode, you will be using line mode + for the interactive shell. This mode is a no-frills com­ + mand-line interface that will look like the default ftp pro­ + gram's command shell. + + The third mode, colon mode, refers to the program's ability + to do a quick retrieve of a file directly from your shell + command line, without going into the program's own shell. + + + +NCEMRSoft Last change: 2.4.2 1 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + This mode is useful for shell scripts. + +INTRODUCTION TO VISUAL MODE + When entering visual mode, the screen clears and is rewrit­ + ten with the splash screen. You should see the black status + bar occupying the second to last row on the screen. Beneath + the status bar is the input line, where you type commands to + the program's shell. + + The program then waits for you to do something. Usually + this means you want to open a remote filesystem to transfer + files to and from your local machine's filesystem. To do + that, you need to know the symbolic name of the remote sys­ + tem, or its Internet Protocol (IP) address. For example, a + symbolic name might be ``typhoon.unl.edu,'' and its IP + address could be ``129.93.33.24.'' To open a connection to + that system, you use the program's open command: + + open typhoon.unl.edu + open 129.93.33.24 + + Both of these try to open the machine called typhoon at the + University of Nebraska. Using the symbolic name is the pre­ + ferred way, because IP addresses may change without notice, + while the symbolic names usually stay the same. + + When you open a remote filesystem, you need to have permis­ + sion. The FTP Protocol's authentication system is very sim­ + ilar to that of logging in to your account. You have to + give an account name, and its password for access to that + account's files. However, most remote systems that have + anything you might be interested in don't require an account + name for use. You can often get anonymous access to a + remote filesystem and exchange files that have been made + publicly accessible. The program attempts to get anonymous + permission to a remote system by default. What actually + happens is that the program tries to use ``anonymous'' as + the account name, and when prompted for a password, uses + your E-mail address as a courtesy to the remote system's + maintainer. You can have the program try to use a specific + account also. That will be explained later. + + If the connection succeeded, you should see the status bar + change to hold the remote system's name on one side, and the + current remote directory on the other side. To see what's + in the current remote directory, you can use the program's + ls and dir commands. The former is terse, preferring more + remote files in less screen space, and the latter is more + verbose, giving detailed information about each item in the + directory. + + + + + +NCEMRSoft Last change: 2.4.2 2 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + You can use the program's cd command to move to other direc­ + tories on the remote system. The cd command behaves very + much like the command of the same name in the Bourne and + Korn shell. + + The purpose of the program is to exchange data with other + systems. You can use the program's get command to copy a + file from the remote system to your local system: + + get README.txt + + The program will display the progress of the transfer on the + screen, so you can tell how much needs to be done before the + transfer finishes. When the transfer does finish, then you + can enter more commands to the program's command shell. + + You can use the program's put command to copy a file from + your system to the remote system: + + put something.tar + + When you are finished using the remote system, you can open + another one or use the quit command to terminate the pro­ + gram. + +THE BOOKMARKS FILE + One of the program's goals is to minimize typing and maxi­ + mize convenience. The program automatically saves informa­ + tion about the sites you call on in a special file called + the bookmarks file, which is stored in the .ncftp subdirec­ + tory of your home directory. Each bookmark saves the host + name along with other settings, including the remote direc­ + tory you were in, the account information, and more. This + makes it easy to call back a site later and have everything + be like it was when you left the last time. + + A big advantage of saving this information is that you can + refer to a site by a shorter, more meaningful name, instead + of using the full symbolic host name for a site. For exam­ + ple, if you called a site named ``typhoon.unl.edu'' fre­ + quently, its bookmark name might be just ``typhoon.'' Then, + instead of: + + open typhoon.unl.edu + + you could use: + + open typhoon + + You could also abbreviate the bookmark name further, as long + as the program will know which site you are referring to. + If no other bookmark's name starts with the letters ``ty,'' + + + +NCEMRSoft Last change: 2.4.2 3 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + you could do just: + + open ty + + Use the bookmarking feature to assign mnemonic names to + hosts whose real names don't give much hint to what you call + there for. A popular game called Nethack is archived at + linc.cis.upenn.edu, in the /pub/NH3.1 directory. You could + assign ``nethack'' as the bookmark name for this site. Then + you could try: + + open nethack + + instead of: + + open linc.cis.upenn.edu + +USING THE BOOKMARK EDITOR + To manipulate the bookmarks stored in your bookmarks file, + you use the program's bookmark editor. Run the bookmark + editor by typing the bookmarks command from within the pro­ + gram. This brings up a new screen of information. + + On the right side is the list of remote systems the program + has saved for you already. Each time you open a connection + to a remote system, the program saves an entry in your book­ + mark file for you automatically. If you have not opened any + sites successfully yet, this list would be empty. + + On the left side is some instructions saying what you can do + with the list. The bookmark editor is waiting for you to do + something, like select a bookmark whose settings you want to + edit. + + Some bookmark editor ``hot key'' commands are one key only. + You do not need to hit enter after the hot key commands. To + exit the bookmark editor for example, you would just type + the ``x'' key only. The multi-key commands require a slash + first and do require the enter key. To delete the selected + site, for example, you would type the ``/'' key, then + ``del,'' and then the enter key. + + You can use the ``d'' key to move down one line in the list, + and the ``u'' key to move up one line. If you have many + entries in the bookmark list, you won't be able to see them + all at once. The bookmark list scrolls as appropriate to + bring the other sites into view. Use the ``p'' and ``n'' + keys to move pages at a time. + + Another way to select a site in the bookmark list is to use + the capital letters. If I had many entries in my bookmark + list, but wanted to select a site whose bookmark name was + + + +NCEMRSoft Last change: 2.4.2 4 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + ``nethack,'' I could type ``N'' and the list would zoom to + the first site with bookmark starting with the letter ``n.'' + + After you have hilited a bookmark you want to edit, use the + /ed command. Doing that brings up another screen with the + settings for that bookmark. + + In the Bookmark Options screen, you use hot keys to select a + setting to edit. To edit the bookmark name, for example, + you would type ``a.'' When you are finished editing this + bookmark, hit the ``x'' key to return to the bookmark edi­ + tor's screen. + +BOOKMARK OPTIONS + Edit the Bookmark name field to change the name you use to + open this site with. Remember, when you change the bookmark + name , you must use this name to refer to this particular + bookmark, so if you change it to ``foobar,'' you need to use + ``open foobar.'' This is required because you can have mul­ + tiple entries for a remote host. For example, you could + have two bookmarks for wuarchive.wustl.edu, named ``wumac'' + and ``wuwindows.'' If you were to say ``open + wuarchive.wustl.edu,'' it would not be clear to the program + which host entry to use. + + Change the login information for the site by editing the + User, Password, and Account fields. Normally you would want + to leave these as is for anonymous logins. Depending on + your situation, you might want to use a specific account on + the remote system. This is one way to get the program to + use a non-anonymous login. + + The Directory field specifies the directory to move to upon + successful connection to the remote host for this bookmark. + When you close the site, this field is updated for you auto­ + matically to be the directory you were in when you closed + the site. + + The Transfer Type field can be changed to use a different + translation mode when transferring files. This program is + usually running on a UNIX system, and most remote systems + are also UNIX variants, so the default transfer type is + binary, which does no translation at all. + + However, when you need to work with plain text files and + transfer them between non-UNIX systems, you can change this + to ASCII. That will guarantee that the text-only files will + translate correctly. Most often, you will need to use the + binary transfer type. + + The Port field can be changed so that the program tries to + use a non-standard port number. I have yet to ever need a + + + +NCEMRSoft Last change: 2.4.2 5 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + different port number, but this capability is here in case + it's needed. + + The Has SIZE Command field will probably not need to be + edited. This field is mostly for your information only. + The SIZE command is an FTP Protocol command that the program + would like the remote server to support. If it is sup­ + ported, the program can get an exact number of bytes of + remote files before transferring. That is nice to know so + the progress reports work better. + + The Has MDTM Command field will probably not need to be + edited either. If the remote server supports it, the pro­ + gram can get the exact modification date of the remote file, + and set the local file to the same date. + + The Can Use Passive FTP field specifies whether the remote + server allows use of the FTP Protocol's PASV command. There + are two ways to set up FTP connections. The default way is + what I call Port FTP. Unfortunately, Port FTP cannot be + used when your local host is hiding behind a Firewall. Pas­ + sive FTP can be used with a firewall, and that's why I would + like to use that method if possible. You probably will not + need to edit this field, since this can be detected automat­ + ically most of the time. + + The Operating System field is used by the program to tell if + it can rely on certain dependencies to specific operating + systems. If the OS is a UNIX variant, the program can make + some assumptions about the remote server's responses. For + example, if the OS is UNIX, the ls command tries to use the + -CF flags, like you could with ``/bin/ls -CF'' on UNIX. If + the OS wasn't UNIX, the ``-CF'' might not make sense to the + remote server and it might complain. You probably will not + need to edit this field, since this can be detected automat­ + ically most of the time. + + The comment field can be used to store a brief description + about the site. For example, for my ``nethack'' entry, I + could use this field to hold ``Archive site for latest ver­ + sion of Nethack.'' When you are in the bookmark editor's + window, if you hilite a site that has a comment, it is + printed at the bottom of the screen so you do not have to + edit the site to look at it. + +PREFERENCES + In addition to remote-host specific options, the program has + global options that are user-configurable. To change the + program's preferences, run the prefs command from within the + program. + + + + + +NCEMRSoft Last change: 2.4.2 6 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + The Default open mode field specifies how the program should + try to open connections. If you do a lot of anonymous + FTPing, you should leave this set to anonymous. You might + want to set this field to user & password if the hosts you + FTP to most often don't allow anonymous logins. For exam­ + ple, if you are using the program on your company network to + copy things from different company machines, you would not + want to use anonymous FTP mode. + + The Anonymous password field lets you change the value given + to the remote host when you use an anonymous login. It is + customary (and sometimes required) to use your e-mail + address as the password for anonymous FTP, so the remote + host's administrator knows who is using the service. If the + program didn't get your e-mail address right, or you want to + use something different, you can change it here. + + The program now uses more whitespace than before to reduce + eyestrain. If you prefer, you can turn off that feature by + changing the Blank lines between cmds field. + + The program can log the transfers you do to a file so you + can refer to the log if you can't remember where you got + something. To turn on the log, which is saved as + ~/.ncftp/log, you can set the User log size field to a num­ + ber greater than zero. You probably do not want to let this + file grow forever, so you set the maximum size of the log by + setting that field. + + Although the program is perfectly happy saving every site + you ever open in the bookmarks file, you may want to put an + upper bound on the number of sites saved. If you have a + slow machine, which might cause the program to take awhile + to load and save the bookmarks, or if disk space is at a + premium, you can set the Max bookmarks to save field to + limit the number of bookmarks saved. Once that limit is + reached, the program will discard sites whose time since the + last connection is the longest. In other words, a site you + only called once a long time ago and forgot about will be + the first to go. + + A few program functions need to use a pager program to view + large amounts of text. For example, the page command + retrieves a remote file and uses the pager to view it. You + can specify the program to use (and its command line flags, + if any) by setting the pager field. + + When you transfer files between the remote host and your + local host, the program uses a progress meter to show you + the status of the transfer. The program has a few different + progress meters to choose from, and you can try out the + other ones by changing the Progress meter field. + + + +NCEMRSoft Last change: 2.4.2 7 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + You can control how much of the remote server's chatter is + printed by changing the Remote messages field. The program + always prints error messages, but most of the time the + remote server doesn't have anything useful to say. There + are a couple of messages that may be worth printing. The + first is the startup message. Typically, when you connect + to a server it has some important information about the + server. Some servers have chdir messages, which are sent + when you enter a special directory. You specify whether to + print these messages by toggling the Remote messages field. + + By default, the program stays in the same directory you were + in when you ran the program, so that downloads will go in + that directory. I like to use a ``download directory'' so + that all of my downloads go to a specific directory. This + prevents me from exceeding my quota, and overwriting my + other files. You can set the Startup in Local Dir field to + have the program change the local directory each time when + the program starts up. Then you know where to expect your + downloads to end up. + + The program itself has some messages which you may get tired + of and want to turn off. You can change the Startup mes­ + sages field to specify whether the program prints its + ``splash screen'' and whether it prints a tip on how to max­ + imize use of the program. + + When you retrieve a remote file, by default the program + tries to also set the exact modification time of the local + file as the remote file. You can turn that off by changing + the File timestamps field. + + If you don't like the full-screen graphics, you can use the + line-oriented mode by changing the Screen graphics field. + Once you turn visual mode off from the Preferences screen, + you won't be able to get back to the preferences screen + again when using line mode. To get back into visual mode, + you can run the program with the ``-V'' flag, like: + + ncftp -V + +COMMAND REFERENCE + I will now describe the commands that the program's command + shell supports. The first command to know is help. If you + just type + + help + + from the command shell, the program prints the names of all + of the supported commands. From there, you can get specific + help for a command by typing the command after, for example: + + + + +NCEMRSoft Last change: 2.4.2 8 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + help open + + prints information about the open command. + + The shell escape command is simply the exclamation point, ! + To spawn a shell, just do: + + ! + + You can also use this to do one command only, like: + + !date +%H:%M:%S + + The cd command changes the working directory on the remote + host. Use this command to move to different areas on the + remote server. If you just opened a new site, you might be + in the root directory. Perhaps there was a directory called + ``/pub/news/comp.sources.d'' that someone told you about. + From the root directory, you could: + + cd pub + cd news + cd comp.sources.d + + or, more concisely, + + cd /pub/news/comp.sources.d + + Then, commands such as get, put, and ls could be used to + refer to items in that directory. + + Some shells in the UNIX environment have a feature I like, + which is switching to the previous directory. Like those + shells, you can do: + + cd - + + to change to the last directory you were in. + + The close command disconnects you from the remote server. + The program does this for you automatically when needed, so + you can simply open other sites or quit the program without + worrying about closing the connection by hand. + + Sometimes it may be necessary to use the create command. + This makes an empty file on the remote host. This can be + useful when you are unable to contact the remote server's + administrator, but hope someone in the know will spot your + file. For example, + + create readline2.0.tar_is_corrupt + + + + +NCEMRSoft Last change: 2.4.2 9 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + might persuade someone to repost that file. + + The debug command is mostly for use by me and the testers. + You could type + + debug 1 + + to turn debugging mode on. Then you could see all messages + between the program and the remote server, and things I + print only in debugging mode. If you report a bug, I might + ask you to send me a trace file. To do that, you would run + the program, and then type + + debug trace 1 + + And so I could see how the program was compiled, you would + type + + version + + After you quit the program, you could then send me an email + with the contents of the ~/.ncftp/trace file, which would + also have the version information in it. + + The dir command prints a detailed directory listing. It + tries to behave like UNIX's ``/bin/ls -l'' command. If the + remote server seems to be a UNIX host, you can also use the + same flags you would with ls, for instance + + dir -rt + + would try to act like + + /bin/ls -lrt + + would on UNIX. + + The echo command wouldn't seem very useful, but it can be + nice for use with the program's macros. It behaves like the + equivalent command does under a UNIX shell, but accepts some + extra flags. All ``percent'' flags are fed through + strftime(4). So you could type + + echo It is now %H:%M on %B %d. + + and you should get something like this printed on your + screen: + + It is now 19:00 on January 22. + + There are also ``at'' flags, which the program expands: + + + + +NCEMRSoft Last change: 2.4.2 10 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + @H : Name of connected host + @D : Full pathname of remote current working directory + @J : Short name of remote current working directory + @N : Newline. + @n : Bookmark name of connected host + + Example: + + echo "Connected to @H at %H:%M." >> junk + + If you later looked at the contents of ``junk,'' it might + say: + + Connected to sphygmomanometer.unl.edu at 20:37. + + The get command copies files from the current working direc­ + tory on the remote host to your machine's current working + directory. To place a copy of ``README'' in your local + directory, you could try: + + get README + + The get command has some powerful features which are + described below, in ``SPECIAL DOWNLOADING FEATURES.'' + + The bookmarks command runs the Bookmark Editor. You already + know how what that does, since you read the section above on + it, right? + + The lcd command is the first of a few ``l'' commands that + work with the local host. This changes the current working + directory on the local host. If you want to download files + into a different local directory, you could use lcd to + change to that directory and then do your downloads. + + Another local command that comes in handy is the lls com­ + mand, which runs ``/bin/ls'' on the local host and displays + the results in the program's window. You can use the same + flags with lls as you would in your command shell, so you + can do things like: + + lcd ~/doc + lls -lrt p*.txt + + The program also has a built-in interface to the name ser­ + vice via the lookup command. This means you can lookup + entries for remote hosts, like: + + lookup cse.unl.edu ftp.cs.unl.edu sphygmomanometer.unl.edu + + prints: + + + + +NCEMRSoft Last change: 2.4.2 11 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + cse.unl.edu 129.93.33.1 + typhoon.unl.edu 129.93.33.24 + sphygmomanometer.unl.edu 129.93.33.126 + + There is also a more detailed option, enabled with ``-v,'' + i.e.: + + lookup -v cse.unl.edu ftp.cs.unl.edu + + prints: + + cse.unl.edu: + Name: cse.unl.edu + Address: 129.93.33.1 + + ftp.cs.unl.edu: + Name: typhoon.unl.edu + Alias: ftp.cs.unl.edu + Address: 129.93.33.24 + + You can also give IP addresses, so this would work too: + + lookup 129.93.33.24 + + prints: + + typhoon.unl.edu 129.93.33.24 + + The lpage command views a local file one page at a time. By + default, the program uses your pager program to view the + files. You can choose to use the built-in pager by using + the ``-b'' flag. Example: + + lpage -b ~/.ncftp/bookmarks + + The lpwd command is prints the current local directory. Use + this command when you forget where you are on your local + machine. + + The ls command prints a brief directory listing. It tries + to behave like UNIX's ``/bin/ls -CF'' command. If the + remote server seems to be a UNIX host, you can also use the + same flags you would with ls, for instance + + ls -rt + + would try to act like + + /bin/ls -CFrt + + would on UNIX. + + + + +NCEMRSoft Last change: 2.4.2 12 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + The mkdir command tries to create a new directory on the + remote host. For many public archives, you won't have the + proper access permissions to do that. + + Some servers let you use different transfer modes. Most + servers support only the default mode, which is stream mode. + The program supports that mode and also block mode. The + primary advantage to using this mode is that you can use the + same data connection for all your transfers. With stream + mode the program and server must establish a new data con­ + nection for each file, and doing that takes extra time and + bandwidth. To use the mode command to turn on block mode, + you would type + + mode b + + and the command to use stream mode would be + + mode s + + The program turns on block mode automatically when it knows + the remote server supports it and implements it correctly, + so you should not need to use this command. + + The open command connects you to a remote host. Many times, + you will simply open a host without using any flags, but + nonetheless the open command has some flags to enable cer­ + tain features. + + To force an anonymous open, use the ``-a'' flag. On the + ftp.probe.net machine, which is the official archive site + for NcFTP, I have a need to use both anonymous logins and + user logins. The Bookmark Editor remembers type of login I + used last, so if the last time was a user login, I could use + the ``-a'' flag to switch back to the anonymous login type + without having to use the Bookmark Editor to change that. + + Likewise, I could use the ``-u'' flag to force a user open. + Then I could give my account name and password to access + that account. + + Many of the big archive sites like wuarchive.wustl.edu are + busy, so you aren't guaranteed a connection to them. The + program lets you ``redial'' sites periodically, until a con­ + nection succeeds. Use the ``-r' flag to turn on automatic + redial. + + Redial itself has a few parameters. You can set the delay, + in seconds, of the time spent waiting between redials. You + can also have the program give up after a maximum number of + redials is reached. Here's an example that fully utilizes + redial mode: + + + +NCEMRSoft Last change: 2.4.2 13 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + open -r -d 75 -g 10 bowser.nintendo.co.jp + + The ``-r'' turns on redialing, the ``-d'' sets the redial + delay to 75 seconds, and the ``-g'' flag limits redialing to + 10 tries. If you like, you can just trust the default + redial settings and only use ``-r.'' + + The open command will run the Bookmark Editor if you don't + supply a hostname to open. You can use the Bookmark Editor + to select a host and open it by hitting the return key. + + The page command lets you browse a remote file one page at a + time. This is useful for reading README's on the remote + host without downloading them first. This command uses + whatever program you have set the pager field in the Prefer­ + ences screen to view the file. + + The pdir and pls commands are equivalent to dir and ls + respectively, only they feed their output to your pager. + These commands are primarily for line mode because directory + listings can scroll offscreen. If you do a normal ls while + in visual mode, if it would go offscreen, the built-in pager + kicks in automatically. Therefore I don't recommend using + pdir and pls while in visual mode. + + The redir and predir commands give you a way to re-display + the last directory listing. The program saves the output + from the last dir or ls command you did, so if you want to + see it again you can do this without wasting network band­ + width. The predir command is the same as redir, except that + the output is fed to your pager. + + I have found that I mostly download, and have next to no + need at all to upload. But the put command is there in case + you need to upload files to remote hosts. For example, if I + wanted to send some files to a remote host, I could do: + + lcd ~/docs/files + put 02.txt 03.txt 05.txt 07.txt 11.txt + + The put command won't work if you don't have the proper + access permissions on the remote host. Also, this command + doesn't have any of the special features that the get com­ + mand has, except for the ``-z'' option. + + The pwd command prints the current remote working directory. + In visual mode, this is in the status bar. + + If you need to change the name of a remote file, you can use + the rename command, like: + + rename SPHYGMTR.TAR sphygmomanometer-2.3.1.tar + + + +NCEMRSoft Last change: 2.4.2 14 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + Of course, when you finish using the program, type quit to + end the program (You could also use bye, exit, or ^D). + + The quote command can be used to send a direct FTP Protocol + command to the remote server. Generally this isn't too use­ + ful to the average user (or me either). + + The rhelp command sends a help request to the remote server. + The list of FTP Protocol commands is often printed, and + sometimes some other information that is actually useful, + like how to reach the site administrator. + + Depending on the remote server, you may be able to give a + parameter to the server also, like: + + rhelp NLST + + One server responded: + + Syntax: NLST [ path-name ] + + If you need to delete a remote file you can try the rm com­ + mand. Much of the time this won't work because you won't + have the proper access permissions. This command doesn't + accept any flags, so you can't nuke a whole tree by using + ``-rf'' flags like you can on UNIX. + + Similarly, the rmdir command removes a directory. Depending + on the remote server, you may be able to remove a non-empty + directory, so be careful. + + The set command is provided for backward compatibility with + older versions of the program, and is superseded by the + prefs command. The basic syntax is: + + set option value + + Where the option is the short name of the corresponding + field in the Preferences screen. The short names of the + preferences fields can be found by browsing your + ~/.ncftp/prefs file. This command is mainly for use with + line mode, but since that mode is no longer officially sup­ + ported by me, I want to discourage the use of this command. + + One obscure command you may have to use someday is site. + The FTP Protocol allows for ``site specific'' commands. + These ``site'' commands vary of course, but one common sub- + command that is useful that some sites support is chmod, + i.e.: + + site chmod 644 README + + + + +NCEMRSoft Last change: 2.4.2 15 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + Try doing one of these to see what the remote server sup­ + ports, if any: + + rhelp SITE + site help + + You may need to change transfer types during the course of a + session with a server. You can use the type command to do + this. Try one of these: + + type ascii + type binary + type image + + If you ever need to contact me about the program, please + familiarize yourself with the version command. This command + dumps a lot of information that tells me which edition of + the program you are using, and how it was installed on your + system. Here's a way to save the output of this command to + a file, so you can send it to me: + + version > version.txt + +SPECIAL DOWNLOADING FEATURES + You probably already know that you use the get command to + copy files on the remote host to the local host. But the + get command has a few other tricks that you might find use­ + ful. First of all, ncftp skips files you already have. If + you try to + + get file24 + + and there is a file named ``file24'' in the current local + directory already, the program uses some additional heuris­ + tics to determine if it should actually waste network band­ + width to download it again. + + The program tries to get the date and size of the remote + file ``file24.'' If that file has the exact same date and + size as the local file ``file24,'' the program will skip + over that file. If the program could not get the date or + size of the remote file, or the size differs, the program + will go ahead and fetch the file. + + In addition, if the local file's date is newer than the + remote file's date, the program skips the download because + it concludes you already have a more recent version. + + What all this means for you is that you can use the program + to mirror another archive. For example, you might have a + task that requires you keep a mirror of all the files of a + remote directory called ``files.'' In that directory, there + + + +NCEMRSoft Last change: 2.4.2 16 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + might be dozens of files, some of which are updated occa­ + sionally. You could use ncftp to help you out by setting + the appropriate local and remote directories, then simply + doing: + + get * + + The program will skip over the old files, and only download + the files that you don't have or have been updated since the + last time. + + Nonetheless, you may want to ignore the program's advice and + download a file anyway, despite the program's thinking that + you don't need to. You can use the ``-f'' flag with get to + force a download: + + get -f README + + You may also need to use the ``-C'' flag to force the pro­ + gram to continue downloading where it left off. I sometimes + call that feature ``forced reget'' for historical reasons. + + You can also turn off wildcard matching with get by using + the ``-G'' flag. Other FTP programs used the syntax + + get remote-file [local-file] + + which allowed you to specify a local pathname for the file + you were trying to download. NcFTP differs in that respect, + and if you used the older programs, you would find that the + program's get behaves more like those other program's mget + command. This means that in NcFTP,that + + get file01 file02 + + tries to download remote files named ``file01'' and + ``file02.'' If you like, you can get that older behavior by + using the ``-z'' flag, so: + + get -z file01 ../junk/files/01.txt + + would get ``file01'' and use the local name + ``../junk/files/01.txt.'' + + Another thing that get does is that you can use the ``-n'' + flag to fetch files that are a certain number of days old or + newer. If you just want to get the newest files at an + archive, you don't have to use a full mirror. You can just + say ``download all files that are 3 days old or newer.'' Do + that by going to a directory, and trying: + + get -n 3 * + + + +NCEMRSoft Last change: 2.4.2 17 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + The program also has ``reget'' mode built into the get com­ + mand. Other FTP programs provided a reget command, which + was useful when you lost a connection during a download. + Instead of the remote host resending the entire file, you + could use the reget command to continue the transfer where + it was cut off. + + NcFTP has this capability built-in, and it examines the date + and size of the remote file and local file to determine if + the program should continue where it left off last time. If + the dates are the same, but the local file is smaller, the + program attempts to ``reget.'' + + The last, and most wasteful feature of get is recursive + mode, which is turned on with the ``-R'' flag. This feature + lets you download an entire directory's contents, i.e.: + + get -R /pub/info/help + + That creates a directory called ``./help'' in the current + local directory, and copies all files and subdirectories + into it. + + Please use some discretion with this feature. If you get a + large directory, you could really bog down the remote host. + Archive administrators are providing a public service, so + don't abuse the archive so much that they have to shut down + public access because the real users of that archive can't + get their work done. + +MACROS + The program has a simple macro/alias facility. You can use + macros to roll your own commands, or do things when certain + events happen. + + To use macros, you will need to create and edit the macros + file in your .ncftp subdirectory of your home directory. + Your ~/.ncftp directory is created for you automatically the + first time you run the program, but you have to make the + macros file yourself since most users won't have a need for + them. + + You can have any number of macros. The syntax is: + + macro macro-name + macro-body... + end + + Here's a simple macro that users of the old ftp program + might appreciate: + + macro binary + + + +NCEMRSoft Last change: 2.4.2 18 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + type i + end + + You could run that macro simply by running the program and + typing the macro name as if it were a regular ncftp command. + + Macros can also have parameters, much like the Korn Shell's + shell functions and the C-Shell's aliases. These parameters + are sent to your macro, and if your macro uses the appropri­ + ate ``dollar'' variables, they are expanded. To illustrate, + try this macro: + + macro cdls + cd $1 + ls + end + + To run that macro, open a connection and try: + + cdls /pub + + That would try to cd to /pub, and then try to list its con­ + tents with ls. + + Dollar variables are somewhat like those in the Bourne and + Korn shells. Example syntax: + + $4 : Argument 4 + $* : All arguments. + $@ : All arguments, each of them surrounded by double quotes. + $(2-5) : Arguments 2, 3, 4, and 5. + $(2,5) : Arguments 2 and 5. + $(3+) : Arguments 3, 4, 5, ..., N. + + A better way to code the ``cdls'' macro might be: + + macro cdls + cd $1 + ls $(2+) + end + + There are some special macros, which I call event macros. + The program looks for macros by special names, and if they + exist, runs the macro when that event happens. + + One event macro is the .start.ncftp macro. If you have a + macro by that name defined in your macros file, the program + will run that macro each time you run the program. + + Similarly, there is also a .quit.ncftp macro that is run + each time you quit the program. + + + + +NCEMRSoft Last change: 2.4.2 19 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + Another set of event macros are site-specific. For example, + if I have a site bookmarked as ``typhoon'' I could then + define macros named .open.typhoon and .close.typhoon which + would run each time I opened and closed ``typhoon.'' + + Another, more generic set of event macros are the .open.any + and .close.any macros which run when I open or close any + site. One possible use for these macros is to run separate + shell scripts to do some processing after you finish using a + site. I could have a macro like this: + + macro .quit.ncftp + echo "Started post-processing downloads at %H:%M:%S" + !sh ~/scripts/download-decoder + echo "Finished post-processing downloads at %H:%M:%S" + end + + Another use is to duplicate the old macdef init hack that + the traditional ftp program used in its .netrc file. For + example: + + macro .open.infomac + echo "Getting recent files list" + get -z /pub/info-mac/help/recent-files ~/docs/recent + ls -lrt + end + +USING COLON MODE + The colon-mode feature is used from your shell's command + line. + + In ancient times, way back during the Disco Era, you could + use a program called tftp to fetch a file using the Internet + standard Trivial File Transfer Protocol. You could use that + program to do something like this from within its shell: + + get wuarchive.wustl.edu:/graphics/gif/README + + and that would call wuarchive and fetch the README file. + + You can use this program to do the same thing from your + shell's command line: + + csh> ncftp wuarchive.wustl.edu:/graphics/gif/README + csh> head README + + This tells your shell, in this case the C-shell to run + NcFTP, which would open wuarchive, fetch /graph­ + ics/gif/README and write the file /README in the current + working directory, and then exits. + + + + + +NCEMRSoft Last change: 2.4.2 20 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + The colon-mode feature is nice if you don't want to browse + around the remote site, and you know exactly want you want. + It also comes in handy in shell scripts, where you don't + want to enter the command shell, and might not want the pro­ + gram to spew output. + + You can use the Uniform Resource Locator standard also. For + example, this would work: + + csh> ncftp ftp://wuarchive.wustl.edu/graphics/gif/README + + There are times where you might not want the program to + write a colon-mode file in the current working directory, or + perhaps you want to pipe the output of a remote file into + something else. Colon-mode has options to do this. It was + inspired by the guy who wrote the ftpcat perl script. The + ``-c'' option tells the program to write on the standard + output stream. The ``-m'' option pipes the file into your + pager (like more) Of course this won't work if the thing you + give colon-mode is a directory! This example just dumps a + remote file to stdout: + + csh> ncftp -c wuarc:/graphics/gif/README + + This example redirects a remote file into a different loca­ + tion: + + csh> ncftp -c wu:/README > ~pdietz/thesis.tex + + This one shows how to use a pipeline: + + csh> ncftp -c wuarc:/README | tail | wc -l + 10 + csh> + + This shows how to page a remote file: + + csh> ncftp -m wuarc:/graphics/gif/README + +USING LINE MODE + The only reason I provide line mode is so that the primitive + operating systems whose curses library is missing or dys­ + functional won't render the program completely useless. + + exceptions of the functions that require visual mode, such + as the Preferences screen and the Bookmark Editor. You will + have to edit the ~/.ncftp/prefs and ~/.ncftp/bookmarks file + manually, with a text editor. + + As a small consolation, you get to use the full-powered + line-editing libraries, like GNU Readline if they were com­ + piled with the program. + + + +NCEMRSoft Last change: 2.4.2 21 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + +SUMMARY OF COMMAND LINE OPTIONS + When you invoke the program from your shell, there are + ``dash flags'' you can use like you can with most other UNIX + programs. + + Here's a list of options you can use from the command line: + + -D : Turns on debugging mode and tracing. + -V : Uses ``visual'' mode for this session. + -L : Uses ``line mode'' for this session. + -H : Prints the information from the ``version'' command and exits. + + When you turn on tracing, the program writes a log with + debugging information to a file called trace in your .ncftp + subdirectory of your home directory. If you need to report + a bug, it would be helpful to mail me the trace file so I + can track it down better. + + In addition to the program flags, you can also use flags + from the open and get commands with a colon mode path. + Here's a really complex example: + + csh> ncftp -r -d 120 -n 3 sphygmomanometer.unl.edu:/pub/stuff/* + + This tries redialing that host every two minutes, and fetch­ + ing all files from the ``/pub/stuff'' directory that are 3 + days old or newer. + +AUTHOR + NcFTP was written by Mike Gleason, NCEMRSoft (mglea­ + son@probe.net). NcFTP is copyrighted 1995 by NCEMRSoft. + All rights reserved. + + As of this writing, the most recent version is archived in + /pub/ncftp, on ftp.probe.net. + +THANKS + Ideas and some code contributed by my partner, Phil Dietz, + NCEMRSoft (dietz@wtc.com). + + Thanks to everyone who has helped test the program, and sent + in feedback over the years. Your support is what drives me + to improve the program! + + I'd like to thank my former system administrators, most + notably Charles Daniel, for making testing on a variety of + platforms possible, letting me have some extra disk space, + and for maintaining the UNL FTP site. + + I also thank Dale Botkin and Tim Russell at Probe + Technology, for giving ncftp a home on probe.net, the mid­ + west's best connection to the internet. + + + +NCEMRSoft Last change: 2.4.2 22 + + + + + + +NcFTP(1) User Commands NcFTP(1) + + + + For testing above and beyond the call of duty, I am espe­ + cially grateful to: Phil Dietz, Kok Hon Yin + (hkok@cse.unl.edu), Andrey A. Chernov (ache@astral.msk.su). + + Thanks to Tim MacKenzie (t.mackenzie@trl.oz.au) for the + filename completion code. + + Thanks to DaviD W. Sanderson (dws@ssec.wisc.edu), for help­ + ing me out with the man page. + +BUGS + Due to a limitation in the curses library, scrolling may be + slow in visual mode. + + Shell escapes, suspending (^Z) and resuming, and interruping + (^C) still have quirks with visual mode. + + There are no such sites named bowser.nintendo.co.jp or + sphygmomanometer.unl.edu. + +SEE ALSO + ftp(1), ftpd(8), nslookup(1), archie(1), rcp(1), tftp(1). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +NCEMRSoft Last change: 2.4.2 23 + + + --- ncftp-2.4.2-dist/Xfer.c Thu May 01 15:13:44 1997 +++ ncftp-2.4.2-win32/Xfer.c Thu May 01 18:21:33 1997 @@ -286,7 +286,7 @@ nread = (*gNetReadProc) (xp); if (nread <= 0) break; - +#ifndef WIN32 /* In ASCII mode, all end-of-lines are denoted by CR/LF. * For UNIX, we don't want that, we want just LFs, so * skip all the CR's. @@ -296,7 +296,7 @@ *o++ = *i; } nread = (int) (o - xbuf); - +#endif nwrote = Swrite(fd, xbuf, nread, gNetworkTimeout); if (nwrote <= 0) break; @@ -349,7 +349,15 @@ lim = cp1 + nread; cp2 = gXferBuf; while (cp1 < lim) { - if (*cp1 == '\n') + /* We read the file in binary mode on WIN32. Which + * means we should not convert lines which are already + * CR-LF terminated on that platform. + */ + if (*cp1 == '\n' +#ifdef WIN32 + && (cp1 == gAsciiSendBuf || *(cp1-1) != '\r') +#endif + ) *cp2++ = '\r'; *cp2++ = *cp1++; }