Skip to content

Commit 0214ecb

Browse files
committed
Update settings code
After discussion with CaptainMurdoch, I re-wrote the precedence ordering and parsing of arguments. Before these changes this is how things worked: * Parse command line arguments * Read configuration file and set things that weren't already set via command line This caused the need to know whether a value was still the default, or if it had been set. This made it such that tri-states were needed (in an enum) instead of booleans and precedence ordering was strange. Now: * Try reading default settings file * Parse arguments, if "settings file" is given, read it at parse time This over-writes things as it goes, so it is possible to have settings in a settings file be over-written by simply putting them later in your args. This also allows for multiple configuration files to be read to set things. Example of settings file and over-written args: ./fppd --config-file set_paths.cfg -v 95 Example of multiple config files: ./fppd --config-file set_paths.cfg --config-file volume.cfg --verbose
1 parent 5d1b8bd commit 0214ecb

File tree

5 files changed

+184
-304
lines changed

5 files changed

+184
-304
lines changed

bin/fppd.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,13 @@ int FPPstatus=FPP_STATUS_IDLE;
2424

2525
int main(int argc, char *argv[])
2626
{
27+
loadSettings("/home/pi/media/settings");
28+
2729
// Parse our arguments first, override any defaults
2830
parseArguments(argc, argv);
2931

3032
printSettings();
3133

32-
// Now load things from our settings file, only load
33-
// things that haven't already been set by the command
34-
// line which should take presidence
35-
loadSettings(getSettingsFile());
36-
37-
printSettings();
38-
3934
// Start functioning
4035
if (getDaemonize())
4136
CreateDaemon();

bin/fppd.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ void CheckExistanceOfDirectoriesAndFiles();
77

88
enum fppModes {
99
PLAYER_MODE = 0,
10-
BRIDGE_MODE,
11-
DEFAULT_MODE
10+
BRIDGE_MODE
1211
};
1312

1413
#endif

bin/log.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ void _LogWrite(char *file, int line, const char *format, ...)
2020
tm.tm_hour,
2121
tm.tm_min,
2222
tm.tm_sec);
23-
if ( getVerbose() == FPP_TRUE )
23+
if ( getVerbose() )
2424
{
2525
fprintf(stdout, "%s %s:%d:", timeStr, file, line);
2626
va_start(arg, format);
2727
vfprintf(stdout, format, arg);
2828
va_end(arg);
2929
}
3030

31-
if ( getDaemonize() == FPP_TRUE )
31+
if ( getDaemonize() )
3232
{
3333
FILE *logFile;
3434

0 commit comments

Comments
 (0)