home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume35 / ncftp / part03 < prev    next >
Encoding:
Text File  |  1993-01-24  |  54.6 KB  |  2,348 lines

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