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

« back to all changes in this revision

Viewing changes to pigeonhole/src/testsuite/cmd-test-message.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-11 11:11:54 UTC
  • mfrom: (1.15.2) (4.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120611111154-678cwbdj6ktgsv1h
Tags: 1:2.1.7-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/{control,rules}: enable PIE hardening.
  + 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.
  + d/control: Added Pre-Depends: dpkg (>= 1.15.6) to dovecot-dbg to support
    xz compression in Ubuntu.
  + d/control: Demote dovecot-common Recommends: to Suggests: to prevent
    install of extra packages on upgrade.
  + d/patches/dovecot-drac.patch: Updated with version for dovecot >= 2.0.0.
  + d/control: Drop B-D on systemd.
* Dropped changes:
  + d/patches/fix-racey-restart.patch: part of 2.1.x, no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Copyright (c) 2002-2012 Pigeonhole authors, see the included COPYING file
2
2
 */
3
3
 
 
4
#include "lib.h"
 
5
#include "istream.h"
 
6
 
4
7
#include "sieve-common.h"
5
8
#include "sieve-commands.h"
 
9
#include "sieve-message.h"
6
10
#include "sieve-validator.h"
7
11
#include "sieve-generator.h"
8
12
#include "sieve-interpreter.h"
15
19
#include "testsuite-mailstore.h"
16
20
 
17
21
/*
18
 
 * Test_message command
 
22
 * Commands
 
23
 */ 
 
24
 
 
25
/* Test_message command
19
26
 *
20
27
 * Syntax:   
21
28
 *   test_message ( :smtp / :mailbox <mailbox: string> ) <index: number>
41
48
        NULL 
42
49
};
43
50
 
 
51
/* Test_message_print command
 
52
 *
 
53
 * Syntax:   
 
54
 *   test_message_print
 
55
 */
 
56
 
 
57
static bool cmd_test_message_print_generate
 
58
        (const struct sieve_codegen_env *cgenv, struct sieve_command *cmd);
 
59
 
 
60
const struct sieve_command_def cmd_test_message_print = { 
 
61
        "test_message_print", 
 
62
        SCT_COMMAND, 
 
63
        0, 0, FALSE, FALSE,
 
64
        NULL, NULL, NULL, NULL,
 
65
        cmd_test_message_print_generate
 
66
        , NULL
 
67
};
 
68
 
 
69
 
44
70
/* 
45
71
 * Operations
46
72
 */ 
75
101
        cmd_test_message_mailbox_operation_execute 
76
102
};
77
103
 
 
104
/* Test_message_print operation */
 
105
 
 
106
static bool cmd_test_message_print_operation_dump
 
107
        (const struct sieve_dumptime_env *denv, sieve_size_t *address);
 
108
static int cmd_test_message_print_operation_execute
 
109
        (const struct sieve_runtime_env *renv, sieve_size_t *address);
 
110
 
 
111
const struct sieve_operation_def test_message_print_operation = { 
 
112
        "TEST_MESSAGE_PRINT",
 
113
        &testsuite_extension, 
 
114
        TESTSUITE_OPERATION_TEST_MESSAGE_PRINT,
 
115
        cmd_test_message_print_operation_dump, 
 
116
        cmd_test_message_print_operation_execute 
 
117
};
 
118
 
78
119
/*
79
120
 * Compiler context data
80
121
 */
254
295
        return TRUE;
255
296
}
256
297
 
 
298
static bool cmd_test_message_print_generate
 
299
(const struct sieve_codegen_env *cgenv, struct sieve_command *cmd)
 
300
{       
 
301
        /* Emit operation */
 
302
        sieve_operation_emit
 
303
                (cgenv->sblock, cmd->ext, &test_message_print_operation);
 
304
        return TRUE;
 
305
}
 
306
 
257
307
/* 
258
308
 * Code dump
259
309
 */
292
342
                sieve_opr_number_dump(denv, address, "index");
293
343
}
294
344
 
 
345
static bool cmd_test_message_print_operation_dump
 
346
(const struct sieve_dumptime_env *denv, sieve_size_t *address ATTR_UNUSED)
 
347
{
 
348
        sieve_code_dumpf(denv, "TEST_MESSAGE_PRINT");
 
349
 
 
350
        return TRUE;
 
351
}
 
352
 
 
353
 
295
354
/*
296
355
 * Intepretation
297
356
 */
420
479
        return SIEVE_EXEC_OK;
421
480
}
422
481
 
 
482
static int cmd_test_message_print_operation_execute
 
483
(const struct sieve_runtime_env *renv, sieve_size_t *address ATTR_UNUSED)
 
484
{
 
485
        struct mail *mail = sieve_message_get_mail(renv->msgctx);
 
486
        struct istream *input;
 
487
        const unsigned char *data;
 
488
        size_t size;
 
489
        int ret;
 
490
 
 
491
        if (mail_get_stream(mail, NULL, NULL, &input) < 0) {
 
492
                sieve_runtime_error(renv, NULL,
 
493
                        "test_message_print: failed to read current message");
 
494
                return SIEVE_EXEC_OK;
 
495
        }
 
496
 
 
497
        printf("\n--MESSAGE: \n");
 
498
 
 
499
        /* Pipe the message to the outgoing SMTP transport */
 
500
        while ((ret=i_stream_read_data(input, &data, &size, 0)) > 0) {
 
501
                ssize_t wret;
 
502
 
 
503
                if ( (wret=write(1, data, size)) <= 0 )
 
504
                        break;
 
505
                i_stream_skip(input, wret);
 
506
        }
 
507
        printf("\n--MESSAGE--\n");
 
508
 
 
509
        return SIEVE_EXEC_OK;
 
510
}
 
511
 
 
512
 
423
513
 
424
514
 
425
515