* readnews - read news articles.
static char *SccsId
= "@(#)readnews.c 2.33 10/15/87";
* readnews - article reading program
char SYSBUF
[BUFSIZ
]; /* to buffer std out */
#define OPTION 0 /* pick up an option string */
#define STRING 1 /* pick up a string of arguments */
* Matt Glickman ucbvax!glickman
* Stephen Daniels duke!swd
register char *ptr
; /* pointer to rest of buffer */
char *user
= NULL
, *home
= NULL
;
int optflag
= FALSE
, space
= FALSE
;
/* set up defaults and initialize. */
header
.title
[0] = header
.nbuf
[0] = '\0';
coptbuf
[0] = datebuf
[0] = '\0';
strcpy(FROMSYSNAME
, ubuf
.nodename
);
savmask
= umask(N_UMASK
); /* set up mask */
/* give reasonable error message if SPOOL directory
* is unaccessable... usually means system administrator
* has "turned off" news reading...
fputs("News articles are not available at this time\n",stderr
);
if ((SHELL
= getenv("SHELL")) == NULL
)
* IHCC forces the use of 'getuser()' to prevent forgery of articles
* by just changing $LOGNAME
* Note that this shouldn't matter in readnews, since inews
* does all the actual posting of news.
if ((user
= getenv("USER")) == NULL
)
user
= getenv("LOGNAME");
if ((home
= getenv("HOME")) == NULL
)
if (user
== NULL
|| home
== NULL
)
username
= AllocCpy(user
);
(void) strcpy(header
.path
, username
);
userhome
= AllocCpy(home
);
if (!(MAILER
= getenv("MAILER")))
MAILER
= "mail"; /* was /bin/mail */
if (myrc
= getenv("PAGER"))
(void) sprintf(bfr
, "%s/bin/%s", logdir(HOME
), PAGE
);
if (ptr
= getenv("NEWSOPTS"))
(void) strcpy(rcbuf
, ptr
);
(void) strcat(rcbuf
, " \1");
for (ptr
= rcbuf
; ; ptr
++) {
xerror("Too many options.");
if ((rcline
[line
] = malloc((unsigned)(strlen(ptr
) + 1))) == NULL
)
xerror("Not enough memory.");
argvrc
[line
] = rcline
[line
];
(void) strcpy(rcline
[line
], ptr
);
(void) sprintf(newsrc
, "%s/%s", userhome
, myrc
);
(void) strcpy(newsrc
, myrc
);
if ((rcfp
= fopen(newsrc
, "r")) != NULL
) {
while (fgets(rcbuf
, LBUFLEN
, rcfp
) != NULL
) {
if (!(space
= isspace(*rcbuf
)))
if (!STRNCMP(rcbuf
, "options ", 8))
(void) strcat(rcbuf
, "\1");
xerror("Too many options.");
if ((rcline
[line
] = malloc((unsigned)(strlen(ptr
) + 1))) == NULL
)
xerror("Not enough memory.");
argvrc
[line
] = rcline
[line
];
(void) strcpy(rcline
[line
], ptr
);
for (i
= 0; i
<= line
; i
++)
fprintf(stderr
, "options: %s\n", rcline
[i
]);
process(line
+ 2, argvrc
);
fprintf(stderr
, "Freeing %d\n", line
);
(void) strcat(header
.nbuf
, ADMSUB
);
(void) sprintf(header
.nbuf
, "%s,%s", ADMSUB
, DFLTSUB
);
char *p
= rindex(header
.nbuf
, ',');
if (p
&& p
[1] == '\0') /* strip of trailing NGDELIM */
makehimask(header
.nbuf
, "junk");
makehimask(header
.nbuf
, "control");
makehimask(header
.nbuf
, "test");
SigTrap
= FALSE
; /* true if a signal has been caught */
if (!pflag
&& !lflag
&& !eflag
) {
(void) signal(SIGQUIT
, SIG_IGN
);
(void) signal(SIGHUP
, cleanup
);
(void) signal(SIGINT
, onsig
);
(void) signal(SIGPIPE
, onsig
);
if (signal(SIGQUIT
, SIG_IGN
) != SIG_IGN
)
(void) signal(SIGQUIT
, cleanup
);
if (signal(SIGHUP
, SIG_IGN
) != SIG_IGN
)
(void) signal(SIGHUP
, cleanup
);
if (signal(SIGINT
, SIG_IGN
) != SIG_IGN
)
(void) signal(SIGINT
, cleanup
);
* ALL of the command line has now been processed. (!)
strcpy(header
.nbuf
, DFLTSUB
);
printf("Subscription list: %s\n", header
.nbuf
);
rcfp
= xfopen(newsrc
, "r");
while (fgets(rcbuf
, LBUFLEN
, rcfp
) != NULL
) {
xerror(".newsrc line too long");
xerror("Too many .newsrc lines");
if ((rcline
[line
] = malloc((unsigned)(strlen(rcbuf
) + 1))) == NULL
)
xerror("Not enough memory");
(void) strcpy(rcline
[line
], rcbuf
);
if (SigTrap
== SIGHUP
|| !rcreadok
)
fprintf(stdout
, "Abort (n)? ");
if (gets(bfr
) == NULL
|| *bfr
== 'y' || *bfr
== 'Y')
if ((actfp
= open_active()) == NULL
)
xerror("Cannot open active newsgroups file");
strcpy(ACTIVE
, active_name());
actfp
= xfopen(ACTIVE
, "r");
fprintf(stderr
, "header.nbuf = %s\n", header
.nbuf
);
(void) signal(SIGHUP
, SIG_IGN
);
if (news
&& !xflag
&& !lflag
&& !tflag
) {
if (*groupdir
&& mode
!= MAIL
)
* stop vnews from clearing the screen if we're
* Write out the .newsrc file. It's already been cleaned up by sortactive()
* Take care that data is all written, and flushed, before we destroy the
/* NEVER write it out if xflag */
(void) strcpy(aline
, newsrc
);
(void) strcat(aline
, ".new");
wrcfp
= xfopen(aline
, "w");
for (i
= 0; i
<= line
; i
++) {
if (fprintf(wrcfp
, "%s\n", rcline
[i
]) < 0)
(void) vmsdelete(newsrc
);
if (rename(aline
, newsrc
) < 0)
xerror("Cannot rename %s to %s", aline
, newsrc
);
xerror("Error writing new .newsrc file - no changes made\n");
* Forbid newsgroup ng, unless he asked for it in nbuf.
(void) sprintf(rindex(nbuf
, '\0'), ",!%s", ng
);
* Return true if the string searchfor is in string, but not if preceded by !.
findex(string
, searchfor
)
char *string
, *searchfor
;
for (p
=index(string
, first
); p
; p
= index(p
+1, first
)) {
if (((p
==string
) || (p
[-1]!='!')) && STRNCMP(p
, searchfor
, strlen(searchfor
)) == 0)