File: engine.h

package info (click to toggle)
mimetic 0.9.3-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,516 kB
  • ctags: 1,749
  • sloc: cpp: 11,182; sh: 7,902; makefile: 162
file content (55 lines) | stat: -rw-r--r-- 1,823 bytes parent folder | download | duplicates (10)
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
#ifndef _MM_ENGINE_H_
#define _MM_ENGINE_H_
#include <mimetic/mimetic.h>
#include <stack>
#include "mm.h"
#include "cmdline.h"

struct engine
{
    typedef mimetic::MimeEntity MimeEntity;
    typedef std::string string;
    typedef std::list<MimeEntity*> parts_hierarchy;
    engine(const command_line&);
    MimeEntity* match(MimeEntity&, int level = 0, parts_hierarchy* ph = 0);
private:
    enum { 
        match_type_none,
        match_type_exact, 
        match_type_regex,
        match_type_shell,
        // flags
        match_flag_case_insensitive     = 1 << 4,
        match_flag_perl_mode        = 1 << 5,
        // masks
        match_type_mask = 0x0F,
        match_flag_mask = 0xF0
    };
    void action_attach(MimeEntity&, parts_hierarchy*, const string& fqn);

    void action(MimeEntity&, parts_hierarchy*);
    int perl_regex_match(const string&, const string&, int);
    int match_filename(const string&, const string&);
    int posix_regex_match(const string&, const string&, int);

    int regex_match(const string&, const string&, int);
    int exact_match(const string&, const string&, int);
    int shell_match(const string&, const string&, int);
    int pattern_match(const string&, const string&, int);

    int pattern_field_match(const MimeEntity& me, const string&, int);
    int fixed_field_match(const MimeEntity&, const string&, const string&, int);

    int has_binary_attach(const MimeEntity&, const command_line_switch&);
    int has_field(const MimeEntity&, const command_line_switch&);
    int attach_filename(const MimeEntity&, const command_line_switch&);
    int field_match(const MimeEntity&, const command_line_switch&);

    string remove_external_blanks(const string&) const;
private:
    command_line m_cl;
    bool m_ignore_childs, m_pcre;
    int m_match_mode;
};

#endif