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

« back to all changes in this revision

Viewing changes to pigeonhole/src/lib-sieve/plugins/variables/ext-variables-common.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"
30
30
 */
31
31
 
32
32
unsigned int sieve_variables_get_max_scope_size(void)
33
 
 
33
{
34
34
        return EXT_VARIABLES_MAX_SCOPE_SIZE;
35
35
}
36
36
 
37
37
/*
38
 
 * Variable scope 
 
38
 * Variable scope
39
39
 */
40
40
 
41
41
struct sieve_variable_scope {
47
47
 
48
48
        struct sieve_variable *error_var;
49
49
 
50
 
        struct hash_table *variables;
51
 
        ARRAY_DEFINE(variable_index, struct sieve_variable *);
 
50
        HASH_TABLE(const char *, struct sieve_variable *) variables;
 
51
        ARRAY(struct sieve_variable *) variable_index;
52
52
};
53
53
 
54
54
struct sieve_variable_scope_binary {
56
56
 
57
57
        unsigned int size;
58
58
        struct sieve_binary_block *sblock;
59
 
        sieve_size_t address;           
 
59
        sieve_size_t address;
60
60
};
61
61
 
62
62
struct sieve_variable_scope_iter {
65
65
};
66
66
 
67
67
struct sieve_variable_scope *sieve_variable_scope_create
68
 
(struct sieve_instance *svinst, const struct sieve_extension *ext) 
 
68
(struct sieve_instance *svinst, const struct sieve_extension *ext)
69
69
{
70
70
        struct sieve_variable_scope *scope;
71
71
        pool_t pool;
78
78
        scope->svinst = svinst;
79
79
        scope->ext = ext;
80
80
 
81
 
        scope->variables = hash_table_create
82
 
                (default_pool, pool, 0, strcase_hash, (hash_cmp_callback_t *)strcasecmp);
 
81
        hash_table_create(&scope->variables, pool, 0, strcase_hash, strcasecmp);
83
82
        p_array_init(&scope->variable_index, pool, 128);
84
 
                
 
83
 
85
84
        return scope;
86
85
}
87
86
 
122
121
                if ( scope->error_var == NULL ) {
123
122
                        new_var->identifier = "@ERROR@";
124
123
                        new_var->index = 0;
125
 
                        
 
124
 
126
125
                        scope->error_var = new_var;
127
126
                        return NULL;
128
127
                }
129
128
 
130
129
                return scope->error_var;
131
130
        }
132
 
        
 
131
 
133
132
        new_var->identifier = p_strdup(scope->pool, identifier);
134
133
        new_var->index = array_count(&scope->variable_index);
135
134
 
136
 
        hash_table_insert
137
 
                (scope->variables, (void *) new_var->identifier, (void *) new_var);
 
135
        hash_table_insert(scope->variables, new_var->identifier, new_var);
138
136
        array_append(&scope->variable_index, &new_var, 1);
139
 
        
 
137
 
140
138
        return new_var;
141
139
}
142
140
 
145
143
{
146
144
        struct sieve_variable *var;
147
145
 
148
 
        var = (struct sieve_variable *)
149
 
                hash_table_lookup(scope->variables, identifier);
 
146
        var = hash_table_lookup(scope->variables, identifier);
150
147
 
151
148
        if ( var == NULL && declare ) {
152
149
                var = sieve_variable_scope_declare(scope, identifier);
158
155
struct sieve_variable *sieve_variable_scope_import
159
156
(struct sieve_variable_scope *scope, struct sieve_variable *var)
160
157
{
161
 
        struct sieve_variable *new_var; 
 
158
        struct sieve_variable *new_var;
162
159
 
163
160
        new_var = p_new(scope->pool, struct sieve_variable, 1);
164
161
        memcpy(new_var, var, sizeof(struct sieve_variable));
165
 
                
166
 
        hash_table_insert
167
 
                (scope->variables, (void *) new_var->identifier, (void *) new_var);
168
 
        
169
 
        /* Not entered into the index because it is an external variable 
 
162
 
 
163
        hash_table_insert(scope->variables, new_var->identifier, new_var);
 
164
 
 
165
        /* Not entered into the index because it is an external variable
170
166
         * (This can be done unlimited; only limited by the size of the external scope)
171
167
         */
172
168
 
188
184
bool sieve_variable_scope_iterate
189
185
(struct sieve_variable_scope_iter *iter, struct sieve_variable **var_r)
190
186
{
191
 
        void *key, *value;
 
187
        const char *key;
192
188
 
193
 
        if ( !hash_table_iterate(iter->hctx, &key, &value) )
194
 
                return FALSE; 
195
 
        
196
 
        *var_r = (struct sieve_variable *) value;
197
 
        return TRUE;
 
189
        return hash_table_iterate
 
190
                (iter->hctx, iter->scope->variables, &key, var_r);
198
191
}
199
192
 
200
193
void sieve_variable_scope_iterate_deinit
226
219
(struct sieve_variable_scope *scope, unsigned int index)
227
220
{
228
221
        struct sieve_variable * const *var;
229
 
        
230
 
        if ( index >= array_count(&scope->variable_index) ) 
 
222
 
 
223
        if ( index >= array_count(&scope->variable_index) )
231
224
                return NULL;
232
 
                
233
 
        var = array_idx(&scope->variable_index, index); 
234
 
        
 
225
 
 
226
        var = array_idx(&scope->variable_index, index);
 
227
 
235
228
        return *var;
236
229
}
237
230
 
238
231
/* Scope binary */
239
232
 
240
233
struct sieve_variable_scope *sieve_variable_scope_binary_dump
241
 
(struct sieve_instance *svinst, const struct sieve_extension *ext, 
 
234
(struct sieve_instance *svinst, const struct sieve_extension *ext,
242
235
        const struct sieve_dumptime_env *denv, sieve_size_t *address)
243
236
{
244
237
        struct sieve_variable_scope *local_scope;
246
239
        sieve_size_t pc;
247
240
        sieve_offset_t end_offset;
248
241
 
249
 
        /* Read scope size */   
 
242
        /* Read scope size */
250
243
        sieve_code_mark(denv);
251
244
        if ( !sieve_binary_read_unsigned(denv->sblock, address, &scope_size) )
252
245
                return FALSE;
253
 
                
 
246
 
254
247
        /* Read offset */
255
 
        pc = *address;  
 
248
        pc = *address;
256
249
        if ( !sieve_binary_read_offset(denv->sblock, address, &end_offset) )
257
250
                return FALSE;
258
 
        
 
251
 
259
252
        /* Create scope */
260
253
        local_scope = sieve_variable_scope_create(svinst, ext);
261
 
        
 
254
 
262
255
        /* Read and dump scope itself */
263
256
 
264
 
        sieve_code_dumpf(denv, "VARIABLES SCOPE [%u] (end: %08x)", 
 
257
        sieve_code_dumpf(denv, "VARIABLES SCOPE [%u] (end: %08x)",
265
258
                scope_size, (unsigned int) (pc + end_offset));
266
 
        
 
259
 
267
260
        for ( i = 0; i < scope_size; i++ ) {
268
261
                string_t *identifier;
269
262
 
271
264
                if (!sieve_binary_read_string(denv->sblock, address, &identifier) ) {
272
265
                        return FALSE;
273
266
                }
274
 
                
 
267
 
275
268
                sieve_code_dumpf(denv, "%3d: '%s'", i, str_c(identifier));
276
 
                
 
269
 
277
270
                (void) sieve_variable_scope_declare(local_scope, str_c(identifier));
278
271
        }
279
 
                
 
272
 
280
273
        return local_scope;
281
274
}
282
275
 
288
281
        scpbin = p_new(scope->pool, struct sieve_variable_scope_binary, 1);
289
282
        scpbin->scope = scope;
290
283
 
291
 
        return scpbin;  
 
284
        return scpbin;
292
285
}
293
286
 
294
287
void sieve_variable_scope_binary_ref
311
304
        struct sieve_variable_scope *scope;
312
305
        struct sieve_variable_scope_binary *scpbin;
313
306
        unsigned int scope_size;
314
 
        const char *ext_name = 
 
307
        const char *ext_name =
315
308
                ( ext == NULL ? "variables" : sieve_extension_name(ext) );
316
309
        sieve_size_t pc;
317
310
        sieve_offset_t end_offset;
318
311
 
319
 
        /* Read scope size */   
 
312
        /* Read scope size */
320
313
        if ( !sieve_binary_read_unsigned(sblock, address, &scope_size) ) {
321
314
                sieve_sys_error
322
315
                        (svinst, "%s: variable scope: failed to read size", ext_name);
326
319
        /* Check size limit */
327
320
        if ( scope_size > EXT_VARIABLES_MAX_SCOPE_SIZE ) {
328
321
                sieve_sys_error(svinst,
329
 
                        "%s: variable scope: size exceeds the limit (%u > %u)", 
 
322
                        "%s: variable scope: size exceeds the limit (%u > %u)",
330
323
                        ext_name, scope_size, EXT_VARIABLES_MAX_SCOPE_SIZE );
331
324
                return NULL;
332
325
        }
333
 
                
 
326
 
334
327
        /* Read offset */
335
 
        pc = *address;  
 
328
        pc = *address;
336
329
        if ( !sieve_binary_read_offset(sblock, address, &end_offset) ) {
337
330
                sieve_sys_error(svinst,
338
331
                        "%s: variable scope: failed to read end offset", ext_name);
339
332
                return NULL;
340
333
        }
341
 
        
 
334
 
342
335
        /* Create scope */
343
336
        scope = sieve_variable_scope_create(svinst, ext);
344
337
 
347
340
        scpbin->sblock = sblock;
348
341
        scpbin->address = *address;
349
342
 
350
 
        *address = pc + end_offset;     
351
 
                        
 
343
        *address = pc + end_offset;
 
344
 
352
345
        return scpbin;
353
346
}
354
347
 
357
350
{
358
351
        const struct sieve_extension *ext = scpbin->scope->ext;
359
352
        struct sieve_instance *svinst = scpbin->scope->svinst;
360
 
        const char *ext_name = 
 
353
        const char *ext_name =
361
354
                ( ext == NULL ? "variables" : sieve_extension_name(ext) );
362
355
        unsigned int i;
363
 
        
 
356
 
364
357
        if ( scpbin->sblock != NULL ) {
365
358
                sieve_size_t *address = &scpbin->address;
366
359
 
367
 
                /* Read scope itself */ 
 
360
                /* Read scope itself */
368
361
                for ( i = 0; i < scpbin->size; i++ ) {
369
362
                        struct sieve_variable *var;
370
363
                        string_t *identifier;
374
367
                                        "%s: variable scope: failed to read variable name", ext_name);
375
368
                                return NULL;
376
369
                        }
377
 
                
 
370
 
378
371
                        var = sieve_variable_scope_declare(scpbin->scope, str_c(identifier));
379
372
 
380
373
                        i_assert( var != NULL );
383
376
 
384
377
                scpbin->sblock = NULL;
385
378
        }
386
 
        
 
379
 
387
380
        return scpbin->scope;
388
381
}
389
382
 
390
383
unsigned int sieve_variable_scope_binary_get_size
391
384
(struct sieve_variable_scope_binary *scpbin)
392
385
{
393
 
        if ( scpbin->sblock != NULL ) 
 
386
        if ( scpbin->sblock != NULL )
394
387
                return scpbin->size;
395
388
 
396
389
        return array_count(&scpbin->scope->variable_index);
397
390
}
398
391
 
399
 
/* 
400
 
 * Variable storage 
 
392
/*
 
393
 * Variable storage
401
394
 */
402
395
 
403
396
struct sieve_variable_storage {
405
398
        struct sieve_variable_scope *scope;
406
399
        struct sieve_variable_scope_binary *scope_bin;
407
400
        unsigned int max_size;
408
 
        ARRAY_DEFINE(var_values, string_t *); 
 
401
        ARRAY(string_t *) var_values;
409
402
};
410
403
 
411
404
struct sieve_variable_storage *sieve_variable_storage_create
412
405
(pool_t pool, struct sieve_variable_scope_binary *scpbin)
413
406
{
414
407
        struct sieve_variable_storage *storage;
415
 
        
 
408
 
416
409
        storage = p_new(pool, struct sieve_variable_storage, 1);
417
410
        storage->pool = pool;
418
411
        storage->scope_bin = scpbin;
419
412
        storage->scope = NULL;
420
 
        
 
413
 
421
414
        storage->max_size = sieve_variable_scope_binary_get_size(scpbin);
422
 
                
 
415
 
423
416
        p_array_init(&storage->var_values, pool, 4);
424
417
 
425
418
        return storage;
435
428
}
436
429
 
437
430
bool sieve_variable_get_identifier
438
 
(struct sieve_variable_storage *storage, unsigned int index, 
 
431
(struct sieve_variable_storage *storage, unsigned int index,
439
432
        const char **identifier)
440
433
{
441
434
        struct sieve_variable * const *var;
480
473
(struct sieve_variable_storage *storage, unsigned int index, string_t **value)
481
474
{
482
475
        *value = NULL;
483
 
        
 
476
 
484
477
        if  ( index < array_count(&storage->var_values) ) {
485
478
                string_t * const *varent;
486
 
                        
 
479
 
487
480
                varent = array_idx(&storage->var_values, index);
488
 
                
 
481
 
489
482
                *value = *varent;
490
483
        } else if ( !sieve_variable_valid(storage, index) )
491
484
                return FALSE;
492
485
 
493
486
        return TRUE;
494
 
 
487
}
495
488
 
496
489
bool sieve_variable_get_modifiable
497
490
(struct sieve_variable_storage *storage, unsigned int index, string_t **value)
498
491
{
499
492
        string_t *dummy;
500
 
        
 
493
 
501
494
        if ( value == NULL ) value = &dummy;
502
 
        
 
495
 
503
496
        if ( !sieve_variable_get(storage, index, value) )
504
497
                return FALSE;
505
 
        
 
498
 
506
499
        if ( *value == NULL ) {
507
500
                *value = str_new(storage->pool, 256);
508
 
                array_idx_set(&storage->var_values, index, value);      
 
501
                array_idx_set(&storage->var_values, index, value);
509
502
        }
510
503
 
511
 
        return TRUE; 
 
504
        return TRUE;
512
505
}
513
506
 
514
507
bool sieve_variable_assign
515
 
(struct sieve_variable_storage *storage, unsigned int index, 
 
508
(struct sieve_variable_storage *storage, unsigned int index,
516
509
        const string_t *value)
517
510
{
518
511
        string_t *varval;
519
 
        
520
 
        if ( !sieve_variable_get_modifiable(storage, index, &varval) ) 
 
512
 
 
513
        if ( !sieve_variable_get_modifiable(storage, index, &varval) )
521
514
                return FALSE;
522
515
 
523
516
        str_truncate(varval, 0);
535
528
 */
536
529
 
537
530
static void ext_variables_ast_free
538
 
(const struct sieve_extension *ext ATTR_UNUSED, 
 
531
(const struct sieve_extension *ext ATTR_UNUSED,
539
532
        struct sieve_ast *ast ATTR_UNUSED, void *context)
540
533
{
541
534
        struct sieve_variable_scope *local_scope =
568
561
{
569
562
        struct sieve_variable_scope *local_scope = (struct sieve_variable_scope *)
570
563
                sieve_ast_extension_get_context(ast, this_ext);
571
 
        
 
564
 
572
565
        return local_scope;
573
566
}
574
567
 
575
568
/*
576
 
 * Validator context 
 
569
 * Validator context
577
570
 */
578
571
 
579
572
static struct ext_variables_validator_context *
580
573
ext_variables_validator_context_create
581
574
(const struct sieve_extension *this_ext, struct sieve_validator *valdtr)
582
 
{               
 
575
{
583
576
        pool_t pool = sieve_validator_pool(valdtr);
584
577
        struct ext_variables_validator_context *ctx;
585
578
        struct sieve_ast *ast = sieve_validator_ast(valdtr);
586
 
        
 
579
 
587
580
        ctx = p_new(pool, struct ext_variables_validator_context, 1);
588
581
        ctx->modifiers = sieve_validator_object_registry_create(valdtr);
589
582
        ctx->namespaces = sieve_validator_object_registry_create(valdtr);
596
589
struct ext_variables_validator_context *ext_variables_validator_context_get
597
590
(const struct sieve_extension *this_ext, struct sieve_validator *valdtr)
598
591
{
599
 
        struct ext_variables_validator_context *ctx = 
 
592
        struct ext_variables_validator_context *ctx =
600
593
                (struct ext_variables_validator_context *)
601
594
                sieve_validator_extension_get_context(valdtr, this_ext);
602
 
        
 
595
 
603
596
        if ( ctx == NULL ) {
604
597
                ctx = ext_variables_validator_context_create(this_ext, valdtr);
605
598
        }
606
 
        
 
599
 
607
600
        return ctx;
608
601
}
609
602
 
611
604
(const struct sieve_extension *this_ext, struct sieve_validator *valdtr)
612
605
{
613
606
        struct ext_variables_validator_context *ctx;
614
 
        
 
607
 
615
608
        /* Create our context */
616
609
        ctx = ext_variables_validator_context_get(this_ext, valdtr);
617
 
        
 
610
 
618
611
        ext_variables_register_core_modifiers(this_ext, ctx);
619
 
        
 
612
 
620
613
        ctx->active = TRUE;
621
614
}
622
615
 
623
616
struct sieve_variable *ext_variables_validator_get_variable
624
 
(const struct sieve_extension *this_ext, struct sieve_validator *validator, 
 
617
(const struct sieve_extension *this_ext, struct sieve_validator *validator,
625
618
        const char *variable, bool declare)
626
619
{
627
 
        struct ext_variables_validator_context *ctx = 
 
620
        struct ext_variables_validator_context *ctx =
628
621
                ext_variables_validator_context_get(this_ext, validator);
629
 
                
 
622
 
630
623
        return sieve_variable_scope_get_variable(ctx->local_scope, variable, declare);
631
624
}
632
625
 
633
626
struct sieve_variable_scope *sieve_ext_variables_get_local_scope
634
627
(const struct sieve_extension *var_ext, struct sieve_validator *validator)
635
628
{
636
 
        struct ext_variables_validator_context *ctx = 
 
629
        struct ext_variables_validator_context *ctx =
637
630
                ext_variables_validator_context_get(var_ext, validator);
638
 
                
 
631
 
639
632
        return ctx->local_scope;
640
633
}
641
634
 
642
635
bool sieve_ext_variables_is_active
643
636
(const struct sieve_extension *var_ext, struct sieve_validator *valdtr)
644
637
{
645
 
        struct ext_variables_validator_context *ctx = 
 
638
        struct ext_variables_validator_context *ctx =
646
639
                ext_variables_validator_context_get(var_ext, valdtr);
647
 
                
 
640
 
648
641
        return ( ctx != NULL && ctx->active );
649
642
}
650
643
 
651
644
/*
652
645
 * Code generation
653
646
 */
654
 
 
 
647
 
655
648
bool ext_variables_generator_load
656
649
(const struct sieve_extension *ext, const struct sieve_codegen_env *cgenv)
657
650
{
658
 
        struct sieve_variable_scope *local_scope = 
 
651
        struct sieve_variable_scope *local_scope =
659
652
                ext_variables_ast_get_local_scope(ext, cgenv->ast);
660
653
        unsigned int count = sieve_variable_scope_size(local_scope);
661
654
        sieve_size_t jump;
666
659
 
667
660
        if ( count > 0 ) {
668
661
                unsigned int size, i;
669
 
                struct sieve_variable *const *vars = 
 
662
                struct sieve_variable *const *vars =
670
663
                        sieve_variable_scope_get_variables(local_scope, &size);
671
664
 
672
 
                for ( i = 0; i < size; i++ ) {                  
 
665
                for ( i = 0; i < size; i++ ) {
673
666
                        sieve_binary_emit_cstring(cgenv->sblock, vars[i]->identifier);
674
667
                }
675
668
        }
676
 
        
 
669
 
677
670
        sieve_binary_resolve_offset(cgenv->sblock, jump);
678
 
                
 
671
 
679
672
        return TRUE;
680
673
}
681
674
 
682
 
/* 
683
 
 * Interpreter context 
 
675
/*
 
676
 * Interpreter context
684
677
 */
685
678
 
686
679
struct ext_variables_interpreter_context {
690
683
        struct sieve_variable_scope_binary *local_scope_bin;
691
684
 
692
685
        struct sieve_variable_storage *local_storage;
693
 
        ARRAY_DEFINE(ext_storages, struct sieve_variable_storage *);
 
686
        ARRAY(struct sieve_variable_storage *) ext_storages;
694
687
};
695
688
 
696
689
static void ext_variables_interpreter_free
697
690
(const struct sieve_extension *ext ATTR_UNUSED,
698
691
        struct sieve_interpreter *interp ATTR_UNUSED, void *context)
699
692
{
700
 
        struct ext_variables_interpreter_context *ctx = 
 
693
        struct ext_variables_interpreter_context *ctx =
701
694
                (struct ext_variables_interpreter_context *)context;
702
695
 
703
696
        sieve_variable_scope_binary_unref(&ctx->local_scope_bin);
711
704
 
712
705
static struct ext_variables_interpreter_context *
713
706
ext_variables_interpreter_context_create
714
 
(const struct sieve_extension *this_ext, struct sieve_interpreter *interp, 
 
707
(const struct sieve_extension *this_ext, struct sieve_interpreter *interp,
715
708
        struct sieve_variable_scope_binary *scpbin)
716
 
{               
 
709
{
717
710
        pool_t pool = sieve_interpreter_pool(interp);
718
711
        struct ext_variables_interpreter_context *ctx;
719
 
        
 
712
 
720
713
        ctx = p_new(pool, struct ext_variables_interpreter_context, 1);
721
714
        ctx->pool = pool;
722
715
        ctx->local_scope = NULL;
723
716
        ctx->local_scope_bin = scpbin;
724
717
        ctx->local_storage = sieve_variable_storage_create(pool, scpbin);
725
 
        p_array_init(&ctx->ext_storages, pool, 
 
718
        p_array_init(&ctx->ext_storages, pool,
726
719
                sieve_extensions_get_count(this_ext->svinst));
727
720
 
728
721
        sieve_interpreter_extension_register
732
725
}
733
726
 
734
727
bool ext_variables_interpreter_load
735
 
(const struct sieve_extension *ext, const struct sieve_runtime_env *renv, 
 
728
(const struct sieve_extension *ext, const struct sieve_runtime_env *renv,
736
729
        sieve_size_t *address)
737
730
{
738
731
        struct sieve_variable_scope_binary *scpbin;
761
754
}
762
755
 
763
756
struct sieve_variable_storage *sieve_ext_variables_runtime_get_storage
764
 
(const struct sieve_extension *var_ext, const struct sieve_runtime_env *renv, 
 
757
(const struct sieve_extension *var_ext, const struct sieve_runtime_env *renv,
765
758
        const struct sieve_extension *ext)
766
759
{
767
 
        struct ext_variables_interpreter_context *ctx = 
 
760
        struct ext_variables_interpreter_context *ctx =
768
761
                ext_variables_interpreter_context_get(var_ext, renv->interp);
769
762
        struct sieve_variable_storage * const *storage;
770
 
                
 
763
 
771
764
        if ( ext == NULL )
772
765
                return ctx->local_storage;
773
766
 
776
769
        } else {
777
770
                storage = array_idx(&ctx->ext_storages, ext->id);
778
771
        }
779
 
        
 
772
 
780
773
        if ( storage == NULL ) return NULL;
781
 
        
 
774
 
782
775
        return *storage;
783
776
}
784
777
 
786
779
(const struct sieve_extension *var_ext, const struct sieve_runtime_env *renv,
787
780
        const struct sieve_extension *ext, struct sieve_variable_storage *storage)
788
781
{
789
 
        struct ext_variables_interpreter_context *ctx = 
 
782
        struct ext_variables_interpreter_context *ctx =
790
783
                ext_variables_interpreter_context_get(var_ext, renv->interp);
791
 
                
 
784
 
792
785
        if ( ctx == NULL || ext == NULL || storage == NULL )
793
786
                return;
794
787
 
795
788
        if ( ext->id < 0 ) return;
796
 
                
 
789
 
797
790
        array_idx_set(&ctx->ext_storages, (unsigned int) ext->id, &storage);
798
791
}
799
792