From 9f864f962e6456a803eda5de9c2a5c451f36edc9 Mon Sep 17 00:00:00 2001 From: imp Date: Sat, 26 Apr 2003 20:59:04 +0000 Subject: Create a new C++ header file called devd.hh which has all the class definitions in it. Begin to document the classes that we use, and how they interrelate (using comments that I can use with doxygen to automatically generate docs with). --- sbin/devd/devd.cc | 103 ++---------------------------------------------------- 1 file changed, 2 insertions(+), 101 deletions(-) (limited to 'sbin/devd/devd.cc') diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc index df9ba7f..2265604 100644 --- a/sbin/devd/devd.cc +++ b/sbin/devd/devd.cc @@ -56,7 +56,8 @@ __FBSDID("$FreeBSD$"); #include #include -#include "devd.h" +#include "devd.h" /* C compatible definitions */ +#include "devd.hh" /* C++ class definitions */ #define CF "/etc/devd.conf" #define SYSCTL "hw.bus.devctl_disable" @@ -88,106 +89,6 @@ delete_and_clear(vector &v) v.clear(); } -class config; - -class var_list -{ -public: - var_list() {} - virtual ~var_list() {} - void set_variable(const string &var, const string &val); - const string &get_variable(const string &var) const; - bool is_set(const string &var) const; - static const string bogus; - static const string nothing; -private: - map _vars; -}; - -class eps -{ -public: - eps() {} - virtual ~eps() {} - virtual bool do_match(config &) = 0; - virtual bool do_action(config &) = 0; -}; - -class match : public eps -{ -public: - match(config &, const char *var, const char *re); - virtual ~match(); - virtual bool do_match(config &); - virtual bool do_action(config &) { return true; } -private: - string _var; - string _re; - regex_t _regex; -}; - -class action : public eps -{ -public: - action(const char *cmd); - virtual ~action(); - virtual bool do_match(config &) { return true; } - virtual bool do_action(config &); -private: - string _cmd; -}; - -class event_proc -{ -public: - event_proc(); - virtual ~event_proc(); - int get_priority() const { return (_prio); } - void set_priority(int prio) { _prio = prio; } - void add(eps *); - bool matches(config &); - bool run(config &); -private: - int _prio; - vector _epsvec; -}; - -class config -{ -public: - config() : _pidfile("") { push_var_table(); } - virtual ~config() { reset(); } - void add_attach(int, event_proc *); - void add_detach(int, event_proc *); - void add_directory(const char *); - void add_nomatch(int, event_proc *); - void set_pidfile(const char *); - void reset(); - void parse(); - void drop_pidfile(); - void push_var_table(); - void pop_var_table(); - void set_variable(const char *var, const char *val); - const string &get_variable(const string &var); - const string expand_string(const string &var); - char *set_vars(char *); - void find_and_execute(char); -protected: - void sort_vector(vector &); - void parse_one_file(const char *fn); - void parse_files_in_dir(const char *dirname); - void expand_one(const char *&src, string &dst); - bool is_id_char(char); - bool chop_var(char *&buffer, char *&lhs, char *&rhs); -private: - vector _dir_list; - string _pidfile; - vector _var_list_table; - vector _attach_list; - vector _detach_list; - vector _nomatch_list; -}; - config cfg; event_proc::event_proc() : _prio(-1) -- cgit v1.1