"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/debug.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.

debug.c  (tin-2.4.4.tar.xz):debug.c  (tin-2.4.5.tar.xz)
/* /*
* Project : tin - a Usenet reader * Project : tin - a Usenet reader
* Module : debug.c * Module : debug.c
* Author : I. Lea * Author : I. Lea
* Created : 1991-04-01 * Created : 1991-04-01
* Updated : 2019-07-23 * Updated : 2020-05-19
* Notes : debug routines * Notes : debug routines
* *
* Copyright (c) 1991-2020 Iain Lea <iain@bricbrac.de> * Copyright (c) 1991-2021 Iain Lea <iain@bricbrac.de>
* 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 110 skipping to change at line 110
unlink(file); unlink(file);
joinpath(file, sizeof(file), TMPDIR, "SCOPES-R"); joinpath(file, sizeof(file), TMPDIR, "SCOPES-R");
unlink(file); unlink(file);
joinpath(file, sizeof(file), TMPDIR, "SCOPES-W"); joinpath(file, sizeof(file), TMPDIR, "SCOPES-W");
unlink(file); unlink(file);
} }
if (debug & (DEBUG_MISC | DEBUG_REMOVE)) { if (debug & (DEBUG_MISC | DEBUG_REMOVE)) {
joinpath(file, sizeof(file), TMPDIR, "ACTIVE"); joinpath(file, sizeof(file), TMPDIR, "ACTIVE");
unlink(file); unlink(file);
joinpath(file, sizeof(file), TMPDIR, "GNKSA");
unlink(file);
} }
} }
/* /*
* tin specific debug routines * tin specific debug routines
*/ */
void void
debug_print_arts( debug_print_arts(
void) void)
{ {
int i; int i;
if (!(debug & DEBUG_FILTER)) for_each_art(i) /* fopen/close() horror */
return;
for_each_art(i)
debug_print_header(&arts[i]); debug_print_header(&arts[i]);
} }
void void
debug_print_header( debug_print_header(
struct t_article *s) struct t_article *s)
{ {
static char file[PATH_LEN] = { '\0' };
FILE *fp; FILE *fp;
char file[PATH_LEN];
if (!(debug & DEBUG_FILTER)) if (!(debug & DEBUG_FILTER))
return; return;
joinpath(file, sizeof(file), TMPDIR, "ARTS"); if (!*file)
joinpath(file, sizeof(file), TMPDIR, "ARTS");
if ((fp = fopen(file, "a")) != NULL) { if ((fp = fopen(file, "a")) != NULL) {
fprintf(fp,"art=[%5"T_ARTNUM_PFMT"] tag=[%s] kill=[%s] selected=[ %s]\n", s->artnum, fprintf(fp, "art=[%5"T_ARTNUM_PFMT"] tag=[%s] kill=[%s] selected= [%s]\n", s->artnum,
bool_unparse(s->tagged), bool_unparse(s->tagged),
bool_unparse(s->killed), bool_unparse(s->killed),
bool_unparse(s->selected)); bool_unparse(s->selected));
fprintf(fp,"subj=[%-38s]\n", s->subject); fprintf(fp, "subj=[%-38s]\n", s->subject);
fprintf(fp,"date=[%ld] from=[%s] name=[%s]\n", (long) s->date, fprintf(fp, "date=[%ld] from=[%s] name=[%s]\n", (long) s->date,
s->from, s->from,
BlankIfNull(s->name)); BlankIfNull(s->name));
fprintf(fp,"msgid=[%s] refs=[%s]\n", fprintf(fp, "msgid=[%s] refs=[%s]\n",
BlankIfNull(s->msgid), BlankIfNull(s->msgid),
BlankIfNull(s->refs)); BlankIfNull(s->refs));
if (s->killed) if (s->killed)
fprintf(fp,"score=[%d] gnksa=[%d] lines=[%d]\n", s->score , s->gnksa_code, s->line_count); fprintf(fp, "score=[%d] gnksa=[%d] lines=[%d]\n", s->scor e, s->gnksa_code, s->line_count);
if (s->archive) { if (s->archive) {
fprintf(fp, "archive.name=[%-38s] ", s->archive->name); fprintf(fp, "archive.name=[%-38s] ", s->archive->name);
if (s->archive->partnum) if (s->archive->partnum)
fprintf(fp, "archive.partnum=[%s] ", s->archive- >partnum); fprintf(fp, "archive.partnum=[%s] ", s->archive- >partnum);
if (s->archive->ispart) if (s->archive->ispart)
fprintf(fp, "archive.ispart=[%s]\n", bool_unparse (s->archive->ispart)); fprintf(fp, "archive.ispart=[%s]\n", bool_unparse (s->archive->ispart));
} }
fprintf(fp,"thread=[%d] prev=[%d] status=[%u]\n\n", s->thread, s->prev, s->status); fprintf(fp, "thread=[%d] prev=[%d] status=[%u]\n\n", s->thread, s->prev, s->status);
fflush(fp); fflush(fp);
#ifdef HAVE_FCHMOD
fchmod(fileno(fp), (S_IRUGO|S_IWUGO)); fchmod(fileno(fp), (S_IRUGO|S_IWUGO));
#else
# ifdef HAVE_CHMOD
chmod(file, (S_IRUGO|S_IWUGO));
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
fclose(fp); fclose(fp);
} }
} }
void void
debug_print_active( debug_print_active(
void) void)
{ {
static char file[PATH_LEN] = { '\0' };
FILE *fp; FILE *fp;
char file[PATH_LEN];
if (!(debug & DEBUG_MISC)) if (!(debug & DEBUG_MISC))
return; return;
joinpath(file, sizeof(file), TMPDIR, "ACTIVE"); if (!*file)
joinpath(file, sizeof(file), TMPDIR, "ACTIVE");
if ((fp = fopen(file, "w")) != NULL) { if ((fp = fopen(file, "w")) != NULL) {
int i; int i;
struct t_group *group; struct t_group *group;
for_each_group(i) { for_each_group(i) {
group = &active[i]; group = &active[i];
fprintf(fp, "[%4d]=[%s] type=[%s] spooldir=[%s]\n", fprintf(fp, "[%4d]=[%s] type=[%s] spooldir=[%s]\n",
i, group->name, i, group->name,
(group->type == GROUP_TYPE_NEWS ? "NEWS" : "MAIL" ), (group->type == GROUP_TYPE_NEWS ? "NEWS" : "MAIL" ),
group->spooldir); group->spooldir);
fprintf(fp, "count=[%4"T_ARTNUM_PFMT"] max=[%4"T_ARTNUM_P FMT"] min=[%4"T_ARTNUM_PFMT"] mod=[%c]\n", fprintf(fp, "count=[%4"T_ARTNUM_PFMT"] max=[%4"T_ARTNUM_P FMT"] min=[%4"T_ARTNUM_PFMT"] mod=[%c]\n",
group->count, group->xmax, group->xmin, group->mo derated); group->count, group->xmax, group->xmin, group->mo derated);
fprintf(fp, " nxt=[%4d] hash=[%lu] description=[%s]\n", group->next, fprintf(fp, " nxt=[%4d] hash=[%lu] description=[%s]\n", group->next,
hash_groupname(group->name), BlankIfNull(group->d escription)); hash_groupname(group->name), BlankIfNull(group->d escription));
if (debug & DEBUG_NEWSRC) if (debug & DEBUG_NEWSRC)
debug_print_newsrc(&group->newsrc, fp); debug_print_newsrc(&group->newsrc, fp);
if (debug & DEBUG_ATTRIB) if (debug & DEBUG_ATTRIB)
debug_print_attributes(group->attribute, fp); debug_print_attributes(group->attribute, fp);
} }
#ifdef HAVE_FCHMOD
fchmod(fileno(fp), (S_IRUGO|S_IWUGO)); fchmod(fileno(fp), (S_IRUGO|S_IWUGO));
#else
# ifdef HAVE_CHMOD
chmod(file, (S_IRUGO|S_IWUGO));
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
fclose(fp); fclose(fp);
} }
} }
static void static void
debug_print_attributes( debug_print_attributes(
struct t_attribute *attr, struct t_attribute *attr,
FILE *fp) FILE *fp)
{ {
if (attr == NULL) if (attr == NULL)
skipping to change at line 244 skipping to change at line 257
BlankIfNull(attr->savedir), BlankIfNull(attr->savedir),
BlankIfNull(attr->savefile)); BlankIfNull(attr->savefile));
fprintf(fp, "sigfile=[%s] followup_to=[%s]\n\n", fprintf(fp, "sigfile=[%s] followup_to=[%s]\n\n",
BlankIfNull(attr->sigfile), BlankIfNull(attr->sigfile),
BlankIfNull(attr->followup_to)); BlankIfNull(attr->followup_to));
fflush(fp); fflush(fp);
} }
void void
debug_print_malloc( debug_print_malloc(
int is_malloc, t_bool is_malloc,
const char *xfile, const char *xfile,
int line, int line,
size_t size) size_t size)
{ {
FILE *fp; static char file[PATH_LEN] = { '\0' };
char file[PATH_LEN];
static size_t total = 0; static size_t total = 0;
FILE *fp;
if (debug & DEBUG_MEM) { if (!*file)
joinpath(file, sizeof(file), TMPDIR, "MALLOC"); joinpath(file, sizeof(file), TMPDIR, "MALLOC");
if ((fp = fopen(file, "a")) != NULL) {
total += size; if ((fp = fopen(file, "a")) != NULL) {
/* sometimes size_t is long */ total += size;
fprintf(fp, "%12s:%-4d %s(%6lu). Total %lu\n", xfile, lin /* sometimes size_t is long */
e, is_malloc ? " malloc" : "realloc", (unsigned long) size, (unsigned long) tota fprintf(fp, "%12s:%-4d %s(%6lu). Total %lu\n", xfile, line, is_ma
l); lloc ? " malloc" : "realloc", (unsigned long) size, (unsigned long) total);
fchmod(fileno(fp), (S_IRUGO|S_IWUGO)); #ifdef HAVE_FCHMOD
fclose(fp); fchmod(fileno(fp), (S_IRUGO|S_IWUGO));
} #else
# ifdef HAVE_CHMOD
chmod(file, (S_IRUGO|S_IWUGO));
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
fclose(fp);
} }
} }
static void static void
debug_print_filter( debug_print_filter(
FILE *fp, FILE *fp,
int num, int num,
struct t_filter *the_filter) struct t_filter *the_filter)
{ {
static const char sign[] = { ' ', '=', '<', '>', '\0' }; static const char sign[] = { ' ', '=', '<', '>', '\0' };
skipping to change at line 302 skipping to change at line 321
sign[(int) the_filter->gnksa_cmp], the_filter->gnksa_num); sign[(int) the_filter->gnksa_cmp], the_filter->gnksa_num);
if (the_filter->time) if (the_filter->time)
fprintf(fp, " time=[%ld][%s]\n", (long) the_filter->time, B lankIfNull(str_trim(ctime(&the_filter->time)))); fprintf(fp, " time=[%ld][%s]\n", (long) the_filter->time, B lankIfNull(str_trim(ctime(&the_filter->time))));
} }
void void
debug_print_filters( debug_print_filters(
void) void)
{ {
FILE *fp;
char file[PATH_LEN];
int i, num; int i, num;
static char file[PATH_LEN] = { '\0' };
struct t_filter *the_filter; struct t_filter *the_filter;
FILE *fp;
if (!(debug & DEBUG_FILTER)) if (!*file)
return; joinpath(file, sizeof(file), TMPDIR, "FILTER");
joinpath(file, sizeof(file), TMPDIR, "FILTER");
if ((fp = fopen(file, "w")) != NULL) { if ((fp = fopen(file, "w")) != NULL) {
/* /*
* print global filter * print global filter
*/ */
num = glob_filter.num; num = glob_filter.num;
the_filter = glob_filter.filter; the_filter = glob_filter.filter;
fprintf(fp, "*** BEG GLOBAL FILTER=[%3d] ***\n", num); fprintf(fp, "*** BEG GLOBAL FILTER=[%3d] ***\n", num);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
debug_print_filter(fp, i, &the_filter[i]); debug_print_filter(fp, i, &the_filter[i]);
fprintf(fp, "\n"); fprintf(fp, "\n");
} }
fprintf(fp, "*** END GLOBAL FILTER ***\n"); fprintf(fp, "*** END GLOBAL FILTER ***\n");
#ifdef HAVE_FCHMOD
fchmod(fileno(fp), (S_IRUGO|S_IWUGO)); fchmod(fileno(fp), (S_IRUGO|S_IWUGO));
#else
# ifdef HAVE_CHMOD
chmod(file, (S_IRUGO|S_IWUGO));
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
fclose(fp); fclose(fp);
} }
} }
void void
debug_print_file( debug_print_file(
const char *fname, const char *fname,
const char *fmt, const char *fmt,
...) ...)
{ {
skipping to change at line 351 skipping to change at line 374
if (!debug) if (!debug)
return; return;
va_start(ap, fmt); va_start(ap, fmt);
buf = fmt_message(fmt, ap); buf = fmt_message(fmt, ap);
va_end(ap); va_end(ap);
joinpath(file, sizeof(file), TMPDIR, fname); joinpath(file, sizeof(file), TMPDIR, fname);
if ((fp = fopen(file, "a")) != NULL) { if ((fp = fopen(file, "a")) != NULL) {
fprintf(fp,"%s\n", buf); fprintf(fp, "%s\n", buf);
#ifdef HAVE_FCHMOD
fchmod(fileno(fp), (S_IRUGO|S_IWUGO)); fchmod(fileno(fp), (S_IRUGO|S_IWUGO));
#else
# ifdef HAVE_CHMOD
chmod(file, (S_IRUGO|S_IWUGO));
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
fclose(fp); fclose(fp);
} }
free(buf); free(buf);
} }
void void
debug_print_comment( debug_print_comment(
const char *comment) const char *comment)
{ {
if (!(debug & DEBUG_NEWSRC)) if (!(debug & DEBUG_NEWSRC))
skipping to change at line 398 skipping to change at line 427
art->artnum, art->artnum,
bool_unparse(art->tagged), bool_unparse(art->tagged),
bool_unparse(art->killed), bool_unparse(art->killed),
bool_unparse(art->selected), bool_unparse(art->selected),
art->subject); art->subject);
fprintf(fp, "thread=[%d] prev=[%d] status=[%s]\ n", fprintf(fp, "thread=[%d] prev=[%d] status=[%s]\ n",
art->thread, art->prev, art->thread, art->prev,
(art->status == ART_READ ? "READ" : "UNRE AD")); (art->status == ART_READ ? "READ" : "UNRE AD"));
} }
debug_print_newsrc(&group->newsrc, fp); debug_print_newsrc(&group->newsrc, fp);
#ifdef HAVE_FCHMOD
fchmod(fileno(fp), (S_IRUGO|S_IWUGO)); fchmod(fileno(fp), (S_IRUGO|S_IWUGO));
#else
# ifdef HAVE_CHMOD
chmod(file, (S_IRUGO|S_IWUGO));
# endif /* HAVE_CHMOD */
#endif /* HAVE_FCHMOD */
fclose(fp); fclose(fp);
} }
} }
} }
static void static void
debug_print_newsrc( debug_print_newsrc(
struct t_newsrc *lnewsrc, struct t_newsrc *lnewsrc,
FILE *fp) FILE *fp)
{ {
 End of changes. 34 change blocks. 
37 lines changed or deleted 71 lines changed or added

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