RuleSet.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 #ifndef __RULESET_H__
00018 #define __RULESET_H__
00019 
00020 namespace oasys {
00021 
00026 struct RuleStorage {
00027     static const unsigned int MAX_RULES       = 128;
00028     static const unsigned int MAX_RULE_LENGTH = 256;
00029 
00030     struct Item {
00031         int  flags_;
00032         int  log_level_;
00033         int  priority_; // larger is higher priority
00034         char rule_[MAX_RULE_LENGTH];
00035     } items_[MAX_RULES];
00036 };
00037 
00038 //----------------------------------------------------------------------------
00044 class RuleSet {
00045 public:
00046     enum {
00048         PREFIX    = 1, 
00050         GLOB      = 2,
00051     };
00052 
00054     RuleSet(RuleStorage* rs);
00055     
00057     RuleStorage::Item* match_rule(char* rule);
00058  
00059     void add_prefix_rule(char* rule, int log_level);
00060     void add_glob_rule(char* rule, int log_level, int priority);
00061  
00062 private:
00063     RuleStorage* rules_;    
00064     unsigned int num_rules_;
00065 
00066     void add_rule(int flags, char* rule, int log_level, int priority_);
00067     bool do_match(char* rule, RuleStorage::Item* item);
00068 };
00069 
00070 } // namespace oasys
00071 
00072 
00073 #endif /* __RULESET_H__ */

Generated on Sat Sep 8 08:43:33 2007 for DTN Reference Implementation by  doxygen 1.5.3