default to foreground=FALSE even without config file

This commit is contained in:
marschap
2006-11-19 14:33:01 +00:00
parent c910fa2987
commit 9b7fa552a3
5 changed files with 38 additions and 28 deletions
+5 -5
View File
@@ -54,7 +54,7 @@ char *progname = "lcdexec";
char * configfile = NULL; char * configfile = NULL;
char * address = NULL; char * address = NULL;
int port = UNSET_INT; int port = UNSET_INT;
int foreground_mode = UNSET_INT; int foreground = FALSE;
static int report_level = UNSET_INT; static int report_level = UNSET_INT;
static int report_dest = UNSET_INT; static int report_dest = UNSET_INT;
char *displayname = NULL; char *displayname = NULL;
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
CHAIN(error, connect_and_setup()); CHAIN(error, connect_and_setup());
CHAIN_END(error); CHAIN_END(error);
if(!foreground_mode) { if(foreground != TRUE) {
if (daemon(1,1) != 0) { if (daemon(1,1) != 0) {
report(RPT_ERR, "Error: daemonize failed"); report(RPT_ERR, "Error: daemonize failed");
} }
@@ -138,7 +138,7 @@ int process_command_line(int argc, char **argv)
} }
break; break;
case 'f': case 'f':
foreground_mode = 1; foreground = TRUE;
break; break;
case 'r': case 'r':
temp_int = strtol(optarg, &end, 0); temp_int = strtol(optarg, &end, 0);
@@ -200,8 +200,8 @@ int process_configfile(char *configfile)
? RPT_DEST_SYSLOG ? RPT_DEST_SYSLOG
: RPT_DEST_STDERR; : RPT_DEST_STDERR;
} }
if (foreground_mode == UNSET_INT) { if (foreground != TRUE) {
foreground_mode = config_get_bool(progname, "Foreground", 0, 0); foreground = config_get_bool(progname, "Foreground", 0, FALSE);
} }
if ((tmp = config_get_string(progname, "DisplayName", 0, NULL)) != NULL) if ((tmp = config_get_string(progname, "DisplayName", 0, NULL)) != NULL)
+11 -8
View File
@@ -1,22 +1,24 @@
/* /*
* lcdexec.c * lcdexec/menu.h
* This file is part of lcdexec, an LCDproc client. * This file is part of lcdexec, an LCDproc client.
* *
* This file is released under the GNU General Public License. Refer to the * This file is released under the GNU General Public License. Refer to the
* COPYING file distributed with this package. * COPYING file distributed with this package.
* *
* Copyright (c) 2002, Joris Robijn * Copyright (c) 2002, Joris Robijn
* Copyright (c) 2006, Peter Marschall
* *
*/ */
#include <stdio.h> #ifndef LCDEXEC_MENU_H
#include <unistd.h> #define LCDEXEC_MENU_H
#include <string.h>
#include "shared/str.h" #ifndef TRUE
#include "shared/report.h" # define TRUE 1
#include "shared/configfile.h" #endif
#include "shared/sockets.h" #ifndef FALSE
# define FALSE 0
#endif
typedef enum { typedef enum {
@@ -48,3 +50,4 @@ const char *menu_command(MenuEntry *me);
void menu_free(MenuEntry *me); void menu_free(MenuEntry *me);
void menu_dump(MenuEntry *me); void menu_dump(MenuEntry *me);
#endif
+6 -6
View File
@@ -108,7 +108,7 @@ static int islow = -1;
char *progname = "lcdproc"; char *progname = "lcdproc";
char *server = NULL; char *server = NULL;
int port = LCDPORT; int port = LCDPORT;
int foreground = UNSET_INT; int foreground = FALSE;
static int report_level = UNSET_INT; static int report_level = UNSET_INT;
static int report_dest = UNSET_INT; static int report_dest = UNSET_INT;
char *configfile = NULL; char *configfile = NULL;
@@ -301,7 +301,7 @@ main(int argc, char **argv)
lcd_cellwid = 5; lcd_cellwid = 5;
lcd_cellhgt = 8; lcd_cellhgt = 8;
if (foreground == 0) { if (foreground != TRUE) {
if (daemon(1,0) != 0) { if (daemon(1,0) != 0) {
fprintf(stderr, "Error: daemonize failed"); fprintf(stderr, "Error: daemonize failed");
return(EXIT_FAILURE); return(EXIT_FAILURE);
@@ -359,18 +359,18 @@ process_configfile(char *configfile)
port = config_get_int(progname, "Port", 0, LCDPORT); port = config_get_int(progname, "Port", 0, LCDPORT);
} }
if(report_level == UNSET_INT) { if (report_level == UNSET_INT) {
report_level = config_get_int(progname, "ReportLevel", 0, RPT_WARNING); report_level = config_get_int(progname, "ReportLevel", 0, RPT_WARNING);
} }
if(report_dest == UNSET_INT) { if (report_dest == UNSET_INT) {
if (config_get_bool(progname, "ReportToSyslog", 0, 0)) { if (config_get_bool(progname, "ReportToSyslog", 0, 0)) {
report_dest = RPT_DEST_SYSLOG; report_dest = RPT_DEST_SYSLOG;
} else { } else {
report_dest = RPT_DEST_STDERR; report_dest = RPT_DEST_STDERR;
} }
} }
if (foreground == UNSET_INT) { if (foreground != TRUE) {
foreground = config_get_bool(progname, "Foreground", 0, 0); foreground = config_get_bool(progname, "Foreground", 0, FALSE);
} }
if (islow < 0) { if (islow < 0) {
islow = config_get_int(progname, "Delay", 0, -1); islow = config_get_int(progname, "Delay", 0, -1);
+9 -9
View File
@@ -54,7 +54,7 @@ char *progname = "lcdvc";
char *configfile = UNSET_STR; char *configfile = UNSET_STR;
/* Variables set by config */ /* Variables set by config */
int foreground_mode = UNSET_INT; int foreground = FALSE;
static int report_level = UNSET_INT; static int report_level = UNSET_INT;
static int report_dest = UNSET_INT; static int report_dest = UNSET_INT;
char *vcsa_device = UNSET_STR; char *vcsa_device = UNSET_STR;
@@ -88,7 +88,7 @@ int main( int argc, char ** argv )
CHAIN( e, connect_and_setup() ); CHAIN( e, connect_and_setup() );
CHAIN_END( e ); CHAIN_END( e );
if (!foreground_mode) { if (foreground != TRUE) {
if (daemon(1,1) != 0) { if (daemon(1,1) != 0) {
report(RPT_ERR, "Error: daemonize failed"); report(RPT_ERR, "Error: daemonize failed");
} }
@@ -132,7 +132,7 @@ int process_command_line( int argc, char ** argv )
} }
break; break;
case 'f': case 'f':
foreground_mode = 1; foreground = TRUE;
break; break;
case 'r': case 'r':
temp_int = strtol(optarg, &end, 0); temp_int = strtol(optarg, &end, 0);
@@ -191,16 +191,16 @@ int process_configfile( char * configfile )
report_dest = RPT_DEST_STDERR; report_dest = RPT_DEST_STDERR;
} }
} }
if (foreground_mode == UNSET_INT) { if (foreground != TRUE) {
foreground_mode = config_get_bool(progname, "Foreground", 0, 0); foreground = config_get_bool(progname, "Foreground", 0, FALSE);
} }
vcs_device = strdup(config_get_string(progname, "vcsDevice", 0, "/dev/vcs")); vcs_device = strdup(config_get_string(progname, "vcsDevice", 0, "/dev/vcs"));
vcsa_device = strdup(config_get_string(progname, "vcsaDevice", 0, "/dev/vcsa")); vcsa_device = strdup(config_get_string(progname, "vcsaDevice", 0, "/dev/vcsa"));
keys[0] = strdup( config_get_string( progname, "UpKey", 0, "Up" )); keys[0] = strdup(config_get_string( progname, "UpKey", 0, "Up"));
keys[1] = strdup( config_get_string( progname, "DownKey", 0, "Down" )); keys[1] = strdup(config_get_string( progname, "DownKey", 0, "Down"));
keys[2] = strdup( config_get_string( progname, "LeftKey", 0, "Left" )); keys[2] = strdup(config_get_string( progname, "LeftKey", 0, "Left"));
keys[3] = strdup( config_get_string( progname, "RightKey", 0, "Right" )); keys[3] = strdup(config_get_string( progname, "RightKey", 0, "Right"));
return 0; return 0;
} }
+7
View File
@@ -9,6 +9,13 @@
#define UNSET_INT -1 #define UNSET_INT -1
#define UNSET_STR "\01" #define UNSET_STR "\01"
#ifndef TRUE
# define TRUE 1
#endif
#ifndef FALSE
# define FALSE 0
#endif
extern char *vcs_device; extern char *vcs_device;
extern char *vcsa_device; extern char *vcsa_device;