home *** CD-ROM | disk | FTP | other *** search
Wrap
Newsgroups: comp.sources.misc From: mgleason@cse.unl.edu (Michael Gleason) Subject: v35i007: ncftp - Alternative User Interface for FTP, Part04/04 Message-ID: <1993Jan25.155527.13802@sparky.imd.sterling.com> X-Md4-Signature: 2fce51c05ceb8c8c59cb91cd292650fa Date: Mon, 25 Jan 1993 15:55:27 GMT Approved: kent@sparky.imd.sterling.com Submitted-by: mgleason@cse.unl.edu (Michael Gleason) Posting-number: Volume 35, Issue 7 Archive-name: ncftp/part04 Environment: UNIX, ANSI-C, getopt Supersedes: ncftp: Volume 34, Issue 14-16 #! /bin/sh # This is a shell archive. Remove anything before this line, then feed it # into a shell via "sh file" or similar. To overwrite existing files, # type "sh file -c". # Contents: Blurb Install copyright.h ftpdefs.h ftprc.h getpass.c # getpass.h glob.h main.h patchlevel.h # Wrapped by kent@sparky on Mon Jan 25 09:48:06 1993 PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH echo If this archive is complete, you will see the following message: echo ' "shar: End of archive 4 (of 4)."' if test -f 'Blurb' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Blurb'\" else echo shar: Extracting \"'Blurb'\" \(2837 characters\) sed "s/^X//" >'Blurb' <<'END_OF_FILE' XSubject: ncftp - Alternative User Interface for FTP, Part01/01 X XArchive-name: ncftp/part01 XEnvironment: UNIX, ANSI-C, getopt X Xncftp - Alternative user interface for FTP Xversion 1.0 PL 2 by Mike Gleason, NCEMRSoft. X XChanges from 1.0 PL 1: X X * ls is more flexible, so now you can do things like "ls -flags directory." X Previous versions of ncftp (and ftp) only allowed "ls -flags" or X "ls directory." X X * Some new progress meters, a fancy bargraph and another similar to the X original % meter that shows how many kilobytes have been transferred. X This meter is also used when the remote site doesn't support the SIZE X command, so you can always have a progress meter. X X * If you don't want ftp and ncftp to share an rc, you can use a '.ncftprc' X for ncftp and a '.netrc' for ftp. X X * Better portability; in addition to support for DG/UX, NeXT, and DYNIX, X the getpass2() function which was causing problems has been replaced X by a more portable version. Also using a private getopt which can be X called more than once. X X * Syslog'ging capability added for system administrators. X X * So many small enhancements and bug fixes that the patch is almost as X large as the shar-chive. See patchlevel.h for the gory details. X X Xncftp was created out of disgust with using the regular 'ftp' Xcommand found on many brands of Unix. People who spend a lot Xof time in ftp will want to install ncftp. X XFeatures: X X * No more typing 'anonymous' and your email address every time X you want to ftp anonymously. You don't need to have the X site in your .netrc. X X * No more typing complete site names. Sites in your .netrc X can be abbreviated. Type 'o wuar' to call wuarchive.wustl.edu. X X * Use your pager (like 'more') to read remote files (and also X compressed files). X X * Use your pager to view remote directory listings. X X * Transfers feature a progress meter. X X * Implicit cd. X X * Fancy prompts. X X * You can keep a log of your actions. See what the path was of X that file you downloaded yesterday so you don't have to X look for it today. X X * Built-in mini-nslookup. X X * The 'ls' command is ls -CF. Some ftp's ls was identical to 'dir.' X X * You can 'redial' a remote host until you connect. X X * Don't need to 'close' a site, just open a new one. X X * Don't feel like typing a long filename? Use a wildcard in single X file commands like get and page. X X * You can create empty remote files. X X * Supports 'colon mode', so you can type 'ncftp cse.unl.edu:/pub/foo', X to copy foo into your current directory. X X * You can re-display the last directory listing without getting it X across the network. X X * Detects when new mail arrives. X X * ncftp is quieter by default -- who cares if the PORT command was X successful (if you do, turn verbose on :-). X X * It can be compiled to log transfers, etc., to the system log. X END_OF_FILE if test 2837 -ne `wc -c <'Blurb'`; then echo shar: \"'Blurb'\" unpacked with wrong size! fi # end of 'Blurb' fi if test -f 'Install' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Install'\" else echo shar: Extracting \"'Install'\" \(647 characters\) sed "s/^X//" >'Install' <<'END_OF_FILE' XThe 'Makefile', 'sys.h' and 'defaults.h' may need to be modified. XRead 'sys.h' first; it will tell you how to configure the program Xfor you particular system. Then edit the Makefile. You can also Xchange the program's default behavior by editing defaults.h (optional). X XIf you have problems, you can mail me, but please try your best to install Xit without my help, because I don't want my mailbox flooded. I do want Xto hear from you if you have comments or bug reports/fixes. I would also Xlike to hear from you if you had a system that wasn't covered in sys.h, Xso I can add an entry for other users of your system. X X--mg (mgleason@cse.unl.edu) END_OF_FILE if test 647 -ne `wc -c <'Install'`; then echo shar: \"'Install'\" unpacked with wrong size! fi # end of 'Install' fi if test -f 'copyright.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'copyright.h'\" else echo shar: Extracting \"'copyright.h'\" \(1333 characters\) sed "s/^X//" >'copyright.h' <<'END_OF_FILE' X/* copyright.h */ X X/* X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X * X * Copyright (c) 1992, 1993 Mike Gleason, NCEMRSoft. X * Copyright (c) 1985, 1989 Regents of the University of California. X * All rights reserved. X * X * Redistribution and use in source and binary forms are permitted provided X * that: (1) source distributions retain this entire copyright notice and X * comment, and (2) distributions including binaries display the following X * acknowledgement: ``This product includes software developed by the X * University of California, Berkeley and its contributors'' in the X * documentation or other materials provided with the distribution and in X * all advertising materials mentioning features or use of this software. X * Neither the name of the University nor the names of its contributors may X * be used to endorse or promote products derived from this software without X * specific prior written permission. X */ X X#ifndef lint X#ifdef _main_c_ Xstatic char copyright[] = "@(#) Copyright (c) 1992, 1993 by NCEMRSoft and Copyright (c) 1985, 1989 Regents of the University of California.\n All rights reserved.\n"; X#endif X#endif /* not lint */ X X/* eof copyright.h */ END_OF_FILE if test 1333 -ne `wc -c <'copyright.h'`; then echo shar: \"'copyright.h'\" unpacked with wrong size! fi # end of 'copyright.h' fi if test -f 'ftpdefs.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ftpdefs.h'\" else echo shar: Extracting \"'ftpdefs.h'\" \(807 characters\) sed "s/^X//" >'ftpdefs.h' <<'END_OF_FILE' X/* ftpdefs.h */ X X#ifndef _ftpdefs_h_ X#define _ftpdefs_h_ X X#define FTP_VERSION "NcFTP 1.0 PL2 (20 Jan 93)" X Xtypedef char string[128], str32[32]; X Xstruct userinfo { X str32 username; X string homedir; X string shell; X string hostname; X int uid; X}; X X/* X * Your compiler may not like the 'const' directives. If it chokes X * here, add -DCONST to your SDEFS line in the Makefile. X */ X#if defined(CONST) || defined(const) X#define Strncpy(a,b) strncpy((a), (const char *) (b), (size_t) sizeof (a)) X#define Strncat(a,b) strncat((a), (const char *) (b), (size_t) sizeof (a)) X#else X#define Strncpy(a,b) strncpy((a), (char *) (b), (size_t) sizeof (a)) X#define Strncat(a,b) strncat((a), (char *) (b), (size_t) sizeof (a)) X#endif X X#define FGets(a,b) fgets((a), sizeof(a) - 1, (b)) X X#endif /* _ftpdefs_h_ */ X/* eof */ END_OF_FILE if test 807 -ne `wc -c <'ftpdefs.h'`; then echo shar: \"'ftpdefs.h'\" unpacked with wrong size! fi # end of 'ftpdefs.h' fi if test -f 'ftprc.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ftprc.h'\" else echo shar: Extracting \"'ftprc.h'\" \(424 characters\) sed "s/^X//" >'ftprc.h' <<'END_OF_FILE' X/* ftprc.h */ X X#ifndef _ftprc_h_ X#define _ftprc_h_ X X#define NETRC "netrc" X#define FTPRC "ncftprc" X X#define RC_DELIM " \n\t," X Xtypedef struct site *siteptr; Xtypedef struct site { X char *name; /* name (or IP address) of site */ X siteptr next; X} site; X Xint thrash_rc(void); Xvoid AddNewSitePtr(char *word); Xint ruserpass2(char *host, char **user, char **pass, char **acct); Xvoid GetFullSiteName(char *host); X X#endif X/* eof */ END_OF_FILE if test 424 -ne `wc -c <'ftprc.h'`; then echo shar: \"'ftprc.h'\" unpacked with wrong size! fi # end of 'ftprc.h' fi if test -f 'getpass.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getpass.c'\" else echo shar: Extracting \"'getpass.c'\" \(2472 characters\) sed "s/^X//" >'getpass.c' <<'END_OF_FILE' X/* Getpass.c */ X X#define PASSWD_LEN 127 X X#include "sys.h" X#include <stdio.h> X#include <signal.h> X X#include "cmds.h" X#include "getpass.h" X#include "copyright.h" X X#ifndef GETPASS X X#ifndef NO_UNISTDH X# include <unistd.h> X#endif X X#ifdef BSD X# include <sys/ioctl.h> X#endif X X#ifdef TERMIOS X# include <termios.h> X#else X# ifdef SGTTYB X# include <sgtty.h> X# else X# include <termio.h> X# endif X#endif /* !TERMIOS */ X Xint ioctl(int, int, ...); X X#endif /* GETPASS */ X X X X Xvoid echo(FILE *fp, int on) X{ X#ifndef GETPASS /* Otherwise just do nothing which is ok. */ X X#ifdef TERMIOS X static struct termios orig, noecho, *tp; X#else X# ifdef SGTTYB X static struct sgttyb orig, noecho, *tp; X# else X static struct termio orig, noecho, *tp; X# endif X#endif X static int state = 0; X int fd = fileno(fp); X X if (state == 0) { X#ifdef TERMIOS X if (tcgetattr(fd, &orig) < 0) X Perror("tcgetattr"); X noecho = orig; X noecho.c_lflag &= ~ECHO; X#else X# ifdef SGTTYB X if (ioctl(fd, TIOCGETP, &orig) < 0) X Perror("ioctl"); X noecho = orig; X noecho.sg_flags &= ~ECHO; X# else X if (ioctl(fd, TCGETA, &orig) < 0) X Perror("ioctl"); X noecho = orig; X noecho.c_lflag &= ~ECHO; X# endif X#endif X state = 1; X } X tp = NULL; X if (on && state == 2) { X /* Turn echo back on. */ X tp = &orig; X state = 1; X } else if (!on && state == 1) { X /* Turn echo off. */ X tp = &noecho; X state = 2; X } X if (tp != NULL) { X#ifdef TERMIOS X if (tcsetattr(fd, TCSAFLUSH, tp) < 0) X Perror("tcsetattr"); X#else X# ifdef SGTTYB X if (ioctl(fd, TIOCSETP, tp) < 0) X Perror("ioctl"); X# else X if (ioctl(fd, TCSETA, tp) < 0) X Perror("ioctl"); X# endif X#endif /* !TERMIOS */ X } X X#endif /* GETPASS */ X} /* echo */ X X X X#ifndef GETPASS X Xchar *Getpass(char *promptstr) X{ X register int ch; X register char *p; X FILE *fp, *outfp; X void (*oldintr)(int); X static char buf[PASSWD_LEN + 1]; X X /* X * read and write to /dev/tty if possible; else read from X * stdin and write to stderr. X */ X if ((outfp = fp = fopen("/dev/tty", "w+")) == NULL) { X outfp = stderr; X fp = stdin; X } X oldintr = signal(SIGINT, SIG_IGN); X echo(fp, 0); /* Turn echoing off. */ X (void) fputs(promptstr, outfp); X (void) rewind(outfp); /* implied flush */ X for (p = buf; (ch = getc(fp)) != EOF && ch != '\n';) X if (p < buf + PASSWD_LEN) X *p++ = ch; X *p = '\0'; X (void)write(fileno(outfp), "\n", 1); X echo(fp, 1); X (void) signal(SIGINT, oldintr); X if (fp != stdin) X (void)fclose(fp); X return(buf); X} /* Getpass */ X X#endif /* GETPASS */ X X/* eof Getpass.c */ END_OF_FILE if test 2472 -ne `wc -c <'getpass.c'`; then echo shar: \"'getpass.c'\" unpacked with wrong size! fi # end of 'getpass.c' fi if test -f 'getpass.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'getpass.h'\" else echo shar: Extracting \"'getpass.h'\" \(188 characters\) sed "s/^X//" >'getpass.h' <<'END_OF_FILE' X/* Getpass.h */ X X#ifndef _getpass_h_ X#define _getpass_h_ X X#define PASSWD_LEN 127 X Xchar *Getpass(char *prompt); Xvoid echo(FILE *fp, int on); X X#endif /* _getpass_h_ */ X X/* eof Getpass.h */ END_OF_FILE if test 188 -ne `wc -c <'getpass.h'`; then echo shar: \"'getpass.h'\" unpacked with wrong size! fi # end of 'getpass.h' fi if test -f 'glob.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'glob.h'\" else echo shar: Extracting \"'glob.h'\" \(240 characters\) sed "s/^X//" >'glob.h' <<'END_OF_FILE' X/* glob.h */ Xchar **glob(char *v); Xint letter(char c); Xint digit(char c); Xint any(int c, char *s); Xint blklen(char **av); Xchar **blkcpy(char **oav, char **bv); Xint blkfree(char **av0); Xchar **copyblk(char **v); Xint gethdir(char *home_dir); END_OF_FILE if test 240 -ne `wc -c <'glob.h'`; then echo shar: \"'glob.h'\" unpacked with wrong size! fi # end of 'glob.h' fi if test -f 'main.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'main.h'\" else echo shar: Extracting \"'main.h'\" \(519 characters\) sed "s/^X//" >'main.h' <<'END_OF_FILE' X/* main.h */ X X#ifndef _main_h_ X#define _main_h_ X Xvoid intr(int unused); Xint getuserinfo(void); Xint init_arrays(void); Xvoid init_transfer_buffer(void); Xvoid init_prompt(void); Xvoid lostpeer(int unused); Xvoid cmdscanner(int top); Xchar *strprompt(void); Xchar *Strpcpy(char *dst, char *src); Xstruct cmd *getcmd(char *name); Xvoid makeargv(void); Xchar *slurpstring(void); Xint help(int argc, char **argv); Xvoid trim_log(void); Xint CheckNewMail(void); Xvoid tcap_put(char *cap); Xvoid termcap_init(void); X X#endif /* _main_h_ */ X END_OF_FILE if test 519 -ne `wc -c <'main.h'`; then echo shar: \"'main.h'\" unpacked with wrong size! fi # end of 'main.h' fi if test -f 'patchlevel.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'patchlevel.h'\" else echo shar: Extracting \"'patchlevel.h'\" \(2689 characters\) sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE' X/* patchlevel.h */ X X/* X * v1.0.0 - December 6, 1992. X * Initial release. X * X * v1.0.1 - December 8, 1992. X * Added default value for NCARGS in glob.c for systems that don't define it. X * Fixed pdir bug which was caused by me mistakenly adding the page-a- X * compressed-file feature to ls instead of page. Fixed bug in documentation, X * which had the same error! Added spec for Ultrix in sys.h. Fixed error X * in sys.h that recommended -Dconst instead of -Dconst="". Added GETPASS X * compile flag to use getpass() instead of getpass2(), which make compiling X * easier if the compiler choked in cmds.c. Added GETCWDSIZET for systems X * whose getcwd() takes a size_t instead of an int. X * X * v1.0.2 - Jan 17, 1993. X * Using the cpp symbol CONST instead of const to tell X * the compiler not to use the 'const' directive. Checking for __sgi as X * well as sgi in sys.h. Added #ifndef __GNUC__ block to make SunOS users X * use gcc. You can avoid trying to include <unistd.h> by defining X * NO_UNISTDH. Added DG/UX entry in sys.h. Also added still another cpp X * symbol, BAD_INETADDR, which is used if inet_addr returns a structure X * instead of a u_long (this is only for DG/UX so far). Changed long to X * int in wait(). Added default value for NCARGS in glob.c. Added cpp X * symbol NO_STDLIBH for systems without <stdlib.h>. Fixed 'quote.' X * Fixed 'size.' Set all's string variable are printed in double quotes. X * Ansi-escapes is init'd to 1 if TERM==xterm. Fixed 'type tenex.' Set X * verbose makes sure verbose is within bounds and prints messages now. X * Better getpass2. Tries .ncftprc before .netrc. @N adds a \n to prompt. X * ls() is more flexible. Macdef and $ print current macros if no arg X * is given. getpass2 is now Getpass, and accompanying this are X * more cpp symbols SGTTYB and TERMIOS. Better SCO support. No longer using X * gets(), instead using own Gets() which is safer. Better termcap support, X * or actually curses support, to get ansi-escape sequences. Using -FC X * instead of -CF for ls flags, do avoid a rare conflict. Progress meters X * work better. Phil Dietz added a cool bar graph one, and I added another X * similar to the default percentage meter that shows the # KB transferred, X * which will work on systems not supporting SIZE. Fixed floating point X * exception bug in put/mput. Fixed implicit_cd to work with wuarchive-ish X * cd messages. Added NeXT and DYNIX blocks in sys.h. X * Fixed bug in _cd, that was trying to use wildcards when it X * shouldn't. Fixed bug in macdef. Fixed small bug in getreply. Turned X * off echoing during the progress-meter. Added syslogging capability. X */ END_OF_FILE if test 2689 -ne `wc -c <'patchlevel.h'`; then echo shar: \"'patchlevel.h'\" unpacked with wrong size! fi # end of 'patchlevel.h' fi echo shar: End of archive 4 \(of 4\). cp /dev/null ark4isdone MISSING="" for I in 1 2 3 4 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 4 archives. rm -f ark[1-9]isdone else echo You still must unpack the following archives: echo " " ${MISSING} fi exit 0 exit 0 # Just in case...