]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
added function to turn off configuration
authorDipanshu <dipanshu231099@gmail.com>
Thu, 23 Jul 2020 15:58:48 +0000 (21:28 +0530)
committerTill Kamppeter <till.kamppeter@gmail.com>
Thu, 20 Aug 2020 20:08:49 +0000 (22:08 +0200)
(cherry picked from commit f51a3c9efd3d85cca0f374a2ba40079af6d4aac4)

utils/cups-browsed.c
utils/cups-browsed.conf.5
utils/cups-browsed.conf.in

index 6871672f126e44b37948dd733bb2db0c2ef51a50..c4bc0944af97403f73dd84b86e20c519643c45ac 100644 (file)
@@ -433,7 +433,7 @@ static uint16_t BrowsePort = 631;
 static browsepoll_t **BrowsePoll = NULL;
 static unsigned int NewBrowsePollQueuesShared = 0;
 static unsigned int AllowResharingRemoteCUPSPrinters = 0;
-static unsigned int DebugLogFileSize = 30;
+static unsigned int DebugLogFileSize = 300;
 static size_t NumBrowsePoll = 0;
 static guint update_netifs_sourceid = 0;
 static char local_server_str[1024];
@@ -718,12 +718,12 @@ void copyToFile(FILE **fp1, FILE **fp2){
     return;
   }
   fseek(*fp1, 0, SEEK_SET);
-  size_t r = fread(buf, sizeof(char), sizeof(buffer_size)-1, *fp1);
-  while(r == sizeof(buffer_size)-1){
-    fwrite(buf, sizeof(char), sizeof(buffer_size)-1, *fp2);
-    r = fread(buf, sizeof(char), sizeof(buffer_size)-1, *fp1);
-  }
-  fwrite(buf, sizeof(char), r, *fp2);
+  size_t r;
+  do {
+    r = fread(buf, sizeof(char), buffer_size, *fp1);
+    fwrite(buf, sizeof(char), r, *fp2);
+  } while(r==buffer_size);
+
 }
 
 void
@@ -750,7 +750,7 @@ debug_printf(const char *format, ...) {
     }
 
     long int log_file_size = findLogFileSize(); 
-    if(log_file_size>(long int)DebugLogFileSize*1024){
+    if(DebugLogFileSize>0 && log_file_size>(long int)DebugLogFileSize*1024){
       fclose(lfp);
       FILE *fp1 = fopen(debug_log_file, "r");
       FILE *fp2 = fopen(debug_log_file_bckp, "w");
@@ -11684,6 +11684,12 @@ read_configuration (const char *filename)
       else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") ||
               !strcasecmp(value, "off") || !strcasecmp(value, "0"))
        NewIPPPrinterQueuesShared = 0;
+    } else if(!strcasecmp(line, "DebugLogFileSize") && value) {
+      int val = atoi(value);
+      if(val<=0){
+        DebugLogFileSize=0;
+      }
+      else DebugLogFileSize=val;
     } else if (!strcasecmp(line, "AllowResharingRemoteCUPSPrinters") && value) {
       if (!strcasecmp(value, "yes") || !strcasecmp(value, "true") ||
          !strcasecmp(value, "on") || !strcasecmp(value, "1"))
index 1719b784e7b3473469539c98e86d05902722bfdd..e1957298d45268bb7837ec621b7988260d89ad12 100644 (file)
@@ -970,13 +970,15 @@ without jobs.
 
 .fam T
 .fi
-The MAX_LOG_SIZE defines the maximum size possible (in KBytes)
+The DebugLogFileSize defines the maximum size possible (in KBytes)
 of the log files (cups-browsed_log and cups-browsed_previous_logs)
 that is created using cups-browsed in the debugging mode.
+Keeping its value to 0 would turn off any restriction
+on the size of the file.
 .PP
 .nf
 .fam C
-        DebugLogFileSize 30
+        DebugLogFileSize 300
 
 .fam T
 .fi
index 28e1640fa96ccd6174efa6e5c8f0a9055d5766e5..3b43e66768bef45794b6a784d8f5990bd95877c2 100644 (file)
@@ -759,8 +759,10 @@ BrowseRemoteProtocols @BROWSEREMOTEPROTOCOLS@
 
 # AutoShutdownTimeout 30
 
-# The MAX_LOG_SIZE defines the maximum size possible (in KBytes)
+# The DebugLogFileSize defines the maximum size possible (in KBytes)
 # of the log files (cups-browsed_log and cups-browsed_previous_logs)
 # that is created using cups-browsed in the debugging mode.
+# Keeping its value to 0 would turn off any restriction
+# on the size of the file.
 
-# DebugLogFileSize 30
+# DebugLogFileSize 300