Create struct that holds FTL related filenames

This commit is contained in:
DL6ER
2017-02-03 23:51:44 +01:00
parent 71ef5723e8
commit 6533043968
5 changed files with 20 additions and 8 deletions
+7
View File
@@ -47,6 +47,12 @@
#define SOCKETBUFFERLEN 1024
// Static structs
typedef struct {
const char* log;
const char* pid;
const char* port;
} FTLFileNamesStruct;
typedef struct {
const char* log;
const char* gravity;
@@ -112,6 +118,7 @@ typedef struct {
enum { QUERIES, FORWARDED, CLIENTS, DOMAINS };
logFileNamesStruct files;
FTLFileNamesStruct FTLfiles;
countersStruct counters;
queriesDataStruct *queries;
+1 -1
View File
@@ -13,7 +13,7 @@
bool test_singularity(void)
{
FILE *f;
if((f = fopen("/etc/pihole/FTL.pid", "r")) == NULL)
if((f = fopen(FTLfiles.pid, "r")) == NULL)
{
logg("WARNING: Unable to read PID from file.");
logg(" Cannot test if another FTL process is running!");
+2 -6
View File
@@ -13,13 +13,9 @@
void open_FTL_log(void)
{
// Open a log file in write mode.
if((logfile = fopen("/etc/pihole/FTL.log", "a+")) == NULL) {;
printf("FATAL: Opening of /etc/pihole/FTL.log failed!\n");
if((logfile = fopen(FTLfiles.log, "a+")) == NULL) {;
printf("FATAL: Opening of FTL log (%s) failed!\n",FTLfiles.log);
printf(" Make sure it exists and is writable using\n");
printf(" sudo touch /etc/pihole/FTL.log\n");
printf(" sudo touch /etc/pihole/FTL.port\n");
printf(" sudo touch /etc/pihole/FTL.pid\n");
printf(" sudo chown user:user /etc/pihole/FTL.*\n");
// Return failure in exit status
exit(1);
}
+1 -1
View File
@@ -154,7 +154,7 @@ void swrite(void)
void saveport(int port)
{
FILE *f;
if((f = fopen("/etc/pihole/FTL.port", "w+")) == NULL)
if((f = fopen(FTLfiles.port, "w+")) == NULL)
{
logg("WARNING: Unable to write used port to file.");
logg(" Continuing anyway (API might not find the port).");
+9
View File
@@ -10,6 +10,15 @@
#include "FTL.h"
FTLFileNamesStruct FTLfiles = {
"/etc/pihole/pihole-FTL.log",
"/etc/pihole/pihole-FTL.pid",
"/etc/pihole/pihole-FTL.port"
// "/var/log/pihole-FTL.log",
// "/var/run/pihole-FTL.pid",
// "/var/run/pihole-FTL.port"
};
logFileNamesStruct files = {
"/var/log/pihole.log",
"/etc/pihole/list.preEventHorizon",