RuleSet.h

Go to the documentation of this file.
00001 #ifndef __RULESET_H__
00002 #define __RULESET_H__
00003 
00004 namespace oasys {
00005 
00010 struct RuleStorage {
00011     static const unsigned int MAX_RULES       = 128;
00012     static const unsigned int MAX_RULE_LENGTH = 256;
00013 
00014     struct Item {
00015         int  flags_;
00016         int  log_level_;
00017         int  priority_; // larger is higher priority
00018         char rule_[MAX_RULE_LENGTH];
00019     } items_[MAX_RULES];
00020 };
00021 
00022 //----------------------------------------------------------------------------
00028 class RuleSet {
00029 public:
00030     enum {
00032         PREFIX    = 1, 
00034         GLOB      = 2,
00035     };
00036 
00038     RuleSet(RuleStorage* rs);
00039     
00041     RuleStorage::Item* match_rule(char* rule);
00042  
00043     void add_prefix_rule(char* rule, int log_level);
00044     void add_glob_rule(char* rule, int log_level, int priority);
00045  
00046 private:
00047     RuleStorage* rules_;    
00048     unsigned int num_rules_;
00049 
00050     void add_rule(int flags, char* rule, int log_level, int priority_);
00051     bool do_match(char* rule, RuleStorage::Item* item);
00052 };
00053 
00054 } // namespace oasys
00055 
00056 
00057 #endif /* __RULESET_H__ */

Generated on Fri Dec 22 14:48:00 2006 for DTN Reference Implementation by  doxygen 1.5.1