home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
TELECOM
/
rn_4_3_blars.lzh
/
newsetup.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-03-08
|
2KB
|
74 lines
/* newsetup.c created from newsetup.SH by blarson@usc.edu */
#include <stdio.h>
#include "config.h"
char *getenv(), *index(), *strtok();
static char WHITE[] = " \t\n";
main(argc, argv)
int argc;
char **argv;
{
register char *cp, *cp2;
char *dotdir;
FILE *fp, *ap;
#define MAXLINE 1023
char line[MAXLINE+1];
dotdir = getenv("DOTDIR");
if(dotdir == NULL) {
dotdir = getenv("HOME");
if(dotdir == NULL) {
printf("Could not determine DOTDIR or HOME\n");
exit(1);
}
}
chdir(dotdir);
if (rename(".oldnewsrc",".newsrc") == 0) {
printf(".oldnewsrc restored as .newsrc\n");
exit(0);
}
/* unlink(".oldnewsrc"); */
printf("Creating .newsrc in %s to be used by news programs.\n", dotdir);
rename(".newsrc", ".oldnewsrc");
if((fp = fopen(".newsrc", "w")) == NULL) {
printf("Could not open %s/.newsrc for writing\n", dotdir);
exit(1);
}
chdir(LIB);
if((ap = fopen("active", "r")) == NULL) {
printf("Could not open %s/active\n", LIB);
exit(1);
}
while(fgets(line, MAXLINE, ap) != NULL) {
cp = strtok(line, WHITE);
strtok(NULL, WHITE);
strtok(NULL, WHITE);
cp2 = strtok(NULL, WHITE);
if(cp != NULL && (cp2 == NULL || (*cp2!='x' && *cp2!='='))) {
cp += strlen(cp);
*cp++ = ':';
*cp++ = '\n';
*cp = '\0';
if(strncmp(line, "compuserve", 10) != 0) {
if(strcmp(line, "control:\n") == 0 ||
strcmp(line, "junk:\n") == 0
|| strncmp(line, "test", 4) == 0 ||
strncmp(line, "to.", 3) == 0 ||
((cp > (line + 6)) && strcmp(cp-6, "test:\n")==0))
cp[-2] = '!';
fputs(line, fp);
}
}
}
fclose(ap);
fclose(fp);
printf("If you have never used the news system before, you may find the articles\n");
printf("in news.announce.newusers to be helpful. There is also a manual entry for rn.\n");
printf("\n");
printf("To get rid of newsgroups you aren't interested in, use the 'u' command.\n");
printf("Type h for help at any time while running rn.\n");
}