aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugin_fifo.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/plugin_fifo.c b/plugin_fifo.c
index 0d4a7d1..d181b97 100644
--- a/plugin_fifo.c
+++ b/plugin_fifo.c
@@ -1,7 +1,7 @@
/* $Id$
* $URL$
*
- * plugin template
+ * Fifo plugin
*
* Copyright (C) 2008 Michael Vogt <michu@neophob.com>
* Copyright (C) 2010 Mattia Jona-Lasinio <mjona@users.sourceforge.net>
@@ -25,7 +25,20 @@
*
*/
-/* define the include files you need */
+/*
+ * Configuration parameters:
+ *
+ * - FifoPath 'string' : use <string> as the fifo complete file path
+ * If absent use /tmp/lcd4linux.fifo)
+ *
+ * - FifoBufSize num : if the plugin is unable to determine the display size then
+ * set the size of the internal buffer to <num> characters
+ * otherwise use the display size (number of columns).
+ * If no display size is available and no FifoBufSize parameter
+ * is specified then arbitrarily set the internal buffer size
+ * to 80 characters.
+ */
+
#include "config.h"
#include <stdlib.h>
@@ -37,7 +50,6 @@
#include <sys/stat.h>
#include <signal.h>
-/* these should always be included */
#include "debug.h"
#include "plugin.h"
#include "cfg.h"
@@ -78,6 +90,13 @@ static int confFifo(struct FifoData *p)
path = cfg_get(fifosect, "FifoPath", string(FIFO_DEFAULT_PATH));
pathlen = strlen(path);
+ if (pathlen == 0) {
+ info("[FIFO] Invalid '%s.FifoPath' entry from '%s'. "
+ "Assuming "string(FIFO_DEFAULT_PATH), fifosect, cfg_source());
+ free(path);
+ path = strdup(string(FIFO_DEFAULT_PATH));
+ pathlen = strlen(path);
+ }
if (pathlen > FIFO_MAXPATH) {
error("[FIFO] Error: Too long '%s.FifoPath' entry from '%s'. "
"(MAX "string(FIFO_MAXPATH)" chars)", fifosect, cfg_source());
@@ -88,7 +107,7 @@ static int confFifo(struct FifoData *p)
disp = cfg_get(NULL, "Display", NULL);
if (disp == NULL) {
- error("[FIFO] Error: Could not get the Display name from '%s'.", cfg_source());
+ error("[FIFO] Error: Could not get the Display name from '%s'", cfg_source());
free(path);
return (-1);
}
@@ -105,21 +124,25 @@ static int confFifo(struct FifoData *p)
disp = cfg_get(sect, "Size", NULL);
if (disp != NULL) {
- info("[FIFO] Getting the buffer size from '%s.Size'.", sect);
- sscanf(disp, "%dx%*d", &p->msglen);
+ info("[FIFO] Getting the buffer size from '%s.Size'", sect);
+ if (sscanf(disp, "%dx%*d", &p->msglen) != 1) {
+ info("[FIFO] Could not determine the display size. "
+ "Assuming "string(FIFO_DEFAULT_BUFSIZE));
+ p->msglen = FIFO_DEFAULT_BUFSIZE;
+ }
+ free(disp);
} else {
info("[FIFO] Could not find a '%s.Size' entry.", sect);
if (cfg_number(fifosect, "FifoBufSize", FIFO_DEFAULT_BUFSIZE, 0, -1, &p->msglen) > 0) {
- info("[FIFO] Getting the buffer size from '%s.FifoBufSize'.", fifosect);
+ info("[FIFO] Getting the buffer size from '%s.FifoBufSize'", fifosect);
} else {
info("[FIFO] Could not find a valid '%s.FifoBufSize' entry. "
- "Assuming "string(FIFO_DEFAULT_BUFSIZE)".", fifosect);
+ "Assuming "string(FIFO_DEFAULT_BUFSIZE), fifosect);
p->msglen = FIFO_DEFAULT_BUFSIZE;
}
}
info("[FIFO] Read buffer size is '%d'", p->msglen);
free(sect);
- free(disp);
if ((p->msg = malloc(2+pathlen+p->msglen)) == NULL) {
error("[FIFO] Error: Memory allocation failed");
1-0/+10 2014-10-15Imported Upstream version 0+git20141009.d26b627upstream/0+git20141009.d26b627Jonathan McCrohan2010-11120/+159271 2014-07-23Release 0+git20140611.14bd6c7-1debian/0+git20140611.14bd6c7-1Jonathan McCrohan1-2/+2 2014-07-23New Upstream Snapshot (commit 14bd6c7)Jonathan McCrohan1-2/+3 2014-07-23Imported Upstream version 0+git20140611.14bd6c7upstream/0+git20140611.14bd6c7Jonathan McCrohan7-11/+60 2014-05-13New Upstream Snapshot (commit 1246b27)Jonathan McCrohan1-0/+6 2014-05-13Imported Upstream version 0+git20140512.1246b27upstream/0+git20140512.1246b27Jonathan McCrohan391-301/+3983 2014-04-05Release 0+git20140326.cfc2975-1debian/0+git20140326.cfc2975-1Jonathan McCrohan1-2/+2 2014-04-05d/control: update Homepage (upstream has moved from Gitweb to cgit)Jonathan McCrohan2-1/+2 2014-04-05New Upstream Snapshot (commit cfc2975)Jonathan McCrohan1-0/+6 2014-04-05Imported Upstream version 0+git20140326.cfc2975upstream/0+git20140326.cfc2975Jonathan McCrohan118-656/+877 2014-01-16Release 0+git20140107.1850cf8-1debian/0+git20140107.1850cf8-1Jonathan McCrohan1-2/+2 2014-01-16Update Standards Version to 3.9.5Jonathan McCrohan2-1/+9