clean-loggraph-extra:
rm -f src/graph/*.moc.cpp
-bin_lognet_SOURCES = src/net/lognet.cpp src/net/lognet.moc.cpp src/global/AppConfiguration.cpp
+bin_lognet_SOURCES = src/net/lognet.cpp src/net/lognet.moc.cpp
bin_lognet_CPPFLAGS = $(bin_lognet_CFLAGS)
bin_lognet_LDADD = $(bin_lognet_LIBS)
src/net/lognet.moc.cpp:
clean-lognet-extra:
rm -f src/net/*.moc.cpp
-bin_logker_SOURCES = src/kernel/kernel.cpp src/kernel/kernel.moc src/global/AppConfiguration.cpp
+bin_logker_SOURCES = src/kernel/kernel.cpp src/kernel/kernel.moc
bin_logker_CPPFLAGS = $(bin_logker_CFLAGS)
bin_logker_LDADD = $(bin_logker_LIBS)
src/kernel/kernel.moc:
+++ /dev/null
-#include "AppConfiguration.h"
-
-void AppConfiguration::error(config_t *cfg)
-{
- fprintf(stderr, "%s: In file %s, line %d\n",
- config_error_text(cfg),
- config_error_file(cfg),
- config_error_line(cfg));
-}
+++ /dev/null
-#include <libconfig.h>
-
-/**
- * Class for maintaining application configuration.
- */
-class AppConfiguration {
-protected:
-public:
- static void error(config_t *cfg);
-};
#include <netinet/in.h>
#include <libconfig.h>
-#include "AppConfiguration.h"
#define GPATH "loggr"
#define IPATH "logi"
exit(3);
}
/* File exists, so file has been locked. Release it. */
- fclose(file);
config_init(&cfg);
/* Read the file. If there is an error, report it and exit. */
- if(!config_read_file(&cfg, fname))
+ if(!config_read(&cfg, file))
{
- AppConfiguration::error(&cfg);
+ fprintf(stderr, "%s! In file %s, line %d\n",
+ config_error_text(&cfg),
+ config_error_file(&cfg),
+ config_error_line(&cfg));
config_destroy(&cfg);
+ fclose(file);
exit(3);/* from original code. */
}
if(!config_lookup_int(&cfg, "node_number", &NodeNumber))
{
- AppConfiguration::error(&cfg);
+ fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+ "Warning",
+ fname,
+ "node_number");
config_destroy(&cfg);
+ fclose(file);
exit(3);
}
ConType = (strcmp(str, "explicit") == 0) ? 1 : 2;
}
else {
- AppConfiguration::error(&cfg);
+ fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+ "Warning",
+ fname,
+ "type");
}
ConnectList.append(new ConnectEntry((char*)str));
}
else {
- AppConfiguration::error(&cfg);
+ fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+ "Warning",
+ fname,
+ "host");
}
if(config_lookup_string(&cfg, "progdir", &str)){
strncpy(progdir, str, 256);
}
else {
- AppConfiguration::error(&cfg);
+ fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+ "Warning",
+ fname,
+ "progdir");
}
if(config_lookup_string(&cfg, "homedir", &str)){
strncpy(HomeDir, str, 255);
}
else {
- AppConfiguration::error(&cfg);
+ fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+ "Warning",
+ fname,
+ "homedir");
}
config_destroy(&cfg);
+ fclose(file);
}
/* +++++++++++++++++++++++++++++++++++++++++++++++ */
#include <unistd.h>
#include <libconfig.h>
-#include "AppConfiguration.h"
#define REMOTE_PATH "REMOTE"
#define MAXLINKS 30
if (!file) {
fprintf(stderr, "Error: Cannot load configuration file %s!\n", fname);
write_at_console("Cannot load configuration file!");
+ fclose(file);
exit(3);
}
- /* File exists, so file has been locked. Release it. */
- fclose(file);
/* Read the file. If there is an error, report it and exit. */
- if(!config_read_file(&cfg, fname))
+ if(!config_read(&cfg, file))
{
- AppConfiguration::error(&cfg);
+ fprintf(stderr, "%s: In file %s, line %d\n",
+ config_error_text(&cfg),
+ config_error_file(&cfg),
+ config_error_line(&cfg));
config_destroy(&cfg);
+ fclose(file);
exit(3);/* from original code. */
}
if (MyNode==-1) {
write_at_console("Node number must be specified");
config_destroy(&cfg);
+ fclose(file);
exit(1);
};
}
else
{
- AppConfiguration::error(&cfg);
+ fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+ "Warning",
+ fname,
+ "node_number");
config_destroy(&cfg);
+ fclose(file);
exit(1);
}
to_connect++;
}
else {
- AppConfiguration::error(&cfg);
+ fprintf(stderr, "%s! In file %s, '%s' was not found.\n",
+ "Warning",
+ fname,
+ "host");
}
config_destroy(&cfg);
+ fclose(file);
if (k==0) all_connected=TRUE;
}