⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rulefile.h

📁 JK Proxy Project - Version 0.1 ------------------------------ This was going to be a proxy serve
💻 H
字号:
/*
+-----------------------------------------------------------------------------+
|                                                                             |
|   rulefile.h                                                                |
|   Last change: yyyy-mm-dd                                                   |
|                                                                             |
|   Author: Jan Krumsiek                                                      |
|   eMail:  proxy@krumsiek.com                                                |
|   Web:    http://www.krumsiek.com/proxy                                     |
|                                                                             |
|   Copyright 2003 - Jan Krumsiek                                             |
|   This source code can freely be modified and redistributed. No liability   |
|   whatsoever is taken by the author for any use of this software.           |
|                                                                             |
|   Description:                                                              |
|   Header file for rulefile.cpp. Various enums and structs needed for        |
|   rulefiles are declared in this file.                                      |
|                                                                             |
+-----------------------------------------------------------------------------+
*/

#ifndef _rulefile_h_
#define _rulefile_h_

// need to disable warning #4786 as Visual C++ causes over 100 warning messages
// when creating the STL map.
#pragma warning(disable:4786)

#include "proxymain.h"
#include <vector>
#include <map>
#include <string>

// enumerations

// this enums indicates if a rule is applied to a part of the header 
// or the body of a msg
enum RULE_FIELD {F_HEADER, F_BODY, F_SIZE};
// which type of string comparision will be used?
enum RULE_TYPE {R_UNKNOWN,
				R_CONTAINS, R_NOTCONTAINS,
				R_EQUALS, R_NOTEQUALS,
				R_PATTERN, R_NOTPATTERN};
// which action is taken if a rule matches?
enum RULE_ACTION {A_ISSPAM, A_PASS};
// what kind of command is the current line in rule file?
enum RULE_COMMAND {C_UNKNOWN, C_RULE, C_LIST, C_EMPTY};

// signature for a string comparison function
typedef int(*CHECKFUNC)(const char *,const char *);

// structure for a single rule
struct RULE {
	RULE_FIELD field;		// Type of field (header or body)
	CHARPTR fieldname;		// Name of filed (if type = header)

	CHECKFUNC compare;		// Pointer to comparison function
	bool negate;			// Negate compare funct result?
	
	bool islist;			// Does this rule use a list?
	void* value;			// Points to a list or to the string itsself
	RULE_ACTION action;		// Mark as spam or pass message?

};

// structure for a list of strings
struct LIST {
	CHARPTR* items;			// Array of pointers to strings
	UINT count;				// Number of elements
};

// typedefs
typedef std::vector<RULE*> RULESET;			// a set of rules
typedef std::vector<RULE*>* RULESETPTR;		// pointer to a set of rules
typedef std::map<std::string, LIST*> LISTMAP;		// a map if lists (key = name of list)
typedef std::map<std::string, LIST*>* LISTMAPPTR;	// pointer to a map of lists

// struct which represents a complete compiled rule file. this can
// be passed to the rule processor to check a message
struct RULEFILE {
	RULESETPTR rules;	// the set of rules
	LISTMAPPTR list;	// map of lists
};


// function prototypes (exported function)
RULEFILE* LoadRules(CHARPTR file);
void ReleaseRuleFile(RULEFILE* rulefile);


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -