make HTML_STATUS configurable
Florian Schlichting
fschlich at CIS.FU-Berlin.DE
Fri Nov 19 15:14:43 UTC 2010
Hi,
there is a compile-time option (a define in innd/status.c) that
determines whether the status file that innd can write out is plain text
or wrapped in HTML header / footer. The default is to write an HTML
status, and as a user of a binary distribution (such as Debian), this
default is impossible to change.
The following patch makes this behaviour configurable from inn.conf,
defaulting to htmlstatus = true just like before.
Florian
diff --git a/doc/pod/inn.conf.pod b/doc/pod/inn.conf.pod
index 0b85533..487ed7b 100644
--- a/doc/pod/inn.conf.pod
+++ b/doc/pod/inn.conf.pod
@@ -1197,9 +1197,17 @@ default value.
=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<htmlstatus>
+
+Whether B<innd> should write the status report as HTML file or in plain text.
+The HTML status goes to I<pathhttp>/inn_status.html, while the plain text
+status is written to I<pathlog>/inn.status. The default is to write an HTML
+status file.
+
=item I<timer>
How frequently (in seconds) innd(8) should report performance timings to
diff --git a/include/inn/innconf.h b/include/inn/innconf.h
index e583572..32aff7e 100644
--- a/include/inn/innconf.h
+++ b/include/inn/innconf.h
@@ -153,6 +153,7 @@ struct innconf {
bool nnrpdoverstats; /* Log overview statistics? */
bool nntplinklog; /* Put storage token into the log? */
unsigned long status; /* Status file update interval */
+ bool htmlstatus; /* Write status file as HTML instead of plain text? */
char *stathist; /* Filename for history profiler outputs */
unsigned long timer; /* Performance monitoring interval */
diff --git a/innd/status.c b/innd/status.c
index a9ebb38..1c95083 100644
--- a/innd/status.c
+++ b/innd/status.c
@@ -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,24 +120,23 @@ STATUSsummary(void)
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 */
-
- 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) */
+ if (innconf->htmlstatus) {
+ 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");
+ }
fprintf (F, "%s\n", INN_VERSION_STRING);
fprintf (F, "pid %d started %s\n", (int) getpid(), start_time);
@@ -385,10 +378,10 @@ STATUSsummary(void)
status = tmp;
}
-#if defined(HTML_STATUS)
/* HTML Footer */
- fprintf (F,"</PRE>\n</BODY>\n</HTML>\n");
-#endif /* defined(HTML_STATUS) */
+ if (innconf->htmlstatus) {
+ fprintf (F,"</PRE>\n</BODY>\n</HTML>\n");
+ }
Fclose(F);
free(path);
diff --git a/lib/innconf.c b/lib/innconf.c
index faa24ee..93e1d5f 100644
--- a/lib/innconf.c
+++ b/lib/innconf.c
@@ -184,6 +184,7 @@ const struct config config_table[] = {
{ K(remembertrash), BOOL (true) },
{ K(stathist), STRING (NULL) },
{ K(status), UNUMBER (0) },
+ { K(htmlstatus), BOOL (true) },
{ K(verifycancels), BOOL (false) },
{ K(verifygroups), BOOL (false) },
{ K(wanttrash), BOOL (false) },
diff --git a/samples/inn.conf.in b/samples/inn.conf.in
index 4e021e2..eaec1aa 100644
--- a/samples/inn.conf.in
+++ b/samples/inn.conf.in
@@ -165,6 +165,7 @@ nnrpdoverstats: false
nntplinklog: false
#stathist:
status: 0
+htmlstatus: true
timer: 0
# System Tuning
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5557 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/inn-workers/attachments/20101119/bd1dc436/attachment.bin>
More information about the inn-workers
mailing list