~ubuntu-branches/ubuntu/trusty/dovecot/trusty-updates

« back to all changes in this revision

Viewing changes to pigeonhole/src/testsuite/testsuite-substitutions.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-08 09:35:49 UTC
  • mfrom: (1.15.3) (96.1.1 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20140108093549-814nkqdcxfbvgktg
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"
17
17
/*
18
18
 * Forward declarations
19
19
 */
20
 
 
 
20
 
21
21
void testsuite_opr_substitution_emit
22
22
        (struct sieve_binary_block *sblock, const struct testsuite_substitution *tsub,
23
23
                const char *param);
24
 
                        
 
24
 
25
25
/*
26
26
 * Testsuite substitutions
27
27
 */
28
 
 
 
28
 
29
29
/* FIXME: make this extendible */
30
30
 
31
31
enum {
39
39
};
40
40
 
41
41
static const unsigned int substitutions_count = N_ELEMENTS(substitutions);
42
 
 
 
42
 
43
43
static inline const struct testsuite_substitution_def *
44
44
testsuite_substitution_get
45
45
(unsigned int code)
46
46
{
47
47
        if ( code > substitutions_count )
48
48
                return NULL;
49
 
        
 
49
 
50
50
        return substitutions[code];
51
51
}
52
52
 
53
53
static const struct testsuite_substitution *testsuite_substitution_create
54
54
(struct sieve_ast *ast, const char *identifier)
55
55
{
56
 
        unsigned int i; 
57
 
        
 
56
        unsigned int i;
 
57
 
58
58
        for ( i = 0; i < substitutions_count; i++ ) {
59
59
                if ( strcasecmp(substitutions[i]->obj_def.identifier, identifier) == 0 ) {
60
60
                        const struct testsuite_substitution_def *tsub_def = substitutions[i];
63
63
                        tsub = p_new(sieve_ast_pool(ast), struct testsuite_substitution, 1);
64
64
                        tsub->object.def = &tsub_def->obj_def;
65
65
                        tsub->object.ext = testsuite_ext;
66
 
                        tsub->def = tsub_def; 
67
 
                
 
66
                        tsub->def = tsub_def;
 
67
 
68
68
                        return tsub;
69
69
                }
70
70
        }
71
 
        
 
71
 
72
72
        return NULL;
73
73
}
74
74
 
75
75
/*
76
76
 * Substitution argument
77
77
 */
78
 
 
 
78
 
79
79
static bool arg_testsuite_substitution_generate
80
 
        (const struct sieve_codegen_env *cgenv, struct sieve_ast_argument *arg, 
 
80
        (const struct sieve_codegen_env *cgenv, struct sieve_ast_argument *arg,
81
81
                struct sieve_command *context);
82
82
 
83
83
struct _testsuite_substitution_context {
85
85
        const char *param;
86
86
};
87
87
 
88
 
const struct sieve_argument_def testsuite_substitution_argument = { 
89
 
        "@testsuite-substitution", 
 
88
const struct sieve_argument_def testsuite_substitution_argument = {
 
89
        "@testsuite-substitution",
90
90
        NULL, NULL, NULL, NULL,
91
 
        arg_testsuite_substitution_generate 
 
91
        arg_testsuite_substitution_generate
92
92
};
93
93
 
94
94
struct sieve_ast_argument *testsuite_substitution_argument_create
95
 
(struct sieve_validator *valdtr ATTR_UNUSED, struct sieve_ast *ast, 
 
95
(struct sieve_validator *valdtr ATTR_UNUSED, struct sieve_ast *ast,
96
96
        unsigned int source_line, const char *substitution, const char *param)
97
97
{
98
98
        const struct testsuite_substitution *tsub;
99
99
        struct _testsuite_substitution_context *tsctx;
100
100
        struct sieve_ast_argument *arg;
101
101
        pool_t pool;
102
 
        
 
102
 
103
103
        tsub = testsuite_substitution_create(ast, substitution);
104
 
        if ( tsub == NULL ) 
 
104
        if ( tsub == NULL )
105
105
                return NULL;
106
 
        
 
106
 
107
107
        arg = sieve_ast_argument_create(ast, source_line);
108
108
        arg->type = SAAT_STRING;
109
109
 
120
120
}
121
121
 
122
122
static bool arg_testsuite_substitution_generate
123
 
(const struct sieve_codegen_env *cgenv, struct sieve_ast_argument *arg, 
 
123
(const struct sieve_codegen_env *cgenv, struct sieve_ast_argument *arg,
124
124
        struct sieve_command *context ATTR_UNUSED)
125
125
{
126
 
        struct _testsuite_substitution_context *tsctx =  
 
126
        struct _testsuite_substitution_context *tsctx =
127
127
                (struct _testsuite_substitution_context *) arg->argument->data;
128
 
        
 
128
 
129
129
        testsuite_opr_substitution_emit(cgenv->sblock, tsctx->tsub, tsctx->param);
130
130
 
131
131
        return TRUE;
139
139
        (const struct sieve_dumptime_env *denv, const struct sieve_operand *oprnd,
140
140
                sieve_size_t *address);
141
141
static int opr_substitution_read_value
142
 
        (const struct sieve_runtime_env *renv, const struct sieve_operand *oprnd, 
 
142
        (const struct sieve_runtime_env *renv, const struct sieve_operand *oprnd,
143
143
                sieve_size_t *address, string_t **str);
144
 
        
145
 
const struct sieve_opr_string_interface testsuite_substitution_interface = { 
 
144
 
 
145
const struct sieve_opr_string_interface testsuite_substitution_interface = {
146
146
        opr_substitution_dump,
147
147
        opr_substitution_read_value
148
148
};
149
 
                
150
 
const struct sieve_operand_def testsuite_substitution_operand = { 
151
 
        "test-substitution", 
152
 
        &testsuite_extension, 
 
149
 
 
150
const struct sieve_operand_def testsuite_substitution_operand = {
 
151
        "test-substitution",
 
152
        &testsuite_extension,
153
153
        TESTSUITE_OPERAND_SUBSTITUTION,
154
154
        &string_class,
155
155
        &testsuite_substitution_interface
157
157
 
158
158
void testsuite_opr_substitution_emit
159
159
(struct sieve_binary_block *sblock, const struct testsuite_substitution *tsub,
160
 
        const char *param) 
 
160
        const char *param)
161
161
{
162
162
        /* Default variable storage */
163
163
        (void) sieve_operand_emit
167
167
}
168
168
 
169
169
static bool opr_substitution_dump
170
 
(const struct sieve_dumptime_env *denv, const struct sieve_operand *oprnd, 
171
 
        sieve_size_t *address) 
 
170
(const struct sieve_dumptime_env *denv, const struct sieve_operand *oprnd,
 
171
        sieve_size_t *address)
172
172
{
173
173
        unsigned int code = 0;
174
174
        const struct testsuite_substitution_def *tsub;
175
 
        string_t *param; 
 
175
        string_t *param;
176
176
 
177
177
        if ( !sieve_binary_read_unsigned(denv->sblock, address, &code) )
178
178
                return FALSE;
179
 
                
 
179
 
180
180
        tsub = testsuite_substitution_get(code);
181
181
        if ( tsub == NULL )
182
 
                return FALSE;   
183
 
                        
 
182
                return FALSE;
 
183
 
184
184
        if ( !sieve_binary_read_string(denv->sblock, address, &param) )
185
185
                return FALSE;
186
 
        
187
 
        if ( oprnd->field_name != NULL ) 
188
 
                sieve_code_dumpf(denv, "%s: TEST_SUBS %%{%s:%s}", 
 
186
 
 
187
        if ( oprnd->field_name != NULL )
 
188
                sieve_code_dumpf(denv, "%s: TEST_SUBS %%{%s:%s}",
189
189
                        oprnd->field_name, tsub->obj_def.identifier, str_c(param));
190
190
        else
191
 
                sieve_code_dumpf(denv, "TEST_SUBS %%{%s:%s}", 
 
191
                sieve_code_dumpf(denv, "TEST_SUBS %%{%s:%s}",
192
192
                        tsub->obj_def.identifier, str_c(param));
193
193
        return TRUE;
194
194
}
195
195
 
196
196
static int opr_substitution_read_value
197
 
(const struct sieve_runtime_env *renv, 
198
 
        const struct sieve_operand *oprnd ATTR_UNUSED, sieve_size_t *address, 
 
197
(const struct sieve_runtime_env *renv,
 
198
        const struct sieve_operand *oprnd ATTR_UNUSED, sieve_size_t *address,
199
199
        string_t **str_r)
200
 
 
200
{
201
201
        const struct testsuite_substitution_def *tsub;
202
202
        unsigned int code = 0;
203
203
        string_t *param;
204
 
        
 
204
 
205
205
        if ( !sieve_binary_read_unsigned(renv->sblock, address, &code) )
206
206
                return SIEVE_EXEC_BIN_CORRUPT;
207
 
                
 
207
 
208
208
        tsub = testsuite_substitution_get(code);
209
209
        if ( tsub == NULL )
210
 
                return SIEVE_EXEC_FAILURE;      
 
210
                return SIEVE_EXEC_FAILURE;
211
211
 
212
 
        /* Parameter str can be NULL if we are requested to only skip and not 
 
212
        /* Parameter str can be NULL if we are requested to only skip and not
213
213
         * actually read the argument.
214
 
         */     
 
214
         */
215
215
        if ( str_r == NULL ) {
216
216
                if ( !sieve_binary_read_string(renv->sblock, address, NULL) )
217
217
                        return SIEVE_EXEC_BIN_CORRUPT;
218
 
                
 
218
 
219
219
                return SIEVE_EXEC_OK;
220
220
        }
221
 
        
 
221
 
222
222
        if ( !sieve_binary_read_string(renv->sblock, address, &param) )
223
223
                return SIEVE_EXEC_BIN_CORRUPT;
224
 
                                
 
224
 
225
225
        if ( !tsub->get_value(str_c(param), str_r) )
226
226
                return SIEVE_EXEC_FAILURE;
227
 
        
 
227
 
228
228
        return SIEVE_EXEC_OK;
229
229
}
230
230
 
231
231
/*
232
232
 * Testsuite substitution definitions
233
233
 */
234
 
 
 
234
 
235
235
static bool testsuite_file_substitution_get_value
236
 
        (const char *param, string_t **result); 
237
 
 
 
236
        (const char *param, string_t **result);
 
237
 
238
238
static const struct testsuite_substitution_def testsuite_file_substitution = {
239
239
        SIEVE_OBJECT(
240
 
                "file", 
241
 
                &testsuite_substitution_operand, 
 
240
                "file",
 
241
                &testsuite_substitution_operand,
242
242
                TESTSUITE_SUBSTITUTION_FILE
243
243
        ),
244
244
        testsuite_file_substitution_get_value