summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2012-01-20 21:49:19 (UTC)
committer Michael Krelin <hacker@klever.net>2012-01-20 21:49:19 (UTC)
commit8e34d78443b8b53e90900fc9e2f7b4d7366596b0 (patch) (side-by-side diff)
tree21017b3ef5f3be00b96814b841aa605a645b6ef7
parent2c469d2d891899dbb51a6125fec3980dac6a7ec0 (diff)
downloadiii-8e34d78443b8b53e90900fc9e2f7b4d7366596b0.zip
iii-8e34d78443b8b53e90900fc9e2f7b4d7366596b0.tar.gz
iii-8e34d78443b8b53e90900fc9e2f7b4d7366596b0.tar.bz2
initialize config's "cfg" to null
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/eyekinfig.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/eyekinfig.cc b/src/eyekinfig.cc
index 6dde7b2..79cec80 100644
--- a/src/eyekinfig.cc
+++ b/src/eyekinfig.cc
@@ -1,32 +1,32 @@
#include <cassert>
#include <stdexcept>
#include <autosprintf.h>
#include "eyekinfig.h"
#include "config.h"
-eyekinfig_t::eyekinfig_t(const std::string& ma) : macaddress(ma) {
+eyekinfig_t::eyekinfig_t(const std::string& ma) : macaddress(ma), cfg(0) {
try {
static cfg_opt_t opts[] = {
CFG_STR((char*)"targetdir",(char*)"/var/lib/" PACKAGE "/%s",CFGF_NONE),
CFG_STR((char*)"uploadkey",(char*)"",CFGF_NONE),
CFG_STR((char*)"on-start-session",(char*)"",CFGF_NONE),
CFG_STR((char*)"on-upload-photo",(char*)"",CFGF_NONE),
CFG_STR((char*)"on-mark-last-photo-in-roll",(char*)"",CFGF_NONE),
CFG_INT((char*)"umask",022,CFGF_NONE),
CFG_END()
};
cfg = cfg_init(opts,CFGF_NONE);
if(!cfg)
throw std::runtime_error("failed to cfg_init()");
std::string::size_type ls = macaddress.rfind('/');
std::string cf = gnu::autosprintf( EYEKIN_CONF_DIR "/%s.conf",
macaddress.c_str()+((ls==std::string::npos)?0:ls+1) );
int r = cfg_parse(cfg,cf.c_str());
if(r != CFG_SUCCESS) {
cfg_free(cfg); cfg=0;
if(CFG_FILE_ERROR) throw std::runtime_error(gnu::autosprintf("failed to open configuration file '%s'",cf.c_str()));
throw std::runtime_error(gnu::autosprintf("failed to parse configuration file '%s'",cf.c_str()));
}
}catch(...) {
if(cfg) cfg_free(cfg), cfg=0;