~siretart/lcd4linux/debian

« back to all changes in this revision

Viewing changes to lcd4linux.c

  • Committer: Reinhard Tartler
  • Date: 2011-04-27 17:28:49 UTC
  • mfrom: (0.1.1 upstream)
  • Revision ID: siretart@tauware.de-20110427172849-mj5cj5a0igpcc9fn
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: lcd4linux.c 783 2007-03-22 06:10:36Z michael $
2
 
 * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/lcd4linux.c $
3
 
 * $URL: https://ssl.bulix.org/svn/lcd4linux/branches/0.10.1/lcd4linux.c $
 
1
/* $Id: lcd4linux.c 1106 2010-02-07 14:03:46Z mzuther $
 
2
 * $URL: https://ssl.bulix.org/svn/lcd4linux/trunk/lcd4linux.c $
4
3
 *
5
4
 * LCD4Linux
6
5
 *
7
 
 * Copyright (C) 1999, 2000, 2001, 2002, 2003 Michael Reinelt <reinelt@eunet.at>
8
 
 * Copyright (C) 2004, 2005, 2006, 2007 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
 
6
 * Copyright (C) 1999, 2000, 2001, 2002, 2003 Michael Reinelt <michael@reinelt.co.at>
 
7
 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
9
8
 *
10
9
 * This file is part of LCD4Linux.
11
10
 *
35
34
#include <errno.h>
36
35
#include <signal.h>
37
36
#include <time.h>
 
37
#include <sys/types.h>          /* umask() */
 
38
#include <sys/stat.h>           /* umask() */
38
39
 
39
40
#include "svn_version.h"
40
41
#include "cfg.h"
44
45
#include "udelay.h"
45
46
#include "drv.h"
46
47
#include "timer.h"
 
48
#include "timer_group.h"
47
49
#include "layout.h"
48
50
#include "plugin.h"
49
51
#include "thread.h"
50
 
 
 
52
#include "event.h"
51
53
#include "widget.h"
52
54
#include "widget_timer.h"
53
55
 
58
60
#define PIDFILE "/var/run/lcd4linux.pid"
59
61
 
60
62
static char *release = "LCD4Linux " VERSION "-" SVN_VERSION;
61
 
static char *copyright = "Copyright (C) 2005, 2006, 2007 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>";
 
63
static char *copyright =
 
64
    "Copyright (C) 2005, 2006, 2007, 2008, 2009 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>";
62
65
static char **my_argv;
63
66
extern char *output;
64
67
 
69
72
{
70
73
    printf("%s\n", release);
71
74
    printf("%s\n", copyright);
72
 
    printf("usage: lcd4linux [-h]\n");
73
 
    printf("       lcd4linux [-l]\n");
74
 
    printf("       lcd4linux [-c key=value] [-i] [-f config-file] [-v] [-p pid-file]\n");
75
 
    printf("       lcd4linux [-c key=value] [-F] [-f config-file] [-o output-file] [-q] [-v]\n");
 
75
    printf("\n");
 
76
    printf("usage:\n");
 
77
    printf(" lcd4linux [-h]\n");
 
78
    printf(" lcd4linux [-l]\n");
 
79
    printf(" lcd4linux [-c key=value] [-i] [-f config-file] [-v] [-p pid-file]\n");
 
80
    printf(" lcd4linux [-c key=value] [-F] [-f config-file] [-o output-file] [-q] [-v]\n");
 
81
    printf("\n");
 
82
    printf("options:\n");
 
83
    printf("  -h               help\n");
 
84
    printf("  -l               list available display drivers and plugins\n");
 
85
    printf("  -c <key>=<value> overwrite entries from the config-file\n");
 
86
    printf("  -i               enter interactive mode (after display initialisation)\n");
 
87
    printf("  -ii              enter interactive mode (before display initialisation)\n");
 
88
    printf("  -f <config-file> use configuration from <config-file> instead of /etc/lcd4linux.conf\n");
 
89
    printf("  -v               generate info messages\n");
 
90
    printf("  -vv              generate debugging messages\n");
 
91
    printf("  -p <pid-file>    specify a different pid-file location (default is /var/run/lcd4linux.pid)\n");
 
92
    printf("  -F               do not fork and detach (run in foreground)\n");
 
93
    printf("  -o <output-file> write picture to file (raster driver only)\n");
 
94
    printf("  -q               suppress startup and exit splash screen\n");
 
95
#ifdef WITH_X11
 
96
    printf("special X11 options:\n");
 
97
    printf("  -display <X11 display name>  preceeds X connection given in $DISPLAY\n");
 
98
    printf("  -synchronous                 use synchronized communication with X server (for debugging)\n");
 
99
    printf("\n");
 
100
    printf("\n");
 
101
    printf("\n");
 
102
#endif
76
103
}
77
104
 
78
105
static void interactive_mode(void)
187
214
    int c;
188
215
    int quiet = 0;
189
216
    int interactive = 0;
 
217
    int list_mode = 0;
190
218
    int pid;
191
219
 
192
220
    /* save arguments for restart */
203
231
    running_foreground = 0;
204
232
    running_background = 0;
205
233
 
 
234
#ifdef WITH_X11
 
235
    drv_X11_parseArgs(&argc, argv);
 
236
    if (argc != thread_argc) {
 
237
        /* info() will not work here because verbose level is not known */
 
238
        printf("recognized special X11 parameters\n");
 
239
    }
 
240
#endif
206
241
    while ((c = getopt(argc, argv, "c:Ff:hilo:qvp:")) != EOF) {
207
242
 
208
243
        switch (c) {
225
260
            interactive++;
226
261
            break;
227
262
        case 'l':
228
 
            printf("%s\n", release);
229
 
            printf("%s\n", copyright);
230
 
            drv_list();
231
 
            exit(0);
 
263
            list_mode++;
 
264
            break;
232
265
        case 'o':
233
266
            output = optarg;
234
267
            break;
256
289
        running_foreground = 1;
257
290
    }
258
291
 
259
 
    info("Version " VERSION "-" SVN_VERSION " starting");
 
292
    if (list_mode > 0) {
 
293
        printf("%s\n", release);
 
294
        printf("%s\n", copyright);
 
295
        printf("\n");
 
296
        drv_list();
 
297
        printf("\n");
 
298
        plugin_list();
 
299
        printf("\n");
 
300
        exit(0);
 
301
    }
 
302
 
 
303
    info("%s starting", release);
260
304
    if (!running_foreground && (my_argv[0] == NULL || my_argv[0][0] != '/')) {
261
305
        info("invoked without full path; restart may not work!");
262
306
    }
263
307
 
264
 
    if (cfg_init(cfg) == -1)
 
308
    if (cfg_init(cfg) == -1) {
 
309
        error("Error reading configuration. Exit!");
265
310
        exit(1);
 
311
    }
266
312
 
267
 
    if (plugin_init() == -1)
 
313
    if (plugin_init() == -1) {
 
314
        error("Error initializing plugins. Exit!");
268
315
        exit(1);
 
316
    }
269
317
 
270
318
    display = cfg_get(NULL, "Display", NULL);
271
319
    if (display == NULL || *display == '\0') {
316
364
 
317
365
    debug("initializing driver %s", driver);
318
366
    if (drv_init(section, driver, quiet) == -1) {
 
367
        error("Error initializing driver %s: Exit!", driver);
319
368
        pid_exit(pidfile);
320
369
        exit(1);
321
370
    }
356
405
        struct timespec delay;
357
406
        if (timer_process(&delay) < 0)
358
407
            break;
359
 
        nanosleep(&delay, NULL);
 
408
        event_process(&delay);
360
409
    }
361
410
 
362
411
    debug("leaving main loop");
365
414
    pid_exit(pidfile);
366
415
    cfg_exit();
367
416
    plugin_exit();
 
417
    timer_exit_group();
368
418
    timer_exit();
369
419
 
370
420
    if (got_signal == SIGHUP) {