/* This file is part of SLD. Copyright (C) 2008 Sebastien LUTTRINGER SLD 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. SLD 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 SLD; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef DAEMON_HH # define DAEMON_HH # include "sld.hh" # include "sll/connection.hh" # include "options.hh" # include // ----------------------------------------------------------------------------- // SLDAEMON CLASS // ----------------------------------------------------------------------------- class SLDaemon { public: static const string version; static SLDaemon &Instance(); struct Job { Job() {} Job(int, const string &, time_t); int pid; string name; time_t start_time; bool operator()(const Job &a, const Job &b); }; inline bool verbose() const { return options.verbose == 2; } Options options; void run(); // friends functions friend void sigchild(int); friend void sigint(int); protected: // current socket Connection c_; // int socket_fd_; // FILE* socket_fs_; // pid list typedef std::set t_job; t_job jobs_; // Options functions void check_options() const; // network functions // void disconnect(); // void send(const char *data, size_t len, bool buf = true); // void send(const string str, bool buf = true); // void send(long int i); // void sendln(const string &s); // char *recv(size_t size); // void recv(size_t size, const string &filename); // char *recvln(); // void flush(); // protocol functions void auth(); // commmand functions void cmd_exit(); void cmd_version(); void cmd_list(); void cmd_status(); void cmd_killall(); void cmd_kill(const char *line); void cmd_exec(const char *line); void cmd_update(); void cmd_file(const char *line); // others functions string md5(const string &file) const; void recv2file(size_t size, const string &filename); void clean_dir(const string &dir) const; private: static SLDaemon *instance_; SLDaemon() {} ~SLDaemon() {} SLDaemon(const SLDaemon &) { assert(true); } SLDaemon &operator=(const SLDaemon &) { assert(true); return *instance_; } }; #endif