home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume34 / ncftp / part03 < prev    next >
Encoding:
Text File  |  1992-12-07  |  48.0 KB  |  2,106 lines

  1. Newsgroups: comp.sources.misc
  2. From: mgleason@cse.unl.edu (Mike Gleason)
  3. Subject:  v34i016:  ncftp - Alternative User Interface for FTP, Part03/03
  4. Message-ID: <1992Dec7.211121.4042@sparky.imd.sterling.com>
  5. X-Md4-Signature: 60456007852732283e42626d5c0456ae
  6. Date: Mon, 7 Dec 1992 21:11:21 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: mgleason@cse.unl.edu (Mike Gleason)
  10. Posting-number: Volume 34, Issue 16
  11. Archive-name: ncftp/part03
  12. Environment: UNIX, ANSI-C, getopt
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then feed it
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # Contents:  Blurb Install Makefile cmds.h copyright.h defaults.h ftp.h
  19. #   ftprc.c glob.c glob.h main.h ncftp.1 patchlevel.h
  20. # Wrapped by kent@sparky on Mon Dec  7 15:06:55 1992
  21. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  22. echo If this archive is complete, you will see the following message:
  23. echo '          "shar: End of archive 3 (of 3)."'
  24. if test -f 'Blurb' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'Blurb'\"
  26. else
  27.   echo shar: Extracting \"'Blurb'\" \(1756 characters\)
  28.   sed "s/^X//" >'Blurb' <<'END_OF_FILE'
  29. XSubject:  ncftp - Alternative User Interface for FTP, part 01/01
  30. X
  31. XArchive-name: ncftp/part01
  32. XEnvironment: UNIX, ANSI-C, getopt
  33. X
  34. Xncftp - Alternative user interface for FTP
  35. Xversion 1.0 by Mike Gleason, NCEMRSoft.
  36. X
  37. Xncftp was created out of disgust with using the regular 'ftp'
  38. Xcommand found on many brands of Unix.  People who spend a lot
  39. Xof time in ftp will want to install ncftp.
  40. X
  41. XFeatures:
  42. X
  43. X * No more typing 'anonymous' and your email address every time
  44. X   you want to ftp anonymously.  You don't need to have the
  45. X   site in your .netrc.
  46. X   
  47. X * No more typing complete site names.  Sites in your .netrc
  48. X   can be abbreviated.  Type 'o wuar' to call wuarchive.wustl.edu.
  49. X * Use your pager (like 'more') to read remote files (and also
  50. X   compressed files).
  51. X
  52. X * Use your pager to view remote directory listings.
  53. X
  54. X * Transfers feature a progress meter.
  55. X * Implicit cd.
  56. X * Fancy prompts.
  57. X * You can keep a log of your actions.  See what the path was of
  58. X   that file you downloaded yesterday so you don't have to
  59. X   look for it today.
  60. X * Built-in mini-nslookup.
  61. X * The 'ls' command is ls -CF.  Some ftp's ls was identical to 'dir.'
  62. X * You can 'redial' a remote host until you connect.
  63. X
  64. X * Don't need to 'close' a site, just open a new one.
  65. X * Don't feel like typing a long filename?  Use a wildcard in single
  66. X   file commands like get and page.
  67. X * You can create empty remote files.
  68. X
  69. X * Supports 'colon mode', so you can type 'ncftp cse.unl.edu:/pub/foo',
  70. X   to copy foo into your current directory.
  71. X
  72. X * You can re-display the last directory listing without getting it
  73. X   across the network.
  74. X
  75. X * Detects when new mail arrives.
  76. X
  77. X * ncftp is quieter by default -- who cares if the PORT command was
  78. X   successful (if you do, turn verbose on :-).
  79. END_OF_FILE
  80.   if test 1756 -ne `wc -c <'Blurb'`; then
  81.     echo shar: \"'Blurb'\" unpacked with wrong size!
  82.   fi
  83.   # end of 'Blurb'
  84. fi
  85. if test -f 'Install' -a "${1}" != "-c" ; then 
  86.   echo shar: Will not clobber existing file \"'Install'\"
  87. else
  88.   echo shar: Extracting \"'Install'\" \(647 characters\)
  89.   sed "s/^X//" >'Install' <<'END_OF_FILE'
  90. XThe 'Makefile', 'sys.h' and 'defaults.h' may need to be modified.
  91. XRead 'sys.h' first; it will tell you how to configure the program
  92. Xfor you particular system.  Then edit the Makefile.  You can also
  93. Xchange the program's default behavior by editing defaults.h (optional).
  94. X
  95. XIf you have problems, you can mail me, but please try your best to install
  96. Xit without my help, because I don't want my mailbox flooded.  I do want
  97. Xto hear from you if you have comments or bug reports/fixes.  I would also
  98. Xlike to hear from you if you had a system that wasn't covered in sys.h,
  99. Xso I can add an entry for other users of your system.
  100. X
  101. X--mg (mgleason@cse.unl.edu)
  102. END_OF_FILE
  103.   if test 647 -ne `wc -c <'Install'`; then
  104.     echo shar: \"'Install'\" unpacked with wrong size!
  105.   fi
  106.   # end of 'Install'
  107. fi
  108. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  109.   echo shar: Will not clobber existing file \"'Makefile'\"
  110. else
  111.   echo shar: Extracting \"'Makefile'\" \(2621 characters\)
  112.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  113. X###
  114. X###  Makefile for ncftp
  115. X###
  116. X
  117. XSRCS=main.c cmds.c cmdtab.c ftp.c glob.c ftprc.c
  118. XOBJS=main.o cmds.o cmdtab.o ftp.o glob.o ftprc.o
  119. XHEADERS=cmds.h copyright.h defaults.h ftp.h ftpdefs.h ftprc.h \
  120. Xglob.h main.h patchlevel.h sys.h
  121. XNAME=ncftp
  122. XMAN=ncftp.1
  123. XALL=$(SRCS) $(HEADERS) Blurb Install Makefile $(MAN)
  124. X
  125. X# Program definitions.
  126. X# At the moment these can be:
  127. X#    -DTCAP:  Uses termcap library to display boldface, underline, etc.
  128. X#       By default ncftp uses hard-coded ANSI escapes (^[[1m etc.).
  129. X#       If you don't have <tcap.h>, don't use it.  A future release will
  130. X#       support Curses.
  131. XPDEFS= 
  132. X
  133. X# System dependent definitions.  See sys.h.
  134. XSDEFS=  
  135. X
  136. X# Choose your compiler and flags below.  Make sure you use an ANSI compiler
  137. X# that handles new style function declarations and prototypes (gcc should).
  138. X
  139. XCC=cc
  140. XCFLAGS=-O
  141. XLFLAGS=-s
  142. X#CFLAGS=-g
  143. X#LFLAGS=-g
  144. X
  145. X# Additional libraries.
  146. X# Some may need any of -lsocket, -lnet, -linet. 
  147. X# You'll need -ltermcap if TCAP is defined
  148. X#
  149. XMORELIBS= 
  150. X
  151. X
  152. XDEFS=$(PDEFS) $(SDEFS)
  153. X
  154. Xall: $(NAME) done
  155. X
  156. X$(NAME): $(OBJS)
  157. X    $(CC) $(LFLAGS) $(OBJS) -o $(NAME) $(MORELIBS)
  158. X
  159. Xmain.o: main.c sys.h defaults.h ftpdefs.h cmds.h main.h ftp.h ftprc.h
  160. X    $(CC) $(CFLAGS) $(DEFS) main.c -c
  161. X
  162. Xcmds.o: cmds.c sys.h defaults.h ftpdefs.h cmds.h main.h ftp.h ftprc.h glob.h
  163. X    $(CC) $(CFLAGS) $(DEFS) cmds.c -c
  164. X
  165. Xcmdtab.o: cmdtab.c sys.h ftpdefs.h cmds.h main.h ftp.h ftprc.h glob.h
  166. X    $(CC) $(CFLAGS) $(DEFS) cmdtab.c -c
  167. X
  168. Xftp.o: ftp.c sys.h defaults.h ftpdefs.h cmds.h main.h ftp.h
  169. X    $(CC) $(CFLAGS) $(DEFS) ftp.c -c
  170. X
  171. Xftprc.o: ftprc.c sys.h defaults.h ftpdefs.h cmds.h main.h ftprc.h
  172. X    $(CC) $(CFLAGS) $(DEFS) ftprc.c -c
  173. X
  174. Xglob.o: glob.c sys.h ftpdefs.h cmds.h glob.h
  175. X    $(CC) $(CFLAGS) $(DEFS) glob.c -c
  176. X
  177. Xclean:
  178. X    rm -f $(OBJS) core $(NAME)
  179. X
  180. Xlint: $(SRCS)
  181. X    lint $(SRCS) $(CFLAGS) $(DEFS) > Lint
  182. X
  183. Xtags:
  184. X    ctags -x $(SRCS) $(HEADERS) | sort -f > tags
  185. X    
  186. Xtar:
  187. X    tar cvf - $(ALL) | compress > $(NAME).tar.Z
  188. X
  189. Xshar2:
  190. X    shar $(ALL) > $(NAME).shar
  191. X
  192. Xshar:
  193. X    shar $(ALL) | cat Blurb - > $(NAME).shar
  194. X
  195. Xdone:
  196. X    -@ls -l $(NAME)
  197. X    -@echo 'Done.'
  198. X
  199. X# Shouldn't need to fool with anything below this point.
  200. X# This is my development stuff.
  201. X
  202. Xpixie: $(NAME) $(NAME).Counts $(NAME).Addrs
  203. X    prof -pixie $(NAME) $(NAME).Addrs $(NAME).Counts -feedback Feedback
  204. X
  205. X$(NAME).Addrs: $(NAME)
  206. X    pixie -o $(NAME).pixie $(NAME)
  207. X
  208. X$(NAME).Counts: ftp $(NAME).Addrs
  209. X    $(NAME).pixie
  210. X
  211. Xprofile:
  212. X    rm -f *.[ou]
  213. X    cc *.c -g -p -o ncftp.prof
  214. X    ncftp.prof
  215. X    prof ncftp.prof mon.out
  216. X
  217. Xmipsopt:
  218. X    cc -O3 *.c $(DEFS) -o ncftp -s
  219. X    rm *.[ou]
  220. X
  221. Xgccopt:
  222. X    gcc -O2 *.c $(DEFS) -o ncftp -s
  223. X
  224. Xopt: mipsopt done
  225. X
  226. Xgopt: gccopt done
  227. X
  228. Xmantst:
  229. X    nroff -man ncftp.1 > ncftp.man
  230. X    less ncftp.man
  231. X
  232. X# eof
  233. END_OF_FILE
  234.   if test 2621 -ne `wc -c <'Makefile'`; then
  235.     echo shar: \"'Makefile'\" unpacked with wrong size!
  236.   fi
  237.   # end of 'Makefile'
  238. fi
  239. if test -f 'cmds.h' -a "${1}" != "-c" ; then 
  240.   echo shar: Will not clobber existing file \"'cmds.h'\"
  241. else
  242.   echo shar: Extracting \"'cmds.h'\" \(3575 characters\)
  243.   sed "s/^X//" >'cmds.h' <<'END_OF_FILE'
  244. X/* cmd.h */
  245. X
  246. X#ifndef _cmd_h_
  247. X#define _cmd_h_
  248. X
  249. X/* Verbosity levels. */
  250. X#define V_QUIET        -1
  251. X#define V_ERRS        0
  252. X#define V_TERSE        1
  253. X#define V_VERBOSE    2
  254. X#define IS_VQUIET    (verbose <= V_QUIET)
  255. X#define IS_VERRS    (verbose == V_ERRS)
  256. X#define IS_VTERSE    (verbose == V_TERSE)
  257. X#define IS_VVERBOSE    (verbose >= V_VERBOSE)
  258. X#define NOT_VQUIET    (verbose > V_QUIET)
  259. X
  260. X/* Open modes. */
  261. X#define OPEN_A 1
  262. X#define OPEN_U 0
  263. X
  264. X/* For 'set.' */
  265. X#define INT 1
  266. X#define LONG 2
  267. X#define STR 3
  268. Xtypedef void (*setvarproc)(char *, int);
  269. Xstruct var {
  270. X    char            *name;
  271. X    short            type;
  272. X    short            conn_required;
  273. X    void            *var;
  274. X    setvarproc        proc;
  275. X};
  276. X
  277. X/*
  278. X * Format of command table.
  279. X */
  280. Xstruct cmd {
  281. X    char    *c_name;    /* name of command */
  282. X    char    *c_help;    /* help string */
  283. X    char    c_bell;        /* give bell when command completes */
  284. X    char    c_conn;        /* must be connected to use command */
  285. X    char    c_proxy;    /* proxy server may execute */
  286. X    char    c_hidden;    /* a hidden command or alias (won't show up in help) */
  287. X    int        (*c_handler)(int, char **);    /* function to call */
  288. X};
  289. X
  290. Xstruct macel {
  291. X    char mac_name[9];    /* macro name */
  292. X    char *mac_start;    /* start of macro in macbuf */
  293. X    char *mac_end;        /* end of macro in macbuf */
  294. X};
  295. X
  296. Xstruct types {
  297. X    char    *t_name;
  298. X    char    *t_mode;
  299. X    int        t_type;
  300. X    char    *t_arg;
  301. X};
  302. X
  303. X#ifdef REDIR
  304. Xstruct lslist {
  305. X    char            *string;
  306. X    struct lslist    *next;
  307. X};
  308. X#endif
  309. X
  310. X/* cmds.c */
  311. Xchar **re_makeargv(char *promptstr, int *argc);
  312. Xint setpeer(int argc, char **argv);
  313. Xint settype(int argc, char **argv);
  314. Xvoid _settype(char *typename);
  315. Xint setbinary(int argc, char **argv);
  316. Xint setascii(int argc, char **argv);
  317. Xvoid set_prompt(char *new, int unset);
  318. Xvoid set_log(char *fname, int unset);
  319. Xvoid set_ldir(char *ldir, int unset);
  320. Xvoid set_pager(char *new, int unset);
  321. Xvoid set_type(char *newtype, int unset);
  322. Xint set(int argc, char **argv);
  323. Xint put(int argc, char **argv);
  324. Xint mput(int argc, char **argv);
  325. Xint rem_glob_one(char *pattern);
  326. Xint get(int argc, char **argv);
  327. Xvoid mabort(int unused);
  328. Xint mget(int argc, char **argv);
  329. Xchar *remglob(char *argv[]);
  330. Xchar *onoff(int bool);
  331. Xint StrToBool(char *s);
  332. Xint setverbose(int argc, char **argv);
  333. Xint setprompt(int argc, char **argv);
  334. Xint setdebug(int argc, char **argv);
  335. Xvoid fix_options(void);
  336. Xint cd(int argc, char **argv);
  337. Xint implicit_cd(char *dir);
  338. Xint _cd(char *dir);
  339. Xint lcd(int argc, char **argv);
  340. Xint do_delete(int argc, char **argv);
  341. Xint mdelete(int argc, char **argv);
  342. Xint renamefile(int argc, char **argv);
  343. Xint ls(int argc, char **argv);
  344. Xint mls(int argc, char **argv);
  345. Xint shell(int argc, char **argv);
  346. Xint do_user(int argc, char **argv);
  347. Xint pwd(int argc, char **argv);
  348. Xint makedir(int argc, char **argv);
  349. Xint removedir(int argc, char **argv);
  350. Xint quote(int argc, char **argv);
  351. Xint rmthelp(int argc, char **argv);
  352. Xint quit(int argc, char **argv);
  353. Xvoid close_streams(int wantShutDown);
  354. Xint disconnect(int argc, char **argv);
  355. Xint confirm(char *cmd, char *file);
  356. Xvoid fatal(char *msg);
  357. Xvoid close_up_shop(void);
  358. Xint globulize(char **cpp);
  359. Xint cdup(int argc, char **argv);
  360. Xint syst(int argc, char **argv);
  361. Xint make_macro(char *name, FILE *fp);
  362. Xint macdef(int argc, char **argv);
  363. Xint domacro(int argc, char **argv);
  364. Xint sizecmd(int argc, char **argv);
  365. Xint modtime(int argc, char **argv);
  366. Xint lookup(int argc, char **argv);
  367. Xint rmtstatus(int argc, char **argv);
  368. Xint create(int argc, char **argv);
  369. Xchar *get_cwd(char *buf, int size);
  370. Xint tmp_name(char *str);
  371. Xint getlocalhostname(char *host, size_t size);
  372. Xchar *getpass2(char *prompt);
  373. Xint show_version(int argc, char **argv);
  374. Xvoid Perror(char *s);
  375. X#ifdef REDIR
  376. Xint showlsbuffer(int argc, char **argv);
  377. X#endif
  378. X
  379. X#endif    /* _cmd_h_ */
  380. END_OF_FILE
  381.   if test 3575 -ne `wc -c <'cmds.h'`; then
  382.     echo shar: \"'cmds.h'\" unpacked with wrong size!
  383.   fi
  384.   # end of 'cmds.h'
  385. fi
  386. if test -f 'copyright.h' -a "${1}" != "-c" ; then 
  387.   echo shar: Will not clobber existing file \"'copyright.h'\"
  388. else
  389.   echo shar: Extracting \"'copyright.h'\" \(1321 characters\)
  390.   sed "s/^X//" >'copyright.h' <<'END_OF_FILE'
  391. X/* copyright.h */
  392. X
  393. X/*
  394. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  395. X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  396. X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  397. X *
  398. X * Copyright (c) 1992 Mike Gleason, NCEMRSoft.
  399. X * Copyright (c) 1985, 1989 Regents of the University of California.
  400. X * All rights reserved.
  401. X *
  402. X * Redistribution and use in source and binary forms are permitted provided
  403. X * that: (1) source distributions retain this entire copyright notice and
  404. X * comment, and (2) distributions including binaries display the following
  405. X * acknowledgement:  ``This product includes software developed by the
  406. X * University of California, Berkeley and its contributors'' in the
  407. X * documentation or other materials provided with the distribution and in
  408. X * all advertising materials mentioning features or use of this software.
  409. X * Neither the name of the University nor the names of its contributors may
  410. X * be used to endorse or promote products derived from this software without
  411. X * specific prior written permission.
  412. X */
  413. X
  414. X#ifndef lint
  415. X#ifdef _main_c_
  416. Xstatic char copyright[] = "@(#) Copyright (c) 1992 by NCEMRSoft and Copyright (c) 1985, 1989 Regents of the University of California.\n All rights reserved.\n";
  417. X#endif
  418. X#endif /* not lint */
  419. X
  420. X/* eof copyright.h */
  421. END_OF_FILE
  422.   if test 1321 -ne `wc -c <'copyright.h'`; then
  423.     echo shar: \"'copyright.h'\" unpacked with wrong size!
  424.   fi
  425.   # end of 'copyright.h'
  426. fi
  427. if test -f 'defaults.h' -a "${1}" != "-c" ; then 
  428.   echo shar: Will not clobber existing file \"'defaults.h'\"
  429. else
  430.   echo shar: Extracting \"'defaults.h'\" \(1763 characters\)
  431.   sed "s/^X//" >'defaults.h' <<'END_OF_FILE'
  432. X/* defaults.h: default values for ftp's common variables */
  433. X
  434. X#ifndef _DEFAULTS_H_
  435. X#define _DEFAULTS_H_
  436. X
  437. X#ifndef NEWMAILMESSAGE            /* For english speakers, "You have new mail." */
  438. X#define NEWMAILMESSAGE "You have new mail."
  439. X#endif
  440. X
  441. X#ifndef ZCAT                    /* Usually "zcat," but use the full pathname */
  442. X                                /* if possible. */
  443. X#define ZCAT "zcat"
  444. X#endif
  445. X
  446. X#ifndef MAX_XFER_BUFSIZE
  447. X#define MAX_XFER_BUFSIZE 32768
  448. X#endif
  449. X
  450. X#ifndef dDEBUG                    /* 1 or 0, usually 0 */
  451. X#define dDEBUG 0
  452. X#endif
  453. X
  454. X#ifndef dMPROMPT                /* Usually 1, I prefer 0... */
  455. X#define dMPROMPT 0
  456. X#endif
  457. X
  458. X#ifndef dVERBOSE                /* V_QUIET, V_ERRS, V_TERSE, V_VERBOSE */
  459. X#include "cmds.h"                /* for definitions of the above */
  460. X#define dVERBOSE V_TERSE
  461. X#endif
  462. X
  463. X#ifndef dPROMPT                    /* short: "@Bftp@P>" */
  464. X                                /* long: "@B@E @UNcFTP@P @B@M@D@P ->" */
  465. X#define dPROMPT "@B@E @UNcFTP@P @B@M@D@P ->"
  466. X#endif
  467. X
  468. X#ifndef dPAGER                    /* if set to empty string, act like 'cat' */
  469. X#define dPAGER "more"
  470. X#endif
  471. X
  472. X#ifndef dLOGNAME                /* put in the user's home directory. */
  473. X#define dLOGNAME ".ftplog"
  474. X#endif
  475. X
  476. X                                /* Do you want logging on by default? */
  477. X#ifndef dLOGGING                /* usually 0 */
  478. X#define dLOGGING 0
  479. X#endif
  480. X
  481. X#ifndef dTYPE                    /* usually TYPE_A */
  482. X#define dTYPE TYPE_A
  483. X#endif
  484. X
  485. X#ifndef dTYPESTR                /* usually "ascii" */
  486. X#define dTYPESTR "ascii"
  487. X#endif
  488. X
  489. X#ifndef dREDIALDELAY            /* usu. 60 (seconds). */
  490. X#define dREDIALDELAY 60
  491. X#endif
  492. X
  493. X#ifndef CMDLINELEN
  494. X#define CMDLINELEN 256
  495. X#endif
  496. X
  497. X#ifndef RECEIVEDLINELEN
  498. X#define RECEIVEDLINELEN 256
  499. X#endif
  500. X
  501. X#ifndef MAXMACROS
  502. X#define MAXMACROS 16
  503. X#endif
  504. X
  505. X#ifndef MACBUFLEN                /* usually 4096. */
  506. X#define MACBUFLEN 4096
  507. X#endif
  508. X
  509. X/* Do you want binary transfers by default? */
  510. X#ifndef dAUTOBINARY                /* usually 1 */
  511. X#define dAUTOBINARY 1
  512. X#endif
  513. X
  514. X#endif    /* _DEFAULTS_H_ */
  515. X
  516. X/* eof */
  517. END_OF_FILE
  518.   if test 1763 -ne `wc -c <'defaults.h'`; then
  519.     echo shar: \"'defaults.h'\" unpacked with wrong size!
  520.   fi
  521.   # end of 'defaults.h'
  522. fi
  523. if test -f 'ftp.h' -a "${1}" != "-c" ; then 
  524.   echo shar: Will not clobber existing file \"'ftp.h'\"
  525. else
  526.   echo shar: Extracting \"'ftp.h'\" \(747 characters\)
  527.   sed "s/^X//" >'ftp.h' <<'END_OF_FILE'
  528. X/* ftp.h */
  529. X
  530. X#ifndef _ftp_h_
  531. X#define _ftp_h_
  532. X
  533. X#define IS_FILE 1
  534. X#define IS_STREAM 0
  535. X#define IS_PIPE -1
  536. X
  537. Xint hookup(char *host, int port);
  538. Xint login(char *, int, int);
  539. Xvoid cmdabort(int unused);
  540. Xint command(char *cmd);
  541. Xint getreply(int expecteof);
  542. Xvoid abortsend(int unused);
  543. Xvoid sendrequest(char *cmd, char *local, char *remote);
  544. Xvoid abortrecv(int unused);
  545. Xvoid recvrequest(char *cmd, char *local, char *remote, char *mode);
  546. Xint initconn(void);
  547. XFILE *dataconn(char *mode);
  548. Xvoid ptransfer(char *direction, long bytes, struct timeval *t0, struct timeval *t1, char *local, char *remote);
  549. Xvoid close_file(FILE **fin, int filetype);
  550. Xlong get_remote_size(char *remote, int filetype);
  551. Xvoid progress_report(void);
  552. X
  553. X#endif /* _ftp_h_ */
  554. X
  555. X/* eof ftp.h */
  556. END_OF_FILE
  557.   if test 747 -ne `wc -c <'ftp.h'`; then
  558.     echo shar: \"'ftp.h'\" unpacked with wrong size!
  559.   fi
  560.   # end of 'ftp.h'
  561. fi
  562. if test -f 'ftprc.c' -a "${1}" != "-c" ; then 
  563.   echo shar: Will not clobber existing file \"'ftprc.c'\"
  564. else
  565.   echo shar: Extracting \"'ftprc.c'\" \(5069 characters\)
  566.   sed "s/^X//" >'ftprc.c' <<'END_OF_FILE'
  567. X/* ftprc.c */
  568. X
  569. X#include "sys.h"
  570. X#include <sys/types.h>
  571. X#include <sys/param.h>
  572. X#include <sys/stat.h>
  573. X#include <stdio.h>
  574. X#include <string.h>
  575. X#include <stdlib.h>
  576. X#include <ctype.h>
  577. X#include "ftpdefs.h"
  578. X#include "defaults.h"
  579. X#include "ftprc.h"
  580. X#include "main.h"
  581. X#include "cmds.h"
  582. X#include "copyright.h"
  583. X
  584. X/* ftprc.c global variables */
  585. Xsiteptr                    firstsite = NULL, lastsite = NULL;
  586. Xchar                    rcname[MAXPATHLEN];
  587. X
  588. Xextern char                *line, *margv[];
  589. Xextern int                margc;
  590. Xextern string            anon_password;        /* most likely your email address */
  591. Xextern struct userinfo    uinfo;
  592. X
  593. Xint thrash_rc(void)
  594. X{
  595. X    struct stat            st;
  596. X    string                word, str;
  597. X    char                *cp, *dp;
  598. X    FILE                *fp;
  599. X
  600. X    (void) get_cwd(rcname, sizeof(rcname));
  601. X    (void) Strncat(rcname, RCNAME);
  602. X    if (stat(rcname, &st) == 0)
  603. X        goto foundrc;
  604. X    
  605. X    (void) get_cwd(rcname, sizeof(rcname));
  606. X    (void) Strncat(rcname, ".");
  607. X    (void) Strncat(rcname, RCNAME);
  608. X    if (stat(rcname, &st) == 0)
  609. X        goto foundrc;
  610. X
  611. X    (void) sprintf(rcname, "%s/.%s", uinfo.homedir, RCNAME);
  612. X    if (stat(rcname, &st) == 0)
  613. X        goto foundrc;
  614. X
  615. X    return (0);    /* it's OK not to have an rc. */
  616. X    
  617. Xfoundrc:    
  618. X    if ((st.st_mode & 077) != 0)                /* rc must be unreadable by others. */
  619. X        (void) chmod(rcname, 0600);
  620. X
  621. X    if ((fp = fopen(rcname, "r")) == NULL) {
  622. X        Perror(rcname);
  623. X        return -1;
  624. X    }
  625. X    
  626. X    while (cp = FGets(str, fp)) {
  627. X        while (isspace(*cp)) ++cp;        /* skip leading space. */
  628. X        if (*cp == '#') {
  629. X            if ((strncmp("set", ++cp, (size_t)3) == 0) || (strncmp("unset", cp, (size_t)5) == 0)) {
  630. X                (void) strcpy(line, cp);
  631. X                makeargv();
  632. X                set(margc, margv);            
  633. X                /* setting or unsetting a variable. */
  634. X            } /* else a comment. */
  635. X        } else {
  636. X            if (strncmp(cp, "machine", (size_t) 7) == 0) {
  637. X                /* We have a new machine record. */
  638. X                cp += 7;
  639. X                while (isspace(*cp)) ++cp;    /* skip delimiting space. */
  640. X                dp = word;
  641. X                while (*cp && !isspace(*cp)) *dp++ = *cp++;    /* copy the name. */
  642. X                *dp = 0;
  643. X                AddNewSitePtr(word);
  644. X            }
  645. X        }
  646. X    }
  647. X    (void) fclose(fp);
  648. X    return 1;
  649. X}    /* thrash_rc */
  650. X
  651. X
  652. X
  653. Xvoid AddNewSitePtr(char *word)
  654. X{
  655. X    siteptr            s;
  656. X
  657. X    if (s = (siteptr) malloc(sizeof(site))) {
  658. X        s->next = NULL;
  659. X        if (s->name = malloc(strlen(word) + 1)) {
  660. X            (void) strcpy(s->name, word);
  661. X            if (firstsite == NULL)
  662. X                firstsite = lastsite = s;
  663. X            else {
  664. X                lastsite->next = s;
  665. X                lastsite = s;
  666. X            }
  667. X        } else {
  668. X            free(s);
  669. X        }
  670. X    }
  671. X}    /* AddNewSitePtr */
  672. X
  673. X
  674. X
  675. X
  676. Xvoid GetFullSiteName(char *host)
  677. X{
  678. X    register siteptr s, s2;
  679. X
  680. X    /* see if 'host' is in our list of favorite sites. */
  681. X    for (s = firstsite; s != NULL; s2=s->next, s=s2)
  682. X        if (strstr(s->name, host) != NULL) {
  683. X            (void) strcpy(host, s->name);
  684. X            break;
  685. X        }
  686. X}    /* GetFullSiteName */
  687. X
  688. X
  689. X
  690. X
  691. Xint ruserpass2(char *host, char **username, char **pass, char **acct)
  692. X{
  693. X    FILE            *fp;
  694. X    char            *cp, *dp, *dst, *ep;
  695. X    str32            macname;
  696. X    char            *varname;
  697. X    int                site_found;
  698. X    string            str;
  699. X    static string    auser;
  700. X    static str32    apass, aacct;
  701. X
  702. X    site_found = 0;
  703. X
  704. X    if ((fp = fopen(rcname, "r")) != NULL) {
  705. X        while (FGets(str, fp)) {
  706. X            if (cp = strstr(str, "machine")) {
  707. X                /* Look for the machine token. */
  708. X                cp += 7;
  709. X                while (isspace(*cp))
  710. X                    cp++;
  711. X            } else
  712. X                continue;
  713. X            if (strncmp(cp, host, strlen(host)) == 0) {
  714. X                site_found = 1;
  715. X                while (!isspace(*cp))
  716. X                    ++cp;        /* skip the site name. */
  717. X                do {
  718. X                    /* Skip any comments ahead of time. */
  719. X                    for (dp=cp; *dp; dp++) {
  720. X                        if (*dp == '#') {
  721. X                            *dp = 0;
  722. X                            break;
  723. X                        }
  724. X                    }
  725. X
  726. X                    ep = cp;
  727. X                    while (1) {
  728. X                        varname = strtok(ep, RC_DELIM);
  729. X                        if (!varname) break;
  730. X                        dst = ep = NULL;
  731. X                        switch (*varname) {
  732. X                            case 'u':    /* user */
  733. X                                *username = dst = auser;
  734. X                                break;
  735. X                            case 'l':    /* login */
  736. X                                *username = dst = auser;
  737. X                                break;
  738. X                            case 'p':    /* password */
  739. X                                *pass = dst = apass;
  740. X                                break;
  741. X                            case 'a':    /* account */
  742. X                                *acct = dst = aacct;
  743. X                                break;
  744. X                        /*    case 'd':  /* default */
  745. X                        /* unused -- use 'set anon_password.' */
  746. X                            case 'm':    /* macdef or machine */
  747. X                                if (strcmp(varname, "macdef"))
  748. X                                    goto done;    /* new machine record... */
  749. X                                dst = macname;
  750. X                                break;
  751. X                            default:
  752. X                                (void) fprintf(stderr, "Unknown %s keyword \"%s\"\n",
  753. X                                    RCNAME,
  754. X                                    varname
  755. X                                );
  756. X                        }
  757. X                        if (dst) {
  758. X                            dp = strtok(ep, RC_DELIM);
  759. X                            if (dp)
  760. X                                (void) strcpy(dst, dp);
  761. X                            if (dst == macname) {
  762. X                                /*
  763. X                                 *    Read in the lines of the macro.
  764. X                                 *    The macro's end is denoted by
  765. X                                 *    a blank line.
  766. X                                 */
  767. X                                (void) make_macro(macname, fp);
  768. X                                goto nextline;
  769. X                            }
  770. X                        }
  771. X                    }
  772. Xnextline: ;
  773. X                } while (cp = FGets(str, fp));
  774. X                break;
  775. X            }        /* end if we found the machine record. */
  776. X        }
  777. Xdone:
  778. X        (void) fclose(fp);
  779. X    }
  780. X
  781. X    if (!site_found) {
  782. X        /* didn't find it in the rc. */
  783. X        return (0);
  784. X    }
  785. X
  786. X    if (*username == NULL) {
  787. X        *username = "anonymous";
  788. X        *pass = anon_password;
  789. X    }
  790. X
  791. X    /* Make sure the password looks like an address. */
  792. X    if (strcmp(*username, "anonymous") == 0) {
  793. X        if (*pass == NULL || index(*pass, '@') == NULL)
  794. X            *pass = anon_password;
  795. X    }
  796. X    return (1);    /* found */
  797. X}    /* ruserpass2 */
  798. X
  799. X/* eof ftprc.c */
  800. END_OF_FILE
  801.   if test 5069 -ne `wc -c <'ftprc.c'`; then
  802.     echo shar: \"'ftprc.c'\" unpacked with wrong size!
  803.   fi
  804.   # end of 'ftprc.c'
  805. fi
  806. if test -f 'glob.c' -a "${1}" != "-c" ; then 
  807.   echo shar: Will not clobber existing file \"'glob.c'\"
  808. else
  809.   echo shar: Extracting \"'glob.c'\" \(9846 characters\)
  810.   sed "s/^X//" >'glob.c' <<'END_OF_FILE'
  811. X/* glob.c */
  812. X
  813. X#include "sys.h"
  814. X#include <sys/param.h>
  815. X#include <sys/stat.h>
  816. X
  817. X/* Dir.h.  Try <sys/dir.h> (add -DSYSDIRH) if <dirent.h> doesn't exist. */
  818. X
  819. X#ifndef SYSDIRH
  820. X#   include <dirent.h>
  821. X#else
  822. X#   include <sys/dir.h>
  823. X#endif
  824. X
  825. X#ifdef SCO324
  826. X#   define direct dirent
  827. X#endif
  828. X
  829. X#include <stdio.h>
  830. X#include <string.h>
  831. X#include <stdlib.h>
  832. X#include <errno.h>
  833. X#include <pwd.h>
  834. X#include "ftpdefs.h"
  835. X#include "glob.h"
  836. X#include "cmds.h"
  837. X#include "copyright.h"
  838. X
  839. X#define    QUOTE 0200
  840. X#define    TRIM 0177
  841. X#define    eq(a,b)        (strcmp(a, b)==0)
  842. X#define    GAVSIZ        (NCARGS/6)
  843. X#define    isdir(d)    ((d.st_mode & S_IFMT) == S_IFDIR)
  844. X
  845. Xstatic ginit(char **agargv);
  846. Xstatic collect(char *as);
  847. Xstatic acollect(char *as);
  848. Xstatic sort(void);
  849. Xstatic expand(char *as);
  850. Xstatic matchdir(char *pattern);
  851. Xstatic execbrc(char *p, char *s);
  852. Xstatic match(char *s, char *p);
  853. Xstatic amatch(char *s, char *p);
  854. Xstatic Gmatch(char *s, char *p);
  855. Xstatic Gcat(char *s1, char *s2);
  856. Xstatic addpath(char c);
  857. Xstatic rscan(char **t, int (*f )(char));
  858. Xstatic tglob(char c);
  859. Xstatic char *strspl(char *cp, char *dp);
  860. Xstatic char *strend(char *cp);
  861. X
  862. Xstatic    char **gargv;    /* Pointer to the (stack) arglist */
  863. Xstatic    int gargc;        /* Number args in gargv */
  864. Xstatic    int gnleft;
  865. Xstatic    short gflag;
  866. Xchar    *globerr;
  867. Xchar    *home;            /* you must initialize this elsewhere! */
  868. Xextern    int errno;
  869. X
  870. Xstatic    int globcnt;
  871. X
  872. Xchar    *globchars = "`{[*?";
  873. X
  874. Xstatic    char *gpath, *gpathp, *lastgpathp;
  875. Xstatic    int globbed;
  876. Xstatic    char *entp;
  877. Xstatic    char **sortbas;
  878. X
  879. Xchar **
  880. Xglob(char *v)
  881. X{
  882. X    char agpath[BUFSIZ];
  883. X    char *agargv[GAVSIZ];
  884. X    char *vv[2];
  885. X    vv[0] = v;
  886. X    vv[1] = 0;
  887. X    gflag = (short) 0;
  888. X    rscan(vv, tglob);
  889. X    if (gflag == (short) 0)
  890. X        return (copyblk(vv));
  891. X
  892. X    globerr = 0;
  893. X    gpath = agpath; gpathp = gpath; *gpathp = 0;
  894. X    lastgpathp = &gpath[sizeof agpath - 2];
  895. X    ginit(agargv); globcnt = 0;
  896. X    collect(v);
  897. X    if (globcnt == 0 && (gflag & (short)1)) {
  898. X        blkfree(gargv), gargv = 0;
  899. X        return (0);
  900. X    } else
  901. X        return (gargv = copyblk(gargv));
  902. X}
  903. X
  904. Xstatic
  905. Xginit(char **agargv)
  906. X{
  907. X    agargv[0] = 0; gargv = agargv; sortbas = agargv; gargc = 0;
  908. X    gnleft = NCARGS - 4;
  909. X}
  910. X
  911. Xstatic
  912. Xcollect(char *as)
  913. X{
  914. X    if (eq(as, "{") || eq(as, "{}")) {
  915. X        Gcat(as, "");
  916. X        sort();
  917. X    } else
  918. X        acollect(as);
  919. X}
  920. X
  921. Xstatic
  922. Xacollect(char *as)
  923. X{
  924. X    register int ogargc = gargc;
  925. X
  926. X    gpathp = gpath; *gpathp = 0; globbed = 0;
  927. X    expand(as);
  928. X    if (gargc != ogargc)
  929. X        sort();
  930. X}
  931. X
  932. Xstatic
  933. Xsort(void)
  934. X{
  935. X    register char **p1, **p2, *c;
  936. X    char **Gvp = &gargv[gargc];
  937. X
  938. X    p1 = sortbas;
  939. X    while (p1 < Gvp-1) {
  940. X        p2 = p1;
  941. X        while (++p2 < Gvp)
  942. X            if (strcmp(*p1, *p2) > 0)
  943. X                c = *p1, *p1 = *p2, *p2 = c;
  944. X        p1++;
  945. X    }
  946. X    sortbas = Gvp;
  947. X}
  948. X
  949. Xstatic
  950. Xexpand(char *as)
  951. X{
  952. X    register char *cs;
  953. X    register char *sgpathp, *oldcs;
  954. X    struct stat stb;
  955. X
  956. X    sgpathp = gpathp;
  957. X    cs = as;
  958. X    if (*cs == '~' && gpathp == gpath) {
  959. X        addpath('~');
  960. X        for (cs++; letter(*cs) || digit(*cs) || *cs == '-';)
  961. X            addpath(*cs++);
  962. X        if (!*cs || *cs == '/') {
  963. X            if (gpathp != gpath + 1) {
  964. X                *gpathp = 0;
  965. X                if (gethdir(gpath + 1))
  966. X                    globerr = "Unknown user name after ~";
  967. X                (void) strcpy(gpath, gpath + 1);
  968. X            } else
  969. X                (void) strcpy(gpath, home);
  970. X            gpathp = strend(gpath);
  971. X        }
  972. X    }
  973. X    while (!any(*cs, globchars)) {
  974. X        if (*cs == 0) {
  975. X            if (!globbed)
  976. X                Gcat(gpath, "");
  977. X            else if (stat(gpath, &stb) >= 0) {
  978. X                Gcat(gpath, "");
  979. X                globcnt++;
  980. X            }
  981. X            goto endit;
  982. X        }
  983. X        addpath(*cs++);
  984. X    }
  985. X    oldcs = cs;
  986. X    while (cs > as && *cs != '/')
  987. X        cs--, gpathp--;
  988. X    if (*cs == '/')
  989. X        cs++, gpathp++;
  990. X    *gpathp = 0;
  991. X    if (*oldcs == '{') {
  992. X        (void) execbrc(cs, ((char *)0));
  993. X        return;
  994. X    }
  995. X    matchdir(cs);
  996. Xendit:
  997. X    gpathp = sgpathp;
  998. X    *gpathp = 0;
  999. X}
  1000. X
  1001. Xstatic
  1002. Xmatchdir(char *pattern)
  1003. X{
  1004. X    struct stat stb;
  1005. X#ifdef SYSDIRH
  1006. X    register struct direct *dp;
  1007. X#else
  1008. X    register struct dirent *dp;
  1009. X#endif
  1010. X    DIR *dirp;
  1011. X
  1012. X    dirp = opendir(gpath);
  1013. X    if (dirp == NULL) {
  1014. X        if (globbed)
  1015. X            return;
  1016. X        goto patherr2;
  1017. X    }
  1018. X    if (fstat(dirp->dd_fd, &stb) < 0)
  1019. X        goto patherr1;
  1020. X    if (!isdir(stb)) {
  1021. X        errno = ENOTDIR;
  1022. X        goto patherr1;
  1023. X    }
  1024. X    while ((dp = readdir(dirp)) != NULL) {
  1025. X        if (dp->d_ino == 0)
  1026. X            continue;
  1027. X        if (match(dp->d_name, pattern)) {
  1028. X            Gcat(gpath, dp->d_name);
  1029. X            globcnt++;
  1030. X        }
  1031. X    }
  1032. X    (void) closedir(dirp);
  1033. X    return;
  1034. X
  1035. Xpatherr1:
  1036. X    (void) closedir(dirp);
  1037. Xpatherr2:
  1038. X    globerr = "Bad directory components";
  1039. X}
  1040. X
  1041. Xstatic
  1042. Xexecbrc(char *p, char *s)
  1043. X{
  1044. X    char restbuf[BUFSIZ + 2];
  1045. X    register char *pe, *pm, *pl;
  1046. X    int brclev = 0;
  1047. X    char *lm, savec, *sgpathp;
  1048. X
  1049. X    for (lm = restbuf; *p != '{'; *lm++ = *p++)
  1050. X        continue;
  1051. X    for (pe = ++p; *pe; pe++)
  1052. X    switch (*pe) {
  1053. X
  1054. X    case '{':
  1055. X        brclev++;
  1056. X        continue;
  1057. X
  1058. X    case '}':
  1059. X        if (brclev == 0)
  1060. X            goto pend;
  1061. X        brclev--;
  1062. X        continue;
  1063. X
  1064. X    case '[':
  1065. X        for (pe++; *pe && *pe != ']'; pe++)
  1066. X            continue;
  1067. X        continue;
  1068. X    }
  1069. Xpend:
  1070. X    brclev = 0;
  1071. X    for (pl = pm = p; pm <= pe; pm++)
  1072. X    switch (*pm & (QUOTE|TRIM)) {
  1073. X
  1074. X    case '{':
  1075. X        brclev++;
  1076. X        continue;
  1077. X
  1078. X    case '}':
  1079. X        if (brclev) {
  1080. X            brclev--;
  1081. X            continue;
  1082. X        }
  1083. X        goto doit;
  1084. X
  1085. X    case ','|QUOTE:
  1086. X    case ',':
  1087. X        if (brclev)
  1088. X            continue;
  1089. Xdoit:
  1090. X        savec = *pm;
  1091. X        *pm = 0;
  1092. X        (void) strcpy(lm, pl);
  1093. X        (void) strcat(restbuf, pe + 1);
  1094. X        *pm = savec;
  1095. X        if (s == 0) {
  1096. X            sgpathp = gpathp;
  1097. X            expand(restbuf);
  1098. X            gpathp = sgpathp;
  1099. X            *gpathp = 0;
  1100. X        } else if (amatch(s, restbuf))
  1101. X            return (1);
  1102. X        sort();
  1103. X        pl = pm + 1;
  1104. X        if (brclev)
  1105. X            return (0);
  1106. X        continue;
  1107. X
  1108. X    case '[':
  1109. X        for (pm++; *pm && *pm != ']'; pm++)
  1110. X            continue;
  1111. X        if (!*pm)
  1112. X            pm--;
  1113. X        continue;
  1114. X    }
  1115. X    if (brclev)
  1116. X        goto doit;
  1117. X    return (0);
  1118. X}
  1119. X
  1120. Xstatic
  1121. Xmatch(char *s, char *p)
  1122. X{
  1123. X    register int c;
  1124. X    register char *sentp;
  1125. X    char sglobbed = globbed;
  1126. X
  1127. X    if (*s == '.' && *p != '.')
  1128. X        return (0);
  1129. X    sentp = entp;
  1130. X    entp = s;
  1131. X    c = amatch(s, p);
  1132. X    entp = sentp;
  1133. X    globbed = sglobbed;
  1134. X    return (c);
  1135. X}
  1136. X
  1137. Xstatic
  1138. Xamatch(char *s, char *p)
  1139. X{
  1140. X    register int scc;
  1141. X    int ok, lc;
  1142. X    char *sgpathp;
  1143. X    struct stat stb;
  1144. X    int c, cc;
  1145. X
  1146. X    globbed = 1;
  1147. X    for (;;) {
  1148. X        scc = *s++ & TRIM;
  1149. X        switch (c = *p++) {
  1150. X
  1151. X        case '{':
  1152. X            return (execbrc(p - 1, s - 1));
  1153. X
  1154. X        case '[':
  1155. X            ok = 0;
  1156. X            lc = 077777;
  1157. X            while (cc = *p++) {
  1158. X                if (cc == ']') {
  1159. X                    if (ok)
  1160. X                        break;
  1161. X                    return (0);
  1162. X                }
  1163. X                if (cc == '-') {
  1164. X                    if (lc <= scc && scc <= *p++)
  1165. X                        ok++;
  1166. X                } else
  1167. X                    if (scc == (lc = cc))
  1168. X                        ok++;
  1169. X            }
  1170. X            if (cc == 0)
  1171. X                if (ok)
  1172. X                    p--;
  1173. X                else
  1174. X                    return 0;
  1175. X            continue;
  1176. X
  1177. X        case '*':
  1178. X            if (!*p)
  1179. X                return (1);
  1180. X            if (*p == '/') {
  1181. X                p++;
  1182. X                goto slash;
  1183. X            }
  1184. X            s--;
  1185. X            do {
  1186. X                if (amatch(s, p))
  1187. X                    return (1);
  1188. X            } while (*s++);
  1189. X            return (0);
  1190. X
  1191. X        case 0:
  1192. X            return (scc == 0);
  1193. X
  1194. X        default:
  1195. X            if (c != scc)
  1196. X                return (0);
  1197. X            continue;
  1198. X
  1199. X        case '?':
  1200. X            if (scc == 0)
  1201. X                return (0);
  1202. X            continue;
  1203. X
  1204. X        case '/':
  1205. X            if (scc)
  1206. X                return (0);
  1207. Xslash:
  1208. X            s = entp;
  1209. X            sgpathp = gpathp;
  1210. X            while (*s)
  1211. X                addpath(*s++);
  1212. X            addpath('/');
  1213. X            if (stat(gpath, &stb) == 0 && isdir(stb))
  1214. X                if (*p == 0) {
  1215. X                    Gcat(gpath, "");
  1216. X                    globcnt++;
  1217. X                } else
  1218. X                    expand(p);
  1219. X            gpathp = sgpathp;
  1220. X            *gpathp = 0;
  1221. X            return (0);
  1222. X        }
  1223. X    }
  1224. X}
  1225. X
  1226. Xstatic
  1227. XGmatch(char *s, char *p)
  1228. X{
  1229. X    register int scc;
  1230. X    int ok, lc;
  1231. X    int c, cc;
  1232. X
  1233. X    for (;;) {
  1234. X        scc = *s++ & TRIM;
  1235. X        switch (c = *p++) {
  1236. X
  1237. X        case '[':
  1238. X            ok = 0;
  1239. X            lc = 077777;
  1240. X            while (cc = *p++) {
  1241. X                if (cc == ']') {
  1242. X                    if (ok)
  1243. X                        break;
  1244. X                    return (0);
  1245. X                }
  1246. X                if (cc == '-') {
  1247. X                    if (lc <= scc && scc <= *p++)
  1248. X                        ok++;
  1249. X                } else
  1250. X                    if (scc == (lc = cc))
  1251. X                        ok++;
  1252. X            }
  1253. X            if (cc == 0)
  1254. X                if (ok)
  1255. X                    p--;
  1256. X                else
  1257. X                    return 0;
  1258. X            continue;
  1259. X
  1260. X        case '*':
  1261. X            if (!*p)
  1262. X                return (1);
  1263. X            for (s--; *s; s++)
  1264. X                if (Gmatch(s, p))
  1265. X                    return (1);
  1266. X            return (0);
  1267. X
  1268. X        case 0:
  1269. X            return (scc == 0);
  1270. X
  1271. X        default:
  1272. X            if ((c & TRIM) != scc)
  1273. X                return (0);
  1274. X            continue;
  1275. X
  1276. X        case '?':
  1277. X            if (scc == 0)
  1278. X                return (0);
  1279. X            continue;
  1280. X
  1281. X        }
  1282. X    }
  1283. X}
  1284. X
  1285. Xstatic
  1286. XGcat(char *s1, char *s2)
  1287. X{
  1288. X    register int len = strlen(s1) + strlen(s2) + 1;
  1289. X
  1290. X    if (len >= gnleft || gargc >= GAVSIZ - 1)
  1291. X        globerr = "Arguments too long";
  1292. X    else {
  1293. X        gargc++;
  1294. X        gnleft -= len;
  1295. X        gargv[gargc] = 0;
  1296. X        gargv[gargc - 1] = strspl(s1, s2);
  1297. X    }
  1298. X}
  1299. X
  1300. Xstatic
  1301. Xaddpath(char c)
  1302. X{
  1303. X
  1304. X    if (gpathp >= lastgpathp)
  1305. X        globerr = "Pathname too long";
  1306. X    else {
  1307. X        *gpathp++ = c;
  1308. X        *gpathp = 0;
  1309. X    }
  1310. X}
  1311. X
  1312. Xstatic
  1313. Xrscan(char **t, int (*f )(char))
  1314. X{
  1315. X    register char *p, c;
  1316. X
  1317. X    while (p = *t++) {
  1318. X        if (f == tglob)
  1319. X            if (*p == '~')
  1320. X                gflag |= (short) 2;
  1321. X            else if (eq(p, "{") || eq(p, "{}"))
  1322. X                continue;
  1323. X        while (c = *p++)
  1324. X            (*f)(c);
  1325. X    }
  1326. X}
  1327. X/*
  1328. Xstatic
  1329. Xscan(t, f)
  1330. X    register char **t;
  1331. X    int (*f)(char);
  1332. X{
  1333. X    register char *p, c;
  1334. X
  1335. X    while (p = *t++)
  1336. X        while (c = *p)
  1337. X            *p++ = (*f)(c);
  1338. X} */
  1339. X
  1340. Xstatic
  1341. Xtglob(char c)
  1342. X{
  1343. X
  1344. X    if (any(c, globchars))
  1345. X        gflag |= (c == '{' ? (short)2 : (short)1);
  1346. X    return (c);
  1347. X}
  1348. X/*
  1349. Xstatic
  1350. Xtrim(c)
  1351. X    char c;
  1352. X{
  1353. X
  1354. X    return (c & TRIM);
  1355. X} */
  1356. X
  1357. X
  1358. Xletter(char c)
  1359. X{
  1360. X    return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_');
  1361. X}
  1362. X
  1363. Xdigit(char c)
  1364. X{
  1365. X    return (c >= '0' && c <= '9');
  1366. X}
  1367. X
  1368. Xany(int c, char *s)
  1369. X{
  1370. X    while (*s)
  1371. X        if (*s++ == c)
  1372. X            return(1);
  1373. X    return(0);
  1374. X}
  1375. X
  1376. Xblklen(char **av)
  1377. X{
  1378. X    register int i = 0;
  1379. X
  1380. X    while (*av++)
  1381. X        i++;
  1382. X    return (i);
  1383. X}
  1384. X
  1385. Xchar **
  1386. Xblkcpy(char **oav, char **bv)
  1387. X{
  1388. X    register char **av = oav;
  1389. X
  1390. X    while (*av++ = *bv++)
  1391. X        continue;
  1392. X    return (oav);
  1393. X}
  1394. X
  1395. Xblkfree(char **av0)
  1396. X{
  1397. X    register char **av = av0;
  1398. X
  1399. X    while (*av)
  1400. X        free(*av++);
  1401. X}
  1402. X
  1403. Xstatic
  1404. Xchar *
  1405. Xstrspl(char *cp, char *dp)
  1406. X{
  1407. X    register char *ep = (char *) malloc((size_t)(strlen(cp) + strlen(dp) + 1L));
  1408. X
  1409. X    if (ep == (char *)0)
  1410. X        fatal("Out of memory");
  1411. X    (void) strcpy(ep, cp);
  1412. X    (void) strcat(ep, dp);
  1413. X    return (ep);
  1414. X}
  1415. X
  1416. Xchar **
  1417. Xcopyblk(char **v)
  1418. X{
  1419. X    register char **nv = (char **)malloc((size_t)((blklen(v) + 1) *
  1420. X                        sizeof(char **)));
  1421. X    if (nv == (char **)0)
  1422. X        fatal("Out of memory");
  1423. X
  1424. X    return (blkcpy(nv, v));
  1425. X}
  1426. X
  1427. Xstatic
  1428. Xchar *
  1429. Xstrend(char *cp)
  1430. X{
  1431. X    while (*cp)
  1432. X        cp++;
  1433. X    return (cp);
  1434. X}
  1435. X
  1436. X/*
  1437. X * Extract a home directory from the password file
  1438. X * The argument points to a buffer where the name of the
  1439. X * user whose home directory is sought is currently.
  1440. X * We write the home directory of the user back there.
  1441. X */
  1442. Xint gethdir(char *home_dir)
  1443. X{
  1444. X    register struct passwd *pp = getpwnam(home_dir);
  1445. X
  1446. X    if (pp == 0)
  1447. X        return (1);
  1448. X    (void) strcpy(home_dir, pp->pw_dir);
  1449. X    return (0);
  1450. X}    /* gethdir */
  1451. X
  1452. X/* eof glob.c */
  1453. END_OF_FILE
  1454.   if test 9846 -ne `wc -c <'glob.c'`; then
  1455.     echo shar: \"'glob.c'\" unpacked with wrong size!
  1456.   fi
  1457.   # end of 'glob.c'
  1458. fi
  1459. if test -f 'glob.h' -a "${1}" != "-c" ; then 
  1460.   echo shar: Will not clobber existing file \"'glob.h'\"
  1461. else
  1462.   echo shar: Extracting \"'glob.h'\" \(240 characters\)
  1463.   sed "s/^X//" >'glob.h' <<'END_OF_FILE'
  1464. X/* glob.h */
  1465. Xchar **glob(char *v);
  1466. Xint letter(char c);
  1467. Xint digit(char c);
  1468. Xint any(int c, char *s);
  1469. Xint blklen(char **av);
  1470. Xchar **blkcpy(char **oav, char **bv);
  1471. Xint blkfree(char **av0);
  1472. Xchar **copyblk(char **v);
  1473. Xint gethdir(char *home_dir);
  1474. END_OF_FILE
  1475.   if test 240 -ne `wc -c <'glob.h'`; then
  1476.     echo shar: \"'glob.h'\" unpacked with wrong size!
  1477.   fi
  1478.   # end of 'glob.h'
  1479. fi
  1480. if test -f 'main.h' -a "${1}" != "-c" ; then 
  1481.   echo shar: Will not clobber existing file \"'main.h'\"
  1482. else
  1483.   echo shar: Extracting \"'main.h'\" \(468 characters\)
  1484.   sed "s/^X//" >'main.h' <<'END_OF_FILE'
  1485. X/* main.h */
  1486. X
  1487. X#ifndef _main_h_
  1488. X#define _main_h_
  1489. X
  1490. Xvoid intr(int unused);
  1491. Xint getuserinfo(void);
  1492. Xint init_arrays(void);
  1493. Xvoid init_transfer_buffer(void);
  1494. Xvoid init_prompt(void);
  1495. Xvoid lostpeer(int unused);
  1496. Xvoid cmdscanner(int top);
  1497. Xchar *strprompt(void);
  1498. Xchar *Strpcpy(char *dst, char *src);
  1499. Xstruct cmd *getcmd(char *name);
  1500. Xvoid makeargv(void);
  1501. Xchar *slurpstring(void);
  1502. Xint help(int argc, char **argv);
  1503. Xvoid trim_log(void);
  1504. Xint CheckNewMail(void);
  1505. X
  1506. X#endif    /* _main_h_ */
  1507. X
  1508. END_OF_FILE
  1509.   if test 468 -ne `wc -c <'main.h'`; then
  1510.     echo shar: \"'main.h'\" unpacked with wrong size!
  1511.   fi
  1512.   # end of 'main.h'
  1513. fi
  1514. if test -f 'ncftp.1' -a "${1}" != "-c" ; then 
  1515.   echo shar: Will not clobber existing file \"'ncftp.1'\"
  1516. else
  1517.   echo shar: Extracting \"'ncftp.1'\" \(13056 characters\)
  1518.   sed "s/^X//" >'ncftp.1' <<'END_OF_FILE'
  1519. X.TH NcFTP 1
  1520. X.SH NAME
  1521. XNcFTP \(em Internet file transfer program
  1522. X.SH SYNOPSIS
  1523. X.B ncftp
  1524. X.RB [ \-v ]
  1525. X.RB [ \-d ]
  1526. X.RB [ \-n ]
  1527. X.RB [ \-H ]
  1528. X.RI [ hostname\c
  1529. X.RI [: pathname ]]
  1530. X.SH DESCRIPTION
  1531. X.I NcFTP
  1532. Xis an alternative user interface to the Internet standard File Transfer
  1533. XProtocol.
  1534. XThe program allows a user to transfer files to and from a
  1535. Xremote network site.
  1536. XThis program offers additional features that
  1537. Xare not found in the standard interface,
  1538. X.IR ftp .
  1539. X.SH FEATURES
  1540. X.TP
  1541. X\(bu
  1542. XBy default, an anonymous login is attempted when you open a site.
  1543. XNo need to enter ``anonymous'' and your email address
  1544. Xevery time you open a site.
  1545. X.TP
  1546. X\(bu
  1547. XYou can save some keystrokes by putting commonly used sites in the
  1548. X.I .netrc
  1549. Xfile, and then just type abbreviations when you open them on the
  1550. Xcommand line.
  1551. XFor example, if you had wuarchive.wustl.edu in your
  1552. X.I .netrc
  1553. Xyou would only need to type ``o wuar'' or ``o wustl''
  1554. X(or any abbreviation that will
  1555. Xseparate it from the rest of the sites in your
  1556. X.IR .netrc ).
  1557. X.TP
  1558. X\(bu
  1559. X.I ncftp
  1560. Xcan keep a log of sites opened and files transferred
  1561. Xfor later reference.
  1562. X.TP
  1563. X\(bu
  1564. X.I ncftp
  1565. Xhas ``implicit\ cd'' where you can just type the name of a directory
  1566. X(when connected) instead of typing ``cd\ <directory>''.
  1567. X.TP
  1568. X\(bu
  1569. XFile transfers use a progress indicator, showing what percentage of
  1570. Xthe file has been transferred.
  1571. X.TP
  1572. X\(bu
  1573. X.I ncftp
  1574. Xhas a built in mini-nslookup facility, for finding IP numbers or site
  1575. Xnames.
  1576. X.TP
  1577. X\(bu
  1578. XThe
  1579. X.I ls
  1580. Xcommand works like ``ls\ \-CF''.
  1581. XSome versions of
  1582. X.I ftp
  1583. Ximplemented
  1584. X.I ls
  1585. Xexactly like
  1586. X.I dir
  1587. X(ls\ \-l).
  1588. X.TP
  1589. X\(bu
  1590. XA
  1591. X.I page
  1592. Xcommand lets you use your pager to read remote files.
  1593. XThere are also the commands
  1594. X.I pls
  1595. Xand
  1596. X.I pdir
  1597. Xwhich let you read directory listings with your pager.
  1598. X.TP
  1599. X\(bu
  1600. XYou don't need to close sites;
  1601. X.I ncftp
  1602. Xcloses an open site when you try to open a different one.
  1603. X.TP
  1604. X\(bu
  1605. XYou can save some typing by using a wildcard to specify one file.
  1606. XFor example, you can type ``get R*'' to fetch a file called README.
  1607. X.TP
  1608. X\(bu
  1609. XYou can invoke
  1610. X.I ncftp
  1611. Xwith ``colon mode'' where you can type ``ncftp\ cse.unl.edu:/pub/foo''
  1612. Xand it will fetch ``foo'' for you then exit.
  1613. X.TP
  1614. X\(bu
  1615. XThere is a
  1616. X.I create
  1617. Xcommand which is useful for creating
  1618. Xmessages on a remote site.
  1619. X.TP
  1620. X\(bu
  1621. X.I ncftp
  1622. Xtells you when new mail has arrived.
  1623. X.TP
  1624. X\(bu
  1625. XFile transfers use a larger buffer, so transfers may be faster.
  1626. X.TP
  1627. X\(bu
  1628. XThe prompt can be customized to include things like the date, time,
  1629. Xcurrent remote working directory, boldface, etc.
  1630. X.TP
  1631. X\(bu
  1632. XThe behavior of
  1633. X.I ncftp
  1634. Xcan be customized with
  1635. X.I set
  1636. Xand
  1637. X.I unset
  1638. Xand the
  1639. X.I .netrc
  1640. Xcan contain commands to set these variables each time you start up.
  1641. X.SH OPTIONS
  1642. X.PP
  1643. XCommand line options:
  1644. X.TP
  1645. X.B \-v
  1646. Xforces
  1647. X.I ncftp
  1648. Xto show all responses from the remote server, as well
  1649. Xas report on data transfer statistics.
  1650. X.TP
  1651. X.B \-n
  1652. Xrestrains
  1653. X.I ncftp
  1654. Xfrom reading the
  1655. X.I .netrc
  1656. X(see below) file in the user's home directory.
  1657. X.TP
  1658. X.B \-d
  1659. Xenables debugging.
  1660. X.TP
  1661. X.B \-H
  1662. Xprints version and compile-time options.
  1663. X.PP
  1664. XThe client host with which
  1665. X.I ncftp
  1666. Xis to communicate may be specified on the command line.
  1667. XIf this is done,
  1668. X.I ncftp
  1669. Xwill immediately attempt to establish a connection to an FTP
  1670. Xserver on that host; otherwise,
  1671. X.I ncftp
  1672. Xwill enter its command interpreter and await instructions
  1673. Xfrom the user.
  1674. X.I ncftp
  1675. Xuses many of the commands provided by
  1676. X.I ftp
  1677. Xbut some old commands will not appear under the main help screen
  1678. Xalthough they are still supported.
  1679. XThis was done to avoid overwhelming the user
  1680. Xwith many commands that do the same thing.
  1681. XExamples of commands that
  1682. Xstill run but don't show up in the help screen are
  1683. X.BR send ,
  1684. X.BR close ,
  1685. X.BR bye ,
  1686. Xand
  1687. X.BR ascii .
  1688. X.SH COMMANDS
  1689. XExplanations of commands specific to
  1690. X.I ncftp
  1691. Xfollow.
  1692. XPlease refer to the manual page for
  1693. X.I ftp
  1694. Xfor descriptions of the standard commands.
  1695. X.TP
  1696. X.I create
  1697. XUse this to create an empty file on the remote site.
  1698. XSometimes it is necessary to leave a note
  1699. Xif you can't get in touch with the remote site's administrator.
  1700. XFor example if a file is corrupted, you could
  1701. Xtype ``create\ Foo.tar_is_corrupt'' so the uploader will replace it.
  1702. X.TP
  1703. X.I lookup
  1704. XUse this if you know a site's IP number but want its name,
  1705. Xor if you know its name but want its IP number.
  1706. XFor example ``lookup cse.unl.edu''
  1707. Xwill spit out ``129.93.1.12'' and vice versa.
  1708. X.TP
  1709. X.I open
  1710. XThis command has been extended to accept flags to specify its behavior.
  1711. XBy default, ``open\ sitename'' tries to login to a site with ``anonymous''
  1712. Xand your email address as the password.  If you would like to specify
  1713. Xa login/password combination (like
  1714. X.I ftp
  1715. Xdoes by default), use the ``\-u'' flag, like ``open\ \-u\ cse.unl.edu.''
  1716. XYou can also specify the ``\-i'' flag if you want to ignore the machine
  1717. Xrecord in your
  1718. X.IR .netrc .
  1719. XOccasionally this is necessary when you have a login/password in the
  1720. X.I .netrc
  1721. Xbut you want to use a different login/password combo.
  1722. X
  1723. X.I ncftp
  1724. Xalso has a ``redial'' feature, the ``\-r'' flag, so if a site is refusing
  1725. Xconnections you can have the program keep trying until you are connected.
  1726. XYou can further customize the redial feature with the ``\-d\ N'' and ``\-g\ N''
  1727. Xflags, which stand for sleep delay and maximum retries respectively.  The
  1728. Xdefault sleep delay is 60 seconds.  If you omit the ``\-g\ N,'' the program
  1729. Xkeeps trying no matter how long it takes (or until you hit the interrupt
  1730. Xkey).  This example shows how to poll ftp.unl.edu every ten minutes
  1731. Xor until 20 retries is reached:  ``open\ \-r\ \-d\ 600\ \-g\ 20\ ftp.unl.edu.''
  1732. XPlease be considerate when you use redialing, so you won't tax the network.
  1733. X
  1734. X.I Open
  1735. Xalso operates in colon mode, where you can specify a file or directory with
  1736. Xthe site name.
  1737. XFor example ``open\ cse.unl.edu:/pub/foo'' can be typed
  1738. Xand if ``foo'' is a file,
  1739. X.I ncftp
  1740. Xwill fetch it and write it in the the current local directory.
  1741. XIf ``foo'' is a directory the current directory is set to ``foo.''
  1742. XNote that if you invoke colon mode from the command line,
  1743. X.I ncftp
  1744. Xexits after it fetches a file (but remains running if the pathname was
  1745. Xa directory).
  1746. XThis is nice if you are reading news and a poster gives
  1747. Xa pathname in the message (often in colon mode format).
  1748. X.TP
  1749. X.I page
  1750. XYou can read a remote file with your pager.
  1751. XIn previous versions of
  1752. X.I ftp
  1753. Xyou could ``get\ myfile.txt\ |more'', but this wasn't widely known.
  1754. X.TP
  1755. X.I pls
  1756. XThis lets you view a
  1757. X.I ls
  1758. Xcommand with your pager.  This command also lets you view compressed
  1759. Xfiles (ending in .Z), by piping the remote file through
  1760. X.I zcat
  1761. Xfirst.
  1762. X.TP
  1763. X.I pdir
  1764. XThis command lets you view a
  1765. X.I dir
  1766. Xcommand with your pager.
  1767. X.TP
  1768. X.I predir
  1769. XThis lets you view the contents of the last
  1770. X.I ls
  1771. Xor
  1772. X.I dir
  1773. Xcommand with your pager.
  1774. X.I ncftp
  1775. Xstores the output of the previous command in memory, so you can
  1776. Xquickly relist the last command without going over the network.
  1777. XThis is handy for slow connections.
  1778. X.TP
  1779. X.I redir
  1780. XThis dumps the contents of the last
  1781. X.I ls
  1782. Xor
  1783. X.I dir
  1784. Xcommand to standard-out.
  1785. X.TP
  1786. X.I version
  1787. XThis prints the version, and compile-time options used.
  1788. X
  1789. X.SH VARIABLES
  1790. X.TP
  1791. X.I set
  1792. X.br
  1793. X.I ncftp
  1794. Xhas some variables that can be set at run time in the
  1795. X.I .netrc
  1796. Xor interactively in the shell.
  1797. XYou can also use the command
  1798. X.I unset
  1799. Xto undefine a variable.
  1800. XIn
  1801. X.IR csh ,
  1802. Xyou type ``set\ var=value'' or ``unset\ var''.
  1803. XIf a variable's value has whitespace in it,
  1804. Xuse double quotes, as in ``set\ var="the\ value"''.
  1805. XYou can also type ``set'' by itself to show the values of all variables.
  1806. XIn the
  1807. X.I .netrc
  1808. Xyou must use ``#set\ var=value'' and ``#unset\ var''.
  1809. XHopefully if you need to use
  1810. X.I ftp
  1811. Xit will think those commands are comments and ignore them.
  1812. X.RS
  1813. X.TP
  1814. X.IR anon-password " (string)"
  1815. Xis set to your email address,
  1816. Xand used as the password when you login anonymously.
  1817. X.TP
  1818. X.IR ansi-escapes " (integer)"
  1819. Xuses ANSI escape sequences for boldface, underline,
  1820. Xand inverse text.  So far this only affects the prompt.
  1821. XThe default is 1 if your
  1822. X.B TERM
  1823. Xis a vt100.
  1824. X.TP
  1825. X.IR auto-binary " (integer)"
  1826. Xwill set binary transfer mode each time you connect
  1827. Xto a remote host.
  1828. X.TP
  1829. X.IR debug " (integer)"
  1830. Xis used to print diagnostic information.
  1831. X.TP
  1832. X.IR local-dir " (string)"
  1833. Xis set to the local current directory.
  1834. XThis is mostly useful to set in the
  1835. X.IR .netrc ,
  1836. Xwhere you may want to always download into a certain directory.
  1837. X.TP
  1838. X.IR logfile " (string)"
  1839. Xis the log file that saves which sites you've opened
  1840. Xand what files you've transferred.
  1841. XIt should be set in the
  1842. X.IR .netrc .
  1843. X.TP
  1844. X.IR logsize " (integer)"
  1845. Xis the maximum size of the log before
  1846. X.I ncftp
  1847. Xdeletes old entries to keep the log around
  1848. X.IR logsize.
  1849. X.TP
  1850. X.IR mprompt " (1 or 0)"
  1851. Xspecifies whether you want the
  1852. X.IR mget ,
  1853. X.IR mput ,
  1854. Xetc., commands ask what to do with each file.
  1855. X.TP
  1856. X.IR pager " (string)"
  1857. Xis the program used to page remote files.
  1858. XIf you don't set it,
  1859. Xit defaults to the value of the
  1860. X.B PAGER
  1861. Xenvironment variable.
  1862. X.TP
  1863. X.IR prompt " (string)"
  1864. Xis the command line prompt,
  1865. Xwhich may use several @ and % flags (see below).
  1866. X.TP
  1867. X.IR progress-reports " (1 or 0)"
  1868. Xshows the percentage of the file being transferred on
  1869. Xremote sites that support the SIZE command.
  1870. X.TP
  1871. X.IR remote-is-unix " (1 or 0)"
  1872. Xis true when the remote site seems to be a UNIX
  1873. Xmachine.
  1874. XThe only reason one would want to unset
  1875. Xthis variable is when the program thinks a remote
  1876. Xhost is UNIX when it actually isn't.
  1877. X.TP
  1878. X.IR type " (string)"
  1879. Xis the current file transfer type, like ``image''.
  1880. X.TP
  1881. X.IR verbose " (integer)"
  1882. Xcontrols the level of output produced by the program.
  1883. X\-1 is quiet mode,
  1884. Xwhere it won't print anything, 0 is normal mode, where only errors are
  1885. Xdisplayed, 1 is terse mode, where errors and messages from fancy ftp
  1886. Xservers like wuarchive.wustl.edu are printed, and 2 is verbose mode, where plenty of output (mostly junk)
  1887. Xis produced.
  1888. X.RE
  1889. X.SH PROMPTS
  1890. X.PP
  1891. XThe following flags insert special values into the prompt:
  1892. X.TP
  1893. X.B @B
  1894. XTurns on boldface mode.
  1895. X.TP
  1896. X.B @D
  1897. XInserts the current remote directory.
  1898. X.TP
  1899. X.BR @E " or " @!
  1900. XInserts the event number (how many commands you've typed).
  1901. X.TP
  1902. X.B @H
  1903. XInserts the name of the remote host.
  1904. X.TP
  1905. X.BR @I " or " @R
  1906. XTurns on inverse (reverse) video mode.
  1907. X.TP
  1908. X.B @M
  1909. XInserts ``(Mail)\0'' if you have mail.
  1910. X.TP
  1911. X.B @P
  1912. XTurns off any video modes you might have set with
  1913. X.BR @B ,
  1914. X.BR @I ,
  1915. X.BR @R ,
  1916. Xor
  1917. X.B @U
  1918. X(if you have a vt100-ish terminal).
  1919. X.TP
  1920. X.B @U
  1921. XTurns on underline mode (if you have a vt100-ish terminal).
  1922. X.PP
  1923. XThe prompt may also contain % flags used by
  1924. X.IR strftime (3)
  1925. Xso you can insert the time or date to your liking.
  1926. XFor example,
  1927. Xput ``#set\ prompt="@!\ %I:%M\ %p\ @D \->"'' in your
  1928. X.I .netrc
  1929. Xto show the event, the time of day, AM or PM, and the current
  1930. Xremote directory in your prompt.
  1931. X.SH NETRC
  1932. XMany users of
  1933. X.I ftp
  1934. Xleave the power of the 
  1935. X.I .netrc
  1936. Xuntapped.
  1937. XWith
  1938. X.IR ncftp ,
  1939. Xthe file should begin with
  1940. X.I #set
  1941. Xand
  1942. X.I #unset
  1943. Xcommands which
  1944. X.I ncftp
  1945. Xruns at startup, followed by machine entries.
  1946. XWhen
  1947. X.I ncftp
  1948. Xruns, it looks for
  1949. X.I netrc
  1950. Xin the current directory, and if it doesn't exist the program looks for
  1951. X.I .netrc
  1952. Xin the current directory, and if it doesn't exist either the program tries
  1953. Xlooking for
  1954. X.I .netrc
  1955. Xin your home directory before giving up.
  1956. XHere is a sample
  1957. X.I .netrc
  1958. Xfile that shows what you can do with it:
  1959. X
  1960. X.nf
  1961. X#set logfile /user/students/ugrad/mgleason/.ftplog
  1962. X#set prompt="@B@E @UNcFTP@P @B@M@D@P ->"
  1963. X
  1964. Xmachine sumex-aim.stanford.edu
  1965. X    macdef init
  1966. X        cd /info-mac
  1967. X        get ./help/recent-files.txt "|grep -v '.abs' > sumex
  1968. X        !less sumex
  1969. X        pwd
  1970. X
  1971. X# This site is in here just so I can use ``apple''
  1972. X# as an abbreviation.
  1973. Xmachine ftp.apple.com 
  1974. X
  1975. X# ncftp will only ask for your password:
  1976. Xmachine cse.unl.edu login mgleason
  1977. X
  1978. X# You can supply a login and a password:
  1979. Xmachine fake.machine.unl.edu
  1980. X    login mgleason
  1981. X    password mypass
  1982. X    macdef init
  1983. X    cd ./foo/bar
  1984. X
  1985. X# If an antiquated non-UNIX machine doesn't use 
  1986. X# the "SYST" command, you may need to unset 
  1987. X# remote-is-unix, if the remote host complains
  1988. X# about ``ls -CF.''
  1989. Xmachine some.vms.unl.edu
  1990. X    macdef init
  1991. X    unset remote-is-unix
  1992. X.fi
  1993. X
  1994. X.SH ENVIRONMENT
  1995. X.I ncftp
  1996. Xuses the following environment variables:
  1997. X.nr n \w'TERMCAP\0\0\0'+1n-1/1n
  1998. X.TP \nn
  1999. X.B HOME
  2000. Xfor default location of a
  2001. X.I .netrc
  2002. Xfile, if
  2003. X.I ./netrc
  2004. Xand
  2005. X.I ./.netrc
  2006. Xdo not exist;
  2007. X.TP
  2008. X.B PAGER
  2009. Xfor the default filter used by the
  2010. X.I page
  2011. Xcommand;
  2012. X.TP
  2013. X.B SHELL
  2014. Xfor shell escapes;
  2015. X.TP
  2016. X.B MAIL
  2017. Xfor detecting new mail;
  2018. X.TP
  2019. X.BR TERM " and"
  2020. X.PD 0
  2021. X.TP
  2022. X.B TERMCAP
  2023. Xfor retrieving ansi-escapes.
  2024. X.PD
  2025. X.SH AUTHORS
  2026. X.I ncftp
  2027. Xwas written by Mike Gleason,
  2028. X.I NCEMRSoft
  2029. X(mgleason@cse.unl.edu), and based on code by the authors of the
  2030. X.I ftp
  2031. Xfrom the BSD 4.3 distribution.
  2032. X.I ncftp
  2033. Xis copyrighted 1992 by NCEMRSoft
  2034. Xand 1985, 1989 by the Regents of California.
  2035. X.PP
  2036. XSome code and much debugging done by Phil Dietz,
  2037. X.I NCEMRSoft
  2038. X(pdietz@cse.unl.edu).
  2039. X.PP
  2040. XExtensive man page formatting work
  2041. Xby DaviD W. Sanderson (dws@ssec.wisc.edu).
  2042. X.PP
  2043. XJan-Piet Mens (jpm@Logix.DE) added termcap support and did the SCO port.
  2044. X.SH BUGS
  2045. XCorrect execution of many commands depends upon proper behavior
  2046. Xby the remote server.
  2047. X.SP
  2048. XTermcap padding is not correctly displayed.
  2049. X.SH "SEE ALSO"
  2050. X.IR strftime (3),
  2051. X.IR ftpd (8),
  2052. X.IR ftp (1),
  2053. X.IR nslookup (1),
  2054. X.IR compress (1),
  2055. X.IR zcat (1),
  2056. X.IR tftp (1).
  2057. END_OF_FILE
  2058.   if test 13056 -ne `wc -c <'ncftp.1'`; then
  2059.     echo shar: \"'ncftp.1'\" unpacked with wrong size!
  2060.   fi
  2061.   # end of 'ncftp.1'
  2062. fi
  2063. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  2064.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  2065. else
  2066.   echo shar: Extracting \"'patchlevel.h'\" \(80 characters\)
  2067.   sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  2068. X/* patchlevel.h */
  2069. X
  2070. X/*
  2071. X * v1.0.0 - December 6, 1992.
  2072. X *    Initial release.
  2073. X */
  2074. END_OF_FILE
  2075.   if test 80 -ne `wc -c <'patchlevel.h'`; then
  2076.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  2077.   fi
  2078.   # end of 'patchlevel.h'
  2079. fi
  2080. echo shar: End of archive 3 \(of 3\).
  2081. cp /dev/null ark3isdone
  2082. MISSING=""
  2083. for I in 1 2 3 ; do
  2084.     if test ! -f ark${I}isdone ; then
  2085.     MISSING="${MISSING} ${I}"
  2086.     fi
  2087. done
  2088. if test "${MISSING}" = "" ; then
  2089.     echo You have unpacked all 3 archives.
  2090.     rm -f ark[1-9]isdone
  2091. else
  2092.     echo You still must unpack the following archives:
  2093.     echo "        " ${MISSING}
  2094. fi
  2095. exit 0
  2096. exit 0 # Just in case...
  2097.