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

  1. Xref: sparky de.comp.sources.os9:8 comp.os.os9:1550
  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 Part02/09
  6. Message-ID: <1hafd5INNpsn@stasys.sta.sub.org>
  7. Date: 23 Dec 92 19:41:25 GMT
  8. Sender: news@stasys.sta.sub.org
  9. Followup-To: de.comp.sources.d
  10. Organization: Stasys News Server, Starnberg, Germany
  11. Lines: 1855
  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/part02
  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/RELS                                  (Directory)'
  22. :     'INEWS/achk.c                                 5018 bytes'
  23. :     'INEWS/adm.c                                   740 bytes'
  24. :     'INEWS/alias.c                                1678 bytes'
  25. :     'INEWS/app.c                                  3437 bytes'
  26. :     'INEWS/arc.c                                  3250 bytes'
  27. :     'INEWS/build.c                                4973 bytes'
  28. :     'INEWS/ccan.c                                 2678 bytes'
  29. :     'INEWS/cchk.c                                 5484 bytes'
  30. :     'INEWS/cnew.c                                 3610 bytes'
  31. :     'INEWS/crct.c                                 2437 bytes'
  32. :     'INEWS/crm.c                                  1831 bytes'
  33. :     'INEWS/crth.c                                 2723 bytes'
  34. if test -d 'INEWS/RELS' ; then
  35.   echo 'Directory INEWS/RELS already exists'
  36. else
  37.   echo Make directory \"'INEWS/RELS'\"
  38.   makdir 'INEWS/RELS'
  39. fi
  40. if test -f 'INEWS/achk.c' ; then
  41.   echo 'File INEWS/achk.c already exists, overwriting it'
  42.   del 'INEWS/achk.c'
  43. fi
  44. echo Extracting \"'INEWS/achk.c'\"
  45. sed "s/^X//" >'INEWS/achk.c' <<'__END__OF__THIS__FILE__'
  46. X/*
  47. X * $Log:    achk.c_v $
  48. X * Revision 1.3  91/12/26  13:35:42  ud
  49. X * Added a feature to just forward articles with a maximum size
  50. X * 
  51. X * Revision 1.2  91/05/22  13:11:51  ud
  52. X * Added better junk handling, added 2nd flag to skip newsgroups in active
  53. X * file (they are present, but have no spooldirectory)
  54. X * 
  55. X * Revision 1.1  90/08/31  15:31:48  cs
  56. X * Initial revision
  57. X * 
  58. X */
  59. X# ifndef    LINT
  60. Xstatic char rcsid[] = "$Id: achk.c_v 1.3 91/12/26 13:35:42 ud Exp $";
  61. X# endif        LINT
  62. X# include    "inews.h"
  63. X
  64. Xextern char    *malloc ();
  65. Xextern char    *rindex ();
  66. X
  67. Xint
  68. Xcheck_active ()
  69. X{
  70. X    register charc    *act;
  71. X    charc        *prev;
  72. X    charc        *tmp, *t2;
  73. X    int        valid;
  74. X    int        isok;
  75. X    register active    *atmp;
  76. X    char        *junkbuf;
  77. X    char        *ptr;
  78. X    char        *comment[4];
  79. X    int        maxlimit;
  80. X    int        is_junked;
  81. X
  82. X    act = isctrl ? isctrl : ngs;
  83. X    t2 = NULL;
  84. X# ifdef        NO_JUNK
  85. X    valid = FALSE;
  86. X# else        /* NO_JUNK */
  87. X    valid = TRUE;
  88. X# endif        /* NO_JUNK */
  89. X    is_junked = 0;
  90. X    maxlimit = -2;
  91. X    while (act) {
  92. X# ifndef    HASH_SEARCH
  93. X        atmp = hact;
  94. X        while (atmp)
  95. X            if (Strieql (act->text, atmp->grp))
  96. X                break;
  97. X            else
  98. X                atmp = atmp->next;
  99. X# else        /* HASH_SEARCH */
  100. X        atmp = find_active (act -> text);
  101. X# endif        /* HASH_SEARCH */
  102. X        if (!atmp) {
  103. X            if (junkbuf = malloc (strlen (act->text) + strlen (NG_JUNK) + 4)) {
  104. X                strcpy (junkbuf, act->text);
  105. X                strcat (junkbuf, ".");
  106. X                strcat (junkbuf, NG_JUNK);
  107. X                do {
  108. X# ifndef    HASH_SEARCH
  109. X                    atmp = hact;
  110. X                    while (atmp)
  111. X                        if (Strieql (atmp->grp, junkbuf))
  112. X                            break;
  113. X                        else
  114. X                            atmp = atmp->next;
  115. X# else        /* HASH_SEARCH */
  116. X                    atmp = find_active (junkbuf);
  117. X# endif        /* HASH_SEARCH */
  118. X                    if (!atmp) {
  119. X                        if (ptr = rindex (junkbuf, '.'))
  120. X                            *ptr = '_';
  121. X                        if (ptr = rindex (junkbuf, '.'))
  122. X                            strcpy (ptr + 1, NG_JUNK);
  123. X                    }
  124. X                } while ((!atmp) && ptr);
  125. X                if (!atmp) {
  126. X                    free (junkbuf);
  127. X                    junkbuf = NULL;
  128. X                }
  129. X            }
  130. X            if (!junkbuf) {
  131. X# ifndef    HASH_SEARCH
  132. X                atmp = hact;
  133. X                while (atmp)
  134. X                    if (Strieql (atmp->grp, NG_JUNK))
  135. X                        break;
  136. X                    else
  137. X                        atmp = atmp->next;
  138. X# else        /* HASH_SEARCH */
  139. X                atmp = find_active (NG_JUNK);
  140. X# endif        /* HASH_SEARCH */
  141. X            }
  142. X            if (atmp)
  143. X                for (tmp = isctrl ? isctrl : ngs; tmp; tmp = tmp -> next)
  144. X                    if (tmp != act)
  145. X                        if (! strcmp (tmp -> text, atmp -> grp)) {
  146. X                            free (junkbuf);
  147. X                            junkbuf = NULL;
  148. X                            atmp = NULL;
  149. X                            break;
  150. X                        }
  151. X            if (atmp && (valid || junkbuf)) {
  152. X                do_log ("Newsgroup '%s' not in active, moved to %s\n", act->text, junkbuf ? junkbuf : NG_JUNK);
  153. X                if (!isctrl) {
  154. X                    ++is_junked;
  155. X                    if (!junkbuf) {
  156. X                        strcpy (act->text, NG_JUNK);
  157. X                        valid = FALSE;
  158. X                    } else {
  159. X                        free (act->text);
  160. X                        act->text = junkbuf;
  161. X                        junkbuf = NULL;
  162. X                    }
  163. X                } else if (junkbuf) {
  164. X                    free (junkbuf);
  165. X                    junkbuf = NULL;
  166. X                }
  167. X            } else
  168. X                atmp = NULL;
  169. X        }
  170. X        isok = TRUE;
  171. X        if (atmp) {
  172. X            if (atmp->aflag[0] == M_MOD) {
  173. X                if (!get_header_line (H_APPROVED))
  174. X                    isok = FALSE;
  175. X            } else if (crthd && (atmp -> aflag[0] == M_READONLY))
  176. X                isok = FALSE;
  177. X            if (atmp->aflag[1] == M_IGNORE)
  178. X                isok = FALSE;
  179. X        }
  180. X        if ((! atmp) || (! isok)) {
  181. X            if (atmp && crthd && user && (atmp -> aflag[0] == M_READONLY)) {
  182. X                comment[0] = "You tried to post to a group which is read-only\n";
  183. X                comment[1] = "Your article follows:\n";
  184. X                comment[2] = NULL;
  185. X                mail_to (user, NULL, "This group is read-only: ", ngs -> text, newstmp, comment);
  186. X            }
  187. X            if (!isctrl) {
  188. X                tmp = act;
  189. X                act = act->next;
  190. X                if (!t2)
  191. X                    ngs = ngs->next;
  192. X                else
  193. X                    t2->next = act;
  194. X                free (tmp->text);
  195. X                free ((char *) tmp);
  196. X            } else {
  197. X                t2 = act;
  198. X                act = act->next;
  199. X            }
  200. X        } else {
  201. X            atmp->changed = TRUE;
  202. X            atmp->high++;
  203. X            if (maxlimit != -1)
  204. X                if (atmp -> kblimit == -1)
  205. X                    maxlimit = -1;
  206. X                else if ((maxlimit == -2) || (atmp -> kblimit < maxlimit))
  207. X                    maxlimit = atmp -> kblimit;
  208. X            act->nr = atmp->high;
  209. X            t2 = act;
  210. X            act = act->next;
  211. X        }
  212. X    }
  213. X
  214. X    if ((maxlimit >= 0) && ((maxlimit << 10) < artsize)) {
  215. X        do_log ("Blocked due too large article (%d kBytes)\n", (artsize >> 10) + 1);
  216. X        block_forward = TRUE;
  217. X    }
  218. X
  219. X    if ((!isctrl) && (!ngs)) {
  220. X        do_log ("No more newsgroups after check_active(), aborted.\n");
  221. X        do_exit (0);
  222. X    }
  223. X
  224. X# ifndef    NO_JUNK
  225. X    if ((!isctrl) && (!valid)) {
  226. X# if        1
  227. X        while (is_junked-- > 0) {
  228. X            for (t2 = ngs; t2 -> next; t2 = t2 -> next)
  229. X                ;
  230. X            prev = NULL;
  231. X            for (act = ngs; act; act = act -> next)
  232. X                if (((ptr = rindex (act -> text, '.')) && Strieql (ptr + 1, NG_JUNK)) || Strieql (act -> text, NG_JUNK))
  233. X                    break;
  234. X                else
  235. X                    prev = act;
  236. X            if (act && (act != t2)) {
  237. X                if (! prev)
  238. X                    ngs = ngs -> next;
  239. X                else
  240. X                    prev -> next = act ->next;
  241. X                act -> next = NULL;
  242. X                t2 -> next = act;
  243. X            }
  244. X        }
  245. X# else
  246. X        act = ngs;
  247. X        t2 = NULL;
  248. X        while (act)
  249. X            if (Strieql (act->text, NG_JUNK))
  250. X                break;
  251. X            else {
  252. X                t2 = act;
  253. X                act = act->next;
  254. X            }
  255. X        if (act && act->next) {
  256. X            if (t2)
  257. X                t2->next = act->next;
  258. X            else
  259. X                ngs = ngs->next;
  260. X            for (t2 = ngs; t2->next; t2 = t2->next)
  261. X                ;
  262. X            t2->next = act;
  263. X            act->next = NULL;
  264. X        }
  265. X# endif
  266. X    }
  267. X# endif        /* NO_JUNK */
  268. X
  269. X    return (0);
  270. X}
  271. __END__OF__THIS__FILE__
  272. if test -f 'INEWS/adm.c' ; then
  273.   echo 'File INEWS/adm.c already exists, overwriting it'
  274.   del 'INEWS/adm.c'
  275. fi
  276. echo Extracting \"'INEWS/adm.c'\"
  277. sed "s/^X//" >'INEWS/adm.c' <<'__END__OF__THIS__FILE__'
  278. X/*
  279. X * $Log:    adm.c_v $
  280. X * Revision 1.2  91/05/22  13:32:15  ud
  281. X * Added check_history_size() for ndbm files (--> file segment list)
  282. X * 
  283. X * Revision 1.1  90/12/01  15:51:09  ud
  284. X * Initial revision
  285. X * 
  286. X */
  287. X# ifndef    LINT
  288. Xstatic char rcsid[] = "$Id: adm.c_v 1.2 91/05/22 13:32:15 ud Exp $";
  289. X# endif        LINT
  290. X# include    "inews.h"
  291. X
  292. Xvoid
  293. Xdo_admin (doexp, delart, delhist, ra, rh, cd)
  294. Xint doexp;
  295. Xchar *delart, *delhist;
  296. Xint ra;
  297. Xint rh;
  298. Xint cd;
  299. X{
  300. X
  301. X    if (do_init (TRUE) < 0)
  302. X        exit (_errmsg (1, "Can't init in expire\n"));
  303. X    if (doexp)
  304. X        do_expire (delart, delhist);
  305. X    if (ra)
  306. X        rebuild_active_file ();
  307. X    if (rh)
  308. X        rebuild_history ();
  309. X# ifdef        USE_NDBM
  310. X    if (cd)
  311. X        check_history_size ();
  312. X# endif        /* USE_NDBM */
  313. X    nunlock ();
  314. X    respool (FALSE);
  315. X    do_exit (0);
  316. X}
  317. X
  318. __END__OF__THIS__FILE__
  319. if test -f 'INEWS/alias.c' ; then
  320.   echo 'File INEWS/alias.c already exists, overwriting it'
  321.   del 'INEWS/alias.c'
  322. fi
  323. echo Extracting \"'INEWS/alias.c'\"
  324. sed "s/^X//" >'INEWS/alias.c' <<'__END__OF__THIS__FILE__'
  325. X/*
  326. X * $Log:    alias.c_v $
  327. X * Revision 1.1  90/08/31  15:31:51  cs
  328. X * Initial revision
  329. X * 
  330. X */
  331. X# ifndef    LINT
  332. Xstatic char rcsid[] = "$Id: alias.c_v 1.1 90/08/31 15:31:51 cs Exp $";
  333. X# endif        LINT
  334. X# include    <modes.h>
  335. X# include    "inews.h"
  336. X
  337. Xextern char    *malloc ();
  338. X
  339. Xvoid
  340. Xdelete_dup_charc (list)
  341. Xcharc *list;
  342. X{
  343. X    register charc    *cur, *prev, *tmp;
  344. X
  345. X    if (!list)
  346. X        return;
  347. X    cur = list;
  348. X    while (cur) {
  349. X        prev = cur;
  350. X        tmp = cur->next;
  351. X        while (tmp)
  352. X            if (Strieql (tmp->text, cur->text))
  353. X                break;
  354. X            else {
  355. X                prev = tmp;
  356. X                tmp = tmp->next;
  357. X            }
  358. X        if (tmp) {
  359. X            prev->next = tmp->next;
  360. X            free (tmp->text);
  361. X            free ((char *) tmp);
  362. X        } else
  363. X            cur = cur->next;
  364. X    }
  365. X}
  366. X
  367. Xint
  368. Xalias_newsgroups ()
  369. X{
  370. X    char        *buf;
  371. X    int        fd;
  372. X    int        n;
  373. X    register charc    *tmp, *prev;
  374. X    char        *new;
  375. X    charc        *newng, *app;
  376. X    int        didit;
  377. X
  378. X    if (!ngs)
  379. X        return (FALSE);
  380. X    if ((fd = open (ALIAS_FILE, S_IREAD)) < 0)
  381. X        return (FALSE);
  382. X    didit = FALSE;
  383. X    catlines = TRUE;
  384. X    while (buf = readbuf (fd, & n)) {
  385. X        if ((n == 1) || (buf[0] == '#'))
  386. X            continue;
  387. X        buf[n - 1] = '\0';
  388. X        new = skipc (buf, '\0');
  389. X        tmp = ngs;
  390. X        prev = NULL;
  391. X        while (tmp)
  392. X            if (Strieql (tmp->text, buf))
  393. X                break;
  394. X            else {
  395. X                prev = tmp;
  396. X                tmp = tmp->next;
  397. X            }
  398. X        if (!tmp)
  399. X            continue;
  400. X        didit = TRUE;
  401. X        if (!*new) {
  402. X            if (prev)
  403. X                prev->next = tmp->next;
  404. X            else
  405. X                ngs = ngs->next;
  406. X        } else if (newng = split_fields (new, TRUE)) {
  407. X            if (prev) {
  408. X                prev->next = newng;
  409. X                app = prev;
  410. X            } else {
  411. X                ngs = newng;
  412. X                app = ngs;
  413. X            }
  414. X            while (app->next)
  415. X                app = app->next;
  416. X            app->next = tmp->next;
  417. X        }
  418. X        free (tmp->text);
  419. X        free ((char *) tmp->text);
  420. X    }
  421. X    catlines = FALSE;
  422. X    close (fd);
  423. X    if (didit)
  424. X        delete_dup_charc (ngs);
  425. X    return (didit);
  426. X}
  427. __END__OF__THIS__FILE__
  428. if test -f 'INEWS/app.c' ; then
  429.   echo 'File INEWS/app.c already exists, overwriting it'
  430.   del 'INEWS/app.c'
  431. fi
  432. echo Extracting \"'INEWS/app.c'\"
  433. sed "s/^X//" >'INEWS/app.c' <<'__END__OF__THIS__FILE__'
  434. X/*
  435. X * $Log:    app.c_v $
  436. X * Revision 1.1  90/08/31  15:31:55  cs
  437. X * Initial revision
  438. X * 
  439. X */
  440. X# ifndef    LINT
  441. Xstatic char rcsid[] = "$Id: app.c_v 1.1 90/08/31 15:31:55 cs Exp $";
  442. X# endif        LINT
  443. X# include    "inews.h"
  444. X
  445. Xextern char    *malloc ();
  446. Xextern char    *strdup ();
  447. X
  448. Xvoid
  449. Xcheck_approved ()
  450. X{
  451. X    register int    t;
  452. X    register charc    *t2;
  453. X    register char    *ptr;
  454. X    char        *recs;
  455. X    register charc    *tmp;
  456. X    char        *from, *sender;
  457. X    active        *atmp;
  458. X    sys        *stmp;
  459. X    char        *comment[10];
  460. X
  461. X    tmp = ngs;
  462. X    while (tmp) {
  463. X# ifndef    HASH_SEARCH
  464. X        atmp = hact;
  465. X        while (atmp)
  466. X            if (Strieql (atmp->grp, tmp->text))
  467. X                break;
  468. X            else
  469. X                atmp = atmp->next;
  470. X# else        /* HASH_SEARCH */
  471. X        atmp = find_active (tmp -> text);
  472. X# endif        /* HASH_SEARCH */
  473. X        if (atmp && (atmp->aflag[0] == M_MOD))
  474. X            break;
  475. X        tmp = tmp->next;
  476. X    }
  477. X    if ((!tmp) || (!atmp) || (!atmp->moderator))
  478. X        return;
  479. X    if (tmp = get_header_line (H_APPROVED))
  480. X        return;
  481. X    sender = find_address_hl (H_SENDER);
  482. X    from = find_address_hl (H_FROM);
  483. X    if (!(sender || from))
  484. X            return;
  485. X    if (atmp->moderator)
  486. X        for (t=0;atmp->moderator[t];++t)
  487. X            if (from && (Strieql (atmp->moderator[t], from)))
  488. X                break;
  489. X            else if (sender && (Strieql (atmp->moderator[t], sender)))
  490. X                break;
  491. X    if ((!atmp->moderator) || (!atmp->moderator[t])) {
  492. X        do_log ("Article %s from wrong sender (%s, %s) in %s\n",
  493. X            get_msgid (),
  494. X            from ? from : "[no From]",
  495. X            sender ? sender : "[no Sender]",
  496. X            atmp->grp);
  497. X        stmp = hsys;
  498. X        while (stmp) {
  499. X            stmp->fwd = FALSE;
  500. X            stmp = stmp->next;
  501. X        }
  502. X# ifdef        NO_MAIL_TO_MODERATOR
  503. X        if (recs = strdup (atmp->grp)) {
  504. X            ptr = recs;
  505. X            while (*ptr)
  506. X                if (*ptr == '.')
  507. X                    *ptr++ = '-';
  508. X                else
  509. X                    ++ptr;
  510. X            comment[0] = "A message had been posted to the moderated group,\n";
  511. X            comment[1] = "where you are listen as the moderator, the submitter was:\n";
  512. X            comment[2] = sender ? sender : (from ? from : "[unknown]");
  513. X            comment[3] = ". The submisson took place in '";
  514. X            comment[4] = atmp->grp;
  515. X            comment[5] = "'.\n";
  516. X            comment[6] = "I hope you know how to handle this mail\n";
  517. X            comment[7] = NULL;
  518. X            mail_to (recs, from, "Non-approved article in moderated group by", from ? from : (sender ? sender : (from ? from : "[unknown]")), newstmp, comment);
  519. X        }
  520. X# endif        /* NO_MAIL_TO_MODERATOR */
  521. X        comment[0] = "You tried to post a message in a moderated group,\n";
  522. X        comment[1] = "Where you aren't the moderator; the group was '";
  523. X        comment[2] = atmp->grp;
  524. X        comment[3] = "'.\n";
  525. X# ifdef        NO_MAIL_TO_MODERATOR
  526. X        if (recs)
  527. X            comment[4] = "Your article had been forwarded to the moderator.\n";
  528. X        else
  529. X            comment[4] = "Please send your article directly via mail to the moderator.\n";
  530. X# else        /* NO_MAIL_TO_MODERATOR */
  531. X        comment[4] = "If you wish to send this to the moderator, send it via mail\n";
  532. X# endif        /* NO_MAIL_TO_MODERATOR */
  533. X        comment[5] = NULL;
  534. X        mail_to (from ? from : sender, NULL, "This is a moderated group!", NULL, recs ? NULL : newstmp, comment);
  535. X        if (recs)
  536. X            free (recs);
  537. X    } else {
  538. X        if (tmp = (charc *) malloc (sizeof (charc))) {
  539. X            tmp->next = NULL;
  540. X            if (tmp->text = malloc (strlen (atmp->moderator[t]) + strlen (hlines[H_APPROVED] + 2) + 6)) {
  541. X                sprintf (tmp->text, "%s %s@%s",
  542. X                    hlines[H_APPROVED] + 2,
  543. X                    news_owner,
  544. X                    fhost);
  545. X                if (!head)
  546. X                    head = tmp;
  547. X                else {
  548. X                    t2 = head;
  549. X                    while (t2->next)
  550. X                        t2 = t2->next;
  551. X                    t2->next = tmp;
  552. X                }
  553. X                sort_header (FALSE);
  554. X            } else
  555. X                free ((char *) tmp);
  556. X        }
  557. X    }
  558. X    if (from)
  559. X        free (from);
  560. X    if (sender)
  561. X        free (sender);
  562. X}
  563. __END__OF__THIS__FILE__
  564. if test -f 'INEWS/arc.c' ; then
  565.   echo 'File INEWS/arc.c already exists, overwriting it'
  566.   del 'INEWS/arc.c'
  567. fi
  568. echo Extracting \"'INEWS/arc.c'\"
  569. sed "s/^X//" >'INEWS/arc.c' <<'__END__OF__THIS__FILE__'
  570. X/*
  571. X * $Log:    arc.c_v $
  572. X * Revision 1.1  90/10/26  14:20:31  ud
  573. X * Initial revision
  574. X * 
  575. X */
  576. X# ifndef    LINT
  577. Xstatic char rcsid[] = "$Id: arc.c_v 1.1 90/10/26 14:20:31 ud Exp $";
  578. X# endif        LINT
  579. X# include    <modes.h>
  580. X# include    <errno.h>
  581. X# include    "inews.h"
  582. X
  583. Xextern char    *malloc ();
  584. Xextern char    *strdup ();
  585. X
  586. Xstatic void
  587. Xdo_copy (fdi, fdo)
  588. Xregister int fdi, fdo;
  589. X{
  590. X    register int    n;
  591. X    register int    size;
  592. X    register char    *buf;
  593. X    register char    smallbuf[128];
  594. X
  595. X    size = 5000;
  596. X    while (size >= 1000)
  597. X        if (buf = malloc (size + 20))
  598. X            break;
  599. X        else
  600. X            size -= 1000;
  601. X    if (size < 1000) {
  602. X        size = 100;
  603. X        buf = smallbuf;
  604. X    }
  605. X    while ((n = read (fdi, buf, size)) > 0)
  606. X        write (fdo, buf, n);
  607. X    if (size > 100)
  608. X        free (buf);
  609. X}
  610. X
  611. Xarchive *
  612. Xsetup_archive ()
  613. X{
  614. X    int    fd;
  615. X    char    *buf;
  616. X    int    n;
  617. X    archive    *ahead, *cur, *tmp;
  618. X    char    *group, *destination, *prefix;
  619. X
  620. X    ahead = NULL;
  621. X    if ((fd = open (ARCHIVE_FILE, S_IREAD)) < 0)
  622. X        return (NULL);
  623. X    catlines = TRUE;
  624. X    while (buf = readbuf (fd, & n)) {
  625. X        if ((n == 1) || (buf[0] == '#'))
  626. X            continue;
  627. X        buf[n - 1] = '\0';
  628. X        group = buf;
  629. X        destination = skipc (group, '\0');
  630. X        prefix = skipc (destination, '\0');
  631. X        if (tmp = (archive *) malloc (sizeof (archive)))
  632. X            if (tmp->grp = strdup (group))
  633. X                if (tmp->dest = strdup (destination)) {
  634. X                    tmp->len = strlen (tmp->grp);
  635. X                    if (prefix && *prefix)
  636. X                        tmp->prefix = strdup (prefix);
  637. X                    else
  638. X                        tmp->prefix = NULL;
  639. X                    tmp->next = NULL;
  640. X                    if (!ahead)
  641. X                        ahead = tmp;
  642. X                    else
  643. X                        cur->next = tmp;
  644. X                    cur = tmp;
  645. X                } else {
  646. X                    free (tmp->grp);
  647. X                    free ((char *) tmp);
  648. X                }
  649. X            else
  650. X                free ((char *) tmp);
  651. X    }
  652. X    catlines = FALSE;
  653. X    close (fd);
  654. X    return (ahead);
  655. X}
  656. X
  657. Xvoid
  658. Xfree_archive (ahead)
  659. Xarchive *ahead;
  660. X{
  661. X    register archive    *tmp, *cur;
  662. X
  663. X    cur = ahead;
  664. X    while (cur) {
  665. X        tmp = cur;
  666. X        cur = cur->next;
  667. X        free (tmp->grp);
  668. X        free (tmp->dest);
  669. X        if (tmp->prefix)
  670. X            free (tmp->prefix);
  671. X    }
  672. X}
  673. X
  674. Xvoid
  675. Xdo_archive (fn, arc)
  676. Xchar *fn;
  677. Xarchive *arc;
  678. X{
  679. X    char    *fullfn;
  680. X    char    *destfn;
  681. X    int    fd, fdo;
  682. X    int    n;
  683. X    int    id;
  684. X
  685. X    if (!(arc && fn))
  686. X        return;
  687. X    if (!(fullfn = create_fn (fn))) {
  688. X        do_log ("FATAL: Can't create full-filename in do_archive().\n");
  689. X        return;
  690. X    }
  691. X    if (!(destfn = malloc (strlen (arc->dest) + 40))) {
  692. X        do_log ("FATAL: Can't malloc for dest in do_archive().\n");
  693. X        free (fullfn);
  694. X        return;
  695. X    }
  696. X    strcpy (destfn, arc->dest);
  697. X    strcat (destfn, "/.seq");
  698. X    do {
  699. X        if ((fd = open (destfn, S_IREAD | S_IWRITE | S_ISHARE)) < 0) {
  700. X            if (errno == E_PNNF) {
  701. X                fd = create (destfn, S_IWRITE | S_ISHARE, 03);
  702. X                id = 1;
  703. X            }
  704. X        } else {
  705. X            read (fd, &id, sizeof (int));
  706. X            lseek (fd, 0, 0);
  707. X        }
  708. X        if ((fd < 0) && (errno == E_SHARE))
  709. X            sleep (1);
  710. X        else
  711. X            break;
  712. X    } while (fd < 0);
  713. X    if (fd != -1) {
  714. X        n = id + 1;
  715. X        write (fd, &n, sizeof (int));
  716. X        close (fd);
  717. X    }
  718. X    if (arc->prefix && *arc->prefix)
  719. X        sprintf (destfn, "%s/%s.%06d", arc->dest, arc->prefix, id);
  720. X    else
  721. X        sprintf (destfn, "%s/%06d", arc->dest, id);
  722. X    if ((fd = open (fullfn, S_IREAD)) != -1) {
  723. X        if ((fdo = create (destfn, S_IWRITE | S_ISIZE, 013, ((n = _gs_size (fd)) > 0) ? n : 4096)) != -1) {
  724. X            do_copy (fd, fdo);
  725. X            close (fdo);
  726. X        } else
  727. X            do_log ("Can't create %s for archive (%d).\n", destfn, errno);
  728. X        close (fd);
  729. X    } else
  730. X        do_log ("Can't read %s for archive (%d).\n", fullfn, errno);
  731. X    free (fullfn);
  732. X    free (destfn);
  733. X}
  734. __END__OF__THIS__FILE__
  735. if test -f 'INEWS/build.c' ; then
  736.   echo 'File INEWS/build.c already exists, overwriting it'
  737.   del 'INEWS/build.c'
  738. fi
  739. echo Extracting \"'INEWS/build.c'\"
  740. sed "s/^X//" >'INEWS/build.c' <<'__END__OF__THIS__FILE__'
  741. X/*
  742. X * $Log:    build.c_v $
  743. X * Revision 1.2  90/12/01  15:43:42  ud
  744. X * Added rebuild_history() to convert from old format to new
  745. X * hashing format; Rebuild from articles have to be done later
  746. X * 
  747. X * Revision 1.1  90/08/31  15:31:59  cs
  748. X * Initial revision
  749. X * 
  750. X */
  751. X# ifndef    LINT
  752. Xstatic char rcsid[] = "$Id: build.c_v 1.2 90/12/01 15:43:42 ud Exp $";
  753. X# endif        LINT
  754. X# include    <stdio.h>
  755. X# include    <c8type.h>
  756. X# include    <modes.h>
  757. X# include    <dir.h>
  758. X# include    "inews.h"
  759. X# include    "hist.h"
  760. X
  761. Xextern char    *malloc ();
  762. Xextern char    *strdup ();
  763. X
  764. Xstatic void
  765. Xbuild (at)
  766. Xactive *at;
  767. X{
  768. X    int        min, max, n;
  769. X    DIR        *dp;
  770. X    struct direct    *ent;
  771. X    char        *path;
  772. X
  773. X    if (!(path = strdup (at->grp)))
  774. X        return;
  775. X    make_fn (path);
  776. X    if (!(dp = opendir (path))) {
  777. X        at->low = at->high;
  778. X        free (path);
  779. X        return;
  780. X    }
  781. X    min = -1;
  782. X    max = -1;
  783. X    while (ent = readdir (dp)) {
  784. X        if (!is8digit (ent->d_name[0]))
  785. X            continue;
  786. X        n = atoi (ent->d_name);
  787. X        if (min < 0) {
  788. X            min = n;
  789. X            max = n;
  790. X        } else {
  791. X            if (min > n)
  792. X                min = n;
  793. X            if (max < n)
  794. X                max = n;
  795. X        }
  796. X    }
  797. X    closedir (dp);
  798. X    if (min < 0) {
  799. X        min = at->high;
  800. X        max = at->high;
  801. X    }
  802. X    if (max < min)
  803. X        max = min;
  804. X    do_log ("rebuild %s (%d, %d) --> (%d, %d)\n", at->grp,
  805. X        at->low, at->high, min, max);
  806. X    at->low = min;
  807. X    at->high = max;
  808. X}
  809. X
  810. Xvoid
  811. Xrebuild_active_file ()
  812. X{
  813. X    active    *atmp;
  814. X    charc    *tmp;
  815. X
  816. X    if ((! hact) && (read_active () < 0)) {
  817. X        catlines = FALSE;
  818. X        do_log ("Can't read active file in rebuild\n");
  819. X        return;
  820. X    }
  821. X    act_rewrite = TRUE;
  822. X    if (chdir (newsdir) < 0) {
  823. X        do_log ("Can't chdir to %s in rebuild\n", newsdir);
  824. X        return;
  825. X    }
  826. X    atmp = hact;
  827. X    while (atmp) {
  828. X        if (ngs) {
  829. X            tmp = ngs;
  830. X            while (tmp)
  831. X                if (_cmpnam (atmp->grp, tmp->text, strlen (tmp->text)) == 0)
  832. X                    break;
  833. X                else
  834. X                    tmp = tmp->next;
  835. X            if (!tmp) {
  836. X                atmp = atmp->next;
  837. X                continue;
  838. X            }
  839. X        }
  840. X        build (atmp);
  841. X        atmp = atmp->next;
  842. X    }
  843. X    if (chdir (newslib) < 0) {
  844. X        do_log ("Can't chdir to %s in rebuild\n", newsdir);
  845. X        return;
  846. X    }
  847. X    if (restore_active () < 0) {
  848. X        do_log ("Can't restore active file in rebuild\n");
  849. X        return;
  850. X    }
  851. X}
  852. X
  853. Xvoid
  854. Xrebuild_history ()
  855. X{
  856. X# ifndef    USE_NDBM
  857. X    int        fd;
  858. X    DIR        *dp;
  859. X    struct direct    *ent;
  860. X    charc        *head, *cur, *tmp;
  861. X    int        err;
  862. X    char        *buf;
  863. X    char        *ptmp;
  864. X    register char    *ptr;
  865. X    register int    t;
  866. X    char        sav;
  867. X    FILE        *fp;
  868. X
  869. X    if (!(buf = malloc (1024))) {
  870. X        do_log ("Can't alloc in rebuild_history()\n");
  871. X        return;
  872. X    }
  873. X    if (chdir (HIST_DIR) < 0) {
  874. X        do_log ("Can't chdir to %s (errno %d\n", HIST_DIR, errno);
  875. X        return;
  876. X    }
  877. X    head = NULL;
  878. X    cur = NULL;
  879. X    if (!(dp = opendir ("."))) {
  880. X        do_log ("Can't read %s (errno %d)\n", HIST_DIR, errno);
  881. X        chdir (newslib);
  882. X        return;
  883. X    }
  884. X    err = 0;
  885. X    while (ent = readdir (dp)) {
  886. X        if ((ent->d_name[0] == '.') || isdigit (ent->d_name[0]))
  887. X            continue;
  888. X        if (!(tmp = (charc *) malloc (sizeof (charc)))) {
  889. X            ++err;
  890. X            break;
  891. X        }
  892. X        if (!(tmp->text = malloc (80))) {
  893. X            free ((char *) tmp);
  894. X            ++err;
  895. X            break;
  896. X        }
  897. X        strcpy (tmp->text, ent->d_name);
  898. X        tmp->next = NULL;
  899. X        if (!cur)
  900. X            head = tmp;
  901. X        else
  902. X            cur->next = tmp;
  903. X        cur = tmp;
  904. X    }
  905. X    closedir (dp);
  906. X    if (err) {
  907. X        do_log ("Error during collecting history-files, aborted\n");
  908. X        chdir (newslib);
  909. X        return;
  910. X    }
  911. X    if (head) {
  912. X        for (tmp = head, t = 0; tmp; tmp = tmp->next) {
  913. X            sprintf (buf, "%06d_conv", t);
  914. X            if (rename (tmp->text, buf) != 0) {
  915. X                ++err;
  916. X                break;
  917. X            }
  918. X            sprintf (tmp->text, "%s/%s", HIST_DIR, buf);
  919. X            ++t;
  920. X        }
  921. X        if (chdir (newslib) < 0) {
  922. X            do_log ("Can't chdir back to %s (%d)\n", newslib, errno);
  923. X            return;
  924. X        }
  925. X        if (err) {
  926. X            do_log ("Problems during renameing of files, aborted\n");
  927. X            return;
  928. X        }
  929. X        for (tmp = head; tmp; tmp = tmp->next) {
  930. X            if (!(fp = fopen (tmp->text, "r"))) {
  931. X                ++err;
  932. X                continue;
  933. X            }
  934. X            while (fgets (buf, 1000, fp)) {
  935. X                ptmp = skipn (buf, '\0');
  936. X                ptr = ptmp;
  937. X                while (*ptr && (!is8space (*ptr)))
  938. X                    ++ptr;
  939. X                if (!*ptr)
  940. X                    continue;
  941. X                sav = *ptr;
  942. X                *ptr = '\0';
  943. X                if ((fd = open_hist (ptmp, S_IREAD | S_IWRITE)) != -1) {
  944. X                    if (lseek (fd, 0, 2) != -1) {
  945. X                        *ptr = sav;
  946. X                        do {
  947. X                            write (fd, buf, strlen (buf));
  948. X                            if (buf[strlen (buf) - 1] != '\n')
  949. X                                if (!fgets (buf, 1000, fp))
  950. X                                    break;
  951. X                        } while (buf[strlen (buf) - 1] != '\n');
  952. X                    }
  953. X                    close (fd);
  954. X                } else
  955. X                    ++err;
  956. X            }
  957. X            fclose (fp);
  958. X            if (!err)
  959. X                unlink (tmp->text);
  960. X        }
  961. X        if (err)
  962. X            do_log ("Error during reformating old entries\n");
  963. X        tmp = head;
  964. X        while (tmp) {
  965. X            cur = tmp;
  966. X            tmp = tmp->next;
  967. X            free (cur->text);
  968. X            free ((char *) cur);
  969. X        }
  970. X    } else {
  971. X        chdir (newslib);
  972. X        do_log ("rebuild_history currently not implemented!\n");
  973. X    }
  974. X    if (chdir (HIST_DIR) < 0) {
  975. X        do_log ("Fatal: Can't rechange to %s\n", HIST_DIR);
  976. X        return;
  977. X    }
  978. X    if (!err)
  979. X        if (dp = opendir (".")) {
  980. X            while (ent = readdir (dp)) {
  981. X                if ((ent->d_name[0] == '.') || is8digit (ent->d_name[0]))
  982. X                    continue;
  983. X                sprintf (buf, "fsort %s", ent->d_name);
  984. X                if (xshell (buf))
  985. X                    ++err;
  986. X            }
  987. X            closedir (dp);
  988. X        }
  989. X    free (buf);
  990. X# else        /* USE_NDBM */
  991. X    do_log ("rebuild_history for dbm currently not implemented!\n");
  992. X# endif        /* USE_NDBM */
  993. X}
  994. __END__OF__THIS__FILE__
  995. if test -f 'INEWS/ccan.c' ; then
  996.   echo 'File INEWS/ccan.c already exists, overwriting it'
  997.   del 'INEWS/ccan.c'
  998. fi
  999. echo Extracting \"'INEWS/ccan.c'\"
  1000. sed "s/^X//" >'INEWS/ccan.c' <<'__END__OF__THIS__FILE__'
  1001. X/*
  1002. X * $Log:    ccan.c_v $
  1003. X * Revision 1.3  91/05/22  13:16:43  ud
  1004. X * Seperate article delete function to be used by Supersedes:
  1005. X * 
  1006. X * Revision 1.2  91/01/02  21:26:25  ud
  1007. X * Added ndbm support for history
  1008. X * 
  1009. X * Revision 1.1  90/08/31  15:32:03  cs
  1010. X * Initial revision
  1011. X * 
  1012. X */
  1013. X# ifndef    LINT
  1014. Xstatic char rcsid[] = "$Id: ccan.c_v 1.3 91/05/22 13:16:43 ud Exp $";
  1015. X# endif        LINT
  1016. X# include    <modes.h>
  1017. X# include    "inews.h"
  1018. X# include    "hist.h"
  1019. X
  1020. Xextern char    *malloc ();
  1021. Xextern char    *strdup ();
  1022. X
  1023. Xstatic int
  1024. Xdo_cancel (fns, id, flag)
  1025. Xregister char *fns;
  1026. Xchar *id;
  1027. Xchar flag;
  1028. X{
  1029. X    register char    *p;
  1030. X    char        *tbuf;
  1031. X    int        ok;
  1032. X
  1033. X    if (! (fns = strdup (fns)))
  1034. X        return (TRUE);
  1035. X    tbuf = fns;
  1036. X    ok = TRUE;
  1037. X    do_log ("Delete '%s' (fns = %s)\n", id, fns);
  1038. X    p = skipc (fns, '\0');
  1039. X    if (may_cancel (fns)) {
  1040. X        if (flag != ART_EXPIRED)
  1041. X            while (*fns) {
  1042. X                if (unlink_in_newsdir_file (fns) == -1)
  1043. X                    ok = FALSE;
  1044. X                fns = p;
  1045. X                p = skipc (fns, '\0');
  1046. X            }
  1047. X    } else {
  1048. X        ok = FALSE;
  1049. X        mail_to ("Postmaster", NULL, "Tries to cancel not-own article: ", find_from (FALSE), newstmp, NULL);
  1050. X    }
  1051. X    free (tbuf);
  1052. X    return (ok);
  1053. X}
  1054. X
  1055. Xint
  1056. Xdelete_msg (id)
  1057. Xchar *id;
  1058. X{
  1059. X    char    *p, *fns;
  1060. X    char    *flag;
  1061. X    int    fd;
  1062. X    char    *ptr, *sav;
  1063. X    char    *buf;
  1064. X    char    *savid;
  1065. X    int    n;
  1066. X    int    found;
  1067. X
  1068. X    if (!(savid = strdup (id))) {
  1069. X        do_log ("FATAL: Can't alloc memory in delete_msg for id\n");
  1070. X        return (0);
  1071. X    }
  1072. X# ifdef        USE_NDBM
  1073. X    if (!(db = open_hist (S_IREAD | S_IWRITE))) {
  1074. X        free (savid);
  1075. X        do_log ("Can't open %s.\n", HISTORY);
  1076. X        return (0);
  1077. X    }
  1078. X# endif        /* USE_NDBM */
  1079. X    found = FALSE;
  1080. X    ptr = savid;
  1081. X    while (*ptr) {
  1082. X        sav = ptr;
  1083. X        ptr = skipc (ptr, '\0');
  1084. X# ifndef    USE_NDBM
  1085. X        if ((fd = open_hist (sav, S_IREAD)) != -1) {
  1086. X            while (buf = readbuf (fd, & n)) {
  1087. X                buf[n - 1] = '\0';
  1088. X                p = skipc (buf, '\0');
  1089. X                flag = skipc (p, '\0');
  1090. X                fns = skipc (flag, '\0');
  1091. X                if (Mideql (sav, p)) {
  1092. X                    found = TRUE;
  1093. X                    if (! do_cancel (fns, sav, flag[0]))
  1094. X                        block_forward = TRUE;
  1095. X                    break;
  1096. X                }
  1097. X            }
  1098. X            close (fd);
  1099. X        }
  1100. X# else        /* USE_NDBM */
  1101. X        key.dptr = lower_mid (sav);
  1102. X        key.dsize = strlen (sav) + 1;
  1103. X        dat = dbm_fetch (db, key);
  1104. X        if (dat.dptr) {
  1105. X            found = TRUE;
  1106. X            memcpy (&hist, dat.dptr, sizeof (history));
  1107. X            if (do_cancel (hist.fns, sav, (char) hist.flag)) {
  1108. X                memcpy (&hist, dat.dptr, sizeof (history));
  1109. X                hist.flag = ART_EXPIRED;
  1110. X                fill_hist ();
  1111. X                dbm_store (db, key, dat, DBM_REPLACE);
  1112. X            } else
  1113. X                block_forward = TRUE;
  1114. X        }
  1115. X# endif        /* USE_NDBM */
  1116. X    }
  1117. X# ifdef        USE_NDBM
  1118. X    dbm_close (db);
  1119. X# endif        /* USE_NDBM */
  1120. X    free (savid);
  1121. X    return (found);
  1122. X}
  1123. X
  1124. Xvoid
  1125. Xcancel_msg (id)
  1126. Xchar *id;
  1127. X{
  1128. X    if (!delete_msg (id)) {
  1129. X        do_log ("Receive Cancel for non existing article, ID = %s\n",
  1130. X            ((id && *id) ? id : "** lost! **"));
  1131. X        do_exit (0);
  1132. X    }
  1133. X}
  1134. __END__OF__THIS__FILE__
  1135. if test -f 'INEWS/cchk.c' ; then
  1136.   echo 'File INEWS/cchk.c already exists, overwriting it'
  1137.   del 'INEWS/cchk.c'
  1138. fi
  1139. echo Extracting \"'INEWS/cchk.c'\"
  1140. sed "s/^X//" >'INEWS/cchk.c' <<'__END__OF__THIS__FILE__'
  1141. X/*
  1142. X * $Log:    cchk.c_v $
  1143. X * Revision 1.2  91/05/22  13:21:26  ud
  1144. X * Added in memory option
  1145. X * Stores now the checkgroups message in the Newsgroups file
  1146. X * 
  1147. X * Revision 1.1  90/08/31  15:32:07  cs
  1148. X * Initial revision
  1149. X * 
  1150. X */
  1151. X# ifndef    LINT
  1152. Xstatic char rcsid[] = "$Id: cchk.c_v 1.2 91/05/22 13:21:26 ud Exp $";
  1153. X# endif        LINT
  1154. X# include    <modes.h>
  1155. X# include    <c8type.h>
  1156. X# include    "inews.h"
  1157. X
  1158. Xextern char    *malloc ();
  1159. Xextern char    *rindex ();
  1160. Xextern char    *strdup ();
  1161. X
  1162. Xstatic cgroup *
  1163. Xadd_group (root, line)
  1164. Xcgroup *root;
  1165. Xchar *line;
  1166. X{
  1167. X    cgroup        *tmp;
  1168. X    register cgroup    *run, *prev;
  1169. X    register char    *ptr;
  1170. X    register int    n;
  1171. X
  1172. X    if (! (tmp = (cgroup *) malloc (sizeof (cgroup))))
  1173. X        return (root);
  1174. X    if (! (tmp -> group = strdup (line))) {
  1175. X        free ((char *) tmp);
  1176. X        return (root);
  1177. X    }
  1178. X    for (ptr = tmp -> group;*ptr && (! is8space (*ptr)); ++ptr)
  1179. X        ;
  1180. X    if (*ptr) {
  1181. X        tmp -> seperate = *ptr;
  1182. X        *ptr++ = '\0';
  1183. X    } else
  1184. X        tmp -> seperate = '\0';
  1185. X    tmp -> comment = ptr;
  1186. X    tmp -> next = NULL;
  1187. X    if (! root)
  1188. X        root = tmp;
  1189. X    else {
  1190. X        prev = NULL;
  1191. X        for (run = root; run; (prev = run), (run = run -> next)) {
  1192. X            n = strcmp (run -> group, tmp -> group);
  1193. X            if (n > 0) {
  1194. X                tmp -> next = run;
  1195. X                if (prev)
  1196. X                    prev -> next = tmp;
  1197. X                else
  1198. X                    root = tmp;
  1199. X                break;
  1200. X            } else if (n == 0) {
  1201. X                free (run -> group);
  1202. X                run -> group = tmp -> group;
  1203. X                run -> seperate = tmp -> seperate;
  1204. X                run -> comment = tmp -> comment;
  1205. X                free ((char *) tmp);
  1206. X                tmp = NULL;
  1207. X                break;
  1208. X            }
  1209. X        }
  1210. X        if ((! run) && prev)
  1211. X            prev -> next = tmp;
  1212. X    }
  1213. X    return (root);
  1214. X}
  1215. X
  1216. Xvoid
  1217. Xcheckgroups ()
  1218. X{
  1219. X    int        fd;
  1220. X    int        fdt;
  1221. X    int        fdn;
  1222. X    int        n, t;
  1223. X# ifndef    IN_MEMORY
  1224. X    char        fn[40 + sizeof (TEMPDIR)];
  1225. X# else        /* IN_MEMORY */
  1226. X    list        *cgrp;
  1227. X    register list    *ntmp;
  1228. X# endif        /* IN_MEMORY */
  1229. X    char        *buf;
  1230. X    char        *sav;
  1231. X    register char    *ptr;
  1232. X    active        *atmp;
  1233. X    charc        *limit;
  1234. X    cgroup        *croot, *crun, *cprev;
  1235. X
  1236. X    if (!(buf = malloc (512))) {
  1237. X        do_log ("FATAL: Can't alloc in checkgroups\n");
  1238. X        do_exit (1);
  1239. X    }
  1240. X# ifndef    IN_MEMORY
  1241. X    if ((fd = open (newstmp, S_IREAD)) < 0) {
  1242. X        do_log ("FATAL: Can't open %s\n", newstmp);
  1243. X        do_exit (1);
  1244. X    }
  1245. X    sprintf (fn, "%s/inewstXXXXXX", TEMPDIR);
  1246. X    mktemp (fn);
  1247. X    if ((fdt = create (fn, S_IWRITE, 03)) < 0) {
  1248. X        do_log ("FATAL: Can't create tmpfile %s\n", fn);
  1249. X        close (fd);
  1250. X        do_exit (1);
  1251. X    }
  1252. X# else        /* IN_MEMORY */
  1253. X    cgrp = NULL;
  1254. X# endif        /* IN_MEMORY */
  1255. X    croot = NULL;
  1256. X    if ((fdn = open (NEWSGROUPS_FILE, S_IREAD)) != -1) {
  1257. X        while (ptr = readbuf (fdn, & n))
  1258. X            if ((n > 1) && (ptr[0] != '#')) {
  1259. X                if (ptr[n - 1] == '\n')
  1260. X                    ptr[n - 1] = '\0';
  1261. X                else
  1262. X                    ptr[n] = '\0';
  1263. X                croot = add_group (croot, ptr);
  1264. X            }
  1265. X        close (fdn);
  1266. X    }
  1267. X    limit = get_limit_newsgroups ();
  1268. X    atmp = hact;
  1269. X    while (atmp) {
  1270. X        atmp->flag = FALSE;
  1271. X        atmp = atmp->next;
  1272. X    }
  1273. X    strcpy (buf, "-tnx\n");
  1274. X# ifndef    IN_MEMORY
  1275. X    write (fdt, buf, strlen (buf));
  1276. X    n = _gs_size (fd);
  1277. X# else        /* IN_MEMORY */
  1278. X    add_list (&cgrp, buf, strlen (buf));
  1279. X    n = 0;
  1280. X    for (ntmp = newstmp; ntmp; ntmp = ntmp->next)
  1281. X        n += ntmp->len;
  1282. X# endif        /* IN_MEMORY */
  1283. X    strcpy (buf, "* Add missing newsgroups\n");
  1284. X# ifndef    IN_MEMORY
  1285. X    write (fdt, buf, strlen (buf));
  1286. X    while ((n = readin (fd, buf, 500)) > 0) {        /* } */
  1287. X# else        /* IN_MEMORY */
  1288. X    add_list (&cgrp, buf, strlen (buf));
  1289. X    for (ntmp = newstmp; ntmp; ntmp = ntmp->next) {
  1290. X        strncpy (buf, ntmp->text, ((n = ntmp->len) > 500 ? 500 : n));
  1291. X# endif        /* IN_MEMORY */
  1292. X        if ((buf[0] == '#') || (buf[0] == '!') || (n == 1))
  1293. X            continue;
  1294. X        buf[n - 1] = '\0';
  1295. X        croot = add_group (croot, buf);
  1296. X        skipc (buf, '\0');
  1297. X# ifndef    HASH_SEARCH
  1298. X        atmp = hact;
  1299. X        while (atmp)
  1300. X            if (Strieql (atmp->grp, buf))
  1301. X                break;
  1302. X            else
  1303. X                atmp = atmp->next;
  1304. X# else        /* HASH_SEARCH */
  1305. X        atmp = find_active (buf);
  1306. X# endif        /* HASH_SEARCH */
  1307. X        if (!atmp) {
  1308. X            if ((check_limit (limit, buf)) && (sav = strdup (buf))) {
  1309. X                sprintf (buf, "inews -v '-c=newgroup:%s' '-d=%s' </nil\n", sav, DST_LOCAL);
  1310. X# ifndef    IN_MEMORY
  1311. X                write (fdt, buf, strlen (buf));
  1312. X# else        /* IN_MEMORY */
  1313. X                add_list (&cgrp, buf, strlen (buf));
  1314. X# endif        /* IN_MEMORY */
  1315. X                free (sav);
  1316. X            }
  1317. X        } else
  1318. X            atmp->flag = TRUE;
  1319. X    }
  1320. X    strcpy (buf, "* Delete obsolete newsgrps\n");
  1321. X# ifndef    IN_MEMORY
  1322. X    write (fdt, buf, strlen (buf));
  1323. X    close (fd);
  1324. X# else        /* IN_MEMORY */
  1325. X    add_list (&cgrp, buf, strlen (buf));
  1326. X# endif        /* IN_MEMORY */
  1327. X    for (atmp = hact; atmp; atmp = atmp->next)
  1328. X        if ((!atmp->flag) && Stricmp (atmp->grp, NG_JUNK) && Stricmp (atmp->grp, NG_CONTROL) && check_limit (limit, atmp->grp))
  1329. X            if ((!(ptr = rindex (atmp->grp, '.'))) || Stricmp (ptr + 1, NG_JUNK)) {
  1330. X                sprintf (buf, "inews -v '-c=rmgroup:%s' </nil\n", atmp->grp);
  1331. X# ifndef    IN_MEMORY
  1332. X                write (fdt, buf, strlen (buf));
  1333. X# else        /* IN_MEMORY */
  1334. X                add_list (&cgrp, buf, strlen (buf));
  1335. X# endif        /* IN_MEMORY */
  1336. X            }
  1337. X# ifndef    IN_MEMORY
  1338. X    close (fdt);
  1339. X    mail_to (news_owner, NULL, "Control Message: Checkgroups", NULL, fn, NULL);
  1340. X    unlink (fn);
  1341. X# else        /* IN_MEMORY */
  1342. X    mail_to (news_owner, NULL, "Control Message: Checkgroups", NULL, cgrp, NULL);
  1343. X    free_list (cgrp);
  1344. X# endif        /* IN_MEMORY */
  1345. X    free (buf);
  1346. X    free_field (limit);
  1347. X    unlink (NEWSGROUPS_FILE);
  1348. X    if (croot && ((fdn = create (NEWSGROUPS_FILE, S_IWRITE | S_ISIZE, 013, n < 0 ? 4096 : n)) != -1)) {
  1349. X        for (crun = croot; crun;) {
  1350. X            if (crun -> seperate)
  1351. X                sprintf (buf, "%s%c%s\n",
  1352. X                    crun -> group,
  1353. X                    crun -> seperate,
  1354. X                    crun -> comment);
  1355. X            else
  1356. X                sprintf (buf, "%s\n",
  1357. X                    crun -> group);
  1358. X            n = strlen (buf);
  1359. X            if (write (fdn, buf, n) != n)
  1360. X                break;
  1361. X            cprev = crun;
  1362. X            crun = crun -> next;
  1363. X            free (cprev -> group);
  1364. X            free ((char *) cprev);
  1365. X        }
  1366. X        close (fdn);
  1367. X    }
  1368. X}
  1369. __END__OF__THIS__FILE__
  1370. if test -f 'INEWS/cnew.c' ; then
  1371.   echo 'File INEWS/cnew.c already exists, overwriting it'
  1372.   del 'INEWS/cnew.c'
  1373. fi
  1374. echo Extracting \"'INEWS/cnew.c'\"
  1375. sed "s/^X//" >'INEWS/cnew.c' <<'__END__OF__THIS__FILE__'
  1376. X/*
  1377. X * $Log:    cnew.c_v $
  1378. X * Revision 1.2  91/05/22  13:13:48  ud
  1379. X * Added auto newgroup
  1380. X * 
  1381. X * Revision 1.1  90/08/31  15:32:11  cs
  1382. X * Initial revision
  1383. X * 
  1384. X */
  1385. X# ifndef    LINT
  1386. Xstatic char rcsid[] = "$Id: cnew.c_v 1.2 91/05/22 13:13:48 ud Exp $";
  1387. X# endif        LINT
  1388. X# include    <c8type.h>
  1389. X# include    "inews.h"
  1390. X
  1391. Xextern char    *index ();
  1392. Xextern char    *skipc ();
  1393. Xextern char    *strdup ();
  1394. X
  1395. Xvoid
  1396. Xnewgroup (ng)
  1397. Xchar *ng;
  1398. X{
  1399. X    active    *atmp, *aact;
  1400. X    char    *ptr;
  1401. X    char    *p;
  1402. X    int    ismod;
  1403. X    int    t;
  1404. X
  1405. X    if (ptr = index (ng, ':')) {
  1406. X        *ptr++ = '\0';
  1407. X        while (is8space (*ptr))
  1408. X            ++ptr;
  1409. X    } else
  1410. X        ptr = skipc (ng, '\0');
  1411. X    ismod = (*ptr && Strnieql (ptr, "mod", 3));
  1412. X# ifndef    HASH_SEARCH
  1413. X    atmp = hact;
  1414. X    while (atmp)
  1415. X        if (Strieql (atmp->grp, ng))
  1416. X            break;
  1417. X        else
  1418. X            atmp = atmp->next;
  1419. X# else        /* HASH_SEARCH */
  1420. X    atmp = find_active (ng);
  1421. X# endif        /* HASH_SEARCH */
  1422. X# ifndef    AUTO_NEWGROUP
  1423. X    if (! isadm) {
  1424. X        if ((! atmp) || ((atmp -> aflag[0] == M_MOD) && (!ismod)) || ((atmp -> aflag[0] == M_NOT_MOD) && ismod)) {
  1425. X            char    *tmp;
  1426. X            char    *comment[6];
  1427. X
  1428. X            comment[0] = "A newgroupmessage has arrived here, but you have disabled\n";
  1429. X            comment[1] = "the automatic creation of a newsgroup. So you have to\n";
  1430. X            comment[2] = "execute the following command as News Admin:\n";
  1431. X            if (atmp)
  1432. X                comment[3] = "The state of moderation had been changed\n";
  1433. X            else
  1434. X                comment[3] = "This newsgroup is completely new\n";
  1435. X            if (tmp = malloc (strlen (ng) + 128)) {
  1436. X                sprintf (tmp, "inews '-c=newgroup:%s%s' -d=local </nil\n", ng, ismod ? " moderated" : "");
  1437. X                comment[4] = tmp;
  1438. X            } else
  1439. X                comment[4] = "inews '-c=<newsgroup> [<moderated>]' -d=local </nil\n";
  1440. X            comment[5] = NULL;
  1441. X            mail_to (news_owner, NULL, "Control Message: newgroup", ng, NULL, comment);
  1442. X            if (tmp)
  1443. X                free (tmp);
  1444. X        }
  1445. X        return;
  1446. X    }
  1447. X# endif        /* AUTO_NEWGROUP */
  1448. X    if (atmp) {
  1449. X        do_log ("Got newgroup for existing group %s\n", atmp->grp);
  1450. X        if (atmp->aflag[1] == M_IGNORE)
  1451. X            atmp->aflag[1] = M_USE;
  1452. X        if ((atmp->aflag[0] == M_MOD) && (!ismod)) {
  1453. X            do_log ("Group status changed from moderated to unmoderated\n");
  1454. X            atmp->aflag[0] = M_NOT_MOD;
  1455. X            for (t=0;atmp->moderator[t];++t)
  1456. X                free (atmp->moderator[t]);
  1457. X            free ((char *) atmp->moderator);
  1458. X            atmp->moderator = NULL;
  1459. X            act_rewrite = TRUE;
  1460. X        } else if ((atmp->aflag[0] == M_NOT_MOD) && ismod) {
  1461. X            do_log ("Group status changed from unmoderated to moderated\n");
  1462. X            atmp->aflag[0] = M_MOD;
  1463. X            if (atmp->moderator = (char **) malloc (sizeof (char *) * 3))
  1464. X                atmp->moderator[0] = NULL;
  1465. X            else {
  1466. X                do_log ("FATAL: Can't alloc memory\n");
  1467. X                do_exit (1);
  1468. X            }
  1469. X            act_rewrite = TRUE;
  1470. X        }
  1471. X        return;
  1472. X    }
  1473. X    if (!(atmp = (active *) malloc (sizeof (active)))) {
  1474. X        do_log ("FATAL: Can't alloc for newgroup\n");
  1475. X        do_exit (1);
  1476. X    }
  1477. X    if (!(atmp->grp = strdup (ng))) {
  1478. X        do_log ("FATAL: Can't alloc for newgroup\n");
  1479. X        do_exit (1);
  1480. X    }
  1481. X    p = atmp->grp;
  1482. X    while (*p) {
  1483. X        *p = to8lower (*p);
  1484. X        ++p;
  1485. X    }
  1486. X    atmp->low = 0;
  1487. X    atmp->high = 0;
  1488. X    atmp->moderator = NULL;
  1489. X    if (ismod) {
  1490. X        atmp->aflag[0] = M_MOD;
  1491. X        if (!(atmp->moderator = (char **) malloc (sizeof (char *) * 3))) {
  1492. X            do_log ("FATAL: Can't alloc for newgroup\n");
  1493. X            do_exit (1);
  1494. X        }
  1495. X        atmp->moderator[0] = NULL;
  1496. X    } else
  1497. X        atmp->aflag[0] = M_NOT_MOD;
  1498. X    atmp->aflag[1] = M_USE;
  1499. X    atmp -> kblimit = -1;
  1500. X    atmp->next = NULL;
  1501. X    if (!hact)
  1502. X        hact = atmp;
  1503. X    else {
  1504. X        aact = hact;
  1505. X        while (aact->next)
  1506. X            aact = aact->next;
  1507. X        aact->next = atmp;
  1508. X    }
  1509. X# ifdef        HASH_SEARCH
  1510. X    atmp -> id = calc_hash (atmp -> grp, TRUE);
  1511. X    atmp -> hnext = hashact[atmp -> id % HASH_ACTIVE];
  1512. X    hashact[atmp -> id % HASH_ACTIVE] = atmp;
  1513. X# endif        /* HASH_SEARCH */
  1514. X    act_rewrite = TRUE;
  1515. X    do_log ("New newsgroup: %s\n", atmp->grp);
  1516. X}
  1517. __END__OF__THIS__FILE__
  1518. if test -f 'INEWS/crct.c' ; then
  1519.   echo 'File INEWS/crct.c already exists, overwriting it'
  1520.   del 'INEWS/crct.c'
  1521. fi
  1522. echo Extracting \"'INEWS/crct.c'\"
  1523. sed "s/^X//" >'INEWS/crct.c' <<'__END__OF__THIS__FILE__'
  1524. X/*
  1525. X * $Log:    crct.c_v $
  1526. X * Revision 1.1  90/08/31  15:32:51  cs
  1527. X * Initial revision
  1528. X * 
  1529. X */
  1530. X# ifndef    LINT
  1531. Xstatic char rcsid[] = "$Id: crct.c_v 1.1 90/08/31 15:32:51 cs Exp $";
  1532. X# endif        LINT
  1533. X# include    <c8type.h>
  1534. X# include    <time.h>
  1535. X# include    "inews.h"
  1536. X
  1537. Xextern char    *malloc ();
  1538. Xextern char    *strdup ();
  1539. X
  1540. Xstatic void
  1541. Xmake_ctl_ngs (ng)
  1542. Xchar *ng;
  1543. X{
  1544. X    char        *ptr;
  1545. X    register char    *p;
  1546. X
  1547. X    if (ngs)
  1548. X        return;
  1549. X    if (!(ptr = strdup (ng)))
  1550. X        return;
  1551. X    skipc (ptr, '\0');
  1552. X    p = ptr;
  1553. X    while (*p) {
  1554. X        *p = to8lower (*p);
  1555. X        ++p;
  1556. X    }
  1557. X    if (ngs = (charc *) malloc (sizeof (charc)))
  1558. X        if (ngs->text = malloc (strlen (ptr) + 10)) {
  1559. X            strcpy (ngs->text, ptr);
  1560. X            strcat (ngs->text, CTRL_POSTFIX);
  1561. X            ngs->next = NULL;
  1562. X        } else {
  1563. X            free ((char *) ngs);
  1564. X            ngs = NULL;
  1565. X        }
  1566. X    free (ptr);
  1567. X}
  1568. X
  1569. Xvoid
  1570. Xcreate_control_message (msg)
  1571. Xchar *msg;
  1572. X{
  1573. X    register int    t;
  1574. X    char        *fn;
  1575. X    char        *opts, *pars;
  1576. X    time_t        dummy;
  1577. X
  1578. X    if (do_init (FALSE) < 0)
  1579. X        exit (_errmsg (1, "Can't initialize the mess\n"));
  1580. X    opts = skipc (msg, ':');
  1581. X    pars = skipc (opts, '\0');
  1582. X    for (t=0;ctrlcodes[t];++t)
  1583. X        if (Strieql (ctrlcodes[t], msg))
  1584. X            break;
  1585. X    if (!ctrlcodes[t])
  1586. X        do_exit (_errmsg (1, "Unknown controlmessage %s.\n", msg));
  1587. X    if (t != CC_CANCEL) {
  1588. X        if (!isadm)
  1589. X            do_exit (_errmsg (1, "You aren't allowed to send control messages\n"));
  1590. X        if (! dists) {
  1591. X            if (dists = (charc *) malloc (sizeof (charc)))
  1592. X                if (dists -> text = strdup (DST_LOCAL))
  1593. X                    dists -> next = NULL;
  1594. X                else {
  1595. X                    free ((char *) dists);
  1596. X                    dists = NULL;
  1597. X                }
  1598. X            if (! dists)
  1599. X                do_exit (_errmsg (1, "Can't make distribution %s for %s\n",
  1600. X                    DST_LOCAL, ctrlcodes[t]));
  1601. X        }
  1602. X    }
  1603. X    switch (t) {
  1604. X        case CC_CANCEL:
  1605. X            if (!*opts)
  1606. X                do_exit (_errmsg (1, "Which article you wish to cancel?\n"));
  1607. X            if (!(fn = exists_message_id (opts, &dummy)))
  1608. X                do_exit (_errmsg (1, "This article isn't written here\n"));
  1609. X            else {
  1610. X                get_dists_and_ngs (fn);
  1611. X                free (fn);
  1612. X            }
  1613. X            break;
  1614. X        case CC_IHAVE:
  1615. X            do_exit (_errmsg (1, "Sorry, this implementation doesn't support %s\n", msg));
  1616. X            break;
  1617. X        case CC_SENDME:
  1618. X            break;
  1619. X        case CC_NEWGROUP:
  1620. X            if (!*opts)
  1621. X                do_exit (_errmsg (1, "Which group do you want to make?\n"));
  1622. X            make_ctl_ngs (opts);
  1623. X            break;
  1624. X        case CC_RMGROUP:
  1625. X            if (!*opts)
  1626. X                do_exit (_errmsg (1, "Which group do you want to remove?\n"));
  1627. X            make_ctl_ngs (opts);
  1628. X            break;
  1629. X        case CC_SENDSYS:
  1630. X        case CC_SENDUUNAME:
  1631. X        case CC_VERSION:
  1632. X        case CC_CHECKGROUPS:
  1633. X            break;
  1634. X    }
  1635. X    send_control (msg, opts, pars);
  1636. X    do_exit (0);
  1637. X}
  1638. __END__OF__THIS__FILE__
  1639. if test -f 'INEWS/crm.c' ; then
  1640.   echo 'File INEWS/crm.c already exists, overwriting it'
  1641.   del 'INEWS/crm.c'
  1642. fi
  1643. echo Extracting \"'INEWS/crm.c'\"
  1644. sed "s/^X//" >'INEWS/crm.c' <<'__END__OF__THIS__FILE__'
  1645. X/*
  1646. X * $Log:    crm.c_v $
  1647. X * Revision 1.2  91/05/22  13:17:29  ud
  1648. X * Added auto rmgroup
  1649. X * 
  1650. X * Revision 1.1  90/08/31  15:32:55  cs
  1651. X * Initial revision
  1652. X * 
  1653. X */
  1654. X# ifndef    LINT
  1655. Xstatic char rcsid[] = "$Id: crm.c_v 1.2 91/05/22 13:17:29 ud Exp $";
  1656. X# endif        LINT
  1657. X# include    "inews.h"
  1658. X
  1659. Xvoid
  1660. Xrmgroup (ng)
  1661. Xchar *ng;
  1662. X{
  1663. X    active    *atmp, *at;
  1664. X    int    t;
  1665. X# ifdef        HASH_SEARCH
  1666. X    int    idx;
  1667. X    active    *tmp;
  1668. X# endif        /* HASH_SEARCH */
  1669. X
  1670. X    atmp = hact;
  1671. X    at = NULL;
  1672. X    while (atmp)
  1673. X        if (Strieql (atmp->grp, ng))
  1674. X            break;
  1675. X        else {
  1676. X            at = atmp;
  1677. X            atmp = atmp->next;
  1678. X        }
  1679. X# ifndef    AUTO_RMGROUP
  1680. X    if (! isadm) {
  1681. X
  1682. X        if (atmp) {
  1683. X            char    *comment[7];
  1684. X
  1685. X            comment[0] = "A rmgroup control message has arrived here, but you have\n";
  1686. X            comment[1] = "automatically remove of newsgroups disabled. So you have\n";
  1687. X            comment[2] = "to execute the following command by hand as News Admin:\n";
  1688. X            comment[3] = "inews '-c=rmgroup:";
  1689. X            comment[4] = ng;
  1690. X            comment[5] = "' -d=local </nil\n";
  1691. X            comment[6] = NULL;
  1692. X            mail_to (news_owner, NULL, "Control Message: rmgroup", ng, NULL, comment);
  1693. X        }
  1694. X        return;
  1695. X    }
  1696. X# endif        /* AUTO_RMGROUP */
  1697. X
  1698. X    if (atmp) {
  1699. X        if (at)
  1700. X            at->next = atmp->next;
  1701. X        else
  1702. X            hact = hact->next;
  1703. X        make_fn (ng);
  1704. X        unlink_in_newsdir_dir (ng);
  1705. X        free (atmp->grp);
  1706. X        if (atmp->moderator) {
  1707. X            t = 0;
  1708. X            while (atmp->moderator[t]) {
  1709. X                free (atmp->moderator[t]);
  1710. X                ++t;
  1711. X            }
  1712. X        }
  1713. X        free ((char *) atmp->moderator);
  1714. X# ifdef        HASH_SEARCH
  1715. X        idx = atmp -> id % HASH_ACTIVE;
  1716. X        at = NULL;
  1717. X        for (tmp = hashact[idx]; tmp; )
  1718. X            if (tmp == atmp)
  1719. X                break;
  1720. X            else {
  1721. X                at = tmp;
  1722. X                tmp = tmp -> hnext;
  1723. X            }
  1724. X        if (tmp)
  1725. X            if (at)
  1726. X                at -> hnext = atmp -> hnext;
  1727. X            else
  1728. X                hashact[idx] = atmp -> next;
  1729. X# endif        /* HASH_SEARCH */
  1730. X        free ((char *) atmp);
  1731. X        act_rewrite = TRUE;
  1732. X        do_log ("Rmgroup: %s\n", ng);
  1733. X    } else
  1734. X        do_log ("Group %s doesn't exists (rmgroup)\n", ng);
  1735. X}
  1736. __END__OF__THIS__FILE__
  1737. if test -f 'INEWS/crth.c' ; then
  1738.   echo 'File INEWS/crth.c already exists, overwriting it'
  1739.   del 'INEWS/crth.c'
  1740. fi
  1741. echo Extracting \"'INEWS/crth.c'\"
  1742. sed "s/^X//" >'INEWS/crth.c' <<'__END__OF__THIS__FILE__'
  1743. X/*
  1744. X * $Log:    crth.c_v $
  1745. X * Revision 1.1  90/08/31  15:32:59  cs
  1746. X * Initial revision
  1747. X * 
  1748. X */
  1749. X# ifndef    LINT
  1750. Xstatic char rcsid[] = "$Id: crth.c_v 1.1 90/08/31 15:32:59 cs Exp $";
  1751. X# endif        LINT
  1752. X# include    <time.h>
  1753. X# include    <pwd.h>
  1754. X# include    "inews.h"
  1755. X
  1756. Xextern char    *getenv ();
  1757. Xextern char    *malloc ();
  1758. X
  1759. Xchar *
  1760. Xmake_own_address (need_fullname)
  1761. Xint need_fullname;
  1762. X{
  1763. X    char        *fullname;
  1764. X    struct passwd    *pw;
  1765. X    struct gecos    *gc;
  1766. X    char        *buf;
  1767. X
  1768. X    fullname = NULL;
  1769. X    if (need_fullname) {
  1770. X        setpwent ();
  1771. X        if ((pw = getpwnam (user)) && pw->pw_gecos && (gc = getgecos (pw->pw_gecos)) && (gc->fullname && *gc->fullname))
  1772. X            fullname = gc->fullname;
  1773. X        endpwent ();
  1774. X    }
  1775. X    if (!fullname)
  1776. X        if (!(fullname = getenv ("NAME")))
  1777. X            fullname = getenv ("FULLNAME");
  1778. X    if (buf = malloc (strlen (user) + strlen (fhost) + 4 + (fullname ? strlen (fullname) + 8 : 0))) {
  1779. X        strcpy (buf, user);
  1780. X        strcat (buf, "@");
  1781. X        strcat (buf, fhost);
  1782. X        if (fullname) {
  1783. X            strcat (buf, " (");
  1784. X            strcat (buf, fullname);
  1785. X            strcat (buf, ")");
  1786. X        }
  1787. X    }
  1788. X    return (buf);
  1789. X}
  1790. X
  1791. Xint
  1792. Xcreate_header (fornews, interactive)
  1793. Xint fornews;
  1794. Xint interactive;
  1795. X{
  1796. X    char        *buf;
  1797. X    time_t        tim;
  1798. X    char        *org;
  1799. X    char        *tmp;
  1800. X    struct passwd    *pw;
  1801. X    struct gecos    *gc;
  1802. X
  1803. X    if (!(buf = malloc (512)))
  1804. X        return (-1);
  1805. X    if (fornews)
  1806. X        insert_header (H_PATH, user, TRUE);
  1807. X    sprintf (buf, "%s@%s", user, fhost);
  1808. X    if (tmp = find_address_hl (H_FROM)) {
  1809. X        if (Stricmp (tmp, buf)) {
  1810. X            insert_header (H_REPLY_TO, tmp, interactive);
  1811. X            if (tmp = make_own_address (TRUE)) {
  1812. X                insert_header (H_SENDER, tmp, TRUE);
  1813. X                free (tmp);
  1814. X            } else
  1815. X                insert_header (H_SENDER, buf, TRUE);
  1816. X        }
  1817. X        free (tmp);
  1818. X    }
  1819. X    org = NULL;
  1820. X    setpwent ();
  1821. X    if ((pw = getpwnam (user)) && pw->pw_gecos && (gc = getgecos (pw->pw_gecos)) && (gc->fullname && *gc->fullname)) {
  1822. X        strcat (buf, " (");
  1823. X        strcat (buf, gc->fullname);
  1824. X        strcat (buf, ")");
  1825. X        if (gc->organization && *gc->organization)
  1826. X            org = gc->organization;
  1827. X    } else {
  1828. X        if (tmp = make_own_address (FALSE)) {
  1829. X            strcpy (buf, tmp);
  1830. X            free (tmp);
  1831. X        }
  1832. X    }
  1833. X    endpwent ();
  1834. X    insert_header (H_FROM, buf, interactive);
  1835. X    time (&tim);
  1836. X    strcpy (buf, ntime (&tim));
  1837. X    insert_header (H_DATE, buf, interactive);
  1838. X    if (!org)
  1839. X        org = getenv ("ORGANIZATION");
  1840. X    if (org)
  1841. X        insert_header (H_ORGANIZATION, org, interactive);
  1842. X    free (buf);
  1843. X    if (fornews) {
  1844. X        if (ngs && (tmp = catcharc (ngs, ","))) {
  1845. X            insert_header (H_NEWSGROUPS, tmp, interactive);
  1846. X            free (tmp);
  1847. X        }
  1848. X        if (dists && (tmp = catcharc (dists, ","))) {
  1849. X            insert_header (H_DISTRIBUTION, tmp, interactive);
  1850. X            free (tmp);
  1851. X        }
  1852. X        insert_header (H_POSTED, atime (&tim), interactive);
  1853. X    } else {
  1854. X        if (recv && (tmp = catcharc (recv, ", "))) {
  1855. X            insert_header (H_TO, tmp, interactive);
  1856. X            free (tmp);
  1857. X        }
  1858. X    }
  1859. X    if (interactive)
  1860. X        sort_header (FALSE);
  1861. X    return (0);
  1862. X}
  1863. __END__OF__THIS__FILE__
  1864. exit 0
  1865. : end of shell archive
  1866.  
  1867. -- 
  1868. Frank Kaefer # fkk@stasys.sta.sub.org # Starnberg, Germany
  1869.