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