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

  1. Xref: sparky de.comp.sources.os9:11 comp.os.os9:1553
  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 Part03/09
  6. Message-ID: <1hafd8INNpss@stasys.sta.sub.org>
  7. Date: 23 Dec 92 19:41:28 GMT
  8. Sender: news@stasys.sta.sub.org
  9. Followup-To: de.comp.sources.d
  10. Organization: Stasys News Server, Starnberg, Germany
  11. Lines: 2321
  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/part03
  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/csme.c                                  515 bytes'
  22. :     'INEWS/cssys.c                                1918 bytes'
  23. :     'INEWS/csuu.c                                 1242 bytes'
  24. :     'INEWS/csver.c                                1398 bytes'
  25. :     'INEWS/ctrl.c                                 3060 bytes'
  26. :     'INEWS/dbg.c                                  1599 bytes'
  27. :     'INEWS/ddst.c                                 1571 bytes'
  28. :     'INEWS/delh.c                                  768 bytes'
  29. :     'INEWS/exp.c                                  8032 bytes'
  30. :     'INEWS/ext.h                                  2171 bytes'
  31. :     'INEWS/fcan.c                                 2345 bytes'
  32. :     'INEWS/ffrom.c                                1922 bytes'
  33. :     'INEWS/ffup.c                                 1692 bytes'
  34. :     'INEWS/getd.c                                 1029 bytes'
  35. :     'INEWS/gfh.c                                   290 bytes'
  36. :     'INEWS/ghead.c                                 487 bytes'
  37. :     'INEWS/hact                                     69 bytes'
  38. :     'INEWS/hash.c                                  435 bytes'
  39. :     'INEWS/hist.h                                  873 bytes'
  40. :     'INEWS/ihead.c                                 947 bytes'
  41. :     'INEWS/inews.c                                1823 bytes'
  42. :     'INEWS/inews.h                               11606 bytes'
  43. if test -f 'INEWS/csme.c' ; then
  44.   echo 'File INEWS/csme.c already exists, overwriting it'
  45.   del 'INEWS/csme.c'
  46. fi
  47. echo Extracting \"'INEWS/csme.c'\"
  48. sed "s/^X//" >'INEWS/csme.c' <<'__END__OF__THIS__FILE__'
  49. X/*
  50. X * $Log:    csme.c_v $
  51. X * Revision 1.1  91/12/26  13:47:10  ud
  52. X * Initial revision
  53. X * 
  54. X * 
  55. X */
  56. X# ifndef    LINT
  57. Xstatic char rcsid[] = "$Id: csme.c_v 1.1 91/12/26 13:47:10 ud Exp $";
  58. X# endif        LINT
  59. X# include    <c8type.h>
  60. X# include    "inews.h"
  61. X
  62. Xextern char    *index ();
  63. Xextern char    *strdup ();
  64. X
  65. Xvoid
  66. Xsend_me ()
  67. X{
  68. X    char    *ptr;
  69. X    charc    *tmp;
  70. X
  71. X    if (! ngs)
  72. X        return;
  73. X    ptr = ngs -> text;
  74. X    if (Strnicmp (ptr, "to.", 3))
  75. X        return;
  76. X    ptr += 3;
  77. X    if (Strieql (ptr, hostname) || Strieql (ptr, fhost)) {
  78. X        /* Handle sendme */
  79. X        return;
  80. X    }
  81. X}
  82. X
  83. __END__OF__THIS__FILE__
  84. if test -f 'INEWS/cssys.c' ; then
  85.   echo 'File INEWS/cssys.c already exists, overwriting it'
  86.   del 'INEWS/cssys.c'
  87. fi
  88. echo Extracting \"'INEWS/cssys.c'\"
  89. sed "s/^X//" >'INEWS/cssys.c' <<'__END__OF__THIS__FILE__'
  90. X/*
  91. X * $Log:    cssys.c_v $
  92. X * Revision 1.1  90/08/31  15:33:03  cs
  93. X * Initial revision
  94. X * 
  95. X */
  96. X# ifndef    LINT
  97. Xstatic char rcsid[] = "$Id: cssys.c_v 1.1 90/08/31 15:33:03 cs Exp $";
  98. X# endif        LINT
  99. X# include    "inews.h"
  100. X
  101. Xextern char    *index ();
  102. Xextern char    *strdup ();
  103. X
  104. Xchar *
  105. Xget_path (tmp)
  106. Xcharc *tmp;
  107. X{
  108. X    char    *path;
  109. X
  110. X    if ((path = index (tmp->text, '!')) || (path = index (tmp->text, ':')))
  111. X        ++path;
  112. X    else
  113. X        path = tmp->text;
  114. X    return (path);
  115. X}
  116. X
  117. Xvoid
  118. Xsendsys ()
  119. X{
  120. X    char    *from, *reply_to;
  121. X    char    *comment[16];
  122. X    charc    *tmp;
  123. X# ifdef        IN_MEMORY
  124. X    list    *ltmp;
  125. X# endif        /* IN_MEMORY */
  126. X
  127. X    if (!(from = find_from_addr (TRUE)))
  128. X        if (!(from = strdup (news_owner)))
  129. X            return;
  130. X
  131. X    reply_to = NULL;
  132. X
  133. X# ifndef    SEND_WORLD
  134. X    if (dist_is_world ()) {
  135. X        reply_to = from;
  136. X        if (! (from = strdup (news_owner))) {
  137. X            free (reply_to);
  138. X            return;
  139. X        }
  140. X    }
  141. X# endif        /* SEND_WORLD */
  142. X
  143. X    do_log ("Received Sendsys Control Message from %s\n", from);
  144. X    comment[0] = "Dear Sender!\n";
  145. X    comment[1] = "You requested our `sys'-file, it is appended to this message\n";
  146. X    comment[2] = "This `sys'-file is currently running on ";
  147. X    comment[3] = fhost;
  148. X    comment[4] = ".\n";
  149. X    comment[5] = "** Note: This `sys'-format isn't compatible to this of BNews or CNews, so\n",
  150. X    comment[6] = "         if you have have got some problems, be free and send a mail\n";
  151. X    comment[7] = "         to postmaster@";
  152. X    comment[8] = fhost;
  153. X    comment[9] = ".\n";
  154. X    if (tmp = get_header_line (H_PATH)) {
  155. X        comment[10] = "The Path to here is: '";
  156. X        comment[11] = get_path (tmp);
  157. X        comment[12] = "'.\n";
  158. X        comment[13] = NULL;
  159. X    } else
  160. X        comment[10] = NULL;
  161. X# ifndef    IN_MEMORY
  162. X    mail_to (from, reply_to, "Request of sys-file from site", fhost, SYS_FILE, comment);
  163. X# else        /* IN_MEMORY */
  164. X    if (ltmp = get_file (SYS_FILE)) {
  165. X        mail_to (from, reply_to, "Request of sys-file from site", fhost, ltmp, comment);
  166. X        free_list (ltmp);
  167. X    }
  168. X# endif        /* IN_MEMORY */
  169. X    free (from);
  170. X    if (reply_to)
  171. X        free (reply_to);
  172. X}
  173. __END__OF__THIS__FILE__
  174. if test -f 'INEWS/csuu.c' ; then
  175.   echo 'File INEWS/csuu.c already exists, overwriting it'
  176.   del 'INEWS/csuu.c'
  177. fi
  178. echo Extracting \"'INEWS/csuu.c'\"
  179. sed "s/^X//" >'INEWS/csuu.c' <<'__END__OF__THIS__FILE__'
  180. X/*
  181. X * $Log:    csuu.c_v $
  182. X * Revision 1.1  90/08/31  15:33:07  cs
  183. X * Initial revision
  184. X * 
  185. X */
  186. X# ifndef    LINT
  187. Xstatic char rcsid[] = "$Id: csuu.c_v 1.1 90/08/31 15:33:07 cs Exp $";
  188. X# endif        LINT
  189. X# include    "inews.h"
  190. X
  191. Xextern char    *strdup ();
  192. X
  193. Xvoid
  194. Xsenduuname ()
  195. X{
  196. X    char    *from, *reply_to;
  197. X    char    *comment[10];
  198. X    charc    *tmp;
  199. X# ifdef        IN_MEMORY
  200. X    list    *ltmp;
  201. X# endif        /* IN_MEMORY */
  202. X
  203. X    if (!(from = find_from_addr (TRUE)))
  204. X        if (!(from = strdup (news_owner)))
  205. X            return;
  206. X
  207. X    reply_to = NULL;
  208. X# ifndef    SEND_WORLD
  209. X    if (dist_is_world ()) {
  210. X        reply_to = from;
  211. X        if (! (from = strdup (news_owner))) {
  212. X            free (reply_to);
  213. X            return;
  214. X        }
  215. X    }
  216. X# endif        /* SEND_WORLD */
  217. X
  218. X    do_log ("Received Senduuname Control Message from %s\n", from);
  219. X    if (tmp = get_header_line (H_PATH)) {
  220. X        comment[0] = "The Path to here is: '";
  221. X        comment[1] = get_path (tmp);
  222. X        comment[2] = "'.\n";
  223. X        comment[3] = NULL;
  224. X    } else
  225. X        comment[0] = NULL;
  226. X# ifndef    IN_MEMORY
  227. X    mail_to (from, reply_to, "Request of uuname from site", fhost, UUNAME_FILE, comment);
  228. X# else        /* IN_MEMORY */
  229. X    if (ltmp = get_file (UUNAME_FILE)) {
  230. X        mail_to (from, reply_to, "Request of uuname from site", fhost, ltmp, comment);
  231. X        free_list (ltmp);
  232. X    }
  233. X# endif        /* IN_MEMORY */
  234. X    free (from);
  235. X    if (reply_to)
  236. X        free (reply_to);
  237. X}
  238. X
  239. __END__OF__THIS__FILE__
  240. if test -f 'INEWS/csver.c' ; then
  241.   echo 'File INEWS/csver.c already exists, overwriting it'
  242.   del 'INEWS/csver.c'
  243. fi
  244. echo Extracting \"'INEWS/csver.c'\"
  245. sed "s/^X//" >'INEWS/csver.c' <<'__END__OF__THIS__FILE__'
  246. X/*
  247. X * $Log:    csver.c_v $
  248. X * Revision 1.2  91/12/26  14:00:58  ud
  249. X * Added RCS-ID as part of the version control message
  250. X * 
  251. X * Revision 1.1  90/08/31  15:33:10  cs
  252. X * Initial revision
  253. X * 
  254. X */
  255. Xstatic char rcsid[] = "$Id: csver.c_v 1.2 91/12/26 14:00:58 ud Exp $";
  256. X
  257. X# include    "inews.h"
  258. X
  259. Xextern char    *strdup ();
  260. X
  261. Xvoid
  262. Xsendversion ()
  263. X{
  264. X    char    *from, *reply_to;
  265. X    char    buf[128];
  266. X    char    *comment[12];
  267. X    charc    *tmp;
  268. X
  269. X    if (!(from = find_from_addr (TRUE)))
  270. X        if (!(from = strdup (news_owner)))
  271. X            return;
  272. X
  273. X    reply_to = NULL;
  274. X# ifndef    SEND_WORLD
  275. X    if (dist_is_world ()) {
  276. X        reply_to = from;
  277. X        if (! (from = strdup (news_owner))) {
  278. X            free (reply_to);
  279. X            return;
  280. X        }
  281. X    }
  282. X# endif        /* SEND_WORLD */
  283. X
  284. X    do_log ("Received Sendversion Control Message from %s\n", from);
  285. X# ifndef    PATCHLEVEL
  286. X    sprintf (buf, VERSIONSTR, VERSION);
  287. X# else        PATCHLEVEL
  288. X    sprintf (buf, VERSIONSTR, VERSION, PATCHLEVEL);
  289. X# endif        PATCHLEVEL
  290. X    comment[0] = "Our current running version on '";
  291. X    comment[1] = fhost;
  292. X    comment[2] = "' is\n";
  293. X    comment[3] = buf;
  294. X    comment[4] = ".\n";
  295. X    comment[5] = "\tRCS: ";
  296. X    comment[6] = rcsid;
  297. X    comment[7] = "\n";
  298. X    if (tmp = get_header_line (H_PATH)) {
  299. X        comment[8] = "The Path to here is: '";
  300. X        comment[9] = get_path (tmp);
  301. X        comment[10] = "'.\n";
  302. X        comment[11] = NULL;
  303. X    } else
  304. X        comment[8] = NULL;
  305. X    mail_to (from, reply_to, "Current News-Version", buf, NULL, comment);
  306. X    free (from);
  307. X    if (reply_to)
  308. X        free (reply_to);
  309. X}
  310. __END__OF__THIS__FILE__
  311. if test -f 'INEWS/ctrl.c' ; then
  312.   echo 'File INEWS/ctrl.c already exists, overwriting it'
  313.   del 'INEWS/ctrl.c'
  314. fi
  315. echo Extracting \"'INEWS/ctrl.c'\"
  316. sed "s/^X//" >'INEWS/ctrl.c' <<'__END__OF__THIS__FILE__'
  317. X/*
  318. X * $Log:    ctrl.c_v $
  319. X * Revision 1.2  91/12/26  13:34:13  ud
  320. X * Tried to insert `sendme', but didn't work as expected
  321. X * 
  322. X * Revision 1.1  90/08/31  15:33:14  cs
  323. X * Initial revision
  324. X * 
  325. X */
  326. X# ifndef    LINT
  327. Xstatic char rcsid[] = "$Id: ctrl.c_v 1.2 91/12/26 13:34:13 ud Exp $";
  328. X# endif        LINT
  329. X# include    "inews.h"
  330. X
  331. Xextern char    *rindex ();
  332. Xextern char    *strdup ();
  333. X
  334. Xstatic void
  335. Xdo_control (msg)
  336. Xchar *msg;
  337. X{
  338. X    register int    t;
  339. X    char        *rmsg;
  340. X    charc        *tmp;
  341. X    char        *opts;
  342. X    char        *ptr;
  343. X
  344. X    if (!(rmsg = strdup (msg))) {
  345. X        do_log ("FATAL: Failed during Control-Message\n");
  346. X        do_exit (1);
  347. X    }
  348. X    opts = skipc (rmsg, '\0');
  349. X    for (t=0;ctrlcodes[t];++t)
  350. X        if (Strieql (ctrlcodes[t], rmsg))
  351. X            break;
  352. X    if (!ctrlcodes[t]) {
  353. X        do_log ("FATAL: Unknown Controlmessage: %s (%s) --> article\n", rmsg, opts);
  354. X        tmp = ngs;
  355. X        while (tmp) {
  356. X            if ((ptr = rindex (tmp->text, '.')) && (Strieql (ptr, CTRL_POSTFIX)))
  357. X                *ptr = '\0';
  358. X            tmp = tmp->next;
  359. X        }
  360. X        return;
  361. X    }
  362. X    do_log ("Received Control Message: %s\n", msg);
  363. X    if (!(isctrl = (charc *) malloc (sizeof (charc)))) {
  364. X        do_log ("FATAL: Can't alloc isctrl!\n");
  365. X        do_exit (1);
  366. X    }
  367. X    isctrl -> text = NULL;
  368. X    switch (t) {
  369. X        case CC_CANCEL:
  370. X        case CC_IHAVE:
  371. X        case CC_NEWGROUP:
  372. X        case CC_RMGROUP:
  373. X        case CC_SENDSYS:
  374. X        case CC_SENDUUNAME:
  375. X        case CC_VERSION:
  376. X        case CC_CHECKGROUPS:
  377. X            isctrl -> text = strdup (NG_CONTROL);
  378. X            break;
  379. X        case CC_SENDME:
  380. X            if (ngs)
  381. X                isctrl -> text = strdup (ngs -> text);
  382. X            else
  383. X                do_log ("No newsgroups: for sendme\n");
  384. X            break;
  385. X    }
  386. X
  387. X    if (! isctrl -> text)
  388. X        do_exit (1);
  389. X
  390. X    isctrl->next = NULL;
  391. X    if (!ngs) {
  392. X        if (!(ngs = (charc *) malloc (sizeof (charc)))) {
  393. X            do_log ("FATAL: Failed during Control-Message\n");
  394. X            do_exit (1);
  395. X        }
  396. X        if (!(ngs->text = strdup (NG_CONTROL))) {
  397. X            do_log ("FATAL: Failed during Control-Message\n");
  398. X            do_exit (1);
  399. X        }
  400. X        ngs->next = NULL;
  401. X    } else {
  402. X        tmp = ngs;
  403. X        while (tmp) {
  404. X            if ((ptr = rindex (tmp->text, '.')) && (Strieql (ptr, CTRL_POSTFIX)))
  405. X                *ptr = '\0';
  406. X            tmp = tmp->next;
  407. X        }
  408. X    }
  409. X    if (t != CC_CANCEL)
  410. X        if (!get_header_line (H_APPROVED)) {
  411. X            do_log ("No Approved: Line for %s found\n", rmsg);
  412. X            do_exit (1);
  413. X        }
  414. X    switch (t) {
  415. X        case CC_CANCEL:
  416. X            cancel_msg (opts);
  417. X            break;
  418. X        case CC_IHAVE:
  419. X            do_log ("Unsopported control-message: %s\n", rmsg);
  420. X            do_exit (0);
  421. X            break;
  422. X        case CC_SENDME:
  423. X            send_me ();
  424. X            break;
  425. X        case CC_NEWGROUP:
  426. X            newgroup (opts);
  427. X            break;
  428. X        case CC_RMGROUP:
  429. X            rmgroup (opts);
  430. X            break;
  431. X        case CC_SENDSYS:
  432. X            sendsys ();
  433. X            break;
  434. X        case CC_SENDUUNAME:
  435. X            senduuname ();
  436. X            break;
  437. X        case CC_VERSION:
  438. X            sendversion ();
  439. X            break;
  440. X        case CC_CHECKGROUPS:
  441. X            checkgroups ();
  442. X            break;
  443. X    }
  444. X}
  445. X
  446. Xvoid
  447. Xcheck_control ()
  448. X{
  449. X    register charc    *tmp;
  450. X    char        *ptr;
  451. X
  452. X    if (tmp = get_header_line (H_CONTROL))
  453. X        ptr = skip_field (tmp->text);
  454. X    else if (ngs) {
  455. X        tmp = ngs;
  456. X        while (tmp)
  457. X            if ((ptr = rindex (ngs->text, '.')) && (Strieql (ptr, CTRL_POSTFIX)))
  458. X                break;
  459. X            else
  460. X                tmp = tmp->next;
  461. X        ptr = NULL;
  462. X        if (tmp)
  463. X            if (tmp = get_header_line (H_SUBJECT))
  464. X                ptr = skip_field (tmp->text);
  465. X    } else
  466. X        ptr = NULL;
  467. X    if (ptr)
  468. X        do_control (ptr);
  469. X}
  470. __END__OF__THIS__FILE__
  471. if test -f 'INEWS/dbg.c' ; then
  472.   echo 'File INEWS/dbg.c already exists, overwriting it'
  473.   del 'INEWS/dbg.c'
  474. fi
  475. echo Extracting \"'INEWS/dbg.c'\"
  476. sed "s/^X//" >'INEWS/dbg.c' <<'__END__OF__THIS__FILE__'
  477. X/*
  478. X * $Log:    dbg.c_v $
  479. X * Revision 1.1  91/05/22  13:38:16  ud
  480. X * Initial revision
  481. X * 
  482. X * 
  483. X */
  484. X# ifndef    LINT
  485. Xstatic char rcsid[] = "$Id: dbg.c_v 1.1 91/05/22 13:38:16 ud Exp $";
  486. X# endif        LINT
  487. X# include    <stdio.h>
  488. X# include    "inews.h"
  489. X# include    "hist.h"
  490. X
  491. Xvoid
  492. Xdump_charc (e)
  493. Xregister charc *e;
  494. X{
  495. X    for (; e; e = e->next)
  496. X        printf ("text=\"%s\", nr=%d\n", e->text, e->nr);
  497. X}
  498. X
  499. Xvoid
  500. Xdump_sys (e)
  501. Xregister sys *e;
  502. X{
  503. X    register int    t;
  504. X
  505. X    for (; e; e = e->next) {
  506. X        printf ("site=\"%s\"\n", e->site);
  507. X        if (e->wsites)
  508. X            for (t = 0; e->wsites[t]; ++t)
  509. X                printf ("\twsites[%d]=\"%s\"\n", t, e->wsites[t]);
  510. X        printf ("\tfwd=%d\n", e->fwd);
  511. X        if (e->grps && e->inv) {
  512. X            printf ("\tinv");
  513. X            for (t = 0; e->grps[t]; ++t)
  514. X                printf (", [%d]=%s", t, e->inv[t] ? "true" : "false");
  515. X            printf ("\n");
  516. X        }
  517. X        if (e->dist)
  518. X            for (t = 0; e->dist[t]; ++t)
  519. X                printf ("\tdist[%d]=\"%s\"\n", t, e->dist[t]);
  520. X        if (e->cmd)
  521. X            printf ("\tcmd=\"%s\"\n", e->cmd);
  522. X    }
  523. X}
  524. X
  525. Xvoid
  526. Xdump_active (e)
  527. Xregister active *e;
  528. X{
  529. X    register int    t;
  530. X
  531. X    for (; e; e = e->next) {
  532. X        printf ("grp=\"%s\", flag=%d, low=%d, high=%d, pos=%d, changed= %d, aflag='%c%c' kblimit=%d\n",
  533. X            e->grp, e->flag, e->low, e->high, e->pos,
  534. X            e->changed, e->aflag[0], e->aflag[1],
  535. X            e -> kblimit);
  536. X        if (e->moderator && e->moderator[0])
  537. X            for (t = 0; e->moderator[t]; ++t)
  538. X                printf ("\tmoderator[%d]=\"%s\"\n", t, e->moderator[t]);
  539. X    }
  540. X}
  541. X
  542. Xvoid
  543. Xdump_archive (e)
  544. Xregister archive *e;
  545. X{
  546. X    for (; e; e = e->next)
  547. X        printf ("grp=\"%s\", len=%d, dest=\"%s\", prefix=\"%s\"\n",
  548. X            e->grp, e->len,
  549. X            e->dest ? e->dest : "(none)",
  550. X            e->prefix ? e->prefix : "(none)");
  551. X}
  552. __END__OF__THIS__FILE__
  553. if test -f 'INEWS/ddst.c' ; then
  554.   echo 'File INEWS/ddst.c already exists, overwriting it'
  555.   del 'INEWS/ddst.c'
  556. fi
  557. echo Extracting \"'INEWS/ddst.c'\"
  558. sed "s/^X//" >'INEWS/ddst.c' <<'__END__OF__THIS__FILE__'
  559. X/*
  560. X * $Log:    ddst.c_v $
  561. X * Revision 1.1  90/08/31  15:33:19  cs
  562. X * Initial revision
  563. X * 
  564. X */
  565. X# ifndef    LINT
  566. Xstatic char rcsid[] = "$Id: ddst.c_v 1.1 90/08/31 15:33:19 cs Exp $";
  567. X# endif        LINT
  568. X# include    <c8type.h>
  569. X# include    <modes.h>
  570. X# include    "inews.h"
  571. X
  572. Xextern char    *malloc ();
  573. X
  574. Xvoid
  575. Xmake_default_dists ()
  576. X{
  577. X    register char    *ptr;
  578. X    regexp        *reg;
  579. X    char        *buf;
  580. X    char        *grp;
  581. X    char        *dst;
  582. X    char        *cmt;
  583. X    int        fd, n;
  584. X    charc        *t1, *t2;
  585. X    charc        *tmp, *append;
  586. X
  587. X    if (!ngs)
  588. X        return;
  589. X    if ((fd = open (DIST_FILE, S_IREAD)) < 0)
  590. X        return;
  591. X    catlines = TRUE;
  592. X    while (buf = readbuf (fd, & n)) {
  593. X        if ((n < 2) || (buf[0] == '#'))
  594. X            continue;
  595. X        buf[n - 1] = '\0';
  596. X        grp = buf;
  597. X        dst = skipc (buf, '\0');
  598. X        cmt = skipc (dst, '\0');
  599. X        if (!(reg = regcomp (grp)))
  600. X            continue;
  601. X        ptr = grp;
  602. X        while (*ptr) {
  603. X            *ptr = to8lower (*ptr);
  604. X            ++ptr;
  605. X        }
  606. X        t1 = ngs;
  607. X        while (t1)
  608. X            if (regexec (reg, t1->text))
  609. X                break;
  610. X            else
  611. X                t1 = t1->next;
  612. X        free ((char *) reg);
  613. X        if (t1 && (tmp = split_fields (dst, TRUE))) {
  614. X            t2 = dists;
  615. X            while (t2) {
  616. X                t1 = tmp;
  617. X                while (t1) {
  618. X                    if (Streql (t2->text, t1->text))
  619. X                        t1->text[0] = '\0';
  620. X                    t1 = t1->next;
  621. X                }
  622. X                t2 = t2->next;
  623. X            }
  624. X            append = dists;
  625. X            if (append)
  626. X                while (append->next)
  627. X                    append = append->next;
  628. X            t1 = tmp;
  629. X            while (t1) {
  630. X                t2 = t1->next;
  631. X                if (t1->text[0] == '\0') {
  632. X                    free (t1->text);
  633. X                    free ((char *) t1);
  634. X                } else {
  635. X                    if (append)
  636. X                        append->next = t1;
  637. X                    else
  638. X                        dists = t1;
  639. X                    append = t1;
  640. X                    append->next = NULL;
  641. X                }
  642. X                t1 = t2;
  643. X            }
  644. X        }
  645. X    }
  646. X    catlines = FALSE;
  647. X    close (fd);
  648. X}
  649. __END__OF__THIS__FILE__
  650. if test -f 'INEWS/delh.c' ; then
  651.   echo 'File INEWS/delh.c already exists, overwriting it'
  652.   del 'INEWS/delh.c'
  653. fi
  654. echo Extracting \"'INEWS/delh.c'\"
  655. sed "s/^X//" >'INEWS/delh.c' <<'__END__OF__THIS__FILE__'
  656. X/*
  657. X * $Log:    delh.c_v $
  658. X * Revision 1.1  90/08/31  15:33:23  cs
  659. X * Initial revision
  660. X * 
  661. X */
  662. X# ifndef    LINT
  663. Xstatic char rcsid[] = "$Id: delh.c_v 1.1 90/08/31 15:33:23 cs Exp $";
  664. X# endif        LINT
  665. X# include    "inews.h"
  666. X
  667. Xvoid
  668. Xdelete_header (id)
  669. Xregister int id;
  670. X{
  671. X    register charc    *tmp, *t2;
  672. X
  673. X    if ((id < 0) || (id > HEADER_MAX))
  674. X        return;
  675. X    tmp = head;
  676. X    t2 = NULL;
  677. X    while (tmp)
  678. X        if (Strnieql (tmp->text, hlines[id] + 2, strlen (hlines[id] + 2))) {
  679. X                if (t2)
  680. X                    t2->next = tmp->next;
  681. X                else
  682. X                    head = head->next;
  683. X                free (tmp->text);
  684. X                free ((char *) tmp);
  685. X                tmp = head;
  686. X            } else {
  687. X                t2 = tmp;
  688. X                tmp = tmp->next;
  689. X            }
  690. X}
  691. X
  692. Xvoid
  693. Xdel_obsolete_header ()
  694. X{
  695. X    register int    t;
  696. X
  697. X    for (t=0;hlines[t];++t) {
  698. X        if (hlines[t][0] != '2')
  699. X            continue;
  700. X        delete_header (t);
  701. X    }
  702. X}
  703. X
  704. __END__OF__THIS__FILE__
  705. if test -f 'INEWS/exp.c' ; then
  706.   echo 'File INEWS/exp.c already exists, overwriting it'
  707.   del 'INEWS/exp.c'
  708. fi
  709. echo Extracting \"'INEWS/exp.c'\"
  710. sed "s/^X//" >'INEWS/exp.c' <<'__END__OF__THIS__FILE__'
  711. X/*
  712. X * $Log:    exp.c_v $
  713. X * Revision 1.5  91/05/22  13:27:47  ud
  714. X * Correct expire of a list of newsgroups (now working)
  715. X * Allows other inews' running while in expire (this isn't the best
  716. X * solution, but better than nothing: Every inews fails when locking
  717. X * for lck.inews and saves the articles in a seperate directory; after
  718. X * each file (in non ndbm mode) and at the end of expire, inews scans
  719. X * this directory and feed them to itself)
  720. X * 
  721. X * Revision 1.4  91/01/02  21:28:02  ud
  722. X * Added ndbm support for history
  723. X * 
  724. X * Revision 1.3  90/12/01  15:52:35  ud
  725. X * Cleaned up a bit; make expire compatible to ols news
  726. X * version
  727. X * 
  728. X * Revision 1.2  90/10/26  14:19:14  ud
  729. X * Added archive stuff; only working with expire and a given list
  730. X * of newsgourps to expire
  731. X * 
  732. X * Revision 1.1  90/08/31  15:33:26  cs
  733. X * Initial revision
  734. X * 
  735. X */
  736. X# ifndef    LINT
  737. Xstatic char rcsid[] = "$Id: exp.c_v 1.5 91/05/22 13:27:47 ud Exp $";
  738. X# endif        LINT
  739. X# include    <c8type.h>
  740. X# include    <time.h>
  741. X# include    <modes.h>
  742. X# include    <dir.h>
  743. X# include    "inews.h"
  744. X# include    "hist.h"
  745. X
  746. X/*
  747. X *    Important! This file must start
  748. X *    with a digit!
  749. X */
  750. X# define    EXP_TMP        "1_working_file"
  751. X
  752. X# define    DO_WRITE    (1<<0)
  753. X# define    DO_DELETE    (1<<1)
  754. X# define    DO_ARCHIVE    (1<<2)
  755. X
  756. Xextern char    *malloc ();
  757. Xextern char    *rindex ();
  758. Xextern char    *strdup ();
  759. X
  760. Xstatic int    deleted, checked, archived;
  761. Xstatic charc    *rngs;
  762. Xstatic archive    *arc, *tarc;
  763. X
  764. Xstatic void
  765. Xsetup_rngs ()
  766. X{
  767. X    register charc    *act, *cur;
  768. X    register active    *ta;
  769. X    charc        *tmp;
  770. X    register char    *p;
  771. X    int        isok;
  772. X
  773. X    if (!hact)
  774. X        if (read_active () < 0)
  775. X            do_exit (_errmsg (1, "Can't read active-file for expire\n"));
  776. X    for (act = ngs; act; act = act->next)
  777. X        act->nr = strlen (act->text);
  778. X    for (ta = hact; ta; ta = ta->next) {
  779. X        act = ngs;
  780. X        isok = FALSE;
  781. X        for (act = ngs; act; act = act->next)
  782. X            if (act->text[0] == '!') {
  783. X                if (_cmpnam (ta->grp, act->text + 1, act->nr - 1) == 0) {
  784. X                    act = NULL;
  785. X                    isok = FALSE;
  786. X                    break;
  787. X                }
  788. X            } else if (_cmpnam (ta->grp, act->text, act->nr) == 0)
  789. X                isok = TRUE;
  790. X        if (isok && (tmp = (charc *) malloc (sizeof (charc))))
  791. X            if (tmp->text = strdup (ta->grp)) {
  792. X                tmp->nr = 0;
  793. X                p = tmp->text;
  794. X                while (*p)
  795. X                    if (((!is8alnum (*p)) || (!is8ascii (*p))) && (*p != '.'))
  796. X                        *p++ = '_';
  797. X                    else
  798. X                        ++p;
  799. X                tmp->next = NULL;
  800. X                if (!rngs)
  801. X                    rngs = tmp;
  802. X                else
  803. X                    cur->next = tmp;
  804. X                cur = tmp;
  805. X            } else
  806. X                free ((char *) tmp);
  807. X    }
  808. X}
  809. X                
  810. Xstatic int
  811. Xto_expire (tima, timh, buf)
  812. Xtime_t tima, timh;
  813. Xchar *buf;
  814. X{
  815. X    register charc    *tmp;
  816. X    char        **ags;
  817. X    register int    t;
  818. X    char        *ptr, *sav;
  819. X    char        artstate;
  820. X    char        *lbuf;
  821. X    char        *gpn;
  822. X    int        status;
  823. X    int        exptim;
  824. X
  825. X    tarc = NULL;
  826. X    exptim = atoi (buf);
  827. X    if (tima < exptim)
  828. X        status = DO_WRITE;
  829. X    else
  830. X        status = DO_DELETE;
  831. X    if (timh < exptim)
  832. X        status |= DO_WRITE;
  833. X    if (!(ngs || arc))
  834. X        return (status);
  835. X    ptr = skipn (buf, '\0');
  836. X    ptr = skipn (ptr, '\0');
  837. X    artstate = *ptr;
  838. X    if (artstate == ART_EXPIRED)
  839. X        status &= (~DO_DELETE);
  840. X    sav = skipn (ptr, '\0');
  841. X
  842. X    if (!(lbuf = strdup (sav)))
  843. X        return (status & (~DO_DELETE));
  844. X    if (getargs (lbuf, &ags) < 0) {
  845. X        free (lbuf);
  846. X        return (status & (~DO_DELETE));
  847. X    }
  848. X    for (t=0;ags[t];++t) {
  849. X        if (!(gpn = strdup (ags[t]))) {
  850. X            status &= (~DO_DELETE);
  851. X            break;
  852. X        }
  853. X        if (ptr = rindex (gpn, '/')) {
  854. X            *ptr = '\0';
  855. X            ptr = gpn;
  856. X            while (*ptr)
  857. X                if (*ptr == '/')
  858. X                    *ptr++ = '.';
  859. X                else
  860. X                    ++ptr;
  861. X        }
  862. X        if (ngs) {
  863. X            tmp = rngs;
  864. X            while (tmp)
  865. X                if (_cmpnam (gpn, tmp->text, strlen (tmp->text)) == 0)
  866. X                    break;
  867. X                else
  868. X                    tmp = tmp->next;
  869. X            if (!tmp) {
  870. X                status &= (~DO_DELETE);
  871. X                if (artstate == ART_EXISTS)
  872. X                    status |= DO_WRITE;
  873. X            }
  874. X        }
  875. X        if (arc) {
  876. X            tarc = arc;
  877. X            while (tarc)
  878. X                if (_cmpnam (gpn, tarc->grp, tarc->len) == 0) {
  879. X                    status |= DO_ARCHIVE;
  880. X                    break;
  881. X                } else
  882. X                    tarc = tarc->next;
  883. X        }
  884. X        free (gpn);
  885. X    }
  886. X    free ((char *) ags);
  887. X    free (lbuf);
  888. X    if ((!(status & DO_DELETE)) && (status & DO_ARCHIVE))
  889. X        status &= (~DO_ARCHIVE);
  890. X    return (status);
  891. X}
  892. X
  893. Xstatic void
  894. Xexpire (fn, diffa, diffh, buf)
  895. Xchar *fn;
  896. Xint diffa, diffh;
  897. Xchar *buf;
  898. X{
  899. X    int    fdi, fdo;
  900. X    int    n;
  901. X    time_t    tima, timh;
  902. X    char    *ptr, *delnam;
  903. X    char    *sav;
  904. X    int    st;
  905. X
  906. X    time (&tima);
  907. X    timh = tima;
  908. X    tima -= diffa;
  909. X    timh -= diffh;
  910. X# ifndef    USE_NDBM
  911. X    if ((fdi = open (fn, S_IREAD)) < 0) {
  912. X        do_log ("Can't open %s while in expire\n", fn);
  913. X        return;
  914. X    }
  915. X    unlink (EXP_TMP);
  916. X    if ((fdo = create (EXP_TMP, S_IWRITE | S_ISIZE, 03, _gs_size (fdi))) < 0) {
  917. X        do_log ("Can't create %s in expire\n", EXP_TMP);
  918. X        close (fdi);
  919. X        return;
  920. X    }
  921. X    while (buf = readbuf (fdi, & n)) {            /* } */
  922. X        buf[n - 1] = '\0';
  923. X# else        /* USE_NDBM */
  924. X    for (key = dbm_firstkey (db); key.dptr; key = dbm_nextkey (db)) {
  925. X        dat = dbm_fetch (db, key);
  926. X        memcpy (&hist, dat.dptr, sizeof (history));
  927. X        sprintf (buf, "%d %s %c %s", 
  928. X            hist.tim,
  929. X            key.dptr,
  930. X            (char) hist.flag,
  931. X            hist.fns);
  932. X# endif        /* USE_NDBM */
  933. X        ++checked;
  934. X        st = to_expire (tima, timh, buf);
  935. X        if (st & DO_DELETE) {
  936. X# ifndef    USE_NDBM
  937. X            if (st & DO_WRITE)
  938. X                sav = strdup (buf);
  939. X            else
  940. X                sav = NULL;
  941. X# endif        /* USE_NDBM */
  942. X            ptr = skipc (buf, '\0');
  943. X            ptr = skipc (ptr, '\0');
  944. X            if (*ptr != ART_EXPIRED) {
  945. X                ptr = skipc (ptr, '\0');
  946. X                ++deleted;
  947. X                while (*ptr) {
  948. X                    delnam = ptr;
  949. X                    ptr = skipc (ptr, '\0');
  950. X                    if (tarc) {
  951. X                        ++archived;
  952. X                        do_archive (delnam, tarc);
  953. X                        tarc = NULL;
  954. X                    }
  955. X                    unlink_in_newsdir_file (delnam);
  956. X                }
  957. X            }
  958. X# ifndef    USE_NDBM
  959. X            if (sav) {
  960. X                strcpy (buf, sav);
  961. X                ptr = skipn (buf, '\0');
  962. X                ptr = skipn (ptr, '\0');
  963. X                *ptr = ART_EXPIRED;
  964. X                free (sav);
  965. X            } else
  966. X                st = 0;
  967. X# else        /* USE_NDBM */
  968. X            hist.flag = ART_EXPIRED;
  969. X# endif        /* USE_NDBM */
  970. X        }
  971. X# ifndef    USE_NDBM
  972. X        if (st & DO_WRITE) {
  973. X            buf[n - 1] = '\n';
  974. X            write (fdo, buf, n);
  975. X        }
  976. X# else        /* USE_NDBM */
  977. X        if (st & DO_WRITE) {
  978. X            fill_hist ();
  979. X            dbm_store (db, key, dat, DBM_REPLACE);
  980. X        } else
  981. X            dbm_delete (db, key);
  982. X# endif        /* USE_NDBM */
  983. X    }
  984. X# ifndef    USE_NDBM
  985. X    close (fdi);
  986. X    n = _gs_size (fdo);
  987. X    close (fdo);
  988. X    unlink (fn);
  989. X    if (n == 0)
  990. X        unlink (EXP_TMP);
  991. X    else
  992. X        rename (EXP_TMP, fn);
  993. X# endif        /* USE_NDBM */
  994. X}
  995. X
  996. Xvoid
  997. Xdo_expire (delart, delhist)
  998. Xchar *delart, *delhist;
  999. X{
  1000. X# ifndef    USE_NDBM
  1001. X    charc        *etmp, *hexp, *e2;
  1002. X    DIR        *dp;
  1003. X    struct direct    *ent;
  1004. X    int        tout;
  1005. X# endif        /* USE_NDBM */
  1006. X    char        *buf;
  1007. X    int        diffart, diffhist;
  1008. X
  1009. X    if (!(buf = malloc (2048)))
  1010. X        do_exit (_errmsg (1, "Can't alloc memory\n"));
  1011. X    diffart = atoi (delart) * 24 * 60 * 60;
  1012. X    if (delhist)
  1013. X        diffhist = atoi (delhist) * 24 * 60 * 60;
  1014. X    else
  1015. X        diffhist = diffart;
  1016. X    checked = 0;
  1017. X    deleted = 0;
  1018. X    archived = 0;
  1019. X    rngs = NULL;
  1020. X    if (ngs) {
  1021. X        setup_rngs ();
  1022. X        if (!rngs)
  1023. X            return;
  1024. X    }
  1025. X    arc = setup_archive ();
  1026. X# ifndef    USE_NDBM
  1027. X    hexp = NULL;
  1028. X    e2 = NULL;
  1029. X    if (!(dp = opendir (HIST_DIR)))
  1030. X        do_exit (_errmsg (1, "Can't open %s\n", HIST_DIR));
  1031. X    while (ent = readdir (dp)) {
  1032. X        if (ent->d_name[0] == '.')
  1033. X            continue;
  1034. X
  1035. X        /*
  1036. X         *    No valid history file may start with
  1037. X         *    a digit! 
  1038. X         */
  1039. X        if (isdigit (ent->d_name[0]))
  1040. X            continue;
  1041. X
  1042. X        if (!(etmp = (charc *) malloc (sizeof (charc))))
  1043. X            do_exit (_errmsg (1, "Can't alloc during dir-reading\n"));
  1044. X        if (!(etmp->text = strdup (ent->d_name)))
  1045. X            do_exit (_errmsg (1, "Can't alloc during dir-reading\n"));
  1046. X        etmp->next = NULL;
  1047. X        if (!hexp)
  1048. X            hexp = etmp;
  1049. X        else
  1050. X            e2->next = etmp;
  1051. X        e2 = etmp;
  1052. X    }
  1053. X    closedir (dp);
  1054. X    if (chdir (HIST_DIR) < 0)
  1055. X        do_exit (_errmsg (1, "Can't chdir to %s\n", HIST_DIR));
  1056. X    etmp = hexp;
  1057. X    while (etmp) {
  1058. X        expire (etmp->text, diffart, diffhist, buf);
  1059. X        etmp = etmp->next;
  1060. X        nunlock ();
  1061. X        respool (FALSE);
  1062. X        while (tout-- > 100)
  1063. X            if (nlock () != -1)
  1064. X                break;
  1065. X        if (tout <= 0)
  1066. X            break;
  1067. X        else if ((chdir (newslib) < 0) || (chdir (HIST_DIR) < 0))
  1068. X            break;
  1069. X    }
  1070. X# else        /* USE_NDBM */
  1071. X    if (!(db = open_hist (S_IREAD | S_IWRITE)))
  1072. X        do_exit (_errmsg (1, "Can't open %s.\n", HISTORY));
  1073. X    expire (NULL, diffart, diffhist, buf);
  1074. X    dbm_close (db);
  1075. X# endif        /* USE_NDBM */
  1076. X    do_log ("Expire: %d articles checked, %d deleted, %d archived.\n", checked, deleted, archived);
  1077. X    if (rngs)
  1078. X        free_field (rngs);
  1079. X    free_archive (arc);
  1080. X    if (chdir (newslib) < 0)
  1081. X        do_exit (_errmsg (1, "Can't chdir to %s\n", newslib));
  1082. X}
  1083. __END__OF__THIS__FILE__
  1084. if test -f 'INEWS/ext.h' ; then
  1085.   echo 'File INEWS/ext.h already exists, overwriting it'
  1086.   del 'INEWS/ext.h'
  1087. fi
  1088. echo Extracting \"'INEWS/ext.h'\"
  1089. sed "s/^X//" >'INEWS/ext.h' <<'__END__OF__THIS__FILE__'
  1090. X/*
  1091. X * 
  1092. X * $Log:    ext.h_v $
  1093. X * Initial revision
  1094. X * Revision 1.1  90/08/31  15:33:31  cs
  1095. X */
  1096. Xextern void    cancel_msg ();
  1097. Xextern void    check_control ();
  1098. Xextern void    check_message_id ();
  1099. Xextern void    checkgroups ();
  1100. Xextern void    del_obsolete_header ();
  1101. Xextern void    delete_dup_charc ();
  1102. Xextern void    do_archive ();
  1103. Xextern void    do_control ();
  1104. Xextern void    do_exit ();
  1105. Xextern void    do_expire ();
  1106. Xextern void    do_log ();
  1107. Xextern void    free_archive ();
  1108. X# ifdef        IN_MEMORY
  1109. Xextern void    free_list ();
  1110. X# endif        /* IN_MEMORY */
  1111. X# ifdef        CANCEL_SEND_CONTROL
  1112. Xextern void    force_cancel ();
  1113. X# endif        /* CANCEL_SEND_CONTROL */
  1114. Xextern void    handle_special ();
  1115. Xextern void    mail_it ();
  1116. Xextern void    mail_to ();
  1117. Xextern void    make_fn ();
  1118. Xextern void    newgroup ();
  1119. Xextern void    parse_args ();
  1120. Xextern void    pipe_it ();
  1121. Xextern void    rebuild_active_file ();
  1122. Xextern void    rmgroup ();
  1123. Xextern void    sendsys ();
  1124. Xextern void    senduuname ();
  1125. Xextern void    sendversion ();
  1126. Xextern void    set_msgid ();
  1127. Xextern void    sort_active ();
  1128. Xextern void    special_header ();
  1129. Xextern void    test_systems ();
  1130. Xextern void    unlink_in_newsdir_dir ();
  1131. Xextern void    write_it ();
  1132. Xextern char    *catcharc ();
  1133. Xextern char    *create_fn ();
  1134. Xextern char    *exists_message_id ();
  1135. Xextern char    *extract_address ();
  1136. Xextern char    *find_address ();
  1137. Xextern char    *find_address_hl ();
  1138. Xextern char    *find_followup_to ();
  1139. Xextern char    *find_from ();
  1140. Xextern char    *find_from_addr ();
  1141. Xextern char    *get_msgid ();
  1142. Xextern char    *get_path ();
  1143. Xextern char    *get_realfilename ();
  1144. Xextern char    *input_line ();
  1145. X# ifdef        USE_NDBM
  1146. Xextern char    *lower_mid ();
  1147. X# endif        /* USE_NDBM */
  1148. Xextern char    *make_own_address ();
  1149. Xextern char    *make_realfilename ();
  1150. Xextern char    *ntime ();
  1151. Xextern char    *readbuf ();
  1152. Xextern char    *skipc ();
  1153. Xextern char    *skipn ();
  1154. Xextern char    *update_lists ();
  1155. Xextern char    do_command ();
  1156. Xextern char    extra_menu ();
  1157. X# ifdef        HASH_SEARCH
  1158. Xextern hash_t    calc_hash ();
  1159. Xextern active    *find_active ();
  1160. X# endif        /* HASH_SEARCH */
  1161. Xextern charc    *copy_field ();
  1162. Xextern charc    *get_header_line ();
  1163. Xextern charc    *get_limit_newsgroups ();
  1164. Xextern charc    *make_head ();
  1165. Xextern charc    *split_fields ();
  1166. Xextern archive    *setup_archive ();
  1167. X# ifdef        IN_MEMORY
  1168. Xextern list    *get_file ();
  1169. X# endif        /* IN_MEMORY */
  1170. __END__OF__THIS__FILE__
  1171. if test -f 'INEWS/fcan.c' ; then
  1172.   echo 'File INEWS/fcan.c already exists, overwriting it'
  1173.   del 'INEWS/fcan.c'
  1174. fi
  1175. echo Extracting \"'INEWS/fcan.c'\"
  1176. sed "s/^X//" >'INEWS/fcan.c' <<'__END__OF__THIS__FILE__'
  1177. X/*
  1178. X * $Log$
  1179. X * 
  1180. X */
  1181. X# ifndef    LINT
  1182. Xstatic char rcsid[] = "$Id$";
  1183. X# endif        LINT
  1184. X# include    <stdio.h>
  1185. X# include    <time.h>
  1186. X# include    "inews.h"
  1187. X
  1188. X# ifdef        CANCEL_SEND_CONTROL
  1189. Xextern char    *malloc ();
  1190. Xextern FILE    *xpopen ();
  1191. X
  1192. Xvoid
  1193. Xforce_cancel (msg)
  1194. Xchar *msg;
  1195. X{
  1196. X    charc    *tmp;
  1197. X    FILE    *pp;
  1198. X    int    t;
  1199. X    char    *ptr;
  1200. X    char    *buf;
  1201. X    char    *name;
  1202. X    time_t    tim;
  1203. X
  1204. X    block_forward = TRUE;
  1205. X    if (! (buf = malloc (512))) {
  1206. X        do_log ("FATAL: malloc in force_cancel()\n");
  1207. X        do_exit (0);
  1208. X    }
  1209. X    nunlock ();
  1210. X    if (! (pp = xpopen (INEWS, "w"))) {
  1211. X        free (buf);
  1212. X        do_exit (0);
  1213. X    }
  1214. X    for (t = 0; hlines[t]; ++t) {
  1215. X        ptr = buf;
  1216. X        switch (t) {
  1217. X            case H_PATH:
  1218. X                sprintf (buf, "%s %s",
  1219. X                    hlines[H_PATH] + 2, news_owner);
  1220. X                break;
  1221. X            case H_FROM:
  1222. X                if (! (name = find_from (FALSE)))
  1223. X                    name = news_owner;
  1224. X                sprintf (buf, "%s %s",
  1225. X                    hlines[H_FROM] + 2, name);
  1226. X                break;
  1227. X            case H_NEWSGROUPS:
  1228. X                if (tmp = get_header_line (H_NEWSGROUPS))
  1229. X                    sprintf (buf, "%s %s",
  1230. X                        hlines[H_NEWSGROUPS] + 2,
  1231. X                        skip_field (tmp -> text));
  1232. X                else
  1233. X                    ptr = NULL;
  1234. X                break;
  1235. X            case H_TO:
  1236. X                sprintf (buf, "%s Postmaster@%s",
  1237. X                    hlines[H_TO] + 2,
  1238. X                    fhost);
  1239. X                break;
  1240. X            case H_SUBJECT:
  1241. X            case H_CONTROL:
  1242. X                if (tmp = get_header_line (H_MESSAGE_ID))
  1243. X                    sprintf (buf, "%s %s %s",
  1244. X                        hlines[t] + 2,
  1245. X                        ctrlcodes[CC_CANCEL],
  1246. X                        skip_field (tmp -> text));
  1247. X                else
  1248. X                    ptr = NULL;
  1249. X                break;
  1250. X            case H_MESSAGE_ID:
  1251. X                if (tmp = get_header_line (H_MESSAGE_ID))
  1252. X                    sprintf (buf, "%s C%s",
  1253. X                        hlines[H_MESSAGE_ID] + 2,
  1254. X                        skip_field (tmp -> text));
  1255. X                else
  1256. X                    ptr = NULL;
  1257. X                break;
  1258. X            case H_DISTRIBUTION:
  1259. X                if (tmp = get_header_line (H_DISTRIBUTION))
  1260. X                    strcpy (buf, tmp -> text);
  1261. X                else
  1262. X                    ptr = NULL;
  1263. X                break;
  1264. X            case H_DATE:
  1265. X                time (&tim);
  1266. X                sprintf (buf, "%s %s",
  1267. X                    hlines[H_DATE] + 2,
  1268. X                    ntime (&tim));
  1269. X                break;
  1270. X            case H_ORGANIZATION:
  1271. X                sprintf (buf, "%s News-Cancel Service",
  1272. X                    hlines[H_ORGANIZATION] + 2);
  1273. X                break;
  1274. X            case H_APPROVED:
  1275. X                if (! (name = find_from (FALSE)))
  1276. X                    name = news_owner;
  1277. X                sprintf (buf, "%s %s",
  1278. X                    hlines[H_APPROVED] + 2,
  1279. X                    name);
  1280. X                break;
  1281. X            case H_LINES:
  1282. X                sprintf (buf, "%s 0",
  1283. X                    hlines[H_LINES] + 2);
  1284. X                break;
  1285. X            default:
  1286. X                ptr = NULL;
  1287. X                break;
  1288. X        }
  1289. X        if (ptr)
  1290. X            fprintf (pp, "%s\n", buf);
  1291. X    }
  1292. X    pclose (pp);
  1293. X    free (buf);
  1294. X    do_exit (0);
  1295. X}
  1296. X# endif        /* CANCEL_SEND_CONTROL */
  1297. X
  1298. __END__OF__THIS__FILE__
  1299. if test -f 'INEWS/ffrom.c' ; then
  1300.   echo 'File INEWS/ffrom.c already exists, overwriting it'
  1301.   del 'INEWS/ffrom.c'
  1302. fi
  1303. echo Extracting \"'INEWS/ffrom.c'\"
  1304. sed "s/^X//" >'INEWS/ffrom.c' <<'__END__OF__THIS__FILE__'
  1305. X/*
  1306. X * $Log:    ffrom.c_v $
  1307. X * Revision 1.1  90/08/31  15:33:35  cs
  1308. X * Initial revision
  1309. X * 
  1310. X */
  1311. X# ifndef    LINT
  1312. Xstatic char rcsid[] = "$Id: ffrom.c_v 1.1 90/08/31 15:33:35 cs Exp $";
  1313. X# endif        LINT
  1314. X# include    <c8type.h>
  1315. X# include    "inews.h"
  1316. X
  1317. Xextern char    *index ();
  1318. Xextern char    *malloc ();
  1319. X
  1320. Xchar *
  1321. Xfind_from (use_reply_first)
  1322. Xint use_reply_first;
  1323. X{
  1324. X    charc    *tmp;
  1325. X    char    *from;
  1326. X
  1327. X    if (use_reply_first) {
  1328. X        if (!(tmp = get_header_line (H_REPLY_TO)))
  1329. X            tmp = get_header_line (H_FROM);
  1330. X    } else
  1331. X        if (!(tmp = get_header_line (H_FROM)))
  1332. X            tmp = get_header_line (H_REPLY_TO);
  1333. X    if (!tmp)
  1334. X        if (!(tmp = get_header_line (H_SENDER)))
  1335. X            return (NULL);
  1336. X    from = skip_field (tmp->text);
  1337. X    return (from);
  1338. X}
  1339. X
  1340. Xchar *
  1341. Xextract_address (s)
  1342. Xchar *s;
  1343. X{
  1344. X    char        *ad;
  1345. X    char        *from;
  1346. X    register char    *p1, *p2;
  1347. X
  1348. X    if (!(ad = malloc (strlen (s) + 10)))
  1349. X        return (NULL);
  1350. X    p1 = skip_field (s);
  1351. X    if (*p1 == '(') {
  1352. X        while (*p1 && (*p1 != ')'))
  1353. X            ++p1;
  1354. X        if (*p1)
  1355. X            ++p1;
  1356. X        while (is8space (*p1))
  1357. X            ++p1;
  1358. X    }
  1359. X    if (!*p1) {
  1360. X        free (ad);
  1361. X        return (NULL);
  1362. X    }
  1363. X    p2 = ad;
  1364. X    from = p1;
  1365. X    if (p1 = index (from, '<')) {
  1366. X        ++p1;
  1367. X        while (*p1 && (*p1 != '>'))
  1368. X            *p2++ = *p1++;
  1369. X    } else {
  1370. X        p1 = from;
  1371. X        while (*p1 && (!is8space (*p1)))
  1372. X            *p2++ = *p1++;
  1373. X    }
  1374. X    *p2 = '\0';
  1375. X    return (ad);
  1376. X}
  1377. X
  1378. Xchar *
  1379. Xfind_address_hl (id)
  1380. Xint id;
  1381. X{
  1382. X    charc    *tmp;
  1383. X    char    *ad;
  1384. X
  1385. X    if (!(tmp = get_header_line (id)))
  1386. X        return (NULL);
  1387. X    ad = extract_address (tmp->text);
  1388. X    return (ad);
  1389. X}
  1390. X
  1391. Xchar *
  1392. Xfind_address ()
  1393. X{
  1394. X    char        *ad;
  1395. X
  1396. X    if (!(ad = find_address_hl (H_FROM)))
  1397. X        ad = find_address_hl (H_SENDER);
  1398. X    return (ad);
  1399. X}
  1400. X
  1401. Xchar *
  1402. Xfind_from_addr (use_reply_first)
  1403. Xint use_reply_first;
  1404. X{
  1405. X    charc    *tmp;
  1406. X    char    *from;
  1407. X
  1408. X    if (use_reply_first) {
  1409. X        if (!(tmp = get_header_line (H_REPLY_TO)))
  1410. X            tmp = get_header_line (H_FROM);
  1411. X    } else
  1412. X        if (!(tmp = get_header_line (H_FROM)))
  1413. X            tmp = get_header_line (H_REPLY_TO);
  1414. X    if (!tmp)
  1415. X        if (!(tmp = get_header_line (H_SENDER)))
  1416. X            return (NULL);
  1417. X    return (extract_address (tmp->text));
  1418. X}
  1419. X
  1420. X
  1421. __END__OF__THIS__FILE__
  1422. if test -f 'INEWS/ffup.c' ; then
  1423.   echo 'File INEWS/ffup.c already exists, overwriting it'
  1424.   del 'INEWS/ffup.c'
  1425. fi
  1426. echo Extracting \"'INEWS/ffup.c'\"
  1427. sed "s/^X//" >'INEWS/ffup.c' <<'__END__OF__THIS__FILE__'
  1428. X/*
  1429. X * $Log:    ffup.c_v $
  1430. X * Revision 1.1  91/02/03  15:35:12  ud
  1431. X * Initial revision
  1432. X * 
  1433. X */
  1434. X# ifndef    LINT
  1435. Xstatic char rcsid[] = "$Id: ffup.c_v 1.1 91/02/03 15:35:12 ud Exp $";
  1436. X# endif        LINT
  1437. X# include    <modes.h>
  1438. X# include    "inews.h"
  1439. X
  1440. Xextern char    *malloc ();
  1441. Xextern char    *strdup ();
  1442. X
  1443. Xchar *
  1444. Xfind_followup_to (list)
  1445. Xcharc *list;
  1446. X{
  1447. X    char        *buf;
  1448. X    int        fd;
  1449. X    int        n;
  1450. X    char        *fup;
  1451. X    char        *res;
  1452. X    charc        *fhead, *tmp, *cur;
  1453. X    register charc    *srch;
  1454. X
  1455. X    if ((fd = open (FOLLOW_FILE, S_IREAD)) < 0)
  1456. X        return (NULL);
  1457. X    if (!(list = copy_field (list))) {
  1458. X        close (fd);
  1459. X        return (NULL);
  1460. X    }
  1461. X    for (srch = list; srch; srch = srch->next)
  1462. X        srch->nr = strlen (srch->text);
  1463. X    fhead = NULL;
  1464. X    cur = NULL;
  1465. X    catlines = TRUE;
  1466. X    while (buf = readbuf (fd, & n)) {
  1467. X        buf[n - 1] = '\0';
  1468. X        if ((buf[0] == '#') || (n == 1))
  1469. X            continue;
  1470. X        fup = skipc (buf, '\0');
  1471. X        if (!(*fup && *buf))
  1472. X            continue;
  1473. X        for (srch = list; srch; srch = srch->next)
  1474. X            if (srch->text[0] && (_cmpnam (buf, srch->text, srch->nr) != -1))
  1475. X                break;
  1476. X        if (srch) {
  1477. X            if (tmp = (charc *) malloc (sizeof (charc)))
  1478. X                if (tmp->text = strdup (fup)) {
  1479. X                    tmp->next = NULL;
  1480. X                    if (!cur)
  1481. X                        fhead = tmp;
  1482. X                    else
  1483. X                        cur->next = tmp;
  1484. X                    cur = tmp;
  1485. X                } else
  1486. X                    free ((char *) tmp);
  1487. X            srch->text[0] = '\0';
  1488. X        }
  1489. X    }
  1490. X    catlines = FALSE;
  1491. X    close (fd);
  1492. X    if (fhead) {
  1493. X        for (cur = fhead; cur->next; cur = cur->next)
  1494. X            ;
  1495. X        for (tmp = list; tmp;) {
  1496. X            srch = tmp;
  1497. X            tmp = tmp->next;
  1498. X            if (srch->text[0]) {
  1499. X                cur->next = srch;
  1500. X                srch->next = NULL;
  1501. X                cur = srch;
  1502. X            } else {
  1503. X                free (srch->text);
  1504. X                free ((char *) srch);
  1505. X            }
  1506. X        }
  1507. X        delete_dup_charc (fhead);
  1508. X        res = catcharc (fhead, ",");
  1509. X        free_field (fhead);
  1510. X    } else
  1511. X        res = NULL;
  1512. X    return (res);
  1513. X}
  1514. __END__OF__THIS__FILE__
  1515. if test -f 'INEWS/getd.c' ; then
  1516.   echo 'File INEWS/getd.c already exists, overwriting it'
  1517.   del 'INEWS/getd.c'
  1518. fi
  1519. echo Extracting \"'INEWS/getd.c'\"
  1520. sed "s/^X//" >'INEWS/getd.c' <<'__END__OF__THIS__FILE__'
  1521. X/*
  1522. X * $Log:    getd.c_v $
  1523. X * Revision 1.1  90/08/31  15:33:39  cs
  1524. X * Initial revision
  1525. X * 
  1526. X */
  1527. X# ifndef    LINT
  1528. Xstatic char rcsid[] = "$Id: getd.c_v 1.1 90/08/31 15:33:39 cs Exp $";
  1529. X# endif        LINT
  1530. X# include    <modes.h>
  1531. X# include    "inews.h"
  1532. X
  1533. Xextern char    *malloc ();
  1534. X
  1535. Xvoid
  1536. Xget_dists_and_ngs (fn)
  1537. Xchar *fn;
  1538. X{
  1539. X    char    *buf;
  1540. X    char    *tmp;
  1541. X    int    n;
  1542. X    int    fd;
  1543. X
  1544. X    if (dists && ngs)
  1545. X        return;
  1546. X    if (!(buf = malloc (512)))
  1547. X        return;
  1548. X    strcpy (buf, newsdir);
  1549. X    strcat (buf, "/");
  1550. X    strcat (buf, fn);
  1551. X    if ((fd = open (buf, S_IREAD)) < 0) {
  1552. X        free (buf);
  1553. X        return;
  1554. X    }
  1555. X    while ((n = readln (fd, buf, 500)) > 1) {
  1556. X        buf[n - 1] = '\0';
  1557. X        if ((!dists) && (Strnieql (buf, hlines[H_DISTRIBUTION] + 2, strlen (hlines[H_DISTRIBUTION] + 2)))) {
  1558. X            tmp = skip_field (buf);
  1559. X            dists = split_fields (tmp, TRUE);
  1560. X            if (dists && ngs)
  1561. X                break;
  1562. X        } else if ((!ngs) && (Strnieql (buf, hlines[H_NEWSGROUPS] + 2, strlen (hlines[H_NEWSGROUPS] + 2)))) {
  1563. X            tmp = skip_field (buf);
  1564. X            ngs = split_fields (tmp, TRUE);
  1565. X            if (dists && ngs)
  1566. X                break;
  1567. X        }
  1568. X    }
  1569. X    close (fd);
  1570. X    free (buf);
  1571. X}
  1572. __END__OF__THIS__FILE__
  1573. if test -f 'INEWS/gfh.c' ; then
  1574.   echo 'File INEWS/gfh.c already exists, overwriting it'
  1575.   del 'INEWS/gfh.c'
  1576. fi
  1577. echo Extracting \"'INEWS/gfh.c'\"
  1578. sed "s/^X//" >'INEWS/gfh.c' <<'__END__OF__THIS__FILE__'
  1579. X/*
  1580. X *    Extra sourcefile for this function, because it should be
  1581. X *    easiely changeable (should be moved to os9lib.l)
  1582. X */
  1583. X# ifdef        NEED_GETFULLHOSTNAME
  1584. Xchar *
  1585. Xgetfullhostname (buf, len)
  1586. Xchar *buf;
  1587. Xint len;
  1588. X{
  1589. X    return (info_str ("fullhost", buf, len - 1));
  1590. X}
  1591. X# endif        /* NEED_GETFULLHOSTNAME */
  1592. __END__OF__THIS__FILE__
  1593. if test -f 'INEWS/ghead.c' ; then
  1594.   echo 'File INEWS/ghead.c already exists, overwriting it'
  1595.   del 'INEWS/ghead.c'
  1596. fi
  1597. echo Extracting \"'INEWS/ghead.c'\"
  1598. sed "s/^X//" >'INEWS/ghead.c' <<'__END__OF__THIS__FILE__'
  1599. X/*
  1600. X * $Log:    ghead.c_v $
  1601. X * Revision 1.1  90/08/31  15:33:43  cs
  1602. X * Initial revision
  1603. X * 
  1604. X */
  1605. X# ifndef    LINT
  1606. Xstatic char rcsid[] = "$Id: ghead.c_v 1.1 90/08/31 15:33:43 cs Exp $";
  1607. X# endif        LINT
  1608. X# include    "inews.h"
  1609. X
  1610. Xcharc *
  1611. Xget_header_line (id)
  1612. Xregister int id;
  1613. X{
  1614. X    register charc    *tmp;
  1615. X
  1616. X    if ((id < 0) || (id > HEADER_MAX))
  1617. X        return (NULL);
  1618. X    tmp = head;
  1619. X    while (tmp)
  1620. X        if (Strnieql (tmp->text, hlines[id] + 2, strlen (hlines[id] + 2)))
  1621. X            break;
  1622. X        else
  1623. X            tmp = tmp->next;
  1624. X    return (tmp);
  1625. X}
  1626. X
  1627. X
  1628. __END__OF__THIS__FILE__
  1629. if test -f 'INEWS/hact' ; then
  1630.   echo 'File INEWS/hact already exists, overwriting it'
  1631.   del 'INEWS/hact'
  1632. fi
  1633. echo Extracting \"'INEWS/hact'\"
  1634. sed "s/^X//" >'INEWS/hact' <<'__END__OF__THIS__FILE__'
  1635. Xachk.c
  1636. Xwact.c
  1637. Xcnew.c
  1638. Xbuild.c
  1639. Xract.c
  1640. Xapp.c
  1641. Xsinfo.c
  1642. Xexp.c
  1643. Xcchk.c
  1644. Xcrm.c
  1645. __END__OF__THIS__FILE__
  1646. if test -f 'INEWS/hash.c' ; then
  1647.   echo 'File INEWS/hash.c already exists, overwriting it'
  1648.   del 'INEWS/hash.c'
  1649. fi
  1650. echo Extracting \"'INEWS/hash.c'\"
  1651. sed "s/^X//" >'INEWS/hash.c' <<'__END__OF__THIS__FILE__'
  1652. X/*
  1653. X * $Log$
  1654. X *
  1655. X */
  1656. X# ifndef    LINT
  1657. Xstatic char rcsid[] = "$Id$";
  1658. X# endif        LINT
  1659. X# include    "inews.h"
  1660. X# ifdef        HASH_SEARCH
  1661. X
  1662. Xactive *
  1663. Xfind_active (grp)
  1664. Xregister char *grp;
  1665. X{
  1666. X    register hash_t    id;
  1667. X    register active    *run;
  1668. X
  1669. X    id = calc_hash (grp, TRUE);
  1670. X    run = hashact[id % HASH_ACTIVE];
  1671. X    while (run)
  1672. X        if ((run -> id == id) && Strieql (grp, run -> grp))
  1673. X            return (run);
  1674. X        else
  1675. X            run = run -> hnext;
  1676. X    return (NULL);
  1677. X}
  1678. X# endif        /* HASH_SEARCH */
  1679. __END__OF__THIS__FILE__
  1680. if test -f 'INEWS/hist.h' ; then
  1681.   echo 'File INEWS/hist.h already exists, overwriting it'
  1682.   del 'INEWS/hist.h'
  1683. fi
  1684. echo Extracting \"'INEWS/hist.h'\"
  1685. sed "s/^X//" >'INEWS/hist.h' <<'__END__OF__THIS__FILE__'
  1686. X/*
  1687. X * $Log:    hist.h_v $
  1688. X * Revision 1.1  91/01/02  21:33:07  ud
  1689. X * Initial revision
  1690. X * 
  1691. X */
  1692. X/*
  1693. X *    Flags in history file
  1694. X */
  1695. X# define    ART_EXISTS    '1'
  1696. X# define    ART_EXPIRED    '0'
  1697. X
  1698. X# ifndef    USE_NDBM
  1699. X# define    HIST_FILE    "HISTORY/history.%04d"
  1700. X# define    HIST_DIR    "HISTORY"
  1701. X
  1702. X/*
  1703. X *    The maximum value for the hash-algorithm
  1704. X *    should be a prim-number
  1705. X *    This is equal to the number of creating
  1706. X *    history-files
  1707. X *    Possible values are: 19, 23, 29, 37, 43, 59, 73, 97
  1708. X *    and a lot of others (these are only some suggenstions!)
  1709. X */
  1710. X# define    HIST_MAXIMUM    37
  1711. X
  1712. X# else        /* USE_NDBM */
  1713. X
  1714. X# include    <ndbm.h>
  1715. X
  1716. X# ifndef    CLK_TCK
  1717. X# include    <time.h>
  1718. X# endif        /* CLK_TCK */
  1719. X
  1720. X# define    HISTORY        "HistoryDBM"
  1721. X
  1722. Xtypedef struct _history {
  1723. X    time_t    tim;
  1724. X    int    flag;
  1725. X    char    fns[1024];
  1726. X} history;
  1727. X
  1728. Xextern DBM    *open_hist ();
  1729. X
  1730. XEXTERN datum    key, dat;
  1731. XEXTERN history    *hptr, hist;
  1732. XEXTERN DBM    *db;
  1733. X# endif        /* USE_NDBM */
  1734. __END__OF__THIS__FILE__
  1735. if test -f 'INEWS/ihead.c' ; then
  1736.   echo 'File INEWS/ihead.c already exists, overwriting it'
  1737.   del 'INEWS/ihead.c'
  1738. fi
  1739. echo Extracting \"'INEWS/ihead.c'\"
  1740. sed "s/^X//" >'INEWS/ihead.c' <<'__END__OF__THIS__FILE__'
  1741. X/*
  1742. X * $Log:    ihead.c_v $
  1743. X * Revision 1.1  90/08/31  15:33:46  cs
  1744. X * Initial revision
  1745. X * 
  1746. X */
  1747. X# ifndef    LINT
  1748. Xstatic char rcsid[] = "$Id: ihead.c_v 1.1 90/08/31 15:33:46 cs Exp $";
  1749. X# endif        LINT
  1750. X# include    "inews.h"
  1751. X
  1752. Xextern char    *malloc ();
  1753. X
  1754. Xint
  1755. Xinsert_header (id, s, replace_it)
  1756. Xint id;
  1757. Xchar *s;
  1758. Xint replace_it;
  1759. X{
  1760. X    char        *buf;
  1761. X    charc        *tmp;
  1762. X    register charc    *t2;
  1763. X
  1764. X    if ((id < 0) || (id > HEADER_MAX))
  1765. X        return (-1);
  1766. X    if (!(buf = malloc (strlen (hlines[id] + 2) + strlen (s) + 6)))
  1767. X        return (-1);
  1768. X    strcpy (buf, hlines[id] + 2);
  1769. X    strcat (buf, " ");
  1770. X    strcat (buf, s);
  1771. X    if (tmp = get_header_line (id)) {
  1772. X        if (replace_it) {
  1773. X            free (tmp->text);
  1774. X            tmp->text = buf;
  1775. X        } else
  1776. X            free (buf);
  1777. X    } else {
  1778. X        if (!(tmp = (charc *) malloc (sizeof (charc)))) {
  1779. X            free (buf);
  1780. X            return (-1);
  1781. X        }
  1782. X        tmp->text = buf;
  1783. X        tmp->next = NULL;
  1784. X        if (!head)
  1785. X            head = tmp;
  1786. X        else {
  1787. X            t2 = head;
  1788. X            while (t2->next)
  1789. X                    t2 = t2->next;
  1790. X            t2->next = tmp;
  1791. X        }
  1792. X    }
  1793. X    return (0);
  1794. X}
  1795. __END__OF__THIS__FILE__
  1796. if test -f 'INEWS/inews.c' ; then
  1797.   echo 'File INEWS/inews.c already exists, overwriting it'
  1798.   del 'INEWS/inews.c'
  1799. fi
  1800. echo Extracting \"'INEWS/inews.c'\"
  1801. sed "s/^X//" >'INEWS/inews.c' <<'__END__OF__THIS__FILE__'
  1802. X/*
  1803. X * $Log:    inews.c_v $
  1804. X * Revision 1.3  91/12/26  13:41:06  ud
  1805. X * insert a new locking mechanism with events; not yet tested
  1806. X * 
  1807. X * Revision 1.2  91/05/22  13:20:01  ud
  1808. X * Added storing of articles in a seperate sub directory if lck.inews
  1809. X * can't be locked
  1810. X * 
  1811. X * Revision 1.1  90/08/31  15:33:49  cs
  1812. X * Initial revision
  1813. X * 
  1814. X */
  1815. X# ifndef    LINT
  1816. Xstatic char rcsid[] = "$Id: inews.c_v 1.3 91/12/26 13:41:06 ud Exp $";
  1817. Xstatic char copyright[] = "Copyright (C) 1989, 1990 by Ulrich Dessauer, Germering, Germany.\n";
  1818. X# endif        LINT
  1819. X# include    <signal.h>
  1820. X# define    EXTERN
  1821. X# include    "inews.h"
  1822. X# include    "hist.h"
  1823. X# ifdef        EVENT_LOCK
  1824. X# include    "lock.h"
  1825. X# endif        /* EVENT_LOCK */
  1826. X
  1827. Xint
  1828. Xhandler (sig)
  1829. Xint sig;
  1830. X{
  1831. X    switch (sig) {
  1832. X        case SIGHUP:
  1833. X            break;
  1834. X# ifdef        EVENT_LOCK
  1835. X        case SIGALRM:
  1836. X            _got_alarm = TRUE;
  1837. X            break;
  1838. X# endif        /* EVENT_LOCK */
  1839. X        default:
  1840. X# ifdef        EVENT_LOCK
  1841. X            do_unlock ("*");
  1842. X# endif        /* EVENT_LOCK */
  1843. X            exit (sig);
  1844. X            break;
  1845. X    }
  1846. X}
  1847. X
  1848. Xint
  1849. Xmain (argc, argv)
  1850. Xint argc;
  1851. Xchar *argv[];
  1852. X{
  1853. X    int    n;
  1854. X
  1855. X    zero_out ();
  1856. X    parse_args (argc, argv);
  1857. X    intercept (handler);
  1858. X    if ((n = do_init (TRUE)) < 0) {
  1859. X        if ((n != -2) || (do_store () < 0)) {
  1860. X            do_log ("Failed in do_init()\n");
  1861. X            do_exit (1);
  1862. X        }
  1863. X        do_exit (0);
  1864. X    }
  1865. X    if (read_active () < 0) {
  1866. X        do_log ("Failed in read_active()\n");
  1867. X        do_exit (1);
  1868. X    }
  1869. X    if (read_sys () < 0) {
  1870. X        do_log ("Failed in read_sys()\n");
  1871. X        do_exit (1);
  1872. X    }
  1873. X    if (read_header (0) < 0) {
  1874. X        do_log ("Failed in read_header()\n");
  1875. X        do_exit (1);
  1876. X    }
  1877. X    if (check_active () < 0) {
  1878. X        do_log ("Failed in check_active()\n");
  1879. X        do_exit (1);
  1880. X    }
  1881. X    if (write_groups () < 0) {
  1882. X        do_log ("Failed in write_groups()\n");
  1883. X        do_exit (1);
  1884. X    }
  1885. X    if (process_sys () < 0) {
  1886. X        do_log ("Failed in process_sys()\n");
  1887. X        do_exit (1);
  1888. X    }
  1889. X    if (restore_active () < 0) {
  1890. X        do_log ("Failed in restore_active()\n");
  1891. X        do_exit (1);
  1892. X    }
  1893. X    do_exit (0);
  1894. X}
  1895. __END__OF__THIS__FILE__
  1896. if test -f 'INEWS/inews.h' ; then
  1897.   echo 'File INEWS/inews.h already exists, overwriting it'
  1898.   del 'INEWS/inews.h'
  1899. fi
  1900. echo Extracting \"'INEWS/inews.h'\"
  1901. sed "s/^X//" >'INEWS/inews.h' <<'__END__OF__THIS__FILE__'
  1902. X/*
  1903. X * $Log:    inews.h_v $
  1904. X * Revision 1.4  91/05/22  13:33:16  ud
  1905. X * Added defines for Newsgroups file, Temp.file
  1906. X * Added define for Supersedes: field
  1907. X * 
  1908. X * Revision 1.3  91/01/02  21:29:38  ud
  1909. X * Removed the defines for history management and put them in a own
  1910. X * include file, hist.h
  1911. X * 
  1912. X * Revision 1.2  90/12/01  15:40:13  ud
  1913. X * Added struct for archiving news
  1914. X * Changed history relevant entries for hashing
  1915. X * 
  1916. X * Revision 1.1  90/08/31  15:34:00  cs
  1917. X * Initial revision
  1918. X * 
  1919. X */
  1920. X/*
  1921. X *    Format of the sys-file
  1922. X *    <site>{/sites(,sites)}{>fflag(s)}:<groups>:<dist>{:<cmd>}
  1923. X *    <site>   ::= the name of the site to forward this news
  1924. X *                   (check against member in the Path: field)
  1925. X *      <sites>  ::= this optional list of sites are to be not part of
  1926. X *                   the Path: otherwise they are not forwarded
  1927. X *    <fflags> ::= Flags to be prefixed to the filename in the file
  1928. X *                   in the batchdirectory
  1929. X *      <groups> ::= A list of to be send newsgroups for this site
  1930. X *    <dist>   ::= List of distributions for this site, !dist is
  1931. X *                   allowed to disable a distributin
  1932. X *      <cmd>    ::= Command to be executed, if not default is used
  1933. X *                   (default is storing all filenames in a file with
  1934. X *                   the filename equal to the sitename in a batch-
  1935. X *                   directory)
  1936. X */
  1937. X/*
  1938. X *    Format of the history-file:
  1939. X *    <number> <msg-id> <flag> <filename> {<filename>}
  1940. X *    number   ::= return value of time()
  1941. X *    msg-id   ::= the messageid of that article
  1942. X *      flag     ::= "0" | "1" ; "1" it article still exists, "0" if only
  1943. X *                   to be checked as duplicate articels
  1944. X *    filename ::= filename of article and all "pseudo"-links
  1945. X */
  1946. X/*
  1947. X *    Format of the active-file:
  1948. X *    <grp>:<low> <high> <aflag>{ <moderator>}
  1949. X *    <grp>       ::= The name of the group
  1950. X *    <low>       ::= the low mark (the number of the oldest article)
  1951. X *      <high>      ::= the high mark (the newest article on the system)
  1952. X *      <aflag>      ::= Moderatorflag (n = not mod., y = is mod.) or ignore
  1953. X *      <moderator> ::= The Name of the Moderators
  1954. X */
  1955. X/*
  1956. X *    Format of the .newsrc File:
  1957. X *      <flag><grp>:<low>:<high>:{<unread>}
  1958. X *      <flag>      ::= the group is unsubscribed
  1959. X *      <grp>       ::= the name of the group
  1960. X *      <low>       ::= All articles lower than this are obsolete (incl. this)
  1961. X *    <high>      ::= All articles higher than this are new
  1962. X *      <unread>    ::= A list of unread articles in this group
  1963. X */
  1964. X/*
  1965. X *    Format of the Distributions File:
  1966. X *    <group> <dist>{,<dist>} [<comment>]
  1967. X *    <group>     ::= A regular expression for the desired group
  1968. X *    <dist>      ::= A default distribution on this group
  1969. X *      <comment>   ::= A comment describing this newsgroup (opt.)
  1970. X */
  1971. X/*
  1972. X *    Format of Archive FIle:
  1973. X *    <group> <directory> {<prefix>}
  1974. X *    <group>     ::= The newsgroup to be archived (wildcard allowed)
  1975. X *      <directory> ::= A valid absolute path to a directory where to this
  1976. X *            gorup should be archived
  1977. X *    <prefix>    ::= Optional prefix to be placed before the unique
  1978. X *            number in the destination directory
  1979. X */
  1980. X# include    <regexp.h> 
  1981. X# include    "news.h"
  1982. X# include    "patchlevel.h"
  1983. X
  1984. X/*
  1985. X *    Some standard defienes
  1986. X */
  1987. X# ifndef    NULL
  1988. X# define    NULL        0
  1989. X# endif        NULL
  1990. X
  1991. X/*
  1992. X *    Current version
  1993. X */
  1994. X# define    VERSION        "1.03"
  1995. X# ifndef    PATCHLEVEL
  1996. X# define    VERSIONSTR    "MNews (minimal News system for OSK) V %s"
  1997. X# else        PATCHLEVEL
  1998. X# define    VERSIONSTR    "MNews (minimal News system for OSK) V %s (PL %d)"
  1999. X# endif        PATCHLEVEL
  2000. X
  2001. X/*
  2002. X *    Default directories
  2003. X */
  2004. X# define    NEWS_BATCH    MNEWS_BATCHDIR
  2005. X# define    NEWS_DIR    MNEWS_NEWSDIR
  2006. X# define    NEWS_LIB    MNEWS_NEWSLIB
  2007. X# define    NEWS_TSPOOL    MNEWS_TSPOOLDIR
  2008. X
  2009. X/*
  2010. X *    Some Filenames
  2011. X */
  2012. X# define    ACTIVE_FILE    "Active"
  2013. X# define    ACT_BAK_FILE    "Active.bak"
  2014. X# define    SYS_FILE    "Sys"
  2015. X# define    DIST_FILE    "Distributions"
  2016. X# define    CHK_FILE    "Checkgroups"
  2017. X# define    ALIAS_FILE    "Aliases"
  2018. X# define    LOG_FILE    "logfile"
  2019. X# define    UUNAME_FILE    "send_uuname"
  2020. X# define    ARCHIVE_FILE    "Archive"
  2021. X# define    FOLLOW_FILE    "Followup"
  2022. X
  2023. X# define    NEWSGROUPS_FILE    "Newsgroups"
  2024. X
  2025. X# define    TEMP_FILE    "$$$temp_file$$$"
  2026. X
  2027. X# define    EDITOR        "me"
  2028. X
  2029. X/*
  2030. X *    Access mode for the path for makdir()
  2031. X */
  2032. X# define    ACCESS_PATH    3
  2033. X
  2034. X/*
  2035. X *    Lock entry, only one program should run which changes
  2036. X *    files relating to inews
  2037. X */
  2038. X# define    NEWS_LOCK    "lck.inews"
  2039. X
  2040. X/*
  2041. X *    this specifies the time how long to wait for a lock
  2042. X *    -1 means wait forever, 0 means don't wait and every
  2043. X *    positiv number is the wait value in seconds
  2044. X */
  2045. X# define    LOCK_TIMEOUT    6
  2046. X
  2047. X/*
  2048. X *    Flags in the Active file (Types of moderation, ignore ng. etc.)
  2049. X */
  2050. X# define    M_NOT_MOD    'n'
  2051. X# define    M_MOD        'y'
  2052. X# define    M_IGNORE    'i'
  2053. X# define    M_USE        'u'
  2054. X# define    M_READONLY    'r'
  2055. X
  2056. X/*
  2057. X *    Some special Newsgroups & Distribution & etc.
  2058. X */
  2059. X# define    NG_JUNK        "junk"
  2060. X# define    NG_CONTROL    "control"
  2061. X
  2062. X# define    DST_LOCAL    "local"
  2063. X# define    DST_WORLD    "world"
  2064. X
  2065. X# define    CTRL_POSTFIX    ".ctl"
  2066. X
  2067. X/*
  2068. X *    Lines in header
  2069. X */
  2070. X# define    H_PATH        0
  2071. X# define    H_FROM        1
  2072. X# define    H_REPLY_TO    2
  2073. X# define    H_NEWSGROUPS    3
  2074. X# define    H_TO        4
  2075. X# define    H_CC        5
  2076. X# define    H_SUBJECT    6
  2077. X# define    H_FOLLOWUP_TO    7
  2078. X# define    H_MESSAGE_ID    8
  2079. X# define    H_DISTRIBUTION    9
  2080. X# define    H_DATE        10
  2081. X# define    H_SENDER    11
  2082. X# define    H_REFERENCES    12
  2083. X# define    H_ORGANIZATION    13
  2084. X# define    H_KEYWORDS    14
  2085. X# define    H_SUMMARY    15
  2086. X# define    H_EXPIRES    16
  2087. X# define    H_SUPERSEDES    17
  2088. X# define    H_CONTROL    18
  2089. X# define    H_APPROVED    19
  2090. X# define    H_LINES        20
  2091. X# define    H_XREF        21
  2092. X# define    H_POSTED    22
  2093. X
  2094. X# define    HEADER_MAX    22
  2095. X
  2096. X# define    S_PATH        0
  2097. X# define    S_NEWSGROUPS    1
  2098. X# define    S_TO        2
  2099. X# define    S_SUBJECT    3
  2100. X# define    S_FOLLOWUP_TO    4
  2101. X# define    S_MESSAGE_ID    5
  2102. X# define    S_DISTRIBUTION    6
  2103. X# define    S_REFERENCES    7
  2104. X# define    S_SUPERSEDES    8
  2105. X
  2106. X# define    SPECIAL_MAX    8
  2107. X
  2108. X/*
  2109. X *    Possible Control Messages
  2110. X */
  2111. X# define    CC_CANCEL    0
  2112. X# define    CC_IHAVE    1
  2113. X# define    CC_SENDME    2
  2114. X# define    CC_NEWGROUP    3
  2115. X# define    CC_RMGROUP    4
  2116. X# define    CC_SENDSYS    5
  2117. X# define    CC_SENDUUNAME    6
  2118. X# define    CC_VERSION    7
  2119. X# define    CC_CHECKGROUPS    8
  2120. X
  2121. X/*
  2122. X *    Possible modes for the user-interface
  2123. X */
  2124. X# define    M_NONE        0
  2125. X# define    M_READ        1
  2126. X# define    M_WRITE        2
  2127. X# define    M_MAIL        3
  2128. X
  2129. X/*
  2130. X *    Some macros...
  2131. X */
  2132. X# define    Write(s)        writeln(1,s,strlen(s))
  2133. X# define    skip_field(s)        skipn ((s), ':')
  2134. X# define    is_part_of_hostname(c)    ((c) && (is8alnum (c) || index ("-+._", (c))))
  2135. X
  2136. X/*
  2137. X *    This keeps the header
  2138. X */
  2139. Xtypedef struct _charc {
  2140. X    char    *text;        /* any kind of text            */
  2141. X    int    nr;        /* Number, e.g. Filename for NG        */
  2142. X    struct _charc    *next;
  2143. X} charc;
  2144. X
  2145. X/*
  2146. X *    This hold every line of the sys-File
  2147. X */
  2148. Xtypedef struct _sys {
  2149. X    char    *site;        /* Destination site            */
  2150. X    char    **wsites;    /* don't forward news with this sitenames
  2151. X                   in the Path:                */
  2152. X    char    *fflags;    /* flags for the batchfile        */
  2153. X    int    fwd;        /* if this article should go to sys    */
  2154. X    regexp    **grps;        /* The desired group in reg.exp.    */
  2155. X    int    *inv;        /* if the matching ng should NOT xmit    */
  2156. X    char    **dist;        /* The distributions for this site    */
  2157. X    char    *cmd;        /* the command to pipe to for this site    */
  2158. X    struct _sys    *next;
  2159. X} sys;
  2160. X
  2161. X/*
  2162. X *    The active File
  2163. X */
  2164. Xtypedef struct _active {
  2165. X    char    *grp;        /* group name                */
  2166. X    int    flag;        /* flag for checkgroups etc.        */
  2167. X    int    low;        /* the lowest current number        */
  2168. X    int    high;        /* the highest current number        */
  2169. X    int    pos;        /* position of low/high in file        */
  2170. X    int    changed;    /* if this entry had been changed    */
  2171. X    char    aflag[10];    /* active flag, moderated or ignore    */
  2172. X    int    kblimit;    /* maximum size of an article to be for-
  2173. X                   warded                */
  2174. X    char    **moderator;    /* the name(s) (accounts  of the 
  2175. X                   moderators                */
  2176. X# ifdef        HASH_SEARCH
  2177. X    hash_t    id;        /* the hashed version of the groupname    */
  2178. X    struct _active    *hnext;    /* next entry in the hashline        */
  2179. X# endif        /* HASH_SEARCH */
  2180. X    struct _active    *next;
  2181. X} active;
  2182. X
  2183. X/*
  2184. X *    To manage archive during expire
  2185. X */
  2186. Xtypedef struct _archive {
  2187. X    char    *grp;        /* the name of the group as a wildcard    */
  2188. X    int    len;        /* strlen (archive->grp)        */
  2189. X    char    *dest;        /* the destination directiory        */
  2190. X    char    *prefix;    /* if there should be a prefix in the
  2191. X                   destination filename            */
  2192. X    struct _archive    *next;
  2193. X} archive;
  2194. X
  2195. X/*
  2196. X *    This structure is used to keep track of groups in the
  2197. X *    Newsgroupsfile and not to delete old groups, if they
  2198. X *    are not in the new checkgroups message
  2199. X */
  2200. Xtypedef struct _cgroup {
  2201. X    char    *group;        /* name of the group            */
  2202. X    char    seperate;    /* the seperate character between
  2203. X                   group and comment (mostly space or
  2204. X                   tab)                    */
  2205. X    char    *comment;    /* comment to the gorup            */
  2206. X    struct _cgroup
  2207. X        *next;
  2208. X}    cgroup;
  2209. X
  2210. X# include    "ext.h"
  2211. X
  2212. X# ifndef    EXTERN
  2213. X# define    EXTERN        extern
  2214. Xextern char    *hlines[];
  2215. Xextern char    *slines[];
  2216. Xextern char    *ctrlcodes[];
  2217. X# else        EXTERN
  2218. Xchar    *hlines[] = {
  2219. X    /* first character is 0, 1 or 2, 0 if the line must be present in
  2220. X       the header, 1 if this line may be there 2 if it have to be deleted */
  2221. X    "0 Path:",
  2222. X    "0 From:",
  2223. X    "1 Reply-To:",
  2224. X    "0 Newsgroups:",
  2225. X    "2 To:",
  2226. X    "2 Cc:",
  2227. X    "0 Subject:",
  2228. X    "1 Followup-To:",
  2229. X    "0 Message-ID:",
  2230. X    "1 Distribution:",
  2231. X    "0 Date:",
  2232. X    "1 Sender:",
  2233. X    "1 References:",
  2234. X    "1 Organization:",
  2235. X    "1 Keywords:",
  2236. X    "1 Summary:",
  2237. X    "1 Expires:",
  2238. X    "1 Supersedes:",
  2239. X    "1 Control:",
  2240. X    "1 Approved:",
  2241. X    "0 Lines:",
  2242. X    "2 Xref:",
  2243. X    "1 Posted:",
  2244. X    NULL
  2245. X};
  2246. X
  2247. Xchar    *slines[] = {
  2248. X    "Path:",
  2249. X    "Newsgroups:",
  2250. X    "To:",
  2251. X    "Subject:",
  2252. X    "Followup-To:",
  2253. X    "Message-Id:",
  2254. X    "Distribution:",
  2255. X    "References:",
  2256. X    "Supersedes:",
  2257. X    NULL
  2258. X};
  2259. X
  2260. Xchar    *ctrlcodes[] = {
  2261. X    "cancel",
  2262. X    "ihave",
  2263. X    "sendme",
  2264. X    "newgroup",
  2265. X    "rmgroup",
  2266. X    "sendsys",
  2267. X    "senduuname",
  2268. X    "version",
  2269. X    "checkgroups",
  2270. X    NULL
  2271. X};
  2272. X# endif        EXTERN
  2273. X
  2274. XEXTERN charc    *ngs;        /* the newsgroups of this article    */
  2275. XEXTERN charc    *dists;        /* the distribuitons of this article    */
  2276. XEXTERN charc    *head;        /* the headerlines            */
  2277. XEXTERN sys    *hsys;        /* the sys-file entries            */
  2278. XEXTERN active    *hact;        /* the active file            */
  2279. X# ifdef        HASH_SEARCH
  2280. XEXTERN active    **hashact;    /* the hashtable for the active file    */
  2281. X# endif        /* HASH_SEARCH */
  2282. XEXTERN int    act_rewrite;    /* active file needs complete written    */
  2283. X
  2284. XEXTERN int    artsize;    /* the size of the article        */
  2285. X
  2286. XEXTERN int    block_forward;    /* if forwarding of this article should
  2287. X                   be blocked                */
  2288. X
  2289. XEXTERN charc    *recv;        /* list of receiver for mailing        */
  2290. X
  2291. XEXTERN char    *hostname;    /* The hostname of this system        */
  2292. XEXTERN char    *fhost;        /* Fullhostname (including domain)    */
  2293. XEXTERN char    *news_owner;    /* the owner of the newssystem        */
  2294. X
  2295. XEXTERN char    *batchdir;    /* Directory where batchfiles lives    */
  2296. XEXTERN char    *newsdir;    /* Directory for the news themselves    */
  2297. XEXTERN char    *newslib;    /* Directory for the news files        */
  2298. XEXTERN char    *newstspool;    /* Directory for temp.spooled files    */
  2299. X
  2300. XEXTERN int    crthd;        /* create missing header lines        */
  2301. XEXTERN int    doconv;        /* if a character translation should
  2302. X                   take place                */
  2303. XEXTERN int    ins_dist;    /* If the automatic determination of
  2304. X                   the distributions (if none present)
  2305. X                   should switched on w/o crthd        */
  2306. X
  2307. X# ifndef    IN_MEMORY
  2308. XEXTERN char    newstmp[40 + sizeof (TEMPDIR)];
  2309. X                /* The temp.filename of the body    */
  2310. X# else        /* IN_MEMORY */
  2311. XEXTERN list    *newstmp;    /* the body in memory            */
  2312. X# endif        /* IN_MEMORY */
  2313. X
  2314. XEXTERN charc    *isctrl;    /* if this is a Ctrl-Msg        */
  2315. XEXTERN int    lines;        /* lines in the message            */
  2316. XEXTERN char    *realfile;    /* the filename of the real article    */
  2317. XEXTERN int    catlines;    /* if TRUE, readin cats lines finished
  2318. X                   with a backslash with the next line    */
  2319. XEXTERN int    conv_it;    /* if TRUE, readin converts a character
  2320. X                   set it possible/neccessary        */
  2321. XEXTERN int    isadm;        /* if caller is news.admin        */
  2322. XEXTERN int    verbose;    /* if log messages should appear on scr    */
  2323. XEXTERN char    *user;        /* the name of the user            */
  2324. XEXTERN char    *home;        /* the homedirectory of current user    */
  2325. X
  2326. XEXTERN void    (*local_term) ();
  2327. X                /* if a subsystem of the newssystem
  2328. X                   needs it own cleanup            */
  2329. __END__OF__THIS__FILE__
  2330. exit 0
  2331. : end of shell archive
  2332.  
  2333. -- 
  2334. Frank Kaefer # fkk@stasys.sta.sub.org # Starnberg, Germany
  2335.