+#include <unistd.h>
#include <cstring>
#include <cstdio>
#include <iostream>
}
if (argc >= 2) conf = argv[1];
+ if (conf[0] != '/') {
+ char *cwd = get_current_dir_name();
+ conf = std::string(cwd) + "/" + conf;
+ free(cwd);
+ }
std::cout << "Config file: " << conf << std::endl;
try {
#include <getopt.h>
+#include <unistd.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
dmlite::Catalog* catalog = NULL;
//dmlite::PoolManager* poolManager = NULL;
dmlite::SecurityCredentials creds;
- char *dmlite_config = NULL, *user = NULL, *address = NULL, *path, *target;
+ char *user = NULL, *address = NULL, *path, *target;
+ std::string dmlite_config;
int opt;
bool safetyCheck = true;
address = strdup(optarg);
break;
case 'c':
- free(dmlite_config);
- dmlite_config = strdup(optarg);
+ dmlite_config = optarg;
break;
case 'h':
usage(argv[0]);
throw dmlite::DmException();
}
+ if (dmlite_config[0] != '/') {
+ char *cwd = get_current_dir_name();
+ dmlite_config = std::string(cwd) + "/" + dmlite_config;
+ free(cwd);
+ }
+
// load configuration
try {
- manager.loadConfiguration(dmlite_config ? : DMLITE_CONFIG_DEFAULT);
+ manager.loadConfiguration(dmlite_config.empty() ? DMLITE_CONFIG_DEFAULT : dmlite_config);
} catch (dmlite::DmException& e) {
std::cout << "Could not load the configuration file." << std::endl
<< "Reason: " << e.what() << std::endl;
delete stack;
} catch (dmlite::DmException& e) {
free(address);
- free(dmlite_config);
free(user);
delete stack;
return 1;
} catch (...) {
free(address);
- free(dmlite_config);
free(user);
delete stack;
throw;
}
free(address);
- free(dmlite_config);
free(user);
return 0;
}