~ubuntu-branches/ubuntu/utopic/dovecot/utopic-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-08 09:35:49 UTC
  • mfrom: (4.1.35 sid)
  • Revision ID: package-import@ubuntu.com-20140108093549-i72o93pux8p0dlaf
Tags: 1:2.2.9-1ubuntu1
* Merge from Debian unstable, remaining changes:
  + Add mail-stack-delivery package:
    - Update d/rules
    - d/control: convert existing dovecot-postfix package to a dummy
      package and add new mail-stack-delivery package.
    - Update maintainer scripts.
    - Rename d/dovecot-postfix.* to debian/mail-stack-delivery.*
    - d/mail-stack-delivery.preinst: Move previously installed backups and
      config files to a new package namespace.
    - d/mail-stack-delivery.prerm: Added to handle downgrades.
  + Use Snakeoil SSL certificates by default:
    - d/control: Depend on ssl-cert.
    - d/dovecot-core.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - d/dovecot-core.ufw.profile: new ufw profile.
    - d/rules: install profile in dovecot-core.
    - d/control: dovecot-core - suggest ufw.
  + d/dovecot-core.dirs: Added usr/share/doc/dovecot-core
  + Add apport hook:
    - d/rules, d/source_dovecot.py
  + Add upstart job:
    - d/rules, d/dovecot-core.dovecot.upstart, d/control,
      d/dovecot-core.dirs, dovecot-imapd.{postrm, postinst, prerm},
      d/dovecot-pop3d.{postinst, postrm, prerm}.
      d/mail-stack-deliver.postinst: Convert init script to upstart.
  + Use the autotools-dev dh addon to update config.guess/config.sub for
    arm64.
* Dropped changes, included in Debian:
  - Update Dovecot name to reflect distribution in login greeting.
  - Update Drac plugin for >= 2.0.0 support.
* d/control: Drop dovecot-postfix package as its no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2002-2012 Pigeonhole authors, see the included COPYING file
 
1
/* Copyright (c) 2002-2013 Pigeonhole authors, see the included COPYING file
2
2
 */
3
3
 
4
4
#include "lib.h"
28
28
 
29
29
struct sieve_match_context *sieve_match_begin
30
30
(const struct sieve_runtime_env *renv,
31
 
        const struct sieve_match_type *mcht, 
 
31
        const struct sieve_match_type *mcht,
32
32
        const struct sieve_comparator *cmp)
33
33
{
34
34
        struct sieve_match_context *mctx;
35
35
        pool_t pool;
36
36
 
37
37
        /* Reject unimplemented match-type */
38
 
        if ( mcht->def == NULL || (mcht->def->match == NULL && 
 
38
        if ( mcht->def == NULL || (mcht->def->match == NULL &&
39
39
                        mcht->def->match_keys == NULL && mcht->def->match_key == NULL) )
40
40
                        return NULL;
41
41
 
42
42
        /* Create match context */
43
43
        pool = pool_alloconly_create("sieve_match_context", 1024);
44
 
        mctx = p_new(pool, struct sieve_match_context, 1);  
 
44
        mctx = p_new(pool, struct sieve_match_context, 1);
45
45
        mctx->pool = pool;
46
46
        mctx->runenv = renv;
47
47
        mctx->match_type = mcht;
79
79
        }
80
80
 
81
81
        /* Match to key values */
82
 
        
 
82
 
83
83
        sieve_stringlist_reset(key_list);
84
84
 
85
85
        if ( mctx->trace )
95
95
 
96
96
                /* Default key match loop */
97
97
                match = 0;
98
 
                while ( match == 0 && 
99
 
                        (ret=sieve_stringlist_next_item(key_list, &key_item)) > 0 ) {                           
 
98
                while ( match == 0 &&
 
99
                        (ret=sieve_stringlist_next_item(key_list, &key_item)) > 0 ) {
100
100
                        T_BEGIN {
101
101
                                match = mcht->def->match_key
102
102
                                        (mctx, value, value_size, str_c(key_item), str_len(key_item));
119
119
 
120
120
        if ( mctx->match_status < 0 || match < 0 )
121
121
                mctx->match_status = -1;
122
 
        else 
123
 
                mctx->match_status = 
 
122
        else
 
123
                mctx->match_status =
124
124
                        ( mctx->match_status > match ? mctx->match_status : match );
125
125
        return match;
126
126
}
140
140
        pool_unref(&(*mctx)->pool);
141
141
 
142
142
        sieve_runtime_trace(renv, SIEVE_TRLVL_MATCHING,
143
 
                "finishing match with result: %s", 
 
143
                "finishing match with result: %s",
144
144
                ( match > 0 ? "matched" : ( match < 0 ? "error" : "not matched" ) ));
145
145
        sieve_runtime_trace_ascend(renv);
146
146
 
149
149
 
150
150
int sieve_match
151
151
(const struct sieve_runtime_env *renv,
152
 
        const struct sieve_match_type *mcht, 
153
 
        const struct sieve_comparator *cmp, 
 
152
        const struct sieve_match_type *mcht,
 
153
        const struct sieve_comparator *cmp,
154
154
        struct sieve_stringlist *value_list,
155
 
        struct sieve_stringlist *key_list, 
 
155
        struct sieve_stringlist *key_list,
156
156
        int *exec_status)
157
157
{
158
158
        struct sieve_match_context *mctx;
171
171
 
172
172
        if ( mcht->def->match != NULL ) {
173
173
                /* Call match-type's match handler */
174
 
                match = mctx->match_status = 
175
 
                        mcht->def->match(mctx, value_list, key_list); 
 
174
                match = mctx->match_status =
 
175
                        mcht->def->match(mctx, value_list, key_list);
176
176
 
177
177
        } else {
178
178
                /* Default value match loop */
179
179
 
180
180
                match = 0;
181
 
                while ( match == 0 && 
 
181
                while ( match == 0 &&
182
182
                        (ret=sieve_stringlist_next_item(value_list, &value_item)) > 0 ) {
183
183
 
184
184
                        match = sieve_match_value
198
198
/*
199
199
 * Reading match operands
200
200
 */
201
 
 
 
201
 
202
202
int sieve_match_opr_optional_dump
203
203
(const struct sieve_dumptime_env *denv, sieve_size_t *address, int *opt_code)
204
204
{
245
245
        }
246
246
 
247
247
        if ( exec_status != NULL )
248
 
                *exec_status = SIEVE_EXEC_OK;                   
 
248
                *exec_status = SIEVE_EXEC_OK;
249
249
 
250
250
        while ( status == SIEVE_EXEC_OK ) {
251
251
                int opt;
252
252
 
253
253
                if ( (opt=sieve_opr_optional_read(renv, address, opt_code)) <= 0 ){
254
254
                        if ( opt < 0 && exec_status != NULL )
255
 
                                *exec_status = SIEVE_EXEC_BIN_CORRUPT;                          
 
255
                                *exec_status = SIEVE_EXEC_BIN_CORRUPT;
256
256
                        return opt;
257
257
                }
258
258
 
275
275
        }
276
276
 
277
277
        if ( exec_status != NULL )
278
 
                *exec_status = status;  
 
278
                *exec_status = status;
279
279
        return -1;
280
280
}
281
281