Loading sls/trunk/Makefile.am +2 Changes for sls/trunk/Makefile.am: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ sls_SOURCES= src/sls.hh \ src/option.cc \ src/database.hh \ src/database.cc \ src/cron.hh \ src/cron.cc \ src/server.hh \ src/server.cc Loading sls/trunk/src/cron.cc +20 Changes for sls/trunk/src/cron.cc: 20 added lines, 0 removed lines. Original line number Diff line number Diff line /* This file is part of SLS. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLS; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sls.hh" #include "cron.hh" sls/trunk/src/cron.hh +22 Changes for sls/trunk/src/cron.hh: 22 added lines, 0 removed lines. Original line number Diff line number Diff line /* This file is part of SLS. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLS; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CRON_HH # define CRON_HH #endif sls/trunk/src/option.cc +44 −23 Changes for sls/trunk/src/option.cc: 44 added lines, 23 removed lines. Original line number Diff line number Diff line Loading @@ -29,9 +29,8 @@ Option::Option() { verbose = false; database = "/var/db/sls.db"; port = 18136; maxthread = 200; maxconn = 200; daemon = true; closefd = true; logfile = "/var/log/sls"; pidfile = "/var/lock/sls.pid"; } Loading @@ -47,11 +46,10 @@ void Option::usage(const char *name, ostream &out) const { << "-v | --verbose : Set verbose mode." << std::endl << "-V | --version : Print version and exit." << std::endl << "-p | --port p : sls listen on port p (def: 18136)." << std::endl << "-t | --max-thread p : Maximun number of thread (def: 200)." << std::endl << "-m | --max-conn p : Maximun number of connection (def: 200)." << std::endl << "-P | --pid-file : Path to pid file (def: /var/lock/sls.pid)." << std::endl << "-l | --log-file : Path to log file (def: /var/log/sls)." << std::endl << "-D | --debug : Run with verbose and not in daemon mode." << std::endl << "-n | --no-close : Don't close stdin,stdout and stderr." << std::endl; << "-D | --debug : Run with verbose and not in daemon mode." << std::endl; } /*! Loading @@ -69,16 +67,15 @@ Option &Option::load(int argc, char *argv[]) { {"verbose", 0, 0, 'v'}, {"version", 0, 0, 'V'}, {"port", 0, 0, 'p'}, {"max-thread", 0, 0, 't'}, {"max-conn", 0, 0, 'm'}, {"pid-file", 0, 0, 'P'}, {"log-file", 0, 0, 'l'}, {"debug", 0, 0, 'D'}, {"no-close", 0, 0, 'n'}, {0, 0, 0, 0}, }; int option; while ((option = getopt_long(argc, argv, "hvnVDd:p:P:l:t:", lopt, 0)) != -1) { while ((option = getopt_long(argc, argv, "hvnVDd:p:P:l:m:", lopt, 0)) != -1) { switch (option) { case 'h': usage(*argv, std::cout); Loading @@ -86,8 +83,8 @@ Option &Option::load(int argc, char *argv[]) { case 'p': port = atoi(optarg); break; case 't': maxthread = atoi(optarg); case 'm': maxconn = atoi(optarg); break; case 'd': database = optarg; Loading @@ -106,9 +103,6 @@ Option &Option::load(int argc, char *argv[]) { case 'v': verbose = true; break; case 'n': closefd = false; break; case '?': usage(*argv, std::cerr); exit(ERR_USAGE); Loading @@ -124,19 +118,46 @@ Option &Option::load(int argc, char *argv[]) { } Option &Option::loadenv() { // const char *senv; const char *senv; // Get log file path if ((senv = getenv("SLS_LOG_FILE")) != 0 && *senv != 0) logfile = senv; // Get pid file path if ((senv = getenv("SLS_PID_FILE")) != 0 && *senv != 0) pidfile = senv; // // Get history path // if ((senv = getenv("SLC_HISTORY_FILE")) != 0 && *senv != 0) // history_file = senv; // Get DB file path if ((senv = getenv("SLS_DB_FILE")) != 0 && *senv != 0) database = senv; // // Get history size // if ((senv = getenv("SLC_HISTORY_SIZE")) != 0 && *senv != 0) // history_size = atoi(senv); // Get port if ((senv = getenv("SLS_PORT")) != 0 && *senv != 0) port = atoi(senv); // // Get log size // if ((senv = getenv("SLC_LOG_SIZE")) != 0 && *senv != 0) // log_size = atoi(senv); // Get max connection if ((senv = getenv("SLS_MAX_CONN")) != 0 && *senv != 0) maxconn = atoi(senv); // Get debug state if ((senv = getenv("SLS_DEBUG")) != 0) { daemon = false; verbose = true; } // Get verbose state if ((senv = getenv("SLS_VERBOSE")) != 0) verbose = true; return *this; } void Option::print(ostream &s) const { s << "Database file: " << database << std::endl << "Log file: " << logfile << std::endl << "Pid file: " << pidfile << std::endl << "TCP Port: " << port << std::endl << "Max conn: " << maxconn << std::endl << "Debug mode: " << !daemon << std::endl; } sls/trunk/src/option.hh +2 −3 Changes for sls/trunk/src/option.hh: 2 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -27,18 +27,17 @@ struct Option { void usage(const char *name, ostream &out) const; friend ostream &operator<<(ostream &, const Option &); void print(ostream &s = std::cout) const; bool verbose; string database; // socket option int port; size_t maxthread; size_t maxconn; // daemon options bool daemon; bool closefd; string pidfile; string logfile; Loading Loading
sls/trunk/Makefile.am +2 Changes for sls/trunk/Makefile.am: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ sls_SOURCES= src/sls.hh \ src/option.cc \ src/database.hh \ src/database.cc \ src/cron.hh \ src/cron.cc \ src/server.hh \ src/server.cc Loading
sls/trunk/src/cron.cc +20 Changes for sls/trunk/src/cron.cc: 20 added lines, 0 removed lines. Original line number Diff line number Diff line /* This file is part of SLS. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLS; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "sls.hh" #include "cron.hh"
sls/trunk/src/cron.hh +22 Changes for sls/trunk/src/cron.hh: 22 added lines, 0 removed lines. Original line number Diff line number Diff line /* This file is part of SLS. Copyright (C) 2008 Sebastien LUTTRINGER <contact@seblu.net> SLS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLS; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef CRON_HH # define CRON_HH #endif
sls/trunk/src/option.cc +44 −23 Changes for sls/trunk/src/option.cc: 44 added lines, 23 removed lines. Original line number Diff line number Diff line Loading @@ -29,9 +29,8 @@ Option::Option() { verbose = false; database = "/var/db/sls.db"; port = 18136; maxthread = 200; maxconn = 200; daemon = true; closefd = true; logfile = "/var/log/sls"; pidfile = "/var/lock/sls.pid"; } Loading @@ -47,11 +46,10 @@ void Option::usage(const char *name, ostream &out) const { << "-v | --verbose : Set verbose mode." << std::endl << "-V | --version : Print version and exit." << std::endl << "-p | --port p : sls listen on port p (def: 18136)." << std::endl << "-t | --max-thread p : Maximun number of thread (def: 200)." << std::endl << "-m | --max-conn p : Maximun number of connection (def: 200)." << std::endl << "-P | --pid-file : Path to pid file (def: /var/lock/sls.pid)." << std::endl << "-l | --log-file : Path to log file (def: /var/log/sls)." << std::endl << "-D | --debug : Run with verbose and not in daemon mode." << std::endl << "-n | --no-close : Don't close stdin,stdout and stderr." << std::endl; << "-D | --debug : Run with verbose and not in daemon mode." << std::endl; } /*! Loading @@ -69,16 +67,15 @@ Option &Option::load(int argc, char *argv[]) { {"verbose", 0, 0, 'v'}, {"version", 0, 0, 'V'}, {"port", 0, 0, 'p'}, {"max-thread", 0, 0, 't'}, {"max-conn", 0, 0, 'm'}, {"pid-file", 0, 0, 'P'}, {"log-file", 0, 0, 'l'}, {"debug", 0, 0, 'D'}, {"no-close", 0, 0, 'n'}, {0, 0, 0, 0}, }; int option; while ((option = getopt_long(argc, argv, "hvnVDd:p:P:l:t:", lopt, 0)) != -1) { while ((option = getopt_long(argc, argv, "hvnVDd:p:P:l:m:", lopt, 0)) != -1) { switch (option) { case 'h': usage(*argv, std::cout); Loading @@ -86,8 +83,8 @@ Option &Option::load(int argc, char *argv[]) { case 'p': port = atoi(optarg); break; case 't': maxthread = atoi(optarg); case 'm': maxconn = atoi(optarg); break; case 'd': database = optarg; Loading @@ -106,9 +103,6 @@ Option &Option::load(int argc, char *argv[]) { case 'v': verbose = true; break; case 'n': closefd = false; break; case '?': usage(*argv, std::cerr); exit(ERR_USAGE); Loading @@ -124,19 +118,46 @@ Option &Option::load(int argc, char *argv[]) { } Option &Option::loadenv() { // const char *senv; const char *senv; // Get log file path if ((senv = getenv("SLS_LOG_FILE")) != 0 && *senv != 0) logfile = senv; // Get pid file path if ((senv = getenv("SLS_PID_FILE")) != 0 && *senv != 0) pidfile = senv; // // Get history path // if ((senv = getenv("SLC_HISTORY_FILE")) != 0 && *senv != 0) // history_file = senv; // Get DB file path if ((senv = getenv("SLS_DB_FILE")) != 0 && *senv != 0) database = senv; // // Get history size // if ((senv = getenv("SLC_HISTORY_SIZE")) != 0 && *senv != 0) // history_size = atoi(senv); // Get port if ((senv = getenv("SLS_PORT")) != 0 && *senv != 0) port = atoi(senv); // // Get log size // if ((senv = getenv("SLC_LOG_SIZE")) != 0 && *senv != 0) // log_size = atoi(senv); // Get max connection if ((senv = getenv("SLS_MAX_CONN")) != 0 && *senv != 0) maxconn = atoi(senv); // Get debug state if ((senv = getenv("SLS_DEBUG")) != 0) { daemon = false; verbose = true; } // Get verbose state if ((senv = getenv("SLS_VERBOSE")) != 0) verbose = true; return *this; } void Option::print(ostream &s) const { s << "Database file: " << database << std::endl << "Log file: " << logfile << std::endl << "Pid file: " << pidfile << std::endl << "TCP Port: " << port << std::endl << "Max conn: " << maxconn << std::endl << "Debug mode: " << !daemon << std::endl; }
sls/trunk/src/option.hh +2 −3 Changes for sls/trunk/src/option.hh: 2 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -27,18 +27,17 @@ struct Option { void usage(const char *name, ostream &out) const; friend ostream &operator<<(ostream &, const Option &); void print(ostream &s = std::cout) const; bool verbose; string database; // socket option int port; size_t maxthread; size_t maxconn; // daemon options bool daemon; bool closefd; string pidfile; string logfile; Loading