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

« back to all changes in this revision

Viewing changes to src/doveadm/doveadm-mail-fetch.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) 2010-2012 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2010-2013 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "array.h"
28
28
        struct ostream *output;
29
29
        struct mail *mail;
30
30
 
31
 
        ARRAY_DEFINE(fields, const struct fetch_field);
 
31
        ARRAY(struct fetch_field) fields;
32
32
        ARRAY_TYPE(const_string) header_fields;
33
33
        enum mail_fetch_field wanted_fields;
34
34
 
101
101
        return 0;
102
102
}
103
103
 
 
104
static int fetch_modseq(struct fetch_cmd_context *ctx)
 
105
{
 
106
        doveadm_print_num(mail_get_modseq(ctx->mail));
 
107
        return 0;
 
108
}
 
109
 
104
110
static int fetch_hdr(struct fetch_cmd_context *ctx)
105
111
{
106
112
        struct istream *input;
126
132
                ret = -1;
127
133
        }
128
134
        i_stream_unref(&input);
129
 
        doveadm_print_stream(NULL, 0);
 
135
        doveadm_print_stream("", 0);
130
136
        return ret;
131
137
}
132
138
 
164
170
                struct message_address *addr;
165
171
 
166
172
                addr = message_address_parse(pool_datastack_create(),
167
 
                                             str_data(str), str_len(str), -1U,
168
 
                                             FALSE);
 
173
                                             str_data(str), str_len(str),
 
174
                                             UINT_MAX, FALSE);
169
175
                str_truncate(str, 0);
170
176
                add_lf = FALSE;
171
177
                for (; addr != NULL; addr = addr->next) {
220
226
                i_error("read() failed: %m");
221
227
                ret = -1;
222
228
        }
223
 
        doveadm_print_stream(NULL, 0);
 
229
        doveadm_print_stream("", 0);
224
230
        return ret;
225
231
}
226
232
 
246
252
                i_error("read() failed: %m");
247
253
                ret = -1;
248
254
        }
249
 
        doveadm_print_stream(NULL, 0);
 
255
        doveadm_print_stream("", 0);
250
256
        return ret;
251
257
}
252
258
 
265
271
        parser = message_parser_init(pool_datastack_create(), input,
266
272
                                     MESSAGE_HEADER_PARSER_FLAG_CLEAN_ONELINE,
267
273
                                     0);
268
 
        decoder = message_decoder_init(0);
 
274
        decoder = message_decoder_init(NULL, 0);
269
275
 
270
276
        while ((ret = message_parser_parse_next_block(parser, &raw_block)) > 0) {
271
277
                if (!message_decoder_decode_next_block(decoder, &raw_block,
293
299
        message_decoder_deinit(&decoder);
294
300
        (void)message_parser_deinit(&parser, &parts);
295
301
 
296
 
        doveadm_print_stream(NULL, 0);
 
302
        doveadm_print_stream("", 0);
297
303
        if (input->stream_errno != 0) {
298
304
                i_error("read() failed: %m");
299
305
                return -1;
404
410
        { "uid",           0,                        fetch_uid },
405
411
        { "guid",          0,                        fetch_guid },
406
412
        { "flags",         MAIL_FETCH_FLAGS,         fetch_flags },
 
413
        { "modseq",        0,                        fetch_modseq },
407
414
        { "hdr",           MAIL_FETCH_STREAM_HEADER, fetch_hdr },
408
415
        { "body",          MAIL_FETCH_STREAM_BODY,   fetch_body },
409
416
        { "text",          MAIL_FETCH_STREAM_HEADER |
474
481
                        array_append(&ctx->fields, field, 1);
475
482
                }
476
483
        }
477
 
        (void)array_append_space(&ctx->header_fields);
 
484
        array_append_zero(&ctx->header_fields);
478
485
}
479
486
 
480
487
static int cmd_fetch_mail(struct fetch_cmd_context *ctx)
500
507
cmd_fetch_box(struct fetch_cmd_context *ctx, const struct mailbox_info *info)
501
508
{
502
509
        struct doveadm_mail_iter *iter;
503
 
        struct mailbox_transaction_context *trans;
504
510
        int ret = 0;
505
511
 
506
512
        if (doveadm_mail_iter_init(&ctx->ctx, info, ctx->ctx.search_args,
507
513
                                   ctx->wanted_fields,
508
514
                                   array_idx(&ctx->header_fields, 0),
509
 
                                   &trans, &iter) < 0)
 
515
                                   &iter) < 0)
510
516
                return -1;
511
517
 
512
518
        while (doveadm_mail_iter_next(iter, &ctx->mail)) {
562
568
        _ctx->search_args = doveadm_mail_build_search_args(args + 1);
563
569
 
564
570
        ctx->output = o_stream_create_fd(STDOUT_FILENO, 0, FALSE);
 
571
        o_stream_set_no_error_handling(ctx->output, TRUE);
565
572
}
566
573
 
567
574
static struct doveadm_mail_cmd_context *cmd_fetch_alloc(void)