home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume19 / xgetftp / part01 < prev    next >
Encoding:
Text File  |  1993-04-27  |  40.3 KB  |  1,387 lines

  1. Newsgroups: comp.sources.x
  2. From: salim@tigger.cs.colorado.edu (Salim Alam)
  3. Subject: v19i022:  xgetftp - Friendly anonymous ftp tool, Part01/04
  4. Message-ID: <csx-v19i022=xgetftp.104700@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 240da1f93ec6649cb398326c6921cbc6
  6. Date: Wed, 10 Mar 1993 16:47:41 GMT
  7. Approved: chris@sparky.imd.sterling.com
  8.  
  9. Submitted-by: salim@tigger.cs.colorado.edu (Salim Alam)
  10. Posting-number: Volume 19, Issue 22
  11. Archive-name: xgetftp/part01
  12. Environment: X11, OSF/Motif
  13.  
  14.  
  15. GETFTP v1.0 RELEASE
  16.  
  17. getftp is a sophisticated browsing and file retrieval tool for anonymous
  18. ftp.  Features include:
  19.  
  20.    o  X/Motif User-interface
  21.    o  Remote directory caching
  22.    o  Easy remote file viewing
  23.    o  Reuse of previously cached directory information
  24.    o  Reuse of previously cached files
  25.    o  Simple multiple file and directory retrieval
  26.  
  27. This submission consists of 4 shar files.
  28.  
  29. --------------------  cut here (shar file 1) -----------------------------
  30. #! /bin/sh
  31. # This is a shell archive.  Remove anything before this line, then unpack
  32. # it by saving it into a file and typing "sh file".  To overwrite existing
  33. # files, type "sh file -c".  You can also feed this as standard input via
  34. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  35. # will see the following message at the end:
  36. #        "End of archive 1 (of 4)."
  37. # Contents:  BLURB Imakefile Makefile Manifest README TODO cache.c
  38. #   cache.h config.h
  39. # Wrapped by salim@anchor on Mon Mar  8 14:04:19 1993
  40. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  41. if test -f 'BLURB' -a "${1}" != "-c" ; then 
  42.   echo shar: Will not clobber existing file \"'BLURB'\"
  43. else
  44. echo shar: Extracting \"'BLURB'\" \(471 characters\)
  45. sed "s/^X//" >'BLURB' <<'END_OF_FILE'
  46. X
  47. XXGETFTP v1.0 RELEASE
  48. X
  49. Xxgetftp is a sophisticated browsing and file retrieval tool for anonymous
  50. Xftp.  Features include:
  51. X
  52. X   o  X/Motif User-interface
  53. X   
  54. X   o  Remote directory caching
  55. X
  56. X   o  Easy remote file viewing
  57. X  
  58. X   o  Reuse of previously cached directory information
  59. X
  60. X   o  Reuse of previously cached files
  61. X
  62. X   o  Simple multiple file and directory retrieval
  63. X
  64. X   o  Interface to Archie
  65. X
  66. Xxgetftp is available on export.lcs.mit.edu as contrib/xgetftp-v1.0.tar.Z.
  67. X
  68. END_OF_FILE
  69. if test 471 -ne `wc -c <'BLURB'`; then
  70.     echo shar: \"'BLURB'\" unpacked with wrong size!
  71. fi
  72. # end of 'BLURB'
  73. fi
  74. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  75.   echo shar: Will not clobber existing file \"'Imakefile'\"
  76. else
  77. echo shar: Extracting \"'Imakefile'\" \(354 characters\)
  78. sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  79. X                 CC = gcc 
  80. X#       CDEBUGFLAGS = -g -DDEBUG
  81. X    EXTRA_LIBRARIES = -lXm -lXt -lX11
  82. X               SRCS = cache.c control.c file_cache.c ftp.c \
  83. X                        main.c prefs.c ui_funcs.c 
  84. X               OBJS = cache.o control.o file_cache.o ftp.o \
  85. X                        main.o prefs.o ui_funcs.o 
  86. X
  87. XComplexProgramTarget(xgetftp)
  88. X
  89. END_OF_FILE
  90. if test 354 -ne `wc -c <'Imakefile'`; then
  91.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  92. fi
  93. # end of 'Imakefile'
  94. fi
  95. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  96.   echo shar: Will not clobber existing file \"'Makefile'\"
  97. else
  98. echo shar: Extracting \"'Makefile'\" \(17441 characters\)
  99. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  100. X# Makefile generated by imake - do not edit!
  101. X# $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $
  102. X#
  103. X# The cpp used on this machine replaces all newlines and multiple tabs and
  104. X# spaces in a macro expansion with a single space.  Imake tries to compensate
  105. X# for this, but is not always successful.
  106. X#
  107. X
  108. X# -------------------------------------------------------------------------
  109. X# Makefile generated from "Imake.tmpl" and </tmp/IIf.022747>
  110. X# $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  111. X#
  112. X# Platform-specific parameters may be set in the appropriate <vendor>.cf
  113. X# configuration files.  Site-specific parameters should be set in the file
  114. X# site.def.  Full rebuilds are recommended if any parameters are changed.
  115. X#
  116. X# If your C preprocessor does not define any unique symbols, you will need
  117. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  118. X# "make World" the first time).
  119. X#
  120. X
  121. X# -------------------------------------------------------------------------
  122. X# site-specific configuration parameters that need to come before
  123. X# the platform-specific parameters - edit site.def to change
  124. X
  125. X# site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  126. X
  127. X# -------------------------------------------------------------------------
  128. X# platform-specific configuration parameters - edit sun.cf to change
  129. X
  130. X# platform:  $XConsortium: sun.cf,v 1.72.1.1 92/03/18 13:13:37 rws Exp $
  131. X
  132. X# operating system:  SunOS 4.1
  133. X
  134. X# $XConsortium: sunLib.rules,v 1.7 91/12/20 11:19:47 rws Exp $
  135. X
  136. X# -------------------------------------------------------------------------
  137. X# site-specific configuration parameters that go after
  138. X# the platform-specific parameters - edit site.def to change
  139. X
  140. X# site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  141. X
  142. X            SHELL = /bin/sh
  143. X
  144. X              TOP = .
  145. X      CURRENT_DIR = .
  146. X
  147. X               AR = ar clq
  148. X  BOOTSTRAPCFLAGS =
  149. X               CC = cc
  150. X               AS = as
  151. X
  152. X         COMPRESS = compress
  153. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  154. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  155. X          INSTALL = install
  156. X               LD = ld
  157. X             LINT = lint
  158. X      LINTLIBFLAG = -C
  159. X         LINTOPTS = -axz
  160. X               LN = ln -s
  161. X             MAKE = make
  162. X               MV = mv
  163. X               CP = cp
  164. X
  165. X           RANLIB = ranlib
  166. X  RANLIBINSTFLAGS =
  167. X
  168. X               RM = rm -f
  169. X            TROFF = psroff
  170. X         MSMACROS = -ms
  171. X              TBL = tbl
  172. X              EQN = eqn
  173. X     STD_INCLUDES =
  174. X  STD_CPP_DEFINES =
  175. X      STD_DEFINES =
  176. X EXTRA_LOAD_FLAGS =
  177. X  EXTRA_LIBRARIES =
  178. X             TAGS = ctags
  179. X
  180. X    SHAREDCODEDEF = -DSHAREDCODE
  181. X         SHLIBDEF = -DSUNSHLIB
  182. X
  183. X    PROTO_DEFINES =
  184. X
  185. X     INSTPGMFLAGS =
  186. X
  187. X     INSTBINFLAGS = -m 0755
  188. X     INSTUIDFLAGS = -m 4755
  189. X     INSTLIBFLAGS = -m 0644
  190. X     INSTINCFLAGS = -m 0444
  191. X     INSTMANFLAGS = -m 0444
  192. X     INSTDATFLAGS = -m 0444
  193. X    INSTKMEMFLAGS = -g kmem -m 2755
  194. X
  195. X      PROJECTROOT = /usr/local/X.V11R5
  196. X
  197. X     TOP_INCLUDES = -I$(INCROOT)
  198. X
  199. X      CDEBUGFLAGS = -O
  200. X        CCOPTIONS = -pipe
  201. X
  202. X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  203. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES)
  204. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  205. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  206. X
  207. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  208. X
  209. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR)
  210. X
  211. X   LDCOMBINEFLAGS = -X -r
  212. X      DEPENDFLAGS =
  213. X
  214. X        MACROFILE = sun.cf
  215. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  216. X
  217. X    IMAKE_DEFINES =
  218. X
  219. X         IRULESRC = $(CONFIGDIR)
  220. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  221. X
  222. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  223. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  224. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  225. X
  226. X# -------------------------------------------------------------------------
  227. X# X Window System Build Parameters
  228. X# $XConsortium: Project.tmpl,v 1.138 91/09/10 09:02:12 rws Exp $
  229. X
  230. X# -------------------------------------------------------------------------
  231. X# X Window System make variables; this need to be coordinated with rules
  232. X
  233. X          PATHSEP = /
  234. X        USRLIBDIR = /usr/local/X.V11R5/lib
  235. X           BINDIR = /usr/local/X.V11R5/bin
  236. X          INCROOT = /usr/local/X.V11R5/include
  237. X     BUILDINCROOT = $(TOP)
  238. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  239. X      BUILDINCTOP = ..
  240. X           INCDIR = $(INCROOT)/X11
  241. X           ADMDIR = /usr/adm
  242. X           LIBDIR = $(USRLIBDIR)
  243. X        CONFIGDIR = $(LIBDIR)/config
  244. X       LINTLIBDIR = $(USRLIBDIR)/lint
  245. X
  246. X          FONTDIR = $(LIBDIR)/fonts
  247. X         XINITDIR = $(LIBDIR)/xinit
  248. X           XDMDIR = $(LIBDIR)/xdm
  249. X           TWMDIR = $(LIBDIR)/twm
  250. X          MANPATH = /usr/local/X.V11R5/man
  251. X    MANSOURCEPATH = $(MANPATH)/man
  252. X        MANSUFFIX = 1
  253. X     LIBMANSUFFIX = 3
  254. X           MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
  255. X        LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX)
  256. X           NLSDIR = $(LIBDIR)/nls
  257. X        PEXAPIDIR = $(LIBDIR)/PEX
  258. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  259. X       FONTCFLAGS = -t
  260. X
  261. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  262. X
  263. X            IMAKE = imake
  264. X           DEPEND = makedepend
  265. X              RGB = rgb
  266. X
  267. X            FONTC = bdftopcf
  268. X
  269. X        MKFONTDIR = mkfontdir
  270. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier
  271. X
  272. X        CONFIGSRC = $(TOP)/config
  273. X       DOCUTILSRC = $(TOP)/doc/util
  274. X        CLIENTSRC = $(TOP)/clients
  275. X          DEMOSRC = $(TOP)/demos
  276. X           LIBSRC = $(TOP)/lib
  277. X          FONTSRC = $(TOP)/fonts
  278. X       INCLUDESRC = $(TOP)/X11
  279. X        SERVERSRC = $(TOP)/server
  280. X          UTILSRC = $(TOP)/util
  281. X        SCRIPTSRC = $(UTILSRC)/scripts
  282. X       EXAMPLESRC = $(TOP)/examples
  283. X       CONTRIBSRC = $(TOP)/../contrib
  284. X           DOCSRC = $(TOP)/doc
  285. X           RGBSRC = $(TOP)/rgb
  286. X        DEPENDSRC = $(UTILSRC)/makedepend
  287. X         IMAKESRC = $(CONFIGSRC)
  288. X         XAUTHSRC = $(LIBSRC)/Xau
  289. X          XLIBSRC = $(LIBSRC)/X
  290. X           XMUSRC = $(LIBSRC)/Xmu
  291. X       TOOLKITSRC = $(LIBSRC)/Xt
  292. X       AWIDGETSRC = $(LIBSRC)/Xaw
  293. X       OLDXLIBSRC = $(LIBSRC)/oldX
  294. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  295. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  296. X      BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf
  297. X      BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf
  298. X     MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir
  299. X         FSLIBSRC = $(FONTSRC)/lib/fs
  300. X    FONTSERVERSRC = $(FONTSRC)/server
  301. X     EXTENSIONSRC = $(TOP)/extensions
  302. X         XILIBSRC = $(EXTENSIONSRC)/lib/xinput
  303. X      PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX
  304. X
  305. X# $XConsortium: sunLib.tmpl,v 1.14.1.1 92/03/17 14:58:46 rws Exp $
  306. X
  307. XSHLIBLDFLAGS = -assert pure-text
  308. XPICFLAGS = -pic
  309. X
  310. X  DEPEXTENSIONLIB =
  311. X     EXTENSIONLIB = -lXext
  312. X
  313. X          DEPXLIB = $(DEPEXTENSIONLIB)
  314. X             XLIB = $(EXTENSIONLIB) -lX11
  315. X
  316. X        DEPXMULIB = $(USRLIBDIR)/libXmu.sa.$(SOXMUREV)
  317. X       XMULIBONLY = -lXmu
  318. X           XMULIB = -lXmu
  319. X
  320. X       DEPOLDXLIB =
  321. X          OLDXLIB = -loldX
  322. X
  323. X      DEPXTOOLLIB = $(USRLIBDIR)/libXt.sa.$(SOXTREV)
  324. X         XTOOLLIB = -lXt
  325. X
  326. X        DEPXAWLIB = $(USRLIBDIR)/libXaw.sa.$(SOXAWREV)
  327. X           XAWLIB = -lXaw
  328. X
  329. X        DEPXILIB =
  330. X           XILIB = -lXi
  331. X
  332. X        SOXLIBREV = 4.10
  333. X          SOXTREV = 4.10
  334. X         SOXAWREV = 5.0
  335. X        SOOLDXREV = 4.10
  336. X         SOXMUREV = 4.10
  337. X        SOXEXTREV = 4.10
  338. X      SOXINPUTREV = 4.10
  339. X
  340. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  341. X         XAUTHLIB =  -lXau
  342. X      DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
  343. X         XDMCPLIB =  -lXdmcp
  344. X
  345. X        DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
  346. X           PHIGSLIB =  -lphigs
  347. X
  348. X       DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
  349. X          XBSDLIB =  -lXbsd
  350. X
  351. X LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln
  352. X         LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln
  353. X          LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln
  354. X        LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln
  355. X          LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln
  356. X           LINTXI = $(LINTLIBDIR)/llib-lXi.ln
  357. X        LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln
  358. X
  359. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  360. X
  361. X         DEPLIBS1 = $(DEPLIBS)
  362. X         DEPLIBS2 = $(DEPLIBS)
  363. X         DEPLIBS3 = $(DEPLIBS)
  364. X
  365. X# -------------------------------------------------------------------------
  366. X# Imake rules for building libraries, programs, scripts, and data files
  367. X# rules:  $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $
  368. X
  369. X# -------------------------------------------------------------------------
  370. X# start of Imakefile
  371. X
  372. X                 CC = gcc
  373. X#       CDEBUGFLAGS = -g -DDEBUG
  374. X    EXTRA_LIBRARIES = -lXm -lXt -lX11
  375. X               SRCS = cache.c control.c file_cache.c ftp.c \
  376. X                        main.c prefs.c ui_funcs.c
  377. X               OBJS = cache.o control.o file_cache.o ftp.o \
  378. X                        main.o prefs.o ui_funcs.o
  379. X
  380. X PROGRAM = xgetftp
  381. X
  382. Xall:: xgetftp
  383. X
  384. Xxgetftp: $(OBJS) $(DEPLIBS)
  385. X    $(RM) $@
  386. X    $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
  387. X
  388. Xsaber_xgetftp:: $(SRCS)
  389. X    # load $(ALLDEFINES) $(SRCS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  390. X
  391. Xosaber_xgetftp:: $(OBJS)
  392. X    # load $(ALLDEFINES) $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  393. X
  394. Xinstall:: xgetftp
  395. X    @if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \
  396. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi
  397. X    $(INSTALL) -c $(INSTPGMFLAGS)  xgetftp $(DESTDIR)$(BINDIR)
  398. X
  399. Xinstall.man:: xgetftp.man
  400. X    @if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \
  401. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi
  402. X    $(INSTALL) -c $(INSTMANFLAGS) xgetftp.man $(DESTDIR)$(MANDIR)/xgetftp.$(MANSUFFIX)
  403. X
  404. Xdepend::
  405. X    $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  406. X
  407. Xlint:
  408. X    $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
  409. Xlint1:
  410. X    $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  411. X
  412. Xclean::
  413. X    $(RM) $(PROGRAM)
  414. X
  415. X# -------------------------------------------------------------------------
  416. X# common rules for all Makefiles - do not edit
  417. X
  418. Xemptyrule::
  419. X
  420. Xclean::
  421. X    $(RM_CMD) "#"*
  422. X
  423. XMakefile::
  424. X    -@if [ -f Makefile ]; then set -x; \
  425. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  426. X    else exit 0; fi
  427. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  428. X
  429. Xtags::
  430. X    $(TAGS) -w *.[ch]
  431. X    $(TAGS) -xw *.[ch] > TAGS
  432. X
  433. Xsaber:
  434. X    # load $(ALLDEFINES) $(SRCS)
  435. X
  436. Xosaber:
  437. X    # load $(ALLDEFINES) $(OBJS)
  438. X
  439. X# -------------------------------------------------------------------------
  440. X# empty rules for directories that do not have SUBDIRS - do not edit
  441. X
  442. Xinstall::
  443. X    @echo "install in $(CURRENT_DIR) done"
  444. X
  445. Xinstall.man::
  446. X    @echo "install.man in $(CURRENT_DIR) done"
  447. X
  448. XMakefiles::
  449. X
  450. Xincludes::
  451. X
  452. X# -------------------------------------------------------------------------
  453. X# dependencies generated by makedepend
  454. X
  455. X# DO NOT DELETE
  456. X
  457. Xcache.o: /usr/include/stdio.h cache.h
  458. Xcontrol.o: /usr/local/X.V11R5/include/X11/Xos.h
  459. Xcontrol.o: /usr/local/X.V11R5/include/X11/Xosdefs.h /usr/include/sys/types.h
  460. Xcontrol.o: /usr/include/sys/stdtypes.h /usr/include/sys/sysmacros.h
  461. Xcontrol.o: /usr/include/string.h /usr/include/fcntl.h
  462. Xcontrol.o: /usr/include/sys/fcntlcom.h /usr/include/sys/stat.h
  463. Xcontrol.o: /usr/include/unistd.h /usr/include/sys/time.h
  464. Xcontrol.o: /usr/include/sys/time.h /usr/include/stdio.h /usr/include/malloc.h
  465. Xcontrol.o: ftp.h cache.h file_cache.h control.h prefs.h
  466. Xcontrol.o: /usr/local/X.V11R5/include/X11/Intrinsic.h
  467. Xcontrol.o: /usr/local/X.V11R5/include/X11/Xlib.h
  468. Xcontrol.o: /usr/local/X.V11R5/include/X11/X.h
  469. Xcontrol.o: /usr/local/X.V11R5/include/X11/Xfuncproto.h /usr/include/stddef.h
  470. Xcontrol.o: /usr/local/X.V11R5/include/X11/Xutil.h
  471. Xcontrol.o: /usr/local/X.V11R5/include/X11/Xresource.h
  472. Xcontrol.o: /usr/local/X.V11R5/include/X11/Core.h
  473. Xcontrol.o: /usr/local/X.V11R5/include/X11/Composite.h
  474. Xcontrol.o: /usr/local/X.V11R5/include/X11/Constraint.h
  475. Xcontrol.o: /usr/local/X.V11R5/include/X11/Object.h
  476. Xcontrol.o: /usr/local/X.V11R5/include/X11/RectObj.h
  477. Xfile_cache.o: /usr/include/stdio.h /usr/local/X.V11R5/include/X11/Xos.h
  478. Xfile_cache.o: /usr/local/X.V11R5/include/X11/Xosdefs.h
  479. Xfile_cache.o: /usr/include/sys/types.h /usr/include/sys/stdtypes.h
  480. Xfile_cache.o: /usr/include/sys/sysmacros.h /usr/include/string.h
  481. Xfile_cache.o: /usr/include/fcntl.h /usr/include/sys/fcntlcom.h
  482. Xfile_cache.o: /usr/include/sys/stat.h /usr/include/unistd.h
  483. Xfile_cache.o: /usr/include/sys/time.h /usr/include/sys/time.h
  484. Xfile_cache.o: /usr/include/malloc.h /usr/include/stdlib.h
  485. Xfile_cache.o: /usr/include/dirent.h /usr/include/sys/dirent.h
  486. Xftp.o: /usr/local/X.V11R5/include/X11/Xos.h
  487. Xftp.o: /usr/local/X.V11R5/include/X11/Xosdefs.h /usr/include/sys/types.h
  488. Xftp.o: /usr/include/sys/stdtypes.h /usr/include/sys/sysmacros.h
  489. Xftp.o: /usr/include/string.h /usr/include/fcntl.h /usr/include/sys/fcntlcom.h
  490. Xftp.o: /usr/include/sys/stat.h /usr/include/unistd.h /usr/include/sys/time.h
  491. Xftp.o: /usr/include/sys/time.h /usr/include/stdio.h /usr/include/sys/socket.h
  492. Xftp.o: /usr/include/netinet/in.h /usr/include/arpa/inet.h
  493. Xftp.o: /usr/include/netdb.h /usr/include/errno.h /usr/include/sys/errno.h
  494. Xftp.o: /usr/local/X.V11R5/include/X11/Intrinsic.h
  495. Xftp.o: /usr/local/X.V11R5/include/X11/Xlib.h
  496. Xftp.o: /usr/local/X.V11R5/include/X11/X.h
  497. Xftp.o: /usr/local/X.V11R5/include/X11/Xfuncproto.h /usr/include/stddef.h
  498. Xftp.o: /usr/local/X.V11R5/include/X11/Xutil.h
  499. Xftp.o: /usr/local/X.V11R5/include/X11/Xresource.h
  500. Xftp.o: /usr/local/X.V11R5/include/X11/Core.h
  501. Xftp.o: /usr/local/X.V11R5/include/X11/Composite.h
  502. Xftp.o: /usr/local/X.V11R5/include/X11/Constraint.h
  503. Xftp.o: /usr/local/X.V11R5/include/X11/Object.h
  504. Xftp.o: /usr/local/X.V11R5/include/X11/RectObj.h
  505. Xmain.o: /usr/local/X.V11R5/include/X11/Xos.h
  506. Xmain.o: /usr/local/X.V11R5/include/X11/Xosdefs.h /usr/include/sys/types.h
  507. Xmain.o: /usr/include/sys/stdtypes.h /usr/include/sys/sysmacros.h
  508. Xmain.o: /usr/include/string.h /usr/include/fcntl.h
  509. Xmain.o: /usr/include/sys/fcntlcom.h /usr/include/sys/stat.h
  510. Xmain.o: /usr/include/unistd.h /usr/include/sys/time.h /usr/include/sys/time.h
  511. Xmain.o: /usr/local/X.V11R5/include/Xm/Xm.h
  512. Xmain.o: /usr/local/X.V11R5/include/X11/Intrinsic.h
  513. Xmain.o: /usr/local/X.V11R5/include/X11/Xlib.h
  514. Xmain.o: /usr/local/X.V11R5/include/X11/X.h
  515. Xmain.o: /usr/local/X.V11R5/include/X11/Xfuncproto.h /usr/include/stddef.h
  516. Xmain.o: /usr/local/X.V11R5/include/X11/Xutil.h
  517. Xmain.o: /usr/local/X.V11R5/include/X11/Xresource.h
  518. Xmain.o: /usr/local/X.V11R5/include/X11/Core.h
  519. Xmain.o: /usr/local/X.V11R5/include/X11/Composite.h
  520. Xmain.o: /usr/local/X.V11R5/include/X11/Constraint.h
  521. Xmain.o: /usr/local/X.V11R5/include/X11/Object.h
  522. Xmain.o: /usr/local/X.V11R5/include/X11/RectObj.h
  523. Xmain.o: /usr/local/X.V11R5/include/X11/Shell.h
  524. Xmain.o: /usr/local/X.V11R5/include/X11/Xatom.h
  525. Xmain.o: /usr/local/X.V11R5/include/Xm/XmStrDefs.h
  526. Xmain.o: /usr/local/X.V11R5/include/X11/StringDefs.h
  527. Xmain.o: /usr/local/X.V11R5/include/Xm/VirtKeys.h
  528. Xmain.o: /usr/local/X.V11R5/include/Xm/VendorS.h
  529. Xmain.o: /usr/local/X.V11R5/include/Xm/PushBG.h
  530. Xmain.o: /usr/local/X.V11R5/include/Xm/Text.h /usr/include/stdio.h
  531. Xmain.o: /usr/local/X.V11R5/include/Xm/List.h /usr/include/signal.h
  532. Xmain.o: /usr/include/sys/signal.h /usr/include/vm/faultcode.h
  533. Xmain.o: /usr/include/pwd.h /usr/include/sys/socket.h /usr/include/netdb.h
  534. Xmain.o: prefs.h control.h ui_funcs.h config.h patchlevel.h
  535. Xprefs.o: /usr/local/X.V11R5/include/X11/Xos.h
  536. Xprefs.o: /usr/local/X.V11R5/include/X11/Xosdefs.h /usr/include/sys/types.h
  537. Xprefs.o: /usr/include/sys/stdtypes.h /usr/include/sys/sysmacros.h
  538. Xprefs.o: /usr/include/string.h /usr/include/fcntl.h
  539. Xprefs.o: /usr/include/sys/fcntlcom.h /usr/include/sys/stat.h
  540. Xprefs.o: /usr/include/unistd.h /usr/include/sys/time.h
  541. Xprefs.o: /usr/include/sys/time.h /usr/include/stdlib.h /usr/include/stdio.h
  542. Xprefs.o: prefs.h
  543. Xui_funcs.o: /usr/local/X.V11R5/include/X11/cursorfont.h
  544. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/Xm.h
  545. Xui_funcs.o: /usr/local/X.V11R5/include/X11/Intrinsic.h
  546. Xui_funcs.o: /usr/local/X.V11R5/include/X11/Xlib.h /usr/include/sys/types.h
  547. Xui_funcs.o: /usr/include/sys/stdtypes.h /usr/include/sys/sysmacros.h
  548. Xui_funcs.o: /usr/local/X.V11R5/include/X11/X.h
  549. Xui_funcs.o: /usr/local/X.V11R5/include/X11/Xfuncproto.h
  550. Xui_funcs.o: /usr/local/X.V11R5/include/X11/Xosdefs.h /usr/include/stddef.h
  551. Xui_funcs.o: /usr/local/X.V11R5/include/X11/Xutil.h
  552. Xui_funcs.o: /usr/local/X.V11R5/include/X11/Xresource.h /usr/include/string.h
  553. Xui_funcs.o: /usr/local/X.V11R5/include/X11/Core.h
  554. Xui_funcs.o: /usr/local/X.V11R5/include/X11/Composite.h
  555. Xui_funcs.o: /usr/local/X.V11R5/include/X11/Constraint.h
  556. Xui_funcs.o: /usr/local/X.V11R5/include/X11/Object.h
  557. Xui_funcs.o: /usr/local/X.V11R5/include/X11/RectObj.h
  558. Xui_funcs.o: /usr/local/X.V11R5/include/X11/Shell.h
  559. Xui_funcs.o: /usr/local/X.V11R5/include/X11/Xatom.h
  560. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/XmStrDefs.h
  561. Xui_funcs.o: /usr/local/X.V11R5/include/X11/StringDefs.h
  562. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/VirtKeys.h
  563. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/VendorS.h
  564. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/MainW.h
  565. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/List.h
  566. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/RowColumn.h
  567. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/PushBG.h
  568. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/Form.h
  569. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/BulletinB.h
  570. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/CascadeB.h
  571. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/Frame.h
  572. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/LabelG.h
  573. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/Text.h /usr/include/stdio.h
  574. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/MessageB.h
  575. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/ToggleBG.h
  576. Xui_funcs.o: /usr/local/X.V11R5/include/Xm/SelectioB.h prefs.h control.h
  577. Xui_funcs.o: ui_funcs.h
  578. END_OF_FILE
  579. if test 17441 -ne `wc -c <'Makefile'`; then
  580.     echo shar: \"'Makefile'\" unpacked with wrong size!
  581. fi
  582. # end of 'Makefile'
  583. fi
  584. if test -f 'Manifest' -a "${1}" != "-c" ; then 
  585.   echo shar: Will not clobber existing file \"'Manifest'\"
  586. else
  587. echo shar: Extracting \"'Manifest'\" \(572 characters\)
  588. sed "s/^X//" >'Manifest' <<'END_OF_FILE'
  589. XImakefile    Used to produce makefile
  590. XMakefile    If you cant use the makefile, try to edit & use this
  591. XREADME        Instructions on compiling, installing
  592. XTODO        For future versions
  593. Xcache.c        Source file
  594. Xcontrol.c    Source file
  595. Xfile_cache.c    Source file
  596. Xftp.c        Source file
  597. Xmain.c        Source file
  598. Xprefs.c        Source file
  599. Xui_funcs.c    Source file
  600. Xcache.h        Source file
  601. Xconfig.h    Source file
  602. Xcontrol.h    Source file
  603. Xfile_cache.h    Source file
  604. Xftp.h        Source file
  605. Xpatchlevel.h    Source file
  606. Xprefs.h        Source file
  607. Xui_funcs.h    Source file
  608. Xxgetftp.man    Man page (uses the man macros)
  609. Xxgetftp.doc    Plain text man page
  610. END_OF_FILE
  611. if test 572 -ne `wc -c <'Manifest'`; then
  612.     echo shar: \"'Manifest'\" unpacked with wrong size!
  613. fi
  614. # end of 'Manifest'
  615. fi
  616. if test -f 'README' -a "${1}" != "-c" ; then 
  617.   echo shar: Will not clobber existing file \"'README'\"
  618. else
  619. echo shar: Extracting \"'README'\" \(1734 characters\)
  620. sed "s/^X//" >'README' <<'END_OF_FILE'
  621. X==========================================================================
  622. Xxgetftp v1.0
  623. X==========================================================================
  624. X
  625. XI. Authors:
  626. X
  627. X   Salim Alam
  628. X   University of Colorado, Boulder
  629. X   salim@cs.colorado.edu
  630. X
  631. X==========================================================================
  632. X
  633. XII. Distribution Policy:
  634. X
  635. X   This program is copyright Salim Alam, 1993.  It is freely distributable
  636. X   under the GNU Software License.
  637. X
  638. X==========================================================================
  639. X
  640. XIII. Building and Installing xgetftp:
  641. X
  642. X   a. Edit the file "config.h" to your satisfaction.
  643. X   b. Type "xmkmf -a" to build the makefile.  If this doesnt work for some
  644. X      reason, you can try and use the Makefile included.
  645. X   c. Type "make" to build the program.
  646. X   d. Type "make install" to install it.
  647. X   e. Type "make install.man" to install the man page.
  648. X   f. Type "make clean" to clean up.
  649. X
  650. X==========================================================================
  651. X
  652. XIV. Running xgetftp:
  653. X
  654. XBecause of the persistent cache, xgetftp is in some ways unusual.
  655. XPlease make sure that you carefully read the man page (an ASCII
  656. Xversion is available as xgetftp.doc if you don't want to install
  657. Xa man page), especially the parts pertaining to the cache.
  658. X
  659. X==========================================================================
  660. X
  661. XV. Acknowledgments:
  662. X
  663. XThe following people helped beta-test this program.  Also, the Imakefile
  664. Xand formatting of the man page were done by Rob.  Thanks guys!
  665. X
  666. XRobert G Henderson    <robh@eclipse.cs.colorado.edu>
  667. XChristopher Joslyn    <joslyn@spot.Colorado.EDU>
  668. XRich Neves        <neves@cs.colorado.edu>
  669. X
  670. X==========================================================================
  671. END_OF_FILE
  672. if test 1734 -ne `wc -c <'README'`; then
  673.     echo shar: \"'README'\" unpacked with wrong size!
  674. fi
  675. # end of 'README'
  676. fi
  677. if test -f 'TODO' -a "${1}" != "-c" ; then 
  678.   echo shar: Will not clobber existing file \"'TODO'\"
  679. else
  680. echo shar: Extracting \"'TODO'\" \(828 characters\)
  681. sed "s/^X//" >'TODO' <<'END_OF_FILE'
  682. X
  683. X
  684. X- Auto selection of "find text" widget in Archie Search
  685. X- Option to "uncache" viewed file -- on view file dialog
  686. X- Add simple "confirm" requester for caches... maybe better to confirm
  687. X  also the cache directory.
  688. X- Allow hostname to also handle IP numbers
  689. X- Better ftp response code handling
  690. X- Add confirm to close connection ; probably need to have a blocking widget
  691. X- Widget/menu item to skip response codes --- in case some server doesnt
  692. X  give us enough responses
  693. X- Cache-consistency checks
  694. X- Limiting size of dir. cache in memory
  695. X- "Hidden files" preference
  696. X- Some kind of background/batch transfer capability
  697. X- Keep track of where user last exited at each site and take him/her back
  698. X  to the same directory upon reconnection
  699. X- Add response view window
  700. X- Better recovery when error occurs while deleting dir cache.
  701. X
  702. Xv1.0
  703. X
  704. END_OF_FILE
  705. if test 828 -ne `wc -c <'TODO'`; then
  706.     echo shar: \"'TODO'\" unpacked with wrong size!
  707. fi
  708. # end of 'TODO'
  709. fi
  710. if test -f 'cache.c' -a "${1}" != "-c" ; then 
  711.   echo shar: Will not clobber existing file \"'cache.c'\"
  712. else
  713. echo shar: Extracting \"'cache.c'\" \(11774 characters\)
  714. sed "s/^X//" >'cache.c' <<'END_OF_FILE'
  715. X/***************************************************************************
  716. X * MODULE:
  717. X *  cache.c
  718. X *
  719. X * DESCRIPTION:
  720. X *  Provides functions to maintain a directory cache.
  721. X *
  722. X * AUTHOR:
  723. X *  Salim Alam
  724. X *  University of Colorado, Boulder
  725. X *
  726. X * MODIFICATION LOG:
  727. X *  93.01.27 S.A. Now closing cache saved/loaded files correctly
  728. X *  92.12.15 S.A. Fixed bug, made cache_load_levels more robust
  729. X *  92.12.09 S.A. Added dir caching functions.
  730. X *  92.12.01 S.A. Added fCached flag.
  731. X *  92.10.27 S.A. Fixed bugs in cache_init_level & cache_set_root, added
  732. X *          file types.
  733. X *
  734. X **************************************************************************/
  735. X
  736. X#include <stdio.h>
  737. X#include "cache.h"
  738. X
  739. X#ifndef TRUE
  740. X#define TRUE 1
  741. X#define FALSE 0
  742. X#endif
  743. X
  744. X/************************* public module variables ************************/
  745. X
  746. Xcacheinfo_ptr toplevel  = NULL;
  747. Xcacheinfo_ptr currlevel = NULL;
  748. X
  749. X
  750. X
  751. X/************************* private module variables ***********************/
  752. X
  753. X/*
  754. X * curr_path holds pointers to names of directories leading to the
  755. X * current path.  For example, curr_path[0] would be the names of
  756. X * the root directory, etc.  The concatenation of all the names
  757. X * (with the appropriate "/"s appended) yield the current directory.
  758. X *
  759. X * curr_path_index is the index to the most recent directory name.
  760. X *
  761. X * Note that memory only needs to be allocated for the root.  All other
  762. X * entries will be pointers into the fileinfo structure.
  763. X */
  764. X#define MAX_PATH_LEN    20
  765. Xstatic int curr_path_index = -1;
  766. Xstatic char *curr_path[MAX_PATH_LEN];
  767. X
  768. X#define MAX_LINESIZE    256    /* Max. size of a line in a dir listing */
  769. X#define MAX_LINKS    256    /* Max. # of traversed entries / level */
  770. X
  771. X/************************* path handling functions ************************/
  772. X
  773. Xvoid cache_set_root(char *root)
  774. X/*
  775. X * saves the root name.
  776. X */
  777. X{
  778. X    int len = strlen(root);
  779. X    
  780. X    /*
  781. X     * save complete pathname of the root, without the "/" postfix
  782. X     */
  783. X    curr_path_index = 0;
  784. X    if (root[len-1] == '/') len--;    
  785. X    curr_path[0] = (char *) malloc(len + 1);
  786. X    strncpy(curr_path[0], root, len);
  787. X    curr_path[0][len] = '\0';
  788. X#ifdef DEBUG
  789. X    printf("cache_set_root: Saving root as: '%s'\n", curr_path[0]);
  790. X#endif
  791. X}
  792. X
  793. X
  794. X
  795. Xvoid cache_next_dir(char *dir)
  796. X/*
  797. X * saves the pointer to the dir name.
  798. X */
  799. X{
  800. X    if (++curr_path_index >= MAX_PATH_LEN)
  801. X    {
  802. X    fprintf(stderr, "WARNING: cache_next_dir: out of stack space.\n");
  803. X    return;
  804. X    }
  805. X
  806. X    curr_path[curr_path_index] = dir;
  807. X}
  808. X
  809. X
  810. X
  811. Xvoid cache_prev_dir(void)
  812. X/*
  813. X * tells us to cd up.
  814. X */
  815. X{
  816. X    if (curr_path_index <= 0)
  817. X    {
  818. X    fprintf(stderr, "WARNING: cache_prev_dir: stack underflow.\n");
  819. X    return;
  820. X    }
  821. X
  822. X    curr_path_index--;
  823. X}
  824. X
  825. X
  826. X
  827. Xchar *cache_make_filename(char *filename)
  828. X/*
  829. X * Creates a string with the complete path for the given file.
  830. X * The address of the string is returned.  This string should be
  831. X * freed later.
  832. X */
  833. X{
  834. X    char *s;
  835. X    int i, path_len = 0, total_len;
  836. X
  837. X    for (i=0; i <= curr_path_index; i++)
  838. X    path_len += strlen(curr_path[i]) + 1;
  839. X
  840. X    total_len = path_len + strlen(filename);
  841. X
  842. X    s = (char *) malloc( total_len + 1);
  843. X    sprintf(s, "%s/", curr_path[0]);
  844. X
  845. X    for (i = 1; i <= curr_path_index; i++)
  846. X    {
  847. X    strcat(s, curr_path[i]);
  848. X    strcat(s, "/");
  849. X    }
  850. X
  851. X    strcat(s, filename);
  852. X
  853. X    return s;
  854. X}
  855. X
  856. X
  857. X
  858. X/************************* cache maintainance functions *******************/
  859. X
  860. Xint cache_init_level(cacheinfo_ptr *level, cacheinfo_ptr prev, char *filename)
  861. X/*
  862. X * Given a ftp directory listing in file "filename" (which should not be
  863. X * open), this function saves the names of the  files and directories in the
  864. X * listing into the parameter *level which should be initially NULL.  The
  865. X * parameter "prev" is a pointer to the cache item for the parent directory
  866. X * -- if the root directory is being cached then "prev" should be NULL.
  867. X *
  868. X * The format of the file "filename" should be _exactly_ as produced by
  869. X * an FTP data connection when given a "LIST" command.  This includes
  870. X * the first line that gives the total.
  871. X *
  872. X * Memory will be allocated for the cacheinfo entry *level, as well
  873. X * as for the fileinfo entries within.
  874. X *
  875. X * Returns TRUE if success and FALSE if file is unreadable.
  876. X *
  877. X */
  878. X{
  879. X    FILE *fp;
  880. X    char line[100];
  881. X    int c, i;
  882. X    int entries = -1;
  883. X    int len;
  884. X    fileinfo *fi;
  885. X    char *s;
  886. X
  887. X    /*
  888. X     * open file and ready it for reading lines of info.
  889. X     */
  890. X    if ((fp=fopen(filename,"r")) == NULL)
  891. X    {
  892. X    fprintf(stderr,"cache_init_level: can't open file '%s'\n", filename);
  893. X    return FALSE;
  894. X    }
  895. X
  896. X    while ( (c=fgetc(fp)) != EOF )
  897. X    if (c=='\n') entries++;        /* count # of lines */
  898. X
  899. X    fseek(fp, 0, 0);
  900. X#ifdef DEBUG
  901. X    printf("cache_init_level: %d entries.\n", entries);
  902. X#endif
  903. X    fgets(line, 98, fp);        /* skip the first line */
  904. X    
  905. X    /*
  906. X     * initialize level
  907. X     */
  908. X    if (*level != NULL)
  909. X    fprintf(stderr, "WARNING: cache_init_level: level re-init.\n");
  910. X
  911. X    *level = (cacheinfo *) malloc(sizeof(cacheinfo));
  912. X    (*level)->prev_level = prev;
  913. X    (*level)->num_entries = entries;
  914. X    (*level)->entry_arr = (fileinfo *) malloc(entries * sizeof(fileinfo));
  915. X
  916. X
  917. X    /*
  918. X     * read in entries
  919. X     */
  920. X    for (i=0; i < entries; i++)
  921. X    {
  922. X    fgets(line, 98, fp);
  923. X    len = strlen(line);
  924. X
  925. X    /* check for newline */
  926. X    if (line[len-1] == '\n')
  927. X        line[(len--) - 1] = '\0';
  928. X    else
  929. X        fprintf(stderr, "WARNING: cache_init_level: incomplete entry.\n");
  930. X
  931. X    /* If we got this in ASCII mode, there will be a linefeed as well */
  932. X    if (line[len-1]=='\r')
  933. X        line[(len--) - 1] = '\0';
  934. X
  935. X    fi = & ( (*level)->entry_arr[i] );
  936. X    fi->line = (char *) malloc(len+1);
  937. X    strcpy(fi->line, line);
  938. X    fi->next_level = NULL;
  939. X
  940. X    fi->type = (line[0]=='-')? fitypFILE :
  941. X           (line[0]=='d')? fitypDIRECTORY :
  942. X           fitypLINK;
  943. X
  944. X    fi->fCached = 0;
  945. X
  946. X    /* point to name */
  947. X    s = fi->line + len - 1;
  948. X    while (*s && (*s != ' ')) s--;
  949. X    fi->name = s+1;
  950. X    }
  951. X
  952. X    fclose(fp);
  953. X    return TRUE;
  954. X}
  955. X
  956. X
  957. Xvoid cache_free_levels(cacheinfo_ptr *plevel)
  958. X/*
  959. X * Recursively deallocates the given level and all levels below it.
  960. X */
  961. X{
  962. X    int i;
  963. X    fileinfo *fi;
  964. X
  965. X    for (i=0; i < (*plevel)->num_entries; i++)
  966. X    {
  967. X    fi = & ( (*plevel)->entry_arr[i] );
  968. X    free ( fi->line );
  969. X    if (fi->next_level)
  970. X    {
  971. X        cache_free_levels(&(fi->next_level));
  972. X    }
  973. X    }
  974. X
  975. X    free( (*plevel)->entry_arr );
  976. X    free( *plevel );
  977. X    *plevel = NULL;
  978. X}
  979. X
  980. X
  981. X/*************************** saving/loading caches **********************/
  982. X
  983. Xint cache_save_cache(char *filepath)
  984. X/*
  985. X * Given the complete pathname of the directory cache file, this
  986. X * function saves the directory cache to that file.
  987. X *
  988. X * Returns TRUE for success, FALSE otherwise.
  989. X */
  990. X{
  991. X    FILE *fp;
  992. X    int stat;
  993. X
  994. X    if ( (fp = fopen(filepath, "w")) == NULL )
  995. X    {
  996. X    fprintf(stderr,"cache_save_cache: can't open '%s'.\n", filepath);
  997. X    return FALSE;
  998. X    }
  999. X
  1000. X    /*
  1001. X     * Save the 'root' of remote hierarchy, with "/" appended
  1002. X     */
  1003. X    fprintf(fp, "%s/\n", curr_path[0]);
  1004. X
  1005. X    /*
  1006. X     * Save the rest of the directory tree
  1007. X     */
  1008. X    stat = cache_save_levels(toplevel, fp);
  1009. X
  1010. X    /*
  1011. X     * Close file and exit
  1012. X     */
  1013. X    fflush(fp);
  1014. X    fclose(fp);
  1015. X
  1016. X    return stat;
  1017. X}
  1018. X
  1019. X
  1020. X
  1021. Xint cache_save_levels(cacheinfo_ptr level, FILE *fp)
  1022. X/*
  1023. X * Given a level "level", and file pointer to an open, writable
  1024. X * file, this function writes out the current level and all
  1025. X * child levels to the file.  The cache is output in using inorder
  1026. X * traversal.
  1027. X *
  1028. X * Returns TRUE if successful, FALSE otherwise.
  1029. X */
  1030. X{
  1031. X    fileinfo *fi;
  1032. X    int i, nlinks = 0;
  1033. X
  1034. X    /*
  1035. X     * Print out number of items 
  1036. X     */
  1037. X    fprintf(fp, "%d\n", level->num_entries);
  1038. X
  1039. X    /*
  1040. X     * Print out all entries for this level
  1041. X     */
  1042. X    for (i=0; i < level->num_entries; i++)
  1043. X    {
  1044. X    fi = & (level->entry_arr[i]);
  1045. X    fprintf(fp, "%s\n", fi->line);
  1046. X    if (fi->next_level) nlinks++;
  1047. X    }
  1048. X
  1049. X    /*
  1050. X     * Print out the links 
  1051. X     */
  1052. X    fprintf(fp, "%d\n", nlinks);
  1053. X    for (i=0; i < level->num_entries; i++)
  1054. X    {
  1055. X    if (level->entry_arr[i].next_level)
  1056. X        fprintf(fp, "%d\n", i);
  1057. X    }
  1058. X
  1059. X   /*
  1060. X    * Traverse and save other levels
  1061. X    */
  1062. X    for (i=0; i < level->num_entries; i++)
  1063. X    {
  1064. X    if (level->entry_arr[i].next_level)
  1065. X        cache_save_levels(level->entry_arr[i].next_level, fp);
  1066. X    }
  1067. X
  1068. X    return TRUE;
  1069. X}
  1070. X
  1071. X
  1072. X
  1073. Xint cache_load_levels(cacheinfo_ptr *plevel, cacheinfo_ptr prev, FILE *fp)
  1074. X/*
  1075. X * Given a double-pointer to a level "plevel", and a file pointer to an
  1076. X * open readable file, this function loads in the data for "plevel" and
  1077. X * all its children levels.  "prev" specifies a pointer to the parent
  1078. X * level, or NULL "plevel" is the root.  Memory is dynamically allocated
  1079. X * for "plevel" and all its children.
  1080. X *
  1081. X * Returns TRUE on success, FALSE otherwise.
  1082. X */
  1083. X{
  1084. X    int n_entries;
  1085. X    int n_links;
  1086. X    int i, len;
  1087. X    int links[MAX_LINKS];
  1088. X    char line[MAX_LINESIZE];
  1089. X    int remove_newline(char *);
  1090. X    fileinfo *fi;
  1091. X
  1092. X    /*
  1093. X     * Read #entries & alloc memory for this level
  1094. X     */
  1095. X    if (fscanf(fp, "%d\n", &n_entries)==EOF)
  1096. X    {
  1097. X    fprintf(stderr, "cache_load_levels: no entries!\n");
  1098. X    return FALSE;
  1099. X    }
  1100. X
  1101. X    *plevel = (cacheinfo *) malloc(sizeof(cacheinfo));
  1102. X    (*plevel)->prev_level = prev;
  1103. X    (*plevel)->num_entries = n_entries;
  1104. X    (*plevel)->entry_arr = (fileinfo *) malloc(n_entries * sizeof(fileinfo));
  1105. X
  1106. X    /*
  1107. X     * Read in entries
  1108. X     */
  1109. X    for (i=0; i < n_entries; i++)
  1110. X    {
  1111. X    char *s;
  1112. X
  1113. X    fgets(line, MAX_LINESIZE-1, fp);
  1114. X    len = remove_newline(line);
  1115. X    fi = & ( (*plevel)->entry_arr[i] );
  1116. X    fi->line = (char *) malloc(len+1);
  1117. X    strcpy(fi->line, line);
  1118. X    fi->next_level = NULL;
  1119. X    fi->type = (line[0]=='-')? fitypFILE :
  1120. X           (line[0]=='d')? fitypDIRECTORY :
  1121. X           fitypLINK;
  1122. X    s = fi->line + len - 1;
  1123. X    while (*s && (*s != ' ')) s--;
  1124. X    fi->name = s+1;
  1125. X    }
  1126. X
  1127. X
  1128. X    /*
  1129. X     * Read in links
  1130. X     */
  1131. X    fscanf(fp, "%d\n", &n_links);
  1132. X    if (n_links > MAX_LINKS)
  1133. X    {
  1134. X    fprintf(stderr, "cache_load_levels: #links > %d! Aborting!\n",
  1135. X        MAX_LINKS);
  1136. X    return FALSE;
  1137. X    }
  1138. X
  1139. X    for (i=0; i < n_links; i++)
  1140. X    fscanf(fp, "%d\n", &(links[i]));
  1141. X
  1142. X
  1143. X    /*
  1144. X     * Traverse the necessary levels
  1145. X     */
  1146. X    for (i=0; i < n_links; i++)
  1147. X    {
  1148. X    fi = & ( (*plevel)->entry_arr[links[i]] );
  1149. X    cache_load_levels(& (fi->next_level), *plevel, fp);
  1150. X    }
  1151. X
  1152. X    return TRUE;
  1153. X}
  1154. X
  1155. X
  1156. X
  1157. Xint cache_load_cache(char *filepath)
  1158. X/*
  1159. X * Given the complete path to the cache file, this function loads in
  1160. X * the cached directory hierarchy into "toplevel".
  1161. X *
  1162. X * WARNING: This function will attempt to free the root stored in
  1163. X *          curr_path as well as toplevel.  These should either be
  1164. X *          NULL or point to valid data.
  1165. X *
  1166. X * Returns TRUE on success, FALSE otherwise.
  1167. X */
  1168. X{
  1169. X    FILE *fp;
  1170. X    int len, stat;
  1171. X    char line[MAX_LINESIZE];
  1172. X    int remove_newline(char *);
  1173. X
  1174. X
  1175. X    /*
  1176. X     * Open file
  1177. X     */
  1178. X    if ( (fp=fopen(filepath,"r")) == NULL )
  1179. X    {
  1180. X    /* fprintf(stderr, "cache_load_cache: can't open '%s'.\n", filepath); */
  1181. X    return FALSE;
  1182. X    }
  1183. X
  1184. X    /*
  1185. X     * Free everything
  1186. X     */
  1187. X    if (curr_path[0])
  1188. X    free(curr_path[0]);
  1189. X
  1190. X    if (toplevel)
  1191. X    cache_free_levels(&toplevel);
  1192. X
  1193. X
  1194. X    /*
  1195. X     * Read in root
  1196. X     */
  1197. X    fgets(line, MAX_LINESIZE-1, fp);
  1198. X    remove_newline(line);
  1199. X    cache_set_root(line);
  1200. X     
  1201. X
  1202. X    /*
  1203. X     * Read in everything else
  1204. X     */
  1205. X    stat = cache_load_levels(&toplevel, NULL, fp);
  1206. X
  1207. X    /*
  1208. X     * Close file and exit
  1209. X     */
  1210. X    fclose(fp);
  1211. X    return stat;
  1212. X}
  1213. X
  1214. X
  1215. X/*************************** misc functions ******************************/
  1216. X
  1217. Xint remove_newline(char *s)
  1218. X/*
  1219. X * Given a string s, removes the newline at the end of s.
  1220. X * Returns length of modified string.
  1221. X */
  1222. X{
  1223. X    int len = strlen(s);
  1224. X
  1225. X    if (s[len-1] == '\n')
  1226. X    s[--len] = '\0';
  1227. X
  1228. X    return len;
  1229. X}
  1230. X
  1231. X
  1232. X/*************************** debugging functions *************************/
  1233. X
  1234. Xvoid cache_print_level(cacheinfo_ptr level)
  1235. X{
  1236. X    fileinfo *fi;
  1237. X    int ent;
  1238. X
  1239. X    for (ent=0; ent < level->num_entries; ent++)
  1240. X    {
  1241. X    printf("%s:", level->entry_arr[ent].name);
  1242. X    printf("'%s'\n", level->entry_arr[ent].line);
  1243. X    }
  1244. X}
  1245. END_OF_FILE
  1246. if test 11774 -ne `wc -c <'cache.c'`; then
  1247.     echo shar: \"'cache.c'\" unpacked with wrong size!
  1248. fi
  1249. # end of 'cache.c'
  1250. fi
  1251. if test -f 'cache.h' -a "${1}" != "-c" ; then 
  1252.   echo shar: Will not clobber existing file \"'cache.h'\"
  1253. else
  1254. echo shar: Extracting \"'cache.h'\" \(1135 characters\)
  1255. sed "s/^X//" >'cache.h' <<'END_OF_FILE'
  1256. X/*
  1257. X * HEADER: cache.h
  1258. X */
  1259. X
  1260. X/*
  1261. X * The following typedefs are exported to other modules, but are not
  1262. X * meant to be used explicitly.
  1263. X */
  1264. X
  1265. Xtypedef struct _cacheinfo *cacheinfo_ptr;
  1266. X
  1267. X#define fitypFILE    0
  1268. X#define fitypDIRECTORY    1
  1269. X#define fitypLINK    2
  1270. X
  1271. Xtypedef struct _fileinfo
  1272. X{
  1273. X    char *line;
  1274. X    char *name;
  1275. X    char type;
  1276. X    char fCached;
  1277. X    cacheinfo_ptr next_level;
  1278. X} fileinfo;
  1279. X
  1280. Xtypedef struct _cacheinfo
  1281. X{
  1282. X    int num_entries;
  1283. X    fileinfo *entry_arr;
  1284. X    cacheinfo_ptr prev_level;
  1285. X} cacheinfo;
  1286. X
  1287. X
  1288. X/*
  1289. X * The following variables are exported to other modules.  They should
  1290. X * be managed using the functions provided by this module.
  1291. X */
  1292. X
  1293. Xextern cacheinfo_ptr toplevel;
  1294. Xextern cacheinfo_ptr currlevel;
  1295. X
  1296. X
  1297. X/*
  1298. X * Public function prototypes.
  1299. X */
  1300. X
  1301. Xvoid
  1302. Xcache_set_root(char *root);
  1303. X
  1304. Xvoid
  1305. Xcache_next_dir(char *dir);
  1306. X
  1307. Xvoid
  1308. Xcache_prev_dir(void);
  1309. X
  1310. Xchar *
  1311. Xcache_make_filename(char *filename);
  1312. X
  1313. Xint
  1314. Xcache_init_level(cacheinfo_ptr *level, cacheinfo_ptr prev, char *filename);
  1315. X
  1316. Xvoid
  1317. Xcache_print_level(cacheinfo_ptr level);
  1318. X
  1319. Xvoid
  1320. Xcache_free_levels(cacheinfo_ptr *plevel);
  1321. X
  1322. Xint
  1323. Xcache_save_cache(char * filepath);
  1324. X
  1325. Xint
  1326. Xcache_load_cache(char * filepath);
  1327. END_OF_FILE
  1328. if test 1135 -ne `wc -c <'cache.h'`; then
  1329.     echo shar: \"'cache.h'\" unpacked with wrong size!
  1330. fi
  1331. # end of 'cache.h'
  1332. fi
  1333. if test -f 'config.h' -a "${1}" != "-c" ; then 
  1334.   echo shar: Will not clobber existing file \"'config.h'\"
  1335. else
  1336. echo shar: Extracting \"'config.h'\" \(523 characters\)
  1337. sed "s/^X//" >'config.h' <<'END_OF_FILE'
  1338. X/*************************************************************************
  1339. X *
  1340. X * User configuration file
  1341. X *
  1342. X * Modify before compiling and installing program
  1343. X *
  1344. X ************************************************************************/
  1345. X
  1346. X/*
  1347. X * ARCHIEBIN should have complete path for archie client program.
  1348. X */
  1349. X#define ARCHIEBIN       "/usr/local/bin/archie"
  1350. X
  1351. X/*
  1352. X * ARCHIESERVER defines the server to use.  The archie client
  1353. X * defined above should allow a "-server" option.
  1354. X *
  1355. X */
  1356. X#define ARCHIESERVER    "archie.sura.net"
  1357. END_OF_FILE
  1358. if test 523 -ne `wc -c <'config.h'`; then
  1359.     echo shar: \"'config.h'\" unpacked with wrong size!
  1360. fi
  1361. # end of 'config.h'
  1362. fi
  1363. echo shar: End of archive 1 \(of 4\).
  1364. cp /dev/null ark1isdone
  1365. MISSING=""
  1366. for I in 1 2 3 4 ; do
  1367.     if test ! -f ark${I}isdone ; then
  1368.     MISSING="${MISSING} ${I}"
  1369.     fi
  1370. done
  1371. if test "${MISSING}" = "" ; then
  1372.     echo You have unpacked all 4 archives.
  1373.     rm -f ark[1-9]isdone
  1374. else
  1375.     echo You still need to unpack the following archives:
  1376.     echo "        " ${MISSING}
  1377. fi
  1378. ##  End of shell archive.
  1379. exit 0
  1380.  
  1381. exit 0 # Just in case...
  1382. -- 
  1383.   // chris@IMD.Sterling.COM            | Send comp.sources.x submissions to:
  1384. \X/  Amiga - The only way to fly!      |
  1385.  "It's intuitively obvious to the most |    sources-x@imd.sterling.com
  1386.   casual observer..."                  |
  1387.