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

« back to all changes in this revision

Viewing changes to pigeonhole/src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.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
/* Extension comparator-i;ascii-numeric
22
22
 
23
23
#include <ctype.h>
24
24
 
25
 
/* 
26
 
 * Forward declarations 
 
25
/*
 
26
 * Forward declarations
27
27
 */
28
28
 
29
29
static const struct sieve_operand_def my_comparator_operand;
30
30
 
31
31
const struct sieve_comparator_def i_ascii_numeric_comparator;
32
32
 
33
 
/* 
 
33
/*
34
34
 * Extension
35
35
 */
36
36
 
37
37
static bool ext_cmp_i_ascii_numeric_validator_load
38
38
        (const struct sieve_extension *ext, struct sieve_validator *validator);
39
39
 
40
 
const struct sieve_extension_def comparator_i_ascii_numeric_extension = { 
41
 
        "comparator-i;ascii-numeric", 
42
 
        NULL, NULL,
43
 
        ext_cmp_i_ascii_numeric_validator_load,
44
 
        NULL, NULL, NULL, NULL, NULL,
45
 
        SIEVE_EXT_DEFINE_NO_OPERATIONS, 
 
40
const struct sieve_extension_def comparator_i_ascii_numeric_extension = {
 
41
        .name = "comparator-i;ascii-numeric",
 
42
        .validator_load = ext_cmp_i_ascii_numeric_validator_load,
46
43
        SIEVE_EXT_DEFINE_OPERAND(my_comparator_operand)
47
44
};
48
45
 
59
56
 
60
57
static const struct sieve_extension_objects ext_comparators =
61
58
        SIEVE_EXT_DEFINE_COMPARATOR(i_ascii_numeric_comparator);
62
 
        
63
 
static const struct sieve_operand_def my_comparator_operand = { 
64
 
        "comparator-i;ascii-numeric", 
 
59
 
 
60
static const struct sieve_operand_def my_comparator_operand = {
 
61
        "comparator-i;ascii-numeric",
65
62
        &comparator_i_ascii_numeric_extension,
66
 
        0, 
 
63
        0,
67
64
        &sieve_comparator_operand_class,
68
65
        &ext_comparators
69
66
};
73
70
 */
74
71
 
75
72
/* Forward declarations */
76
 
 
 
73
 
77
74
static int cmp_i_ascii_numeric_compare
78
 
        (const struct sieve_comparator *cmp, 
 
75
        (const struct sieve_comparator *cmp,
79
76
                const char *val1, size_t val1_size, const char *val2, size_t val2_size);
80
77
 
81
78
/* Comparator object */
82
79
 
83
 
const struct sieve_comparator_def i_ascii_numeric_comparator = { 
 
80
const struct sieve_comparator_def i_ascii_numeric_comparator = {
84
81
        SIEVE_OBJECT("i;ascii-numeric", &my_comparator_operand, 0),
85
82
        SIEVE_COMPARATOR_FLAG_ORDERING | SIEVE_COMPARATOR_FLAG_EQUALITY,
86
83
        cmp_i_ascii_numeric_compare,
91
88
/* Comparator implementation */
92
89
 
93
90
static int cmp_i_ascii_numeric_compare
94
 
        (const struct sieve_comparator *cmp ATTR_UNUSED, 
 
91
        (const struct sieve_comparator *cmp ATTR_UNUSED,
95
92
                const char *val, size_t val_size, const char *key, size_t key_size)
96
 
{       
 
93
{
97
94
        const char *vend = val + val_size;
98
95
        const char *kend = key + key_size;
99
96
        const char *vp = val;
100
97
        const char *kp = key;
101
98
        int digits, i;
102
99
 
103
 
        /* RFC 4790: All input is valid; strings that do not start with a digit 
 
100
        /* RFC 4790: All input is valid; strings that do not start with a digit
104
101
         * represent positive infinity.
105
102
         */
106
103
        if ( !i_isdigit(*vp) ) {
114
111
                        return -1;
115
112
                }
116
113
        }
117
 
        
 
114
 
118
115
        /* Ignore leading zeros */
119
116
 
120
 
        while ( *vp == '0' && vp < vend )  
 
117
        while ( *vp == '0' && vp < vend )
121
118
                vp++;
122
119
 
123
 
        while ( *kp == '0' && kp < kend )  
 
120
        while ( *kp == '0' && kp < kend )
124
121
                kp++;
125
122
 
126
123
        /* Check whether both numbers are equally long in terms of digits */
129
126
        while ( vp < vend && kp < kend && i_isdigit(*vp) && i_isdigit(*kp) ) {
130
127
                vp++;
131
128
                kp++;
132
 
                digits++;       
 
129
                digits++;
133
130
        }
134
131
 
135
132
        if ( vp == vend || !i_isdigit(*vp) ) {
138
135
                        return -1;
139
136
                }
140
137
        } else {
141
 
                /* Value is greater */  
 
138
                /* Value is greater */
142
139
                return 1;
143
140
        }
144
141
 
157
154
                vp++;
158
155
                i++;
159
156
        }
160
 
                
 
157
 
161
158
        return 0;
162
159
}
163
160