INN commit: trunk (6 files)

INN Commit rra at isc.org
Sun Jan 23 10:17:49 UTC 2011


    Date: Sunday, January 23, 2011 @ 02:17:49
  Author: iulius
Revision: 9159

Add the htmlstatus parameter to inn.conf to determine whether the status file
that innd can write out (depending on the value of the status parameter)
is plain text or wrapped in HTML.  It previously only was a compile-time
option, set to true by default.  The behaviour was therefore impossible
to modify without compiling again INN.

Thanks to Florian Schlichting for the patch.

Also fix the syntax of the generated HTML file.  The refresh time should
not end with a semi-colon.  Add the English language, and validate HTML 5.

Modified:
  trunk/doc/pod/inn.conf.pod
  trunk/doc/pod/news.pod
  trunk/include/inn/innconf.h
  trunk/innd/status.c
  trunk/lib/innconf.c
  trunk/samples/inn.conf.in

-----------------------+
 doc/pod/inn.conf.pod  |   11 ++++++++++-
 doc/pod/news.pod      |   10 +++++++++-
 include/inn/innconf.h |    1 +
 innd/status.c         |   40 +++++++++++++++++-----------------------
 lib/innconf.c         |    1 +
 samples/inn.conf.in   |    1 +
 6 files changed, 39 insertions(+), 25 deletions(-)

Modified: doc/pod/inn.conf.pod
===================================================================
--- doc/pod/inn.conf.pod	2011-01-23 09:56:16 UTC (rev 9158)
+++ doc/pod/inn.conf.pod	2011-01-23 10:17:49 UTC (rev 9159)
@@ -1132,6 +1132,14 @@
 is the default for C<cnfsstat -l>, currently 600 seconds).  This is a
 boolean value and the default is false.
 
+=item I<htmlstatus>
+
+Whether B<innd> should write the status report as HTML file or in plain text.
+The HTML status file goes to I<pathhttp>/inn_status.html, while the plain
+text status file is written to I<pathlog>/inn.status.  This is a boolean
+value and the default is true (an HTML status file is written).  Also see
+the I<status> parameter.
+
 =item I<incominglogfrequency>
 
 How many articles to process on an incoming channel before logging the
@@ -1204,7 +1212,8 @@
 =item I<status>
 
 How frequently (in seconds) innd(8) should write out a status report.  The
-report is written to I<pathhttp>/inn_status.html.  If this is set to C<0> or
+report is written to I<pathhttp>/inn_status.html or I<pathlog>/inn.status 
+depending on the value of I<htmlstatus>.  If this is set to C<0> or
 C<false>, status reporting is disabled.  The default value is C<0>.
 
 =item I<timer>

Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	2011-01-23 09:56:16 UTC (rev 9158)
+++ doc/pod/news.pod	2011-01-23 10:17:49 UTC (rev 9159)
@@ -202,6 +202,14 @@
 
 =item *
 
+A new parameter has been added to F<inn.conf> to determine whether the status
+file that B<innd> can write out (depending on the value of the I<status>
+parameter) is plain text or wrapped in HTML.  It previously only was a
+compile-time option, set to true by default.  Florian Schlichting added
+the I<htmlstatus> parameter to provide a configurable behaviour.
+
+=item *
+
 It is now possible to run a script at the end of the execution of
 B<innshellvars> scripts.  If a file named F<innshellvars.local>,
 F<innshellvars.pl.local> or F<innshellvars.tcl.local> is present and
@@ -1139,7 +1147,7 @@
 
 B<inncheck> now uses a range of permissions to see whether the file modes
 are correctly set.  Therefore, different configurations depending on the
-security the user wants to enforce on his sytem are possible.
+security the user wants to enforce on his system are possible.
 
 =item *
 

Modified: include/inn/innconf.h
===================================================================
--- include/inn/innconf.h	2011-01-23 09:56:16 UTC (rev 9158)
+++ include/inn/innconf.h	2011-01-23 10:17:49 UTC (rev 9159)
@@ -142,6 +142,7 @@
 
     /* Logging */
     bool docnfsstat;            /* Run cnfsstat in the background? */
+    bool htmlstatus;            /* Write status file as HTML instead of plain text? */
     unsigned long incominglogfrequency;  /* Checkpoint log after this many articles */
     bool logartsize;            /* Log article sizes? */
     bool logcancelcomm;         /* Log ctlinnd cancel commands to syslog? */

Modified: innd/status.c
===================================================================
--- innd/status.c	2011-01-23 09:56:16 UTC (rev 9158)
+++ innd/status.c	2011-01-23 10:17:49 UTC (rev 9159)
@@ -13,12 +13,6 @@
 #include "innperl.h"
 
 #define MIN_REFRESH   60  /* 1 min */
-#define HTML_STATUS
-#if defined(HTML_STATUS)
-#define STATUS_FILE	"inn_status.html"	/* will be in pathhttp */
-#else
-#define STATUS_FILE	"inn.status"		/* will be in pathlog */
-#endif
 
 typedef struct _STATUS {
     char		name[SMBUF];
@@ -126,25 +120,25 @@
   char			str[9];
   time_t		now;
  
-#if defined(HTML_STATUS)
-  path = concatpath(innconf->pathhttp, STATUS_FILE);
-#else
-  path = concatpath(innconf->pathlog, STATUS_FILE);
-#endif
+  if (innconf->htmlstatus) {
+    path = concatpath(innconf->pathhttp, "inn_status.html");
+  } else {
+    path = concatpath(innconf->pathlog, "inn.status");
+  }
   if ((F = Fopen(path, "w", TEMPORARYOPEN)) == NULL) {
     syswarn("SERVER cant open %s", path);
     return;
   }
 
-#if defined(HTML_STATUS)
-  /* HTML Header */
+  /* HTML header. */
+  if (innconf->htmlstatus) {
+    fprintf(F, "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n");
+    fprintf(F, "<meta http-equiv=\"refresh\" content=\"%lu\">\n",
+            innconf->status < MIN_REFRESH ? MIN_REFRESH : innconf->status);
+    fprintf(F, "<title>%s: incoming feeds</title>\n", innconf->pathhost);
+    fprintf(F, "</head>\n<body>\n<pre>\n");
+  }
 
-  fprintf (F,"<HTML>\n<HEAD>\n<META HTTP-EQUIV=\"Refresh\" CONTENT=\"%lu;\">\n",
-	   innconf->status < MIN_REFRESH ? MIN_REFRESH : innconf->status);
-  fprintf (F, "<TITLE>%s: incoming feeds</TITLE>\n", innconf->pathhost);
-  fprintf (F, "</HEAD>\n<BODY>\n<PRE>\n") ;
-#endif /* defined(HTML_STATUS) */
-
   fprintf (F, "%s\n", INN_VERSION_STRING);
   fprintf (F, "pid %d started %s\n", (int) getpid(), start_time);
 
@@ -385,10 +379,10 @@
     status = tmp;
   }
 
-#if defined(HTML_STATUS)
-  /* HTML Footer */
-  fprintf (F,"</PRE>\n</BODY>\n</HTML>\n");
-#endif /* defined(HTML_STATUS) */
+  /* HTML footer. */
+  if (innconf->htmlstatus) {
+    fprintf (F, "</pre>\n</body>\n</html>\n");
+  }
 
   Fclose(F);
   free(path);

Modified: lib/innconf.c
===================================================================
--- lib/innconf.c	2011-01-23 09:56:16 UTC (rev 9158)
+++ lib/innconf.c	2011-01-23 10:17:49 UTC (rev 9159)
@@ -159,6 +159,7 @@
     { K(datamovethreshold),       UNUMBER (8192) },
     { K(dontrejectfiltered),      BOOL   (false) },
     { K(hiscachesize),            UNUMBER  (256) },
+    { K(htmlstatus),              BOOL    (true) },
     { K(icdsynccount),            UNUMBER   (10) },
     { K(ignorenewsgroups),        BOOL   (false) },
     { K(incominglogfrequency),    UNUMBER  (200) },

Modified: samples/inn.conf.in
===================================================================
--- samples/inn.conf.in	2011-01-23 09:56:16 UTC (rev 9158)
+++ samples/inn.conf.in	2011-01-23 10:17:49 UTC (rev 9159)
@@ -153,6 +153,7 @@
 # Logging
 
 docnfsstat:                  false
+htmlstatus:                  true
 incominglogfrequency:        200
 logartsize:                  true
 logcancelcomm:               false




More information about the inn-committers mailing list