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

  1. Newsgroups: comp.sources.x
  2. From: ferguson@cs.rochester.edu (George Ferguson)
  3. Subject: v20i042:  xarchie - An X browser interface to Archie, v2.0.6, Part14/24
  4. Message-ID: <1993Jun15.223407.933@sparky.imd.sterling.com>
  5. X-Md4-Signature: be279a54b869dd0eb2ae183c6544a918
  6. Sender: chris@sparky.imd.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Tue, 15 Jun 1993 22:34:07 GMT
  9. Approved: chris@sparky.imd.sterling.com
  10.  
  11. Submitted-by: ferguson@cs.rochester.edu (George Ferguson)
  12. Posting-number: Volume 20, Issue 42
  13. Archive-name: xarchie/part14
  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/part14
  19.  
  20. #!/bin/sh
  21. # this is Part.14 (part 14 of xarchie-2.0.6)
  22. # do not concatenate these parts, unpack them in order with /bin/sh
  23. # file xarchie-2.0.6/regex.c 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" != 14; 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/regex.c'
  39. else
  40. echo 'x - continuing file xarchie-2.0.6/regex.c'
  41. sed 's/^X//' << 'SHAR_EOF' >> 'xarchie-2.0.6/regex.c' &&
  42. X *    matches:    fo foo fooo foobar fobar foxx ...
  43. X *
  44. X *    pattern:    fo[ob]a[rz]    
  45. X *    compile:    CHR f CHR o CCL bitset CHR a CCL bitset END
  46. X *    matches:    fobar fooar fobaz fooaz
  47. X *
  48. X *    pattern:    foo\\+
  49. X *    compile:    CHR f CHR o CHR o CHR \ CLO CHR \ END END
  50. X *    matches:    foo\ foo\\ foo\\\  ...
  51. X *
  52. X *    pattern:    \(foo\)[1-3]\1    (same as foo[1-3]foo)
  53. X *    compile:    BOT 1 CHR f CHR o CHR o EOT 1 CCL bitset REF 1 END
  54. X *    matches:    foo1foo foo2foo foo3foo
  55. X *
  56. X *    pattern:    \(fo.*\)-\1
  57. X *    compile:    BOT 1 CHR f CHR o CLO ANY END EOT 1 CHR - REF 1 END
  58. X *    matches:    foo-foo fo-fo fob-fob foobar-foobar ...
  59. X * 
  60. X */
  61. X
  62. #define MAXNFA  1024
  63. #define MAXTAG  10
  64. X
  65. #define OKP     1
  66. #define NOP     0
  67. X
  68. #define CHR     1
  69. #define ANY     2
  70. #define CCL     3
  71. #define BOL     4
  72. #define EOL     5
  73. #define BOT     6
  74. #define EOT     7
  75. #define BOW    8
  76. #define EOW    9
  77. #define REF     10
  78. #define CLO     11
  79. X
  80. #define END     0
  81. X
  82. /*
  83. X * The following defines are not meant
  84. X * to be changeable. They are for readability
  85. X * only.
  86. X *
  87. X */
  88. #define MAXCHR    128
  89. #define CHRBIT    8
  90. #define BITBLK    MAXCHR/CHRBIT
  91. #define BLKIND    0170
  92. #define BITIND    07
  93. X
  94. #define ASCIIB    0177
  95. X
  96. typedef /*unsigned*/ char CHAR;
  97. X
  98. static int  tagstk[MAXTAG];             /* subpat tag stack..*/
  99. static CHAR nfa[MAXNFA];        /* automaton..       */
  100. static int  sta = NOP;                   /* status of lastpat */
  101. X
  102. static CHAR bittab[BITBLK];        /* bit table for CCL */
  103. X                    /* pre-set bits...   */
  104. static CHAR bitarr[] = {1,2,4,8,16,32,64,128};
  105. X
  106. static int internal_error;
  107. X
  108. static void
  109. chset(c)
  110. register CHAR c;
  111. {
  112. X    bittab[((c) & BLKIND) >> 3] |= bitarr[(c) & BITIND];
  113. }
  114. X
  115. #define badpat(x)    return (*nfa = END, x)
  116. #define store(x)    *mp++ = x
  117. char *     
  118. re_comp(pat)
  119. char *pat;
  120. {
  121. X    register char *p;               /* pattern pointer   */
  122. X    register CHAR *mp = nfa;        /* nfa pointer       */
  123. X    register CHAR *lp;              /* saved pointer..   */
  124. X    register CHAR *sp = nfa;        /* another one..     */
  125. X
  126. X    register int tagi = 0;          /* tag stack index   */
  127. X    register int tagc = 1;          /* actual tag count  */
  128. X
  129. X    register int n;
  130. X    register CHAR mask;        /* xor mask -CCL/NCL */
  131. X    int c1, c2;
  132. X        
  133. X    if (!pat || !*pat)
  134. X        if (sta)
  135. X            return 0;
  136. X        else
  137. X            badpat("No previous regular expression");
  138. X    sta = NOP;
  139. X
  140. X    for (p = pat; *p; p++) {
  141. X        lp = mp;
  142. X        switch(*p) {
  143. X
  144. X        case '.':               /* match any char..  */
  145. X            store(ANY);
  146. X            break;
  147. X
  148. X        case '^':               /* match beginning.. */
  149. X            if (p == pat)
  150. X                store(BOL);
  151. X            else {
  152. X                store(CHR);
  153. X                store(*p);
  154. X            }
  155. X            break;
  156. X
  157. X        case '$':               /* match endofline.. */
  158. X            if (!*(p+1))
  159. X                store(EOL);
  160. X            else {
  161. X                store(CHR);
  162. X                store(*p);
  163. X            }
  164. X            break;
  165. X
  166. X        case '[':               /* match char class..*/
  167. X            store(CCL);
  168. X
  169. X            if (*++p == '^') {
  170. X                mask = 0377;    
  171. X                p++;
  172. X            }
  173. X            else
  174. X                mask = 0;
  175. X
  176. X            if (*p == '-')        /* real dash */
  177. X                chset(*p++);
  178. X            if (*p == ']')        /* real brac */
  179. X                chset(*p++);
  180. X            while (*p && *p != ']') {
  181. X                if (*p == '-' && *(p+1) && *(p+1) != ']') {
  182. X                    p++;
  183. X                    c1 = *(p-2) + 1;
  184. X                    c2 = *p++;
  185. X                    while (c1 <= c2)
  186. X                        chset(c1++);
  187. X                }
  188. #ifdef EXTEND
  189. X                else if (*p == '\\' && *(p+1)) {
  190. X                    p++;
  191. X                    chset(*p++);
  192. X                }
  193. #endif
  194. X                else
  195. X                    chset(*p++);
  196. X            }
  197. X            if (!*p)
  198. X                badpat("Missing ]");
  199. X
  200. X            for (n = 0; n < BITBLK; bittab[n++] = (char) 0)
  201. X                store(mask ^ bittab[n]);
  202. X    
  203. X            break;
  204. X
  205. X        case '*':               /* match 0 or more.. */
  206. X        case '+':               /* match 1 or more.. */
  207. X            if (p == pat)
  208. X                badpat("Empty closure");
  209. X            lp = sp;        /* previous opcode */
  210. X            if (*lp == CLO)        /* equivalence..   */
  211. X                break;
  212. X            switch(*lp) {
  213. X
  214. X            case BOL:
  215. X            case BOT:
  216. X            case EOT:
  217. X            case BOW:
  218. X            case EOW:
  219. X            case REF:
  220. X                badpat("Illegal closure");
  221. X            default:
  222. X                break;
  223. X            }
  224. X
  225. X            if (*p == '+')
  226. X                for (sp = mp; lp < sp; lp++)
  227. X                    store(*lp);
  228. X
  229. X            store(END);
  230. X            store(END);
  231. X            sp = mp;
  232. X            while (--mp > lp)
  233. X                *mp = mp[-1];
  234. X            store(CLO);
  235. X            mp = sp;
  236. X            break;
  237. X
  238. X        case '\\':              /* tags, backrefs .. */
  239. X            switch(*++p) {
  240. X
  241. X            case '(':
  242. X                if (tagc < MAXTAG) {
  243. X                    tagstk[++tagi] = tagc;
  244. X                    store(BOT);
  245. X                    store(tagc++);
  246. X                }
  247. X                else
  248. X                    badpat("Too many \\(\\) pairs");
  249. X                break;
  250. X            case ')':
  251. X                if (*sp == BOT)
  252. X                    badpat("Null pattern inside \\(\\)");
  253. X                if (tagi > 0) {
  254. X                    store(EOT);
  255. X                    store(tagstk[tagi--]);
  256. X                }
  257. X                else
  258. X                    badpat("Unmatched \\)");
  259. X                break;
  260. X            case '<':
  261. X                store(BOW);
  262. X                break;
  263. X            case '>':
  264. X                if (*sp == BOW)
  265. X                    badpat("Null pattern inside \\<\\>");
  266. X                store(EOW);
  267. X                break;
  268. X            case '1':
  269. X            case '2':
  270. X            case '3':
  271. X            case '4':
  272. X            case '5':
  273. X            case '6':
  274. X            case '7':
  275. X            case '8':
  276. X            case '9':
  277. X                n = *p-'0';
  278. X                if (tagi > 0 && tagstk[tagi] == n)
  279. X                    badpat("Cyclical reference");
  280. X                if (tagc > n) {
  281. X                    store(REF);
  282. X                    store(n);
  283. X                }
  284. X                else
  285. X                    badpat("Undetermined reference");
  286. X                break;
  287. #ifdef EXTEND
  288. X            case 'b':
  289. X                store(CHR);
  290. X                store('\b');
  291. X                break;
  292. X            case 'n':
  293. X                store(CHR);
  294. X                store('\n');
  295. X                break;
  296. X            case 'f':
  297. X                store(CHR);
  298. X                store('\f');
  299. X                break;
  300. X            case 'r':
  301. X                store(CHR);
  302. X                store('\r');
  303. X                break;
  304. X            case 't':
  305. X                store(CHR);
  306. X                store('\t');
  307. X                break;
  308. #endif
  309. X            default:
  310. X                store(CHR);
  311. X                store(*p);
  312. X            }
  313. X            break;
  314. X
  315. X        default :               /* an ordinary char  */
  316. X            store(CHR);
  317. X            store(*p);
  318. X            break;
  319. X        }
  320. X        sp = lp;
  321. X    }
  322. X    if (tagi > 0)
  323. X        badpat("Unmatched \\(");
  324. X    store(END);
  325. X    sta = OKP;
  326. X    return 0;
  327. }
  328. X
  329. X
  330. static char *bol;
  331. static char *bopat[MAXTAG];
  332. static char *eopat[MAXTAG];
  333. char *pmatch();
  334. X
  335. /*
  336. X * re_exec:
  337. X *     execute nfa to find a match.
  338. X *
  339. X *    special cases: (nfa[0])    
  340. X *        BOL
  341. X *            Match only once, starting from the
  342. X *            beginning.
  343. X *        CHR
  344. X *            First locate the character without
  345. X *            calling pmatch, and if found, call
  346. X *            pmatch for the remaining string.
  347. X *        END
  348. X *            re_comp failed, poor luser did not
  349. X *            check for it. Fail fast.
  350. X *
  351. X *    If a match is found, bopat[0] and eopat[0] are set
  352. X *    to the beginning and the end of the matched fragment,
  353. X *    respectively.
  354. X *
  355. X */
  356. X
  357. int
  358. re_exec(lp)
  359. register char *lp;
  360. {
  361. X    register char c;
  362. X    register char *ep = 0;
  363. X    register CHAR *ap = nfa;
  364. X
  365. X    bol = lp;
  366. X
  367. X    bopat[0] = 0;
  368. X    bopat[1] = 0;
  369. X    bopat[2] = 0;
  370. X    bopat[3] = 0;
  371. X    bopat[4] = 0;
  372. X    bopat[5] = 0;
  373. X    bopat[6] = 0;
  374. X    bopat[7] = 0;
  375. X    bopat[8] = 0;
  376. X    bopat[9] = 0;
  377. X
  378. X    switch(*ap) {
  379. X
  380. X    case BOL:            /* anchored: match from BOL only */
  381. X        ep = pmatch(lp,ap);
  382. X        break;
  383. X    case CHR:            /* ordinary char: locate it fast */
  384. X        c = *(ap+1);
  385. X        while (*lp && *lp != c)
  386. X            lp++;
  387. X        if (!*lp)        /* if EOS, fail, else fall thru. */
  388. X            return 0;
  389. X    default:            /* regular matching all the way. */
  390. X        while (*lp) {
  391. X            if ((ep = pmatch(lp,ap)))
  392. X                break;
  393. X            lp++;
  394. X        }
  395. X        break;
  396. X    case END:            /* munged automaton. fail always */
  397. X        return 0;
  398. X    }
  399. X    if (!ep)
  400. X        return 0;
  401. X
  402. X    if (internal_error)
  403. X        return -1;
  404. X
  405. X    bopat[0] = lp;
  406. X    eopat[0] = ep;
  407. X    return 1;
  408. }
  409. X
  410. /* 
  411. X * pmatch: 
  412. X *    internal routine for the hard part
  413. X *
  414. X *     This code is mostly snarfed from an early
  415. X *     grep written by David Conroy. The backref and
  416. X *     tag stuff, and various other mods are by oZ.
  417. X *
  418. X *    special cases: (nfa[n], nfa[n+1])
  419. X *        CLO ANY
  420. X *            We KNOW ".*" will match ANYTHING
  421. X *            upto the end of line. Thus, go to
  422. X *            the end of line straight, without
  423. X *            calling pmatch recursively. As in
  424. X *            the other closure cases, the remaining
  425. X *            pattern must be matched by moving
  426. X *            backwards on the string recursively,
  427. X *            to find a match for xy (x is ".*" and 
  428. X *            y is the remaining pattern) where
  429. X *            the match satisfies the LONGEST match
  430. X *            for x followed by a match for y.
  431. X *        CLO CHR
  432. X *            We can again scan the string forward
  433. X *            for the single char without recursion, 
  434. X *            and at the point of failure, we execute 
  435. X *            the remaining nfa recursively, as
  436. X *            described above.
  437. X *
  438. X *    At the end of a successful match, bopat[n] and eopat[n]
  439. X *    are set to the beginning and end of subpatterns matched
  440. X *    by tagged expressions (n = 1 to 9).    
  441. X *
  442. X */
  443. X
  444. /*
  445. X * character classification table for word boundary
  446. X * operators BOW and EOW. the reason for not using 
  447. X * ctype macros is that we can let the user add into 
  448. X * our own table. see re_modw. This table is not in
  449. X * the bitset form, since we may wish to extend it
  450. X * in the future for other character classifications. 
  451. X *
  452. X *    TRUE for 0-9 A-Z a-z _
  453. X */
  454. static char chrtyp[MAXCHR] = {
  455. X    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  456. X    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  457. X    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  458. X    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  459. X    0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 
  460. X    1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 
  461. X    0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 
  462. X    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  463. X    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  464. X    1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 
  465. X    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  466. X    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  467. X    1, 1, 1, 0, 0, 0, 0, 0
  468. X    };
  469. X
  470. #define inascii(x)    (0177&(x))
  471. #define iswordc(x)     chrtyp[inascii(x)]
  472. #define isinset(x,y)     ((x)[((y)&BLKIND)>>3] & bitarr[(y)&BITIND])
  473. X
  474. /*
  475. X * skip values for CLO XXX to skip past the closure
  476. X *
  477. X */
  478. X
  479. #define ANYSKIP    2     /* [CLO] ANY END ...         */
  480. #define CHRSKIP    3    /* [CLO] CHR chr END ...     */
  481. #define CCLSKIP 18    /* [CLO] CCL 16bytes END ... */
  482. X
  483. static char *
  484. pmatch(lp, ap)
  485. register char *lp;
  486. register CHAR *ap;
  487. {
  488. X    register int op, c, n;
  489. X    register char *e;        /* extra pointer for CLO */
  490. X    register char *bp;        /* beginning of subpat.. */
  491. X    register char *ep;        /* ending of subpat..     */
  492. X    char *are;            /* to save the line ptr. */
  493. X
  494. X    while ((op = *ap++) != END)
  495. X        switch(op) {
  496. X
  497. X        case CHR:
  498. X            if (*lp++ != *ap++)
  499. X                return 0;
  500. X            break;
  501. X        case ANY:
  502. X            if (!*lp++)
  503. X                return 0;
  504. X            break;
  505. X        case CCL:
  506. X            c = *lp++;
  507. X            if (!isinset(ap,c))
  508. X                return 0;
  509. X            ap += BITBLK;
  510. X            break;
  511. X        case BOL:
  512. X            if (lp != bol)
  513. X                return 0;
  514. X            break;
  515. X        case EOL:
  516. X            if (*lp)
  517. X                return 0;
  518. X            break;
  519. X        case BOT:
  520. X            bopat[*ap++] = lp;
  521. X            break;
  522. X        case EOT:
  523. X            eopat[*ap++] = lp;
  524. X            break;
  525. X         case BOW:
  526. X            if (lp!=bol && iswordc(lp[-1]) || !iswordc(*lp))
  527. X                return 0;
  528. X            break;
  529. X        case EOW:
  530. X            if (lp==bol || !iswordc(lp[-1]) || iswordc(*lp))
  531. X                return 0;
  532. X            break;
  533. X        case REF:
  534. X            n = *ap++;
  535. X            bp = bopat[n];
  536. X            ep = eopat[n];
  537. X            while (bp < ep)
  538. X                if (*bp++ != *lp++)
  539. X                    return 0;
  540. X            break;
  541. X        case CLO:
  542. X            are = lp;
  543. X            switch(*ap) {
  544. X
  545. X            case ANY:
  546. X                while (*lp)
  547. X                    lp++;
  548. X                n = ANYSKIP;
  549. X                break;
  550. X            case CHR:
  551. X                c = *(ap+1);
  552. X                while (*lp && c == *lp)
  553. X                    lp++;
  554. X                n = CHRSKIP;
  555. X                break;
  556. X            case CCL:
  557. X                while ((c = *lp) && isinset(ap+1,c))
  558. X                    lp++;
  559. X                n = CCLSKIP;
  560. X                break;
  561. X            default:
  562. X                internal_error++;
  563. X                return 0;
  564. X            }
  565. X
  566. X            ap += n;
  567. X
  568. X            while (lp >= are) {
  569. X                if (e = pmatch(lp, ap))
  570. X                    return e;
  571. X                --lp;
  572. X            }
  573. X            return 0;
  574. X        default:
  575. X            internal_error++;
  576. X            return 0;
  577. X        }
  578. X    return lp;
  579. }
  580. SHAR_EOF
  581. echo 'File xarchie-2.0.6/regex.c is complete' &&
  582. chmod 0644 xarchie-2.0.6/regex.c ||
  583. echo 'restore of xarchie-2.0.6/regex.c failed'
  584. Wc_c="`wc -c < 'xarchie-2.0.6/regex.c'`"
  585. test 15953 -eq "$Wc_c" ||
  586.     echo 'xarchie-2.0.6/regex.c: original size 15953, current size' "$Wc_c"
  587. rm -f _shar_wnt_.tmp
  588. fi
  589. # ============= xarchie-2.0.6/regex.h ==============
  590. if test -f 'xarchie-2.0.6/regex.h' -a X"$1" != X"-c"; then
  591.     echo 'x - skipping xarchie-2.0.6/regex.h (File already exists)'
  592.     rm -f _shar_wnt_.tmp
  593. else
  594. > _shar_wnt_.tmp
  595. echo 'x - extracting xarchie-2.0.6/regex.h (Text)'
  596. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/regex.h' &&
  597. /*
  598. X * regex.h : External defs for Ozan Yigit's regex functions, for systems
  599. X *    that don't have them builtin. See regex.c for copyright and other
  600. X *    details.
  601. X *
  602. X * Note that this file can be included even if we're linking against the
  603. X * system routines, since the interface is (deliberately) identical.
  604. X *
  605. X * George Ferguson, ferguson@cs.rochester.edu, 11 Sep 1991.
  606. X */
  607. X
  608. #if defined(_AUX_SOURCE) || defined(USG)
  609. /* Let them use ours if they wish.  */
  610. # ifndef NOREGEX
  611. extern char *regcmp();
  612. extern char *regex();
  613. #define re_comp regcmp
  614. #define re_exec regex
  615. # endif
  616. #else
  617. extern char *re_comp();
  618. extern int re_exec();
  619. #endif
  620. SHAR_EOF
  621. chmod 0644 xarchie-2.0.6/regex.h ||
  622. echo 'restore of xarchie-2.0.6/regex.h failed'
  623. Wc_c="`wc -c < 'xarchie-2.0.6/regex.h'`"
  624. test 624 -eq "$Wc_c" ||
  625.     echo 'xarchie-2.0.6/regex.h: original size 624, current size' "$Wc_c"
  626. rm -f _shar_wnt_.tmp
  627. fi
  628. # ============= xarchie-2.0.6/resolv.c ==============
  629. if test -f 'xarchie-2.0.6/resolv.c' -a X"$1" != X"-c"; then
  630.     echo 'x - skipping xarchie-2.0.6/resolv.c (File already exists)'
  631.     rm -f _shar_wnt_.tmp
  632. else
  633. > _shar_wnt_.tmp
  634. echo 'x - extracting xarchie-2.0.6/resolv.c (Text)'
  635. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/resolv.c' &&
  636. /*
  637. X * resolv.c : Program to test if you need -lresolv to ensure DNS
  638. X *          hostname lookups.
  639. X *
  640. X * George Ferguson, ferguson@cs.rochester.edu, 23 Apr 1993.
  641. X *
  642. X * Compile with: cc -o resolv resolv.c
  643. X *
  644. X * If you get an error message when you run the program, you need -lresolv.
  645. X */
  646. X
  647. #include <stdio.h>
  648. #include <netdb.h>
  649. X
  650. main(argc,argv)
  651. int argc;
  652. char *argv[];
  653. {
  654. X    char *hostname = "archie.ans.net";
  655. X    char *addr;
  656. X    struct hostent *host;
  657. X    int i;
  658. X
  659. X    if (argc > 1)
  660. X    hostname = argv[1];
  661. X    if((host=gethostbyname(hostname)) == NULL) {
  662. X        herror(hostname);
  663. X        exit(1);
  664. X    } else {
  665. X    if (strcmp(hostname,host->h_name) != 0)
  666. X        printf("%s has official name %s\n",hostname,host->h_name);
  667. X    for (i=0; host->h_aliases[i]; i++)
  668. X        if (strcmp(hostname,host->h_aliases[i]) != 0)
  669. X        printf("%s has alias %s\n",hostname,host->h_aliases[i]);
  670. X    for (i=0; host->h_addr_list[i]; i++) {
  671. X        addr = host->h_addr_list[i];
  672. X        printf("%s has address %d.%d.%d.%d\n",hostname,
  673. X           ((unsigned char *)addr)[0],((unsigned char *)addr)[1],
  674. X           ((unsigned char *)addr)[2],((unsigned char *)addr)[3]);
  675. X    }
  676. X    exit(0);
  677. X    }
  678. }
  679. SHAR_EOF
  680. chmod 0644 xarchie-2.0.6/resolv.c ||
  681. echo 'restore of xarchie-2.0.6/resolv.c failed'
  682. Wc_c="`wc -c < 'xarchie-2.0.6/resolv.c'`"
  683. test 1122 -eq "$Wc_c" ||
  684.     echo 'xarchie-2.0.6/resolv.c: original size 1122, current size' "$Wc_c"
  685. rm -f _shar_wnt_.tmp
  686. fi
  687. # ============= xarchie-2.0.6/saveload.c ==============
  688. if test -f 'xarchie-2.0.6/saveload.c' -a X"$1" != X"-c"; then
  689.     echo 'x - skipping xarchie-2.0.6/saveload.c (File already exists)'
  690.     rm -f _shar_wnt_.tmp
  691. else
  692. > _shar_wnt_.tmp
  693. echo 'x - extracting xarchie-2.0.6/saveload.c (Text)'
  694. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/saveload.c' &&
  695. /*
  696. X * saveload.c : Device-independent routines for writing (ie printing),
  697. X *    saving, and restoring the browser contents.
  698. X *
  699. X * George Ferguson, ferguson@cs.rochester.edu, 23 Apr 1993.
  700. X */
  701. #include <stdio.h>
  702. #include "sysdefs.h"
  703. #include "stringdefs.h"
  704. #include "pfs.h"
  705. #include "pprot.h"
  706. #include "xtypes.h"
  707. #include "db.h"
  708. #include "query.h"
  709. #include "browser.h"
  710. #include "settings.h"
  711. #include "types.h"
  712. #include "appres.h"
  713. #include "alert.h"
  714. #include "status.h"
  715. X
  716. /*
  717. X * Functions defined here
  718. X */
  719. int save(),load(),writeToFile();
  720. X
  721. static void writeEntry(),saveEntry();
  722. X
  723. /*    -    -    -    -    -    -    -    -    */
  724. /*
  725. X * Save browser contents to FILENAME for later load.
  726. X */
  727. int
  728. save(db,filename)
  729. DbEntry *db;
  730. char *filename;
  731. {
  732. X    FILE *fp;
  733. X    DbEntry *hostp,*locp,*filep;
  734. X
  735. X    if ((fp=fopen(filename,"w")) == NULL) {
  736. X    alert1("Can't open %s for writing",filename);
  737. X    return(0);
  738. X    }
  739. X    status1("Saving to %s...",filename);
  740. X    /* Save the settinsg first */
  741. X    fprintf(fp,"archieHost: %s\n",appResources.archieHost);
  742. X    fprintf(fp,"searchType: %s\n",searchTypeToString(appResources.searchType));
  743. X    fprintf(fp,"sortType: %s\n",sortTypeToString(appResources.sortType));
  744. X    fprintf(fp,"niceLevel: %d\n",appResources.niceLevel);
  745. X    fprintf(fp,"maxHits: %d\n",appResources.maxHits);
  746. X    fprintf(fp,"timeout: %d\n",appResources.timeout);
  747. X    fprintf(fp,"retries: %d\n",appResources.retries);
  748. X    /* Now dump the browser */
  749. X    for (hostp=db->entries; hostp != NULL; hostp = hostp->next)
  750. X    for (locp=hostp->entries; locp != NULL; locp = locp->next)
  751. X        for (filep=locp->entries; filep != NULL; filep=filep->next)
  752. X        saveEntry(fp,filep);
  753. X    fclose(fp);
  754. X    status0("Ready");
  755. X    return(1);
  756. }
  757. X
  758. static void
  759. saveEntry(fp,dbp)
  760. FILE *fp;
  761. DbEntry *dbp;
  762. {
  763. X    VLINK vl;
  764. X    DbEntry *entry;
  765. X
  766. X    /* Sanity check */
  767. X    if ((vl=dbp->vlink) == NULL) {
  768. X    fprintf(stderr,"NULL vlink to save()\n");
  769. X    return;
  770. X    }
  771. X    /* Save the vlink info */
  772. X    fprintf(fp,"LINK %c %s '%s' %s %s %s %s %d %d ", vl->linktype,
  773. X        vl->type, vl->name, vl->hosttype, vl->host, 
  774. X        vl->nametype, vl->filename, vl->version,
  775. X        vl->f_magic_no);
  776. X    /* And the relevant attributes */
  777. X    fprintf(fp,"%d ",dbp->size);
  778. X    fprintf(fp,"%s ",dbp->modes);
  779. X    fprintf(fp,"%s",dbp->gt_date);
  780. #ifdef undef
  781. X    /* When we didn't keep gt_date (now needed for sorting), we used this: */
  782. X    for (ap = vl->lattrib; ap; ap = ap->next)
  783. X    if (strcmp(ap->aname,"LAST-MODIFIED") == 0)
  784. X        fprintf(fp,"%s",ap->value.ascii);
  785. #endif
  786. X    fprintf(fp,"\n");
  787. X    /* Recursively save the sub-entries */
  788. X    for (entry=dbp->entries; entry != NULL; entry=entry->next)
  789. X    saveEntry(fp,entry);
  790. }
  791. X
  792. /*
  793. X * Load browser from FILENAME made by save.
  794. X */
  795. int
  796. load(db,filename)
  797. DbEntry *db;
  798. char *filename;
  799. {
  800. X    FILE *fp;
  801. X    char buf[256];
  802. X    VLINK first_link,last_link,cur_link;
  803. X    PATTRIB cur_at;
  804. X    char l_linktype;
  805. X    char l_name[MAX_DIR_LINESIZE];
  806. X    char l_type[MAX_DIR_LINESIZE];
  807. X    char l_htype[MAX_DIR_LINESIZE];
  808. X    char l_host[MAX_DIR_LINESIZE];
  809. X    char l_ntype[MAX_DIR_LINESIZE];
  810. X    char l_fname[MAX_DIR_LINESIZE];
  811. X    int    tmp;
  812. X
  813. X    if ((fp=fopen(filename,"r")) == NULL) {
  814. X    alert1("Can't open %s for reading",filename);
  815. X    return(0);
  816. X    }
  817. X    status1("Loading from %s...",filename);
  818. X    /* Load the settings */
  819. X    if (fscanf(fp,"archieHost: %s\n",appResources.archieHost) < 1 ||
  820. X    fscanf(fp,"searchType: %s\n",buf) < 1 ||
  821. X    (appResources.searchType=stringToSearchType(buf)) == GfError ||
  822. X    fscanf(fp,"sortType: %s\n",buf) < 1 ||
  823. X    (appResources.sortType=stringToSortType(buf)) == GfError ||
  824. X    fscanf(fp,"niceLevel: %d\n",&(appResources.niceLevel)) < 1 ||
  825. X    fscanf(fp,"maxHits: %d\n",&(appResources.maxHits)) < 1 ||
  826. X    fscanf(fp,"timeout: %d\n",&(appResources.timeout)) < 1 ||
  827. X    fscanf(fp,"retries: %d\n",&(appResources.retries)) < 1) {
  828. X    fclose(fp);
  829. X    alert1("Error in header of file \"%s\"!",filename);
  830. X    return(0);
  831. X    } else {
  832. X    reinitSettings();
  833. X    }
  834. X    /* Load the browser */
  835. X    first_link = last_link = NULL;
  836. X    while (!feof(fp)) {
  837. X    /* Get a new vlink */
  838. X    cur_link = vlalloc();
  839. X    /* Read the vlink fields */
  840. X    tmp = fscanf(fp,"LINK %c %s %s %s %s %s %s %d %d", &l_linktype,
  841. X             l_type, l_name, l_htype, l_host, 
  842. X             l_ntype, l_fname, &(cur_link->version),
  843. X             &(cur_link->f_magic_no));
  844. X    if (tmp != 9) {
  845. X        alert1("Load error in file %s!",filename);
  846. X        vlfree(cur_link);
  847. X        break;
  848. X    }
  849. X    /* Store data in vlink */
  850. X    cur_link->linktype = l_linktype;
  851. X    cur_link->type = stcopyr(l_type,cur_link->type);
  852. X    cur_link->name = stcopyr(unquote(l_name),cur_link->name);
  853. X    cur_link->hosttype = stcopyr(l_htype,cur_link->hosttype);
  854. X    cur_link->host = stcopyr(l_host,cur_link->host);
  855. X    cur_link->nametype = stcopyr(l_ntype,cur_link->nametype);
  856. X    cur_link->filename = stcopyr(l_fname,cur_link->filename);
  857. X    /* Add vlink to chain */
  858. X    if (first_link == NULL) {
  859. X        last_link = first_link = cur_link;
  860. X        cur_link->next = cur_link->previous = NULL;
  861. X    } else {
  862. X        last_link->next = cur_link;
  863. X        cur_link->previous = last_link;
  864. X        cur_link->next = NULL;
  865. X        last_link = cur_link;
  866. X    }
  867. X    /* Read the attributes */
  868. X    tmp = fscanf(fp,"%s %s %s\n",l_name,l_type,l_htype);
  869. X    if (tmp != 3) {
  870. X        alert1("Load error in file %s!",filename);
  871. X        break;
  872. X    }
  873. X    /* Put them in the vlink's attribute list */
  874. X    cur_link->lattrib = cur_at = atalloc();
  875. X    cur_at->aname = stcopyr("SIZE",cur_at->aname);
  876. X    cur_at->avtype = stcopyr("ASCII",cur_at->avtype);
  877. X    cur_at->value.ascii = stcopyr(l_name,cur_at->value.ascii);
  878. X    cur_at->next = atalloc();
  879. X    cur_at->next->previous = cur_at;
  880. X    cur_at = cur_at->next;
  881. X    cur_at->aname = stcopyr("UNIX-MODES",cur_at->aname);
  882. X    cur_at->avtype = stcopyr("ASCII",cur_at->avtype);
  883. X    cur_at->value.ascii = stcopyr(l_type,cur_at->value.ascii);
  884. X    cur_at->next = atalloc();
  885. X    cur_at->next->previous = cur_at;
  886. X    cur_at = cur_at->next;
  887. X    cur_at->aname = stcopyr("LAST-MODIFIED",cur_at->aname);
  888. X    cur_at->avtype = stcopyr("ASCII",cur_at->avtype);
  889. X    cur_at->value.ascii = stcopyr(l_htype,cur_at->value.ascii);
  890. X    }
  891. X    fclose(fp);
  892. X    if (first_link == NULL) {
  893. X    status0("No entries loaded!");
  894. X    return(0);
  895. X    }
  896. X    status0("Parsing...");
  897. X    resetBrowser();
  898. X    clearEntries(db);
  899. X    tmp = parseArchieQueryResults(db,first_link,NULL);
  900. X    displayEntries(db,0);
  901. X    status2("Loaded %d entries from \"%s\"",(char *)tmp,filename);
  902. X    return(1);
  903. }
  904. X
  905. /*    -    -    -    -    -    -    -    -    */
  906. /*
  907. X * Write browser contents to FILENAME. If ONELINE is True, each entry gets
  908. X *    whole line.
  909. X */
  910. int
  911. writeToFile(db,filename,oneline)
  912. DbEntry *db;
  913. char *filename;
  914. int oneline;
  915. {
  916. X    FILE *fp;
  917. X    DbEntry *hostp,*locp,*filep;
  918. X    char *prefix;
  919. X
  920. X    if ((fp=fopen(filename,"w")) == NULL) {
  921. X    alert1("Can't open %s for writing",filename);
  922. X    return(0);
  923. X    }
  924. X    status1("Writing to %s...",filename);
  925. X    if (oneline) {
  926. X    for (hostp=db->entries; hostp != NULL; hostp = hostp->next)
  927. X        for (locp=hostp->entries; locp != NULL; locp = locp->next)
  928. X        for (filep=locp->entries; filep != NULL; filep=filep->next) {
  929. X            prefix = malloc(strlen(hostp->name)+strlen(locp->name)+3);
  930. X            sprintf(prefix,"%s:%s/",hostp->name,locp->name);
  931. X            writeEntry(fp,filep,oneline,prefix);
  932. X            free(prefix);
  933. X        }
  934. X    } else {
  935. X    for (hostp=db->entries; hostp != NULL; hostp = hostp->next) {
  936. X        fprintf(fp,"%s\n",hostp->name);
  937. X        for (locp=hostp->entries; locp != NULL; locp = locp->next) {
  938. X        fprintf(fp,"\t%s\n",locp->name);
  939. X        for (filep=locp->entries; filep != NULL; filep=filep->next)
  940. X            writeEntry(fp,filep,oneline,"");
  941. X        }
  942. X    }
  943. X    }
  944. X    fclose(fp);
  945. X    status0("Ready");
  946. X    return(1);
  947. }
  948. X
  949. static void
  950. writeEntry(fp,filep,oneline,prefix)
  951. FILE *fp;
  952. DbEntry *filep;
  953. int oneline;
  954. char *prefix;
  955. {
  956. X    DbEntry *entry;
  957. X    char *newprefix;
  958. X
  959. X    /* Write this entry */
  960. X    if (oneline) {
  961. X    fprintf(fp,"%s %10d  %12s  %s%s\n",
  962. X        filep->modes,filep->size,filep->date,prefix,filep->name);
  963. X    } else {
  964. X    fprintf(fp,"\t\t%s %10d  %12s  %s%s\n",
  965. X        filep->modes,filep->size,filep->date,prefix,filep->name);
  966. X    }
  967. X    /* Add this entry to the prefix */
  968. X    newprefix = malloc(strlen(prefix)+strlen(filep->name)+2);
  969. X    sprintf(newprefix,"%s%s/",prefix,filep->name);
  970. X    /* Recursively write the sub-entries */
  971. X    for (entry=filep->entries; entry != NULL; entry=entry->next)
  972. X    writeEntry(fp,entry,oneline,newprefix);
  973. X    free(newprefix);
  974. }
  975. SHAR_EOF
  976. chmod 0644 xarchie-2.0.6/saveload.c ||
  977. echo 'restore of xarchie-2.0.6/saveload.c failed'
  978. Wc_c="`wc -c < 'xarchie-2.0.6/saveload.c'`"
  979. test 8181 -eq "$Wc_c" ||
  980.     echo 'xarchie-2.0.6/saveload.c: original size 8181, current size' "$Wc_c"
  981. rm -f _shar_wnt_.tmp
  982. fi
  983. # ============= xarchie-2.0.6/saveload.h ==============
  984. if test -f 'xarchie-2.0.6/saveload.h' -a X"$1" != X"-c"; then
  985.     echo 'x - skipping xarchie-2.0.6/saveload.h (File already exists)'
  986.     rm -f _shar_wnt_.tmp
  987. else
  988. > _shar_wnt_.tmp
  989. echo 'x - extracting xarchie-2.0.6/saveload.h (Text)'
  990. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/saveload.h' &&
  991. /*
  992. X * saveload.h : Device-independent routines for dumping (ie printing),
  993. X *    saving, and restoring state.
  994. X *
  995. X * George Ferguson, ferguson@cs.rochester.edu, 23 Apr 1993.
  996. X */
  997. X
  998. #ifndef SAVELOAD_H
  999. #define SAVELOAD_H
  1000. X
  1001. extern int save(),load(),writeToFile();
  1002. X
  1003. #endif
  1004. SHAR_EOF
  1005. chmod 0644 xarchie-2.0.6/saveload.h ||
  1006. echo 'restore of xarchie-2.0.6/saveload.h failed'
  1007. Wc_c="`wc -c < 'xarchie-2.0.6/saveload.h'`"
  1008. test 261 -eq "$Wc_c" ||
  1009.     echo 'xarchie-2.0.6/saveload.h: original size 261, current size' "$Wc_c"
  1010. rm -f _shar_wnt_.tmp
  1011. fi
  1012. # ============= xarchie-2.0.6/selectdefs.h ==============
  1013. if test -f 'xarchie-2.0.6/selectdefs.h' -a X"$1" != X"-c"; then
  1014.     echo 'x - skipping xarchie-2.0.6/selectdefs.h (File already exists)'
  1015.     rm -f _shar_wnt_.tmp
  1016. else
  1017. > _shar_wnt_.tmp
  1018. echo 'x - extracting xarchie-2.0.6/selectdefs.h (Text)'
  1019. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/selectdefs.h' &&
  1020. /*
  1021. X * selectdefs.h : FD_SET and relatives
  1022. X *
  1023. X * George Ferguson, ferguson@cs.rochester.edu, 23 Apr 1993.
  1024. X *
  1025. X * I don't really expect this to work if none of the include cases
  1026. X * is used. I mean, where's the definition of the fd_set structure,
  1027. X * anyway? However, perhaps it's a start. Better would be to add a case
  1028. X * to the confgure script to find the things no matter where they are.
  1029. X *
  1030. X * 13 May 1993: Fail if none of the macros defined.
  1031. X */
  1032. X
  1033. #include "config.h"
  1034. X
  1035. #include <stdio.h>            /* Some folks need this also */
  1036. X
  1037. #ifdef FD_SET_IN_SYS_TYPES_H            /* normal */
  1038. # include <sys/types.h>
  1039. #else
  1040. #ifdef FD_SET_IN_SYS_SELECT_H
  1041. # include <sys/select.h>            /* _AIX */
  1042. #else
  1043. #ifdef FD_SET_IN_SYS_INET_H
  1044. # include <sys/inet.h>                /* u3b2 */
  1045. #else
  1046. "One of the FD_SET_IN_* macros must be defined in config.h!";
  1047. #endif
  1048. #endif
  1049. #endif
  1050. X
  1051. #ifndef NBBY
  1052. # define NBBY        8                /* bits per byte */
  1053. #endif
  1054. #ifndef NFDBITS
  1055. # define NFDBITS    (sizeof (fd_mask) * NBBY)       /* bits per mask */
  1056. #endif
  1057. #ifndef FD_SETSIZE
  1058. # define FD_SETSIZE    32
  1059. #endif
  1060. #ifndef FD_SET
  1061. # define FD_SET(n,p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  1062. #endif
  1063. #ifndef FD_CLR
  1064. # define FD_CLR(n,p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  1065. #endif
  1066. #ifndef FD_ISSET
  1067. # define FD_ISSET(n,p)    ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  1068. #endif
  1069. #ifndef FD_ZERO
  1070. # define FD_ZERO(p)    bzero((char *)(p), sizeof(*(p)))
  1071. #endif
  1072. SHAR_EOF
  1073. chmod 0644 xarchie-2.0.6/selectdefs.h ||
  1074. echo 'restore of xarchie-2.0.6/selectdefs.h failed'
  1075. Wc_c="`wc -c < 'xarchie-2.0.6/selectdefs.h'`"
  1076. test 1399 -eq "$Wc_c" ||
  1077.     echo 'xarchie-2.0.6/selectdefs.h: original size 1399, current size' "$Wc_c"
  1078. rm -f _shar_wnt_.tmp
  1079. fi
  1080. # ============= xarchie-2.0.6/selection.c ==============
  1081. if test -f 'xarchie-2.0.6/selection.c' -a X"$1" != X"-c"; then
  1082.     echo 'x - skipping xarchie-2.0.6/selection.c (File already exists)'
  1083.     rm -f _shar_wnt_.tmp
  1084. else
  1085. > _shar_wnt_.tmp
  1086. echo 'x - extracting xarchie-2.0.6/selection.c (Text)'
  1087. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/selection.c' &&
  1088. /*
  1089. X * selection.c : Code that the X and Curses browsers use, but that
  1090. X *    others might be able to do without, or do better.
  1091. X *
  1092. X * Note that we need to maintain the selections for those levels
  1093. X * of the browser that aren't displayed right now. Again, you may
  1094. X * get better mileage from your window system.
  1095. X *
  1096. X * George Ferguson, ferguson@cs.rochester.edu, 23 Apr 1993.
  1097. X * 13 May 1993: Store selections in order they're made.
  1098. X */
  1099. #include <stdio.h>
  1100. #include "xtypes.h"
  1101. #include "sysdefs.h"
  1102. #include "db.h"
  1103. #include "display.h"
  1104. #include "browser.h"
  1105. #include "selection.h"
  1106. #include "debug.h"
  1107. X
  1108. /*
  1109. X * Functions defined here:
  1110. X */
  1111. void resetSelections();
  1112. void redrawSelectionsForPane(),resetSelectionsForPane();
  1113. void addSelection(),addSelectionInPane(),removeSelection();
  1114. SelectedItem *getSelection();
  1115. Boolean isSelected(),isSelectedInPane();
  1116. Boolean hasSelection(),hasSelectionInPane();
  1117. void forEachSelectedItemAtDepth(),forEachSelectedItem();
  1118. X
  1119. /*
  1120. X * Data defined here:
  1121. X */
  1122. static SelectedItem *selectedItems[MAX_DEPTH];
  1123. static int deepest;
  1124. X
  1125. /*    -    -    -    -    -    -    -    -    */
  1126. X
  1127. void
  1128. resetSelections(depth)
  1129. int depth;
  1130. {
  1131. X    SelectedItem *item,*nextItem;
  1132. X    int i;
  1133. X
  1134. X    DEBUG1("clearing selections for depth >= %d\n",depth);
  1135. X    for (i=depth; i < MAX_DEPTH; i++) {
  1136. X    for (item=selectedItems[i]; item != NULL; item = nextItem) {
  1137. X        nextItem = item->next;
  1138. X        XtFree((char *)item);
  1139. X    }
  1140. X    selectedItems[i] = NULL;
  1141. X    }
  1142. X    deepest = depth-1;
  1143. X    DEBUG1("deepest now = %d\n",deepest);
  1144. }
  1145. X
  1146. void
  1147. redrawSelectionsForPane(pane)
  1148. int pane;
  1149. {
  1150. X    SelectedItem *item;
  1151. X
  1152. X    DEBUG1("redrawing selections for pane %d\n",pane);
  1153. X    for (item=selectedItems[paneDepth(pane)]; item != NULL;
  1154. X     item=item->next) {
  1155. X    highlightBrowserItem(pane,item->list_index);
  1156. X    }
  1157. }
  1158. X
  1159. void
  1160. resetSelectionsForPane(pane)
  1161. int pane;
  1162. {
  1163. X    DEBUG1("clearing selections for pane %d\n",pane);
  1164. X    resetSelections(paneDepth(pane));
  1165. }
  1166. X
  1167. /*    -    -    -    -    -    -    -    -    */
  1168. X
  1169. void
  1170. addSelection(depth,dbp,list_index)
  1171. int depth;
  1172. DbEntry *dbp;
  1173. int list_index;
  1174. {
  1175. X    SelectedItem *last;
  1176. X
  1177. X    DEBUG3("adding selection \"%s\"(0x%x) at depth %d\n",dbp->name,dbp,depth);
  1178. X    if (selectedItems[depth] == NULL) {
  1179. X    selectedItems[depth] = XtNew(SelectedItem);
  1180. X    selectedItems[depth]->prev = NULL;
  1181. X    selectedItems[depth]->next = NULL;
  1182. X    last = selectedItems[depth];
  1183. X    } else {
  1184. X    for (last=selectedItems[depth]; last->next != NULL; last=last->next)
  1185. X        /*EMPTY*/;
  1186. X    last->next = XtNew(SelectedItem);
  1187. X    last->next->prev = last;
  1188. X    last->next->next = NULL;
  1189. X    last = last->next;
  1190. X    }
  1191. X    last->entry = dbp;
  1192. X    last->list_index = list_index;
  1193. X    dbp->selected = depth;
  1194. X    if (depth > deepest) {
  1195. X    deepest = depth;
  1196. X    DEBUG1("deepest now = %d\n",deepest);
  1197. X    }
  1198. }
  1199. X
  1200. void
  1201. addSelectionInPane(pane,dbp,list_index)
  1202. int pane;
  1203. DbEntry *dbp;
  1204. int list_index;
  1205. {
  1206. X    DEBUG3("adding selection \"%s\"(0x%x) in pane %d\n",dbp->name,dbp,pane);
  1207. X    addSelection(paneDepth(pane),dbp,list_index);
  1208. }
  1209. X
  1210. void
  1211. removeSelection(depth,dbp,list_index)
  1212. int depth;
  1213. DbEntry *dbp;
  1214. int list_index;
  1215. {
  1216. X    SelectedItem *item;
  1217. X
  1218. X    DEBUG3("removing selection \"%s\"(0x%x) at depth %d\n",
  1219. X       (dbp?dbp->name:"<NIL>"),dbp,depth);
  1220. X    for (item=selectedItems[depth]; item != NULL; item = item->next)
  1221. X    if ((dbp == NULL || item->entry == dbp) &&
  1222. X        (list_index == -1  || item->list_index == list_index))
  1223. X        break;
  1224. X    if (item == NULL) {
  1225. X    fprintf(stderr,"removeSelection: Can't find entry 0x%x (list_index=%d) at depth %d\n",dbp,list_index,depth);
  1226. X    return;
  1227. X    }
  1228. X    if (item == selectedItems[depth]) {
  1229. X    selectedItems[depth] = item->next;
  1230. X    if (item->next != NULL)
  1231. X        item->next->prev = NULL;
  1232. X    } else {
  1233. X    item->prev->next = item->next;
  1234. X    if (item->next != NULL)
  1235. X        item->next->prev = item->prev;
  1236. X    }
  1237. X    XtFree((char *)item);
  1238. X    if (selectedItems[depth] == NULL) {
  1239. X    deepest = depth-1;
  1240. X    DEBUG1("deepest now = %d\n",deepest);
  1241. X    }
  1242. }
  1243. X
  1244. SelectedItem *
  1245. getSelection(depth)
  1246. int depth;
  1247. {
  1248. X    return(selectedItems[depth]);
  1249. }
  1250. X
  1251. /*    -    -    -    -    -    -    -    -    */
  1252. X
  1253. Boolean
  1254. isSelected(depth,list_index)
  1255. int depth,list_index;
  1256. {
  1257. X    SelectedItem *item;
  1258. X
  1259. X    for (item=selectedItems[depth];
  1260. X     item != NULL && item->list_index != list_index; item=item->next)
  1261. X    /*EMPTY*/;
  1262. X    return(item != NULL);
  1263. }
  1264. X
  1265. Boolean
  1266. isSelectedInPane(pane,list_index)
  1267. int pane,list_index;
  1268. {
  1269. X    return(isSelected(paneDepth(pane),list_index));
  1270. }
  1271. X
  1272. Boolean
  1273. hasSelection(depth)
  1274. int depth;
  1275. {
  1276. X    return(selectedItems[depth] != NULL);
  1277. }
  1278. X
  1279. Boolean
  1280. hasSelectionInPane(pane)
  1281. int pane;
  1282. {
  1283. X    return(hasSelection(paneDepth(pane)));
  1284. }
  1285. X
  1286. /*    -    -    -    -    -    -    -    -    */
  1287. /*
  1288. X * Calls "func" for each selected item at depth "depth", passing DbEntry
  1289. X * and list_index.
  1290. X */
  1291. void
  1292. forEachSelectedItemAtDepth(depth,func)
  1293. int depth;
  1294. void (*func)();
  1295. {
  1296. X    SelectedItem *item;
  1297. X
  1298. X    for (item=selectedItems[depth]; item != NULL; item=item->next)
  1299. X    (*func)(item->entry,item->list_index);
  1300. }
  1301. X
  1302. /*
  1303. X * Like above, but calls "func" for each item selected at the deepest
  1304. X * level.
  1305. X */
  1306. void
  1307. forEachSelectedItem(func)
  1308. void (*func)();
  1309. {
  1310. X    SelectedItem *item;
  1311. X
  1312. X    if (deepest == -1) {
  1313. X    DEBUG0("forEachSelectedItem: nothing selected\n");
  1314. X       return;
  1315. X    }
  1316. X    for (item=selectedItems[deepest]; item != NULL; item=item->next)
  1317. X    (*func)(item->entry,item->list_index);
  1318. }
  1319. SHAR_EOF
  1320. chmod 0644 xarchie-2.0.6/selection.c ||
  1321. echo 'restore of xarchie-2.0.6/selection.c failed'
  1322. Wc_c="`wc -c < 'xarchie-2.0.6/selection.c'`"
  1323. test 5127 -eq "$Wc_c" ||
  1324.     echo 'xarchie-2.0.6/selection.c: original size 5127, current size' "$Wc_c"
  1325. rm -f _shar_wnt_.tmp
  1326. fi
  1327. # ============= xarchie-2.0.6/selection.h ==============
  1328. if test -f 'xarchie-2.0.6/selection.h' -a X"$1" != X"-c"; then
  1329.     echo 'x - skipping xarchie-2.0.6/selection.h (File already exists)'
  1330.     rm -f _shar_wnt_.tmp
  1331. else
  1332. > _shar_wnt_.tmp
  1333. echo 'x - extracting xarchie-2.0.6/selection.h (Text)'
  1334. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/selection.h' &&
  1335. /*
  1336. X * selection.h : Defs for manipulating items selected in the browser
  1337. X *
  1338. X * George Ferguson, ferguson@cs.rochester.edu, 23 Apr 1993.
  1339. X */
  1340. X
  1341. #ifndef SELECTION_H
  1342. #define SELECTION_H
  1343. X
  1344. #include "db.h"
  1345. X
  1346. typedef struct SelectedItem_s {
  1347. X    DbEntry *entry;
  1348. X    int list_index;
  1349. X    struct SelectedItem_s *next,*prev;
  1350. } SelectedItem;
  1351. X
  1352. extern void resetSelections();
  1353. extern void redrawSelectionsForPane(),resetSelectionsForPane();
  1354. extern void addSelection(),addSelectionInPane(),removeSelection();
  1355. extern SelectedItem *getSelection();
  1356. extern Boolean isSelected(),isSelectedInPane();
  1357. extern Boolean hasSelection(),hasSelectionInPane();
  1358. extern void forEachSelectedItemAtDepth(),forEachSelectedItem();
  1359. X
  1360. #endif
  1361. SHAR_EOF
  1362. chmod 0644 xarchie-2.0.6/selection.h ||
  1363. echo 'restore of xarchie-2.0.6/selection.h failed'
  1364. Wc_c="`wc -c < 'xarchie-2.0.6/selection.h'`"
  1365. test 697 -eq "$Wc_c" ||
  1366.     echo 'xarchie-2.0.6/selection.h: original size 697, current size' "$Wc_c"
  1367. rm -f _shar_wnt_.tmp
  1368. fi
  1369. # ============= xarchie-2.0.6/settings.c ==============
  1370. if test -f 'xarchie-2.0.6/settings.c' -a X"$1" != X"-c"; then
  1371.     echo 'x - skipping xarchie-2.0.6/settings.c (File already exists)'
  1372.     rm -f _shar_wnt_.tmp
  1373. else
  1374. > _shar_wnt_.tmp
  1375. echo 'x - extracting xarchie-2.0.6/settings.c (Text)'
  1376. sed 's/^X//' << 'SHAR_EOF' > 'xarchie-2.0.6/settings.c' &&
  1377. /*
  1378. X * settings.c : Set program parameters on a popup panel
  1379. X *
  1380. X * George Ferguson, ferguson@cs.rochester.edu, 22 Oct 1991.
  1381. X * Version 2.0: 23 Apr 1993.
  1382. X */
  1383. X
  1384. #include <stdio.h>
  1385. #include <X11/Intrinsic.h>
  1386. #include <X11/Shell.h>
  1387. #include <X11/StringDefs.h>
  1388. #include <X11/Xaw/Form.h>
  1389. #include <X11/Xaw/MenuButton.h>
  1390. #include <X11/Xaw/Label.h>
  1391. #include <X11/Xaw/AsciiText.h>
  1392. #include <X11/Xaw/Cardinals.h>
  1393. #include "xarchie.h"
  1394. #include "types.h"
  1395. #include "appres.h"
  1396. #include "m-defs.h"
  1397. #include "rdgram.h"
  1398. #include "alert.h"
  1399. #include "status.h"
  1400. #include "popups.h"
  1401. #include "xutil.h"
  1402. #include "stringdefs.h"
  1403. #include "weight.h"
  1404. #include "tilde.h"
  1405. extern void resortBrowser();        /* browser.c */
  1406. X
  1407. /*
  1408. X * Functions declared in this file
  1409. X */
  1410. void initSettings(),reinitSettings();
  1411. void setSettingsShellState();
  1412. void updateSettingsHost(),updateSettingsSearchType();
  1413. void updateSettingsSortType(),updateSettingsNiceLevel();
  1414. void updateSettingsAutoScroll();
  1415. void updateSettingsFtpType(),updateSettingsFtpPrompt();
  1416. void updateSettingsFtpTrace(),updateSettingsFtpStrip();
  1417. void setSettingsChangedFlag();
  1418. X
  1419. static void initSettingsWidgets();
  1420. static void addTextEventHandler(),textEventProc();
  1421. static void popupSettingsAction();
  1422. static void applySettingsAction(),defaultSettingsAction(),doneSettingsAction();
  1423. static void setHostAction(),setSearchTypeAction();
  1424. static void setSortTypeAction(),setNiceLevelAction();
  1425. static void setHostNowAction(),setSearchTypeNowAction();
  1426. static void setSortTypeNowAction(),setNiceLevelNowAction();
  1427. static int settingsConfirm();
  1428. static void settingsConfirmCallback();
  1429. X
  1430. /*
  1431. X * Data declared in this file
  1432. X */
  1433. static Widget settingsShell;
  1434. static Widget setApplyButton;
  1435. static Widget setHostText;
  1436. static Widget setSearchLabel,setSortLabel;
  1437. static Widget setNiceText,setMaxHitsText;
  1438. static Widget setTimeoutText,setRetriesText;
  1439. static Widget setAutoScrollLabel;
  1440. static Widget ftpLocalDirText,ftpTypeLabel;
  1441. static Widget ftpPromptLabel,ftpTraceLabel,ftpStripLabel;
  1442. static Widget ftpMailAddressText;
  1443. static Widget setHostWeightsLabel,setHostWeightsText;
  1444. X
  1445. static char *defArchieHost;
  1446. static SearchType currentSearchType,defSearchType;
  1447. static SortType currentSortType,defSortType;
  1448. static int defMaxHits,defTimeout,defRetries,defNiceLevel;
  1449. static Boolean currentAutoScroll,defAutoScroll;
  1450. static char *defFtpLocalDir,*defFtpType;
  1451. static Boolean currentFtpPrompt,defFtpPrompt;
  1452. static Boolean currentFtpTrace,defFtpTrace;
  1453. static Boolean currentFtpStrip,defFtpStrip;
  1454. static char *defFtpMailAddress;
  1455. static char *defHostWeights;
  1456. static Boolean settingsChanged,isPoppedUp;
  1457. X
  1458. static XtActionsRec actionTable[] = {
  1459. X    { "popup-settings",        popupSettingsAction },
  1460. X    { "settings-apply",        applySettingsAction },
  1461. X    { "settings-default",    defaultSettingsAction },
  1462. X    { "settings-done",        doneSettingsAction },
  1463. X    { "set-host",        setHostAction },
  1464. X    { "set-host-now",        setHostNowAction },
  1465. X    { "set-search-type",    setSearchTypeAction },
  1466. X    { "set-search-type-now",    setSearchTypeNowAction },
  1467. X    { "set-sort-type",        setSortTypeAction },
  1468. X    { "set-sort-type-now",    setSortTypeNowAction },
  1469. X    { "set-nice-level",        setNiceLevelAction },
  1470. X    { "set-nice-level-now",    setNiceLevelNowAction },
  1471. };
  1472. X
  1473. /*    -    -    -    -    -    -    -    -    */
  1474. /*
  1475. X * initSettings() : Stores away the values of the application resources
  1476. X *    at startup for use by the default-settings() action. Also
  1477. X *    create the settings panel and register the action procedures.
  1478. X */
  1479. void
  1480. initSettings()
  1481. {
  1482. X    defArchieHost = XtNewString(appResources.archieHost);
  1483. X    defSearchType = appResources.searchType;
  1484. X    defSortType = appResources.sortType;
  1485. X    defNiceLevel = appResources.niceLevel;
  1486. X    defMaxHits = appResources.maxHits;
  1487. X    defTimeout = appResources.timeout;
  1488. X    defRetries = appResources.retries;
  1489. X    defAutoScroll = appResources.autoScroll;
  1490. X    defFtpLocalDir = XtNewString(appResources.ftpLocalDir);
  1491. X    defFtpType = XtNewString(appResources.ftpType);
  1492. X    defFtpPrompt = appResources.ftpPrompt;
  1493. X    defFtpTrace = appResources.ftpTrace;
  1494. X    defFtpStrip = appResources.ftpStrip;
  1495. X    defFtpMailAddress = XtNewString(appResources.ftpMailAddress);
  1496. X    defHostWeights = XtNewString(appResources.hostWeights);
  1497. X    isPoppedUp = False;
  1498. X    XtAppAddActions(appContext,actionTable,XtNumber(actionTable));
  1499. X    initSettingsWidgets();
  1500. }
  1501. X
  1502. /*
  1503. X * reinitSettings() : Sets the values in the settings editor from the
  1504. X *    current state of the application resources.
  1505. X */
  1506. void
  1507. reinitSettings()
  1508. {
  1509. X    char buf[16];
  1510. X    static int firsttime = 1;
  1511. X
  1512. X    setWidgetString(setHostText,appResources.archieHost);
  1513. X    updateSettingsSearchType(appResources.searchType);
  1514. X    updateSettingsSortType(appResources.sortType);
  1515. X    sprintf(buf,"%d",appResources.niceLevel);
  1516. X    setWidgetString(setNiceText,buf);
  1517. X    sprintf(buf,"%d",appResources.maxHits);
  1518. X    setWidgetString(setMaxHitsText,buf);
  1519. X    sprintf(buf,"%d",appResources.timeout);
  1520. X    setWidgetString(setTimeoutText,buf);
  1521. X    sprintf(buf,"%d",appResources.retries);
  1522. X    setWidgetString(setRetriesText,buf);
  1523. X    updateSettingsAutoScroll(appResources.autoScroll);
  1524. X    /* Kludge to prevent tilde from being expanded in the Text item */
  1525. X    if (firsttime) {
  1526. X    setWidgetString(ftpLocalDirText,appResources.ftpLocalDir);
  1527. X    firsttime = 0;
  1528. X    }
  1529. X    updateSettingsFtpType(appResources.ftpType);
  1530. X    updateSettingsFtpPrompt(appResources.ftpPrompt);
  1531. X    updateSettingsFtpTrace(appResources.ftpTrace);
  1532. X    updateSettingsFtpStrip(appResources.ftpStrip);
  1533. X    setWidgetString(ftpMailAddressText,appResources.ftpMailAddress);
  1534. X    setWidgetString(setHostWeightsText,appResources.hostWeights);
  1535. X    setSettingsChangedFlag(False);
  1536. X    updateSettingsMenuMarks();
  1537. }
  1538. X
  1539. /*
  1540. X * initSettingsWidgets() : Create the popup settings editor.
  1541. X */
  1542. static void
  1543. initSettingsWidgets()
  1544. {
  1545. X    Widget form;
  1546. X
  1547. X    settingsShell = XtCreatePopupShell("settingsShell",
  1548. X                       topLevelShellWidgetClass,toplevel,
  1549. X                       NULL,0);
  1550. X    form = XtCreateManagedWidget("settingsForm",formWidgetClass,
  1551. X                 settingsShell,NULL,0);
  1552. X    (void) XtCreateManagedWidget("setDoneButton",commandWidgetClass,
  1553. X                 form,NULL,0);
  1554. X    setApplyButton = XtCreateManagedWidget("setApplyButton",commandWidgetClass,
  1555. X                       form,NULL,0);
  1556. X    (void)XtCreateManagedWidget("setDefaultButton",commandWidgetClass,
  1557. X                form,NULL,0);
  1558. X    (void)XtCreateManagedWidget("setHostButton",menuButtonWidgetClass,
  1559. X                form,NULL,0);
  1560. X    setHostText = XtCreateManagedWidget("setHostText",asciiTextWidgetClass,
  1561. X                    form,NULL,0);
  1562. X    (void)XtCreateManagedWidget("setSearchButton",menuButtonWidgetClass,
  1563. X                form,NULL,0);
  1564. X    setSearchLabel = XtCreateManagedWidget("setSearchLabel",labelWidgetClass,
  1565. X                       form,NULL,0);
  1566. X    (void)XtCreateManagedWidget("setSortButton",menuButtonWidgetClass,
  1567. X                form,NULL,0);
  1568. X    setSortLabel = XtCreateManagedWidget("setSortLabel",labelWidgetClass,
  1569. X                     form,NULL,0);
  1570. X    (void)XtCreateManagedWidget("setNiceButton",menuButtonWidgetClass,
  1571. X                form,NULL,0);
  1572. X    setNiceText = XtCreateManagedWidget("setNiceText",asciiTextWidgetClass,
  1573. X                    form,NULL,0);
  1574. X    (void)XtCreateManagedWidget("setMaxHitsLabel",labelWidgetClass,
  1575. X                form,NULL,0);
  1576. X    setMaxHitsText = XtCreateManagedWidget("setMaxHitsText",
  1577. X                       asciiTextWidgetClass,
  1578. X                       form,NULL,0);
  1579. X    (void)XtCreateManagedWidget("setTimeoutLabel",labelWidgetClass,
  1580. X                form,NULL,0);
  1581. X    setTimeoutText = XtCreateManagedWidget("setTimeoutText",
  1582. X                       asciiTextWidgetClass,
  1583. X                       form,NULL,0);
  1584. X    (void)XtCreateManagedWidget("setRetriesLabel",labelWidgetClass,
  1585. X                form,NULL,0);
  1586. X    setRetriesText = XtCreateManagedWidget("setRetriesText",
  1587. X                       asciiTextWidgetClass,
  1588. X                       form,NULL,0);
  1589. X    (void)XtCreateManagedWidget("setAutoScrollButton",menuButtonWidgetClass,
  1590. X                form,NULL,0);
  1591. X    setAutoScrollLabel = XtCreateManagedWidget("setAutoScrollLabel",
  1592. X                           labelWidgetClass,
  1593. X                           form,NULL,0);
  1594. X    (void)XtCreateManagedWidget("ftpMailAddressLabel",labelWidgetClass,
  1595. X                form,NULL,0);
  1596. X    ftpMailAddressText = XtCreateManagedWidget("ftpMailAddressText",
  1597. X                           asciiTextWidgetClass,
  1598. X                           form,NULL,0);
  1599. X    (void)XtCreateManagedWidget("ftpLocalDirLabel",labelWidgetClass,
  1600. X                form,NULL,0);
  1601. X    ftpLocalDirText = XtCreateManagedWidget("ftpLocalDirText",
  1602. X                        asciiTextWidgetClass,
  1603. X                        form,NULL,0);
  1604. X    (void)XtCreateManagedWidget("ftpTypeButton",menuButtonWidgetClass,
  1605. X                form,NULL,0);
  1606. X    ftpTypeLabel = XtCreateManagedWidget("ftpTypeLabel",labelWidgetClass,
  1607. X                     form,NULL,0);
  1608. X    (void)XtCreateManagedWidget("ftpPromptButton",menuButtonWidgetClass,
  1609. X                form,NULL,0);
  1610. X    ftpPromptLabel = XtCreateManagedWidget("ftpPromptLabel",labelWidgetClass,
  1611. X                       form,NULL,0);
  1612. X    (void)XtCreateManagedWidget("ftpTraceButton",menuButtonWidgetClass,
  1613. X                form,NULL,0);
  1614. X    ftpTraceLabel = XtCreateManagedWidget("ftpTraceLabel",labelWidgetClass,
  1615. X                       form,NULL,0);
  1616. X    (void)XtCreateManagedWidget("ftpStripButton",menuButtonWidgetClass,
  1617. X                form,NULL,0);
  1618. X    ftpStripLabel = XtCreateManagedWidget("ftpStripLabel",labelWidgetClass,
  1619. X                       form,NULL,0);
  1620. X    setHostWeightsLabel = XtCreateManagedWidget("setHostWeightsLabel",
  1621. X                        labelWidgetClass,
  1622. X                        form,NULL,0);
  1623. X    setHostWeightsText = XtCreateManagedWidget("setHostWeightsText",
  1624. X                           asciiTextWidgetClass,
  1625. X                           form,NULL,0);
  1626. X    /* Add event handler for detecting changes */
  1627. X    addTextEventHandler(setHostText);
  1628. X    addTextEventHandler(setMaxHitsText);
  1629. X    addTextEventHandler(setTimeoutText);
  1630. X    addTextEventHandler(setRetriesText);
  1631. X    addTextEventHandler(setNiceText);
  1632. X    addTextEventHandler(setHostWeightsText);
  1633. X    addTextEventHandler(ftpMailAddressText);
  1634. X    addTextEventHandler(ftpLocalDirText);
  1635. X    XtRealizeWidget(settingsShell);
  1636. X    /* Enable WM_DELETE_WINDOW handling */
  1637. X    (void)XSetWMProtocols(XtDisplay(settingsShell),XtWindow(settingsShell),
  1638. X              &WM_DELETE_WINDOW,1);
  1639. }
  1640. X
  1641. static void
  1642. addTextEventHandler(w)
  1643. Widget w;
  1644. {
  1645. X    if (w != NULL)
  1646. X    XtAddEventHandler(w,KeyPressMask|ButtonPressMask,False,
  1647. X              textEventProc,(XtPointer)NULL);
  1648. }
  1649. X
  1650. void
  1651. setSettingsShellState(state)
  1652. int state;
  1653. {
  1654. X    if (!isPoppedUp)
  1655. X    return;
  1656. X    switch (state) {
  1657. X    case NormalState:
  1658. X        XtMapWidget(settingsShell);
  1659. X        break;
  1660. X    case IconicState:
  1661. X        XtUnmapWidget(settingsShell);
  1662. X        break;
  1663. X    }
  1664. }
  1665. X
  1666. /*    -    -    -    -    -    -    -    -    */
  1667. /* Action procedures */
  1668. X
  1669. #define ACTION_PROC(NAME)    void NAME(w,event,params,num_params) \
  1670. X                    Widget w; \
  1671. X                    XEvent *event; \
  1672. X                    String *params; \
  1673. X                    Cardinal *num_params;
  1674. X
  1675. /*
  1676. X * popupSettingsAction() : Pops up the settings editor, and fills it with
  1677. X *    the information from the current values of the application settings.
  1678. X */
  1679. /*ARGSUSED*/
  1680. static
  1681. ACTION_PROC(popupSettingsAction)
  1682. {
  1683. X    if (isPoppedUp) {
  1684. X    XRaiseWindow(display,XtWindow(settingsShell));
  1685. X    } else {
  1686. X    reinitSettings();
  1687. X    XtPopup(settingsShell,XtGrabNone);
  1688. X    isPoppedUp = True;
  1689. X    }
  1690. }
  1691. X
  1692. /*
  1693. X * applySettingsAction() : Callback for apply button - Set the application
  1694. X *    resources from the items on the settings editor panel. Some of these
  1695. X *    require special action when changed, and this routine does that.
  1696. X */
  1697. /*ARGSUSED*/
  1698. static
  1699. ACTION_PROC(applySettingsAction)
  1700. {
  1701. X    char *s;
  1702. X    int n;
  1703. X
  1704. X    /* Host */
  1705. X    s = getWidgetString(setHostText);
  1706. X    if (strcmp(appResources.archieHost,s) != 0) {
  1707. X    XtFree(appResources.archieHost);
  1708. X    appResources.archieHost = XtNewString(s);
  1709. X    setHostMenuMark(appResources.archieHost);
  1710. X    }
  1711. X    /* Search type */
  1712. X    if (appResources.searchType != currentSearchType) {
  1713. X    appResources.searchType = currentSearchType;
  1714. X    setSearchMenuMark(appResources.searchType);
  1715. X    }
  1716. X    /* Sort type */
  1717. X    if (appResources.sortType != currentSortType) {
  1718. X    appResources.sortType = currentSortType;
  1719. X    setSortMenuMark(appResources.searchType);
  1720. X    resortBrowser();
  1721. X    }
  1722. X    /* Nice level */
  1723. X    s = getWidgetString(setNiceText);
  1724. X    n = atoi(s);
  1725. X    if (n < RDGRAM_MIN_PRI)        /* leave -32766 to -32768 alone */
  1726. X    n = RDGRAM_MIN_PRI;
  1727. X    else if (n > RDGRAM_MAX_SPRI)
  1728. X    n = RDGRAM_MAX_PRI;
  1729. X    if (appResources.niceLevel != n) {
  1730. X    appResources.niceLevel = n;
  1731. X    setNiceMenuMark(appResources.niceLevel);
  1732. X    }
  1733. X    /* Max hits */
  1734. X    s = getWidgetString(setMaxHitsText);
  1735. X    appResources.maxHits = atoi(s);
  1736. X    /* Timeout */
  1737. X    s = getWidgetString(setTimeoutText);
  1738. X    appResources.timeout = atoi(s);
  1739. X    /* Retries */
  1740. X    s = getWidgetString(setRetriesText);
  1741. X    appResources.retries = atoi(s);
  1742. X    /* Auto Scroll */
  1743. X    appResources.autoScroll = currentAutoScroll;
  1744. X    /* Ftp mail address */
  1745. X    s = getWidgetString(ftpMailAddressText);
  1746. X    if (strcmp(appResources.ftpMailAddress,s) != 0) {
  1747. X    XtFree(appResources.ftpMailAddress);
  1748. X    appResources.ftpMailAddress = XtNewString(s);
  1749. X    }
  1750. X    /* Ftp local dir */
  1751. X    s = getWidgetString(ftpLocalDirText);
  1752. X    s = tildeExpand(s);
  1753. X    if (strcmp(appResources.ftpLocalDir,s) != 0) {
  1754. X    XtFree(appResources.ftpLocalDir);
  1755. X    appResources.ftpLocalDir = XtNewString(s);
  1756. X    }
  1757. X    /* Ftp type (uses Label not Text) */
  1758. X    s = getWidgetLabel(ftpTypeLabel);
  1759. X    if (strcmp(appResources.ftpType,s) != 0) {
  1760. X    XtFree(appResources.ftpType);
  1761. X    appResources.ftpType = XtNewString(s);
  1762. X    }
  1763. X    /* Ftp prompt */
  1764. X    appResources.ftpPrompt = currentFtpPrompt;
  1765. X    /* Ftp trace */
  1766. X    appResources.ftpTrace = currentFtpTrace;
  1767. X    /* Ftp strip */
  1768. X    appResources.ftpStrip = currentFtpStrip;
  1769. X    /* Host Weights */
  1770. X    s = getWidgetString(setHostWeightsText);
  1771. X    if (strcmp(appResources.hostWeights,s) != 0) {
  1772. X    XtFree(appResources.hostWeights);
  1773. X    appResources.hostWeights = XtNewString(s);
  1774. X    reinitHostWeights();
  1775. X    resortBrowser();
  1776. X    }
  1777. X    /* All done */
  1778. X    setSettingsChangedFlag(False);
  1779. }
  1780. X
  1781. /*
  1782. X * defaultSettingsAction() : Callback for default button - Reset the items
  1783. X *      to their default values.
  1784. X */
  1785. /*ARGSUSED*/
  1786. static
  1787. ACTION_PROC(defaultSettingsAction)
  1788. {
  1789. X    char buf[16];
  1790. X
  1791. X    setWidgetString(setHostText,defArchieHost);
  1792. X    updateSettingsSearchType(defSearchType);
  1793. X    updateSettingsSortType(defSortType);
  1794. X    sprintf(buf,"%d",defNiceLevel);
  1795. X    setWidgetString(setNiceText,buf);
  1796. X    sprintf(buf,"%d",defMaxHits);
  1797. X    setWidgetString(setMaxHitsText,buf);
  1798. X    sprintf(buf,"%d",defTimeout);
  1799. X    setWidgetString(setTimeoutText,buf);
  1800. X    sprintf(buf,"%d",defRetries);
  1801. X    setWidgetString(setRetriesText,buf);
  1802. X    updateSettingsAutoScroll(defAutoScroll);
  1803. X    setWidgetString(ftpMailAddressText,defFtpMailAddress);
  1804. X    setWidgetString(ftpLocalDirText,defFtpLocalDir);
  1805. X    updateSettingsFtpType(defFtpType);
  1806. X    updateSettingsFtpPrompt(defFtpPrompt);
  1807. X    updateSettingsFtpTrace(defFtpTrace);
  1808. X    updateSettingsFtpStrip(defFtpStrip);
  1809. X    setWidgetString(setHostWeightsText,defHostWeights);
  1810. X    setSettingsChangedFlag(True);
  1811. }
  1812. X
  1813. /*
  1814. X * doneSettingsAction() : Callback for done button - Pop down the editor.
  1815. X */
  1816. /*ARGSUSED*/
  1817. static
  1818. ACTION_PROC(doneSettingsAction)
  1819. {
  1820. X    if (!settingsChanged || settingsConfirm()) {
  1821. X    XtPopdown(settingsShell);
  1822. X    isPoppedUp = False;
  1823. X    }
  1824. }
  1825. X
  1826. /*    -    -    -    -    -    -    -    -    */
  1827. /*
  1828. X * setHostAction() : Action procedure to set the host.
  1829. X */
  1830. /*ARGSUSED*/
  1831. static
  1832. ACTION_PROC(setHostAction)
  1833. {
  1834. X    if (*num_params != 1) {
  1835. X    alert0("Incorrect number of arguments to set-host()");
  1836. X    return;
  1837. X    }
  1838. X    if (setHostText == NULL) {
  1839. X    alert0("set-host() has no effect since setHostText was not created");
  1840. X    return;
  1841. X    }
  1842. X    setWidgetString(setHostText,*params);
  1843. X    setSettingsChangedFlag(True);
  1844. }
  1845. X
  1846. /*
  1847. X * setSearchTypeAction() : Action procedure to set the search type.
  1848. X */
  1849. /*ARGSUSED*/
  1850. static
  1851. ACTION_PROC(setSearchTypeAction)
  1852. {
  1853. X    XrmValue from,to;
  1854. X
  1855. X    if (*num_params != 1) {
  1856. X    alert0("Incorrect number of arguments to set-search-type()");
  1857. X    return;
  1858. X    }
  1859. X    from.addr = *params;
  1860. X    from.size = sizeof(String);
  1861. X    to.addr = NULL;
  1862. X    XtConvertAndStore(w,XtRString,&from,GfRSearchType,&to);
  1863. X    if (to.addr != NULL)
  1864. X    updateSettingsSearchType((SearchType)(*(to.addr)));
  1865. X    setSettingsChangedFlag(True);
  1866. }
  1867. X
  1868. /*
  1869. X * setSortTypeAction() : Action procedure to set the sort type.
  1870. X */
  1871. /*ARGSUSED*/
  1872. static
  1873. ACTION_PROC(setSortTypeAction)
  1874. {
  1875. X    XrmValue from,to;
  1876. SHAR_EOF
  1877. true || echo 'restore of xarchie-2.0.6/settings.c failed'
  1878. fi
  1879. echo 'End of xarchie-2.0.6 part 14'
  1880. echo 'File xarchie-2.0.6/settings.c is continued in part 15'
  1881. echo 15 > _shar_seq_.tmp
  1882. exit 0
  1883.  
  1884. exit 0 # Just in case...
  1885. -- 
  1886.   // chris@IMD.Sterling.COM       | Send comp.sources.x submissions to:
  1887. \X/  Amiga - The only way to fly! |    sources-x@imd.sterling.com
  1888.  "It's intuitively obvious to the |
  1889.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1890.