home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-08-09 | 156.6 KB | 5,668 lines |
- diff -cb orig/active.c new/active.c
- *** orig/active.c Thu Jun 11 22:48:12 1992
- --- new/active.c Sun Aug 09 01:39:15 1992
- ***************
- *** 1,5 ****
- /*
- ! SNEWS 1.0
-
- active.c - routines to manipulate the active and ng files
-
- --- 1,5 ----
- /*
- ! SNEWS 2.0
-
- active.c - routines to manipulate the active and ng files
-
- ***************
- *** 122,127 ****
- --- 122,128 ----
- }
-
- this->next = NULL;
- + head->groups = ct;
-
- local_head = head;
-
- ***************
- *** 181,187 ****
- * of the linked list.
- */
- char fn[80], buf[81], *p;
- ! POST_GROUPS *this, *head = NULL ;
- int ct = 0;
- FILE *ngf;
-
- --- 182,188 ----
- * of the linked list.
- */
- char fn[80], buf[81], *p;
- ! POST_GROUPS *this = NULL, *head = NULL ;
- int ct = 0;
- FILE *ngf;
-
- ***************
- *** 215,221 ****
- exit(1);
- }
-
- -
- if ((p = strtok(buf, " \n\r\t")) == NULL) {
- fprintf(stderr, "newsgroup 'ng' file corrupt at line %d\n", ct);
- exit(1);
- --- 216,221 ----
- ***************
- *** 222,231 ****
- --- 222,234 ----
- }
-
- strcpy(this->group, p);
- + this -> local = isupper(*this -> group);
- + strlwr(this -> group);
- }
-
- }
-
- + if ( this )
- this->next = NULL;
-
- fclose(ngf);
- ***************
- *** 281,286 ****
- --- 284,305 ----
- }
-
-
- + int is_local_group(char *ng)
- + {
- + POST_GROUPS *this;
- +
- + this = pg;
- +
- + while (this != NULL) {
- + if (strcmp(ng, this->group) == 0)
- + return(this->local);
- + this = this->next;
- + }
- +
- + return (TRUE);
- + }
- +
- +
-
-
- /*-------------------- find a newsgroup in active list ----------------------*/
- ***************
- *** 481,486 ****
- --- 500,506 ----
-
- ct = 0;
-
- + if (act->read_list)
- for (i = 0; i < articles; i++) {
- if(*((act->read_list)+i)) {
- ct++;
- ***************
- *** 515,521 ****
-
- int res = 0;
- int i;
- ! char buf[256];
- char *fn, *p, *v;
- FILE *tmp;
-
- --- 535,541 ----
-
- int res = 0;
- int i;
- ! char buf[256], confdir[256];
- char *fn, *p, *v;
- FILE *tmp;
-
- ***************
- *** 531,538 ****
- if (my_stuff.news_dir[ strlen(my_stuff.news_dir)-1 ] != '\\')
- strcat(my_stuff.news_dir, "\\");
-
- -
- -
- /* read the system file first */
- for (i = 0; i < 2; i++) {
-
- --- 551,556 ----
- ***************
- *** 554,563 ****
-
- while (fgets(buf, 255, tmp)) {
- p = strtok(buf, " =\r\n");
- ! if (*p != '#') {
-
- v = strtok(NULL, " =\r\n");
-
- if (stricmp(p, "mailserv") == 0) {
- strcpy(my_stuff.mail_server, v);
- res++;
- --- 572,584 ----
-
- while (fgets(buf, 255, tmp)) {
- p = strtok(buf, " =\r\n");
- ! if (p && *p != '#') {
-
- v = strtok(NULL, " =\r\n");
-
- + if (stricmp(p, "confdir") == 0)
- + strcpy(confdir, v);
- +
- if (stricmp(p, "mailserv") == 0) {
- strcpy(my_stuff.mail_server, v);
- res++;
- ***************
- *** 572,577 ****
- --- 593,604 ----
- strcat(my_stuff.incoming_dir, "\\");
- res++;
- }
- + if (stricmp(p, "spooldir") == 0) {
- + strcpy(my_stuff.spool_dir, v);
- + if (my_stuff.spool_dir[ strlen(my_stuff.spool_dir)-1 ] != '\\')
- + strcat(my_stuff.spool_dir, "\\");
- + res++;
- + }
- if (stricmp(p, "domain") == 0) {
- strcpy(my_stuff.my_domain, v);
- res++;
- ***************
- *** 578,584 ****
- }
- if (stricmp(p, "tempdir") == 0) {
- strcpy(my_stuff.temp_name, v);
- - strcat(my_stuff.temp_name, "\\$unbatch");
- res++;
- }
- if (stricmp(p, "mailbox") == 0) {
- --- 605,610 ----
- ***************
- *** 634,640 ****
- }
- }
-
- ! return(res == 11);
- }
-
-
- --- 660,677 ----
- }
- }
-
- ! if ( (p = getenv("LOGNAME")) != NULL ) {
- ! struct passwd *pwd;
- ! if ( (pwd = getpwnam(p, confdir)) != NULL ) {
- ! strcpy(my_stuff.user, pwd -> pw_name);
- ! strcpy(my_stuff.home, pwd -> pw_dir);
- ! strcpy(my_stuff.my_name, pwd -> pw_gecos);
- ! if (my_stuff.home[ strlen(my_stuff.home)-1 ] != '\\')
- ! strcat(my_stuff.home, "\\");
- ! }
- ! }
- !
- ! return(res >= 12);
- }
-
-
- ***************
- *** 657,663 ****
- (gp->hi_num)++;
- update_active_entry(gp);
-
- ! if ((tmp = fopen(fn, "r+b")) == NULL) {
- fprintf(stderr,"active: cannot open text file %s\n", fn);
- exit(1);
- }
- --- 694,700 ----
- (gp->hi_num)++;
- update_active_entry(gp);
-
- ! if ((tmp = flockopen(fn, "r+b")) == NULL) {
- fprintf(stderr,"active: cannot open text file %s\n", fn);
- exit(1);
- }
- ***************
- *** 664,671 ****
- fseek(tmp, 0, SEEK_END);
-
- return(tmp);
- -
- -
- }
-
-
- --- 701,706 ----
- ***************
- *** 685,691 ****
- fn = make_news_group_name(gp->group);
- sprintf(fnx, "%s.IDX", fn);
-
- ! if((tmp = fopen(fnx, "r+b")) == NULL) {
- fprintf(stderr, "active: cannot open index file %s\n", fn);
- exit(1);
- }
- --- 720,726 ----
- fn = make_news_group_name(gp->group);
- sprintf(fnx, "%s.IDX", fn);
-
- ! if((tmp = flockopen(fnx, "r+b")) == NULL) {
- fprintf(stderr, "active: cannot open index file %s\n", fn);
- exit(1);
- }
- ***************
- *** 692,698 ****
- fseek(tmp, 0, SEEK_END);
-
- return(tmp);
- -
- }
-
-
- --- 727,732 ----
- ***************
- *** 712,724 ****
- strcpy(fn, my_stuff.news_dir);
- strcat(fn, "nseq");
-
- ! if ((seq_file = fopen(fn, "r+")) != NULL) {
- fscanf(seq_file, "%d", &seq);
- seq++;
- rewind(seq_file);
- } else {
- seq = 0;
- ! seq_file = fopen(fn, "wt");
- }
-
- fprintf(seq_file, "%d", seq);
- --- 746,758 ----
- strcpy(fn, my_stuff.news_dir);
- strcat(fn, "nseq");
-
- ! if ((seq_file = flockopen(fn, "r+t")) != NULL) {
- fscanf(seq_file, "%d", &seq);
- seq++;
- rewind(seq_file);
- } else {
- seq = 0;
- ! seq_file = flockopen(fn, "wt");
- }
-
- fprintf(seq_file, "%d", seq);
- ***************
- *** 733,739 ****
- {
- void *p;
- if ((p = malloc(size)) == NULL) {
- - gotoxy(1,25);
- fprintf(stderr, "\n\nSORRY - NO MEMORY LEFT \n");
- exit(1);
- }
- --- 767,772 ----
- diff -cb orig/addgroup.c new/addgroup.c
- *** orig/addgroup.c Thu Jun 11 22:48:13 1992
- --- new/addgroup.c Sun Aug 02 20:34:18 1992
- ***************
- *** 1,5 ****
- /*
- ! SNEWS 1.0
-
- addgroup - add a new newsgroup
-
- --- 1,5 ----
- /*
- ! SNEWS 2.0
-
- addgroup - add a new newsgroup
-
- ***************
- *** 46,51 ****
- --- 46,53 ----
- FILE *active_file, *new_active_file;
-
-
- + fprintf(stderr, "ADDGROUP: (%s)\n\n", VERSION);
- +
- if (argc > 1) {
-
- if (!load_stuff()) {
- ***************
- *** 74,81 ****
- fprintf(stderr, "addgroup: cannot create file %s\n", buf);
- exit(1);
- }
- - }
- fclose(tmp);
- sprintf(buf, "%snewsbase\\00000000.idx", my_stuff.news_dir);
- if (access(buf, 0) != 0) {
- if ((tmp = fopen(buf, "wb")) == NULL) {
- --- 76,83 ----
- fprintf(stderr, "addgroup: cannot create file %s\n", buf);
- exit(1);
- }
- fclose(tmp);
- + }
- sprintf(buf, "%snewsbase\\00000000.idx", my_stuff.news_dir);
- if (access(buf, 0) != 0) {
- if ((tmp = fopen(buf, "wb")) == NULL) {
- ***************
- *** 82,89 ****
- fprintf(stderr, "addgroup: cannot create file %s\n", buf);
- exit(1);
- }
- - }
- fclose(tmp);
-
- load_active_file();
- close_active();
- --- 84,91 ----
- fprintf(stderr, "addgroup: cannot create file %s\n", buf);
- exit(1);
- }
- fclose(tmp);
- + }
-
- load_active_file();
- close_active();
- ***************
- *** 180,186 ****
-
-
- } else {
- ! fprintf(stderr, "addgroup: newsgroup %s already exists\n", argv[1]);
- }
-
- }
- --- 182,188 ----
-
-
- } else {
- ! fprintf(stderr, "addgroup: newsgroup %s already exists\n", argv[i]);
- }
-
- }
- ***************
- *** 188,194 ****
- close_active_file();
-
- } else {
- ! printf("USAGE: addgroup newsgroup names....\n");
- }
-
- }
- --- 190,196 ----
- close_active_file();
-
- } else {
- ! printf("usage: addgroup newsgroup names....\n");
- }
-
- }
- Only in new: amatch.c
- diff -cb orig/article.c new/article.c
- *** orig/article.c Thu Jun 11 22:48:13 1992
- --- new/article.c Sun Aug 02 20:34:18 1992
- ***************
- *** 1,6 ****
- /*
-
- ! SNEWS 1.0
-
- news - routines to read and display an article
-
- --- 1,6 ----
- /*
-
- ! SNEWS 2.0
-
- news - routines to read and display an article
-
- ***************
- *** 24,33 ****
- */
-
-
- #include "defs.h"
- #include "snews.h"
-
- ! #include <io.h>
-
- /*------------------------- read in an article -----------------------------*/
- TEXT *load_article(char *fnx, long offset)
- --- 24,74 ----
- */
-
-
- + #include <process.h>
- +
- #include "defs.h"
- #include "snews.h"
-
- !
- ! /*------------------------- recognize address ------------------------------*/
- ! char *plain_address(char *raw)
- ! {
- ! char *ptr = raw, *end;
- !
- ! while (*ptr && !isalnum(*ptr)) {
- !
- ! while (isspace(*ptr)) ptr++;
- !
- ! if (isalnum(*ptr))
- ! break;
- !
- ! if (*ptr == '(') {
- ! for (ptr++; *ptr && *ptr != ')'; ptr++);
- ! if (*ptr == ')') ptr++;
- ! }
- ! else if (*ptr == '"') {
- ! for (ptr++; *ptr && *ptr != '"'; ptr++);
- ! if (*ptr == '"') ptr++;
- ! }
- ! else if (*ptr == '<') {
- ! ptr++;
- ! if ((end = strchr(ptr, '>')) != NULL)
- ! *end = 0;
- ! }
- ! else
- ! ptr++;
- ! }
- !
- ! if ((end = strchr(ptr, ' ')) != NULL)
- ! *end = 0;
- ! if ((end = strchr(ptr, '\t')) != NULL)
- ! *end = 0;
- ! if ((end = strchr(ptr, '\n')) != NULL)
- ! *end = 0;
- !
- ! return ptr;
- ! }
- !
-
- /*------------------------- read in an article -----------------------------*/
- TEXT *load_article(char *fnx, long offset)
- ***************
- *** 38,44 ****
- */
-
- FILE *tmp_file;
- ! char buf[256], lnbuf[256], *p;
- TEXT *tx;
- LINE *ln, *lz;
- int ct, i;
- --- 79,85 ----
- */
-
- FILE *tmp_file;
- ! char lnbuf[MAXLINE];
- TEXT *tx;
- LINE *ln, *lz;
- int ct, i;
- ***************
- *** 46,91 ****
- tx = NULL;
- ct = 0;
-
- ! if ((tmp_file = fopen(fnx, "rb")) != NULL) {
-
- fseek(tmp_file, offset, SEEK_SET);
-
- tx = xmalloc(sizeof(TEXT));
- tx->top = NULL;
- tx->start = NULL;
- ! strcpy(tx->follow_up, "");
- ! strcpy(tx->author, " ** none ** ");
- ! strcpy(tx->organisation, " ** none ** ");
- !
- ! while (fgets(buf, 255, tmp_file) != NULL) {
-
- ! if (strncmp(buf, "@@@@END", 7) == 0) break;
-
- ! expand_tabs(buf, 255);
-
- ! /*
- ! * We now have a line of input. If the line is two long
- ! * it is wrapped at spaces or '!'. The lines of text are
- ! * stored in LINE structures
- ! */
- ! p = &buf[0];
- ! while (strlen(p) > 0) {
- !
- ! strcpy(lnbuf, p);
- ! if (strlen(p) <= 80) {
- ! strcpy(lnbuf, p);
- ! *p = '\x00';
- ! } else {
- ! p += 79;
- ! for (i = 79; i > 50; i--) {
- ! if ((lnbuf[i] == ' ') || (lnbuf[i] == '!'))
- ! break;
- ! p--;
- ! }
- ! lnbuf[i] = '\x00';
- ! }
-
- ! /* is it the first line - if so int the TEXT structure */
- if (ct == 0) {
- ln = xmalloc(sizeof(LINE));
- ln->last = NULL;
- --- 87,112 ----
- tx = NULL;
- ct = 0;
-
- ! if ((tmp_file = flockopen(fnx, "rb")) != NULL) {
-
- + setvbuf(tmp_file, iobuf, _IOFBF, IOBUFSIZE);
- fseek(tmp_file, offset, SEEK_SET);
-
- tx = xmalloc(sizeof(TEXT));
- tx->top = NULL;
- tx->start = NULL;
- ! tx->subject = NULL;
- ! tx->follow_up = NULL;
- ! tx->author = NULL;
- ! tx->organisation = NULL;
-
- ! while (fgets(lnbuf, sizeof(lnbuf) - 1, tmp_file) != NULL) {
-
- ! lnbuf[sizeof(lnbuf) -1] = 0;
-
- ! if (strncmp(lnbuf, "@@@@END", 7) == 0) break;
-
- ! /* is it the first line - if so init the TEXT structure */
- if (ct == 0) {
- ln = xmalloc(sizeof(LINE));
- ln->last = NULL;
- ***************
- *** 97,104 ****
- ln->last = lz;
- }
-
- - lnbuf[79] = '\x00';
- ln->index = ct;
- strcpy(ln->data, lnbuf);
-
- if ((strlen(lnbuf) == 1) && (tx->start == NULL))
- --- 118,125 ----
- ln->last = lz;
- }
-
- ln->index = ct;
- + ln->data = xmalloc(strlen(lnbuf) + 1);
- strcpy(ln->data, lnbuf);
-
- if ((strlen(lnbuf) == 1) && (tx->start == NULL))
- ***************
- *** 108,130 ****
-
- /* save the header info */
- if ((tx->start == NULL) && (strncmp("From:", lnbuf, 5) == 0)) {
- ! eat_gunk(lnbuf);
- ! lnbuf[WHO_LENGTH-1] = '\x00';
- strcpy(tx->author, lnbuf);
- }
- if ((tx->start == NULL) &&
- ((strncmp("Organisation:", lnbuf, 13) == 0) ||
- (strncmp("Organization:", lnbuf, 13) == 0))) {
- ! eat_gunk(lnbuf);
- ! lnbuf[WHO_LENGTH-1] = '\x00';
- ! strcpy(tx->organisation, lnbuf);
- }
-
- ! if ((tx->start == NULL) && (strncmp("Followup-To:", lnbuf, 12) == 0)) {
- ! eat_gunk(lnbuf);
- ! lnbuf[79] = '\x00';
- ! strcpy(tx->follow_up, lnbuf);
- }
- }
-
- }
- --- 129,156 ----
-
- /* save the header info */
- if ((tx->start == NULL) && (strncmp("From:", lnbuf, 5) == 0)) {
- ! strcpy(lnbuf, plain_address(lnbuf + 5));
- ! tx->author = xmalloc(strlen(lnbuf) + 1);
- strcpy(tx->author, lnbuf);
- }
- if ((tx->start == NULL) &&
- ((strncmp("Organisation:", lnbuf, 13) == 0) ||
- (strncmp("Organization:", lnbuf, 13) == 0))) {
- ! lnbuf[strlen(lnbuf) - 1] = 0;
- ! tx->organisation = xmalloc(strlen(lnbuf + 14) + 1);
- ! strcpy(tx->organisation, lnbuf + 14);
- }
-
- ! if ((tx->start == NULL) && (strncmp("Subject:", lnbuf, 8) == 0)) {
- ! lnbuf[strlen(lnbuf) - 1] = 0;
- ! tx->subject = xmalloc(strlen(lnbuf + 9) + 1);
- ! strcpy(tx->subject, lnbuf + 9);
- }
- +
- + if ((tx->start == NULL) && (strncmp("Followup-To:", lnbuf, 12) == 0)) {
- + lnbuf[strlen(lnbuf) - 1] = 0;
- + tx->follow_up = xmalloc(strlen(lnbuf + 13) + 1);
- + strcpy(tx->follow_up, lnbuf + 13);
- }
-
- }
- ***************
- *** 150,165 ****
- while (l != NULL) {
- k = l;
- l = l->next;
- free(k);
- }
-
- free(t);
- }
-
-
-
- /*---------------------------- read an article ----------------------------*/
- ! int read_article(ACTIVE *gp, TEXT *tx, char *subject, int a_ct, int of_ct)
- {
- /*
- * This routine alloas the user to read an article
- --- 176,222 ----
- while (l != NULL) {
- k = l;
- l = l->next;
- + free(k->data);
- free(k);
- }
-
- + if (t->subject)
- + free(t->subject);
- + if (t->follow_up)
- + free(t->follow_up);
- + if (t->author)
- + free(t->author);
- + if (t->organisation)
- + free(t->organisation);
- free(t);
- }
-
-
- + /*---------------------------- display a line -----------------------------*/
- + void putline(char *line, int margin)
- + {
- + char buf[MAXLINE];
- + int length;
- +
- + strcpy(buf, line);
- + expand_tabs(buf, MAXLINE);
- + length = strlen(buf);
- +
- + if ( length > margin ) {
- + if ( length > margin + _columns )
- + printf("%-*.*s$", _columns - 1, _columns - 1, buf + margin);
- + else {
- + puts(buf + margin);
- + if ( length - margin < _columns )
- + clreol();
- + }
- + }
- + else
- + clreol();
- + }
-
- /*---------------------------- read an article ----------------------------*/
- ! int read_article(ACTIVE *gp, TEXT *tx, int a_ct, int of_ct)
- {
- /*
- * This routine alloas the user to read an article
- ***************
- *** 167,179 ****
-
- LINE *this, *tmp; /* current thread */
- int exit_code; /* why we are exiting the loop */
- ! char sub_tmp[80];
- !
- ! int ch, i;
-
- this = tx->start;
- exit_code = 0;
- ! show_article(gp, tx, subject, this, a_ct, of_ct);
-
- while ((exit_code == 0) || (exit_code == EX_DUMMY)) {
-
- --- 224,239 ----
-
- LINE *this, *tmp; /* current thread */
- int exit_code; /* why we are exiting the loop */
- ! char buf[MAXLINE];
- ! int ch, i, maxx, margin, newmargin;
-
- this = tx->start;
- + if (this->next != NULL)
- + this = this->next;
- +
- exit_code = 0;
- ! margin = 0;
- ! show_article(gp, tx, this, a_ct, of_ct, margin);
-
- while ((exit_code == 0) || (exit_code == EX_DUMMY)) {
-
- ***************
- *** 182,211 ****
- switch (ch) {
-
- case 0 :
- ! ch = getch();
-
- switch (ch) {
-
- case UP_ARR :
- if (this->last != NULL) {
- this = this->last;
- - gotoxy(1,TEXT_LINE+PAGE_LENGTH-1);
- - delline();
- gotoxy(1,TEXT_LINE);
- insline();
- ! clreol();
- ! cputs(this->data);
- ! exit_code = EX_DUMMY;
- }
- break;
-
- case DN_ARR :
- ! if (this->next != NULL) {
- this = this->next;
- gotoxy(1,TEXT_LINE);
- delline();
- gotoxy(1,TEXT_LINE+PAGE_LENGTH-1);
- - insline();
-
- tmp = this;
- for (i = 0; i < PAGE_LENGTH-1; i++) {
- --- 242,321 ----
- switch (ch) {
-
- case 0 :
- ! case 0xE0 :
-
- + ch = getch();
- switch (ch) {
-
- + case F1 :
- + show_help(HELP_ARTICLES);
- + break;
- +
- + case L_ARR :
- + if ( margin == 0 )
- + exit_code = EX_DUMMY;
- + else
- + margin = max(0, margin - 4);
- + break;
- +
- + case C_L_ARR :
- + if ( margin == 0 )
- + exit_code = EX_DUMMY;
- + else
- + margin = 0;
- + break;
- +
- + case R_ARR :
- + tmp = this;
- + newmargin = margin;
- + for (i = 0; i < PAGE_LENGTH-1; i++) {
- + strcpy(buf, tmp->data);
- + expand_tabs(buf, MAXLINE);
- + newmargin = max(newmargin, strlen(buf));
- + tmp = tmp->next;
- + if (tmp == NULL) break;
- + }
- + if ( margin >= newmargin - _columns )
- + exit_code = EX_DUMMY;
- + else
- + margin += 4;
- + break;
- +
- + case C_R_ARR :
- + tmp = this;
- + newmargin = margin;
- + for (i = 0; i < PAGE_LENGTH-1; i++) {
- + strcpy(buf, tmp->data);
- + expand_tabs(buf, MAXLINE);
- + newmargin = max(newmargin, strlen(buf));
- + tmp = tmp->next;
- + if (tmp == NULL) break;
- + }
- + newmargin = ((newmargin - 1) / 4 + 1) * 4;
- + if ( newmargin == margin + _columns )
- + exit_code = EX_DUMMY;
- + else
- + margin = newmargin - _columns;
- + break;
- +
- case UP_ARR :
- if (this->last != NULL) {
- this = this->last;
- gotoxy(1,TEXT_LINE);
- insline();
- ! putline(this->data, margin);
- }
- + exit_code = EX_DUMMY;
- break;
-
- case DN_ARR :
- ! if (this->next != NULL &&
- ! (this->index + PAGE_LENGTH < tx->lines ||
- ! this->index <= tx->start->index)) {
- this = this->next;
- gotoxy(1,TEXT_LINE);
- delline();
- gotoxy(1,TEXT_LINE+PAGE_LENGTH-1);
-
- tmp = this;
- for (i = 0; i < PAGE_LENGTH-1; i++) {
- ***************
- *** 213,225 ****
- if (tmp == NULL) break;
- }
-
- ! clreol();
- ! cputs(tmp->data);
- exit_code = EX_DUMMY;
- }
- break;
-
- case PGUP :
- for (i = 0; i < PAGE_LENGTH-1; i++) {
- if (this->last == NULL) break;
- this = this->last;
- --- 323,362 ----
- if (tmp == NULL) break;
- }
-
- ! if (tmp)
- ! putline(tmp->data, margin);
- ! }
- ! exit_code = EX_DUMMY;
- ! break;
- !
- ! case HOME :
- ! tmp = this;
- ! this = tx->start;
- ! if (this->next != NULL)
- ! this = this->next;
- ! if (this == tmp)
- exit_code = EX_DUMMY;
- + break;
- +
- + case END :
- + tmp = this;
- + this = tx->start;
- + while (this->next != NULL)
- + this = this->next;
- + for (i = 0; i < PAGE_LENGTH-1; i++) {
- + if (this->last == NULL) break;
- + if (tx->start->next && this == tx->start->next)
- + break;
- + this = this->last;
- }
- + if (this == tmp)
- + exit_code = EX_DUMMY;
- break;
-
- case PGUP :
- + if ( this->last == NULL )
- + exit_code = EX_DUMMY;
- + else
- for (i = 0; i < PAGE_LENGTH-1; i++) {
- if (this->last == NULL) break;
- this = this->last;
- ***************
- *** 227,280 ****
- break;
-
- case PGDN :
- ! for (i = 0; i < PAGE_LENGTH-2; i++) {
- if (this->next == NULL) break;
- this = this->next;
- }
- break;
-
- ! case HOME :
- ! this = tx->start;
- ! break;
- ! case END :
- ! this = tx->start;
- ! while (this->next != NULL)
- ! this = this->next;
- break;
- }
- break;
-
- case 'p' :
- ! strcpy(sub_tmp, "");
- ! post(NULL, gp->group, sub_tmp);
- break;
-
- case 'f' :
- ! if (strcmp(tx->follow_up, "") == 0)
- ! post(tx, gp->group, subject);
- else
- ! post(tx, tx->follow_up, subject);
- break;
-
- case 'r' :
- ! reply_to_article(tx, subject);
- break;
-
- case 'm' :
- mail_to_someone(tx);
- break;
-
- case 's' :
- save_to_disk(tx);
- - message("-- Done --");
- break;
-
- case 'x' :
- rot13(tx);
- break;
-
- - case '?' :
- case 'h' :
- show_help(HELP_ARTICLES);
- break;
-
- --- 364,427 ----
- break;
-
- case PGDN :
- ! if ( this->next == NULL )
- ! exit_code = EX_DUMMY;
- ! else {
- ! maxx = tx->lines - this->index - PAGE_LENGTH;
- ! maxx = min(maxx, PAGE_LENGTH - 1);
- ! maxx = max(maxx, tx->start->index + 1 - this->index);
- !
- ! if ( maxx <= 0 )
- ! exit_code = EX_DUMMY;
- ! else
- ! for (i = 0; i < maxx; i++) {
- if (this->next == NULL) break;
- this = this->next;
- }
- + }
- break;
-
- ! default:
- ! exit_code = EX_DUMMY;
- break;
- }
- break;
-
- case 'p' :
- ! case 'P' :
- ! post(NULL, gp->group);
- break;
-
- case 'f' :
- ! case 'F' :
- ! if (!tx->follow_up || strcmp(tx->follow_up, "") == 0)
- ! post(tx, gp->group);
- else
- ! post(tx, tx->follow_up);
- break;
-
- case 'r' :
- ! case 'R' :
- ! reply_to_article(tx);
- break;
-
- case 'm' :
- + case 'M' :
- mail_to_someone(tx);
- break;
-
- case 's' :
- + case 'S' :
- save_to_disk(tx);
- break;
-
- case 'x' :
- + case 'X' :
- rot13(tx);
- break;
-
- case 'h' :
- + case 'H' :
- show_help(HELP_ARTICLES);
- break;
-
- ***************
- *** 286,297 ****
- exit_code = EX_NEXT;
- break;
-
- case ESCAPE :
- exit_code = EX_QUIT;
- break;
- };
- if (exit_code == 0)
- ! show_article(gp, tx, subject, this, a_ct, of_ct);
- }
-
- return(exit_code);
- --- 433,470 ----
- exit_code = EX_NEXT;
- break;
-
- + case BACKSP :
- + exit_code = EX_PREVIOUS;
- + break;
- +
- + case '+' :
- + case '/' :
- + exit_code = EX_SEARCH_FORW;
- + break;
- +
- + case '-' :
- + case '?' :
- + exit_code = EX_SEARCH_BACKW;
- + break;
- +
- case ESCAPE :
- exit_code = EX_QUIT;
- break;
- +
- + default:
- + exit_code = EX_DUMMY;
- + break;
- };
- +
- if (exit_code == 0)
- ! show_article(gp, tx, this, a_ct, of_ct, margin);
- ! else {
- ! gotoxy(_columns - 16,2);
- ! textbackground(LIGHTGRAY); textcolor(BLACK);
- ! sprintf(buf, "Line %d of %d", this->index + 1, tx->lines);
- ! printf("%17s", buf);
- ! textbackground(BLACK); textcolor(LIGHTGRAY);
- ! }
- }
-
- return(exit_code);
- ***************
- *** 300,346 ****
-
-
- /*-------------------- show the list of active groups -----------------------*/
- ! void show_article(ACTIVE *gp, TEXT *tx, char *subject, LINE *this, int a_ct,
- ! int of_ct)
- {
- /*
- * This routine show a page of an article
- */
-
- ! int i;
- ! char buf[60];
- !
- !
- !
- ! clrscr();
- ! strcpy(buf, subject);
- ! buf[49] = '\x00';
- !
-
- textbackground(LIGHTGRAY); textcolor(BLACK);
- ! clreol();
- ! cprintf("Group: %-30s Article: %2d of %2d\r\n",
- ! gp->group, a_ct, of_ct);
- ! clreol();
- ! cprintf("Subject: %-50s %4d lines\r\n", buf, tx->lines);
- ! clreol();
- ! cprintf("From: %s; %s", tx->author, tx->organisation);
- textbackground(BLACK); textcolor(LIGHTGRAY);
-
- -
- - gotoxy(1, TEXT_LINE);
- for (i = 0; i < PAGE_LENGTH; i++) {
- gotoxy(1, i+TEXT_LINE);
- ! cputs(this->data);
- this = this->next;
- - if (this == NULL) break;
- }
-
- ! command("ESC=select thread TAB=next unread ENTER=next ?=help");
- ! }
- !
- !
-
-
-
- /*-------------------------- save article --------------------------------*/
- --- 473,521 ----
-
-
- /*-------------------- show the list of active groups -----------------------*/
- ! void show_article(ACTIVE *gp, TEXT *tx, LINE *this, int a_ct,
- ! int of_ct, int margin)
- {
- /*
- * This routine show a page of an article
- */
-
- ! int i, length;
- ! char buf[256], buf2[32];
-
- + gotoxy(1,1);
- textbackground(LIGHTGRAY); textcolor(BLACK);
- ! sprintf(buf2, "Article %d of %d", a_ct, of_ct);
- ! printf("Group: %-*.*s %18s", _columns - 27, _columns - 27,
- ! gp->group, buf2);
- ! gotoxy(1,2);
- ! strcpy(buf, tx->author ? tx->author : "<unknown>");
- ! if (tx->organisation) {
- ! strcat(buf, "; ");
- ! strcat(buf, tx->organisation);
- ! }
- ! sprintf(buf2, "Line %d of %d", this->index + 1, tx->lines);
- ! printf("From: %-*.*s %17s", _columns - 25, _columns - 25, buf, buf2);
- ! gotoxy(1,3);
- ! sprintf(buf2, margin ? ">%d" : "", margin);
- ! printf("Subject: %-*.*s %4s", _columns - 14, _columns - 14,
- ! tx->subject, buf2);
- textbackground(BLACK); textcolor(LIGHTGRAY);
-
- for (i = 0; i < PAGE_LENGTH; i++) {
- + if (this == NULL) break;
- gotoxy(1, i+TEXT_LINE);
- ! putline(this->data, margin);
- this = this->next;
- }
-
- ! if ( i < PAGE_LENGTH ) {
- ! gotoxy(1, i+TEXT_LINE);
- ! clreos();
- ! }
-
- + message("ESC=select thread TAB=next unread ENTER=next F1=help");
- + }
-
-
- /*-------------------------- save article --------------------------------*/
- ***************
- *** 352,363 ****
-
- FILE *tmp = NULL;
- LINE *ln;
- ! char fn[80];
- int ch;
- !
- !
- ! message("Enter filename? ");
-
- gets(fn);
-
- if (access(fn, 0) == 0) {
- --- 527,539 ----
-
- FILE *tmp = NULL;
- LINE *ln;
- ! char fn[256];
- int ch;
- ! time_t now;
- ! struct tm *tmnow;
- ! char timestr[64];
-
- + lmessage("Enter filename? ");
- gets(fn);
-
- if (access(fn, 0) == 0) {
- ***************
- *** 366,373 ****
- while (((ch = getch()) != 'y') && (ch != 'n'));
- if (ch == 'y') {
- if ((tmp = fopen(fn, "at")) == NULL) {
- ! message("*** Cannot open file for appending - "
- ! "please any key to continue ***");
- getch();
- }
- }
- --- 542,549 ----
- while (((ch = getch()) != 'y') && (ch != 'n'));
- if (ch == 'y') {
- if ((tmp = fopen(fn, "at")) == NULL) {
- ! message("*** cannot open file for appending - "
- ! "press any key ***");
- getch();
- }
- }
- ***************
- *** 375,388 ****
- } else {
-
- if ((tmp = fopen(fn, "wt")) == NULL) {
- ! message("*** Cannot open file for output - press a key to continue ***");
- getch();
- }
-
- }
-
- if (tmp != NULL) {
-
- ln = tx->top;
- while (ln != NULL) {
- fputs(ln->data, tmp);
- --- 551,578 ----
- } else {
-
- if ((tmp = fopen(fn, "wt")) == NULL) {
- ! message("*** cannot open file for output - press any key ***");
- getch();
- }
-
- + setvbuf(tmp, iobuf, _IOFBF, IOBUFSIZE);
- }
-
- if (tmp != NULL) {
-
- + time(&now);
- + tmnow = localtime(&now);
- + strftime(timestr, sizeof(timestr), "%a %b %d %H:%M:%S %z %Y", tmnow);
- +
- + ln = tx->top;
- + while (ln != NULL && strncmp(ln->data, "Path: ", 6)) {
- + ln = ln->next;
- + }
- + strcpy(fn, ln->data + 6);
- + for ( ch = strlen(fn); fn[ch - 1] == '\n' || fn[ch - 1] == '\r'; ch--)
- + fn[ch - 1] = 0;
- + fprintf(tmp, "From %s %s\n", fn, timestr);
- +
- ln = tx->top;
- while (ln != NULL) {
- fputs(ln->data, tmp);
- ***************
- *** 398,404 ****
-
-
- /*-------------------------- reply to article ---------------------------*/
- ! void reply_to_article(TEXT *tx, char *subject)
- {
- /*
- * Mail reply to article
- --- 588,594 ----
-
-
- /*-------------------------- reply to article ---------------------------*/
- ! void reply_to_article(TEXT *tx)
- {
- /*
- * Mail reply to article
- ***************
- *** 405,411 ****
- */
-
- #ifdef INCLUDE_SIG
- ! FILE *sig
- char sig_fn[80];
- #endif
-
- --- 595,601 ----
- */
-
- #ifdef INCLUDE_SIG
- ! FILE *sig;
- char sig_fn[80];
- #endif
-
- ***************
- *** 412,424 ****
- FILE *tmp;
- LINE *ln;
- int ch;
- ! char fn[80];
- char buf[256];
- ! char author[80], msg_id[80];
-
- ! strcpy(fn, "reply.tmp");
-
- ! if ((tmp= fopen(fn, "wt")) != NULL) {
-
- get_his_stuff(tx, author, msg_id);
-
- --- 602,620 ----
- FILE *tmp;
- LINE *ln;
- int ch;
- ! char fn[256];
- char buf[256];
- ! char author[80], msg_id[MAXLINE];
- ! char *mailer = getenv("MAILER");
-
- ! if (mailer == NULL)
- ! mailer = "mail";
-
- ! strcpy(fn, my_stuff.news_dir);
- ! strcat(fn, "letter");
- ! unlink(fn);
- !
- ! if ((tmp = fopen(fn, "wt")) != NULL) {
-
- get_his_stuff(tx, author, msg_id);
-
- ***************
- *** 427,436 ****
- while (((ch = getch()) != 'y') && (ch != 'n'));
-
- if (ch == 'y') {
- ! fprintf(tmp, "\nIn article %s you write:\n\n", msg_id);
- ln = tx->start;
- while (ln != NULL) {
- ! fprintf(tmp, " > %s", ln->data);
- ln = ln->next;
- }
- }
- --- 623,632 ----
- while (((ch = getch()) != 'y') && (ch != 'n'));
-
- if (ch == 'y') {
- ! fprintf(tmp, "In article %s you write:\n", msg_id);
- ln = tx->start;
- while (ln != NULL) {
- ! fprintf(tmp, "> %s", ln->data);
- ln = ln->next;
- }
- }
- ***************
- *** 443,451 ****
- if ((sig= fopen(sig_fn, "rt")) != NULL) {
- while (fgets(buf, 79, sig) != NULL)
- fputs(buf, tmp);
- - }
- -
- fclose(sig);
- #endif
- fclose(tmp);
-
- --- 639,646 ----
- if ((sig= fopen(sig_fn, "rt")) != NULL) {
- while (fgets(buf, 79, sig) != NULL)
- fputs(buf, tmp);
- fclose(sig);
- + }
- #endif
- fclose(tmp);
-
- ***************
- *** 455,470 ****
- sprintf(buf, "Send message to %s (y/n)? ", author);
- message(buf);
- while (((ch = getch()) != 'y') && (ch != 'n'));
- if (ch == 'y') {
- ! sprintf(buf, "mail -s \"Re: %s\" %s <%s", subject, author, fn);
- system(buf);
- }
- ! unlink(fn);
- ! message("-- Press any key to continue --");
- ! getch();
-
- } else {
- ! message("*** Cannot open temp file - press any key to continue ***");
- getch();
- }
-
- --- 650,671 ----
- sprintf(buf, "Send message to %s (y/n)? ", author);
- message(buf);
- while (((ch = getch()) != 'y') && (ch != 'n'));
- + gotoxy(1,PAGE_SIZE);
- + clreol();
- +
- + strcpy(msg_id, tx->subject);
- + eat_gunk(msg_id);
- +
- if (ch == 'y') {
- ! sprintf(buf, "%s -s \"Re: %s\" %s <%s >nul 2>&1",
- ! mailer, msg_id, author, fn);
- system(buf);
- }
- !
- ! /* unlink(fn); /* keep it around like rn */
-
- } else {
- ! message("*** cannot open temp file - press any key ***");
- getch();
- }
-
- ***************
- *** 484,530 ****
- FILE *tmp;
- LINE *ln;
- int ch;
- ! char fn[80];
- char buf[256], who[80];
- ! char author[80], msg_id[80];
-
- ! strcpy(fn, "reply.tmp");
-
- if ((tmp= fopen(fn, "wt")) != NULL) {
-
- ! get_his_stuff(tx, author, msg_id);
- !
- ! /* add the quoted message */
- ! command("");
- ! lmessage("Who do you want to mail this article to? ");
- gets(who);
-
- ! fprintf(tmp, "\nThis article was forwarded to you by %s@%s (%s):\n\n",
- my_stuff.user, my_stuff.my_domain, my_stuff.my_name);
- ! fprintf(tmp,"--------------------------------- cut here -----------------------------\n\n");
- ln = tx->top;
- while (ln != NULL) {
- ! fprintf(tmp, "%s", ln->data);
- ln = ln->next;
- }
-
- - fprintf(tmp,"--------------------------------- cut here -----------------------------\n\n");
- -
- fclose(tmp);
-
- ! sprintf(buf, "Send message to %s (y/n)? ", who);
- message(buf);
- while (((ch = getch()) != 'y') && (ch != 'n'));
- if (ch == 'y') {
- ! sprintf(buf, "mail %s <%s", who, fn);
- system(buf);
- }
- unlink(fn);
- - message("-- Press any key to continue --");
- - getch();
-
- } else {
- ! message("*** Cannot open temp file - press any key to continue ***");
- getch();
- }
-
- --- 685,733 ----
- FILE *tmp;
- LINE *ln;
- int ch;
- ! char fn[256];
- char buf[256], who[80];
- ! char *subj = tx->subject ? tx->subject : "No subject";
-
- ! sprintf(fn, "%s\\snews.tmp", my_stuff.temp_name);
-
- if ((tmp= fopen(fn, "wt")) != NULL) {
-
- ! lmessage("Mail this article to? ");
- gets(who);
-
- ! fprintf(tmp, "Resent-From: %s@%s (%s)\n",
- my_stuff.user, my_stuff.my_domain, my_stuff.my_name);
- ! fprintf(tmp, "Resent-To: %s\n", who);
- !
- ln = tx->top;
- while (ln != NULL) {
- ! fputs(ln->data, tmp);
- ln = ln->next;
- }
-
- fclose(tmp);
-
- ! message("Edit outgoing message (y/n)? ");
- ! while (((ch = getch()) != 'y') && (ch != 'n'));
- !
- ! if (ch == 'y') {
- ! sprintf(buf, my_stuff.editor, fn);
- ! system(buf);
- ! }
- !
- ! sprintf(buf, "Mail article to %s (y/n)? ", who);
- message(buf);
- while (((ch = getch()) != 'y') && (ch != 'n'));
- if (ch == 'y') {
- ! sprintf(buf, "rmail -t <%s 2>nul", fn);
- system(buf);
- }
- +
- unlink(fn);
-
- } else {
- ! message("*** cannot open temp file - press any key ***");
- getch();
- }
-
- ***************
- *** 541,547 ****
-
- LINE *ln;
- char *p;
- ! char buf[100];
- char *null_name = {" ** none ** "};
-
- strcpy(author, null_name);
- --- 744,750 ----
-
- LINE *ln;
- char *p;
- ! char buf[MAXLINE];
- char *null_name = {" ** none ** "};
-
- strcpy(author, null_name);
- ***************
- *** 549,554 ****
- --- 752,759 ----
-
- ln = tx->top;
- while (ln != NULL) {
- + if (strlen(ln->data) < 2) break;
- +
- strcpy(buf, ln->data);
- p = strtok(buf, " :\n\r");
- p = strtok(NULL, " :\n\r");
- ***************
- *** 558,571 ****
-
- if ((strnicmp(ln->data, "From:", 5) == 0) &&
- (strcmp(author, null_name) == 0)) {
- ! strcpy(author, p);
- }
-
- ! if (strnicmp(ln->data, "Reply-To:", 5) == 0) {
- ! strcpy(author, p);
- }
-
- - if (strlen(ln->data) < 2) break;
- ln = ln->next;
- }
- }
- --- 763,775 ----
-
- if ((strnicmp(ln->data, "From:", 5) == 0) &&
- (strcmp(author, null_name) == 0)) {
- ! strcpy(author, plain_address(ln->data+5));
- }
-
- ! if (strnicmp(ln->data, "Reply-to:", 9) == 0) {
- ! strcpy(author, plain_address(ln->data+9));
- }
-
- ln = ln->next;
- }
- }
- ***************
- *** 600,606 ****
- void expand_tabs(char *buf, int max_len)
- {
- int l, k;
- ! char tmp[256], *p, *t;
-
- p = buf;
- t = &tmp[0];
- --- 804,810 ----
- void expand_tabs(char *buf, int max_len)
- {
- int l, k;
- ! char tmp[MAXLINE], *p, *t;
-
- p = buf;
- t = &tmp[0];
- ***************
- *** 625,628 ****
- --- 829,836 ----
-
- *t = '\x00';
- strcpy(buf, tmp);
- + l = strlen(buf);
- +
- + if (buf[l - 1] == '\n')
- + buf[l - 1] = 0;
- }
- diff -cb orig/defs.h new/defs.h
- *** orig/defs.h Thu Jun 11 22:48:14 1992
- --- new/defs.h Sun Aug 02 20:34:18 1992
- ***************
- *** 1,5 ****
- /*
- ! SNEWS 1.0
-
- General public decls
-
- --- 1,5 ----
- /*
- ! SNEWS 2.0
-
- General public decls
-
- ***************
- *** 22,28 ****
-
- */
-
- ! #include <alloc.h>
- #include <time.h>
- #include <string.h>
- #include <conio.h>
- --- 22,28 ----
-
- */
-
- ! #include <malloc.h>
- #include <time.h>
- #include <string.h>
- #include <conio.h>
- ***************
- *** 30,41 ****
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/stat.h>
- ! #include <dir.h>
-
-
- - #define VERSION "Simple NEWS 1.12"
-
- #define HIST_MEM_LIMIT 75000l /* leave this much meme free loading history */
-
- #define ACTIVE_NUM_LEN 8 /* length of the numbers in the active file */
- --- 30,47 ----
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- + #include <io.h>
- + #include <sys/types.h>
- #include <sys/stat.h>
- ! #include <direct.h>
-
- + #include "os2defs.h"
-
-
- + #define VERSION "SNEWS /2 2.0"
- + #define COPYRIGHT "(c) 1991 John McCombs, (c) 1992 Kai Uwe Rommel"
- +
- +
- #define HIST_MEM_LIMIT 75000l /* leave this much meme free loading history */
-
- #define ACTIVE_NUM_LEN 8 /* length of the numbers in the active file */
- ***************
- *** 43,63 ****
- #define TRUE 1
- #define FALSE 0
-
-
- /* this is the data we get from the UUPC .rc files */
- typedef struct {
- ! char temp_name[80]; /* unbatch temp file */
- ! char news_dir[80]; /* news base directory */
- ! char incoming_dir[80]; /* incoming news spool directory */
- ! char user[80]; /* current user id */
- ! char my_name[80]; /* my full name */
- ! char my_domain[80]; /* our domain */
- ! char my_site[80]; /* site name */
- ! char my_organisation[80]; /* organisation */
- ! char mail_server[80]; /* where posts are routed to */
- ! char editor[80]; /* system editor */
- ! char home[80]; /* home mail directory */
- ! char signature[80]; /* signature file */
- } INFO;
-
-
- --- 49,73 ----
- #define TRUE 1
- #define FALSE 0
-
- + #define IOBUFSIZE 32000
- + extern char iobuf[IOBUFSIZE];
-
- +
- /* this is the data we get from the UUPC .rc files */
- typedef struct {
- ! char temp_name[256]; /* unbatch temp file */
- ! char news_dir[256]; /* news base directory */
- ! char incoming_dir[256]; /* incoming news spool directory */
- ! char spool_dir[256]; /* spool directory, log files */
- ! char user[256]; /* current user id */
- ! char my_name[256]; /* my full name */
- ! char my_domain[256]; /* our domain */
- ! char my_site[256]; /* site name */
- ! char my_organisation[256]; /* organisation */
- ! char mail_server[256]; /* where posts are routed to */
- ! char editor[256]; /* system editor */
- ! char home[256]; /* home mail directory */
- ! char signature[256]; /* signature file */
- } INFO;
-
-
- ***************
- *** 64,73 ****
- extern INFO my_stuff;
-
-
- /* NOTE - if hi_num and lo_num are the same there are no articles */
- typedef struct active {
- char group[60]; /* group name */
- ! char gp_file[9]; /* name of the file that the data is in */
- long lo_num; /* lowest number less one */
- long hi_num; /* highest number */
- long num_pos; /* file offset of the numbers */
- --- 74,96 ----
- extern INFO my_stuff;
-
-
- + /*
- + * This structure is a linked list of lines that make up an article. The
- + * file is read in and the linked list is built
- + */
- + typedef struct line {
- + char *data; /* line of text */
- + struct line *next; /* next line */
- + struct line *last; /* last line */
- + int index; /* line number from start */
- + } LINE;
- +
- +
- +
- /* NOTE - if hi_num and lo_num are the same there are no articles */
- typedef struct active {
- char group[60]; /* group name */
- ! char gp_file[60]; /* name of the file that the data is in */
- long lo_num; /* lowest number less one */
- long hi_num; /* highest number */
- long num_pos; /* file offset of the numbers */
- ***************
- *** 75,80 ****
- --- 98,105 ----
- struct active *last; /* last entry */
- int index; /* which number in the list, from 0 */
- char *read_list; /* array hi_num-lo_num long. TRUE=read it */
- + int groups; /* filled in by load_active_file() in head */
- + int threads; /* filled in by get_headers() */
- } ACTIVE;
-
-
- ***************
- *** 85,90 ****
- --- 110,116 ----
- */
- typedef struct post_groups {
- char group[60]; /* group name */
- + int local; /* local news group */
- struct post_groups *next; /* next entry */
- } POST_GROUPS;
-
- Only in new: exe
- diff -cb orig/expire.c new/expire.c
- *** orig/expire.c Thu Jun 11 22:48:14 1992
- --- new/expire.c Sun Aug 02 20:34:18 1992
- ***************
- *** 1,5 ****
- /*
- ! Simple NEWS
-
- EXPIRE - expire news database articles by number of days since rx'd
-
- --- 1,5 ----
- /*
- ! SNEWS 2.0
-
- EXPIRE - expire news database articles by number of days since rx'd
-
- ***************
- *** 30,36 ****
-
- INFO my_stuff;
-
- -
- /*------------------------------- main --------------------------------*/
- void main(int argc, char *argv[])
- {
- --- 30,35 ----
- ***************
- *** 51,56 ****
- --- 50,57 ----
- long secs, i, offset;
- int days;
- int no_space;
- + int cnt;
- + int matches;
- long art_time;
- long where;
-
- ***************
- *** 59,102 ****
- FILE *text;
- FILE *old_text;
-
- ! int articles;
- ! int articles_deleted;
- ! int gp_art;
- ! int gp_art_deleted;
-
- ! long total_bytes;
- ! long total_bytes_deleted;
- long gp_bytes;
- long gp_bytes_deleted;
-
-
- ! articles = 0;
- ! articles_deleted = 0;
-
- ! total_bytes = 0;
- ! total_bytes_deleted = 0;
-
-
- ! fprintf(stderr, "EXPIRE: (%s)\n\n", VERSION);
-
- ! if (argc == 2) {
-
- if (!load_stuff()) {
- fprintf(stderr, "Couldn't read rc info\n");
- }
-
- head = load_active_file();
- -
- - time(¤t);
- -
- - days = atoi(argv[1]);
- - secs = days * 86400l;
- -
- gp = head;
-
- ! printf("NEWSGROUP : ARTICLES DELETED\n\n");
-
- ! while (gp != NULL) {
-
- no_space = FALSE;
-
- --- 60,109 ----
- FILE *text;
- FILE *old_text;
-
- ! long articles = 0;
- ! long articles_deleted = 0;
- ! long gp_art;
- ! long gp_art_deleted;
-
- ! long total_bytes = 0;
- ! long total_bytes_deleted = 0;
- long gp_bytes;
- long gp_bytes_deleted;
-
-
- ! fprintf(stderr, "EXPIRE: (%s)\n\n", VERSION);
-
- ! if (argc < 2) {
- ! fprintf(stderr, "usage: expire -<days> [group-pattern ...]\n");
- ! exit(1);
- ! }
-
- + argc--;
- + argv++;
-
- ! time(¤t);
-
- ! if ( **argv == '-' ) {
- ! days = atoi(*argv + 1);
- ! secs = days * 86400l;
- ! argc--;
- ! argv++;
- ! } else {
- ! fprintf(stderr, "usage: expire -<days> [group-pattern ...]\n");
- ! exit(1);
- ! }
-
- if (!load_stuff()) {
- fprintf(stderr, "Couldn't read rc info\n");
- + exit(1);
- }
-
- head = load_active_file();
- gp = head;
-
- ! printf("%-40s : ARTICLES DELETED\n\n", "NEWSGROUP");
-
- ! for (gp = head; gp != NULL; gp = gp->next) {
-
- no_space = FALSE;
-
- ***************
- *** 107,130 ****
-
- if ((gp->hi_num - gp->lo_num) > 0) {
-
- /*
- * Open all the files. First the old ones, then the new
- */
- - fn = make_news_group_name(gp->group);
-
- stat(fn, &st);
- - gp_bytes_deleted = st.st_size;
-
- ! if ((old_text = fopen(fn, "rb")) == NULL) crash("can't open old text", fn);
- ! setvbuf(old_text, NULL, _IOFBF, 16384);
- ! sprintf(buf, "%s.IDX", fn);
- ! if ((old_index = fopen(buf, "rb")) == NULL) crash("can't open old index", buf);
-
- ! sprintf(buf, "%s.NEW", fn);
- ! if ((text = fopen(buf, "wb")) == NULL) crash("can't create new text", buf);
- ! setvbuf(text, NULL, _IOFBF, 16384);
- ! sprintf(buf, "%s.NDX", fn);
- ! if ((index = fopen(buf, "wb")) == NULL) crash("can't create new index", buf);
-
- /* numbers go chronologically */
- for (i = (gp->lo_num)+1; i <= gp->hi_num; i++) {
- --- 114,164 ----
-
- if ((gp->hi_num - gp->lo_num) > 0) {
-
- + printf("%-40s : ", gp->group);
- + fflush(stdout);
- +
- /*
- * Open all the files. First the old ones, then the new
- */
-
- + fn = make_news_group_name(gp->group);
- stat(fn, &st);
-
- ! if (argc) {
- ! matches = FALSE;
- ! for (cnt = 0; cnt < argc; cnt++)
- ! if (amatch(argv[cnt], gp->group))
- ! matches = TRUE;
- ! }
- ! else
- ! matches = TRUE;
- !
- ! if (!matches) {
- ! gp_art = gp->hi_num - gp->lo_num;
- ! printf("%4ld %5ld k\n", gp_art, (st.st_size+500)/1000);
- ! articles += gp_art;
- ! total_bytes += st.st_size;
- ! continue;
- ! }
- !
- ! gp_bytes_deleted = st.st_size;
-
- ! if ((old_text = fopen(fn, "rb")) == NULL)
- ! crash("can't open old text", fn);
- ! setvbuf(old_text, NULL, _IOFBF, IOBUFSIZE);
- ! sprintf(buf, "%s.idx", fn);
- ! if ((old_index = fopen(buf, "rb")) == NULL)
- ! crash("can't open old index", buf);
- ! setvbuf(old_index, NULL, _IOFBF, IOBUFSIZE);
- !
- ! sprintf(buf, "%s.new", fn);
- ! if ((text = fopen(buf, "wb")) == NULL)
- ! crash("can't create new text", buf);
- ! setvbuf(text, NULL, _IOFBF, IOBUFSIZE);
- ! sprintf(buf, "%s.ndx", fn);
- ! if ((index = fopen(buf, "wb")) == NULL)
- ! crash("can't create new index", buf);
- ! setvbuf(index, NULL, _IOFBF, IOBUFSIZE);
-
- /* numbers go chronologically */
- for (i = (gp->lo_num)+1; i <= gp->hi_num; i++) {
- ***************
- *** 138,143 ****
- --- 172,179 ----
-
- /* get the time the article was processed */
- art_time = atol(buf+18);
- + /* and the subject */
- + strcpy(subject, buf+28);
-
- if ((current - art_time) > secs) {
-
- ***************
- *** 160,175 ****
- /* copy to new file */
- offset = atol(buf);
- fseek(old_text, offset, SEEK_SET);
- - while (fgets(buf, 255, old_text)) {
-
- ! if (strnicmp(buf,"Subject:",8) == 0) {
- ! strcpy(subject, buf+8);
- ! }
-
- if (fputs(buf, text) == EOF) {
- no_space = TRUE;
- break;
- }
- if (strnicmp(buf, "@@@@END", 7) == 0) break;
- }
-
- --- 196,209 ----
- /* copy to new file */
- offset = atol(buf);
- fseek(old_text, offset, SEEK_SET);
-
- ! while (fgets(buf, 255, old_text)) {
-
- if (fputs(buf, text) == EOF) {
- no_space = TRUE;
- break;
- }
- +
- if (strnicmp(buf, "@@@@END", 7) == 0) break;
- }
-
- ***************
- *** 190,198 ****
- fclose(text);
- fclose(index);
-
- -
- - fn = make_news_group_name(gp->group);
- -
- /* out of disk on expire, delete the temp files */
- if (no_space) {
- fprintf(stderr, "expire: no room to expire %s\n", gp->group);
- --- 224,229 ----
- ***************
- *** 215,221 ****
-
- /* print all groups with articles */
-
- ! gp_art = (int)(gp->hi_num - gp->lo_num);
- gp_bytes_deleted -= gp_bytes;
-
- articles += gp_art;
- --- 246,252 ----
-
- /* print all groups with articles */
-
- ! gp_art = gp->hi_num - gp->lo_num;
- gp_bytes_deleted -= gp_bytes;
-
- articles += gp_art;
- ***************
- *** 226,261 ****
- if ((gp_art > 0) || (gp_art_deleted > 0)) {
-
- if (gp_art_deleted > 0)
- ! printf("%-35s : %4d %5ldKb %4d %5ldKb\n",
- ! gp->group,
- gp_art, (gp_bytes+500)/1000,
- gp_art_deleted, (gp_bytes_deleted+500)/1000);
- else
- ! printf("%-35s : %4d %5ldKb\n",
- ! gp->group,
- gp_art, (gp_bytes+500)/1000);
-
- }
- }
- ! gp = gp->next;
- }
-
- close_active_file();
- -
- expire_history(current, secs);
-
- ! printf("\n%7d articles deleted\n"
- ! "%7ld Kb deleted\n"
- ! "%7d articles remaining\n"
- ! "%7ld Kb of text remaining\n",
- articles_deleted,
- (total_bytes_deleted+500)/1000,
- articles,
- (total_bytes+500)/1000);
-
- ! } else {
- ! fprintf(stderr, "usage: expire <days>\n");
- ! }
- }
-
-
- --- 257,287 ----
- if ((gp_art > 0) || (gp_art_deleted > 0)) {
-
- if (gp_art_deleted > 0)
- ! printf("%4ld %5ld k %4ld %5ld k\n",
- gp_art, (gp_bytes+500)/1000,
- gp_art_deleted, (gp_bytes_deleted+500)/1000);
- else
- ! printf("%4ld %5ld k\n",
- gp_art, (gp_bytes+500)/1000);
-
- }
- }
- !
- }
-
- close_active_file();
- expire_history(current, secs);
-
- ! printf("\n%7ld articles deleted\n"
- ! "%7ld k of text deleted\n"
- ! "%7ld articles remaining\n"
- ! "%7ld k of text remaining\n",
- articles_deleted,
- (total_bytes_deleted+500)/1000,
- articles,
- (total_bytes+500)/1000);
-
- ! exit(0);
- }
-
-
- ***************
- *** 285,295 ****
- --- 311,323 ----
- fprintf(stderr, "expire: cannot open file %s for input\n", buf);
- exit(1);
- }
- + setvbuf(hist_file, NULL, _IOFBF, IOBUFSIZE);
- sprintf(buf, "%shistory.new", my_stuff.news_dir);
- if ((new_hist_file = fopen(buf, "wb")) == NULL) {
- fprintf(stderr, "expire: cannot open file %s for output\n", buf);
- exit(1);
- }
- + setvbuf(new_hist_file, NULL, _IOFBF, IOBUFSIZE);
-
- while (fgets(buf, 255, hist_file) != NULL) {
- sscanf(buf, "%*s %ld", &age);
- ***************
- *** 309,313 ****
- rename(buf, buf2);
- sprintf(buf, "%shistory.bak", my_stuff.news_dir);
- unlink(buf);
- -
- }
- --- 337,340 ----
- Only in new: FILES
- diff -cb orig/history.c new/history.c
- *** orig/history.c Thu Jun 11 22:48:14 1992
- --- new/history.c Sun Aug 02 20:34:18 1992
- ***************
- *** 1,5 ****
- /*
- ! SNEWS 1.0
-
- History routines
-
- --- 1,5 ----
- /*
- ! SNEWS 2.0
-
- History routines
-
- ***************
- *** 143,149 ****
- }
-
- where = 0;
- ! hlist = NULL;
-
- while (fgets(buf, 511, hist)) {
-
- --- 143,149 ----
- }
-
- where = 0;
- ! hlist = h = NULL;
-
- while (fgets(buf, 511, hist)) {
-
- ***************
- *** 160,172 ****
- h->mid = hash_msg_id(p);
- h->offset = where;
-
- - /* leave some memory for other things */
- - if (farcoreleft() < HIST_MEM_LIMIT) break;
- -
- -
- where = ftell(hist);
- }
-
- h->next = NULL;
-
- return(hlist);
- --- 160,169 ----
- h->mid = hash_msg_id(p);
- h->offset = where;
-
- where = ftell(hist);
- }
-
- + if ( h )
- h->next = NULL;
-
- return(hlist);
- ***************
- *** 256,262 ****
-
- /* now look up the history file */
- cx = NULL;
- ! if (h->mid == hid) {
- fseek(hist, h->offset, SEEK_SET);
- if (fgets(buf, 511, hist) != NULL) {
-
- --- 253,259 ----
-
- /* now look up the history file */
- cx = NULL;
- ! if (h && h->mid == hid) {
- fseek(hist, h->offset, SEEK_SET);
- if (fgets(buf, 511, hist) != NULL) {
-
- ***************
- *** 287,299 ****
- strcpy(c->group, p);
- p = strtok(NULL, " \t\n\r");
- c->art_num = atol(p);
-
- } else {
- /* eat article number */
- p = strtok(NULL, " \t\n\r");
- }
- -
- - c->next = NULL;
-
- p = strtok(NULL, " \t\n\r");
- }
- --- 284,295 ----
- strcpy(c->group, p);
- p = strtok(NULL, " \t\n\r");
- c->art_num = atol(p);
- + c->next = NULL;
-
- } else {
- /* eat article number */
- p = strtok(NULL, " \t\n\r");
- }
-
- p = strtok(NULL, " \t\n\r");
- }
- Only in new: lock.c
- Only in new: Makefile
- Only in new: os2defs.h
- Only in new: os2util.c
- Only in new: patches.os2
- Only in new: pipe.c
- diff -cb orig/post.c new/post.c
- *** orig/post.c Thu Jun 11 22:48:14 1992
- --- new/post.c Sun Aug 02 20:34:18 1992
- ***************
- *** 1,5 ****
- /*
- ! SNEWS 1.0
-
- snews - posting stuff
-
- --- 1,5 ----
- /*
- ! SNEWS 2.0
-
- snews - posting stuff
-
- ***************
- *** 34,40 ****
-
-
- /*------------------------------- post an article --------------------------*/
- ! void post(TEXT *tx, char *gx, char *subject)
- {
- /*
- * Ask for the data we are not given in the arguments,
- --- 34,40 ----
-
-
- /*------------------------------- post an article --------------------------*/
- ! void post(TEXT *tx, char *gx)
- {
- /*
- * Ask for the data we are not given in the arguments,
- ***************
- *** 43,62 ****
-
- FILE *article, *sig;
- LINE *ln;
- ! char buf[80];
- ! char newsgroups[256];
- char sig_fn[80];
- ! char author[80], msg_id[80];
- int ch;
-
- strcpy(newsgroups, gx);
-
- strcpy(author, "");
- strcpy(msg_id, "");
-
- ! if ((article = fopen("post.tmp", "w+")) != NULL) {
-
- - command("");
- if (strlen(newsgroups) == 0) {
-
- /* if no groups ask for them */
- --- 43,64 ----
-
- FILE *article, *sig;
- LINE *ln;
- ! char buf[MAXLINE];
- ! char fn[256], newsgroups[256], subject[256];
- char sig_fn[80];
- ! char author[80], msg_id[256];
- int ch;
-
- + strcpy(fn, my_stuff.news_dir);
- + strcat(fn, "article");
- + unlink(fn);
- strcpy(newsgroups, gx);
-
- strcpy(author, "");
- strcpy(msg_id, "");
-
- ! if ((article = fopen(fn, "w+")) != NULL) {
-
- if (strlen(newsgroups) == 0) {
-
- /* if no groups ask for them */
- ***************
- *** 80,94 ****
- /* check for a valid newsgroups line */
- if (newsgroups_valid(newsgroups)) {
-
- - if (strlen(subject) == 0) {
- - lmessage("Subject? ");
- - gets(subject);
- - }
- -
- /* add the quoted message */
- /* are we quoting */
- if (tx != NULL) {
-
- message("Quote article (y/n)? ");
- while (((ch = getch()) != 'y') && (ch != 'n'));
-
- --- 82,101 ----
- /* check for a valid newsgroups line */
- if (newsgroups_valid(newsgroups)) {
-
- /* add the quoted message */
- /* are we quoting */
- if (tx != NULL) {
-
- + if (strlen(tx->subject) == 0) {
- + lmessage("Subject? ");
- + gets(subject);
- + }
- + else
- + if ( strnicmp(tx->subject, "Re: ", 4) != 0 )
- + sprintf(subject, "Re: %s", tx->subject);
- + else
- + strcpy(subject, tx->subject);
- +
- message("Quote article (y/n)? ");
- while (((ch = getch()) != 'y') && (ch != 'n'));
-
- ***************
- *** 95,108 ****
- if (ch == 'y') {
-
- get_his_stuff(tx, author, msg_id);
- ! fprintf(article, "\nIn article %s %s writes:\n\n", msg_id, author);
- ln = tx->start;
- while (ln != NULL) {
- ! fprintf(article, " > %s", ln->data);
- ln = ln->next;
- }
- }
- }
-
- /* append the signature if there is one */
- strcpy(sig_fn, my_stuff.home);
- --- 102,119 ----
- if (ch == 'y') {
-
- get_his_stuff(tx, author, msg_id);
- ! fprintf(article, "%s writes in article %s:\n", author, msg_id);
- ln = tx->start;
- while (ln != NULL) {
- ! fprintf(article, "> %s", ln->data);
- ln = ln->next;
- }
- }
- }
- + else {
- + lmessage("Subject? ");
- + gets(subject);
- + }
-
- /* append the signature if there is one */
- strcpy(sig_fn, my_stuff.home);
- ***************
- *** 110,127 ****
- if ((sig = fopen(sig_fn, "rt")) != NULL) {
- while (fgets(buf, 79, sig) != NULL)
- fputs(buf, article);
- }
-
-
- fclose(article);
- ! sprintf(buf, my_stuff.editor, "post.tmp");
- system(buf);
- ! article = fopen("post.tmp", "rt");
-
- sprintf(buf, "Post this article to %s (y/n)? ", newsgroups);
- message(buf);
- while (((ch = getch()) != 'y') && (ch != 'n'));
- ! gotoxy(1,24);
-
- if (ch == 'y')
- post_it(article, newsgroups, subject, "world", msg_id);
- --- 121,139 ----
- if ((sig = fopen(sig_fn, "rt")) != NULL) {
- while (fgets(buf, 79, sig) != NULL)
- fputs(buf, article);
- + fclose(sig);
- }
-
-
- fclose(article);
- ! sprintf(buf, my_stuff.editor, fn);
- system(buf);
- ! article = fopen(fn, "rt");
-
- sprintf(buf, "Post this article to %s (y/n)? ", newsgroups);
- message(buf);
- while (((ch = getch()) != 'y') && (ch != 'n'));
- ! gotoxy(1,PAGE_SIZE);
-
- if (ch == 'y')
- post_it(article, newsgroups, subject, "world", msg_id);
- ***************
- *** 129,135 ****
- }
-
- fclose(article);
- ! unlink("post.tmp");
-
- } else {
- message("*** couldn't open temp article file - press any key ***");
- --- 141,147 ----
- }
-
- fclose(article);
- ! /* unlink(fn); /* keep it around like rn */
-
- } else {
- message("*** couldn't open temp article file - press any key ***");
- ***************
- *** 152,163 ****
-
- FILE *tmp, *local, *log;
- char buf[256], *p;
- ! char ng[256];
- char d_name[20], x_name[20];
- char short_d_name[20], short_x_name[20];
- int ct, seq;
- time_t t;
- ! struct tm *gmt;
- long where;
- ACTIVE *gp;
-
- --- 164,176 ----
-
- FILE *tmp, *local, *log;
- char buf[256], *p;
- ! char ng[256], timestr[64];
- char d_name[20], x_name[20];
- char short_d_name[20], short_x_name[20];
- + char remotegroups[256];
- int ct, seq;
- time_t t;
- ! struct tm *gmt, *tmnow;
- long where;
- ACTIVE *gp;
-
- ***************
- *** 183,189 ****
- while (fgets(buf, 255, article) != NULL)
- ct++;
-
- -
- /*
- * Make the final article file. This posting stuff is a horrible
- * kludge (blush). If you get a around to fixing this, please
- --- 196,201 ----
- ***************
- *** 191,202 ****
- */
- if ((tmp = fopen(short_d_name, "w+b")) != NULL) {
-
- fprintf(tmp, "Path: %s!%s\n", my_stuff.my_site, my_stuff.user);
- fprintf(tmp, "From: %s@%s (%s)\n", my_stuff.user, my_stuff.my_domain,
- my_stuff.my_name);
- fprintf(tmp, "Newsgroups: %s\n", newsgroups);
- fprintf(tmp, "Subject: %s\n", subject);
- ! fprintf(tmp, "Distribution: %s\n", dist);
-
- fprintf(tmp, "Message-ID: <%ldsnx@%s>\n", time(&t), my_stuff.my_domain);
-
- --- 203,226 ----
- */
- if ((tmp = fopen(short_d_name, "w+b")) != NULL) {
-
- + remotegroups[0] = 0;
- + strcpy(ng, newsgroups);
- + p = strtok(ng, " ,");
- + while (p != NULL) {
- + if (!is_local_group(p)) {
- + if (remotegroups[0])
- + strcat(remotegroups, ",");
- + strcat(remotegroups, p);
- + }
- + p = strtok(NULL, " ,");
- + }
- +
- fprintf(tmp, "Path: %s!%s\n", my_stuff.my_site, my_stuff.user);
- fprintf(tmp, "From: %s@%s (%s)\n", my_stuff.user, my_stuff.my_domain,
- my_stuff.my_name);
- fprintf(tmp, "Newsgroups: %s\n", newsgroups);
- fprintf(tmp, "Subject: %s\n", subject);
- ! fprintf(tmp, "Distribution: %s\n", remotegroups[0] ? dist : "local");
-
- fprintf(tmp, "Message-ID: <%ldsnx@%s>\n", time(&t), my_stuff.my_domain);
-
- ***************
- *** 211,217 ****
- gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
-
- fprintf(tmp, "Organization: %s\n", my_stuff.my_organisation);
- ! fprintf(tmp, "Lines: %d\n\n", ct);
-
- /* copy the rest */
- rewind(article);
- --- 235,251 ----
- gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
-
- fprintf(tmp, "Organization: %s\n", my_stuff.my_organisation);
- ! fprintf(tmp, "Lines: %d\n", ct);
- !
- ! strcpy(buf, my_stuff.news_dir);
- ! strcat(buf, "headers");
- ! if ((local = fopen(buf, "r")) != NULL) {
- ! while (fgets(buf, 255, local) != NULL)
- ! fputs(buf, tmp);
- ! fclose(local);
- ! }
- !
- ! fputs("\n", tmp);
-
- /* copy the rest */
- rewind(article);
- ***************
- *** 251,259 ****
- /* finally log it */
- strcpy(buf, my_stuff.news_dir);
- strcat(buf, "post.log");
- ! if ((log = fopen(buf, "at")) != NULL) {
- fprintf(log, "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
- "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\n");
-
- fseek(tmp, 0L, SEEK_SET);
- while (fgets(buf, 255, tmp) != NULL) {
- --- 285,297 ----
- /* finally log it */
- strcpy(buf, my_stuff.news_dir);
- strcat(buf, "post.log");
- ! if ((log = flockopen(buf, "at")) != NULL) {
- fprintf(log, "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
- "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\n");
- + tmnow = localtime(&t);
- + strftime(timestr, sizeof(timestr), "%a %b %d %H:%M:%S %z %Y", gmt);
- + fprintf(log, "From %s!%s %s\n", my_stuff.my_site, my_stuff.user,
- + timestr);
-
- fseek(tmp, 0L, SEEK_SET);
- while (fgets(buf, 255, tmp) != NULL) {
- ***************
- *** 265,272 ****
-
- fclose(tmp);
-
- -
- /* now the the X... file */
- if ((tmp = fopen(short_x_name, "wb")) != NULL) {
- fprintf(tmp, "U news %s\n", my_stuff.my_site);
- fprintf(tmp, "Z\n");
- --- 303,310 ----
-
- fclose(tmp);
-
- /* now the the X... file */
- + if (remotegroups[0])
- if ((tmp = fopen(short_x_name, "wb")) != NULL) {
- fprintf(tmp, "U news %s\n", my_stuff.my_site);
- fprintf(tmp, "Z\n");
- ***************
- *** 275,287 ****
- fprintf(tmp, "C rnews\n");
- fclose(tmp);
-
- ! sprintf(buf, "uucp -C %s %s!%s ", short_d_name, my_stuff.mail_server,
- ! d_name);
- ! gotoxy(1,24); clreol();
- system(buf);
- ! sprintf(buf, "uucp -C %s %s!%s ", short_x_name, my_stuff.mail_server,
- ! x_name);
- ! gotoxy(1,24); clreol();
- system(buf);
-
- } else {
- --- 313,325 ----
- fprintf(tmp, "C rnews\n");
- fclose(tmp);
-
- ! sprintf(buf, "uucp -C %s %s!%s 2>nul", short_d_name,
- ! my_stuff.mail_server, d_name);
- ! gotoxy(1,PAGE_SIZE); clreol();
- system(buf);
- ! sprintf(buf, "uucp -C %s %s!%s 2>nul", short_x_name,
- ! my_stuff.mail_server, x_name);
- ! gotoxy(1,PAGE_SIZE); clreol();
- system(buf);
-
- } else {
- ***************
- *** 317,325 ****
-
- while (p != NULL) {
- if (!check_valid_post_group(p)) {
- ! sprintf(msg, "** Can't post to %s **", p);
- message(msg);
- - command("-- Press any key to continue --");
- getch();
- return(FALSE);
- }
- --- 355,362 ----
-
- while (p != NULL) {
- if (!check_valid_post_group(p)) {
- ! sprintf(msg, "*** can't post to %s - press any key ***", p);
- message(msg);
- getch();
- return(FALSE);
- }
- Only in new: pwd.c
- Only in new: pwd.h
- Only in new: README.OS2
- diff -cb orig/rmgroup.c new/rmgroup.c
- *** orig/rmgroup.c Thu Jun 11 22:48:15 1992
- --- new/rmgroup.c Sun Aug 02 20:34:18 1992
- ***************
- *** 1,5 ****
- /*
- ! SNEWS 1.0
-
- rmgroup - remove newsgroups from the active file, and delete the files
-
- --- 1,5 ----
- /*
- ! SNEWS 2.0
-
- rmgroup - remove newsgroups from the active file, and delete the files
-
- ***************
- *** 49,54 ****
- --- 49,56 ----
- FILE *active_file, *new_active_file;
-
-
- + fprintf(stderr, "RMGROUP: (%s)\n\n", VERSION);
- +
- if (argc > 1) {
-
- if (!load_stuff()) {
- ***************
- *** 68,74 ****
-
- /* form the directory name */
- dir = make_news_group_name(argv[i]);
- ! unlink(buf);
- sprintf(buf, "%s.IDX", dir);
- unlink(buf);
-
- --- 70,76 ----
-
- /* form the directory name */
- dir = make_news_group_name(argv[i]);
- ! unlink(dir);
- sprintf(buf, "%s.IDX", dir);
- unlink(buf);
-
- ***************
- *** 113,119 ****
-
-
- } else {
- ! fprintf(stderr, "rmgroup: newsgroup %s not found\n", argv[1]);
- }
-
- }
- --- 115,121 ----
-
-
- } else {
- ! fprintf(stderr, "rmgroup: newsgroup %s not found\n", argv[i]);
- }
-
- }
- ***************
- *** 121,127 ****
- close_active_file();
-
- } else {
- ! printf("USAGE: rmgroup newsgroup names....\n");
- }
-
- }
- --- 123,129 ----
- close_active_file();
-
- } else {
- ! printf("usage: rmgroup newsgroup names....\n");
- }
-
- }
- Only in new: rnews.c
- Only in new: rnews.h
- diff -cb orig/snews.c new/snews.c
- *** orig/snews.c Thu Jun 11 22:48:16 1992
- --- new/snews.c Sun Aug 09 01:29:29 1992
- ***************
- *** 1,5 ****
- /*
- ! SNEWS 1.0
-
- snews - a simple threaded news reader
-
- --- 1,5 ----
- /*
- ! SNEWS 2.0
-
- snews - a simple threaded news reader
-
- ***************
- *** 27,32 ****
- --- 27,34 ----
-
-
- INFO my_stuff;
- + char iobuf[IOBUFSIZE];
- + char search_text[256];
-
-
- /*------------------------------- main --------------------------------*/
- ***************
- *** 35,50 ****
- ACTIVE *gp, *head;
- int done;
-
- ! printf("loading config... ");
- if (load_stuff()) {
-
- ! printf("loading active... ");
- head = load_active_file();
- ! printf("loading read list... ");
- load_read_list();
- ! printf("loading history... ");
- load_history_list();
-
- done = FALSE;
- gp = NULL;
-
- --- 37,57 ----
- ACTIVE *gp, *head;
- int done;
-
- ! ignore_signals();
- !
- ! printf("loading config...\n");
- if (load_stuff()) {
-
- ! printf("loading active...\n");
- head = load_active_file();
- ! printf("loading read list...\n");
- load_read_list();
- ! printf("loading history...\n");
- load_history_list();
-
- + scrinit();
- + clrscr();
- +
- done = FALSE;
- gp = NULL;
-
- ***************
- *** 56,68 ****
- }
- }
-
- clrscr();
-
- free_hist_list();
- save_read_list();
- close_active_file();
- } else {
- ! fprintf(stderr, "Couldn't fine neccessary item in the .rc files\n");
- }
- }
-
- --- 63,77 ----
- }
- }
-
- + screxit();
- clrscr();
-
- free_hist_list();
- save_read_list();
- close_active_file();
- +
- } else {
- ! fprintf(stderr, "Couldn't find necessary item in the .rc files\n");
- }
- }
-
- ***************
- *** 74,80 ****
- {
- /*
- * Present the list of groups, and allow him to move up and down with
- ! * the arrow and PgUp and PgDn keys. 'h' for help, -/+ for searches
- */
-
- ACTIVE *top; /* newsgroup at the top of the page */
- --- 83,89 ----
- {
- /*
- * Present the list of groups, and allow him to move up and down with
- ! * the arrow and PgUp and PgDn keys.
- */
-
- ACTIVE *top; /* newsgroup at the top of the page */
- ***************
- *** 81,87 ****
- ACTIVE *this; /* current newsgroup */
- ACTIVE *tmp_ng;
- int exit_code; /* why we are exiting the loop */
- - char sub_tmp[80];
-
- int ch, i, j, articles, unread;
-
- --- 90,95 ----
- ***************
- *** 90,96 ****
- top = head;
- exit_code = 0;
-
- ! show_groups(&top, this, TRUE);
-
- while (exit_code == 0) {
-
- --- 98,104 ----
- top = head;
- exit_code = 0;
-
- ! show_groups(&top, this, TRUE, head);
-
- while (exit_code == 0) {
-
- ***************
- *** 98,107 ****
- switch (ch) {
-
- case 0 :
- ! ch = getch();
-
- switch (ch) {
-
- case UP_ARR :
- if (this->last != NULL) this = this->last;
- break;
- --- 106,121 ----
- switch (ch) {
-
- case 0 :
- ! case 0xE0 :
-
- + ch = getch();
- switch (ch) {
-
- + case F1 :
- + show_help(HELP_GROUP);
- + show_groups(&top, this, TRUE, head);
- + break;
- +
- case UP_ARR :
- if (this->last != NULL) this = this->last;
- break;
- ***************
- *** 126,133 ****
-
- case HOME :
- top = this = head;
- ! show_groups(&top, this, TRUE);
- break;
- case END :
- this = head;
- while (this->next != NULL)
- --- 140,148 ----
-
- case HOME :
- top = this = head;
- ! show_groups(&top, this, TRUE, head);
- break;
- +
- case END :
- this = head;
- while (this->next != NULL)
- ***************
- *** 137,156 ****
- break;
-
- case 'p' :
- ! strcpy(sub_tmp, "");
- ! post(NULL, this->group, sub_tmp);
- ! show_groups(&top, this, TRUE);
- break;
-
- - case '?' :
- case 'h' :
- show_help(HELP_GROUP);
- ! show_groups(&top, this, TRUE);
- break;
-
- case 'c' :
- mark_group_as_read(this);
- ! show_groups(&top, this, TRUE);
- break;
-
- case TAB :
- --- 152,172 ----
- break;
-
- case 'p' :
- ! case 'P' :
- ! post(NULL, this->group);
- ! show_groups(&top, this, TRUE, head);
- break;
-
- case 'h' :
- + case 'H' :
- show_help(HELP_GROUP);
- ! show_groups(&top, this, TRUE, head);
- break;
-
- case 'c' :
- + case 'C' :
- mark_group_as_read(this);
- ! show_groups(&top, this, TRUE, head);
- break;
-
- case TAB :
- ***************
- *** 181,187 ****
- break;
- };
- if (exit_code == 0)
- ! show_groups(&top, this, FALSE);
- }
-
- if (exit_code == EX_DONE)
- --- 197,203 ----
- break;
- };
- if (exit_code == 0)
- ! show_groups(&top, this, FALSE, head);
- }
-
- if (exit_code == EX_DONE)
- ***************
- *** 194,247 ****
-
-
- /*---------------------------- help screen ----------------------------------*/
- ! void show_help(int h)
- {
-
- ! char *type[] = {"New Group", "Thread", "Article"};
-
- ! clrscr();
- textbackground(LIGHTGRAY); textcolor(BLACK);
- clreol();
- - cprintf(" %s Help (%s)\r\n", type[h], VERSION);
- - clreol();
- textbackground(BLACK); textcolor(LIGHTGRAY);
-
- ! printf("\n\n");
- ! printf(" PgUp - move display up one page\n");
- ! printf(" PgDn - move display down one page\n");
- ! printf(" Home - move to top of list/article\n");
- ! printf(" End - move to bottom of list/article\n");
- ! printf(" \x18 - move up one line\n");
- ! printf(" \x19 - move down one line\n\n");
-
- switch (h) {
- case HELP_GROUP :
- ! printf(" TAB - go to next newgroup with unread articles\n");
- ! printf(" ENTER - enter selected newsgroup\n\n");
- ! printf(" p - post article in selected newsgroup\n");
- ! printf(" c - mark all articles in this newsgroup as read\n");
- break;
-
- case HELP_THREAD :
- ! printf(" TAB - go to next unread article\n");
- ! printf(" ENTER - read the selected thread from the begining\n\n");
- ! printf(" p - post article in selected newsgroup\n");
- ! printf(" c - mark all articles in this newsgroup as read\n");
- ! printf(" s - save thread to disk\n");
- break;
-
- case HELP_ARTICLES:
- ! printf(" TAB - go to next unread article\n");
- ! printf(" ENTER - go to next article in thread\n\n");
- ! printf(" p - Post article in selected newsgroup\n");
- ! printf(" f - post Followup to this article\n\n");
- ! printf(" r - mail a Reply to this article\n\n");
- ! printf(" m - mail this article to someone\n\n");
- ! printf(" c - mark all articles in this newsgroup as read\n");
- ! printf(" s - save article to disk\n");
- break;
- };
-
- message("-- Press any key to continue --");
- getch();
-
- --- 210,291 ----
-
-
- /*---------------------------- help screen ----------------------------------*/
- !
- ! void help(char *text)
- {
- + printf("%*s", _columns / 2 - 40, "");
-
- ! while (*text) {
- ! if (*text == '\n')
- ! clreol(), _line++;
- ! putch(*text++);
- ! }
- ! }
-
- ! void show_help(int h)
- ! {
- ! char *type[] = {"Group Help", "Thread Help", "Article Help"};
- ! char *msg = COPYRIGHT;
- ! int x;
- !
- ! gotoxy(1,1);
- textbackground(LIGHTGRAY); textcolor(BLACK);
- + printf("%-18s %*s", type[h], _columns - 19, VERSION);
- + gotoxy(1,2);
- + x = _columns / 2 - strlen(msg) / 2;
- + printf("%*s%s", x, "", msg);
- clreol();
- textbackground(BLACK); textcolor(LIGHTGRAY);
- + putch('\n');
-
- ! help("\n");
- ! help(" PageUp - move display up one page\n");
- ! help(" PageDn - move display down one page\n");
- ! help(" Home - move to top of list/article\n");
- ! help(" End - move to bottom of list/article\n");
- ! help(" Up - move up one line\n");
- ! help(" Down - move down one line\n");
-
- switch (h) {
- case HELP_GROUP :
- ! help("\n");
- ! help(" Tab - go to next newgroup with unread articles\n");
- ! help(" Enter - enter selected newsgroup\n\n");
- ! help(" c - mark all articles in selected group as read\n");
- ! help(" p - post article to selected group\n");
- break;
-
- case HELP_THREAD :
- ! help("\n");
- ! help(" Tab - go to next thread with unread articles or\n");
- ! help(" enter this thread if it is already selected\n");
- ! help(" and move to the first unread article in the thread\n");
- ! help(" Enter - read the selected thread from the beginning\n");
- ! help(" Backspace - go to the last article in the selected thread\n\n");
- ! help(" c - mark all articles in selected thread as read\n");
- ! help(" s - save selected thread to disk\n");
- ! help(" p - post article to this group\n\n");
- ! help(" + - search for text in subjects\n");
- ! help(" / - search for text in article bodies\n");
- break;
-
- case HELP_ARTICLES:
- ! help(" Left - scroll right\n");
- ! help(" Right - scroll left\n\n");
- ! help(" Tab - go to next unread article\n");
- ! help(" Enter - go to next article in thread\n");
- ! help(" Backspace - go to previous article in thread\n\n");
- ! help(" s - save this article to disk\n");
- ! help(" p - post new article to current group\n");
- ! help(" f - post follow-up to this article\n");
- ! help(" r - reply to sender of this article via e-mail\n");
- ! help(" m - mail this article to someone\n");
- ! help(" + / - search for text in following articles\n");
- ! help(" - ? - search for text in preceding articles\n");
- break;
- };
-
- + clreos();
- message("-- Press any key to continue --");
- getch();
-
- ***************
- *** 251,257 ****
-
-
- /*-------------------- show the list of active groups -----------------------*/
- ! void show_groups(ACTIVE **top, ACTIVE *this, int force)
- {
- /*
- * This routine takes 'top', a pointer to the first line on the screen
- --- 295,301 ----
-
-
- /*-------------------- show the list of active groups -----------------------*/
- ! void show_groups(ACTIVE **top, ACTIVE *this, int force, ACTIVE *head)
- {
- /*
- * This routine takes 'top', a pointer to the first line on the screen
- ***************
- *** 264,269 ****
- --- 308,314 ----
- static last_index;
- int i, ur;
- ACTIVE *that;
- + char buf[32];
-
- /*
- * If 'this' is above the 'top' or it is more than a screen length below,
- ***************
- *** 276,289 ****
- ((*top)->index > this->index) ||
- (this->index - (*top)->index) > PAGE_LENGTH-1) {
-
- ! clrscr();
- textbackground(LIGHTGRAY); textcolor(BLACK);
- ! clreol();
- ! cprintf(" Select Newsgroup (%s) [%ldk]\r\n",
- ! VERSION, farcoreleft()/1000);
- clreol();
- - cprintf("\r\n");
- - clreol();
- textbackground(BLACK); textcolor(LIGHTGRAY);
-
- /* now adjust the top */
- --- 321,332 ----
- ((*top)->index > this->index) ||
- (this->index - (*top)->index) > PAGE_LENGTH-1) {
-
- ! gotoxy(1,1);
- textbackground(LIGHTGRAY); textcolor(BLACK);
- ! sprintf(buf, "Group %d of %d", last_index + 1, head->groups);
- ! printf("Select Group %*s", _columns - 13, buf);
- ! gotoxy(1,2);
- clreol();
- textbackground(BLACK); textcolor(LIGHTGRAY);
-
- /* now adjust the top */
- ***************
- *** 294,333 ****
- }
-
- that = *top;
- ! for (i = 0; i < PAGE_LENGTH; i++) {
- ur = count_unread_in_group(that);
- ! gotoxy(7, i+4);
- ! printf("%4d. %-50s", ((*top)->index)+i, that->group);
- ! if (ur == 0)
- ! printf(" ", ur);
- else
- ! printf(" %4d", ur);
- ! printf(" (%d)\n", that->hi_num - that->lo_num);
- that = that->next;
- - if (that == NULL) break;
- }
-
- last_y = this->index - (*top)->index;
- ! gotoxy(5, last_y + PAGE_HEADER);
- ! putch('>');
- last_index = this->index;
-
- } else {
-
- ! gotoxy(5, last_y + PAGE_HEADER);
- ! putch(' ');
-
- last_y += (this->index - last_index);
- ! gotoxy(5, last_y + PAGE_HEADER);
- ! putch('>');
- last_index = this->index;
-
- }
-
- ! command("ESC=quit TAB=next unread group ENTER=read group '?'=help");
- ! }
- !
-
-
-
- /*--------------------------- process message -------------------------------*/
- --- 337,382 ----
- }
-
- that = *top;
- ! for (i = 0; i < PAGE_LENGTH+1; i++) {
- ! gotoxy(1, i+PAGE_HEADER);
- ! if (that == NULL) break;
- ur = count_unread_in_group(that);
- ! if (ur > 0)
- ! printf(" %4d %4ld %s", ur,
- ! that->hi_num - that->lo_num, that->group);
- else
- ! printf(" %4ld %s",
- ! that->hi_num - that->lo_num, that->group);
- ! clreol();
- that = that->next;
- }
-
- + clreos();
- last_y = this->index - (*top)->index;
- ! gotoxy(2, last_y + PAGE_HEADER);
- ! puts("->");
- last_index = this->index;
-
- } else {
-
- ! gotoxy(2, last_y + PAGE_HEADER);
- ! puts(" ");
-
- last_y += (this->index - last_index);
- ! gotoxy(2, last_y + PAGE_HEADER);
- ! puts("->");
- last_index = this->index;
-
- }
-
- ! gotoxy(_columns - 16,1);
- ! textbackground(LIGHTGRAY); textcolor(BLACK);
- ! sprintf(buf, "Group %d of %d", last_index + 1, head->groups);
- ! printf("%17s", buf);
- ! textbackground(BLACK); textcolor(LIGHTGRAY);
-
- + message("ESC=quit TAB=next unread group ENTER=read group F1=help");
- + }
-
-
- /*--------------------------- process message -------------------------------*/
- ***************
- *** 341,356 ****
- ARTICLE *start;
-
- if (gp->lo_num < gp->hi_num) {
- -
- - clrscr();
- - printf(" Select Thread (%s) [%ldk]\n", VERSION,
- - farcoreleft()/1000);
- - printf("Group: %s ", gp->group);
- -
- start = get_headers(gp);
- -
- select_thread(gp, start);
- -
- free_header(start);
- }
-
- --- 390,397 ----
- ***************
- *** 359,365 ****
-
-
- /*-------------------- show the list of active groups -----------------------*/
- ! void show_threads(ACTIVE *gp, ARTICLE **top, ARTICLE *this, int force)
- {
- /*
- * This routine takes 'top', a pointer to the first line on the screen
- --- 400,407 ----
-
-
- /*-------------------- show the list of active groups -----------------------*/
- ! void show_threads(ACTIVE *gp, ARTICLE **top, ARTICLE *this, int force,
- ! ARTICLE *head)
- {
- /*
- * This routine takes 'top', a pointer to the first line on the screen
- ***************
- *** 372,378 ****
- static last_index;
- int i;
- ARTICLE *that;
- ! int unread;
-
- /*
- * If 'this' is above the 'top' or it is more than a screen length below,
- --- 414,421 ----
- static last_index;
- int i;
- ARTICLE *that;
- ! int ur;
- ! char buf[32];
-
- /*
- * If 'this' is above the 'top' or it is more than a screen length below,
- ***************
- *** 385,398 ****
- ((*top)->index > this->index) ||
- (this->index - (*top)->index) > PAGE_LENGTH-1) {
-
- ! clrscr();
- textbackground(LIGHTGRAY); textcolor(BLACK);
- ! clreol();
- ! cprintf(" Select Thread (%s) [%ldk]\r\n", VERSION,
- ! farcoreleft()/1000);
- ! clreol();
- ! cprintf("Group: %s\r\n", gp->group);
- ! clreol();
- textbackground(BLACK); textcolor(LIGHTGRAY);
-
- /* now adjust the top */
- --- 428,445 ----
- ((*top)->index > this->index) ||
- (this->index - (*top)->index) > PAGE_LENGTH-1) {
-
- ! for (that = head, ur = 0; that; that = that->next)
- ! ur += count_unread_in_thread(gp, that);
- !
- ! gotoxy(1,1);
- textbackground(LIGHTGRAY); textcolor(BLACK);
- ! sprintf(buf, "Thread %d of %d", last_index + 1, gp->threads);
- ! printf("Select Thread %*s", _columns - 14, buf);
- ! gotoxy(1,2);
- ! sprintf(buf, "%ld Articles, %d unread",
- ! gp->hi_num - gp->lo_num, ur);
- ! printf("Group: %-*.*s %26s", _columns - 34, _columns - 34,
- ! gp->group, buf);
- textbackground(BLACK); textcolor(LIGHTGRAY);
-
- /* now adjust the top */
- ***************
- *** 403,452 ****
- }
-
- that = *top;
- ! for (i = 0; i < PAGE_LENGTH; i++) {
- ! unread = count_unread_in_thread(gp, that),
- ! gotoxy(7, i+4);
- ! if (unread > 0) {
- ! printf("%4d. %4d %4d %s", ((*top)->index)+i,
- ! unread,
- that->num_articles, that->header);
- ! } else {
- ! printf("%4d. %4d %s", ((*top)->index)+i,
- that->num_articles, that->header);
- ! }
- that = that->next;
- - if (that == NULL) break;
- }
-
- last_y = this->index - (*top)->index;
- ! gotoxy(5, last_y + PAGE_HEADER);
- ! putch('>');
- last_index = this->index;
-
- } else {
-
- ! gotoxy(5, last_y + PAGE_HEADER);
- ! putch(' ');
-
- last_y += (this->index - last_index);
- ! gotoxy(5, last_y + PAGE_HEADER);
- ! putch('>');
- last_index = this->index;
-
- }
-
- ! command("ESC=select group TAB=next unread ENTER=next article '?'=help");
- }
-
-
-
-
- ! /*-------------------------- find which group to read -----------------------*/
- void select_thread(ACTIVE *gp, ARTICLE *head)
- {
- /*
- * Present the list of threads, and allow him to move up and down with
- ! * the arrow and PgUp and PgDn keys. 'h' for help, -/+ for searches
- */
-
- ARTICLE *top; /* thread at the top of the page */
- --- 450,589 ----
- }
-
- that = *top;
- ! for (i = 0; i < PAGE_LENGTH+1; i++) {
- ! gotoxy(1, i+PAGE_HEADER);
- ! if (that == NULL) break;
- ! ur = count_unread_in_thread(gp, that);
- ! if (ur > 0)
- ! printf(" %4d %4d %s", ur,
- that->num_articles, that->header);
- ! else
- ! printf(" %4d %s",
- that->num_articles, that->header);
- ! clreol();
- that = that->next;
- }
-
- + clreos();
- +
- last_y = this->index - (*top)->index;
- ! gotoxy(2, last_y + PAGE_HEADER);
- ! puts("->");
- last_index = this->index;
-
- } else {
-
- ! gotoxy(2, last_y + PAGE_HEADER);
- ! puts(" ");
-
- last_y += (this->index - last_index);
- ! gotoxy(2, last_y + PAGE_HEADER);
- ! puts("->");
- last_index = this->index;
-
- + gotoxy(_columns - 17,1);
- + textbackground(LIGHTGRAY); textcolor(BLACK);
- + sprintf(buf, "Thread %d of %d", last_index + 1, gp->threads);
- + printf("%18s", buf);
- + textbackground(BLACK); textcolor(LIGHTGRAY);
- +
- }
-
- ! message("ESC=select group TAB=next unread ENTER=next article F1=help");
- }
-
-
-
- + /*--------------- search through threads ------------------------------------*/
- + ARTICLE *search_thread(ACTIVE *gp, ARTICLE *head, int search_body)
- + {
- + int offset = 0, found = FALSE, irq = FALSE;
- + ARTICLE *this;
- + ART_ID *art;
- + TEXT *tx;
- + LINE *text;
- + char *fn;
- + char prompt[128], pattern[128];
- +
- + if (head == NULL || head->next == NULL)
- + return head;
-
- ! sprintf(prompt, "Search %s for? [%s] ",
- ! search_body ? "articles" : "subjects", search_text);
- ! lmessage(prompt);
- ! if (gets(pattern) == NULL)
- ! return head;
- !
- ! if (strlen(pattern) > 0)
- ! strcpy(search_text, pattern);
- ! else
- ! strcpy(pattern, search_text);
- !
- ! strlwr(pattern);
- !
- ! if (search_body) {
- !
- ! message("*** searching - please wait (press ESC to abort) ***");
- ! tflush();
- !
- ! for (this = head->next; this != NULL; this = this->next) {
- !
- ! /* for each article */
- ! for (art = this->art_num; art != NULL; art = art->next_art) {
- !
- ! fn = make_news_group_name(gp->group);
- ! tx = load_article(fn, art->art_off);
- !
- ! for (text = tx->start; !found && text != NULL;
- ! text = text->next) {
- ! strlwr(text->data);
- ! found = (strstr(text->data, pattern) != NULL);
- ! }
- !
- ! free_article(tx);
- !
- ! if (kbhit())
- ! irq = (getch() == 27);
- !
- ! if (found || irq)
- ! break;
- ! }
- !
- ! if (found || irq)
- ! break;
- ! }
- !
- ! } else {
- !
- ! for (this = head->next; this != NULL; this = this->next) {
- !
- ! strcpy(prompt, this->header);
- ! strlwr(prompt);
- ! found = (strstr(prompt, pattern) != NULL);
- !
- ! if (found)
- ! break;
- ! }
- !
- ! }
- !
- ! if (!found && !irq) {
- ! sprintf(prompt, "*** '%s' not found - press any key ***", pattern);
- ! message(prompt);
- ! getch();
- ! }
- !
- ! return found ? this : head;
- ! }
- !
- !
- !
- ! /*-------------------------- find which thread to read ----------------------*/
- void select_thread(ACTIVE *gp, ARTICLE *head)
- {
- /*
- * Present the list of threads, and allow him to move up and down with
- ! * the arrow and PgUp and PgDn keys.
- */
-
- ARTICLE *top; /* thread at the top of the page */
- ***************
- *** 454,469 ****
- ARTICLE *th;
- ART_ID *art;
- int exit_code; /* why we are exiting the loop */
- - char sub_tmp[80];
-
- int ch, i, idx, hit, a_ct;
-
- this = head;
- -
- top = head;
- exit_code = 0;
-
- ! show_threads(gp, &top, this, TRUE);
-
- while (exit_code == 0) {
-
- --- 591,604 ----
- ARTICLE *th;
- ART_ID *art;
- int exit_code; /* why we are exiting the loop */
-
- int ch, i, idx, hit, a_ct;
-
- this = head;
- top = head;
- exit_code = 0;
-
- ! show_threads(gp, &top, this, TRUE, head);
-
- while (exit_code == 0) {
-
- ***************
- *** 471,480 ****
- --- 606,621 ----
- switch (ch) {
-
- case 0 :
- + case 0xE0 :
- ch = getch();
-
- switch (ch) {
-
- + case F1 :
- + show_help(HELP_THREAD);
- + show_threads(gp, &top, this, TRUE, head);
- + break;
- +
- case UP_ARR :
- if (this->last != NULL) this = this->last;
- break;
- ***************
- *** 499,505 ****
-
- case HOME :
- top = this = head;
- ! show_threads(gp, &top, this, TRUE);
- break;
- case END :
- this = head;
- --- 640,646 ----
-
- case HOME :
- top = this = head;
- ! show_threads(gp, &top, this, TRUE, head);
- break;
- case END :
- this = head;
- ***************
- *** 510,527 ****
- break;
-
- case 's' :
- save_thread_to_disk(gp, this);
- break;
-
- case 'p' :
- ! strcpy(sub_tmp, "");
- ! post(NULL, gp->group, sub_tmp);
- ! show_threads(gp, &top, this, TRUE);
- break;
-
- - case '?' :
- case 'h' :
- show_help(HELP_THREAD);
- break;
-
- case TAB :
- --- 651,670 ----
- break;
-
- case 's' :
- + case 'S' :
- save_thread_to_disk(gp, this);
- break;
-
- case 'p' :
- ! case 'P' :
- ! post(NULL, gp->group);
- ! show_threads(gp, &top, this, TRUE, head);
- break;
-
- case 'h' :
- + case 'H' :
- show_help(HELP_THREAD);
- + show_threads(gp, &top, this, TRUE, head);
- break;
-
- case TAB :
- ***************
- *** 554,575 ****
- }
-
- if (hit) {
- ! this = th;
- read_thread(gp, this, art, a_ct);
- ! show_threads(gp, &top, this, TRUE);
- ! } else {
- ! message("-- No more articles to read --");
- }
- break;
-
- case 'c' :
- ! mark_group_as_read(gp);
- ! show_threads(gp, &top, this, TRUE);
- break;
-
- case ENTER :
- read_thread(gp, this, this->art_num, 1);
- ! show_threads(gp, &top, this, TRUE);
- break;
-
- case ESCAPE :
- --- 697,735 ----
- }
-
- if (hit) {
- ! if (this == th )
- read_thread(gp, this, art, a_ct);
- ! this = th;
- ! show_threads(gp, &top, this, TRUE, head);
- }
- break;
-
- case 'c' :
- ! case 'C' :
- ! mark_thread_as_read(gp, this);
- ! show_threads(gp, &top, this, TRUE, head);
- break;
-
- case ENTER :
- read_thread(gp, this, this->art_num, 1);
- ! show_threads(gp, &top, this, TRUE, head);
- ! break;
- !
- ! case BACKSP :
- ! art = this->art_num;
- ! a_ct = 1;
- ! while (art->next_art != NULL) {
- ! a_ct++;
- ! art = art->next_art;
- ! }
- ! read_thread(gp, this, art, a_ct);
- ! show_threads(gp, &top, this, TRUE, head);
- ! break;
- !
- ! case '+' :
- ! case '/' :
- ! this = search_thread(gp, this, ch == '/');
- ! show_threads(gp, &top, this, TRUE, head);
- break;
-
- case ESCAPE :
- ***************
- *** 577,583 ****
- break;
- };
- if (exit_code == 0)
- ! show_threads(gp, &top, this, FALSE);
- }
-
-
- --- 737,743 ----
- break;
- };
- if (exit_code == 0)
- ! show_threads(gp, &top, this, FALSE, head);
- }
-
-
- ***************
- *** 586,592 ****
-
-
-
- ! /*------------------------ read a thread ------------------------------*/
- void save_thread_to_disk(ACTIVE *gp, ARTICLE *this)
- {
- ART_ID *id;
- --- 746,761 ----
-
-
-
- ! /*------------------------ save a thread ------------------------------*/
- !
- ! int cmp(TEXT **art1, TEXT **art2)
- ! {
- ! char *subj1 = (*art1) -> subject, *subj2 = (*art2) -> subject;
- ! while (isspace(*subj1)) subj1++;
- ! while (isspace(*subj2)) subj2++;
- ! return strcmp(subj1, subj2);
- ! }
- !
- void save_thread_to_disk(ACTIVE *gp, ARTICLE *this)
- {
- ART_ID *id;
- ***************
- *** 593,607 ****
- char *fn;
- TEXT *tx;
- LINE *ln;
- ! int a_ct;
- ! char fnx[80];
- ! int ch;
- ! FILE *tmp;
-
- ! message("Enter filename? ");
- gets(fnx);
-
- - tmp = NULL;
- if (access(fnx, 0) == 0) {
-
- message("File exists - append(y/n)? ");
- --- 762,778 ----
- char *fn;
- TEXT *tx;
- LINE *ln;
- ! char fnx[256];
- ! int ch, art, idx;
- ! TEXT *text[MAXART];
- ! FILE *tmp = NULL;
- ! time_t now;
- ! struct tm *tmnow;
- ! char timestr[64];
-
- ! lmessage("Enter filename? ");
- gets(fnx);
-
- if (access(fnx, 0) == 0) {
-
- message("File exists - append(y/n)? ");
- ***************
- *** 608,615 ****
- while (((ch = getch()) != 'y') && (ch != 'n'));
- if (ch == 'y') {
- if ((tmp = fopen(fnx, "at")) == NULL) {
- ! message("*** Cannot open file for appending - "
- ! "please any key to continue ***");
- getch();
- }
- }
- --- 779,786 ----
- while (((ch = getch()) != 'y') && (ch != 'n'));
- if (ch == 'y') {
- if ((tmp = fopen(fnx, "at")) == NULL) {
- ! message("*** cannot open file for appending - "
- ! "please any key ***");
- getch();
- }
- }
- ***************
- *** 617,641 ****
- } else {
-
- if ((tmp = fopen(fnx, "wt")) == NULL) {
- ! message("*** Cannot open file for output - press a key to continue ***");
- getch();
- }
-
- }
-
- -
- -
- -
- if (tmp != NULL) {
-
- fn = make_news_group_name(gp->group);
-
- id = this->art_num;
- ! a_ct = 0;
-
- ! while (id != NULL) {
-
- ! tx = load_article(fn, id->art_off);
-
- ln = tx->top;
- while (ln != NULL) {
- --- 788,830 ----
- } else {
-
- if ((tmp = fopen(fnx, "wt")) == NULL) {
- ! message("*** cannot open file for output - press any key ***");
- getch();
- }
-
- + setvbuf(tmp, iobuf, _IOFBF, IOBUFSIZE);
- }
-
- if (tmp != NULL) {
-
- fn = make_news_group_name(gp->group);
-
- id = this->art_num;
- ! idx = 0;
-
- ! while (id != NULL && idx < MAXART) {
- ! text[idx++] = load_article(fn, id->art_off);
- ! id = id->next_art;
- ! }
-
- ! qsort(text, idx, sizeof(TEXT *), cmp);
- !
- ! time(&now);
- ! tmnow = localtime(&now);
- ! strftime(timestr, sizeof(timestr), "%a %b %d %H:%M:%S %z %Y", tmnow);
- !
- ! for ( art = 0; art < idx; art++ ) {
- !
- ! tx = text[art];
- !
- ! ln = tx->top;
- ! while (ln != NULL && strncmp(ln->data, "Path: ", 6)) {
- ! ln = ln->next;
- ! }
- ! strcpy(fn, ln->data + 6);
- ! for ( ch = strlen(fn); fn[ch - 1] == '\n' || fn[ch - 1] == '\r'; ch--)
- ! fn[ch - 1] = 0;
- ! fprintf(tmp, "From %s %s\n", fn, timestr);
-
- ln = tx->top;
- while (ln != NULL) {
- ***************
- *** 642,664 ****
- fputs(ln->data, tmp);
- ln = ln->next;
- }
- fputs("\n\n", tmp);
-
- ! a_ct++;
- ! id = id->next_art;
-
- free_article(tx);
-
- }
-
- ! fclose(tmp);
- }
-
- ! message("");
- }
-
-
- -
- /*------------------------ read a thread ------------------------------*/
- int read_thread(ACTIVE *gp, ARTICLE *this, ART_ID *first, int a_ct)
- {
- --- 831,898 ----
- fputs(ln->data, tmp);
- ln = ln->next;
- }
- +
- fputs("\n\n", tmp);
- + free_article(tx);
- + }
-
- ! fclose(tmp);
- ! }
- ! }
- !
- !
-
- + /*------------------------ search through articles --------------------*/
- + int search_message(char *fn, ART_ID *current, int forward)
- + {
- + int offset = 0, found = FALSE;
- + TEXT *tx;
- + LINE *text;
- + char prompt[128], pattern[128];
- +
- + sprintf(prompt, "Search %s for? [%s] ",
- + forward ? "forward" : "backward", search_text);
- + lmessage(prompt);
- + if (gets(pattern) == NULL)
- + return 0;
- +
- + if (strlen(pattern) > 0)
- + strcpy(search_text, pattern);
- + else
- + strcpy(pattern, search_text);
- +
- + strlwr(pattern);
- +
- + for (;;) {
- +
- + current = forward ? current->next_art : current->last_art;
- + if (current == NULL)
- + break;
- +
- + offset++;
- + tx = load_article(fn, current->art_off);
- +
- + for (text = tx->start; !found && text != NULL; text = text->next) {
- + strlwr(text->data);
- + found = (strstr(text->data, pattern) != NULL);
- + }
- +
- free_article(tx);
-
- + if (found)
- + break;
- }
-
- ! if (!found) {
- ! sprintf(prompt, "*** '%s' not found - press any key ***", pattern);
- ! message(prompt);
- ! getch();
- }
-
- ! return found ? offset : 0;
- }
-
-
- /*------------------------ read a thread ------------------------------*/
- int read_thread(ACTIVE *gp, ARTICLE *this, ART_ID *first, int a_ct)
- {
- ***************
- *** 679,689 ****
-
- tx = load_article(fn, id->art_off);
-
- ! res = read_article(gp, tx, this->header, a_ct, this->num_articles);
-
- /* mark this article as read */
- idx = (int) ((id->id) - gp->lo_num - 1);
- ! *((gp->read_list)+idx) = TRUE;
-
- /* mark the crossposts */
- get_his_stuff(tx, author, msg_id);
- --- 913,923 ----
-
- tx = load_article(fn, id->art_off);
-
- ! res = read_article(gp, tx, a_ct, this->num_articles);
-
- /* mark this article as read */
- idx = (int) ((id->id) - gp->lo_num - 1);
- ! (gp->read_list)[idx] = TRUE;
-
- /* mark the crossposts */
- get_his_stuff(tx, author, msg_id);
- ***************
- *** 693,699 ****
- while (h != NULL) {
- gx = find_news_group(h->group);
- idx = (int) ((h->art_num) - gx->lo_num - 1);
- ! *((gx->read_list)+idx) = TRUE;
- h = h->next;
- }
-
- --- 927,934 ----
- while (h != NULL) {
- gx = find_news_group(h->group);
- idx = (int) ((h->art_num) - gx->lo_num - 1);
- ! if ( 0 <= idx && idx < gx->hi_num )
- ! (gx->read_list)[idx] = TRUE;
- h = h->next;
- }
-
- ***************
- *** 700,705 ****
- --- 935,942 ----
- free_cross_post_list(h0);
- }
-
- + free_article(tx);
- +
- if (res == EX_QUIT) break;
-
- if (res == EX_NEXT_UNREAD) {
- ***************
- *** 713,728 ****
- id = id->next_art;
- }
-
- ! if (id == NULL)
- ! message("-- No more articles in thread --");
- !
- } else {
- a_ct++;
- id = id->next_art;
- }
- -
- - free_article(tx);
- -
- }
-
- return(res);
- --- 950,974 ----
- id = id->next_art;
- }
-
- ! } else if (res == EX_SEARCH_FORW) {
- ! res = search_message(fn, id, 1);
- ! while (res--) {
- ! a_ct++;
- ! id = id->next_art;
- ! }
- ! } else if (res == EX_SEARCH_BACKW) {
- ! res = search_message(fn, id, 0);
- ! while (res--) {
- ! a_ct--;
- ! id = id->last_art;
- ! }
- ! } else if (res == EX_PREVIOUS) {
- ! a_ct--;
- ! id = id->last_art;
- } else {
- a_ct++;
- id = id->next_art;
- }
- }
-
- return(res);
- ***************
- *** 732,737 ****
- --- 978,1114 ----
-
-
- /*------------------------- read the headers --------------------------*/
- +
- + int strip_off_part(char *str)
- + {
- + char *ptr = str + strlen(str);
- +
- + /* strip off (case-insensitive) things like:
- + - "Part01/10"
- + - "Part 01/10"
- + - "Part 01 of 10"
- + - "[1/10]"
- + - "(1 of 10)"
- + - "1 of 10"
- + - "Patch02a/04"
- + - "Patch20"
- + */
- +
- + while ( ptr > str && ptr[-1] == ' ' )
- + ptr--;
- +
- + if ( ptr > str && (ptr[-1] == ')' || ptr[-1] == ']') )
- + ptr--;
- +
- + while ( ptr > str && isdigit(ptr[-1]) )
- + ptr--;
- +
- + if ( !isdigit(*ptr) )
- + return 0;
- +
- + if ( ptr > str && ptr[-1] == '/' )
- + ptr--;
- + else if ( ptr > str + 3 && strnicmp(ptr - 4, " of ", 4) == 0 )
- + ptr -= 4;
- + else if ( ptr > str + 4 && strnicmp(ptr - 5, "Patch", 5) == 0 )
- + {
- + ptr -= 5;
- + goto label;
- + }
- + else if ( ptr > str + 5 && strnicmp(ptr - 6, "Patch ", 6) == 0 )
- + {
- + ptr -= 6;
- + goto label;
- + }
- + else
- + return 0;
- +
- + if ( ptr > str && 'a' <= ptr[-1] && ptr[-1] <= 'z' )
- + ptr--;
- +
- + while ( ptr > str && isdigit(ptr[-1]) )
- + ptr--;
- +
- + if ( !isdigit(*ptr) )
- + return 0;
- +
- + if ( ptr > str && (ptr[-1] == '(' || ptr[-1] == '[') )
- + ptr--;
- +
- + while ( ptr > str && ptr[-1] == ' ' )
- + ptr--;
- +
- + if ( ptr > str + 3 && strnicmp(ptr - 4, "Part", 4) == 0 )
- + ptr -= 4;
- +
- + label:
- + while ( ptr > str && ptr[-1] == ' ' )
- + ptr--;
- +
- + if ( ptr > str && ptr[-1] == ',' )
- + ptr--;
- + else if ( ptr > str && ptr[-1] == ':' )
- + ptr--;
- +
- + *ptr = 0;
- + return 1;
- + }
- +
- + char *skip_vi(char *str)
- + {
- + char *ptr = str;
- +
- + /* skip things like "v02i0027: " */
- +
- + while ( isspace(*ptr) )
- + ptr++;
- +
- + if ( *ptr++ != 'v' )
- + return str;
- +
- + if ( !isdigit(*ptr) )
- + return str;
- +
- + while ( isdigit(*ptr) )
- + ptr++;
- +
- + if ( *ptr++ != 'i' )
- + return str;
- +
- + if ( !isdigit(*ptr) )
- + return str;
- +
- + while ( isdigit(*ptr) )
- + ptr++;
- +
- + if ( *ptr++ != ':' )
- + return str;
- +
- + if ( *ptr++ != ' ' )
- + return str;
- +
- + while ( isspace(*ptr) )
- + ptr++;
- +
- + return ptr;
- + }
- +
- + int smartcmp(char *str1, char *str2)
- + {
- + char s1[256], s2[256];
- +
- + strcpy(s1, str1);
- + strcpy(s2, str2);
- +
- + if ( strip_off_part(s1) && strip_off_part(s2) )
- + {
- + str1 = skip_vi(s1);
- + str2 = skip_vi(s2);
- + }
- +
- + return stricmp(str1, str2);
- + }
- +
- ARTICLE *get_headers(ACTIVE *gp)
- {
- /*
- ***************
- *** 739,751 ****
- */
-
- char *fn;
- ! char buf[256], fnx[256], *buf_p;
- long g, n_read;
- FILE *tmp_file;
-
- ARTICLE *start, *that, *tmp;
- ART_ID *art_this, *new;
- ! int ct_art;
-
- n_read = 0;
- ct_art = 0;
- --- 1116,1129 ----
- */
-
- char *fn;
- ! char buf[MAXLINE], fnx[256], *buf_p;
- long g, n_read;
- FILE *tmp_file;
-
- ARTICLE *start, *that, *tmp;
- + ARTICLE **ptr;
- ART_ID *art_this, *new;
- ! int ct_art, cmp;
-
- n_read = 0;
- ct_art = 0;
- ***************
- *** 754,766 ****
- fn = make_news_group_name(gp->group);
- sprintf(fnx, "%s.IDX", fn);
-
- ! if ((tmp_file = fopen(fnx, "rb")) != NULL) {
-
- for (g = gp->lo_num+1; g <= gp->hi_num; g++) {
-
- ! if ((n_read++ %10) == 0) {
- ! gotoxy(1,25);
- printf("%d articles processed", n_read-1);
- }
-
- /*
- --- 1132,1150 ----
- fn = make_news_group_name(gp->group);
- sprintf(fnx, "%s.IDX", fn);
-
- ! if ((tmp_file = flockopen(fnx, "rb")) != NULL) {
-
- + setvbuf(tmp_file, iobuf, _IOFBF, IOBUFSIZE);
- +
- for (g = gp->lo_num+1; g <= gp->hi_num; g++) {
-
- ! if ((n_read++ % 100) == 0) {
- ! gotoxy(1,PAGE_SIZE);
- ! textbackground(LIGHTGRAY); textcolor(BLACK);
- printf("%d articles processed", n_read-1);
- + clreol();
- + textbackground(BLACK); textcolor(LIGHTGRAY);
- + tflush();
- }
-
- /*
- ***************
- *** 770,777 ****
- * - add to the existing list
- */
-
- ! if (fgets(buf, 255, tmp_file) == NULL) {
- ! gotoxy(1,25);
- fprintf(stderr, "\nsnews: index file is corrupt\n");
- exit(1);
- }
- --- 1154,1161 ----
- * - add to the existing list
- */
-
- ! if (fgets(buf, sizeof(buf), tmp_file) == NULL) {
- ! gotoxy(1,PAGE_SIZE);
- fprintf(stderr, "\nsnews: index file is corrupt\n");
- exit(1);
- }
- ***************
- *** 778,784 ****
-
- /* check all is in sync */
- if (g != atol(buf+9)) {
- ! gotoxy(1,25);
- fprintf(stderr, "\nsnews: article %ld found when %ld"
- "expected\n", atol(buf+9), g);
- exit(1);
- --- 1162,1168 ----
-
- /* check all is in sync */
- if (g != atol(buf+9)) {
- ! gotoxy(1,PAGE_SIZE);
- fprintf(stderr, "\nsnews: article %ld found when %ld"
- "expected\n", atol(buf+9), g);
- exit(1);
- ***************
- *** 786,808 ****
-
- /* skip the two eight digit numbers and the 9 and the spaces */
- buf_p = buf+28;
- -
- eat_gunk(buf_p);
- ! tmp = start;
- ! while (tmp != NULL) {
- ! if (stricmp(buf_p, tmp->header) == 0)
- break;
- - tmp = tmp->next;
- }
- !
- ! if (tmp != NULL) {
-
- /* allocate new article number */
- new = xmalloc(sizeof (ART_ID));
- new->id = g;
- new->art_off = atol(buf);
- - new->next_art = NULL;
- - tmp->num_articles++;
-
- /* place it at the end */
- art_this = tmp->art_num;
- --- 1170,1207 ----
-
- /* skip the two eight digit numbers and the 9 and the spaces */
- buf_p = buf+28;
- eat_gunk(buf_p);
- !
- ! for ( tmp = start; tmp != NULL; ) {
- !
- ! cmp = smartcmp(buf_p, tmp->header);
- !
- ! if (cmp > 0) {
- ! if (tmp->left)
- ! tmp = tmp->left;
- ! else {
- ! ptr = &(tmp->left);
- ! tmp = NULL;
- break;
- }
- ! }
- ! else if (cmp < 0) {
- ! if (tmp->right)
- ! tmp = tmp->right;
- ! else {
- ! ptr = &(tmp->right);
- ! tmp = NULL;
- ! break;
- ! }
- ! }
- ! else {
- ! /* found this subject */
- ! tmp->num_articles++;
-
- /* allocate new article number */
- new = xmalloc(sizeof (ART_ID));
- new->id = g;
- new->art_off = atol(buf);
-
- /* place it at the end */
- art_this = tmp->art_num;
- ***************
- *** 809,858 ****
- while (art_this->next_art != NULL) {
- art_this = art_this->next_art;
- }
- -
- art_this->next_art = new;
-
- ! } else {
-
- /* not found - allocate new thread */
- if (start == NULL) {
- ! start = that = xmalloc(sizeof (ARTICLE));
- ! start->last = NULL;
- ! start->next = NULL;
- ! start->index = ct_art;
- } else {
- ct_art++;
- that->next = xmalloc(sizeof (ARTICLE));
- that->next->last = that;
- that = that->next;
- that->next = NULL;
- that->index = ct_art;
- ! }
-
- /* store article data */
- strcpy(that->header, buf_p);
- that->num_articles = 1;
- that->art_num = xmalloc(sizeof (ART_ID));
- that->art_num->next_art = NULL;
- that->art_num->id = g;
- that->art_num->art_off = atol(buf);
-
- }
- -
- - that->next = NULL;
- -
- }
-
- fclose(tmp_file);
-
- } else {
- ! gotoxy(1,25);
- fprintf(stderr, "\nsnews: can't open index file %s\n", fnx);
- exit(1);
- }
-
- ! return(start);
-
- }
-
-
- --- 1208,1267 ----
- while (art_this->next_art != NULL) {
- art_this = art_this->next_art;
- }
- art_this->next_art = new;
-
- ! new->last_art = art_this;
- ! new->next_art = NULL;
- !
- ! break;
- ! }
-
- + }
- +
- + if (tmp == NULL) {
- /* not found - allocate new thread */
- +
- if (start == NULL) {
- ! start = xmalloc(sizeof (ARTICLE));
- ! that = start;
- ! that->last = NULL;
- } else {
- ct_art++;
- that->next = xmalloc(sizeof (ARTICLE));
- that->next->last = that;
- that = that->next;
- + *ptr = that;
- + }
- +
- that->next = NULL;
- that->index = ct_art;
- ! that->left = that->right = NULL;
-
- /* store article data */
- + that->header = xmalloc(strlen(buf_p) + 1);
- strcpy(that->header, buf_p);
- that->num_articles = 1;
- +
- that->art_num = xmalloc(sizeof (ART_ID));
- + that->art_num->last_art = NULL;
- that->art_num->next_art = NULL;
- that->art_num->id = g;
- that->art_num->art_off = atol(buf);
-
- }
- }
-
- fclose(tmp_file);
-
- } else {
- ! gotoxy(1,PAGE_SIZE);
- fprintf(stderr, "\nsnews: can't open index file %s\n", fnx);
- exit(1);
- }
-
- ! gp->threads = ct_art + 1;
-
- + return(start);
- }
-
-
- ***************
- *** 862,877 ****
- {
- /*
- * This routine take the header line, and strips the
- ! * word header word, 'Re:', and any extra blanks, trim to 59 chars
- */
-
- ! char *p, tmp[256];
- !
- ! buf[58] = 0;
-
- -
- /* strip the Subject: etc off the front */
- ! while ((strstr(buf, "Re:") != NULL) ||
- (strnicmp(buf, "From:", 5) == 0) ||
- (strnicmp(buf, "Path:", 5) == 0) ||
- (strnicmp(buf, "Subject:", 8) == 0) ||
- --- 1271,1283 ----
- {
- /*
- * This routine take the header line, and strips the
- ! * word header word, 'Re:', and any extra blanks
- */
-
- ! char *p, tmp[MAXLINE];
-
- /* strip the Subject: etc off the front */
- ! while ( /*(strstr(buf, "Re:") != NULL) ||*/
- (strnicmp(buf, "From:", 5) == 0) ||
- (strnicmp(buf, "Path:", 5) == 0) ||
- (strnicmp(buf, "Subject:", 8) == 0) ||
- ***************
- *** 878,884 ****
- (strnicmp(buf, "Organization:", 13) == 0) ||
- (strnicmp(buf, "Organisation:", 13) == 0) ||
- (strnicmp(buf, "Followup-To:", 12) == 0)) {
- ! p = strstr(buf, ":");
- strcpy(buf, p+1);
- }
-
- --- 1284,1290 ----
- (strnicmp(buf, "Organization:", 13) == 0) ||
- (strnicmp(buf, "Organisation:", 13) == 0) ||
- (strnicmp(buf, "Followup-To:", 12) == 0)) {
- ! p = strchr(buf, ':');
- strcpy(buf, p+1);
- }
-
- ***************
- *** 925,930 ****
- --- 1331,1337 ----
- }
-
- t = a->next;
- + free(a->header);
- free(a);
- a = t;
- }
- ***************
- *** 970,975 ****
- --- 1377,1383 ----
- ct = 0;
- articles = (int)(gp->hi_num - gp->lo_num);
-
- + if (gp->read_list)
- for (i = 0; i < articles; i++) {
- if (*((gp->read_list)+i) == FALSE)
- ct++;
- ***************
- *** 980,986 ****
-
-
-
- ! /*------------------- count unread articles in a group --------------------*/
- void mark_group_as_read(ACTIVE *gp)
- {
- /*
- --- 1388,1394 ----
-
-
-
- ! /*------------------- mark articles as read ---------------------------------*/
- void mark_group_as_read(ACTIVE *gp)
- {
- /*
- ***************
- *** 990,996 ****
-
- int articles, i, ch;
-
- ! message("Mark all articles as read (y/n)? ");
- while (((ch = getch()) != 'y') && (ch != 'n') && (ch != ESCAPE));
-
- if (ch == 'y') {
- --- 1398,1404 ----
-
- int articles, i, ch;
-
- ! message("Mark all articles in this group as read (y/n)? ");
- while (((ch = getch()) != 'y') && (ch != 'n') && (ch != ESCAPE));
-
- if (ch == 'y') {
- ***************
- *** 1005,1050 ****
- }
-
-
- !
- ! /*-------------------------- status message ---------------------------------*/
- ! void message(char *msg)
- {
- ! int x;
-
- ! x = 40 - (strlen(msg)/2);
-
- ! gotoxy(1,24);
- ! textbackground(LIGHTGRAY); textcolor(BLACK);
- ! clreol();
- ! gotoxy(x,24);
- ! cprintf("%s", msg);
- ! textbackground(BLACK); textcolor(LIGHTGRAY);
- }
-
-
- /*-------------------------- status message ---------------------------------*/
- ! void lmessage(char *msg)
- {
- ! gotoxy(1,24);
- textbackground(LIGHTGRAY); textcolor(BLACK);
- clreol();
- - cprintf("%s", msg);
- textbackground(BLACK); textcolor(LIGHTGRAY);
- }
-
-
- /*-------------------------- status message ---------------------------------*/
- ! void command(char *msg)
- {
- ! int x;
- !
- ! x = 40 - (strlen(msg)/2);
- ! gotoxy(1,25);
- textbackground(LIGHTGRAY); textcolor(BLACK);
- clreol();
- -
- - gotoxy(x,25);
- - cprintf(msg);
- -
- textbackground(BLACK); textcolor(LIGHTGRAY);
- }
- --- 1413,1465 ----
- }
-
-
- ! void mark_thread_as_read(ACTIVE *gp, ARTICLE *a)
- {
- ! /*
- ! * Take the thread 'a' for the given group 'gp' and return the number
- ! * of unread articles
- ! */
-
- ! ART_ID *id;
- ! int idx, ch;
-
- ! message("Mark all articles in this thread as read (y/n)? ");
- ! while (((ch = getch()) != 'y') && (ch != 'n') && (ch != ESCAPE));
- !
- ! if (ch == 'y') {
- !
- ! id = a->art_num;
- !
- ! while (id != NULL) {
- ! idx = (int)(id->id - gp->lo_num - 1);
- ! *((gp->read_list)+idx) = TRUE;
- ! id = id->next_art;
- ! }
- ! }
- !
- }
-
-
- /*-------------------------- status message ---------------------------------*/
- ! void message(char *msg)
- {
- ! int x;
- !
- ! x = _columns / 2 - (strlen(msg)/2);
- ! gotoxy(1,PAGE_SIZE);
- textbackground(LIGHTGRAY); textcolor(BLACK);
- + printf("%*s%s", x, "", msg);
- clreol();
- textbackground(BLACK); textcolor(LIGHTGRAY);
- }
-
-
- /*-------------------------- status message ---------------------------------*/
- ! void lmessage(char *msg)
- {
- ! gotoxy(1,PAGE_SIZE);
- textbackground(LIGHTGRAY); textcolor(BLACK);
- + printf("%s", msg);
- clreol();
- textbackground(BLACK); textcolor(LIGHTGRAY);
- }
- Only in new: snews.def
- diff -cb orig/snews.doc new/snews.doc
- *** orig/snews.doc Fri Nov 08 06:50:18 1991
- --- new/snews.doc Sun Aug 02 18:28:08 1992
- ***************
- *** 1,4 ****
- --- 1,7 ----
- + NOTE: This documentation is somewhat out of date. Read README.OS2 for
- + changes in the OS/2 (SNEWS /2) releases.
-
- + -----------
- Simple NEWS 1.0
- ===============
-
- diff -cb orig/snews.h new/snews.h
- *** orig/snews.h Thu Jun 11 22:48:16 1992
- --- new/snews.h Sun Aug 02 20:34:18 1992
- ***************
- *** 1,5 ****
- /*
- ! SNEWS 1.0
-
- Private decls the SNEWS news reader
-
- --- 1,5 ----
- /*
- ! SNEWS 2.0
-
- Private decls the SNEWS news reader
-
- ***************
- *** 22,41 ****
-
- */
-
- - #include <alloc.h>
- - #include <process.h>
- - #include <io.h>
-
- !
- ! /* #define INCLUDE_SIG */ /* enable this to have the reply function put */
- /* your sig on the reply - mail ususally does */
- /* this */
-
- !
-
- #define ENTER 0x0D
- #define ESCAPE 0x1B
- #define TAB 0x09
-
- #define EX_DONE 1
- #define EX_QUIT 2
- --- 22,39 ----
-
- */
-
-
- ! #define INCLUDE_SIG /* enable this to have the reply function put */
- /* your sig on the reply - mail ususally does */
- /* this */
-
- ! #define MAXLINE 1024
- ! #define MAXART 256
-
- #define ENTER 0x0D
- #define ESCAPE 0x1B
- #define TAB 0x09
- + #define BACKSP 0x08
-
- #define EX_DONE 1
- #define EX_QUIT 2
- ***************
- *** 44,56 ****
- #define EX_NEXT_UNREAD 5
- #define EX_ROT13 6
- #define EX_DUMMY 7
-
- - #define TEXT_LINE 5
-
-
- ! #define PAGE_HEADER 4
- ! #define PAGE_LENGTH 19
-
- /* if you change these see show_help */
- #define HELP_GROUP 0
- #define HELP_THREAD 1
- --- 42,60 ----
- #define EX_NEXT_UNREAD 5
- #define EX_ROT13 6
- #define EX_DUMMY 7
- + #define EX_PREVIOUS 8
- + #define EX_SEARCH_FORW 9
- + #define EX_SEARCH_BACKW 10
-
-
- + /* screen size */
- + #define TEXT_LINE 4
- + #define PAGE_HEADER 3
-
- ! #define PAGE_LENGTH (_lines - 4)
- ! #define PAGE_SIZE _lines
-
- +
- /* if you change these see show_help */
- #define HELP_GROUP 0
- #define HELP_THREAD 1
- ***************
- *** 58,67 ****
- --- 62,76 ----
-
- #define UP_ARR 'H'
- #define DN_ARR 'P'
- + #define L_ARR 'K'
- + #define R_ARR 'M'
- + #define C_L_ARR 's'
- + #define C_R_ARR 't'
- #define PGUP 'I'
- #define PGDN 'Q'
- #define HOME 'G'
- #define END 'O'
- + #define F1 ';'
-
-
-
- ***************
- *** 72,79 ****
- --- 81,90 ----
- long id; /* article number */
- long art_off; /* offset of the article */
- struct art_id *next_art; /* pointer to next article number */
- + struct art_id *last_art; /* pointer to previous article number */
- } ART_ID;
-
- +
- /*
- * This structure is a doubly linked list of the unique article headers. The
- * linked list of article numbers is built on 'art_num'. This system
- ***************
- *** 82,139 ****
- * But hey, it's simple
- */
- typedef struct article {
- ! char header[60]; /* article header */
- int num_articles; /* number with this header */
- ART_ID *art_num; /* pointer to list of articles */
- struct article *next; /* next topic */
- struct article *last; /* last topic */
- int index; /* topic number from start */
- } ARTICLE;
-
-
- -
- -
- -
- /*
- - * This structure is a linked list of lines that make up an article. The
- - * file is read in and the linked list is built
- - */
- - typedef struct line {
- - char data[80]; /* line of text */
- - struct line *next; /* next line */
- - struct line *last; /* last line */
- - int index; /* line number from start */
- - } LINE;
- -
- -
- - /*
- * This structure is the handle for an article in ram. The file
- * is read in and the linked list built.
- */
- - #define WHO_LENGTH 35
- typedef struct {
- ! char author[WHO_LENGTH]; /* truncated author */
- ! char organisation[WHO_LENGTH]; /* truncated organisation */
- ! char follow_up[80]; /* group for follow-up article */
- ! int lines; /* total lines in file */
- LINE *top; /* points to start of article, incl header */
- ! LINE *start; /* ponts to start of text */
- } TEXT;
-
-
- -
- -
- -
- ACTIVE *select_group(ACTIVE *head, ACTIVE *current);
- void show_help(int h);
- int read_group(ACTIVE *gp);
- ! void show_groups(ACTIVE **top, ACTIVE *this, int force);
- ARTICLE *get_headers(ACTIVE *gp);
- void eat_gunk(char *buf);
- void free_header(ARTICLE *start);
-
-
- ! void show_threads(ACTIVE *gp, ARTICLE **top, ARTICLE *this, int force);
- void select_thread(ACTIVE *gp, ARTICLE *head);
- int read_thread(ACTIVE *gp, ARTICLE *this, ART_ID *first, int a_ct);
-
- --- 93,135 ----
- * But hey, it's simple
- */
- typedef struct article {
- ! char *header; /* article header */
- int num_articles; /* number with this header */
- ART_ID *art_num; /* pointer to list of articles */
- struct article *next; /* next topic */
- struct article *last; /* last topic */
- int index; /* topic number from start */
- + struct article *left; /* for tree structure */
- + struct article *right;
- } ARTICLE;
-
-
- /*
- * This structure is the handle for an article in ram. The file
- * is read in and the linked list built.
- */
- typedef struct {
- ! char *subject; /* header */
- ! char *author; /* author */
- ! char *organisation; /* organisation */
- ! char *follow_up; /* group for follow-up article */
- ! int lines; /* total lines in article */
- ! int startline; /* first text line in article */
- LINE *top; /* points to start of article, incl header */
- ! LINE *start; /* points to start of text */
- } TEXT;
-
-
- ACTIVE *select_group(ACTIVE *head, ACTIVE *current);
- void show_help(int h);
- int read_group(ACTIVE *gp);
- ! void show_groups(ACTIVE **top, ACTIVE *this, int force, ACTIVE *head);
- ARTICLE *get_headers(ACTIVE *gp);
- void eat_gunk(char *buf);
- void free_header(ARTICLE *start);
-
-
- ! void show_threads(ACTIVE *gp, ARTICLE **top, ARTICLE *this, int force, ARTICLE *head);
- void select_thread(ACTIVE *gp, ARTICLE *head);
- int read_thread(ACTIVE *gp, ARTICLE *this, ART_ID *first, int a_ct);
-
- ***************
- *** 140,145 ****
- --- 136,142 ----
- int count_unread_in_thread(ACTIVE *gp, ARTICLE *a);
- int count_unread_in_group(ACTIVE *gp);
- void mark_group_as_read(ACTIVE *gp);
- + void mark_thread_as_read(ACTIVE *gp, ARTICLE *a);
-
- void command(char *msg);
- void message(char *msg);
- ***************
- *** 149,165 ****
- void free_article(TEXT *t);
-
-
- ! int read_article(ACTIVE *gp, TEXT *tx, char *subject, int a_ct, int of_ct);
- ! void show_article(ACTIVE *gp, TEXT *tx, char *subject, LINE *this, int a_ct,
- ! int of_ct);
-
-
- void save_to_disk(TEXT *tx);
- ! void reply_to_article(TEXT *tx, char *subject);
- void get_his_stuff(TEXT *tx, char *author, char *msg_id);
-
-
- ! void post(TEXT *tx, char *newsgroups, char *subject);
- void post_it(FILE *article, char *newsgroups, char *subject, char *dist,
- char *msg_id);
-
- --- 146,162 ----
- void free_article(TEXT *t);
-
-
- ! int read_article(ACTIVE *gp, TEXT *tx, int a_ct, int of_ct);
- ! void show_article(ACTIVE *gp, TEXT *tx, LINE *this, int a_ct,
- ! int of_ct, int margin);
-
-
- void save_to_disk(TEXT *tx);
- ! void reply_to_article(TEXT *tx);
- void get_his_stuff(TEXT *tx, char *author, char *msg_id);
-
-
- ! void post(TEXT *tx, char *newsgroups);
- void post_it(FILE *article, char *newsgroups, char *subject, char *dist,
- char *msg_id);
-
- Only in new: termcap.c
- Only in new: termcap.dat
- Only in new: termcap.h
- diff -cb orig/unbatch.c new/unbatch.c
- *** orig/unbatch.c Thu Jun 11 22:48:16 1992
- --- new/unbatch.c Sun Aug 02 20:34:18 1992
- ***************
- *** 1,5 ****
- /*
- ! SNEWS 1.0
-
- unbatch - quick and dirty news toss, no feeding of other sites
-
- --- 1,5 ----
- /*
- ! SNEWS 2.0
-
- unbatch - quick and dirty news toss, no feeding of other sites
-
- ***************
- *** 35,42 ****
- --- 35,47 ----
- unsigned _stklen = 16384;
-
- INFO my_stuff;
- + char iobuf[IOBUFSIZE];
-
- + #ifdef system
- + #undef system
- + #endif
-
- +
- /*------------------------------- main --------------------------------*/
- void main(int argc, char *argv[])
- {
- ***************
- *** 70,88 ****
- printf("unbatch: processing %s\n", name);
-
- /*
- ! * Check for enough room. We need:
- ! *
- ! * - more than twice the size of the batch for uncompressed
- ! * batch, say 2.8
- ! *
- ! * - space for the articles.
- ! *
- ! * For example a 100k batch may require 280kb for the uncompressed
- ! * batch, then another 280 kb for the articles.
- */
- stat(name, &st);
-
- ! required_disk = (st.st_size*2.8) * 2;
-
- drive = getdisk();
- getdfree(drive+1, &df);
- --- 75,94 ----
- printf("unbatch: processing %s\n", name);
-
- /*
- ! Check for enough room. First, the batch in copied without
- ! the header. Thus, the same space is needed again. Then,
- ! the copied batch is uncompressed and read in over a pipe
- ! which doesn't need extra space. Only space for the
- ! articles is needed, slightly more than the uncompressed
- ! size of the batch, say 3 times as much. We need a total
- ! space of about four times the size of the original batch.
- ! And this is only if no different device is used for the
- ! temp files.
- */
- +
- stat(name, &st);
-
- ! required_disk = st.st_size * 4L;
-
- drive = getdisk();
- getdfree(drive+1, &df);
- ***************
- *** 93,112 ****
- exit(1);
- }
-
-
- - /* uncompress the news batch and return a pointer to the temp file */
- - if ((tmp_file = decode_batches(name, no_toss)) != NULL) {
- -
- open_hist_file();
- toss(tmp_file);
- close_hist_file();
- fclose(tmp_file);
-
- unlink(name);
- - sprintf(name, "%s", my_stuff.temp_name);
- - unlink(name);
-
- ! } else {
- printf("could not unpack compressed news batch %s\n", name);
- exit(1);
- }
- --- 99,121 ----
- exit(1);
- }
-
- + /* uncompress the news batch and return a pointer to the pipe */
- + if ((tmp_file = decode_batch(name, in_name, no_toss)) != NULL) {
-
- open_hist_file();
- toss(tmp_file);
- close_hist_file();
- +
- + if (in_name[0]) {
- + pclose(tmp_file);
- + unlink(in_name);
- + }
- + else
- fclose(tmp_file);
-
- unlink(name);
-
- ! } else if (!no_toss) {
- printf("could not unpack compressed news batch %s\n", name);
- exit(1);
- }
- ***************
- *** 119,206 ****
- }
-
-
- -
- -
- -
- -
- -
- /*--------------------------- unpack the batch ------------------------*/
- ! void toss(FILE *tmp_file)
- {
- /*
- ! * Toss it into the appropriate files.
- ! *
- ! * TODO:
- ! * - badly structured, sort it out
- */
- !
- FILE *out_file = NULL;
- ! FILE *spool_file = NULL;
- ! char buf[512], msg[256], subject[256], msg_id[256], *p;
- ! char newsgroups[256], nglist[256];
- ! long where;
- ACTIVE *gp;
- time_t t;
- ! int already_junked, in_header;
- !
- ! strcpy(msg_id, "");
- ! strcpy(subject, "-- no subject --\n");
- ! strcpy(newsgroups, "");
-
- - rewind(tmp_file);
- time(&t);
- ! in_header = TRUE;
- !
- ! /* read the file */
- ! while (fgets(buf, 511, tmp_file) != NULL) {
- !
- ! if (strstr(buf, "#! rnews") != NULL) {
-
- - if (strlen(newsgroups) != 0) {
- - strcpy(nglist, newsgroups+11);
- p = strtok(newsgroups, " \r\n,:");
- p = strtok(NULL, " \r\n,:");
-
- ! /*
- ! * For each newsgroup
- ! * - open the text file
- ! * - save the file pointer
- ! * - append the message to it
- ! * - close the file
- ! * - open the index file
- ! * - save the file pointer and the subject line
- ! */
-
- ! while (p != '\x00') {
-
- ! out_file = open_out_file(p);
-
- where = ftell(out_file);
- ! rewind(spool_file);
- ! while (fgets(buf, 511, spool_file) != NULL)
- ! fputs(buf, out_file);
- fprintf(out_file, "\n@@@@END\n");
- fclose(out_file);
-
- ! out_file = open_index_file(p);
- ! gp = find_news_group(p);
- fprintf(out_file,"%08ld %08ld %09ld %s", where,
- gp->hi_num, t, subject);
- fclose(out_file);
-
- ! p = strtok(NULL, " \r\n,:");
- }
- ! add_hist_record(msg_id, nglist);
- ! fclose(spool_file);
- }
-
- strcpy(subject, "-- no subject --\n");
- in_header = TRUE;
-
- ! if ((spool_file = fopen("$$item", "w+b")) == NULL) {
- ! fprintf(stderr, "can't open temp article file %s\n", "$$item");
- ! exit(1);
- ! }
-
- } else {
- /* flag the end of the header */
- --- 128,235 ----
- }
-
-
- /*--------------------------- unpack the batch ------------------------*/
- ! void save_message(LINE *spool, char *newsgroups,
- ! char *subject, char *msg_id)
- {
- /*
- ! * For each newsgroup
- ! * - open the text file
- ! * - save the file pointer
- ! * - append the message to it
- ! * - close the file
- ! * - open the index file
- ! * - save the file pointer and the subject line
- */
- ! char buf[512], nglist[256], *group, *p;
- FILE *out_file = NULL;
- ! LINE *help;
- ACTIVE *gp;
- + long where;
- time_t t;
- ! int saved = FALSE;
-
- time(&t);
- ! nglist[0] = 0;
-
- p = strtok(newsgroups, " \r\n,:");
- p = strtok(NULL, " \r\n,:");
-
- ! while (p != NULL) {
-
- ! group = p;
- ! p = strtok(NULL, " \r\n,:");
-
- ! gp = find_news_group(group);
- ! if (stricmp(gp->group, "junk") == 0 && (p != NULL || saved))
- ! continue;
-
- + out_file = open_out_file(group);
- where = ftell(out_file);
- ! help = spool;
- !
- ! setvbuf(out_file, iobuf, _IOFBF, IOBUFSIZE);
- !
- ! for (help = spool; help != NULL; help = help->next)
- ! fputs(help->data, out_file);
- !
- fprintf(out_file, "\n@@@@END\n");
- fclose(out_file);
-
- ! out_file = open_index_file(group);
- fprintf(out_file,"%08ld %08ld %09ld %s", where,
- gp->hi_num, t, subject);
- fclose(out_file);
-
- ! saved = TRUE;
- ! if ( nglist[0] )
- ! strcat(nglist, ",");
- ! strcat(nglist, group);
- }
- !
- ! while (spool) {
- ! help = spool;
- ! spool = spool->next;
- ! free(help->data);
- ! free(help);
- }
-
- + add_hist_record(msg_id, nglist);
- + }
- +
- + void toss(FILE *tmp_file)
- + {
- + /*
- + * Toss it into the appropriate files.
- + */
- + LINE *spool = NULL, *help;
- + char buf[512], buf2[512], *p;
- + char newsgroups[256], subject[256], msg_id[256];
- + int in_header, control;
- +
- + strcpy(msg_id, "");
- strcpy(subject, "-- no subject --\n");
- + strcpy(newsgroups, "");
- +
- + rewind(tmp_file);
- in_header = TRUE;
- + control = FALSE;
-
- ! /* read the file */
- ! while (fgets(buf, 511, tmp_file) != NULL) {
- !
- ! if (strstr(buf, "#! rnews") != NULL) {
- !
- ! if (control)
- ! strcpy(newsgroups, "Newsgroups: control"); /* kludge */
- !
- ! if (spool != NULL)
- ! save_message(spool, newsgroups, subject, msg_id);
- !
- ! strcpy(subject, "-- no subject --\n");
- ! in_header = TRUE;
- ! control = FALSE;
- ! spool = NULL;
-
- } else {
- /* flag the end of the header */
- ***************
- *** 210,262 ****
- /* save the newsgroups line */
- if (in_header) {
- if (strnicmp(buf,"Message-ID:",11) == 0) {
- ! strcpy(msg, buf);
- ! p = strtok(msg, " \t\r\n"); p = strtok(NULL, " \t\r\n");
- strcpy(msg_id, p);
- }
- ! if (strnicmp(buf,"Newsgroups:",11) == 0) strcpy(newsgroups,buf);
- ! if (strnicmp(buf,"Subject:",8) == 0) {
- strcpy(subject, buf+8);
- ! }
- ! }
- /* add our system name to the path list */
- if (strnicmp(buf, "Path:", 5) == 0) {
- p = strtok(buf, " \t");
- p = strtok(NULL, " \t");
- ! fprintf(spool_file, "Path: %s!%s", my_stuff.my_site, p);
- ! } else {
- ! fprintf(spool_file, "%s", buf);
- }
- }
-
- }
-
- ! /* process the last one */
- ! if (strlen(newsgroups) != 0) {
- ! strcpy(nglist, newsgroups+11);
- ! p = strtok(newsgroups, " \r\n,:");
- ! p = strtok(NULL, " \r\n,:");
- ! while (p != '\x00') {
-
- ! out_file = open_out_file(p);
- ! where = ftell(out_file);
- ! rewind(spool_file);
- ! while (fgets(buf, 511, spool_file) != NULL)
- ! fputs(buf, out_file);
- ! fprintf(out_file, "\n@@@@END\n");
- ! fclose(out_file);
-
- ! out_file = open_index_file(p);
- ! gp = find_news_group(p);
- ! fprintf(out_file,"%08ld %08ld %09ld %s", where, gp->hi_num, t, subject);
- ! fclose(out_file);
-
- ! p = strtok(NULL, " \r\n,:");
- ! }
- ! add_hist_record(msg_id, nglist);
- ! fclose(spool_file);
- ! unlink("$$item");
- ! }
- }
-
-
- --- 239,283 ----
- /* save the newsgroups line */
- if (in_header) {
- if (strnicmp(buf,"Message-ID:",11) == 0) {
- ! strcpy(buf2, buf);
- ! p = strtok(buf2, " \t\r\n"); p = strtok(NULL, " \t\r\n");
- strcpy(msg_id, p);
- }
- ! if (strnicmp(buf,"Newsgroups:",11) == 0)
- ! strcpy(newsgroups,buf);
- ! if (strnicmp(buf,"Subject:",8) == 0)
- strcpy(subject, buf+8);
- ! if (strnicmp(buf,"Control:",8) == 0)
- ! control = TRUE;
- /* add our system name to the path list */
- if (strnicmp(buf, "Path:", 5) == 0) {
- p = strtok(buf, " \t");
- p = strtok(NULL, " \t");
- ! strcpy(buf2, p);
- ! sprintf(buf, "Path: %s!%s", my_stuff.my_site, buf2);
- }
- }
-
- + if (spool == NULL)
- + spool = help = (LINE *) xmalloc(sizeof(LINE));
- + else {
- + help->next = (LINE *) xmalloc(sizeof(LINE));
- + help = help->next;
- }
- + help->next = NULL;
- + help->data = (char *) xmalloc(strlen(buf) + 1);
- + strcpy(help->data, buf);
- + }
-
- ! }
-
- ! /* process the last one */
-
- ! if (control)
- ! strcpy(newsgroups, "Newsgroups: control"); /* kludge */
-
- ! if (spool != NULL)
- ! save_message(spool, newsgroups, subject, msg_id);
- }
-
-
- ***************
- *** 264,270 ****
-
-
- /*--------------------------- unpack the batch ------------------------*/
- ! FILE *decode_batches(char *fn, int no_toss)
- {
- /*
- * take the batch, strip off the !cunbatch, and feed the file to
- --- 285,291 ----
-
-
- /*--------------------------- unpack the batch ------------------------*/
- ! FILE *decode_batch(char *fn, char *tn, int no_toss)
- {
- /*
- * take the batch, strip off the !cunbatch, and feed the file to
- ***************
- *** 272,300 ****
- */
-
- FILE *in_file, *out_file;
- ! int res, buf_cnt;
- ! char buf[1025];
- ! char name[128];
-
- buf_cnt = 0;
-
- /* open the batch file */
- ! strcpy(name, fn);
- ! if ((in_file = fopen(name, "rb")) == NULL) {
- ! printf("batchfile %s could not be opened\n", name);
- return(NULL);
- }
-
- /* open the compressed */
- ! sprintf(name, "%s.z", my_stuff.temp_name);
- ! if ((out_file = fopen(name, "wb")) == NULL) {
- ! printf("cannot open output file %s\n", name);
- return(NULL);
- }
-
- while ((res = fread(buf, 1, 1024, in_file)) > 0) {
- ! fwrite(buf_cnt == 0 ? buf+12 : buf, 1,
- ! buf_cnt == 0 ? res-12 : res, out_file);
- buf_cnt++;
- }
-
- --- 293,354 ----
- */
-
- FILE *in_file, *out_file;
- ! int res, buf_cnt, header;
- ! char buf[1025], out[256];
- ! char compr[16];
- ! long pos;
- ! short magic;
-
- buf_cnt = 0;
- + header = FALSE;
- + *tn = 0;
-
- /* open the batch file */
- ! if ((in_file = fopen(fn, "rb")) == NULL) {
- ! printf("batchfile %s could not be opened\n", fn);
- ! return(NULL);
- ! }
- !
- ! if (fread(buf, 1, 12, in_file) == 0) {
- ! printf("batch %s is inexplicably too small\n", fn);
- ! return(NULL);
- ! }
- !
- ! if (memcmp(buf, "#! rnews ", 9) == 0) {
- ! rewind(in_file);
- ! return(in_file);
- ! }
- !
- ! if (memcmp(buf, "#! cunbatch\n", 12) == 0)
- ! header = TRUE;
- ! else if (memcmp(buf, "#! funbatch\n", 12) == 0)
- ! header = TRUE;
- ! else
- ! rewind(in_file);
- !
- ! pos = ftell(in_file);
- ! fread(&magic, 1, sizeof(short), in_file);
- ! fseek(in_file, pos, SEEK_SET);
- !
- ! if (magic == COMPRESS)
- ! strcpy(compr, "compress");
- ! else if (magic == FREEZE)
- ! strcpy(compr, "freeze");
- ! else {
- ! printf("batch %s has unknown compression type\n", fn);
- return(NULL);
- }
-
- + if (header) {
- /* open the compressed */
- ! sprintf(tn, "%s\\unbatch.tmp", my_stuff.temp_name);
- ! if ((out_file = fopen(tn, "wb")) == NULL) {
- ! printf("cannot open output file %s\n", buf);
- return(NULL);
- }
-
- while ((res = fread(buf, 1, 1024, in_file)) > 0) {
- ! fwrite(buf, 1, res, out_file);
- buf_cnt++;
- }
-
- ***************
- *** 301,320 ****
- fclose(in_file);
- fclose(out_file);
-
- ! unlink(my_stuff.temp_name);
- ! sprintf(name, "compress -d %s.z", my_stuff.temp_name);
- ! /* printf("unbatch: decompressing batch (%s)\n", name); */
- ! system(name);
-
- ! if (no_toss) return(NULL);
-
- /* open the uncompressed */
- ! sprintf(name, "%s", my_stuff.temp_name);
- ! if ((out_file = fopen(name, "rb")) == NULL) {
- ! printf("cannot open uncompressed file %s\n", name);
- return(NULL);
- }
-
- return(out_file);
- -
- }
- --- 355,395 ----
- fclose(in_file);
- fclose(out_file);
-
- ! if (no_toss) {
- ! sprintf(out, "%s\\n_XXXXXX", my_stuff.temp_name);
- ! mktemp(out);
- ! sprintf(buf, "%s -d <%s >%s", compr, tn, out);
- ! system(buf);
- ! unlink(tn);
- ! return(NULL);
- ! }
- !
- ! /* open the uncompressed */
- ! sprintf(buf, "%s -d <%s", compr, tn);
- ! if ((out_file = popen(buf, "rb")) == NULL) {
- ! printf("cannot open pipe to \"%s\"\n", buf);
- ! return(NULL);
- ! }
- ! }
- ! else {
- ! fclose(in_file);
- ! *tn = 0;
-
- ! if (no_toss) {
- ! sprintf(out, "%s\\n_XXXXXX", my_stuff.temp_name);
- ! mktemp(out);
- ! sprintf(buf, "%s -d <%s >%s", compr, fn, out);
- ! system(buf);
- ! return(NULL);
- ! }
-
- /* open the uncompressed */
- ! sprintf(buf, "%s -d <%s", compr, fn);
- ! if ((out_file = popen(buf, "rb")) == NULL) {
- ! printf("cannot open pipe to \"%s\"\n", buf);
- return(NULL);
- }
- + }
-
- return(out_file);
- }
- diff -cb orig/unbatch.h new/unbatch.h
- *** orig/unbatch.h Thu Jun 11 22:48:17 1992
- --- new/unbatch.h Sun Aug 02 20:34:18 1992
- ***************
- *** 1,5 ****
- /*
- ! SNEWS 1.0
-
- Unbatch private decls
-
- --- 1,5 ----
- /*
- ! SNEWS 2.0
-
- Unbatch private decls
-
- ***************
- *** 27,31 ****
-
-
- /*----------------------------- prototypes --------------------------------*/
- ! FILE *decode_batches(char *fn, int no_toss);
- void toss(FILE *tmp_file);
- --- 27,34 ----
-
-
- /*----------------------------- prototypes --------------------------------*/
- ! FILE *decode_batch(char *fn, char *tn, int no_toss);
- void toss(FILE *tmp_file);
- +
- + #define COMPRESS 0x9D1F
- + #define FREEZE 0x9F1F
-