]> granicus.if.org Git - vnstat/commitdiff
fix image output --headertext not being applied to some output types, resolves #123
authorTeemu Toivola <git@humdi.net>
Mon, 4 Feb 2019 19:12:30 +0000 (21:12 +0200)
committerTeemu Toivola <git@humdi.net>
Mon, 4 Feb 2019 19:12:30 +0000 (21:12 +0200)
CHANGES
src/image.c

diff --git a/CHANGES b/CHANGES
index c4e68fed03c3b9bc41743056659cf80a2e6d56ea..bcfbb9e9d216e6b3daaae8ef56ea0ef9cc7fb423 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,7 @@
 
  - Fixed
    - O_CLOEXEC undeclared error when compiling with glibc older than 2.12
+   - Image output --headertext wasn't being applied to some output types
  - New
    - Detection of 32-bit / 64-bit kernel interface counters for improving
      traffic calculations in rollover situations, cfg: 64bitInterfaceCounters
index 3925e29cab66d45d657f3b6b4eab325b51691ccb..15dbb0165dfcd60d8e24b2c454bb80c0655839fe 100644 (file)
@@ -464,10 +464,14 @@ void drawhourly(IMAGECONTENT *ic, const int rate)
 
        colorinit(ic);
 
-       if (strcmp(ic->interface.name, ic->interface.alias) == 0 || strlen(ic->interface.alias) == 0) {
-               snprintf(buffer, 512, "%s / hourly", ic->interface.name);
+       if (strlen(ic->headertext)) {
+               strncpy_nt(buffer, ic->headertext, 65);
        } else {
-               snprintf(buffer, 512, "%s (%s) / hourly", ic->interface.alias, ic->interface.name);
+               if (strcmp(ic->interface.name, ic->interface.alias) == 0 || strlen(ic->interface.alias) == 0) {
+                       snprintf(buffer, 512, "%s / hourly", ic->interface.name);
+               } else {
+                       snprintf(buffer, 512, "%s (%s) / hourly", ic->interface.alias, ic->interface.name);
+               }
        }
 
        layoutinit(ic, buffer, width, height);
@@ -592,10 +596,14 @@ void drawlist(IMAGECONTENT *ic, const char *listname)
 
        colorinit(ic);
 
-       if (strcmp(ic->interface.name, ic->interface.alias) == 0 || strlen(ic->interface.alias) == 0) {
-               snprintf(buffer, 512, "%s / %s", ic->interface.name, titlename);
+       if (strlen(ic->headertext)) {
+               strncpy_nt(buffer, ic->headertext, 65);
        } else {
-               snprintf(buffer, 512, "%s (%s) / %s", ic->interface.alias, ic->interface.name, titlename);
+               if (strcmp(ic->interface.name, ic->interface.alias) == 0 || strlen(ic->interface.alias) == 0) {
+                       snprintf(buffer, 512, "%s / %s", ic->interface.name, titlename);
+               } else {
+                       snprintf(buffer, 512, "%s (%s) / %s", ic->interface.alias, ic->interface.name, titlename);
+               }
        }
 
        layoutinit(ic, buffer, width, height);