~ubuntu-branches/ubuntu/quantal/dovecot/quantal

« back to all changes in this revision

Viewing changes to sieve/src/lib-sieve/sieve-match.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short, Scott Kitterman
  • Date: 2010-06-22 10:33:51 UTC
  • mfrom: (1.13.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100622103351-ifbmnklp8kxrhb30
Tags: 1:1.2.12-0ubuntu1
* New upstream release:
  - deliver: Don't crash when a message with Auto-submitted: header gets
   rejected.
  - lib-storage: Fixed header searches to work correctly when there are
    multiple headers with same name.
  - dict client: Disconnect from dict server after 1 second of idling.
  - dict: If process crashed, it wasn't automatically restarted
  - dict file: If dict file's group permissions equal world permissions,
    don't try to change its gid.
  - maildir: Fixed a memory leak when copying with hardlinks.
  - maildir: Expunging last messages may have assert-crashed if their
    filenames had just changed.
 * Update sieve patch to 0.1.17
 * debian/dovecot-common.postinst: Add warning about expired certificate.
   (Debian Bug: #576455)
 * Silence lintian warnings.

 [Scott Kitterman]
 * Rename dovecot-postfix to mail-stack-delivery per server-maverick-mail-
   integration spec.
   - Update debian/rules
   - Convert existing package to a dummy package and add new binary in debian/control
   - Update maintainer scripts.
   - Move previously installed backups and config files to new package name
     space in preinst
   - Add new debian/mail-stack-delivery.prerm to handle downgrades
   - Rename debian/dovecot-postfix.* to debian/mail-stack-delivery.*

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 */
25
25
 
26
26
struct sieve_match_context *sieve_match_begin
27
 
(struct sieve_interpreter *interp, const struct sieve_match_type *mcht,
28
 
        const struct sieve_comparator *cmp,
 
27
(struct sieve_interpreter *interp, const struct sieve_match_type *mcht, 
 
28
        const struct sieve_comparator *cmp, 
29
29
        const struct sieve_match_key_extractor *kextract,
30
30
        struct sieve_coded_stringlist *key_list)
31
31
{
33
33
        pool_t pool;
34
34
 
35
35
        pool = pool_alloconly_create("sieve_match_context", 1024);
36
 
        mctx = p_new(pool, struct sieve_match_context, 1);
 
36
        mctx = p_new(pool, struct sieve_match_context, 1);  
37
37
 
38
38
        mctx->pool = pool;
39
39
        mctx->interp = interp;
59
59
        /* Reject unimplemented match-type */
60
60
        if ( mcht->def == NULL || mcht->def->match == NULL )
61
61
                return FALSE;
62
 
 
 
62
                                
63
63
        /* Match to all key values */
64
64
        if ( mcht->def->is_iterative ) {
65
65
                unsigned int key_index = 0;
66
66
                string_t *key_item = NULL;
67
67
                int ret = 0;
68
 
 
69
 
                while ( (ok=sieve_coded_stringlist_next_item(mctx->key_list, &key_item))
70
 
                        && key_item != NULL ) {
 
68
        
 
69
                while ( (ok=sieve_coded_stringlist_next_item(mctx->key_list, &key_item)) 
 
70
                        && key_item != NULL ) {                         
71
71
                        T_BEGIN {
72
72
                                if ( mctx->kextract != NULL && mcht->def->allow_key_extract ) {
73
73
                                        const struct sieve_match_key_extractor *kext = mctx->kextract;
74
74
                                        void *kctx;
75
 
 
 
75
                                
76
76
                                        if ( (ret=kext->init(&kctx, key_item)) > 0 ) {
77
77
                                                const char *key;
78
78
                                                size_t key_size;
79
 
 
80
 
                                                while ( (ret=kext->extract_key(kctx, &key, &key_size)) > 0 ) {
 
79
                                                                
 
80
                                                while ( (ret=kext->extract_key(kctx, &key, &key_size)) > 0 ) {                          
81
81
                                                        ret = mcht->def->match
82
82
                                                                (mctx, value, val_size, key, key_size, key_index);
83
 
 
 
83
                                                
84
84
                                                        if ( ret != 0 ) break;
85
85
                                                }
86
 
                                        }
 
86
                                        }  
87
87
                                } else {
88
 
                                        ret = mcht->def->match(mctx, value, val_size, str_c(key_item),
 
88
                                        ret = mcht->def->match(mctx, value, val_size, str_c(key_item), 
89
89
                                                        str_len(key_item), key_index);
90
90
                                }
91
91
                        } T_END;
92
 
 
 
92
                        
93
93
                        if ( ret != 0 )
94
94
                                break;
95
 
 
 
95
        
96
96
                        key_index++;
97
97
                }
98
98
 
99
 
                if ( !ok )
 
99
                if ( !ok ) 
100
100
                        return -1;
101
101
 
102
 
                if ( ret < 0 )
 
102
                if ( ret < 0 ) 
103
103
                        return ret;
104
104
                if ( ret > 0 )
105
105
                        return TRUE;
135
135
/*
136
136
 * Reading match operands
137
137
 */
138
 
 
 
138
 
139
139
bool sieve_match_dump_optional_operands
140
140
(const struct sieve_dumptime_env *denv, sieve_size_t *address, int *opt_code)
141
141
{
142
 
        if ( *opt_code != SIEVE_MATCH_OPT_END ||
 
142
        if ( *opt_code != SIEVE_MATCH_OPT_END || 
143
143
                sieve_operand_optional_present(denv->sbin, address) ) {
144
144
                do {
145
 
                        if ( !sieve_operand_optional_read(denv->sbin, address, opt_code) )
 
145
                        if ( !sieve_operand_optional_read(denv->sbin, address, opt_code) ) 
146
146
                                return FALSE;
147
147
 
148
148
                        switch ( *opt_code ) {
156
156
                                if ( !sieve_opr_match_type_dump(denv, address) )
157
157
                                        return FALSE;
158
158
                                break;
159
 
                        default:
 
159
                        default: 
160
160
                                return TRUE;
161
161
                        }
162
162
                } while ( *opt_code != SIEVE_MATCH_OPT_END );
163
163
        }
164
 
 
 
164
        
165
165
        return TRUE;
166
166
}
167
167
 
168
168
int sieve_match_read_optional_operands
169
169
(const struct sieve_runtime_env *renv, sieve_size_t *address, int *opt_code,
170
170
        struct sieve_comparator *cmp, struct sieve_match_type *mcht)
171
 
{
 
171
{        
172
172
        /* Handle any optional arguments */
173
 
        if ( *opt_code != SIEVE_MATCH_OPT_END ||
 
173
        if ( *opt_code != SIEVE_MATCH_OPT_END || 
174
174
                sieve_operand_optional_present(renv->sbin, address) ) {
175
175
                do {
176
176
                        if ( !sieve_operand_optional_read(renv->sbin, address, opt_code) ) {
179
179
                        }
180
180
 
181
181
                        switch ( *opt_code ) {
182
 
                        case SIEVE_MATCH_OPT_END:
 
182
                        case SIEVE_MATCH_OPT_END: 
183
183
                                break;
184
184
                        case SIEVE_MATCH_OPT_COMPARATOR:
185
185
                                if ( !sieve_opr_comparator_read(renv, address, cmp) ) {
198
198
                        }
199
199
                } while ( *opt_code != SIEVE_MATCH_OPT_END );
200
200
        }
201
 
 
 
201
        
202
202
        return SIEVE_EXEC_OK;
203
203
}
204
204