#983258 db.c: add "keep_active_file" and "only_newsrc_groups" and use them

Package:
src:nn
Source:
nn
Submitter:
Bjarni Ingi Gislason
Date:
2021-02-21 16:24:04 UTC
Severity:
normal
Tags:
#983258#5
Date:
2021-02-21 16:21:21 UTC
From:
To:
Dear Maintainer,

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 db.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/db.c b/db.c
index cfe979d..4278dda 100644
--- a/db.c
+++ b/db.c
@@ -98,6 +98,8 @@ extern char
                *master_directory, *db_directory, *db_data_directory, *news_directory, *news_lib_directory;
 extern int      db_data_subdirs, new_group_action;

+int             keep_active_file = 0;
+
 master_header   master;

 #ifdef MALLOC_64K_LIMITATION
@@ -533,6 +535,9 @@ make_master_copy(int force_copy)
 /*
  *	Init the groups data from active file.
  */
+
+int             only_newsrc_groups = 0;
+
 void
 open_master(int mode)
 {
@@ -543,7 +548,11 @@ open_master(int mode)
     active_groups = NULL;
     sorted_groups = NULL;

-    readactfile();		/* Read in the active file - count groups */
+    if (only_newsrc_groups)
+	readpartactfile();
+    else
+	readactfile();		/* Read in the active file - count groups */
+
     readtimfile();		/* Read the newsgroup creation time file */

     db_expand_master();		/* uses count from readact() call! */
@@ -1007,6 +1016,7 @@ readactfile(void)
     int             i;
     FILE           *actfp;
     stlist_t       *sthead, *stp = NULL;
+    extern int      keep_active_file;

     if (actlist != NULL)
 	return;
@@ -1028,6 +1038,19 @@ readactfile(void)
      * groups we can use for internal tables.
      */
     sthead = NULL;
+    gotoxy(0, 3);
+    tprintf("Reading active file ... ");
+    fflush(stdout);
+
+    if (nntp_debug || keep_active_file) {
+	if (f_user == NULL) {
+	    f_user = open_file(relative(active_directory, "ACTIVE"), OPEN_CREATE);
+	    if (f_user == NULL) {
+		msg("Could not open file in the %s directoy for writing the active file, %s%s%d\n",
+		     active_directory, __FILE__, ":", __LINE__);
+	    }
+        }
+    }

 #ifdef NNTP
     while (use_nntp ? nntp_fgets(actline, sizeof actline)
@@ -1037,6 +1060,9 @@ readactfile(void)
 #endif				/* NNTP */

     {
+	if ( (nntp_debug || keep_active_file) && (f_user != NULL))
+	    fprintf(f_user, "%s\n", actline);
+
 	stlist_t       *stnew = (stlist_t *) strkeep(actline, sizeof(stlisthdr_t), POOL_ACT);
 	if (stnew == NULL) {
 	    nn_exitmsg(1, "out of mem for active file (at line %d)\n", count + 1);