Article View: news.software.nntp
Article #1762Re: Force user to read certain groups
From: Alan Barrett
Date: Wed, 31 Mar 1993 22:20
Date: Wed, 31 Mar 1993 22:20
196 lines
6649 bytes
6649 bytes
In article <1pbca3$5b4@lucy.ee.und.ac.za>, I wrote:
> If you are contemplating modifying your newsreader software to support
> XMOTD, I believe that you would be better advised to modify your
> newsreader software to force users to read the foolocal.announce
> group. While you're at it, force them to read news.announce.newusers
> too.
Here's a patch for strn-0.8.4 to do some enforcement. Compile with
-DENFORCE. This is not very well designed or tested. Something
similar might work in other versions of strn or trn.
The new force_early_subscription() function adds the specified group to
the newsrc, forces it to be subscribed, and moves it to the specified
location near the front of the newsrc.
The new setngtoforce() function adds a newsgroup to the enforcement
list, and calls force_early_subscription().
The existing initialise() function now calls setngtoforce() for each
group that the administrator chooses to add to the enforcement list.
The existing inlist() function now also checks if the group is in the
enforcement list. This means that restricting newsgroups via the
command line or the 'a' or 'o' commands does not remove the enforced
groups from consideration.
The existing sg_use_file() function now adds the enforced groups to the
front of the top level menu in scangroup mode.
There is no way of removing an entry from the enforcement list, but the
user can manually unsubscribe or move the group to another place in the
newsrc. Of course, next time the user runs trn, the enforcements will
be made again, so unsubscribing is rather pointless.
--apb
Alan Barrett, Dept. of Electronic Eng., Univ. of Natal, Durban, South Africa
RFC822: barrett@ee.und.ac.za
--- init.c.084 Wed Mar 31 22:01:32 1993
+++ init.c Wed Mar 31 23:03:44 1993
@@ -170,6 +170,10 @@
thread_init();
util_init();
+ /* add some groups to the enforcement list */
+ setngtoforce("news.announce.newusers");
+ setngtoforce("news.announce.important");
+
#ifdef NEWSFILTER
if (!strEQ(getval("NCLIP","///"),"///")) {
#ifdef SCORE
--- only.h.084 Wed Mar 31 22:03:16 1993
+++ only.h Wed Mar 31 23:51:28 1993
@@ -24,13 +24,22 @@
# endif
#endif
-EXT int maxngtodo INIT(0); /* 0 => no restrictions */
+EXT int maxngtodo INIT(0); /* 0 => no restrictions */
/* >0 => # of entries in ngtodo */
+#ifdef ENFORCE
+ EXT char *ngtoforce[NGMAX]; /* enforcements in effect */
+ EXT int maxngtoforce INIT(0); /* 0 => no enforcements */
+ /* >0 => # of entries in ngtoforce */
+#endif
+
void only_init _((void));
-bool inlist _((char*)); /* return TRUE if ngname is in command line list */
+bool inlist _((char*)); /* return TRUE if ngname is in enforcement or restriction list */
/* or if there was no list */
-void setngtodo _((char*));
+void setngtodo _((char*)); /* add pattern to restriction list */
+#ifdef ENFORCE
+void setngtoforce _((char*)); /* add group to enforcement list */
+#endif
#ifdef ONLY
-void end_only _((void));
+void end_only _((void)); /* remove restrictions */
#endif
--- only.c.084 Wed Mar 31 22:01:58 1993
+++ only.c Wed Mar 31 23:49:22 1993
@@ -16,6 +16,7 @@
#include "EXTERN.h"
#include "common.h"
#include "search.h"
+#include "rcstuff.h"
#include "util.h"
#include "final.h"
#include "ngsrch.h"
@@ -28,6 +29,7 @@
;
}
+/* add a pattern to the restriction list */
void
setngtodo(pat)
char *pat;
@@ -60,6 +62,39 @@
#endif
}
+#ifdef ENFORCE
+/* Subscribe to a group and move it to near the head of the list. */
+static void
+force_early_subscription(ngnam,loc)
+char *ngnam;
+NG_NUM loc;
+{
+ NG_NUM ng;
+
+ ng = find_ng(ngnam);
+ if (ng == nextrcline) { /* not in .newsrc? */
+ ng = add_newsgroup(ngnam, ':');
+ } else { /* force subscription */
+ register char *cp = rcline[ng] + rcnums[ng];
+ rcchar[ng] = (*cp && cp[1] == '0' ? '0' : ':');
+ }
+ set_toread(ng);
+ ng = relocate_newsgroup(ng, loc);
+}
+
+/* add a group to the enforcement list */
+void
+setngtoforce(ngnam)
+char *ngnam;
+{
+ if (maxngtoforce < NGMAX) {
+ ngtoforce[maxngtoforce] = savestr(ngnam);
+ force_early_subscription(ngnam, (NG_NUM)maxngtoforce);
+ maxngtoforce++;
+ }
+}
+#endif /* ENFORCE */
+
/* if command line list is non-null, is this newsgroup wanted? */
bool
@@ -72,6 +107,12 @@
if (maxngtodo == 0)
return TRUE;
+#ifdef ENFORCE
+ for (i=0; i<maxngtoforce; i++) {
+ if (strEQ(ngtoforce[i],ngnam))
+ return TRUE;
+ }
+#endif
for (i=0; i<maxngtodo; i++) {
if (execute(compextodo[i],ngnam))
return TRUE;
@@ -83,6 +124,12 @@
if (maxngtodo == 0)
return TRUE;
+#ifdef ENFORCE
+ for (i=0; i<maxngtoforce; i++) {
+ if (strEQ(ngtoforce[i],ngnam))
+ return TRUE;
+ }
+#endif
init_compex(&ilcompex);
for (i=0; i<maxngtodo; i++) {
if ((s = ng_comp(&ilcompex,ngtodo[i],TRUE,TRUE)) != Nullch) {
--- sgfile.c.084 Wed Mar 31 23:43:22 1993
+++ sgfile.c Thu Apr 1 00:01:48 1993
@@ -7,6 +7,7 @@
/* trim the list */
#include "EXTERN.h"
#include "common.h"
+#include "only.h"
#include "intrp.h"
#include "search.h"
#include "sgroup.h"
@@ -177,6 +178,19 @@
(void)sg_new_context();
sg_contexts[sg_num_contexts-1].title = savestr(title);
sg_contexts[sg_num_contexts-1].filename = savestr(s);
+
+#ifdef ENFORCE
+ /* If this file is the top-level menu, start with the enforcement list */
+ if (sg_num_contexts == 1) {
+ int i, j;
+ NG_NUM ng;
+ for (i=0; i<maxngtoforce; i++) {
+ ng = find_ng(ngtoforce[i]);
+ j = sg_add_ent(1,ngtoforce[i]);
+ sg_ents[j].groupnum = ng;
+ }
+ }
+#endif /* ENFORCE */
/* Later considerations:
* 1. Long lines
(end)
Technical Details
Message-ID:
<1pd5fa$956@lucy.ee.und.ac.za>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!sparky!uunet!psgrain!ee.und.ac.za!tplinfmReferences:
<1p56qs$pkg@sdl.Warren.MENTORG.COM> <1p7e93INNme2@rodan.UU.NET> <1pakha$35k@genesis.ait.psu.edu> <1pbca3$5b4@lucy.ee.und.ac.za>Show Full Headers
Complete Article Headers
Message-ID: <1pd5fa$956@lucy.ee.und.ac.za> Subject: Re: Force user to read certain groups Date: Wed, 31 Mar 1993 22:20:26 +0000 From: barrett@lucy.ee.und.ac.za (Alan Barrett) References: <1p56qs$pkg@sdl.Warren.MENTORG.COM> <1p7e93INNme2@rodan.UU.NET> <1pakha$35k@genesis.ait.psu.edu> <1pbca3$5b4@lucy.ee.und.ac.za> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!sparky!uunet!psgrain!ee.und.ac.za!tplinfm Newsgroups: news.software.readers,news.software.nntp Organization: Elec. Eng., Univ. Natal, Durban, S. Africa Lines: 196 Distribution: world NNTP-Posting-Host: lucy.ee.und.ac.za