aboutsummaryrefslogtreecommitdiffstats
path: root/filter/filter-xml.h
blob: a2e0cfada040c5ec9f10d7bc5cb627cdb37ad92d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

#ifndef _FILTER_XML_H
#define _FILTER_XML_H

#include <glib.h>
#include <gnome-xml/tree.h>

#include "filter-arg.h"

enum filter_xml_token {
    FILTER_XML_TEXT=0,
    FILTER_XML_RULE,
    FILTER_XML_CODE,
    FILTER_XML_DESC,
    FILTER_XML_RULESET,
    FILTER_XML_OPTION,
    FILTER_XML_OPTIONRULE,
    FILTER_XML_OPTIONSET,
    FILTER_XML_OPTIONVALUE,
    FILTER_XML_SOURCE,
    FILTER_XML_SEND,
    FILTER_XML_RECEIVE,
    FILTER_XML_ADDRESS,
    FILTER_XML_FOLDER,
    FILTER_XML_NAME,
    FILTER_XML_MATCH,
    FILTER_XML_ACTION,
    FILTER_XML_EXCEPT
};

struct filter_desc {
    int type;
    char *data;
    char *varname;      /* for named types */
    int vartype;
};

struct filter_rule {
    int type;
    char *name;
    char *code;
    GList *description;
};

struct filter_optionrule {
    struct filter_rule *rule;
    GList *args;        /* FilterArg objects */
};

struct filter_option {
    int type;       /* 'send' 'receive'? */
    GList *description; /* filter_desc */
    GList *options;     /* option_rule */
};

GList *filter_load_ruleset(xmlDocPtr doc);
GList *filter_load_optionset(xmlDocPtr doc, GList *rules);
xmlNodePtr filter_write_optionset(xmlDocPtr doc, GList *optionl);

/* callbacks for searching GLists of various types */
int filter_find_rule(struct filter_rule *a, char *name);
int filter_find_arg(FilterArg *a, char *name);

/* utility functions */
struct filter_optionrule *filter_clone_optionrule(struct filter_optionrule *or);
void filter_clone_optionrule_free(struct filter_optionrule *or);
struct filter_optionrule *filter_optionrule_new_from_rule(struct filter_rule *rule);

#endif /* ! _FILTER_XML_H */