]> git.webhop.me Git - lcd4linux.git/commitdiff
raspi: Disabled unless explicitly enabled by user
authorjmccrohan <jmccrohan@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 15 May 2013 22:58:56 +0000 (22:58 +0000)
committerjmccrohan <jmccrohan@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Wed, 15 May 2013 22:58:56 +0000 (22:58 +0000)
Add a raspi enabled stanza to lcd4linux.conf file to enable:

Plugin raspi {
    enabled 1
}

Signed-off-by: Jonathan McCrohan <jmccrohan@gmail.com>
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1197 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

plugin_raspi.c

index c6e7e45c4d3471dc54b7964786d1a91f15850b4e..5932d08608af47d2abf5f5aa6529b5b039ae1001 100644 (file)
@@ -5,6 +5,7 @@
  *
  * Copyright (C) 2003 Michael Reinelt <michael@reinelt.co.at>
  * Copyright (C) 2013 Volker Gerng <v.gering@t-online.de>
+ * Copyright (C) 2013 Jonathan McCrohan <jmccrohan@gmail.com>
  * Copyright (C) 2004, 2005, 2006, 2007, 2008 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
  *
  * This file is part of LCD4Linux.
@@ -39,6 +40,7 @@
 /* these should always be included */
 #include "debug.h"
 #include "plugin.h"
+#include "cfg.h"
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -64,6 +66,8 @@
 #define strings(a, b) "_cat(a,b)"
 
 
+static char Section[] = "Plugin:raspi";
+static int plugin_enabled;
 char tmpstr[128];
 
 
@@ -132,6 +136,17 @@ static void my_cputemp(RESULT * result)
 /* MUST NOT be declared 'static'! */
 int plugin_init_raspi(void)
 {
+    /* Check if raspi plugin section exists in config file */
+    if (cfg_number(Section, "enabled", 0, 0, 1, &plugin_enabled) < 1) {
+       plugin_enabled = 0;
+    }
+
+    /* Disable plugin unless it is explicitly enabled */
+    if (plugin_enabled != 1) {
+       info("[raspi] WARNING: Plugin is not enabled! (set 'enabled 1' to enable this plugin)");
+       return 0;
+    }
+
     char checkFile[128];
 
     snprintf(checkFile, sizeof(checkFile), "%s%s", RASPI_TEMP_PATH, RASPI_TEMP_IDFILE);