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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-06-29 09:21:32 UTC
  • mfrom: (4.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20100629092132-q4pr5lfuvmjqou19
Tags: 1:1.2.12-1ubuntu1
* Merge from Debian Unstable, remaining changes:
  + Add mail-stack-delivery as 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.*
  + Use Snakeoil SSL certificates by default.
    - debian/control: Depend on ssl-cert.
    - debian/patches/ssl-cert-snakeoil.dpatch: Change default SSL cert paths to snakeoil.
    - debian/dovecot-common.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - Created debian/dovecot-common.ufw.profile.
    - debian/rules: install profile.
    - debian/control: suggest ufw.
  + debian/{control,rules}: enable PIE hardening.
  + debian/control: Update Vcs-* headers.
  + Add SMTP-AUTH support for Outlook (login auth mechanism) 
  + debian/dovecot-common.dirs: Added usr/share/doc/dovecot-common
  + debian/patches/fix-dovecot-config-parser.patch: Fix ordering of external config 
    files. (LP: #597818)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
/*
18
18
 * Forward declarations
19
19
 */
20
 
 
 
20
 
21
21
void testsuite_opr_substitution_emit
22
22
        (struct sieve_binary *sbin, 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->sbin, tsctx->tsub, tsctx->param);
130
130
 
131
131
        return TRUE;
139
139
        (const struct sieve_dumptime_env *denv, const struct sieve_operand *opr,
140
140
                sieve_size_t *address, const char *field_name);
141
141
static bool opr_substitution_read_value
142
 
        (const struct sieve_runtime_env *renv, const struct sieve_operand *opr, 
 
142
        (const struct sieve_runtime_env *renv, const struct sieve_operand *opr,
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 *sbin, 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, 
 
170
(const struct sieve_dumptime_env *denv,
171
171
        const struct sieve_operand *opr ATTR_UNUSED, sieve_size_t *address,
172
 
        const char *field_name) 
 
172
        const char *field_name)
173
173
{
174
174
        unsigned int code = 0;
175
175
        const struct testsuite_substitution_def *tsub;
176
 
        string_t *param; 
 
176
        string_t *param;
177
177
 
178
178
        if ( !sieve_binary_read_unsigned(denv->sbin, address, &code) )
179
179
                return FALSE;
180
 
                
 
180
 
181
181
        tsub = testsuite_substitution_get(code);
182
182
        if ( tsub == NULL )
183
 
                return FALSE;   
184
 
                        
 
183
                return FALSE;
 
184
 
185
185
        if ( !sieve_binary_read_string(denv->sbin, address, &param) )
186
186
                return FALSE;
187
 
        
188
 
        if ( field_name != NULL ) 
189
 
                sieve_code_dumpf(denv, "%s: TEST_SUBS %%{%s:%s}", 
 
187
 
 
188
        if ( field_name != NULL )
 
189
                sieve_code_dumpf(denv, "%s: TEST_SUBS %%{%s:%s}",
190
190
                        field_name, tsub->obj_def.identifier, str_c(param));
191
191
        else
192
 
                sieve_code_dumpf(denv, "TEST_SUBS %%{%s:%s}", 
 
192
                sieve_code_dumpf(denv, "TEST_SUBS %%{%s:%s}",
193
193
                        tsub->obj_def.identifier, str_c(param));
194
194
        return TRUE;
195
195
}
196
196
 
197
197
static bool opr_substitution_read_value
198
 
(const struct sieve_runtime_env *renv, 
199
 
        const struct sieve_operand *opr ATTR_UNUSED, sieve_size_t *address, 
 
198
(const struct sieve_runtime_env *renv,
 
199
        const struct sieve_operand *opr ATTR_UNUSED, sieve_size_t *address,
200
200
        string_t **str)
201
 
 
201
{
202
202
        const struct testsuite_substitution_def *tsub;
203
203
        unsigned int code = 0;
204
204
        string_t *param;
205
 
        
 
205
 
206
206
        if ( !sieve_binary_read_unsigned(renv->sbin, address, &code) )
207
207
                return FALSE;
208
 
                
 
208
 
209
209
        tsub = testsuite_substitution_get(code);
210
210
        if ( tsub == NULL )
211
 
                return FALSE;   
 
211
                return FALSE;
212
212
 
213
 
        /* Parameter str can be NULL if we are requested to only skip and not 
 
213
        /* Parameter str can be NULL if we are requested to only skip and not
214
214
         * actually read the argument.
215
 
         */     
216
 
        if ( str == NULL ) 
 
215
         */
 
216
        if ( str == NULL )
217
217
                return sieve_binary_read_string(renv->sbin, address, NULL);
218
 
        
 
218
 
219
219
        if ( !sieve_binary_read_string(renv->sbin, address, &param) )
220
220
                return FALSE;
221
 
                                
 
221
 
222
222
        return tsub->get_value(str_c(param), str);
223
223
}
224
224
 
225
225
/*
226
226
 * Testsuite substitution definitions
227
227
 */
228
 
 
 
228
 
229
229
static bool testsuite_file_substitution_get_value
230
 
        (const char *param, string_t **result); 
231
 
 
 
230
        (const char *param, string_t **result);
 
231
 
232
232
static const struct testsuite_substitution_def testsuite_file_substitution = {
233
233
        SIEVE_OBJECT(
234
 
                "file", 
235
 
                &testsuite_substitution_operand, 
 
234
                "file",
 
235
                &testsuite_substitution_operand,
236
236
                TESTSUITE_SUBSTITUTION_FILE
237
237
        ),
238
238
        testsuite_file_substitution_get_value