Loading sld/README +1 −0 Original line number Diff line number Diff line Max command line size = 512 Max conf file line size = 2048 sld/TODO +0 −2 Original line number Diff line number Diff line Loading @@ -2,5 +2,3 @@ IMPROVMENTS: remove static magic MAX_LINE_SIZE in sscanf BUG: SLDaemon::binpath() ne recupere pas le bon nom pour le binaire en cours d'execution RELOAD return bad address during execl sld/examples/conffile 0 → 100644 +6 −0 Original line number Diff line number Diff line host=trinity pass=sex server=localhost port=18136 scriptdir=examples/scripts/ verbose=1 sld/examples/scripts/hello 0 → 100755 +4 −0 Original line number Diff line number Diff line #!/bin/bash echo "Hello World !" sld/src/daemon.cc +55 −9 Original line number Diff line number Diff line Loading @@ -28,11 +28,6 @@ SLDaemon &SLDaemon::Instance() { return *instance_; } SLDaemon::Options::Options() { this->port = 0; this->verbose = 3; } void SLDaemon::usage(const char *argv0) const { std::cerr << "usage: " << argv0 Loading Loading @@ -116,10 +111,42 @@ SLDaemon::Options *SLDaemon::getoptions(int argc, char *argv[]) const { } SLDaemon::Options *SLDaemon::getoptions(const string file) const { if (file == "") throw Error(ERR_BADPARAM, "Conf file not implemented"); throw Error(ERR_BADPARAM, "Conf file not implemented"); ifstream fs; char line[MAX_CONF_LINE_SIZE]; int i=0; char name[11], value[MAX_CONF_LINE_SIZE - 10 + 1]; SLDaemon::Options o; fs.open(file.c_str(), ifstream::in); if (!fs.is_open()) return 0; while (fs.good()) { fs.getline(line, MAX_CONF_LINE_SIZE); if (fs.eof()) break; sscanf(line, "%10[^=]=%2039s\n", name, value); //TODO: fix magic number if (!strcasecmp(name, "host")) o.login = value; else if (!strcasecmp(name, "pass")) o.pass = value; else if (!strcasecmp(name, "server")) o.server = value; else if (!strcasecmp(name, "port")) o.port = atoi(value); else if (!strcasecmp(name, "scriptdir")) o.scriptdir = value; else if (!strcasecmp(name, "verbose")) o.verbose = atoi(value); else std::cerr << "Invalid line " << i << ": " << line; } fs.close(); return new SLDaemon::Options(o); } void SLDaemon::applyoptions(const Options *opt) { Loading Loading @@ -711,6 +738,25 @@ string SLDaemon::md5(const string &file) const { return string(digest); } //****************************************************************************** // Class Options functions //****************************************************************************** SLDaemon::Options::Options() { this->port = 0; this->verbose = 3; } void SLDaemon::Options::print() { std::cout << "server: " << server << std::endl; std::cout << "port: " << port << std::endl; std::cout << "host login: " << login << std::endl; std::cout << "host pass: " << pass << std::endl; std::cout << "script directory: " << scriptdir << std::endl; std::cout << "configuration file: " << conffile << std::endl; std::cout << "verbose level: " << verbose << std::endl; } //****************************************************************************** // Class Job functions //****************************************************************************** Loading Loading
sld/README +1 −0 Original line number Diff line number Diff line Max command line size = 512 Max conf file line size = 2048
sld/TODO +0 −2 Original line number Diff line number Diff line Loading @@ -2,5 +2,3 @@ IMPROVMENTS: remove static magic MAX_LINE_SIZE in sscanf BUG: SLDaemon::binpath() ne recupere pas le bon nom pour le binaire en cours d'execution RELOAD return bad address during execl
sld/examples/conffile 0 → 100644 +6 −0 Original line number Diff line number Diff line host=trinity pass=sex server=localhost port=18136 scriptdir=examples/scripts/ verbose=1
sld/examples/scripts/hello 0 → 100755 +4 −0 Original line number Diff line number Diff line #!/bin/bash echo "Hello World !"
sld/src/daemon.cc +55 −9 Original line number Diff line number Diff line Loading @@ -28,11 +28,6 @@ SLDaemon &SLDaemon::Instance() { return *instance_; } SLDaemon::Options::Options() { this->port = 0; this->verbose = 3; } void SLDaemon::usage(const char *argv0) const { std::cerr << "usage: " << argv0 Loading Loading @@ -116,10 +111,42 @@ SLDaemon::Options *SLDaemon::getoptions(int argc, char *argv[]) const { } SLDaemon::Options *SLDaemon::getoptions(const string file) const { if (file == "") throw Error(ERR_BADPARAM, "Conf file not implemented"); throw Error(ERR_BADPARAM, "Conf file not implemented"); ifstream fs; char line[MAX_CONF_LINE_SIZE]; int i=0; char name[11], value[MAX_CONF_LINE_SIZE - 10 + 1]; SLDaemon::Options o; fs.open(file.c_str(), ifstream::in); if (!fs.is_open()) return 0; while (fs.good()) { fs.getline(line, MAX_CONF_LINE_SIZE); if (fs.eof()) break; sscanf(line, "%10[^=]=%2039s\n", name, value); //TODO: fix magic number if (!strcasecmp(name, "host")) o.login = value; else if (!strcasecmp(name, "pass")) o.pass = value; else if (!strcasecmp(name, "server")) o.server = value; else if (!strcasecmp(name, "port")) o.port = atoi(value); else if (!strcasecmp(name, "scriptdir")) o.scriptdir = value; else if (!strcasecmp(name, "verbose")) o.verbose = atoi(value); else std::cerr << "Invalid line " << i << ": " << line; } fs.close(); return new SLDaemon::Options(o); } void SLDaemon::applyoptions(const Options *opt) { Loading Loading @@ -711,6 +738,25 @@ string SLDaemon::md5(const string &file) const { return string(digest); } //****************************************************************************** // Class Options functions //****************************************************************************** SLDaemon::Options::Options() { this->port = 0; this->verbose = 3; } void SLDaemon::Options::print() { std::cout << "server: " << server << std::endl; std::cout << "port: " << port << std::endl; std::cout << "host login: " << login << std::endl; std::cout << "host pass: " << pass << std::endl; std::cout << "script directory: " << scriptdir << std::endl; std::cout << "configuration file: " << conffile << std::endl; std::cout << "verbose level: " << verbose << std::endl; } //****************************************************************************** // Class Job functions //****************************************************************************** Loading