"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/newsrc.c" between
tin-2.4.4.tar.xz and tin-2.4.5.tar.xz

About: TIN is a threaded NNTP and spool based UseNet newsreader.

newsrc.c  (tin-2.4.4.tar.xz):newsrc.c  (tin-2.4.5.tar.xz)
/* /*
* Project : tin - a Usenet reader * Project : tin - a Usenet reader
* Module : newsrc.c * Module : newsrc.c
* Author : I. Lea & R. Skrenta * Author : I. Lea & R. Skrenta
* Created : 1991-04-01 * Created : 1991-04-01
* Updated : 2018-11-23 * Updated : 2020-05-09
* Notes : ArtCount = (ArtMax - ArtMin) + 1 [could have holes] * Notes : ArtCount = (ArtMax - ArtMin) + 1 [could have holes]
* *
* Copyright (c) 1991-2020 Iain Lea <iain@bricbrac.de>, Rich Skrenta <skrenta@pb m.com> * Copyright (c) 1991-2021 Iain Lea <iain@bricbrac.de>, Rich Skrenta <skrenta@pb m.com>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
skipping to change at line 223 skipping to change at line 223
return -1L; /* can't access newsrc */ return -1L; /* can't access newsrc */
} }
if (!note_stat_newsrc.st_size) { if (!note_stat_newsrc.st_size) {
fclose(fp_ip); fclose(fp_ip);
return 0L; /* newsrc is empty */ return 0L; /* newsrc is empty */
} }
if ((fp_op = fopen(newnewsrc, "w")) != NULL) { if ((fp_op = fopen(newnewsrc, "w")) != NULL) {
if (newsrc_mode) if (newsrc_mode)
#ifdef HAVE_FCHMOD
fchmod(fileno(fp_op), newsrc_mode); fchmod(fileno(fp_op), newsrc_mode);
#else
# ifdef HAVE_CHMOD
chmod(newnewsrc, newsrc_mode);
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
while ((line = tin_fgets(fp_ip, FALSE)) != NULL) while ((line = tin_fgets(fp_ip, FALSE)) != NULL)
tot += write_newsrc_line(fp_op, line); tot += write_newsrc_line(fp_op, line);
/* /*
* Don't rename if either fclose() fails or ferror() is set * Don't rename if either fclose() fails or ferror() is set
*/ */
if ((err = ferror(fp_op)) || fclose(fp_op)) { if ((err = ferror(fp_op)) || fclose(fp_op)) {
error_message(2, _(txt_filesystem_full), NEWSRC_FILE); error_message(2, _(txt_filesystem_full), NEWSRC_FILE);
unlink(newnewsrc); unlink(newnewsrc);
skipping to change at line 337 skipping to change at line 343
if (!batch_mode) if (!batch_mode)
wait_message(0, _(txt_autosubscribing_groups)); wait_message(0, _(txt_autosubscribing_groups));
if ((fp_newsrc = fopen(newsrc_file, "w")) == NULL) { if ((fp_newsrc = fopen(newsrc_file, "w")) == NULL) {
TIN_FCLOSE(fp_subs); TIN_FCLOSE(fp_subs);
return; return;
} }
if (newsrc_mode) if (newsrc_mode)
#ifdef HAVE_FCHMOD
fchmod(fileno(fp_newsrc), newsrc_mode); fchmod(fileno(fp_newsrc), newsrc_mode);
#else
# ifdef HAVE_CHMOD
chmod(newsrc_file, newsrc_mode);
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
/* TODO: test me! */ /* TODO: test me! */
while ((ptr = tin_fgets(fp_subs, FALSE)) != NULL) { while ((ptr = tin_fgets(fp_subs, FALSE)) != NULL) {
if (ptr[0] != '#') { if (ptr[0] != '#') {
if (group_find(ptr, FALSE) != NULL) if (group_find(ptr, FALSE) != NULL)
fprintf(fp_newsrc, "%s:\n", ptr); fprintf(fp_newsrc, "%s:\n", ptr);
} }
} }
/* We ignore user 'q'uits here. They will get them next time in any case */ /* We ignore user 'q'uits here. They will get them next time in any case */
skipping to change at line 545 skipping to change at line 557
int sub; int sub;
t_bool found = FALSE; t_bool found = FALSE;
if (no_write) if (no_write)
return; return;
if ((newfp = fopen(newnewsrc, "w")) == NULL) if ((newfp = fopen(newnewsrc, "w")) == NULL)
return; return;
if (newsrc_mode) if (newsrc_mode)
#ifdef HAVE_FCHMOD
fchmod(fileno(newfp), newsrc_mode); fchmod(fileno(newfp), newsrc_mode);
#else
# ifdef HAVE_CHMOD
chmod(newnewsrc, newsrc_mode);
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
if ((fp = fopen(newsrc, "r")) != NULL) { if ((fp = fopen(newsrc, "r")) != NULL) {
while ((line = tin_fgets(fp, FALSE)) != NULL) { while ((line = tin_fgets(fp, FALSE)) != NULL) {
if ((seq = parse_newsrc_line(line, &sub))) { if ((seq = parse_newsrc_line(line, &sub))) {
if (STRCMPEQ(line, group->name)) { if (STRCMPEQ(line, group->name)) {
fprintf(newfp, "%s%c %s\n", line, sub_sta te, seq); fprintf(newfp, "%s%c %s\n", line, sub_sta te, seq);
group->subscribed = SUB_BOOL(sub_state); group->subscribed = SUB_BOOL(sub_state);
/* If previously subscribed to in .newsrc , load up any existing information */ /* If previously subscribed to in .newsrc , load up any existing information */
if (sub_state == SUBSCRIBED) if (sub_state == SUBSCRIBED)
skipping to change at line 603 skipping to change at line 621
reset_newsrc( reset_newsrc(
void) void)
{ {
FILE *fp; FILE *fp;
FILE *newfp; FILE *newfp;
char *line; char *line;
int sub, i; int sub, i;
if (!no_write && (newfp = fopen(newnewsrc, "w")) != NULL) { if (!no_write && (newfp = fopen(newnewsrc, "w")) != NULL) {
if (newsrc_mode) if (newsrc_mode)
#ifdef HAVE_FCHMOD
fchmod(fileno(newfp), newsrc_mode); fchmod(fileno(newfp), newsrc_mode);
#else
# ifdef HAVE_CHMOD
chmod(newnewsrc, newsrc_mode);
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
if ((fp = fopen(newsrc, "r")) != NULL) { if ((fp = fopen(newsrc, "r")) != NULL) {
while ((line = tin_fgets(fp, FALSE)) != NULL) { while ((line = tin_fgets(fp, FALSE)) != NULL) {
(void) parse_newsrc_line(line, &sub); (void) parse_newsrc_line(line, &sub);
fprintf(newfp, "%s%c\n", line, sub); fprintf(newfp, "%s%c\n", line, sub);
} }
fclose(fp); fclose(fp);
} }
if ((sub = ferror(newfp)) || fclose(newfp)) { if ((sub = ferror(newfp)) || fclose(newfp)) {
error_message(2, _(txt_filesystem_full), NEWSRC_FILE); error_message(2, _(txt_filesystem_full), NEWSRC_FILE);
skipping to change at line 645 skipping to change at line 669
FILE *newfp; FILE *newfp;
char *line; char *line;
char *seq; char *seq;
int sub; int sub;
if (no_write) if (no_write)
return; return;
if ((newfp = fopen(newnewsrc, "w")) != NULL) { if ((newfp = fopen(newnewsrc, "w")) != NULL) {
if (newsrc_mode) if (newsrc_mode)
#ifdef HAVE_FCHMOD
fchmod(fileno(newfp), newsrc_mode); fchmod(fileno(newfp), newsrc_mode);
#else
# ifdef HAVE_CHMOD
chmod(newnewsrc, newsrc_mode);
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
if ((fp = fopen(newsrc, "r")) != NULL) { if ((fp = fopen(newsrc, "r")) != NULL) {
while ((line = tin_fgets(fp, FALSE)) != NULL) { while ((line = tin_fgets(fp, FALSE)) != NULL) {
if ((seq = parse_newsrc_line(line, &sub))) { if ((seq = parse_newsrc_line(line, &sub))) {
if (!STRCMPEQ(line, group)) if (!STRCMPEQ(line, group))
fprintf(newfp, "%s%c %s\n", line, sub, seq); fprintf(newfp, "%s%c %s\n", line, sub, seq);
} }
} }
fclose(fp); fclose(fp);
} }
skipping to change at line 1193 skipping to change at line 1223
if ((fp_in = fopen(newsrc, "r")) == NULL) if ((fp_in = fopen(newsrc, "r")) == NULL)
goto rewrite_group_done; goto rewrite_group_done;
if ((fp_out = fopen(newnewsrc, "w")) == NULL) if ((fp_out = fopen(newnewsrc, "w")) == NULL)
goto rewrite_group_done; goto rewrite_group_done;
newnewsrc_created = TRUE; newnewsrc_created = TRUE;
if (newsrc_mode) if (newsrc_mode)
#ifdef HAVE_FCHMOD
fchmod(fileno(fp_out), newsrc_mode); fchmod(fileno(fp_out), newsrc_mode);
#else
# ifdef HAVE_CHMOD
chmod(newnewsrc, newsrc_mode);
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
joinpath(filename, sizeof(filename), TMPDIR, ".subrc"); joinpath(filename, sizeof(filename), TMPDIR, ".subrc");
snprintf(sub, sizeof(sub), "%s.%ld", filename, (long) process_id); snprintf(sub, sizeof(sub), "%s.%ld", filename, (long) process_id);
joinpath(filename, sizeof(filename), TMPDIR, ".unsubrc"); joinpath(filename, sizeof(filename), TMPDIR, ".unsubrc");
snprintf(unsub, sizeof(unsub), "%s.%ld", filename, (long) process_id); snprintf(unsub, sizeof(unsub), "%s.%ld", filename, (long) process_id);
if ((fp_sub = fopen(sub, "w")) == NULL) if ((fp_sub = fopen(sub, "w")) == NULL)
goto rewrite_group_done; goto rewrite_group_done;
 End of changes. 14 change blocks. 
2 lines changed or deleted 38 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)