aboutsummaryrefslogtreecommitdiffstats
path: root/lcd4linux.c
diff options
context:
space:
mode:
Diffstat (limited to 'lcd4linux.c')
-rw-r--r--lcd4linux.c88
1 files changed, 69 insertions, 19 deletions
diff --git a/lcd4linux.c b/lcd4linux.c
index 0fc3d15..842f653 100644
--- a/lcd4linux.c
+++ b/lcd4linux.c
@@ -1,11 +1,10 @@
-/* $Id: lcd4linux.c 783 2007-03-22 06:10:36Z michael $
- * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/lcd4linux.c $
- * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/lcd4linux.c $
+/* $Id: lcd4linux.c 1106 2010-02-07 14:03:46Z mzuther $
+ * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/lcd4linux.c $
*
* LCD4Linux
*
- * Copyright (C) 1999, 2000, 2001, 2002, 2003 Michael Reinelt <reinelt@eunet.at>
- * Copyright (C) 2004, 2005, 2006, 2007 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
+ * Copyright (C) 1999, 2000, 2001, 2002, 2003 Michael Reinelt <michael@reinelt.co.at>
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
*
* This file is part of LCD4Linux.
*
@@ -35,6 +34,8 @@
#include <errno.h>
#include <signal.h>
#include <time.h>
+#include <sys/types.h> /* umask() */
+#include <sys/stat.h> /* umask() */
#include "svn_version.h"
#include "cfg.h"
@@ -44,10 +45,11 @@
#include "udelay.h"
#include "drv.h"
#include "timer.h"
+#include "timer_group.h"
#include "layout.h"
#include "plugin.h"
#include "thread.h"
-
+#include "event.h"
#include "widget.h"
#include "widget_timer.h"
@@ -58,7 +60,8 @@
#define PIDFILE "/var/run/lcd4linux.pid"
static char *release = "LCD4Linux " VERSION "-" SVN_VERSION;
-static char *copyright = "Copyright (C) 2005, 2006, 2007 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>";
+static char *copyright =
+ "Copyright (C) 2005, 2006, 2007, 2008, 2009 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>";
static char **my_argv;
extern char *output;
@@ -69,10 +72,34 @@ static void usage(void)
{
printf("%s\n", release);
printf("%s\n", copyright);
- printf("usage: lcd4linux [-h]\n");
- printf(" lcd4linux [-l]\n");
- printf(" lcd4linux [-c key=value] [-i] [-f config-file] [-v] [-p pid-file]\n");
- printf(" lcd4linux [-c key=value] [-F] [-f config-file] [-o output-file] [-q] [-v]\n");
+ printf("\n");
+ printf("usage:\n");
+ printf(" lcd4linux [-h]\n");
+ printf(" lcd4linux [-l]\n");
+ printf(" lcd4linux [-c key=value] [-i] [-f config-file] [-v] [-p pid-file]\n");
+ printf(" lcd4linux [-c key=value] [-F] [-f config-file] [-o output-file] [-q] [-v]\n");
+ printf("\n");
+ printf("options:\n");
+ printf(" -h help\n");
+ printf(" -l list available display drivers and plugins\n");
+ printf(" -c <key>=<value> overwrite entries from the config-file\n");
+ printf(" -i enter interactive mode (after display initialisation)\n");
+ printf(" -ii enter interactive mode (before display initialisation)\n");
+ printf(" -f <config-file> use configuration from <config-file> instead of /etc/lcd4linux.conf\n");
+ printf(" -v generate info messages\n");
+ printf(" -vv generate debugging messages\n");
+ printf(" -p <pid-file> specify a different pid-file location (default is /var/run/lcd4linux.pid)\n");
+ printf(" -F do not fork and detach (run in foreground)\n");
+ printf(" -o <output-file> write picture to file (raster driver only)\n");
+ printf(" -q suppress startup and exit splash screen\n");
+#ifdef WITH_X11
+ printf("special X11 options:\n");
+ printf(" -display <X11 display name> preceeds X connection given in $DISPLAY\n");
+ printf(" -synchronous use synchronized communication with X server (for debugging)\n");
+ printf("\n");
+ printf("\n");
+ printf("\n");
+#endif
}
static void interactive_mode(void)
@@ -187,6 +214,7 @@ int main(int argc, char *argv[])
int c;
int quiet = 0;
int interactive = 0;
+ int list_mode = 0;
int pid;
/* save arguments for restart */
@@ -203,6 +231,13 @@ int main(int argc, char *argv[])
running_foreground = 0;
running_background = 0;
+#ifdef WITH_X11
+ drv_X11_parseArgs(&argc, argv);
+ if (argc != thread_argc) {
+ /* info() will not work here because verbose level is not known */
+ printf("recognized special X11 parameters\n");
+ }
+#endif
while ((c = getopt(argc, argv, "c:Ff:hilo:qvp:")) != EOF) {
switch (c) {
@@ -225,10 +260,8 @@ int main(int argc, char *argv[])
interactive++;
break;
case 'l':
- printf("%s\n", release);
- printf("%s\n", copyright);
- drv_list();
- exit(0);
+ list_mode++;
+ break;
case 'o':
output = optarg;
break;
@@ -256,16 +289,31 @@ int main(int argc, char *argv[])
running_foreground = 1;
}
- info("Version " VERSION "-" SVN_VERSION " starting");
+ if (list_mode > 0) {
+ printf("%s\n", release);
+ printf("%s\n", copyright);
+ printf("\n");
+ drv_list();
+ printf("\n");
+ plugin_list();
+ printf("\n");
+ exit(0);
+ }
+
+ info("%s starting", release);
if (!running_foreground && (my_argv[0] == NULL || my_argv[0][0] != '/')) {
info("invoked without full path; restart may not work!");
}
- if (cfg_init(cfg) == -1)
+ if (cfg_init(cfg) == -1) {
+ error("Error reading configuration. Exit!");
exit(1);
+ }
- if (plugin_init() == -1)
+ if (plugin_init() == -1) {
+ error("Error initializing plugins. Exit!");
exit(1);
+ }
display = cfg_get(NULL, "Display", NULL);
if (display == NULL || *display == '\0') {
@@ -316,6 +364,7 @@ int main(int argc, char *argv[])
debug("initializing driver %s", driver);
if (drv_init(section, driver, quiet) == -1) {
+ error("Error initializing driver %s: Exit!", driver);
pid_exit(pidfile);
exit(1);
}
@@ -356,7 +405,7 @@ int main(int argc, char *argv[])
struct timespec delay;
if (timer_process(&delay) < 0)
break;
- nanosleep(&delay, NULL);
+ event_process(&delay);
}
debug("leaving main loop");
@@ -365,6 +414,7 @@ int main(int argc, char *argv[])
pid_exit(pidfile);
cfg_exit();
plugin_exit();
+ timer_exit_group();
timer_exit();
if (got_signal == SIGHUP) {