home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sources / misc / 4285 < prev    next >
Encoding:
Text File  |  1993-01-25  |  54.8 KB  |  2,354 lines

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