home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume20 / xarchie / part06 < prev    next >
Encoding:
Text File  |  1993-06-14  |  50.4 KB  |  1,767 lines

  1. Newsgroups: comp.sources.x
  2. From: ferguson@cs.rochester.edu (George Ferguson)
  3. Subject: v20i034:  xarchie - An X browser interface to Archie, v2.0.6, Part06/24
  4. Message-ID: <1993Jun15.223225.29976@sparky.imd.sterling.com>
  5. X-Md4-Signature: f4abd6ca99b8442e9eb32b2ecd046ee2
  6. Sender: chris@sparky.imd.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Tue, 15 Jun 1993 22:32:25 GMT
  9. Approved: chris@sparky.imd.sterling.com
  10.  
  11. Submitted-by: ferguson@cs.rochester.edu (George Ferguson)
  12. Posting-number: Volume 20, Issue 34
  13. Archive-name: xarchie/part06
  14. Environment: X11
  15. Supersedes: xarchie: Volume 14, Issue 82-90
  16.  
  17. Submitted-by: ferguson@cs.rochester.edu
  18. Archive-name: xarchie-2.0.6/part06
  19.  
  20. #!/bin/sh
  21. # this is Part.06 (part 6 of xarchie-2.0.6)
  22. # do not concatenate these parts, unpack them in order with /bin/sh
  23. # file xarchie-2.0.6/config.h.in continued
  24. #
  25. if test ! -r _shar_seq_.tmp; then
  26.     echo 'Please unpack part 1 first!'
  27.     exit 1
  28. fi
  29. (read Scheck
  30.  if test "$Scheck" != 6; then
  31.     echo Please unpack part "$Scheck" next!
  32.     exit 1
  33.  else
  34.     exit 0
  35.  fi
  36. ) < _shar_seq_.tmp || exit 1
  37. if test ! -f _shar_wnt_.tmp; then
  38.     echo 'x - still skipping xarchie-2.0.6/config.h.in'
  39. else
  40. echo 'x - continuing file xarchie-2.0.6/config.h.in'
  41. sed 's/^X//' << 'SHAR_EOF' >> 'xarchie-2.0.6/config.h.in' &&
  42. /* Define if your sys/select.h declares FD_SET.  */
  43. #undef FD_SET_IN_SYS_SELECT_H
  44. /* Define if your sys/inet.h declares FD_SET.  */
  45. #undef FD_SET_IN_SYS_INET_H
  46. X
  47. /* Define if you have re_comp() and re_exec() */
  48. #undef HAVE_RE_COMP
  49. /* Some systems use regcmp() and regex() instead (like AIX) */
  50. #undef HAVE_REGCMP
  51. X
  52. /* Define if you have strcasecmp() */
  53. #undef HAVE_STRCASECMP
  54. X
  55. /* Define if you have random() */
  56. #undef HAVE_RANDOM
  57. /* Some systems use rand() instead (like HPUX) */
  58. #undef HAVE_RAND
  59. X
  60. /* Define if you have the ANSI function strerror() */
  61. #undef HAVE_STRERROR
  62. X
  63. /* Define if you have errno (who doesn't)? */
  64. #undef HAVE_ERRNO
  65. X
  66. /* Define if you have sys_errlist (not needed if you have strerror) */
  67. #undef HAVE_SYS_ERRLIST
  68. X
  69. /* Define if you have getlogin() (who doesn't?) */
  70. #undef HAVE_GETLOGIN
  71. X
  72. /* Define if you have getpwuid() defined in <pwd.h> */
  73. #undef HAVE_GETPWUID
  74. X
  75. /* Define if you have strspn() */
  76. #undef HAVE_STRSPN
  77. X
  78. /* Define this if you need -lresolv in your link line (used by imake) */
  79. #undef NEED_LRESOLV
  80. X
  81. #endif /*!_CONFIG_H*/
  82. SHAR_EOF
  83. echo 'File xarchie-2.0.6/config.h.in is complete' &&
  84. chmod 0644 xarchie-2.0.6/config.h.in ||
  85. echo 'restore of xarchie-2.0.6/config.h.in failed'
  86. Wc_c="`wc -c < 'xarchie-2.0.6/config.h.in'`"
  87. test 1659 -eq "$Wc_c" ||
  88.     echo 'xarchie-2.0.6/config.h.in: original size 1659, current size' "$Wc_c"
  89. rm -f _shar_wnt_.tmp
  90. fi
  91. # ============= xarchie-2.0.6/configure ==============
  92. if test -f 'xarchie-2.0.6/configure' -a X"$1" != X"-c"; then
  93.     echo 'x - skipping xarchie-2.0.6/configure (File already exists)'
  94.     rm -f _shar_wnt_.tmp
  95. else
  96. > _shar_wnt_.tmp
  97. echo 'x - extracting xarchie-2.0.6/configure (Text)'
  98. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/configure' &&
  99. #!/bin/sh
  100. # Guess values for system-dependent variables and create Makefiles.
  101. # Generated automatically using autoconf.
  102. # Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
  103. X
  104. # This program is free software; you can redistribute it and/or modify
  105. # it under the terms of the GNU General Public License as published by
  106. # the Free Software Foundation; either version 2, or (at your option)
  107. # any later version.
  108. X
  109. # This program is distributed in the hope that it will be useful,
  110. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  111. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  112. # GNU General Public License for more details.
  113. X
  114. # You should have received a copy of the GNU General Public License
  115. # along with this program; if not, write to the Free Software
  116. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  117. X
  118. # Usage: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp] [--no-create]
  119. #        [--prefix=PREFIX] [--exec-prefix=PREFIX] [--with-PACKAGE] [TARGET]
  120. # Ignores all args except --srcdir, --prefix, --exec-prefix, --no-create, and
  121. # --with-PACKAGE unless this script has special code to handle it.
  122. X
  123. X
  124. for arg
  125. do
  126. X  # Handle --exec-prefix with a space before the argument.
  127. X  if test x$next_exec_prefix = xyes; then exec_prefix=$arg; next_exec_prefix=
  128. X  # Handle --host with a space before the argument.
  129. X  elif test x$next_host = xyes; then next_host=
  130. X  # Handle --prefix with a space before the argument.
  131. X  elif test x$next_prefix = xyes; then prefix=$arg; next_prefix=
  132. X  # Handle --srcdir with a space before the argument.
  133. X  elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir=
  134. X  else
  135. X    case $arg in
  136. X     # For backward compatibility, also recognize exact --exec_prefix.
  137. X     -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*)
  138. X    exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
  139. X     -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- | --exec | --exe | --ex | --e)
  140. X    next_exec_prefix=yes ;;
  141. X
  142. X     -gas | --gas | --ga | --g) ;;
  143. X
  144. X     -host=* | --host=* | --hos=* | --ho=* | --h=*) ;;
  145. X     -host | --host | --hos | --ho | --h)
  146. X    next_host=yes ;;
  147. X
  148. X     -nfp | --nfp | --nf) ;;
  149. X
  150. X     -no-create | --no-create | --no-creat | --no-crea | --no-cre | --no-cr | --no-c | --no- | --no)
  151. X        no_create=1 ;;
  152. X
  153. X     -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
  154. X    prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
  155. X     -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
  156. X    next_prefix=yes ;;
  157. X
  158. X     -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*)
  159. X    srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;;
  160. X     -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s)
  161. X    next_srcdir=yes ;;
  162. X
  163. X     -with-* | --with-*)
  164. X       package=`echo $arg|sed 's/-*with-//'`
  165. X       # Delete all the valid chars; see if any are left.
  166. X       if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then
  167. X         echo "configure: $package: invalid package name" >&2; exit 1
  168. X       fi
  169. X       eval "with_`echo $package|sed s/-/_/g`=1" ;;
  170. X
  171. X     *) ;;
  172. X    esac
  173. X  fi
  174. done
  175. X
  176. trap 'rm -f conftest* core; exit 1' 1 3 15
  177. X
  178. rm -f conftest*
  179. compile='${CC-cc} $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1'
  180. X
  181. # A filename unique to this package, relative to the directory that
  182. # configure is in, which we can look for to find out if srcdir is correct.
  183. unique_file=xarchie.c
  184. X
  185. # Find the source files, if location was not specified.
  186. if test -z "$srcdir"; then
  187. X  srcdirdefaulted=yes
  188. X  # Try the directory containing this script, then `..'.
  189. X  prog=$0
  190. X  confdir=`echo $prog|sed 's%/[^/][^/]*$%%'`
  191. X  test "X$confdir" = "X$prog" && confdir=.
  192. X  srcdir=$confdir
  193. X  if test ! -r $srcdir/$unique_file; then
  194. X    srcdir=..
  195. X  fi
  196. fi
  197. if test ! -r $srcdir/$unique_file; then
  198. X  if test x$srcdirdefaulted = xyes; then
  199. X    echo "configure: Can not find sources in \`${confdir}' or \`..'." 1>&2
  200. X  else
  201. X    echo "configure: Can not find sources in \`${srcdir}'." 1>&2
  202. X  fi
  203. X  exit 1
  204. fi
  205. # Preserve a srcdir of `.' to avoid automounter screwups with pwd.
  206. # But we can't avoid them for `..', to make subdirectories work.
  207. case $srcdir in
  208. X  .|/*|~*) ;;
  209. X  *) srcdir=`cd $srcdir; pwd` ;; # Make relative path absolute.
  210. esac
  211. X
  212. X
  213. if test -z "$CC"; then
  214. X  echo checking for gcc
  215. X  saveifs="$IFS"; IFS="${IFS}:"
  216. X  for dir in $PATH; do
  217. X    test -z "$dir" && dir=.
  218. X    if test -f $dir/gcc; then
  219. X      CC="gcc"
  220. X      break
  221. X    fi
  222. X  done
  223. X  IFS="$saveifs"
  224. fi
  225. test -z "$CC" && CC="cc"
  226. X
  227. # Find out if we are using GNU C, under whatever name.
  228. cat > conftest.c <<EOF
  229. #ifdef __GNUC__
  230. X  yes
  231. #endif
  232. EOF
  233. ${CC-cc} -E conftest.c > conftest.out 2>&1
  234. if egrep yes conftest.out >/dev/null 2>&1; then
  235. X  GCC=1 # For later tests.
  236. fi
  237. rm -f conftest*
  238. X
  239. echo checking how to run the C preprocessor
  240. if test -z "$CPP"; then
  241. X  CPP='${CC-cc} -E'
  242. X  cat > conftest.c <<EOF
  243. #include <stdio.h>
  244. EOF
  245. err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
  246. if test -z "$err"; then
  247. X  :
  248. else
  249. X  CPP=/lib/cpp
  250. fi
  251. rm -f conftest*
  252. fi
  253. X
  254. if test -n "$GCC"; then
  255. X  echo checking whether -traditional is needed
  256. X  pattern="Autoconf.*'x'"
  257. X  prog='#include <sgtty.h>
  258. Autoconf TIOCGETP'
  259. X  cat > conftest.c <<EOF
  260. $prog
  261. EOF
  262. eval "$CPP $DEFS conftest.c > conftest.out 2>&1"
  263. if egrep "$pattern" conftest.out >/dev/null 2>&1; then
  264. X  need_trad=1
  265. fi
  266. rm -f conftest*
  267. X
  268. X
  269. X  if test -z "$need_trad"; then
  270. X    prog='#include <termio.h>
  271. Autoconf TCGETA'
  272. X    cat > conftest.c <<EOF
  273. $prog
  274. EOF
  275. eval "$CPP $DEFS conftest.c > conftest.out 2>&1"
  276. if egrep "$pattern" conftest.out >/dev/null 2>&1; then
  277. X  need_trad=1
  278. fi
  279. rm -f conftest*
  280. X
  281. X  fi
  282. X  test -n "$need_trad" && CC="$CC -traditional"
  283. fi
  284. X
  285. echo checking for POSIXized ISC
  286. if test -d /etc/conf/kconfig.d &&
  287. X  grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
  288. then
  289. X  ISC=1 # If later tests want to check for ISC.
  290. X  DEFS="$DEFS -D_POSIX_SOURCE=1"
  291. SEDDEFS="${SEDDEFS}\${SEDdA}_POSIX_SOURCE\${SEDdB}_POSIX_SOURCE\${SEDdC}1\${SEDdD}
  292. \${SEDuA}_POSIX_SOURCE\${SEDuB}_POSIX_SOURCE\${SEDuC}1\${SEDuD}
  293. \${SEDeA}_POSIX_SOURCE\${SEDeB}_POSIX_SOURCE\${SEDeC}1\${SEDeD}
  294. "
  295. X  if test -n "$GCC"; then
  296. X    CC="$CC -posix"
  297. X  else
  298. X    CC="$CC -Xp"
  299. X  fi
  300. fi
  301. X
  302. echo checking for IRIX libsun
  303. if test -f /usr/lib/libsun.a; then
  304. X  LIBS="$LIBS -lsun"
  305. fi
  306. X
  307. echo checking for ANSI C header files
  308. cat > conftest.c <<EOF
  309. #include <stdlib.h>
  310. #include <stdarg.h>
  311. #include <string.h>
  312. #include <float.h>
  313. EOF
  314. err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
  315. if test -z "$err"; then
  316. X  # SunOS string.h does not declare mem*, contrary to ANSI.
  317. echo '#include <string.h>' > conftest.c
  318. eval "$CPP $DEFS conftest.c > conftest.out 2>&1"
  319. if egrep "memchr" conftest.out >/dev/null 2>&1; then
  320. X  # SGI's /bin/cc from Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
  321. cat > conftest.c <<EOF
  322. #include <ctype.h>
  323. #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
  324. #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
  325. #define XOR(e,f) (((e) && !(f)) || (!(e) && (f)))
  326. int main () { int i; for (i = 0; i < 256; i++)
  327. if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
  328. exit (0); }
  329. X
  330. EOF
  331. eval $compile
  332. if test -s conftest && (./conftest; exit) 2>/dev/null; then
  333. X  DEFS="$DEFS -DSTDC_HEADERS=1"
  334. SEDDEFS="${SEDDEFS}\${SEDdA}STDC_HEADERS\${SEDdB}STDC_HEADERS\${SEDdC}1\${SEDdD}
  335. \${SEDuA}STDC_HEADERS\${SEDuB}STDC_HEADERS\${SEDuC}1\${SEDuD}
  336. \${SEDeA}STDC_HEADERS\${SEDeB}STDC_HEADERS\${SEDeC}1\${SEDeD}
  337. "
  338. fi
  339. rm -f conftest*
  340. fi
  341. rm -f conftest*
  342. X
  343. fi
  344. rm -f conftest*
  345. X
  346. for hdr in string.h memory.h sys/param.h
  347. do
  348. trhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'`
  349. echo checking for ${hdr}
  350. cat > conftest.c <<EOF
  351. #include <${hdr}>
  352. EOF
  353. err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
  354. if test -z "$err"; then
  355. X  DEFS="$DEFS -D${trhdr}=1"
  356. SEDDEFS="${SEDDEFS}\${SEDdA}${trhdr}\${SEDdB}${trhdr}\${SEDdC}1\${SEDdD}
  357. \${SEDuA}${trhdr}\${SEDuB}${trhdr}\${SEDuC}1\${SEDuD}
  358. \${SEDeA}${trhdr}\${SEDeB}${trhdr}\${SEDeC}1\${SEDeD}
  359. "
  360. fi
  361. rm -f conftest*
  362. done
  363. X
  364. echo checking for fd_set in sys/types.h
  365. cat > conftest.c <<EOF
  366. #include <stdio.h>
  367. #include <sys/types.h>
  368. main() { exit(0); } 
  369. t() { fd_set foo; }
  370. EOF
  371. if eval $compile; then
  372. X  DEFS="$DEFS -DFD_SET_IN_SYS_TYPES_H=1"
  373. SEDDEFS="${SEDDEFS}\${SEDdA}FD_SET_IN_SYS_TYPES_H\${SEDdB}FD_SET_IN_SYS_TYPES_H\${SEDdC}1\${SEDdD}
  374. \${SEDuA}FD_SET_IN_SYS_TYPES_H\${SEDuB}FD_SET_IN_SYS_TYPES_H\${SEDuC}1\${SEDuD}
  375. \${SEDeA}FD_SET_IN_SYS_TYPES_H\${SEDeB}FD_SET_IN_SYS_TYPES_H\${SEDeC}1\${SEDeD}
  376. "
  377. else
  378. X  echo checking for fd_set in sys/select.h
  379. cat > conftest.c <<EOF
  380. #include <stdio.h>
  381. #include <sys/select.h>
  382. main() { exit(0); } 
  383. t() { fd_set foo; }
  384. EOF
  385. if eval $compile; then
  386. X  DEFS="$DEFS -DFD_SET_IN_SYS_SELECT_H=1"
  387. SEDDEFS="${SEDDEFS}\${SEDdA}FD_SET_IN_SYS_SELECT_H\${SEDdB}FD_SET_IN_SYS_SELECT_H\${SEDdC}1\${SEDdD}
  388. \${SEDuA}FD_SET_IN_SYS_SELECT_H\${SEDuB}FD_SET_IN_SYS_SELECT_H\${SEDuC}1\${SEDuD}
  389. \${SEDeA}FD_SET_IN_SYS_SELECT_H\${SEDeB}FD_SET_IN_SYS_SELECT_H\${SEDeC}1\${SEDeD}
  390. "
  391. else
  392. X  echo checking for fd_set in sys/inet.h
  393. cat > conftest.c <<EOF
  394. #include <stdio.h>
  395. #include <sys/inet.h>
  396. main() { exit(0); } 
  397. t() { fd_set foo; }
  398. EOF
  399. if eval $compile; then
  400. X  DEFS="$DEFS -DFD_SET_IN_SYS_INET_H=1"
  401. SEDDEFS="${SEDDEFS}\${SEDdA}FD_SET_IN_SYS_INET_H\${SEDdB}FD_SET_IN_SYS_INET_H\${SEDdC}1\${SEDdD}
  402. \${SEDuA}FD_SET_IN_SYS_INET_H\${SEDuB}FD_SET_IN_SYS_INET_H\${SEDuC}1\${SEDuD}
  403. \${SEDeA}FD_SET_IN_SYS_INET_H\${SEDeB}FD_SET_IN_SYS_INET_H\${SEDeC}1\${SEDeD}
  404. "
  405. fi
  406. rm -f conftest*
  407. X
  408. fi
  409. rm -f conftest*
  410. X
  411. fi
  412. rm -f conftest*
  413. X
  414. echo checking for struct tm in time.h
  415. cat > conftest.c <<EOF
  416. #include <sys/types.h>
  417. #include <time.h>
  418. main() { exit(0); } 
  419. t() { struct tm *tp; }
  420. EOF
  421. if eval $compile; then
  422. X  :
  423. else
  424. X  DEFS="$DEFS -DTM_IN_SYS_TIME=1"
  425. SEDDEFS="${SEDDEFS}\${SEDdA}TM_IN_SYS_TIME\${SEDdB}TM_IN_SYS_TIME\${SEDdC}1\${SEDdD}
  426. \${SEDuA}TM_IN_SYS_TIME\${SEDuB}TM_IN_SYS_TIME\${SEDuC}1\${SEDuD}
  427. \${SEDeA}TM_IN_SYS_TIME\${SEDeB}TM_IN_SYS_TIME\${SEDeC}1\${SEDeD}
  428. "
  429. fi
  430. rm -f conftest*
  431. X
  432. for func in re_comp regcmp strcasecmp random rand strerror getlogin getpwuid
  433. do
  434. trfunc=HAVE_`echo $func | tr '[a-z]' '[A-Z]'`
  435. echo checking for ${func}
  436. cat > conftest.c <<EOF
  437. #include <stdio.h>
  438. main() { exit(0); } 
  439. t() { 
  440. #ifdef __stub_${func}
  441. choke me
  442. #else
  443. /* Override any gcc2 internal prototype to avoid an error.  */
  444. extern char ${func}(); ${func}();
  445. #endif
  446. X }
  447. EOF
  448. if eval $compile; then
  449. X  DEFS="$DEFS -D${trfunc}=1"
  450. SEDDEFS="${SEDDEFS}\${SEDdA}${trfunc}\${SEDdB}${trfunc}\${SEDdC}1\${SEDdD}
  451. \${SEDuA}${trfunc}\${SEDuB}${trfunc}\${SEDuC}1\${SEDuD}
  452. \${SEDeA}${trfunc}\${SEDeB}${trfunc}\${SEDeC}1\${SEDeD}
  453. "
  454. fi
  455. rm -f conftest*
  456. #endif
  457. done
  458. X
  459. for func in strspn
  460. do
  461. trfunc=HAVE_`echo $func | tr '[a-z]' '[A-Z]'`
  462. echo checking for ${func}
  463. cat > conftest.c <<EOF
  464. #include <stdio.h>
  465. main() { exit(0); } 
  466. t() { 
  467. #ifdef __stub_${func}
  468. choke me
  469. #else
  470. /* Override any gcc2 internal prototype to avoid an error.  */
  471. extern char ${func}(); ${func}();
  472. #endif
  473. X }
  474. EOF
  475. if eval $compile; then
  476. X  DEFS="$DEFS -D${trfunc}=1"
  477. SEDDEFS="${SEDDEFS}\${SEDdA}${trfunc}\${SEDdB}${trfunc}\${SEDdC}1\${SEDdD}
  478. \${SEDuA}${trfunc}\${SEDuB}${trfunc}\${SEDuC}1\${SEDuD}
  479. \${SEDeA}${trfunc}\${SEDeB}${trfunc}\${SEDeC}1\${SEDeD}
  480. "
  481. fi
  482. rm -f conftest*
  483. #endif
  484. done
  485. X
  486. echo checking for errno
  487. cat > conftest.c <<EOF
  488. X
  489. main() { exit(0); } 
  490. t() { extern int errno; int i=errno; }
  491. EOF
  492. if eval $compile; then
  493. X  DEFS="$DEFS -DHAVE_ERRNO=1"
  494. SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_ERRNO\${SEDdB}HAVE_ERRNO\${SEDdC}1\${SEDdD}
  495. \${SEDuA}HAVE_ERRNO\${SEDuB}HAVE_ERRNO\${SEDuC}1\${SEDuD}
  496. \${SEDeA}HAVE_ERRNO\${SEDeB}HAVE_ERRNO\${SEDeC}1\${SEDeD}
  497. "
  498. fi
  499. rm -f conftest*
  500. X
  501. echo checking for sys_errlist
  502. cat > conftest.c <<EOF
  503. X
  504. main() { exit(0); } 
  505. t() { extern char **sys_errlist; char *s=*sys_errlist; }
  506. EOF
  507. if eval $compile; then
  508. X  DEFS="$DEFS -DHAVE_SYS_ERRLIST=1"
  509. SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_SYS_ERRLIST\${SEDdB}HAVE_SYS_ERRLIST\${SEDdC}1\${SEDdD}
  510. \${SEDuA}HAVE_SYS_ERRLIST\${SEDuB}HAVE_SYS_ERRLIST\${SEDuC}1\${SEDuD}
  511. \${SEDeA}HAVE_SYS_ERRLIST\${SEDeB}HAVE_SYS_ERRLIST\${SEDeC}1\${SEDeD}
  512. "
  513. fi
  514. rm -f conftest*
  515. X
  516. echo checking whether -lresolv is needed
  517. cat > conftest.c <<EOF
  518. #include "resolv.c"
  519. EOF
  520. eval $compile
  521. if test -s conftest && (./conftest; exit) 2>/dev/null; then
  522. X  :
  523. else
  524. X  DEFS="$DEFS -DNEED_LRESOLV=1"
  525. SEDDEFS="${SEDDEFS}\${SEDdA}NEED_LRESOLV\${SEDdB}NEED_LRESOLV\${SEDdC}1\${SEDdD}
  526. \${SEDuA}NEED_LRESOLV\${SEDuB}NEED_LRESOLV\${SEDuC}1\${SEDuD}
  527. \${SEDeA}NEED_LRESOLV\${SEDeB}NEED_LRESOLV\${SEDeC}1\${SEDeD}
  528. "
  529. fi
  530. rm -f conftest*
  531. if test -n "$prefix"; then
  532. X  test -z "$exec_prefix" && exec_prefix='${prefix}'
  533. X  prsub="s%^prefix\\([     ]*\\)=\\([     ]*\\).*$%prefix\\1=\\2$prefix%"
  534. fi
  535. if test -n "$exec_prefix"; then
  536. X  prsub="$prsub
  537. s%^exec_prefix\\([     ]*\\)=\\([     ]*\\).*$%\
  538. exec_prefix\\1=\\2$exec_prefix%"
  539. fi
  540. X
  541. trap 'rm -f config.status; exit 1' 1 3 15
  542. echo creating config.status
  543. rm -f config.status
  544. cat > config.status <<EOF
  545. #!/bin/sh
  546. # Generated automatically by configure.
  547. # Run this file to recreate the current configuration.
  548. # This directory was configured as follows,
  549. # on host `(hostname || uname -n) 2>/dev/null`:
  550. #
  551. # $0 $*
  552. X
  553. for arg
  554. do
  555. X  case "\$arg" in
  556. X    -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
  557. X    exec /bin/sh $0 $* ;;
  558. X    *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;;
  559. X  esac
  560. done
  561. X
  562. trap 'rm -f  config.h conftest*; exit 1' 1 3 15
  563. CC='$CC'
  564. CPP='$CPP'
  565. FD_SET_IN_SYS_TYPES_H='$FD_SET_IN_SYS_TYPES_H'
  566. FD_SET_IN_SYS_SELECT_H='$FD_SET_IN_SYS_SELECT_H'
  567. FD_SET_IN_SYS_INET_H='$FD_SET_IN_SYS_INET_H'
  568. HAVE_ERRNO='$HAVE_ERRNO'
  569. HAVE_SYS_ERRLIST='$HAVE_SYS_ERRLIST'
  570. NEED_LRESOLV='$NEED_LRESOLV'
  571. LIBS='$LIBS'
  572. srcdir='$srcdir'
  573. prefix='$prefix'
  574. exec_prefix='$exec_prefix'
  575. prsub='$prsub'
  576. EOF
  577. cat >> config.status <<\EOF
  578. X
  579. top_srcdir=$srcdir
  580. for file in .. ; do if [ "x$file" != "x.." ]; then
  581. X  srcdir=$top_srcdir
  582. X  # Remove last slash and all that follows it.  Not all systems have dirname.
  583. X  dir=`echo $file|sed 's%/[^/][^/]*$%%'`
  584. X  if test "$dir" != "$file"; then
  585. X    test "$top_srcdir" != . && srcdir=$top_srcdir/$dir
  586. X    test ! -d $dir && mkdir $dir
  587. X  fi
  588. X  echo creating $file
  589. X  rm -f $file
  590. X  echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file
  591. X  sed -e "
  592. $prsub
  593. s%@CC@%$CC%g
  594. s%@CPP@%$CPP%g
  595. s%@FD_SET_IN_SYS_TYPES_H@%$FD_SET_IN_SYS_TYPES_H%g
  596. s%@FD_SET_IN_SYS_SELECT_H@%$FD_SET_IN_SYS_SELECT_H%g
  597. s%@FD_SET_IN_SYS_INET_H@%$FD_SET_IN_SYS_INET_H%g
  598. s%@HAVE_ERRNO@%$HAVE_ERRNO%g
  599. s%@HAVE_SYS_ERRLIST@%$HAVE_SYS_ERRLIST%g
  600. s%@NEED_LRESOLV@%$NEED_LRESOLV%g
  601. s%@LIBS@%$LIBS%g
  602. s%@srcdir@%$srcdir%g
  603. s%@DEFS@%-DHAVE_CONFIG_H%" $top_srcdir/${file}.in >> $file
  604. fi; done
  605. X
  606. echo creating config.h
  607. # These sed commands are put into SEDDEFS when defining a macro.
  608. # They are broken into pieces to make the sed script easier to manage.
  609. # They are passed to sed as "A NAME B NAME C VALUE D", where NAME
  610. # is the cpp macro being defined and VALUE is the value it is being given.
  611. # Each defining turns into a single global substitution command.
  612. #
  613. # SEDd sets the value in "#define NAME VALUE" lines.
  614. SEDdA='s@^\([     ]*\)#\([     ]*define[     ][     ]*\)'
  615. SEDdB='\([     ][     ]*\)[^     ]*@\1#\2'
  616. SEDdC='\3'
  617. SEDdD='@g'
  618. # SEDu turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
  619. SEDuA='s@^\([     ]*\)#\([     ]*\)undef\([     ][     ]*\)'
  620. SEDuB='\([     ]\)@\1#\2define\3'
  621. SEDuC=' '
  622. SEDuD='\4@g'
  623. # SEDe turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
  624. SEDeA='s@^\([     ]*\)#\([     ]*\)undef\([     ][     ]*\)'
  625. SEDeB='$@\1#\2define\3'
  626. SEDeC=' '
  627. SEDeD='@g'
  628. rm -f conftest.sed
  629. cat > conftest.sed <<CONFEOF
  630. EOF
  631. # Turn off quoting long enough to insert the sed commands.
  632. cat >> config.status <<EOF
  633. $SEDDEFS
  634. EOF
  635. cat >> config.status <<\EOF
  636. CONFEOF
  637. rm -f conftest.h
  638. # Break up the sed commands because old seds have small limits.
  639. cp $top_srcdir/config.h.in conftest.h1
  640. while :
  641. do
  642. X  lines=`grep -c . conftest.sed`
  643. X  if test -z "$lines" || test "$lines" -eq 0; then break; fi
  644. X  rm -f conftest.s1 conftest.s2 conftest.h2
  645. X  sed 40q conftest.sed > conftest.s1 # Like head -40.
  646. X  sed 1,40d conftest.sed > conftest.s2 # Like tail +41.
  647. X  sed -f conftest.s1 < conftest.h1 > conftest.h2
  648. X  rm -f conftest.s1 conftest.h1 conftest.sed
  649. X  mv conftest.h2 conftest.h1
  650. X  mv conftest.s2 conftest.sed
  651. done
  652. rm -f conftest.sed conftest.h
  653. echo "/* config.h.  Generated automatically by configure.  */" > conftest.h
  654. cat conftest.h1 >> conftest.h
  655. rm -f conftest.h1
  656. if cmp -s config.h conftest.h 2>/dev/null; then
  657. X  # The file exists and we would not be changing it.
  658. X  rm -f conftest.h
  659. else
  660. X  rm -f config.h
  661. X  mv conftest.h config.h
  662. fi
  663. X
  664. EOF
  665. chmod +x config.status
  666. test -n "$no_create" || ./config.status
  667. X
  668. SHAR_EOF
  669. chmod 0755 xarchie-2.0.6/configure ||
  670. echo 'restore of xarchie-2.0.6/configure failed'
  671. Wc_c="`wc -c < 'xarchie-2.0.6/configure'`"
  672. test 16545 -eq "$Wc_c" ||
  673.     echo 'xarchie-2.0.6/configure: original size 16545, current size' "$Wc_c"
  674. rm -f _shar_wnt_.tmp
  675. fi
  676. # ============= xarchie-2.0.6/configure.in ==============
  677. if test -f 'xarchie-2.0.6/configure.in' -a X"$1" != X"-c"; then
  678.     echo 'x - skipping xarchie-2.0.6/configure.in (File already exists)'
  679.     rm -f _shar_wnt_.tmp
  680. else
  681. > _shar_wnt_.tmp
  682. echo 'x - extracting xarchie-2.0.6/configure.in (Text)'
  683. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/configure.in' &&
  684. dnl Process this file with autoconf to produce a configure script.
  685. dnl
  686. AC_INIT(xarchie.c)
  687. AC_CONFIG_HEADER(config.h)
  688. AC_PROG_CC
  689. AC_PROG_CPP
  690. AC_GCC_TRADITIONAL
  691. AC_ISC_POSIX
  692. AC_IRIX_SUN
  693. AC_STDC_HEADERS
  694. AC_HAVE_HEADERS(string.h memory.h [sys/param.h])
  695. AC_COMPILE_CHECK([fd_set in sys/types.h],
  696. [#include <stdio.h>
  697. #include <sys/types.h>], [fd_set foo;],
  698. X AC_DEFINE(FD_SET_IN_SYS_TYPES_H,1),
  699. X AC_COMPILE_CHECK([fd_set in sys/select.h],
  700. [#include <stdio.h>
  701. #include <sys/select.h>], [fd_set foo;],
  702. X AC_DEFINE(FD_SET_IN_SYS_SELECT_H,1),
  703. X AC_COMPILE_CHECK([fd_set in sys/inet.h],
  704. [#include <stdio.h>
  705. #include <sys/inet.h>], [fd_set foo;],
  706. X AC_DEFINE(FD_SET_IN_SYS_INET_H,1))))
  707. AC_SUBST(FD_SET_IN_SYS_TYPES_H)dnl 
  708. AC_SUBST(FD_SET_IN_SYS_SELECT_H)dnl 
  709. AC_SUBST(FD_SET_IN_SYS_INET_H)dnl 
  710. AC_STRUCT_TM
  711. AC_HAVE_FUNCS(re_comp regcmp strcasecmp random rand strerror getlogin getpwuid)
  712. AC_HAVE_FUNCS(strspn)
  713. AC_COMPILE_CHECK(errno, , [extern int errno; int i=errno;],
  714. X AC_DEFINE(HAVE_ERRNO))
  715. AC_SUBST(HAVE_ERRNO)dnl
  716. AC_COMPILE_CHECK(sys_errlist, ,
  717. X [extern char **sys_errlist; char *s=*sys_errlist;],
  718. X AC_DEFINE(HAVE_SYS_ERRLIST))
  719. AC_SUBST(HAVE_SYS_ERRLIST)dnl
  720. dnl To test for -lresolv we use the provided test program, resolv.c:
  721. echo checking whether -lresolv is needed
  722. AC_TEST_PROGRAM([#include "resolv.c"], , AC_DEFINE(NEED_LRESOLV))
  723. AC_SUBST(NEED_LRESOLV)dnl
  724. AC_OUTPUT()
  725. SHAR_EOF
  726. chmod 0644 xarchie-2.0.6/configure.in ||
  727. echo 'restore of xarchie-2.0.6/configure.in failed'
  728. Wc_c="`wc -c < 'xarchie-2.0.6/configure.in'`"
  729. test 1360 -eq "$Wc_c" ||
  730.     echo 'xarchie-2.0.6/configure.in: original size 1360, current size' "$Wc_c"
  731. rm -f _shar_wnt_.tmp
  732. fi
  733. # ============= xarchie-2.0.6/confirm.c ==============
  734. if test -f 'xarchie-2.0.6/confirm.c' -a X"$1" != X"-c"; then
  735.     echo 'x - skipping xarchie-2.0.6/confirm.c (File already exists)'
  736.     rm -f _shar_wnt_.tmp
  737. else
  738. > _shar_wnt_.tmp
  739. echo 'x - extracting xarchie-2.0.6/confirm.c (Text)'
  740. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/confirm.c' &&
  741. /*
  742. X * confirm.c : Confirmer popup
  743. X *
  744. X * George Ferguson, ferguson@cs.rochester.edu, 23 Apr 1993.
  745. X */
  746. X
  747. #include <X11/Intrinsic.h>
  748. #include "popups.h"
  749. X
  750. /*
  751. X * Functions defined here:
  752. X */
  753. int confirm0();
  754. static void confirmCallback();
  755. X
  756. /*
  757. X * Data defined here:
  758. X */
  759. static Widget confirmShell;
  760. static int confirmResult;
  761. X
  762. /*    -    -    -    -    -    -    -    -    */
  763. X
  764. int
  765. confirm0(str)
  766. char *str;
  767. {
  768. X    if (confirmShell == NULL)
  769. X    confirmShell = createPopup("confirm",2,confirmCallback);
  770. X    setPopupLabel(confirmShell,"confirm",str);
  771. X    popupMainLoop(confirmShell);
  772. X    return(confirmResult);
  773. }
  774. X
  775. /*ARGSUSED*/
  776. static void
  777. confirmCallback(w,client_data,call_data)
  778. Widget w;
  779. XXtPointer client_data;        /* button number */
  780. XXtPointer call_data;
  781. {
  782. X    switch ((int)client_data) {
  783. X      case 0:            /* YES */
  784. X    confirmResult = 1;
  785. X    break;
  786. X      case 1:            /* NO */
  787. X    confirmResult = 0;
  788. X    break;
  789. X    }
  790. X    popupDone();
  791. }
  792. SHAR_EOF
  793. chmod 0644 xarchie-2.0.6/confirm.c ||
  794. echo 'restore of xarchie-2.0.6/confirm.c failed'
  795. Wc_c="`wc -c < 'xarchie-2.0.6/confirm.c'`"
  796. test 875 -eq "$Wc_c" ||
  797.     echo 'xarchie-2.0.6/confirm.c: original size 875, current size' "$Wc_c"
  798. rm -f _shar_wnt_.tmp
  799. fi
  800. # ============= xarchie-2.0.6/confirm.h ==============
  801. if test -f 'xarchie-2.0.6/confirm.h' -a X"$1" != X"-c"; then
  802.     echo 'x - skipping xarchie-2.0.6/confirm.h (File already exists)'
  803.     rm -f _shar_wnt_.tmp
  804. else
  805. > _shar_wnt_.tmp
  806. echo 'x - extracting xarchie-2.0.6/confirm.h (Text)'
  807. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/confirm.h' &&
  808. /*
  809. X * confirm.h : External defs for confirmer functions
  810. X *
  811. X * George Ferguson, ferguson@cs.rochester.edu, 23 Apr 1993.
  812. X */
  813. X
  814. #ifndef _CONFIRM_H
  815. #define _CONFIRM_H
  816. X
  817. extern int confirm0();
  818. X
  819. #endif
  820. SHAR_EOF
  821. chmod 0644 xarchie-2.0.6/confirm.h ||
  822. echo 'restore of xarchie-2.0.6/confirm.h failed'
  823. Wc_c="`wc -c < 'xarchie-2.0.6/confirm.h'`"
  824. test 194 -eq "$Wc_c" ||
  825.     echo 'xarchie-2.0.6/confirm.h: original size 194, current size' "$Wc_c"
  826. rm -f _shar_wnt_.tmp
  827. fi
  828. # ============= xarchie-2.0.6/copyright.h ==============
  829. if test -f 'xarchie-2.0.6/copyright.h' -a X"$1" != X"-c"; then
  830.     echo 'x - skipping xarchie-2.0.6/copyright.h (File already exists)'
  831.     rm -f _shar_wnt_.tmp
  832. else
  833. > _shar_wnt_.tmp
  834. echo 'x - extracting xarchie-2.0.6/copyright.h (Text)'
  835. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/copyright.h' &&
  836. /* These are the uw-copyright.h and usc-copyright.h files that appear in
  837. X   the Prospero distribution.  */
  838. X
  839. /* 
  840. X  Copyright (c) 1989, 1990, 1991 by the University of Washington
  841. X
  842. X  Permission to use, copy, modify, and distribute this software and its
  843. X  documentation for non-commercial purposes and without fee is hereby
  844. X  granted, provided that the above copyright notice appear in all copies
  845. X  and that both the copyright notice and this permission notice appear in
  846. X  supporting documentation, and that the name of the University of
  847. X  Washington not be used in advertising or publicity pertaining to
  848. X  distribution of the software without specific, written prior
  849. X  permission.  The University of Washington makes no representations
  850. X  about the suitability of this software for any purpose.  It is
  851. X  provided "as is" without express or implied warranty.
  852. X
  853. X  Prospero was written by Clifford Neuman (bcn@isi.edu).
  854. X
  855. X  Questions concerning this software should be directed to 
  856. X  info-prospero@isi.edu.
  857. X
  858. X  */
  859. X
  860. /* 
  861. X  Copyright (c) 1991, 1992 by the University of Southern California
  862. X  All rights reserved.
  863. X
  864. X  Permission to use, copy, modify, and distribute this software and its
  865. X  documentation in source and binary forms for non-commercial purposes
  866. X  and without fee is hereby granted, provided that the above copyright
  867. X  notice appear in all copies and that both the copyright notice and
  868. X  this permission notice appear in supporting documentation. and that
  869. X  any documentation, advertising materials, and other materials related
  870. X  to such distribution and use acknowledge that the software was
  871. X  developed by the University of Southern California, Information
  872. X  Sciences Institute.  The name of the University may not be used to
  873. X  endorse or promote products derived from this software without
  874. X  specific prior written permission.
  875. X
  876. X  THE UNIVERSITY OF SOUTHERN CALIFORNIA makes no representations about
  877. X  the suitability of this software for any purpose.  THIS SOFTWARE IS
  878. X  PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
  879. X  INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  880. X  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  881. X
  882. X  Other copyrights might apply to parts of the Prospero distribution
  883. X  and are so noted when applicable.
  884. X
  885. X  Prospero was originally written by Clifford Neuman (bcn@isi.edu).
  886. X  Contributors include Benjamin Britt (britt@isi.edu)
  887. X  and others identified in individual modules.
  888. X
  889. X  Questions concerning this software should be directed to 
  890. X  info-prospero@isi.edu.
  891. X
  892. X  */
  893. SHAR_EOF
  894. chmod 0644 xarchie-2.0.6/copyright.h ||
  895. echo 'restore of xarchie-2.0.6/copyright.h failed'
  896. Wc_c="`wc -c < 'xarchie-2.0.6/copyright.h'`"
  897. test 2519 -eq "$Wc_c" ||
  898.     echo 'xarchie-2.0.6/copyright.h: original size 2519, current size' "$Wc_c"
  899. rm -f _shar_wnt_.tmp
  900. fi
  901. # ============= xarchie-2.0.6/db.c ==============
  902. if test -f 'xarchie-2.0.6/db.c' -a X"$1" != X"-c"; then
  903.     echo 'x - skipping xarchie-2.0.6/db.c (File already exists)'
  904.     rm -f _shar_wnt_.tmp
  905. else
  906. > _shar_wnt_.tmp
  907. echo 'x - extracting xarchie-2.0.6/db.c (Text)'
  908. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/db.c' &&
  909. /*
  910. X * db.c : Database routines for xarchie
  911. X *
  912. X * George Ferguson, ferguson@cs.rochester.edu, 2 Nov 1991.
  913. X * Version 2.0: 23 Apr 1993.
  914. X */
  915. X
  916. #include <stdio.h>
  917. #include "db.h"
  918. #include "weight.h"
  919. #include "stringdefs.h"
  920. #include "debug.h"
  921. X
  922. #ifdef XARCHIE
  923. # include <X11/Intrinsic.h>
  924. #else /*!XARCHIE*/
  925. # include "xtypes.h"
  926. #endif
  927. X
  928. /*
  929. X * Functions defined here:
  930. X */
  931. DbEntry *newEntry();
  932. void clearEntries();
  933. DbEntry *addEntry();
  934. DbEntry *lastEntry();
  935. DbEntry *findEntryFromString();
  936. DbEntry *findEntryFromIndex();
  937. int findIndexFromEntry();
  938. void setEntryData(), freeEntryData();
  939. void sortEntriesRecursively(), sortEntries();
  940. int cmpEntryNames(), cmpEntryDates(), cmpEntryWeights();
  941. X
  942. static void clearEntriesInternal();
  943. static char *entryDate(),*hostDate(),*locationDate();
  944. X
  945. /*    -    -    -    -    -    -    -    -    */
  946. X
  947. DbEntry *
  948. newEntry()
  949. {
  950. X    DbEntry *new;
  951. X
  952. X    new = XtNew(DbEntry);
  953. X    new->name = NULL;
  954. X    new->type = DB_NOTYPE;
  955. X    new->size = -1;
  956. X    new->modes = "";
  957. X    new->date = "";
  958. X    new->gt_date = "";
  959. X    new->vlink = NULL;
  960. X    new->selected = -1;
  961. X    new->entries = NULL;
  962. X    new->next = new->prev = new->parent = NULL;
  963. X    return(new);
  964. }
  965. X
  966. void
  967. clearEntries(dbp)
  968. DbEntry *dbp;
  969. {
  970. X    if (dbp == NULL) {
  971. X    fprintf(stderr,"DB Error: Attempt to clear NULL list\n");
  972. X    return;
  973. X    } else {
  974. X    clearEntriesInternal(dbp->entries);
  975. X    dbp->entries = NULL;
  976. X    }
  977. }
  978. X
  979. static void
  980. clearEntriesInternal(dbp)
  981. DbEntry *dbp;
  982. {
  983. X    DbEntry *t;
  984. X
  985. X    while (dbp != NULL) {
  986. X    clearEntriesInternal(dbp->entries);
  987. X    freeEntryData(dbp);
  988. X    t = dbp;
  989. X    dbp = dbp->next;
  990. X    XtFree((char *)t);
  991. X    }
  992. }
  993. X
  994. /*    -    -    -    -    -    -    -    -    */
  995. X
  996. DbEntry *
  997. addEntry(parent,before)
  998. DbEntry *parent;
  999. DbEntry *before;
  1000. {
  1001. X    DbEntry *new,*last;
  1002. X
  1003. X    DEBUG2("adding entry to 0x%x before 0x%x\n",parent,before);
  1004. X    if (parent == NULL) {
  1005. X    fprintf(stderr,"DB error: attempt to add entry to NULL list\n");
  1006. X    return(NULL);
  1007. X    } else if (parent->entries == NULL) {
  1008. X    /* No items already in list */
  1009. X    DEBUG0("  inserting as new list\n");
  1010. X    new = XtNew(DbEntry);
  1011. X    DEBUG1("  new entry is 0x%x\n",new);
  1012. X    parent->entries = new;
  1013. X    new->prev = NULL;
  1014. X    new->next = NULL;
  1015. X    } else if (before == NULL) {
  1016. X    /* Insert at end of list */
  1017. X    DEBUG0("  inserting at end of list\n");
  1018. X    last = lastEntry(parent);
  1019. X    new = XtNew(DbEntry);
  1020. X    DEBUG1("  new entry is 0x%x\n",new);
  1021. X    last->next = new;
  1022. X    new->prev = last;
  1023. X    new->next = NULL;
  1024. X    } else if (before->prev == NULL) {
  1025. X    /* Insert at head of list */
  1026. X    DEBUG0("  inserting at head of list\n");
  1027. X    new = XtNew(DbEntry);
  1028. X    DEBUG1("  new entry is 0x%x\n",new);
  1029. X    parent->entries = new;
  1030. X    new->prev = NULL;
  1031. X    new->next = before;
  1032. X    before->prev = new;
  1033. X    } else {
  1034. X    /* Insert somewhere in the middle of list */
  1035. X    DEBUG0("  inserting in middle of list\n");
  1036. X    new = XtNew(DbEntry);
  1037. X    DEBUG1("  new entry is 0x%x\n",new);
  1038. X    before->prev->next = new;
  1039. X    new->prev = before->prev;
  1040. X    new->next = before;
  1041. X    before->prev = new;
  1042. X    }
  1043. X    new->parent = parent;
  1044. X    new->entries = NULL;
  1045. X    new->name = NULL;
  1046. X    new->type = DB_NOTYPE;
  1047. X    new->size = -1;
  1048. X    new->modes = "";
  1049. X    new->date = "";
  1050. X    new->gt_date = "";
  1051. X    new->vlink = NULL;
  1052. X    DEBUG0("  done adding new entry\n");
  1053. X    return(new);
  1054. }
  1055. X
  1056. DbEntry *
  1057. lastEntry(parent)
  1058. DbEntry *parent;
  1059. {
  1060. X    DbEntry *dbp;
  1061. X
  1062. X    DEBUG1("finding last entry in entries for 0x%x\n",parent);
  1063. X    if (parent == NULL) {
  1064. X    fprintf(stderr,"DB error: attempt to find last entry of NULL list\n");
  1065. X    return(NULL);
  1066. X    } else if (parent->entries == NULL) {
  1067. X    DEBUG1("no entries for 0x%x, returning NULL\n",parent);
  1068. X    return(NULL);
  1069. X    } else {
  1070. X    for (dbp=parent->entries; dbp->next != NULL; dbp=dbp->next)
  1071. X        /* EMPTY */ ;
  1072. X    DEBUG2("last entry for 0x%x is 0x%x\n",parent,dbp);
  1073. X    return(dbp);
  1074. X    }
  1075. }
  1076. X
  1077. DbEntry *
  1078. findEntryFromString(parent,string)
  1079. DbEntry *parent;
  1080. char *string;
  1081. {
  1082. X    DbEntry *dbp;
  1083. X
  1084. X    DEBUG2("finding entry \"%s\" in entries for 0x%x\n",string,parent);
  1085. X    if (parent == NULL) {
  1086. X    fprintf(stderr,"DB error: attempt to find \"%s\" in NULL list",string);
  1087. X    return(NULL);
  1088. X    } else {
  1089. X    for (dbp=parent->entries; dbp != NULL &&
  1090. X                  strcmp(dbp->name,string) != 0; dbp=dbp->next)
  1091. X        /* EMPTY */ ;
  1092. X    DEBUG1("  find returning 0x%x\n",dbp);
  1093. X    return(dbp);
  1094. X    }
  1095. }
  1096. X
  1097. DbEntry *
  1098. findEntryFromIndex(parent,index)
  1099. DbEntry *parent;
  1100. int index;
  1101. {
  1102. X    DbEntry *dbp;
  1103. X
  1104. X    DEBUG2("finding entry with index %d in entries for 0x%x\n",index,parent);
  1105. X    if (parent == NULL) {
  1106. X    fprintf(stderr,"DB error: attempt to find index %d in NULL list",index);
  1107. X    return(NULL);
  1108. X    } else {
  1109. X    for (dbp=parent->entries; dbp != NULL && index--; dbp=dbp->next)
  1110. X        /* EMPTY */ ;
  1111. X    DEBUG1("  find returning 0x%x\n",dbp);
  1112. X    return(dbp);
  1113. X    }
  1114. }
  1115. X
  1116. int
  1117. findIndexFromEntry(parent,entry)
  1118. DbEntry *parent,*entry;
  1119. {
  1120. X    DbEntry *dbp;
  1121. X    int index;
  1122. X
  1123. X    DEBUG2("finding index for entry 0x%x in entries for 0x%x\n",entry,parent);
  1124. X    index = 0;
  1125. X    if (parent == NULL) {
  1126. X    fprintf(stderr,"DB error: attempt to find entry 0x%x in NULL list",entry);
  1127. X    return(0);
  1128. X    } else {
  1129. X    for (dbp=parent->entries; dbp != NULL; dbp=dbp->next) {
  1130. X        if (strcmp(entry->name,dbp->name) == 0) {
  1131. X        DEBUG1("  return index %d\n",index);
  1132. X        return(index);
  1133. X        }
  1134. X        index += 1;
  1135. X    }
  1136. X    }
  1137. X    return(-1);
  1138. }
  1139. X
  1140. /*    -    -    -    -    -    -    -    -    */
  1141. /*
  1142. X * Allocate and set the data for the given DbEntry.
  1143. X */
  1144. void
  1145. setEntryData(dbp,name,type,size,modes,date,gt_date,vlink)
  1146. DbEntry *dbp;
  1147. char *name;
  1148. int type;
  1149. int size;
  1150. char *modes,*date,*gt_date;
  1151. VLINK vlink;
  1152. {
  1153. X    XtFree(dbp->name);
  1154. X    dbp->name = XtNewString(name);
  1155. X    dbp->type = type;
  1156. X    dbp->size = size;
  1157. X    dbp->modes = XtNewString(modes);
  1158. X    dbp->date = XtNewString(date);
  1159. X    dbp->gt_date = XtNewString(gt_date);
  1160. X    dbp->vlink = vlink;
  1161. X    DEBUG2("set data for entry 0x%x, name=\"%s\"\n",dbp,dbp->name);
  1162. }
  1163. X
  1164. /*
  1165. X * Free up anything associated with the given DbEntry.
  1166. X */
  1167. void
  1168. freeEntryData(dbp)
  1169. DbEntry *dbp;
  1170. {
  1171. X    XtFree((char *)(dbp->name));
  1172. X    if (dbp->vlink)
  1173. X    vlfree(dbp->vlink);
  1174. }
  1175. X
  1176. /*    -    -    -    -    -    -    -    -    */
  1177. /*
  1178. X * Sorts entries of parent and then calls itself on each of them.
  1179. X */
  1180. void
  1181. sortEntriesRecursively(parent,cmp_proc)
  1182. DbEntry *parent;
  1183. int (*cmp_proc)();
  1184. {
  1185. X    DbEntry *dbp;
  1186. X
  1187. X    if (parent == NULL || cmp_proc == NULL)
  1188. X    return;
  1189. X    DEBUG1(" sorting entries recursively for 0x%x\n",parent);
  1190. X    sortEntries(parent,cmp_proc);
  1191. X    for (dbp=parent->entries; dbp != NULL; dbp = dbp->next)
  1192. X    sortEntriesRecursively(dbp->entries,cmp_proc);
  1193. X    DEBUG1(" done sorting entries recursively for 0x%x\n",parent);
  1194. }
  1195. X
  1196. /*
  1197. X * Sorts entries of parent using a selection sort and the given cmp_proc.
  1198. X */
  1199. void
  1200. sortEntries(parent,cmp_proc)
  1201. DbEntry *parent;
  1202. int (*cmp_proc)();
  1203. {
  1204. X    DbEntry *p,*nextp,*lowest,*q,*pnext,*pprev;
  1205. X
  1206. X    DEBUG1("  sorting entries for 0x%x\n",parent);
  1207. X    for (p = parent->entries; p != NULL; p = nextp) {
  1208. X    nextp = p->next;
  1209. X    lowest = p;
  1210. X    for (q = p->next; q != NULL; q = q->next)
  1211. X        if ((*cmp_proc)(q,lowest) < 0)
  1212. X        lowest = q;
  1213. X    if (p != lowest) {
  1214. X        /* swap the two links */
  1215. X        pnext = p->next;
  1216. X        pprev = p->prev;
  1217. X        if (lowest->next != NULL)
  1218. X        lowest->next->prev = p;
  1219. X        p->next = lowest->next;
  1220. X        if (nextp == lowest) {
  1221. X        p->prev = lowest;
  1222. X        } else {
  1223. X        lowest->prev->next = p;
  1224. X        p->prev = lowest->prev;
  1225. X        }
  1226. X        if (nextp == lowest) {
  1227. X        lowest->next = p;
  1228. X        } else {
  1229. X        pnext->prev = lowest;
  1230. X        lowest->next = pnext;
  1231. X        }
  1232. X        if (pprev != NULL)
  1233. X        pprev->next = lowest;
  1234. X        lowest->prev = pprev;
  1235. X        /* keep the head of the list in the right place */
  1236. X        if (parent->entries == p)
  1237. X        parent->entries = lowest;
  1238. X    }
  1239. X    }
  1240. X    DEBUG1("  done sorting entries for 0x%x\n",parent);
  1241. }
  1242. X
  1243. /*
  1244. X * cmpEntryNames(p,q) : Compare entries by name. Returns < 0 if p belongs
  1245. X *    before q, > 0 if q belongs before p, and == 0 if names are identical.
  1246. X */
  1247. int
  1248. cmpEntryNames(p,q)
  1249. DbEntry *p,*q;
  1250. {
  1251. X    return(strcmp(p->name,q->name));
  1252. }
  1253. X
  1254. /*
  1255. X * cmpEntryDates(p,q) : Compare entries by date. If the dates are the same
  1256. X *    or both entries don't have a date, then compare by name.
  1257. X *
  1258. X * To make this useful, I've made it sort hosts and locations by the
  1259. X * newest thing in them. To make it faster, it caches the computed date
  1260. X * in the otherwise unused date field.
  1261. X */
  1262. int
  1263. cmpEntryDates(p,q)
  1264. DbEntry *p,*q;
  1265. {
  1266. X    int result;
  1267. X
  1268. X    if (!*(p->gt_date))
  1269. X    p->gt_date = entryDate(p);
  1270. X    if (!*(q->gt_date))
  1271. X    q->gt_date = entryDate(q);
  1272. X    if ((result=strcmp(q->gt_date,p->gt_date)) != 0) /* note order! */
  1273. X    return(result);
  1274. X    else
  1275. X    return(cmpEntryNames(p,q));
  1276. }
  1277. X
  1278. static char *
  1279. entryDate(dbp)
  1280. DbEntry *dbp;
  1281. {
  1282. X    if (dbp->type == DB_HOST)
  1283. X    return(hostDate(dbp));
  1284. X    else if (dbp->type == DB_LOCATION)
  1285. X    return(locationDate(dbp));
  1286. X    else
  1287. X    return(dbp->gt_date);
  1288. }
  1289. X
  1290. /*
  1291. X * Returns the date of the newest (biggest date) location in the host.
  1292. X */
  1293. static char *
  1294. hostDate(dbp)
  1295. DbEntry *dbp;
  1296. {
  1297. X    DbEntry *loc;
  1298. X    char *date = "";
  1299. X    char *locdate;
  1300. X
  1301. X    for (loc=dbp->entries; loc != NULL; loc=loc->next) {
  1302. X    locdate = locationDate(loc);
  1303. X    if (!*date || strcmp(date,locdate) < 0)
  1304. X        date = locdate;
  1305. X    }
  1306. X    return(date);
  1307. }
  1308. X
  1309. /*
  1310. X * Returns the date of the newest (biggest date) entry in the location.
  1311. X */
  1312. static char *
  1313. locationDate(dbp)
  1314. DbEntry *dbp;
  1315. {
  1316. X    DbEntry *file;
  1317. X    char *date = "";
  1318. X
  1319. X    for (file=dbp->entries; file != NULL; file=file->next) {
  1320. X    if (!*date || strcmp(date,file->gt_date) < 0)
  1321. X        date = file->gt_date;
  1322. X    }
  1323. X    return(date);
  1324. }
  1325. X
  1326. /*
  1327. X * cmpEntryWeights(p,q) : Compare entries by user-defined "weights".
  1328. X */
  1329. int
  1330. cmpEntryWeights(p,q)
  1331. DbEntry *p,*q;
  1332. {
  1333. X    int result;
  1334. X
  1335. X    if ((result=hostWeight(p->name)-hostWeight(q->name)) != 0)
  1336. X    return(result);
  1337. X    else
  1338. X    return(cmpEntryNames(p,q));
  1339. }
  1340. SHAR_EOF
  1341. chmod 0644 xarchie-2.0.6/db.c ||
  1342. echo 'restore of xarchie-2.0.6/db.c failed'
  1343. Wc_c="`wc -c < 'xarchie-2.0.6/db.c'`"
  1344. test 9438 -eq "$Wc_c" ||
  1345.     echo 'xarchie-2.0.6/db.c: original size 9438, current size' "$Wc_c"
  1346. rm -f _shar_wnt_.tmp
  1347. fi
  1348. # ============= xarchie-2.0.6/db.h ==============
  1349. if test -f 'xarchie-2.0.6/db.h' -a X"$1" != X"-c"; then
  1350.     echo 'x - skipping xarchie-2.0.6/db.h (File already exists)'
  1351.     rm -f _shar_wnt_.tmp
  1352. else
  1353. > _shar_wnt_.tmp
  1354. echo 'x - extracting xarchie-2.0.6/db.h (Text)'
  1355. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/db.h' &&
  1356. /*
  1357. X * db.h : Definitions of the database record type, and external defs of
  1358. X *    the database functions.
  1359. X *
  1360. X * George Ferguson, ferguson@cs.rochester.edu, 2 Nov 1991.
  1361. X * Version 2.0: 23 Apr 1993.
  1362. X */
  1363. X
  1364. #ifndef DB_H
  1365. #define DB_H
  1366. X
  1367. #include "pfs.h"        /* for VLINK */
  1368. X
  1369. #define DB_NOTYPE    0
  1370. #define DB_FILE        1
  1371. #define DB_DIRECTORY    2
  1372. #define DB_LOCATION    3
  1373. #define DB_HOST        4
  1374. X
  1375. typedef struct _DbEntry {
  1376. X    char *name;            /* print name */
  1377. X    int type;            /* DB_{FILE,DIRECTORY} */
  1378. #ifdef MSDOS
  1379. X    unsigned long size;
  1380. #else
  1381. X    int size;
  1382. #endif
  1383. X    char *modes;        /* drwxrwxrwx + \0 */
  1384. X    char *date;            /* "mmm dd yyyy\0" or "mmm dd hh:mm\0" */
  1385. X    char *gt_date;        /* YYYYMMDDHHMMSSZ\0 */
  1386. X    int selected;        /* Selected in browser? Where? */
  1387. X    VLINK vlink;        /* Prospero VLINK for expansion */
  1388. X    struct _DbEntry *entries;        /* children */
  1389. X    struct _DbEntry *next,*prev;    /* siblings */
  1390. X    struct _DbEntry *parent;        /* parent */
  1391. } DbEntry;
  1392. X
  1393. extern DbEntry*newEntry();
  1394. extern void clearEntries();
  1395. extern DbEntry *addEntry();
  1396. extern DbEntry *lastEntry();
  1397. extern DbEntry *findEntryFromString();
  1398. extern DbEntry *findEntryFromIndex();
  1399. extern int findIndexFromEntry();
  1400. extern void setEntryData(), freeEntryData();
  1401. extern void sortEntriesRecursively(), sortEntries();
  1402. extern int cmpEntryNames(), cmpEntryDates(), cmpEntryWeights();
  1403. X
  1404. #define DB_ISDIR(dbp) ((dbp)->type == DB_DIRECTORY)
  1405. X
  1406. #endif /* DB_H */
  1407. SHAR_EOF
  1408. chmod 0644 xarchie-2.0.6/db.h ||
  1409. echo 'restore of xarchie-2.0.6/db.h failed'
  1410. Wc_c="`wc -c < 'xarchie-2.0.6/db.h'`"
  1411. test 1386 -eq "$Wc_c" ||
  1412.     echo 'xarchie-2.0.6/db.h: original size 1386, current size' "$Wc_c"
  1413. rm -f _shar_wnt_.tmp
  1414. fi
  1415. # ============= xarchie-2.0.6/debug.h ==============
  1416. if test -f 'xarchie-2.0.6/debug.h' -a X"$1" != X"-c"; then
  1417.     echo 'x - skipping xarchie-2.0.6/debug.h (File already exists)'
  1418.     rm -f _shar_wnt_.tmp
  1419. else
  1420. > _shar_wnt_.tmp
  1421. echo 'x - extracting xarchie-2.0.6/debug.h (Text)'
  1422. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/debug.h' &&
  1423. /*
  1424. X * debug.h : Macros for debug messages
  1425. X *
  1426. X * George Ferguson, ferguson@cs.rochester.edu, 23 Apr 1993.
  1427. X */
  1428. X
  1429. #ifdef DEBUG
  1430. #define DEBUG0(S)        fprintf(stderr,S)
  1431. #define DEBUG1(S,A1)        fprintf(stderr,S,A1)
  1432. #define DEBUG2(S,A1,A2)        fprintf(stderr,S,A1,A2)
  1433. #define DEBUG3(S,A1,A2,A3)    fprintf(stderr,S,A1,A2,A3)
  1434. #else
  1435. /*SUPPRESS 558*//* Saber: condition always false */
  1436. /*SUPPRESS 530*//* Saber: empty body of loop */
  1437. #define DEBUG0(S)
  1438. #define DEBUG1(S,A1)
  1439. #define DEBUG2(S,A1,A2)
  1440. #define DEBUG3(S,A1,A2,A3)
  1441. #endif
  1442. SHAR_EOF
  1443. chmod 0644 xarchie-2.0.6/debug.h ||
  1444. echo 'restore of xarchie-2.0.6/debug.h failed'
  1445. Wc_c="`wc -c < 'xarchie-2.0.6/debug.h'`"
  1446. test 509 -eq "$Wc_c" ||
  1447.     echo 'xarchie-2.0.6/debug.h: original size 509, current size' "$Wc_c"
  1448. rm -f _shar_wnt_.tmp
  1449. fi
  1450. # ============= xarchie-2.0.6/dirsend.c ==============
  1451. if test -f 'xarchie-2.0.6/dirsend.c' -a X"$1" != X"-c"; then
  1452.     echo 'x - skipping xarchie-2.0.6/dirsend.c (File already exists)'
  1453.     rm -f _shar_wnt_.tmp
  1454. else
  1455. > _shar_wnt_.tmp
  1456. echo 'x - extracting xarchie-2.0.6/dirsend.c (Text)'
  1457. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/dirsend.c' &&
  1458. /*
  1459. X * Copyright (c) 1989, 1990, 1991 by the University of Washington
  1460. X *
  1461. X * For copying and distribution information, please see the file
  1462. X * <copyright.h>.
  1463. X *
  1464. X * xarchie v2.0 - (gf)     - Sync with archie-1.4.1 (uses config.h)
  1465. X * v1.2.3 - 11/04/91 (bcn) - removed host comparison and replaced with check
  1466. X                  for connection id (undoes effect of v1.2.2.).
  1467. X * v1.2.2 - 11/02/91 (gf)  - removed extra inet_ntoa() calls and stuff for
  1468. X                 multi-interface nets (lmjm@doc.imperial.ac.uk)
  1469. X * v1.2.1 - 10/20/91 (gf)  - asynch implementation
  1470. X * v1.2.0 - 09/17/91 (bpk) - added BULL & USG stuff, thanks to Jim Sillas
  1471. X * v1.1.2 - 08/30/91 (bpk) - added VMS support
  1472. X * v1.1.1 - 08/29/91 (bcn) - changed backoff handling
  1473. X * v1.1.0 - 08/13/91 (gf)  - added XArchie status calls
  1474. X *
  1475. X * gf: 20 Oct 1991:
  1476. X *  Broken into pieces so that under X dirsend() doesn't block in select()
  1477. X *  but rather uses Xt calls to allow continued event processing. If
  1478. X *  XARCHIE is not defined, can still be used since processEvent() will
  1479. X *  use select() in this case.
  1480. X *
  1481. X * bpk: For archie client v1.3.2:
  1482. X * If you're going to hack on this, I'd suggest using unifdef with -UCUTCP
  1483. X * and possibly -UVMS, for your working copy.  When you've got your changes
  1484. X * done, come back and add them into this main file.  It's getting pretty
  1485. X * nasty down there.
  1486. X */
  1487. X
  1488. #include <copyright.h>
  1489. #include <stdio.h>
  1490. #include <errno.h>
  1491. X
  1492. /*
  1493. X * Complaints or suggestions regarding the portability or lack thereof
  1494. X * of these includes and defines should be directed to Brendan Kehoe,
  1495. X * brendan@cs.widener.edu.
  1496. X */
  1497. #ifdef VMS
  1498. # ifdef WOLLONGONG
  1499. #  include "twg$tcp:[netdist.include]netdb.h"
  1500. # else /* not Wollongong */
  1501. #  ifdef UCX
  1502. #   include <netdb.h>
  1503. #  else /* Multinet */
  1504. #   include "multinet_root:[multinet.include]netdb.h"
  1505. #  endif
  1506. # endif
  1507. # include <vms.h>
  1508. #else /* not VMS */
  1509. # ifdef PCNFS
  1510. #  include <tklib.h>
  1511. #  include <tk_errno.h>
  1512. #  include <sys/nfs_time.h>
  1513. # endif
  1514. # include "config.h"                /* gf */
  1515. # include "stringdefs.h"            /* gf */
  1516. # include "selectdefs.h"            /* gf */
  1517. # include <sys/time.h>                /* gf */
  1518. # ifdef CUTCP
  1519. #  include <msdos/cutcp.h>
  1520. #  include <msdos/netevent.h>
  1521. #  include <msdos/hostform.h>
  1522. # else /* not CUTCP */
  1523. #  include <netdb.h>
  1524. #  include <sys/socket.h>
  1525. # endif
  1526. # ifndef IN_H
  1527. #  ifndef _TYPES_
  1528. #   include <sys/types.h>
  1529. #  endif
  1530. #  include <netinet/in.h>
  1531. #  define IN_H
  1532. # endif
  1533. # if !defined(hpux) && !defined(PCNFS)
  1534. #  include <arpa/inet.h>
  1535. # endif
  1536. #endif /* !VMS */
  1537. X
  1538. /* Interactive UNIX keeps some of the socket definitions in funny places.  */
  1539. #ifdef ISC
  1540. # include <net/errno.h>
  1541. #endif /* ISC */
  1542. /* PC-NFS Toolkit 4.0 keeps important forward definitions here. */
  1543. #ifdef PCNFS
  1544. # include <in_addr.h>
  1545. #endif
  1546. X
  1547. #include <pfs.h>
  1548. #include <pprot.h>
  1549. #include <pcompat.h>
  1550. #include <perrno.h>
  1551. X
  1552. /* gf: Removed SUN_GNU_FIX stuff since inet_ntoa.c is now included. */
  1553. X
  1554. static int notprived = 0;
  1555. #ifndef MSDOS
  1556. extern int errno;
  1557. #endif
  1558. extern int perrno;
  1559. #ifdef DEBUG
  1560. extern int pfs_debug;
  1561. #endif
  1562. extern int pfs_disable_flag;
  1563. X
  1564. char    *nlsindex();
  1565. X
  1566. #define max(X, Y)  ((X) > (Y) ? (X) : (Y))
  1567. X
  1568. static int        dir_udp_port = 0;    /* Remote UDP port number */
  1569. X
  1570. #ifdef CUTCP
  1571. # define    NS_TIMEOUT    15
  1572. #endif
  1573. X
  1574. static unsigned short    next_conn_id = 0;
  1575. X
  1576. /* Always needed externally */
  1577. int client_dirsrv_timeout = CLIENT_DIRSRV_TIMEOUT;
  1578. int client_dirsrv_retry = CLIENT_DIRSRV_RETRY; 
  1579. int rdgram_priority = 0;            /* gf: was in rdgram.h */
  1580. X
  1581. /* These were parameters to dirsend() */
  1582. static PTEXT pkt;
  1583. static char *hostname;
  1584. static struct sockaddr_in *hostaddr;
  1585. X
  1586. /* These were locals in dirsend(). Note that the initializations here
  1587. X * are really meaningless since we have to redo them for each call to
  1588. X * dirsend() since they were formerly automatically initialized.
  1589. X */
  1590. static PTEXT        first = NULL;    /* First returned packet     */
  1591. static PTEXT        next;        /* The one we are waiting for      */
  1592. static PTEXT        vtmp;           /* For reorganizing linked list  */
  1593. static PTEXT        comp_thru;    /* We have all packets though    */
  1594. static int        lp = -1;    /* Opened UDP port             */
  1595. static int        hdr_len;    /* Header Length                 */
  1596. static int        nd_pkts;    /* Number of packets we want     */
  1597. static int        no_pkts;    /* Number of packets we have     */
  1598. static int        pkt_cid;        /* Packet connection identifier  */
  1599. static unsigned short    this_conn_id;    /* Connection ID we are using    */
  1600. static unsigned short    recvd_thru;    /* Received through              */
  1601. static short        priority;    /* Priority for request          */
  1602. static short        one = 0;    /* Pointer to value 1            */
  1603. static short        zero = 0;    /* Pointer to value 0         */
  1604. static char        *seqtxt;    /* Pointer to text w/ sequence # */
  1605. static struct sockaddr_in  us;        /* Our address                   */
  1606. static struct sockaddr_in  to;        /* Address to send query     */
  1607. static struct sockaddr_in  from;    /* Reply received from         */
  1608. static int        from_sz;    /* Size of from structure     */
  1609. static struct hostent    *host;        /* Host info from gethostbyname  */
  1610. static long        newhostaddr;    /* New host address from *host   */
  1611. static int        req_udp_port=0; /* Requested port (optional)     */
  1612. static char        *openparen;    /* Delimits port in name         */
  1613. static char        hostnoport[500];/* Host name without port        */
  1614. static int        ns;        /* Number of bytes actually sent */
  1615. static int        nr;        /* Number of bytes received      */
  1616. static fd_set    readfds;    /* Used for select         */
  1617. static int        tmp;
  1618. static char        *ctlptr;    /* Pointer to control field      */
  1619. static short        stmp;        /* Temp short for conversions    */
  1620. static int        backoff;    /* Server requested backoff      */
  1621. static unsigned char    rdflag11;    /* First byte of flags (bit vect)*/
  1622. static unsigned char    rdflag12;    /* Second byte of flags (int)    */
  1623. static int        scpflag = 0;    /* Set if any sequencd cont pkts */
  1624. static int        ackpend = 0;    /* Acknowledgement pending      */
  1625. static int        gaps = 0;    /* Gaps present in recvd pkts   */
  1626. static struct timeval    timeout;    /* Time to wait for response    */
  1627. static struct timeval    ackwait;    /* Time to wait before acking   */
  1628. static struct timeval    gapwait;    /* Time to wait b4 filling gaps */
  1629. static struct timeval    *selwait;    /* Time to wait for select      */
  1630. static int        retries;    /* was = client_dirsrv_retry    */
  1631. char   to_hostname[512];        /* lmjm: saves inet_ntoa() str  */
  1632. X
  1633. /* These are added so dirsend() "blocks" properly */
  1634. static PTEXT dirsendReturn;
  1635. static int dirsendDone;
  1636. X
  1637. /* And here are the values for dirsendDone */
  1638. #define DSRET_DONE        1
  1639. #define DSRET_SEND_ERROR    -1
  1640. #define DSRET_RECV_ERROR    -2
  1641. #define DSRET_SELECT_ERROR    -3
  1642. #define DSRET_TIMEOUT        -4
  1643. #define DSRET_ABORTED        -5
  1644. X
  1645. /* New procedures to break up dirsend() */
  1646. static int initDirsend();
  1647. static void retryDirsend(), keepWaitingDirsend();
  1648. static void timeoutProc();
  1649. static void readProc();
  1650. X
  1651. /* Wrappers around X calls to allow non-X usage */
  1652. static void addInputSource(), removeInputSource();
  1653. static void addTimeOut(), removeTimeOut();
  1654. static void processEvent();
  1655. X
  1656. /* External status procedures */
  1657. extern void status0(),status1(),status2();
  1658. X
  1659. #if defined(XARCHIE) || defined(VARCHIE)
  1660. static int packetCounter;
  1661. #endif
  1662. X
  1663. /* Extra stuff for the asynchronous X version of dirsend() */
  1664. #ifdef XARCHIE
  1665. #include <X11/Intrinsic.h>
  1666. extern XtAppContext appContext;
  1667. #else
  1668. #ifdef VARCHIE
  1669. #include "xtypes.h"
  1670. #else
  1671. typedef char *XtPointer;
  1672. typedef char *XtInputId;
  1673. typedef char *XtIntervalId;
  1674. #endif /* VARCHIE */
  1675. #endif /* XARCHIE */
  1676. X
  1677. static XtInputId inputId;
  1678. static XtIntervalId timerId = (XtIntervalId)0;
  1679. X
  1680. /*
  1681. X * dirsend - send packet and receive response
  1682. X *
  1683. X *   DIRSEND takes a pointer to a structure of type PTEXT, a hostname,
  1684. X *   and a pointer to a host address.  It then sends the supplied
  1685. X *   packet off to the directory server on the specified host.  If
  1686. X *   hostaddr points to a valid address, that address is used.  Otherwise,
  1687. X *   the hostname is looked up to obtain the address.  If hostaddr is a
  1688. X *   non-null pointer to a 0 address, then the address will be replaced
  1689. X *   with that found in the hostname lookup.
  1690. X *
  1691. X *   DIRSEND will wait for a response and retry an appropriate
  1692. X *   number of times as defined by timeout and retries (both static
  1693. X *   variables).  It will collect however many packets form the reply, and
  1694. X *   return them in a structure (or structures) of type PTEXT.
  1695. X *
  1696. X *   DIRSEND will free the packet that it is presented as an argument.
  1697. X *   The packet is freed even if dirsend fails.
  1698. X */
  1699. PTEXT
  1700. dirsend(pkt_p,hostname_p,hostaddr_p)
  1701. X    PTEXT pkt_p;
  1702. X    char *hostname_p;
  1703. X    struct sockaddr_in    *hostaddr_p;
  1704. {
  1705. X    /* copy parameters to globals since other routines use them */
  1706. X    pkt = pkt_p;
  1707. X    hostname = hostname_p;
  1708. X    hostaddr = hostaddr_p;
  1709. X    /* Do the initializations of formerly auto variables */
  1710. X    first = NULL;
  1711. X    lp = -1;
  1712. X    one = 0;
  1713. X    zero = 0;
  1714. X    req_udp_port=0;
  1715. X    scpflag = 0;
  1716. X    ackpend = 0;
  1717. X    gaps = 0;
  1718. X    retries = client_dirsrv_retry;
  1719. X
  1720. X    if (initDirsend() < 0)
  1721. X    return(NULL);
  1722. X    addInputSource();
  1723. X    /* set the first timeout */
  1724. X    retryDirsend();
  1725. X
  1726. X    dirsendReturn = NULL;
  1727. X    dirsendDone = 0;
  1728. X    /* Until one of the callbacks says to return, keep processing events */
  1729. X    while (!dirsendDone)
  1730. X    processEvent();
  1731. X    /* Clean up event generators */
  1732. X    removeTimeOut();
  1733. X    removeInputSource();
  1734. #if defined(XARCHIE) || defined(VARCHIE)
  1735. X    /* Set status if needed (has to be outside of loop or X will crash) */
  1736. X    switch (dirsendDone) {
  1737. X    case DSRET_SEND_ERROR: status0("Send error"); break;
  1738. X    case DSRET_RECV_ERROR: status0("Recv error"); break;
  1739. X        case DSRET_TIMEOUT:
  1740. X        status1("Connection to %s timed out",to_hostname);
  1741. X        break;
  1742. X        case DSRET_ABORTED: status0("Aborted"); break;
  1743. X    }
  1744. #endif
  1745. X    /* Return whatever we're supposed to */
  1746. X    return(dirsendReturn);
  1747. }
  1748. X
  1749. X
  1750. /*    -    -    -    -    -    -    -    -    */
  1751. /* This function does all the initialization that used to be done at the
  1752. X * start of dirsend(), including opening the socket descriptor "lp". It
  1753. SHAR_EOF
  1754. true || echo 'restore of xarchie-2.0.6/dirsend.c failed'
  1755. fi
  1756. echo 'End of xarchie-2.0.6 part 6'
  1757. echo 'File xarchie-2.0.6/dirsend.c is continued in part 7'
  1758. echo 7 > _shar_seq_.tmp
  1759. exit 0
  1760.  
  1761. exit 0 # Just in case...
  1762. -- 
  1763.   // chris@IMD.Sterling.COM       | Send comp.sources.x submissions to:
  1764. \X/  Amiga - The only way to fly! |    sources-x@imd.sterling.com
  1765.  "It's intuitively obvious to the |
  1766.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1767.