1 /* $Id: prop.h,v 1.10 2015/06/16 12:27:29 manu Exp $ */
2 
3 /*
4  * Copyright (c) 2008-2012 Emmanuel Dreyfus
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *        This product includes software developed by Emmanuel Dreyfus
18  *
19  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
23  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29  * OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _PROP_H_
33 #define _PROP_H_
34 
35 #include "config.h"
36 
37 struct prop_data {
38 	char *upd_name;
39 	void *upd_data;
40 };
41 
42 struct acl_opnum_prop {
43 	enum operator aonp_op;
44 	enum { AONP_MSGSIZE, AONP_RCPTCOUNT, AONP_SPAMD } aonp_type;
45 	char *aonp_name;
46 };
47 
48 /* pop for PROP OP PROP */
49 struct acl_prop_pop {
50 	char *apop_rhs;
51 	enum operator apop_op;
52 	char *apop_lhs;
53 };
54 
55 struct prop {
56 	char *up_name;
57 	char *up_value;
58 	int up_flags;
59 	char *up_rcpt;
60 	LIST_ENTRY(prop) up_list;
61 };
62 
63 #define UP_CLEARPROP	0x04
64 #define UP_TMPPROP	0x08
65 #define UP_PLAINPROP	0x10
66 
67 void prop_push(char *, char *, int, struct mlfi_priv *);
68 void prop_clear(struct mlfi_priv *, int);
69 void prop_untmp(struct mlfi_priv *);
70 char *prop_byname(struct mlfi_priv *, char *);
71 int prop_rhsnum_validate(acl_data_t *, acl_stage_t,
72 			 struct acl_param *, struct mlfi_priv *);
73 int prop_lhsnum_validate(acl_data_t *, acl_stage_t,
74 			 struct acl_param *, struct mlfi_priv *);
75 int prop_pop_validate(acl_data_t *, acl_stage_t,
76 		      struct acl_param *, struct mlfi_priv *);
77 int prop_string_validate(acl_data_t *, acl_stage_t,
78 			 struct acl_param *, struct mlfi_priv *);
79 int prop_glob_validate(acl_data_t *, acl_stage_t,
80 		       struct acl_param *, struct mlfi_priv *);
81 int prop_regex_validate(acl_data_t *, acl_stage_t,
82 			struct acl_param *, struct mlfi_priv *);
83 int prop_body_validate(acl_data_t *, acl_stage_t,
84 		       struct acl_param *, struct mlfi_priv *);
85 int prop_header_validate(acl_data_t *, acl_stage_t,
86 			 struct acl_param *, struct mlfi_priv *);
87 
88 int prop_eqset_string(acl_data_t *, acl_stage_t,
89 		      struct acl_param *, struct mlfi_priv *);
90 int prop_eqrset_string(acl_data_t *, acl_stage_t,
91 		       struct acl_param *, struct mlfi_priv *);
92 int prop_incset_string(acl_data_t *, acl_stage_t,
93 		       struct acl_param *, struct mlfi_priv *);
94 int prop_incrset_string(acl_data_t *, acl_stage_t,
95 		        struct acl_param *, struct mlfi_priv *);
96 int prop_decset_string(acl_data_t *, acl_stage_t,
97 		       struct acl_param *, struct mlfi_priv *);
98 int prop_decrset_string(acl_data_t *, acl_stage_t,
99 		        struct acl_param *, struct mlfi_priv *);
100 int prop_eqset_prop(acl_data_t *, acl_stage_t,
101 		    struct acl_param *, struct mlfi_priv *);
102 int prop_eqrset_prop(acl_data_t *, acl_stage_t,
103 		     struct acl_param *, struct mlfi_priv *);
104 int prop_incset_prop(acl_data_t *, acl_stage_t,
105 		     struct acl_param *, struct mlfi_priv *);
106 int prop_incrset_prop(acl_data_t *, acl_stage_t,
107 		      struct acl_param *, struct mlfi_priv *);
108 int prop_decset_prop(acl_data_t *, acl_stage_t,
109 		     struct acl_param *, struct mlfi_priv *);
110 int prop_decrset_prop(acl_data_t *, acl_stage_t,
111 		      struct acl_param *, struct mlfi_priv *);
112 
113 char *prop_opnum_print(acl_data_t *, char *, size_t);
114 void prop_opnum_add(acl_data_t *, void *);
115 void prop_opnum_free(acl_data_t *);
116 
117 #endif /* _PROP_H_ */
118