home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / de / comp / sources / os9 / 9 < prev    next >
Encoding:
Internet Message Format  |  1992-12-23  |  42.9 KB

  1. Xref: sparky de.comp.sources.os9:9 comp.os.os9:1551
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!news2me.EBay.Sun.COM!seven-up.East.Sun.COM!sungy!stasys!stasys!not-for-mail
  3. From: frank.kaefer@stasys.sta.sub.org (Frank Kaefer)
  4. Newsgroups: de.comp.sources.os9,comp.os.os9
  5. Subject: MNews Prerelease Part04/09
  6. Message-ID: <1hafdcINNpt1@stasys.sta.sub.org>
  7. Date: 23 Dec 92 19:41:32 GMT
  8. Sender: news@stasys.sta.sub.org
  9. Followup-To: de.comp.sources.d
  10. Organization: Stasys News Server, Starnberg, Germany
  11. Lines: 2043
  12. Approved: frank.kaefer@stasys.sta.sub.org (Frank Kaefer)
  13. NNTP-Posting-Host: stasys.sta.sub.org
  14.  
  15. Submitted-by: Ulrich Dessauer <ud@Nightmare.ddt.sub.org>
  16. Archive-name: mnews/part04
  17.  
  18. : ----- Cut here ----- Cut here ----- Cut here ----- Cut here -----
  19. : Use  sh filename  to extract shell archive
  20. : This shell archive contains following files:
  21. :     'INEWS/inrd.c                                 1557 bytes'
  22. :     'INEWS/limit.c                                1752 bytes'
  23. :     'INEWS/list.c                                 1183 bytes'
  24. :     'INEWS/mail.c                                 1947 bytes'
  25. :     'INEWS/makh.c                                 2443 bytes'
  26. :     'INEWS/mcan.c                                 2482 bytes'
  27. :     'INEWS/mhead.c                                1363 bytes'
  28. :     'INEWS/mid.c                                  3093 bytes'
  29. :     'INEWS/misc.c                                 5154 bytes'
  30. :     'INEWS/mit.c                                   314 bytes'
  31. :     'INEWS/oart.c                                 1037 bytes'
  32. :     'INEWS/ohist.c                                3849 bytes'
  33. :     'INEWS/pargs.c                                6543 bytes'
  34. :     'INEWS/pit.c                                  1246 bytes'
  35. :     'INEWS/pmail.c                                2650 bytes'
  36. if test -f 'INEWS/inrd.c' ; then
  37.   echo 'File INEWS/inrd.c already exists, overwriting it'
  38.   del 'INEWS/inrd.c'
  39. fi
  40. echo Extracting \"'INEWS/inrd.c'\"
  41. sed "s/^X//" >'INEWS/inrd.c' <<'__END__OF__THIS__FILE__'
  42. X/*
  43. X * $Log:    inrd.c_v $
  44. X * Revision 1.2  91/05/22  13:04:04  ud
  45. X * Added flag driven character conversation
  46. X * 
  47. X * Revision 1.1  90/08/31  15:34:22  cs
  48. X * Initial revision
  49. X * 
  50. X */
  51. X# ifndef    LINT
  52. Xstatic char rcsid[] = "$Id: inrd.c_v 1.2 91/05/22 13:04:04 ud Exp $";
  53. X# endif        LINT
  54. X# include    "inews.h"
  55. X
  56. Xint
  57. Xreadin (fd, buf, len)
  58. Xregister int fd;
  59. Xregister char *buf;
  60. Xregister int len;
  61. X{
  62. X    register int    n, siz;
  63. X    register char    *ptr;
  64. X
  65. X    ptr = buf;
  66. X    siz = 0;
  67. X    while ((n = readln (fd, ptr, len)) > 0) {
  68. X        siz += n;
  69. X        len -= n;
  70. X        if (catlines && (n > 1) && (ptr[n-2] == '\\') && (ptr[n-1] == '\n')) {
  71. X            ptr += (n - 2);
  72. X            len += 2;
  73. X            siz -= 2;
  74. X        } else if ((ptr[n-1] == '\n') || (len <= 0))
  75. X            break;
  76. X        else
  77. X            ptr += n;
  78. X    }
  79. X    if (conv_it && doconv && (siz > 0))
  80. X        conv_charset (buf, siz);
  81. X    return (siz);
  82. X}
  83. X
  84. Xchar *
  85. Xreadbuf (fd, len)
  86. Xregister int fd;
  87. Xregister int *len;
  88. X{
  89. X    static char    *buf = NULL;
  90. X    static int    size = 0;
  91. X    register char    *ptr;
  92. X    register int    n, siz;
  93. X
  94. X    siz = 0;
  95. X    ptr = buf;
  96. X    do {
  97. X        if (siz >= size) {
  98. X            size += 256;
  99. X            if (! (buf = realloc (buf, size + 8))) {
  100. X                size = 0;
  101. X                return (NULL);
  102. X            }
  103. X            ptr = buf + siz;
  104. X        }
  105. X        if ((n = readln (fd, ptr, size - siz)) > 0) {
  106. X            ptr += n;
  107. X            siz += n;
  108. X            if (*(ptr - 1) == '\n') {
  109. X                if (catlines && (n + siz > 1) && (*(ptr - 2) == '\\')) {
  110. X                    ptr -= 2;
  111. X                    n -= 2;
  112. X                    siz -= 2;
  113. X                } else
  114. X                    break;
  115. X            }
  116. X        } else {
  117. X            *ptr = '\0';
  118. X            break;
  119. X        }
  120. X    } while (1);
  121. X    if (len)
  122. X        *len = siz;
  123. X    if (siz) {
  124. X        *ptr = '\0';
  125. X        if (conv_it && doconv)
  126. X            conv_charset (buf, siz);
  127. X        return (buf);
  128. X    } else
  129. X        return (NULL);
  130. X}
  131. __END__OF__THIS__FILE__
  132. if test -f 'INEWS/limit.c' ; then
  133.   echo 'File INEWS/limit.c already exists, overwriting it'
  134.   del 'INEWS/limit.c'
  135. fi
  136. echo Extracting \"'INEWS/limit.c'\"
  137. sed "s/^X//" >'INEWS/limit.c' <<'__END__OF__THIS__FILE__'
  138. X/*
  139. X * $Log:    limit.c_v $
  140. X * Revision 1.1  90/08/31  15:34:26  cs
  141. X * Initial revision
  142. X * 
  143. X */
  144. X# ifndef    LINT
  145. Xstatic char rcsid[] = "$Id: limit.c_v 1.1 90/08/31 15:34:26 cs Exp $";
  146. X# endif        LINT
  147. X# include    <modes.h>
  148. X# include    "inews.h"
  149. X
  150. Xextern char    *malloc ();
  151. Xextern char    *strdup ();
  152. X
  153. Xcharc *
  154. Xget_limit_newsgroups ()
  155. X{
  156. X    register int    fd;
  157. X    register char    *buf;
  158. X    int        n;
  159. X    charc        *tmp, *lhead, *lprev;
  160. X    char        *prefix;
  161. X    char        *ptmp, *ctmp;
  162. X
  163. X    lhead = NULL;
  164. X    lprev = NULL;
  165. X    if ((fd = open (CHK_FILE, S_IREAD)) < 0)
  166. X        return (NULL);
  167. X    catlines = TRUE;
  168. X    while (buf = readbuf (fd, & n)) {
  169. X        if ((n == 1) || (buf[0] == '#'))
  170. X            continue;
  171. X        buf[n - 1] = '\0';
  172. X        prefix = skipc (buf, '\0');
  173. X        if (!dists) {
  174. X            if (Stricmp (buf, DST_WORLD))
  175. X                continue;
  176. X        } else {
  177. X            tmp = dists;
  178. X            while (tmp)
  179. X                if (Strieql (tmp->text, buf))
  180. X                    break;
  181. X                else
  182. X                    tmp = tmp->next;
  183. X            if (!tmp)
  184. X                continue;
  185. X        }
  186. X        ptmp = prefix;
  187. X        while (ctmp = skipc (ptmp, ',')) {
  188. X            tmp = lhead;
  189. X            while (tmp)
  190. X                if (Strieql (tmp->text, ptmp))
  191. X                    break;
  192. X                else
  193. X                    tmp = tmp->next;
  194. X            if ((!tmp) && (tmp = (charc *) malloc (sizeof (charc))))
  195. X                if (tmp->text = strdup (ptmp)) {
  196. X                    tmp->next = NULL;
  197. X                    if (!lprev)
  198. X                        lhead = tmp;
  199. X                    else
  200. X                        lprev->next = tmp;
  201. X                    lprev = tmp;
  202. X                } else
  203. X                    free ((char *) tmp);
  204. X            if (!ctmp[0])
  205. X                break;
  206. X            ptmp = ctmp;
  207. X        }
  208. X    }
  209. X    catlines = FALSE;
  210. X    close (fd);
  211. X    return (lhead);
  212. X}
  213. X
  214. Xint
  215. Xcheck_limit (lm, s)
  216. Xregister charc *lm;
  217. Xregister char *s;
  218. X{
  219. X    if (!lm)
  220. X        return (TRUE);
  221. X    while (lm) {
  222. X        if (lm -> text[0] == '!') {
  223. X            if (_cmpnam (s, lm -> text + 1, strlen (lm -> text + 1)) == 0) {
  224. X                lm = NULL;
  225. X                break;
  226. X            }
  227. X        } else if (_cmpnam (s, lm->text, strlen (lm->text)) == 0)
  228. X            break;
  229. X        lm = lm->next;
  230. X    }
  231. X    return (lm ? TRUE : FALSE);
  232. X}
  233. __END__OF__THIS__FILE__
  234. if test -f 'INEWS/list.c' ; then
  235.   echo 'File INEWS/list.c already exists, overwriting it'
  236.   del 'INEWS/list.c'
  237. fi
  238. echo Extracting \"'INEWS/list.c'\"
  239. sed "s/^X//" >'INEWS/list.c' <<'__END__OF__THIS__FILE__'
  240. X/*
  241. X * $Log:    list.c_v $
  242. X * Revision 1.1  91/05/22  13:35:52  ud
  243. X * Initial revision
  244. X * 
  245. X * 
  246. X */
  247. X# ifndef    LINT
  248. Xstatic char rcsid[] = "$Id: list.c_v 1.1 91/05/22 13:35:52 ud Exp $";
  249. X# endif        LINT
  250. X# include    <stdio.h>
  251. X# include    "inews.h"
  252. X
  253. X# ifdef        IN_MEMORY
  254. Xvoid
  255. Xadd_list (l, s, n)
  256. Xlist **l;
  257. Xchar *s;
  258. Xint n;
  259. X{
  260. X    list        *tmp;
  261. X    register list    *run;
  262. X
  263. X    if (tmp = (list *) malloc (sizeof (list)))
  264. X        if (tmp->text = malloc (n + 2)) {
  265. X            strncpy (tmp->text, s, n);
  266. X            tmp->text[n] = '\0';
  267. X            tmp->len =
  268. X            tmp->siz = n;
  269. X            tmp->next = NULL;
  270. X            if (!*l)
  271. X                *l = tmp;
  272. X            else {
  273. X                for (run = *l; run->next; run = run->next)
  274. X                    ;
  275. X                run->next = tmp;
  276. X            }
  277. X        } else {
  278. X            free ((char *) tmp);
  279. X            tmp = NULL;
  280. X        }
  281. X    if (! tmp) {
  282. X        do_log ("Out of memory in add_list ()\n");
  283. X        do_exit (1);
  284. X    }
  285. X}
  286. X
  287. Xvoid
  288. Xfree_list (l)
  289. Xregister list *l;
  290. X{
  291. X    register list    *tmp;
  292. X
  293. X    while (l) {
  294. X        tmp = l;
  295. X        l = l->next;
  296. X        free (tmp->text);
  297. X        free ((char *) tmp);
  298. X    }
  299. X}
  300. X
  301. Xlist *
  302. Xget_file (fn)
  303. Xchar *fn;
  304. X{
  305. X    FILE    *fp;
  306. X    char    buf[256];
  307. X    int    n;
  308. X    list    *l;
  309. X
  310. X    if (! (fp = fopen (fn, "r")))
  311. X        return (NULL);
  312. X    l = NULL;
  313. X    while (fgets (buf, 256, fp))
  314. X        add_list (&l, buf, strlen (buf));
  315. X    fclose (fp);
  316. X    return (l);
  317. X}
  318. X# endif        /* IN_MEMORY */
  319. __END__OF__THIS__FILE__
  320. if test -f 'INEWS/mail.c' ; then
  321.   echo 'File INEWS/mail.c already exists, overwriting it'
  322.   del 'INEWS/mail.c'
  323. fi
  324. echo Extracting \"'INEWS/mail.c'\"
  325. sed "s/^X//" >'INEWS/mail.c' <<'__END__OF__THIS__FILE__'
  326. X/*
  327. X * $Log:    mail.c_v $
  328. X * Revision 1.3  91/05/22  13:18:02  ud
  329. X * Added in memory option
  330. X * 
  331. X * Revision 1.2  90/12/01  15:48:39  ud
  332. X * A new switch had been added to allow sending a copy of a mail
  333. X * to the local postmaster
  334. X * 
  335. X * Revision 1.1  90/08/31  15:34:29  cs
  336. X * Initial revision
  337. X * 
  338. X */
  339. X# ifndef    LINT
  340. Xstatic char rcsid[] = "$Id: mail.c_v 1.3 91/05/22 13:18:02 ud Exp $";
  341. X# endif        LINT
  342. X# include    <stdio.h>
  343. X# include    "inews.h"
  344. X
  345. Xextern char    *malloc ();
  346. Xextern FILE    *xpopen ();
  347. X
  348. Xvoid
  349. Xmail_to (to, reply_to, subj, subjv, fn, comment)
  350. Xchar *to, *reply_to, *subj, *subjv;
  351. X# ifndef    IN_MEMORY
  352. Xchar *fn;
  353. X# else        /* IN_MEMORY */
  354. Xlist *fn;
  355. X# endif        /* IN_MEMORY */
  356. Xchar **comment;
  357. X{
  358. X    FILE    *pp;
  359. X# ifndef    IN_MEMORY
  360. X    FILE    *fp;
  361. X# else        /* IN_MEMORY */
  362. X    list    *ltmp;
  363. X# endif        /* IN_MEMORY */
  364. X    char    buf[80];
  365. X    char    *cmd;
  366. X    int    t;
  367. X
  368. X    if (!(cmd = malloc (strlen (to) + 50)))
  369. X        return;
  370. X# ifdef        COPY_TO_POSTMASTER
  371. X    sprintf (cmd, "rmail postmaster '%s'", to);
  372. X# else        /* COPY_TO_POSTMASTER */
  373. X    sprintf (cmd, "rmail '%s'", to);
  374. X# endif        /* COPY_TO_POSTMASTER */
  375. X    if (!(pp = xpopen (cmd, "w"))) {
  376. X        do_log ("FATAL: Can't fork '%s'\n", cmd);
  377. X        return;
  378. X    }
  379. X    fprintf (pp, "From: %s@%s (News Subsystem)\n", news_owner, fhost);
  380. X    fprintf (pp, "To: %s\n", to);
  381. X# ifdef        COPY_TO_POSTMASTER
  382. X    fprintf (pp, "Cc: postmaster@%s\n", fhost);
  383. X# endif        /* COPY_TO_POSTMASTER */
  384. X    if (reply_to)
  385. X        fprintf (pp, "Reply-To: %s\n", reply_to);
  386. X    else
  387. X        fprintf (pp, "Reply-To: Postmaster@%s\n", fhost);
  388. X    fprintf (pp, "Subject: %s %s\n", subj, subjv ? subjv : "");
  389. X    fprintf (pp, "\n");
  390. X    if (comment && comment[0]) {
  391. X        for (t=0;comment[t];++t)
  392. X            fputs (comment[t], pp);
  393. X        fputs ("\n\n", pp);
  394. X    }
  395. X# ifndef    IN_MEMORY
  396. X    if (fn && (fp = fopen (fn, "r"))) {
  397. X        while (fgets (buf, 78, fp))
  398. X            fputs (buf, pp);
  399. X        fclose (fp);
  400. X    }
  401. X# else        /* IN_MEMORY */
  402. X    for (ltmp = fn; ltmp; ltmp = ltmp->next)
  403. X        fwrite (ltmp->text, sizeof (char), ltmp->len, pp);
  404. X# endif        /* IN_MEMORY */
  405. X    pclose (pp);
  406. X    free (cmd);
  407. X}
  408. __END__OF__THIS__FILE__
  409. if test -f 'INEWS/makh.c' ; then
  410.   echo 'File INEWS/makh.c already exists, overwriting it'
  411.   del 'INEWS/makh.c'
  412. fi
  413. echo Extracting \"'INEWS/makh.c'\"
  414. sed "s/^X//" >'INEWS/makh.c' <<'__END__OF__THIS__FILE__'
  415. X/*
  416. X * $Log:    makh.c_v $
  417. X * Revision 1.1  90/08/31  15:34:33  cs
  418. X * Initial revision
  419. X * 
  420. X */
  421. X# ifndef    LINT
  422. Xstatic char rcsid[] = "$Id: makh.c_v 1.1 90/08/31 15:34:33 cs Exp $";
  423. X# endif        LINT
  424. X# include    <time.h>
  425. X# include    "inews.h"
  426. X
  427. Xextern char    *index ();
  428. Xextern char    *malloc ();
  429. Xextern char    *strdup ();
  430. X
  431. Xcharc *
  432. Xmake_head (id)
  433. Xint id;
  434. X{
  435. X    charc        *dest;
  436. X    register char    *p1, *from;
  437. X    time_t        tim;
  438. X
  439. X    if (!(dest = (charc *) malloc (sizeof (charc))))
  440. X        return (NULL);
  441. X    dest->next = NULL;
  442. X    switch (id) {
  443. X        case H_PATH:
  444. X            if (!(from = find_address ())) {
  445. X                do_log ("No Path: Field found!\n");
  446. X                do_exit (1);
  447. X            }
  448. X            if (!(dest->text = malloc (strlen (from) + strlen (hlines[H_PATH] + 2) + 6))) {
  449. X                do_log ("Unable to alloc while creating Path:\n");
  450. X                do_exit (1);
  451. X            }
  452. X            strcpy (dest->text, hlines[H_PATH] + 2);
  453. X            strcat (dest->text, " ");
  454. X            strcat (dest->text, from);
  455. X            free (from);
  456. X            break;
  457. X        case H_FROM:
  458. X            if (!(from = find_from (FALSE))) {
  459. X                do_log ("No From: Field found!\n");
  460. X                do_exit (1);
  461. X            }
  462. X            if (!(dest->text = malloc (strlen (from) + strlen (hlines[H_FROM] + 2) + 6))) {
  463. X                do_log ("Can't alloc memory when creating From: Field\n");
  464. X                do_exit (1);
  465. X            }
  466. X            strcpy (dest->text, hlines[H_FROM] + 2);
  467. X            strcat (dest->text, " ");
  468. X            strcat (dest->text, from);
  469. X            break;
  470. X        case H_SUBJECT:
  471. X            if (!(dest->text = strdup ("Subject: [none]"))) {
  472. X                do_log ("Can't alloc memory in Field Subject:\n");
  473. X                do_exit (1);
  474. X            }
  475. X            break;
  476. X        case H_NEWSGROUPS:
  477. X            do_log ("No Newsgroups: Field found!\n");
  478. X            do_exit (1);
  479. X            break;
  480. X        case H_MESSAGE_ID:
  481. X            p1 = get_msgid ();
  482. X            if (!(dest->text = malloc (strlen (p1) + strlen (hlines[H_MESSAGE_ID] + 2) + 6))) {
  483. X                do_log ("Can't alloc memory in Field Message-ID:\n");
  484. X                do_exit (1);
  485. X            }
  486. X            strcpy (dest->text, hlines[H_MESSAGE_ID] + 2);
  487. X            strcat (dest->text, " ");
  488. X            strcat (dest->text, p1);
  489. X            break;
  490. X        case H_DATE:
  491. X            if (!(dest->text = malloc (60))) {
  492. X                do_log ("Can't alloc memory in Field Date\n");
  493. X                do_exit (1);
  494. X            }
  495. X            strcpy (dest->text, hlines[H_DATE] + 2);
  496. X            strcat (dest->text, " ");
  497. X            time (&tim);
  498. X            strcat (dest->text, ntime (&tim));
  499. X            break;
  500. X        case H_LINES:
  501. X            if (!(dest->text = malloc (strlen (hlines[H_LINES]) + 20))) {
  502. X                do_log ("Can't alloc memory in Lines: field.\n");
  503. X                do_exit (1);
  504. X            }
  505. X            sprintf (dest->text, "%s %d", hlines[H_LINES] + 2, lines);
  506. X            break;
  507. X        default:
  508. X            free ((char *) dest);
  509. X            dest = NULL;
  510. X            break;
  511. X    }
  512. X    return (dest);
  513. X}
  514. __END__OF__THIS__FILE__
  515. if test -f 'INEWS/mcan.c' ; then
  516.   echo 'File INEWS/mcan.c already exists, overwriting it'
  517.   del 'INEWS/mcan.c'
  518. fi
  519. echo Extracting \"'INEWS/mcan.c'\"
  520. sed "s/^X//" >'INEWS/mcan.c' <<'__END__OF__THIS__FILE__'
  521. X/*
  522. X * $Log:    mcan.c_v $
  523. X * Revision 1.1  90/08/31  15:34:37  cs
  524. X * Initial revision
  525. X * 
  526. X */
  527. X# ifndef    LINT
  528. Xstatic char rcsid[] = "$Id: mcan.c_v 1.1 90/08/31 15:34:37 cs Exp $";
  529. X# endif        LINT
  530. X# include    <modes.h>
  531. X# include    "inews.h"
  532. X
  533. Xextern char    *malloc ();
  534. Xextern char    *rindex ();
  535. Xextern char    *strdup ();
  536. X
  537. Xint
  538. Xmay_cancel (fn)
  539. Xchar *fn;
  540. X{
  541. X    int    fd;
  542. X    char    *buf;
  543. X    char    *from, *sender, *reply;
  544. X    char    *tfrom, *tsender;
  545. X    char    *news, *newsorig, *ptr;
  546. X    int    n;
  547. X    int    ret;
  548. X
  549. X    if (!(buf = malloc (strlen (newsdir) + strlen (fn) + 8))) {
  550. X        do_log ("FATAL: Can't alloc in may_cancel()\n");
  551. X        do_exit (1);
  552. X    }
  553. X    strcpy (buf, newsdir);
  554. X    strcat (buf, "/");
  555. X    strcat (buf, fn);
  556. X    fd = open (buf, S_IREAD);
  557. X    free (buf);
  558. X    if (fd < 0)
  559. X        return (TRUE);
  560. X    if (!(tfrom = find_address_hl (H_FROM)))
  561. X        tfrom = find_address_hl (H_REPLY_TO);
  562. X    tsender = find_address_hl (H_SENDER);
  563. X    if ((!tfrom) && (!tsender)) {
  564. X        close (fd);
  565. X        do_log ("No from/reply-to/sender in cancel message\n");
  566. X        return (FALSE);
  567. X    }
  568. X    if ((!tfrom) || (!(ptr = rindex (tfrom, '@')))) {
  569. X        if (tsender && (ptr = rindex (tsender, '@')))
  570. X            newsorig = tsender;
  571. X    } else
  572. X        newsorig = tfrom;
  573. X    news = NULL;
  574. X    if (ptr && (Strnieql (news_owner, newsorig, strlen (news_owner)) && newsorig[strlen (news_owner)] == '@'))
  575. X        news = strdup (ptr + 1);
  576. X    from = NULL;
  577. X    reply = NULL;
  578. X    sender = NULL;
  579. X    conv_it = TRUE;
  580. X    while (buf = readbuf (fd, & n)) {
  581. X        if (n == 1)
  582. X            break;
  583. X        buf[n - 1] = '\0';
  584. X        if ((!from) && (Strnieql (buf, hlines[H_FROM] + 2, strlen (hlines[H_FROM] + 2))))
  585. X            from = extract_address (buf);
  586. X        else if ((!reply) && (Strnieql (buf, hlines[H_REPLY_TO] + 2, strlen (hlines[H_REPLY_TO] + 2))))
  587. X            reply = extract_address (buf);
  588. X        else if ((!sender) && (Strnieql (buf, hlines[H_SENDER] + 2, strlen (hlines[H_SENDER] + 2))))
  589. X            sender = extract_address (buf);
  590. X    }
  591. X    conv_it = FALSE;
  592. X    close (fd);
  593. X    if (reply)
  594. X        if (!from)
  595. X            from = reply;
  596. X        else
  597. X            free (reply);
  598. X    ret = FALSE;
  599. X    if (tsender && sender)
  600. X        ret = Strieql (sender, tsender);
  601. X    if ((!ret) && (tsender && from))
  602. X        ret = Strieql (from, tsender);
  603. X    if ((!ret) && (tfrom && sender))
  604. X        ret = Strieql (sender, tfrom);
  605. X    if ((!ret) && (tfrom && from))
  606. X        ret = Strieql (from, tfrom);
  607. X    if ((!ret) && news) {
  608. X        if ((!sender) || (!(ptr = rindex (sender, '@'))))
  609. X            if (from)
  610. X                ptr = rindex (from, '@');
  611. X        if (ptr)
  612. X            ret = Strieql (news, ptr + 1);
  613. X    }
  614. X    if (from)
  615. X        free (from);
  616. X    if (tfrom)
  617. X        free (tfrom);
  618. X    if (sender)
  619. X        free (sender);
  620. X    if (tsender)
  621. X        free (tsender);
  622. X    if (news)
  623. X        free (news);
  624. X    return (ret);
  625. X}
  626. __END__OF__THIS__FILE__
  627. if test -f 'INEWS/mhead.c' ; then
  628.   echo 'File INEWS/mhead.c already exists, overwriting it'
  629.   del 'INEWS/mhead.c'
  630. fi
  631. echo Extracting \"'INEWS/mhead.c'\"
  632. sed "s/^X//" >'INEWS/mhead.c' <<'__END__OF__THIS__FILE__'
  633. X/*
  634. X * $Log:    mhead.c_v $
  635. X * Revision 1.1  90/08/31  15:34:42  cs
  636. X * Initial revision
  637. X * 
  638. X */
  639. X# ifndef    LINT
  640. Xstatic char rcsid[] = "$Id: mhead.c_v 1.1 90/08/31 15:34:42 cs Exp $";
  641. X# endif        LINT
  642. X# include    <c8type.h>
  643. X# include    "inews.h"
  644. X
  645. Xextern char    *malloc ();
  646. Xextern char    *strdup ();
  647. X
  648. Xcharc *
  649. Xsplit_fields (s, lc)
  650. Xchar *s;
  651. Xint lc;
  652. X{
  653. X    charc        *top, *tmp, *act;
  654. X    char        *buf;
  655. X    register char    *sav, *ptr, *p;
  656. X    int        len;
  657. X
  658. X    top = NULL;
  659. X    act = NULL;
  660. X    if (!(buf = strdup (s))) {
  661. X        do_log ("Can't alloc memory in split_fields\n");
  662. X        do_exit (1);
  663. X    }
  664. X    ptr = buf;
  665. X    while (is8space (*ptr) || (*ptr == ','))
  666. X        ++ptr;
  667. X    while (*ptr) {
  668. X        sav = ptr;
  669. X        while (*ptr && (!is8space (*ptr)) && (*ptr != ','))
  670. X            ++ptr;
  671. X        if (*ptr) {
  672. X            *ptr++ = '\0';
  673. X            while (is8space (*ptr) || (*ptr == ','))
  674. X                ++ptr;
  675. X        }
  676. X        if (!sav[0])
  677. X            continue;
  678. X        if (!(tmp = (charc *) malloc (sizeof (charc)))) {
  679. X            do_log ("Can't alloc memory during split_fields\n");
  680. X            do_exit (1);
  681. X        }
  682. X        len = strlen (sav);
  683. X        if (len < 10)
  684. X            len = 10;
  685. X        len += 2;
  686. X        if (!(tmp->text = malloc (len))) {
  687. X            do_log ("Can't alloc memory during split_fields\n");
  688. X            do_exit (1);
  689. X        } else
  690. X            strcpy (tmp->text, sav);
  691. X        p = tmp->text;
  692. X        if (lc)
  693. X            while (*p) {
  694. X                *p = to8lower (*p);
  695. X                ++p;
  696. X            }
  697. X        tmp->nr = 0;
  698. X        tmp->next = NULL;
  699. X        if (!act)
  700. X            top = tmp;
  701. X        else
  702. X            act->next = tmp;
  703. X        act = tmp;
  704. X    }
  705. X    free (buf);
  706. X    return (top);
  707. X}
  708. X
  709. __END__OF__THIS__FILE__
  710. if test -f 'INEWS/mid.c' ; then
  711.   echo 'File INEWS/mid.c already exists, overwriting it'
  712.   del 'INEWS/mid.c'
  713. fi
  714. echo Extracting \"'INEWS/mid.c'\"
  715. sed "s/^X//" >'INEWS/mid.c' <<'__END__OF__THIS__FILE__'
  716. X/*
  717. X * $Log:    mid.c_v $
  718. X * Revision 1.3  91/05/22  13:35:19  ud
  719. X * Added short message-ids
  720. X * 
  721. X * Revision 1.2  91/01/02  21:23:12  ud
  722. X * Added ndbm for history support
  723. X * 
  724. X * Revision 1.1  90/08/31  15:34:45  cs
  725. X * Initial revision
  726. X * 
  727. X */
  728. X# ifndef    LINT
  729. Xstatic char rcsid[] = "$Id: mid.c_v 1.3 91/05/22 13:35:19 ud Exp $";
  730. X# endif        LINT
  731. X# include    <c8type.h>
  732. X# include    <modes.h>
  733. X# include    <time.h>
  734. X# include    "inews.h"
  735. X# include    "hist.h"
  736. X
  737. X# define    SEQ        ".seq"
  738. X
  739. Xextern char    *malloc ();
  740. Xextern char    *strdup ();
  741. X
  742. Xstatic int    yetcreated = FALSE;
  743. Xstatic char    msgid[128];
  744. X
  745. X# ifdef        SHORT_MSGID
  746. Xstatic char    msgmap[] = {
  747. X    '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',',
  748. X    '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8',
  749. X    '9', ':', ';', '=', '?', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
  750. X    'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
  751. X    'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', ']', '^', '_', '`',
  752. X    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
  753. X    'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
  754. X    'y', 'z', '{', '|', '}', '~'
  755. X};
  756. X# endif        /* SHORT_MSGID */
  757. X
  758. Xchar *
  759. Xget_msgid ()
  760. X{
  761. X    int        fd;
  762. X    unsigned int    id;
  763. X    register char    *ptr;
  764. X
  765. X    if (yetcreated)
  766. X        return (msgid);
  767. X    if (access (SEQ, 0) < 0) {
  768. X        fd = create (SEQ, S_IWRITE, 03);
  769. X        id = 0;
  770. X    } else if ((fd = open (SEQ, S_IREAD | S_IWRITE)) != -1) {
  771. X        if (read (fd, &id, sizeof (int)) != sizeof (int))
  772. X            id = 0;
  773. X        lseek (fd, 0, 0);
  774. X    }
  775. X    ++id;
  776. X    if (fd != -1) {
  777. X        write (fd, &id, sizeof (int));
  778. X        close (fd);
  779. X    }
  780. X    yetcreated = TRUE;
  781. X# ifndef    SHORT_MSGID
  782. X    sprintf (msgid, "<%d@%s>", id, fhost);
  783. X# else        /* SHORT_MSGID */
  784. X    ptr = msgid;
  785. X    *ptr++ = '<';
  786. X    while (id != 0) {
  787. X        *ptr++ = msgmap[id % sizeof (msgmap)];
  788. X        id /= sizeof (msgmap);
  789. X    }
  790. X    sprintf (ptr, "@%s>", fhost);
  791. X# endif        /* SHORT_MSGID */
  792. X    return (msgid);
  793. X}
  794. X
  795. Xvoid
  796. Xset_msgid (s)
  797. Xchar *s;
  798. X{
  799. X    if (!yetcreated) {
  800. X        strncpy (msgid, s, 120);
  801. X        yetcreated = TRUE;
  802. X    }
  803. X}
  804. X
  805. Xvoid
  806. Xclear_msgid ()
  807. X{
  808. X    yetcreated = FALSE;
  809. X}
  810. X
  811. Xchar *
  812. Xexists_message_id (id, tim)
  813. Xchar *id;
  814. Xtime_t *tim;
  815. X{
  816. X# ifndef    USE_NDBM
  817. X    register char    *p1, *p2;
  818. X    char        *buf;
  819. X    int        fd;
  820. X    char        *sav;
  821. X    char        *fn;
  822. X    char        *flag;
  823. X    int        n;
  824. X
  825. X    if ((fd = open_hist (id, S_IREAD)) < 0)
  826. X        return (NULL);
  827. X    while (buf = readbuf (fd, & n)) {
  828. X        buf[n-1] = '\0';
  829. X        sav = skipc (buf, '\0');
  830. X        flag = skipc (sav, '\0');
  831. X        if (Mideql (sav, id)) {
  832. X            fn = skipc (flag, '\0');
  833. X            break;
  834. X        }
  835. X    }
  836. X    close (fd);
  837. X    if (n > 0) {
  838. X        *tim = atol (buf);
  839. X        skipc (fn, '\0');
  840. X        p1 = buf;
  841. X        p2 = fn;
  842. X        while (*p2)
  843. X            *p1++ = *p2++;
  844. X        *p1 = '\0';
  845. X        return (strdup (buf));
  846. X    }
  847. X    return (NULL);
  848. X# else        /* USE_NDBM */
  849. X    register char    *ptr;
  850. X
  851. X    if (!(db = open_hist (S_IREAD)))
  852. X        return (NULL);
  853. X    key.dptr = lower_mid (id);
  854. X    key.dsize = strlen (id) + 1;
  855. X    dat = dbm_fetch (db, key);
  856. X    dbm_close (db);
  857. X    if (dat.dptr == NULL)
  858. X        return (NULL);
  859. X    memcpy (&hist, dat.dptr, sizeof (history));
  860. X    skipc (hist.fns, '\0');
  861. X    *tim = hist.tim;
  862. X    return (strdup (hist.fns));
  863. X# endif        /* USE_NDBM */
  864. X}
  865. X
  866. Xvoid
  867. Xcheck_message_id (id)
  868. Xchar *id;
  869. X{
  870. X    time_t    dummy;
  871. X
  872. X    if (exists_message_id (id, &dummy)) {
  873. X        do_log ("Duplicated article received '%s'\n", id);
  874. X        do_exit (0);
  875. X    }
  876. X}
  877. __END__OF__THIS__FILE__
  878. if test -f 'INEWS/misc.c' ; then
  879.   echo 'File INEWS/misc.c already exists, overwriting it'
  880.   del 'INEWS/misc.c'
  881. fi
  882. echo Extracting \"'INEWS/misc.c'\"
  883. sed "s/^X//" >'INEWS/misc.c' <<'__END__OF__THIS__FILE__'
  884. X/*
  885. X * $Log:    misc.c_v $
  886. X * Revision 1.2  91/05/22  13:09:21  ud
  887. X * Added 8 bit support and assembler routines
  888. X * 
  889. X * Revision 1.1  90/08/31  15:34:49  cs
  890. X * Initial revision
  891. X * 
  892. X */
  893. X# ifndef    LINT
  894. Xstatic char rcsid[] = "$Id: misc.c_v 1.2 91/05/22 13:09:21 ud Exp $";
  895. X# endif        LINT
  896. X# include    <c8type.h>
  897. X# include    <modes.h>
  898. X# include    <time.h>
  899. X# include    "inews.h"
  900. X
  901. Xextern char    *malloc ();
  902. Xextern char    *strdup ();
  903. X
  904. Xstatic char    *months[] = {
  905. X    "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  906. X    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL
  907. X};
  908. X
  909. X# ifndef    USE_ASM    
  910. Xchar *
  911. Xskipc (s, c)
  912. Xregister char *s;
  913. Xregister char c;
  914. X{
  915. X    if (c)
  916. X        while (*s && (*s != c))
  917. X            ++s;
  918. X    else
  919. X        while (*s && (!is8space (*s)))
  920. X            ++s;
  921. X    if (*s) {
  922. X        *s++ = '\0';
  923. X        while (is8space (*s))
  924. X            ++s;
  925. X    }
  926. X    return (s);
  927. X}
  928. X
  929. Xchar *
  930. Xskipn (s, c)
  931. Xregister char *s;
  932. Xregister char c;
  933. X{
  934. X    if (c)
  935. X        while (*s && (*s != c))
  936. X            ++s;
  937. X    else
  938. X        while (*s && (!is8space (*s)))
  939. X            ++s;
  940. X    if (*s) {
  941. X        ++s;
  942. X        while (is8space (*s))
  943. X            ++s;
  944. X    }
  945. X    return (s);
  946. X}
  947. X# else        /* USE_ASM */
  948. X# asm
  949. Xxskip:
  950. X    move.l    d0,a0
  951. X    andi.l    #255,d1
  952. X    tst.b    d1
  953. X    bne.b    skip2
  954. Xl1
  955. X    tst.b    (a0)
  956. X    beq.b    fin
  957. X    move.b    (a0),d1
  958. X    lea.l    _ch8codes(a6),a1
  959. X    btst.b    #4,0(a1,d1)
  960. X    bne.b    fin
  961. X    adda.l    #1,a0
  962. X    bra.b    l1
  963. Xskip2
  964. X    tst.b    (a0)
  965. X    beq.b    fin
  966. X    cmp.b    (a0),d1
  967. X    beq.b    fin
  968. X    adda.l    #1,a0
  969. X    bra.b    skip2
  970. Xfin
  971. X    tst.b    (a0)
  972. X    beq.s    finfin
  973. X    tst.b    d2
  974. X    beq.s    no_clr
  975. X    clr.b    (a0)
  976. Xno_clr
  977. X    addq.l    #1,a0
  978. Xfinfin
  979. X    tst.b    (a0)
  980. X    beq.b    lastfin
  981. X    move.b    (a0),d2
  982. X    lea.l    _ch8codes(a6),a1
  983. X    btst.b    #4,0(a1,d2)
  984. X    beq.b    lastfin
  985. X    adda.l    #1,a0
  986. X    bra.b    finfin
  987. Xlastfin
  988. X    move.l    a0,d0
  989. X    rts
  990. X*
  991. Xskipc:
  992. X    move.l    d2,-(sp)
  993. X    move.l    #1,d2
  994. Xdoit
  995. X    bsr    xskip
  996. X    move.l    (sp)+,d2
  997. X    rts
  998. Xskipn:
  999. X    move.l    d2,-(sp)
  1000. X    clr.l    d2
  1001. X    bra    doit
  1002. X# endasm
  1003. X# endif        /* USE_ASM */
  1004. X
  1005. Xchar *
  1006. Xitoa (n)
  1007. Xint n;
  1008. X{
  1009. X    static char    nbuf[34];
  1010. X    register char    *p;
  1011. X    int        prefix;
  1012. X
  1013. X    p = nbuf + 32;
  1014. X    *p = '\0';
  1015. X    if (n == 0)
  1016. X        *--p = '0';
  1017. X    else {
  1018. X        if (n < 0) {
  1019. X            n = -n;
  1020. X            prefix = -1;
  1021. X        } else
  1022. X            prefix = 1;
  1023. X        while (n > 0) {
  1024. X            *--p = (n % 10) + '0';
  1025. X            n = n / 10;
  1026. X        }
  1027. X        if (prefix < 0)
  1028. X            *--p = '-';
  1029. X    }
  1030. X    return (p);
  1031. X}
  1032. X
  1033. Xvoid
  1034. Xfree_field (fld)
  1035. Xregister charc *fld;
  1036. X{
  1037. X    register charc    *tmp;
  1038. X
  1039. X    while (fld) {
  1040. X        tmp = fld->next;
  1041. X        free (fld->text);
  1042. X        free ((char *) fld);
  1043. X        fld = tmp;
  1044. X    }
  1045. X}
  1046. X
  1047. Xcharc *
  1048. Xcopy_field (fld)
  1049. Xregister charc *fld;
  1050. X{
  1051. X    register charc    *hd, *tmp, *cur;
  1052. X    register int    err;
  1053. X
  1054. X    cur = NULL;
  1055. X    err = 0;
  1056. X    while (fld) {
  1057. X        if (tmp = (charc *) malloc (sizeof (charc)))
  1058. X            if (tmp->text = strdup (fld->text)) {
  1059. X                tmp->nr = fld->nr;
  1060. X                tmp->next = NULL;
  1061. X                if (!cur)
  1062. X                    hd = tmp;
  1063. X                else
  1064. X                    cur->next = tmp;
  1065. X                cur = tmp;
  1066. X            } else {
  1067. X                ++err;
  1068. X                break;
  1069. X            }
  1070. X        else {
  1071. X            ++err;
  1072. X            break;
  1073. X        }
  1074. X        fld = fld->next;
  1075. X    }
  1076. X    if (err && hd) {
  1077. X        free_field (hd);
  1078. X        hd = NULL;
  1079. X    }
  1080. X    return (hd);
  1081. X}
  1082. X        
  1083. Xchar *
  1084. Xcatcharc (hd, sp)
  1085. Xcharc *hd;
  1086. Xchar *sp;
  1087. X{
  1088. X    register charc    *tmp;
  1089. X    register char    *p1, *p2;
  1090. X    char        *ptr;
  1091. X    int        siz;
  1092. X    register int    slen;
  1093. X
  1094. X    slen = strlen (sp);
  1095. X    tmp = hd;
  1096. X    siz = 0;
  1097. X    while (tmp) {
  1098. X        siz += strlen (tmp->text) + slen + 4;
  1099. X        tmp = tmp->next;
  1100. X    }
  1101. X    if (!(ptr = malloc (siz + 10)))
  1102. X        return (NULL);
  1103. X    p1 = ptr;
  1104. X    tmp = hd;
  1105. X    while (tmp) {
  1106. X        if (tmp != hd) {
  1107. X            p2 = sp;
  1108. X            while (*p2)
  1109. X                *p1++ = *p2++;
  1110. X        }
  1111. X        p2 = tmp->text;
  1112. X        while (*p2)
  1113. X            *p1++ = *p2++;
  1114. X        tmp = tmp->next;
  1115. X    }
  1116. X    *p1 = '\0';
  1117. X    return (ptr);
  1118. X}
  1119. X
  1120. Xchar *
  1121. Xget_realfilename (fn, fd)
  1122. Xchar *fn;
  1123. Xint *fd;
  1124. X{
  1125. X    char    *newfn;
  1126. X    int    len;
  1127. X    int    n;
  1128. X
  1129. X    if (!(newfn = malloc (512)))
  1130. X        return (NULL);
  1131. X    if ((*fd = open (fn, S_IREAD)) < 0) {
  1132. X        free (newfn);
  1133. X        return (NULL);
  1134. X    }
  1135. X    len = strlen (LINK_ID);
  1136. X    if (read (*fd, newfn, len) == len) {
  1137. X        if (Strneql (newfn, LINK_ID, len)) {
  1138. X            if ((n = readln (*fd, newfn, 500)) > 0) {
  1139. X                newfn[n - 1] = '\0';
  1140. X                close (*fd);
  1141. X                if ((*fd = open (newfn, S_IREAD)) < 0) {
  1142. X                    free (newfn);
  1143. X                    newfn = NULL;
  1144. X                }
  1145. X                return (newfn);
  1146. X            } else {
  1147. X                free (newfn);
  1148. X                close (*fd);
  1149. X                return (NULL);
  1150. X            }
  1151. X        } else {
  1152. X            lseek (*fd, 0, 0);
  1153. X            strcpy (newfn, fn);
  1154. X            return (newfn);
  1155. X        }
  1156. X    } else {
  1157. X        close (*fd);
  1158. X        free (newfn);
  1159. X        return (NULL);
  1160. X    }
  1161. X}
  1162. X
  1163. Xchar *
  1164. Xmake_realfilename (s, n, fd)
  1165. Xchar *s;
  1166. Xint n;
  1167. Xint *fd;
  1168. X{
  1169. X    char    *rfn, *fn;
  1170. X
  1171. X    if (!(rfn = malloc (strlen (s) + 40)))
  1172. X        return (NULL);
  1173. X    sprintf (rfn, "%s/%d", s, n);
  1174. X    make_fn (rfn);
  1175. X    fn = get_realfilename (rfn, fd);
  1176. X    free (rfn);
  1177. X    return (fn);
  1178. X}
  1179. X
  1180. Xchar *
  1181. Xntime (tim)
  1182. Xtime_t *tim;
  1183. X{
  1184. X    struct tm    *tt;
  1185. X    static char    tbuf[64];
  1186. X
  1187. X    if (tt = gmtime (tim)) {
  1188. X        sprintf (tbuf, "%d %s %04d %02d:%02d:%02d GMT",
  1189. X            tt->tm_mday,
  1190. X            months[tt->tm_mon],
  1191. X            tt->tm_year + 1900,
  1192. X            tt->tm_hour,
  1193. X            tt->tm_min,
  1194. X            tt->tm_sec);
  1195. X    } else
  1196. X        strcpy (tbuf, "");
  1197. X    return (tbuf);
  1198. X}
  1199. X
  1200. X# ifndef    SEND_WORLD
  1201. Xint
  1202. Xdist_is_world ()
  1203. X{
  1204. X    charc        *hd;
  1205. X    charc        *ptr;
  1206. X    register charc    *tmp;
  1207. X    int        ret;
  1208. X
  1209. X    ret = TRUE;
  1210. X    if (hd = get_header_line (H_DISTRIBUTION))
  1211. X        if (ptr = split_fields (hd->text)) {
  1212. X            ret = FALSE;
  1213. X            for (tmp = ptr; tmp; tmp = tmp->next)
  1214. X                if (Strieql (tmp->text, DST_WORLD)) {
  1215. X                    ret = TRUE;
  1216. X                    break;
  1217. X                }
  1218. X            free_field (ptr);
  1219. X        }
  1220. X    if (ret)
  1221. X        block_forward = TRUE;
  1222. X    return (ret);
  1223. X}
  1224. X# endif        /* SEND_WORLD */
  1225. X
  1226. X# ifdef        HASH_SEARCH
  1227. Xhash_t
  1228. Xcalc_hash (str, icase)
  1229. Xregister char *str;
  1230. Xregister int icase;
  1231. X{
  1232. X    register hash_t    ret;
  1233. X
  1234. X    ret = 0;
  1235. X    while (*str)
  1236. X        ret += (icase ? tolower (*str++) : *str++) & 0xff;
  1237. X    return (ret);
  1238. X}
  1239. X# endif        /* HASH_SEARCH */
  1240. __END__OF__THIS__FILE__
  1241. if test -f 'INEWS/mit.c' ; then
  1242.   echo 'File INEWS/mit.c already exists, overwriting it'
  1243.   del 'INEWS/mit.c'
  1244. fi
  1245. echo Extracting \"'INEWS/mit.c'\"
  1246. sed "s/^X//" >'INEWS/mit.c' <<'__END__OF__THIS__FILE__'
  1247. X/*
  1248. X * $Log:    mit.c_v $
  1249. X * Revision 1.1  90/08/31  15:34:54  cs
  1250. X * Initial revision
  1251. X * 
  1252. X */
  1253. X# ifndef    LINT
  1254. Xstatic char rcsid[] = "$Id: mit.c_v 1.1 90/08/31 15:34:54 cs Exp $";
  1255. X# endif        LINT
  1256. X# include    "inews.h"
  1257. X
  1258. Xvoid
  1259. Xmail_it (rec)
  1260. Xchar *rec;
  1261. X{
  1262. X    mail_to (rec, NULL, "This is a moderated group", NULL, newstmp, NULL);
  1263. X}
  1264. __END__OF__THIS__FILE__
  1265. if test -f 'INEWS/oart.c' ; then
  1266.   echo 'File INEWS/oart.c already exists, overwriting it'
  1267.   del 'INEWS/oart.c'
  1268. fi
  1269. echo Extracting \"'INEWS/oart.c'\"
  1270. sed "s/^X//" >'INEWS/oart.c' <<'__END__OF__THIS__FILE__'
  1271. X/*
  1272. X * $Log$
  1273. X * 
  1274. X */
  1275. X# ifndef    LINT
  1276. Xstatic char rcsid[] = "$Id$";
  1277. X# endif        LINT
  1278. X# include    <c8type.h>
  1279. X# include    <modes.h>
  1280. X# include    "inews.h"
  1281. X
  1282. Xextern char    *malloc ();
  1283. X
  1284. Xstatic char    *nfn = NULL;
  1285. X
  1286. Xchar *
  1287. Xopen_article (fn, readit)
  1288. Xchar *fn;
  1289. Xint readit;
  1290. X{
  1291. X    register char    *p1, *p2;
  1292. X    register int    n;
  1293. X    int        fd;
  1294. X    char        buf[32];
  1295. X
  1296. X    if (! nfn)
  1297. X        if (! (nfn = malloc (1024)))
  1298. X            return (NULL);
  1299. X    for (p1 = fn, p2 = nfn, n = 0; *p1;)
  1300. X        if ((*p1 == '/') || (*p1 == '.')) {
  1301. X            *p2++ = '/';
  1302. X            ++p1;
  1303. X            n = 0;
  1304. X        } else {
  1305. X            if ((! is8alnum (*p1)) && (! index ("$_.", *p1))) {
  1306. X                ++p1;
  1307. X                *p2++ = '_';
  1308. X            } else
  1309. X                *p2++ = *p1++;
  1310. X            if (++n > 26)
  1311. X                while (*p1 && (*p1 != '/'))
  1312. X                    ++p1;
  1313. X        }
  1314. X    *p2 = '\0';
  1315. X    if (readit && ((fd = open (nfn, S_IREAD)) != -1)) {
  1316. X        n = strlen (LINK_ID);
  1317. X        if ((read (fd, buf, n) == n) && Strneql (buf, LINK_ID, n))
  1318. X            if ((n = read (fd, nfn, 1000)) > 0) {
  1319. X                nfn[n] = '\0';
  1320. X                if (access (nfn, 0) == -1)
  1321. X                    n = -1;
  1322. X            } else
  1323. X                n = -1;
  1324. X        close (fd);
  1325. X        if (n < 0)
  1326. X            return (open_article (fn, FALSE));
  1327. X    }
  1328. X    return (nfn);
  1329. X}
  1330. __END__OF__THIS__FILE__
  1331. if test -f 'INEWS/ohist.c' ; then
  1332.   echo 'File INEWS/ohist.c already exists, overwriting it'
  1333.   del 'INEWS/ohist.c'
  1334. fi
  1335. echo Extracting \"'INEWS/ohist.c'\"
  1336. sed "s/^X//" >'INEWS/ohist.c' <<'__END__OF__THIS__FILE__'
  1337. X/*
  1338. X * $Log:    ohist.c_v $
  1339. X * Revision 1.4  91/05/22  13:07:32  ud
  1340. X * - Included assembler routines
  1341. X * - better ndbm support
  1342. X * 
  1343. X * Revision 1.3  91/01/02  21:24:47  ud
  1344. X * Added ndbm support for history, optional
  1345. X * 
  1346. X * Revision 1.2  90/12/01  15:45:16  ud
  1347. X * Changed generating of filenames for historyfiles to hashing mode
  1348. X * 
  1349. X * Revision 1.1  90/08/31  15:34:57  cs
  1350. X * Initial revision
  1351. X * 
  1352. X */
  1353. X# ifndef    LINT
  1354. Xstatic char rcsid[] = "$Id: ohist.c_v 1.4 91/05/22 13:07:32 ud Exp $";
  1355. X# endif        LINT
  1356. X# include    <c8type.h>
  1357. X# include    <modes.h>
  1358. X# include    <direct.h>
  1359. X# include    "inews.h"
  1360. X# include    "hist.h"
  1361. X
  1362. X# ifndef    USE_ASM
  1363. Xint
  1364. XMideql (id1, id2)
  1365. Xregister char *id1, *id2;
  1366. X{
  1367. X    register int    is_local;
  1368. X
  1369. X    is_local = TRUE;
  1370. X    while (*id1 && *id2)
  1371. X        if (is_local ? (*id1 != *id2) : (to8lower (*id1) != to8lower (*id2)))
  1372. X            return (FALSE);
  1373. X        else {
  1374. X            if (*id1 == '@')
  1375. X                is_local = FALSE;
  1376. X            ++id1;
  1377. X            ++id2;
  1378. X        }
  1379. X    return (!(*id1 || *id2));
  1380. X}
  1381. X# else        /* USE_ASM */
  1382. X# asm
  1383. XMideql:
  1384. X    move.l    d2,-(sp)
  1385. X    move.l    d0,a0
  1386. X    move.l    d1,a1
  1387. X    moveq.l    #1,d0
  1388. Xloop
  1389. X    tst.b    (a0)
  1390. X    beq.b    fin
  1391. X    tst.b    (a1)
  1392. X    beq.b    fin
  1393. X    tst.b    d0
  1394. X    beq    no_sense
  1395. X    move.b    (a0),d1
  1396. X    cmp.b    (a1),d1
  1397. X    bne.b    fin
  1398. X    cmp.b    #$40,d1
  1399. X    bne.s    reloop
  1400. X    clr.l    d0
  1401. Xreloop
  1402. X    addq.l    #1,a0
  1403. X    addq.l    #1,a1
  1404. X    bra.b    loop
  1405. Xno_sense
  1406. X    move.b    (a0),d1
  1407. X    cmp.b    #$5a,d1
  1408. X    bgt.s    no1
  1409. X    cmp.b    #$41,d1
  1410. X    blt.s    no1
  1411. X    and.b    #$20,d1
  1412. Xno1
  1413. X    move.b    (a1),d2
  1414. X    cmp.b    #$5a,d2
  1415. X    bgt.s    no2
  1416. X    cmp.b    #$41,d2
  1417. X    blt.s    no2
  1418. X    and.b    #$20,d2
  1419. Xno2
  1420. X    cmp.b    d0,d1
  1421. X    beq.b    reloop
  1422. Xfin
  1423. X    move.l    #1,d0
  1424. X    move.b    (a0),d1
  1425. X    sub.b    (a1),d1
  1426. X    beq.s    Okay
  1427. X    clr.l    d0
  1428. XOkay
  1429. X    move.l    (sp)+,d2
  1430. X    rts
  1431. X# endasm
  1432. X# endif        /* USE_ASM */
  1433. X
  1434. X# ifndef    USE_NDBM
  1435. Xint
  1436. Xopen_hist (id, mode)
  1437. Xchar *id;
  1438. Xint mode;
  1439. X{
  1440. X    int            fd;
  1441. X    char            fn[80];
  1442. X    register int        is_local;
  1443. X    register char        *ptr;
  1444. X    register unsigned int    count;
  1445. X
  1446. X    ptr = id;
  1447. X    count = 0;
  1448. X    is_local = TRUE;
  1449. X    while (*ptr) {
  1450. X        count += (is_local ? *ptr : to8lower (*ptr)) & 0xff;
  1451. X        if (*ptr++ == '@')
  1452. X            is_local = FALSE;
  1453. X    }
  1454. X    sprintf (fn, HIST_FILE, count % HIST_MAXIMUM);
  1455. X    if ((fd = open (fn, mode)) < 0)
  1456. X        if (mode & S_IWRITE)
  1457. X            fd = create (fn, mode, 03);
  1458. X    return (fd);
  1459. X}
  1460. X# else        /* USE_NDBM */
  1461. Xchar *
  1462. Xlower_mid (id)
  1463. Xchar *id;
  1464. X{
  1465. X    static int    siz = 0;
  1466. X    static char    *buf = NULL;
  1467. X    int        len;
  1468. X    register char    *p1, *p2;
  1469. X    register int    is_local;
  1470. X
  1471. X    if ((len = strlen (id)) >= siz) {
  1472. X        siz = len + 32;
  1473. X        if (!(buf = realloc (buf, siz + 2)))
  1474. X            return (NULL);
  1475. X    }
  1476. X    is_local = TRUE;
  1477. X    p1 = id;
  1478. X    p2 = buf;
  1479. X    while (*p1) {
  1480. X        *p2++ = is_local ? *p1 : to8lower (*p1);
  1481. X        if (*p1++ == '@')
  1482. X            is_local = FALSE;
  1483. X    }
  1484. X    *p2 = '\0';
  1485. X    return (buf);
  1486. X}
  1487. X
  1488. Xvoid
  1489. Xfill_hist ()
  1490. X{
  1491. X    dat.dsize = strlen (hist.fns) + 1 + sizeof (int) + sizeof (time_t);
  1492. X    dat.dptr = (char *) &hist;
  1493. X}
  1494. X
  1495. Xstatic void
  1496. Xcheck_history (suffix)
  1497. Xchar *suffix;
  1498. X{
  1499. X    int        fd, fdo;
  1500. X    char        fn[40];
  1501. X    char        *buf;
  1502. X    int        n, siz;
  1503. X    struct fildes    fdes;
  1504. X
  1505. X    strcpy (fn, HISTORY);
  1506. X    strcat (fn, suffix);
  1507. X    if ((fd = open (fn, 0)) != -1) {
  1508. X        if (_gs_gfd (fd, &fdes, sizeof (struct fildes)) != -1) {
  1509. X            for (t = 0; t < 48; ++t)
  1510. X                if (! (fdes.fdseg[t].addr[0] ||
  1511. X                       fdes.fdseg[t].addr[0] ||
  1512. X                       fdes.fdseg[t].addr[0]))
  1513. X                           break;
  1514. X            if (t > 43) {
  1515. X                do_log ("%s has %d file segments\n", fn, t);
  1516. X                if (rename (fn, TEMP_FILE) == 0) {
  1517. X                    if ((fdo = create (fn, S_IWRITE | S_ISIZE, 013, _gs_size (fd)) != -1) {
  1518. X                        siz = 5000;
  1519. X                        do {
  1520. X                            if (! (buf = malloc (siz + 32)))
  1521. X                                siz -= 1000;
  1522. X                        } while ((! buf) && (siz > 0));
  1523. X                        if (! buf) {
  1524. X                            buf = &c;
  1525. X                            siz = 1;
  1526. X                        }
  1527. X                        while ((n = read (fd, buf, siz)) > 0)
  1528. X                            write (fdo, buf, n);
  1529. X                        close (fdo);
  1530. X                        if (siz > 1)
  1531. X                            free (buf);
  1532. X                    } else
  1533. X                        rename (TEMP_FILE, fn);
  1534. X                } else
  1535. X                    do_log ("rename (%s, %s) failed\n", fn, TEMP_FILE);
  1536. X        }
  1537. X        close (fd);
  1538. X    }
  1539. X}
  1540. X
  1541. Xvoid
  1542. Xcheck_history_size ()
  1543. X{
  1544. X    check_history (DIREXT);
  1545. X    check_history (PAGEXT);
  1546. X}
  1547. X
  1548. XDBM *
  1549. Xopen_hist (mode)
  1550. Xint mode;
  1551. X{
  1552. X    return (dbm_open (HISTORY, mode, 013));
  1553. X}
  1554. X# endif        /* USE_NDBM */
  1555. __END__OF__THIS__FILE__
  1556. if test -f 'INEWS/pargs.c' ; then
  1557.   echo 'File INEWS/pargs.c already exists, overwriting it'
  1558.   del 'INEWS/pargs.c'
  1559. fi
  1560. echo Extracting \"'INEWS/pargs.c'\"
  1561. sed "s/^X//" >'INEWS/pargs.c' <<'__END__OF__THIS__FILE__'
  1562. X/*
  1563. X * $Log:    pargs.c_v $
  1564. X * Revision 1.3  91/05/22  13:10:38  ud
  1565. X * Added ndbm file checks
  1566. X * 
  1567. X * Revision 1.2  90/12/01  15:42:35  ud
  1568. X * Added new option for rebuildig history
  1569. X * Currently only for converting from old format to new
  1570. X * hashing format possible
  1571. X * 
  1572. X * Revision 1.1  90/08/31  15:35:01  cs
  1573. X * Initial revision
  1574. X * 
  1575. X */
  1576. X# ifndef    LINT
  1577. Xstatic char rcsid[] = "$Id: pargs.c_v 1.3 91/05/22 13:10:38 ud Exp $";
  1578. X# endif        LINT
  1579. X# include    "inews.h"
  1580. X
  1581. Xextern char    *rindex ();
  1582. Xextern char    *strdup ();
  1583. X
  1584. Xstatic char    *help[] = {
  1585. X    "Syntax: inews [<opts>]\n",
  1586. X    "Function: stores and forwards news articles\n",
  1587. X    "Options:\n",
  1588. X    "     -a         runs in admin mode (execute control-messages)\n",
  1589. X    "     -e=<days>  removes all article that are longer than <days> on the machine\n",
  1590. X    "     -E=<days>  remove older entries from the history file (to use with `-e')\n",
  1591. X    "     -r         rebuilds the active file\n",
  1592. X    "     -H         rebuilds all history files (warning! slow!)\n",
  1593. X# ifdef        USE_NDBM
  1594. X    "     -C         check DBM history files for file segment list\n",
  1595. X# endif        /* USE_NDBM */
  1596. X    "     -h         create a new message (insert missing header lines)\n",
  1597. X    "     -t         enable translation of 8 bit chars even w/o `-h' option\n",
  1598. X    "     -D         enable auto.determination of distribution w/o `-h'\n",
  1599. X    "     -v         verbose mode, prints log messages on screen, too\n",
  1600. X    "     -c=<ctrl>  send <ctrl> as control message\n",
  1601. X    "     -g=<grps>  specify list of groups\n",
  1602. X    "     -d=<dist>  specify list of distribution(s)\n",
  1603. X    "\n",
  1604. X    "     -M=<msgid> retreives the filename for this message id and writes it\n",
  1605. X    "                to stdout (more -M's can be used to get more filenames).\n",
  1606. X    "     -R         respool droped articles\n",
  1607. X    "\n",
  1608. X    "     -m=<mode>  mode of user-interface (mode can be `read' or `write'\n",
  1609. X    "     -p=<rec>   if mode is <mail> these are the receivers\n",
  1610. X    NULL
  1611. X};
  1612. X
  1613. Xstatic void
  1614. Xusage ()
  1615. X{
  1616. X    register int    t;
  1617. X
  1618. X    for (t=0;help[t];++t)
  1619. X        writeln (2, help[t], strlen (help[t]));
  1620. X}
  1621. X
  1622. Xvoid
  1623. Xparse_args (ac, av)
  1624. Xint ac;
  1625. Xchar *av[];
  1626. X{
  1627. X    register int    t;
  1628. X    register char    *ptr;
  1629. X    charc        *tmp, *t2;
  1630. X    int        muid, ruid;
  1631. X    char        *expire, *exphist;
  1632. X    char        *ctrlmsg;
  1633. X    int        rebuild_active;
  1634. X    int        rebuild_history;
  1635. X    int        check_dbmsiz;
  1636. X    char        *srcfn;
  1637. X    charc        *retr_msgid;
  1638. X    int        mode;
  1639. X    int        rev_conv;
  1640. X    int        do_respool;
  1641. X
  1642. X    isadm = FALSE;
  1643. X    expire = NULL;
  1644. X    exphist = NULL;
  1645. X    ctrlmsg = NULL;
  1646. X    rebuild_active = FALSE;
  1647. X    rebuild_history = FALSE;
  1648. X    check_dbmsiz = FALSE;
  1649. X    retr_msgid = NULL;
  1650. X    if (ptr = rindex (av[0], '/'))
  1651. X        ++ptr;
  1652. X    else
  1653. X        ptr = av[0];
  1654. X    mode = (! _strccmp (ptr, "mnews") ? M_READ : M_NONE);
  1655. X    doconv = FALSE;
  1656. X    conv_it = FALSE;
  1657. X    rev_conv = FALSE;
  1658. X    do_respool = FALSE;
  1659. X    srcfn = NULL;
  1660. X    crthd = FALSE;
  1661. X    ins_dist = FALSE;
  1662. X    for (t=1;t<ac;++t)
  1663. X        if (av[t][0] == '-') {
  1664. X            ptr = av[t] + 1;
  1665. X            while (*ptr) {
  1666. X                switch (*ptr) {
  1667. X                    case 'v':
  1668. X                        verbose = TRUE;
  1669. X                         break;
  1670. X                    case 'h':
  1671. X                        crthd = TRUE;
  1672. X                        /* Fall through ... */
  1673. X                    case 't':
  1674. X                        doconv = TRUE;
  1675. X                        break;
  1676. X                    case 'D':
  1677. X                        ins_dist = TRUE;
  1678. X                        break;
  1679. X                    case 'r':
  1680. X                        rebuild_active = TRUE;
  1681. X                        break;
  1682. X                    case 'H':
  1683. X                        rebuild_history = TRUE;
  1684. X                        break;
  1685. X# ifdef        USE_NDBM
  1686. X                    case 'C':
  1687. X                        check_dbmsiz = TRUE;
  1688. X                        break;
  1689. X# endif        /* USE_NDBM */
  1690. X                    case 'e':
  1691. X                        ptr += (*(ptr+1) == '=') ? 2 : 1;
  1692. X                        expire = ptr;
  1693. X                        while (*ptr)
  1694. X                            ++ptr;
  1695. X                        break;
  1696. X                    case 'E':
  1697. X                        ptr += (*(ptr+1) == '=') ? 2 : 1;
  1698. X                        exphist = ptr;
  1699. X                        while (*ptr)
  1700. X                            ++ptr;
  1701. X                        break;
  1702. X                    case 'c':
  1703. X                        ptr += (*(ptr+1) == '=') ? 2 : 1;
  1704. X                        ctrlmsg = ptr;
  1705. X                        while (*ptr)
  1706. X                            ++ptr;
  1707. X                        break;
  1708. X                    case 'g':
  1709. X                        ptr += (*(ptr+1) == '=') ? 2 : 1;
  1710. X                        tmp = split_fields (ptr, TRUE);
  1711. X                        if (tmp) {
  1712. X                            if (!ngs)
  1713. X                                ngs = tmp;
  1714. X                            else {
  1715. X                                t2 = ngs;
  1716. X                                while (t2->next)
  1717. X                                    t2 = t2->next;
  1718. X                                t2->next = tmp;
  1719. X                            }
  1720. X                        }
  1721. X                        while (*ptr)
  1722. X                            ++ptr;
  1723. X                        break;
  1724. X                    case 'd':
  1725. X                        ptr += (*(ptr+1) == '=') ? 2 : 1;
  1726. X                        tmp = split_fields (ptr, TRUE);
  1727. X                        if (tmp) {
  1728. X                            if (!dists)
  1729. X                                dists = tmp;
  1730. X                            else {
  1731. X                                t2 = dists;
  1732. X                                while (t2->next)
  1733. X                                    t2 = t2->next;
  1734. X                                t2->next = tmp;
  1735. X                            }
  1736. X                        }
  1737. X                        while (*ptr)
  1738. X                            ++ptr;
  1739. X                        break;
  1740. X                    case 'a':
  1741. X                        break;
  1742. X                    case 'M':
  1743. X                        ptr += (*(ptr+1) == '=') ? 2 : 1;
  1744. X                        if ((tmp = (charc *) malloc (sizeof (charc))) && (tmp->text = strdup (ptr))) {
  1745. X                            tmp->next = NULL;
  1746. X                            if (!retr_msgid)
  1747. X                                retr_msgid = tmp;
  1748. X                            else {
  1749. X                                for (t2 = retr_msgid; t2->next; t2 = t2->next)
  1750. X                                    ;
  1751. X                                t2->next = tmp;
  1752. X                            }
  1753. X                        } else
  1754. X                            exit (_errmsg (1, "Out of memory.\n"));
  1755. X                        while (*ptr)
  1756. X                            ++ptr;
  1757. X                        break;
  1758. X                    case 'R':
  1759. X                        do_respool = TRUE;
  1760. X                        break;
  1761. X                    case 'm':
  1762. X                        ptr += (*(ptr+1) == '=') ? 2 : 1;
  1763. X                        if (Strieql (ptr, "read"))
  1764. X                            mode = M_READ;
  1765. X                        else if (Strieql (ptr, "write"))
  1766. X                            mode = M_WRITE;
  1767. X                        else if (Strieql (ptr, "mail"))
  1768. X                            mode = M_MAIL;
  1769. X                        else
  1770. X                            exit (_errmsg (1, "Unknown mode %s.\n", ptr));
  1771. X                        while (*ptr)
  1772. X                            ++ptr;
  1773. X                        break;
  1774. X                    case 'p':
  1775. X                        ptr += (*(ptr+1) == '=') ? 2 : 1;
  1776. X                        tmp = split_fields (ptr, FALSE);
  1777. X                        if (tmp) {
  1778. X                            if (!recv)
  1779. X                                recv= tmp;
  1780. X                            else {
  1781. X                                t2 = recv;
  1782. X                                while (t2->next)
  1783. X                                    t2 = t2->next;
  1784. X                                t2->next = tmp;
  1785. X                            }
  1786. X                        }
  1787. X                        while (*ptr)
  1788. X                            ++ptr;
  1789. X                        break;
  1790. X                    case '?':
  1791. X                    default:
  1792. X                        usage ();
  1793. X                        exit (*ptr == '?' ? 0 :
  1794. X                            _errmsg (1, "Unknown option '%c'\n", *ptr));
  1795. X                        break;
  1796. X                }
  1797. X                if (*ptr)
  1798. X                    ++ptr;
  1799. X            }
  1800. X        } else if (!srcfn)
  1801. X            srcfn = strdup (av[t]);
  1802. X
  1803. X    if (mode != M_NONE) {
  1804. X        doconv = TRUE;
  1805. X        rev_conv = TRUE;
  1806. X        verbose = TRUE;
  1807. X    }
  1808. X
  1809. X    setup_convtable (doconv, rev_conv);
  1810. X
  1811. X    muid = getmuid ();
  1812. X    ruid = getuid ();
  1813. X    isadm = (muid == ruid) || (ruid == 0);
  1814. X
  1815. X    if (mode != M_NONE) {
  1816. X        user_interface (mode, srcfn);
  1817. X        do_exit (0);
  1818. X    }
  1819. X
  1820. X    setuid (getmuid ());
  1821. X
  1822. X    if (retr_msgid) {
  1823. X        retreive_message_id (retr_msgid);
  1824. X        do_exit (0);
  1825. X    }
  1826. X
  1827. X    if (do_respool) {
  1828. X        if (do_init (FALSE) < 0)
  1829. X            exit (_errmsg (1, "Can't init in respool\n"));
  1830. X        respool (FALSE);
  1831. X        do_exit (0);
  1832. X    }
  1833. X    
  1834. X    if ((expire != NULL) || rebuild_active || rebuild_history || check_dbmsiz) {
  1835. X        if (!isadm)
  1836. X            exit (_errmsg (1, "Sorry, admin-mode requires %03d.%03d!\n", muid >> 16, muid & 0xffff));
  1837. X        do_admin ((expire != NULL ? TRUE : FALSE), expire, exphist, rebuild_active, rebuild_history, check_dbmsiz);
  1838. X        do_exit (0);
  1839. X    }
  1840. X    if (ctrlmsg) {
  1841. X        create_control_message (ctrlmsg, isadm);
  1842. X        do_exit (0);
  1843. X    }
  1844. X}
  1845. __END__OF__THIS__FILE__
  1846. if test -f 'INEWS/pit.c' ; then
  1847.   echo 'File INEWS/pit.c already exists, overwriting it'
  1848.   del 'INEWS/pit.c'
  1849. fi
  1850. echo Extracting \"'INEWS/pit.c'\"
  1851. sed "s/^X//" >'INEWS/pit.c' <<'__END__OF__THIS__FILE__'
  1852. X/*
  1853. X * $Log:    pit.c_v $
  1854. X * Revision 1.1  90/08/31  15:35:06  cs
  1855. X * Initial revision
  1856. X * 
  1857. X */
  1858. X# ifndef    LINT
  1859. Xstatic char rcsid[] = "$Id: pit.c_v 1.1 90/08/31 15:35:06 cs Exp $";
  1860. X# endif        LINT
  1861. X# include    <stdio.h>
  1862. X# include    <errno.h>
  1863. X# include    "inews.h"
  1864. X
  1865. Xextern char    *malloc ();
  1866. Xextern char    *strdup ();
  1867. Xextern FILE    *xpopen ();
  1868. X
  1869. Xvoid
  1870. Xpipe_it (cmd)
  1871. Xchar *cmd;
  1872. X{
  1873. X    char    *rcmd;
  1874. X    char    *rfn;
  1875. X    FILE    *pp;
  1876. X    FILE    *fp;
  1877. X    char    *buf;
  1878. X    int    n;
  1879. X
  1880. X    if (!(buf = malloc (512))) {
  1881. X        do_log ("FATAL: Can't alloc for command %s\n", cmd);
  1882. X        return;
  1883. X    }
  1884. X    if (!(rcmd = strdup (cmd))) {
  1885. X        do_log ("FATAL: Can't alloc for command %s\n", cmd);
  1886. X        return;
  1887. X    }
  1888. X    if (!(rfn = malloc (strlen (newsdir) + strlen (realfile) + 6))) {
  1889. X        do_log ("FATAL: Can't malloc in pipe_it(%s)\n", cmd);
  1890. X        return;
  1891. X    }
  1892. X    sprintf (rfn, "%s/%s", newsdir, realfile);
  1893. X    if (!(fp = fopen (rfn, "r"))) {
  1894. X        do_log ("FATAL: Can't open %s\n", realfile);
  1895. X        return;
  1896. X    }
  1897. X    if (!(pp = xpopen (rcmd, "w"))) {
  1898. X        fclose (fp);
  1899. X        do_log ("FATAL: Can't fork command %s\n", rcmd);
  1900. X        return;
  1901. X    }
  1902. X    while (fgets (buf, 500, fp))
  1903. X        if (fputs (buf, pp) == -1) {
  1904. X            do_log ("Broken pipe for %s (%d)?\n", cmd, errno);
  1905. X            break;
  1906. X        }
  1907. X    fclose (fp);
  1908. X    if (n = pclose (pp))
  1909. X        do_log ("Pclose(%s) returned %d\n", cmd, n);
  1910. X    free (rcmd);
  1911. X    free (buf);
  1912. X}
  1913. __END__OF__THIS__FILE__
  1914. if test -f 'INEWS/pmail.c' ; then
  1915.   echo 'File INEWS/pmail.c already exists, overwriting it'
  1916.   del 'INEWS/pmail.c'
  1917. fi
  1918. echo Extracting \"'INEWS/pmail.c'\"
  1919. sed "s/^X//" >'INEWS/pmail.c' <<'__END__OF__THIS__FILE__'
  1920. X/*
  1921. X * $Log:    pmail.c_v $
  1922. X * Revision 1.1  91/09/11  18:17:54  ud
  1923. X * Initial revision
  1924. X * 
  1925. X * 
  1926. X */
  1927. X# ifndef    LINT
  1928. Xstatic char rcsid[] = "$Id: pmail.c_v 1.1 91/09/11 18:17:54 ud Exp $";
  1929. X# endif        LINT
  1930. X# include    <stdio.h>
  1931. X# include    <c8type.h>
  1932. X# include    "inews.h"
  1933. X
  1934. X# ifdef        CAN_MAIL
  1935. Xextern char    *index ();
  1936. Xextern char    *malloc ();
  1937. Xextern char    *rindex ();
  1938. Xextern FILE    *xpopen ();
  1939. X
  1940. Xstatic struct {
  1941. X    char    *text;
  1942. X    int    len;
  1943. X} pattern[] = {
  1944. X    "To: ",        4,
  1945. X    "Cc: ",        4,
  1946. X    "Bcc: ",    5,
  1947. X    NULL,        0
  1948. X};
  1949. X
  1950. Xvoid
  1951. Xsend_private_mail ()
  1952. X{
  1953. X    register charc    *tmp;
  1954. X    register int    t;
  1955. X    charc        *rec;
  1956. X    charc        *cur, *prev;
  1957. X    charc        *path;
  1958. X    char        *pt;
  1959. X    int        len;
  1960. X    char        *ptr, *tptr;
  1961. X    char        *quote;
  1962. X# ifdef        IN_MEMORY
  1963. X    list        *ltmp;
  1964. X# else        /* IN_MEMORY */
  1965. X    int        ch;
  1966. X    FILE        *fp;
  1967. X# endif        /* IN_MEMORY */
  1968. X    FILE        *pp;
  1969. X
  1970. X    if (! crthd)
  1971. X        return;
  1972. X
  1973. X    tmp = head;
  1974. X    prev = NULL;
  1975. X    rec = NULL;
  1976. X    for (tmp = head; tmp; tmp = tmp -> next)
  1977. X        for (t = 0; pattern[t].text; ++t)
  1978. X            if (Strnieql (pattern[t].text, tmp -> text, pattern[t].len)) {
  1979. X                ptr = skip_field (tmp -> text);
  1980. X                if (! (cur = split_fields (ptr, FALSE)))
  1981. X                    break;
  1982. X                if (! prev)
  1983. X                    rec = cur;
  1984. X                else
  1985. X                    prev -> next = cur;
  1986. X                while (cur -> next)
  1987. X                    cur = cur -> next;
  1988. X                prev = cur;
  1989. X            }
  1990. X    if (! rec)
  1991. X        return;
  1992. X    len = strlen (MAILCMD) + 4;
  1993. X    for (tmp = rec; tmp; tmp = tmp -> next)
  1994. X        len += strlen (tmp -> text) + 5;
  1995. X    if (! (ptr = malloc (len))) {
  1996. X        free_field (rec);
  1997. X        return;
  1998. X    }
  1999. X    strcpy (ptr, MAILCMD);
  2000. X    for (tmp = rec; tmp; tmp = tmp -> next) {
  2001. X        if (tptr = index (tmp -> text, '<')) {
  2002. X            strcpy (tmp -> text, tptr + 1);
  2003. X            if (tptr = index (tmp -> text, '>'))
  2004. X                *tptr = '\0';
  2005. X        } else if (tmp -> text[0] == '(') {
  2006. X            if (tptr = rindex (tmp -> text, ')')) {
  2007. X                ++tptr;
  2008. X                while (is8space (*tptr))
  2009. X                    ++tptr;
  2010. X                strcpy (tmp -> text, tptr);
  2011. X            }
  2012. X        } else {
  2013. X            tptr = tmp -> text;
  2014. X            while (*tptr && (! is8space (*tptr)))
  2015. X                ++tptr;
  2016. X            *tptr = '\0';
  2017. X        }
  2018. X        if (tmp -> text[0]) {
  2019. X            if (index (tmp -> text, '\''))
  2020. X                quote = "\"";
  2021. X            else
  2022. X                quote = "'";
  2023. X            strcat (ptr, " ");
  2024. X            strcat (ptr, quote);
  2025. X            strcat (ptr, tmp -> text);
  2026. X            strcat (ptr, quote);
  2027. X        }
  2028. X    }
  2029. X    do_log ("Mail using `%s'\n", ptr);
  2030. X    if (pp = xpopen (ptr, "w")) {
  2031. X        for (tmp = head; tmp; tmp = tmp -> next)
  2032. X            if (Strnicmp (tmp -> text, pattern[2].text, pattern[2].len))
  2033. X                fprintf (pp, "%s\n", tmp -> text);
  2034. X        putc ('\n', pp);
  2035. X# ifdef        IN_MEMORY
  2036. X        for (ltmp = newstmp; ltmp; ltmp = ltmp->next)
  2037. X            fputs (ltmp -> text, pp);
  2038. X# else        /* IN_MEMORY */
  2039. X        if (fp = fopen (newstmp, "r")) {
  2040. X            while ((ch = getc (fp)) != EOF)
  2041. X                putc (ch, pp);
  2042. X            fclose (fp);
  2043. X        }
  2044. X# endif        /* IN_MEMORY */
  2045. X        pclose (pp);
  2046. X    }
  2047. X    free (ptr);
  2048. X    free_field (rec);
  2049. X}
  2050. X# endif        /* CAN_MAIL */
  2051. __END__OF__THIS__FILE__
  2052. exit 0
  2053. : end of shell archive
  2054.  
  2055. -- 
  2056. Frank Kaefer # fkk@stasys.sta.sub.org # Starnberg, Germany
  2057.