mbox-sync-rewrite.c revision a2637488c8d514ec1ac3914811deee814f9761b3
6ae232055d4d8a97267517c5e50074c2c819941and/* Copyright (C) 2004-2005 Timo Sirainen */
6ae232055d4d8a97267517c5e50074c2c819941and output = o_stream_create_file(sync_ctx->write_fd, default_pool,
b43f840409794ed298e8634f6284741f193b6c4ftakashi "o_stream_seek()");
6ae232055d4d8a97267517c5e50074c2c819941and input = i_stream_create_limit(default_pool, sync_ctx->file_input,
6ae232055d4d8a97267517c5e50074c2c819941and else if (ret >= 0) {
6ae232055d4d8a97267517c5e50074c2c819941and } else if (ret < 0) {
6ae232055d4d8a97267517c5e50074c2c819941and "o_stream_send_istream()");
6ae232055d4d8a97267517c5e50074c2c819941and return (int)ret;
6ae232055d4d8a97267517c5e50074c2c819941andstatic int mbox_fill_space(struct mbox_sync_context *sync_ctx,
b9f522ae1c0ed2bf3fc4444245bf28b2e2449a65nd if (pwrite_full(sync_ctx->write_fd, space, size, offset) < 0) {
6ae232055d4d8a97267517c5e50074c2c819941and return -1;
6ae232055d4d8a97267517c5e50074c2c819941andvoid mbox_sync_headers_add_space(struct mbox_sync_mail_context *ctx,
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi const unsigned char *data;
6ae232055d4d8a97267517c5e50074c2c819941and /* update the header using the existing offset.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi otherwise we might chose wrong header and just decrease
6ae232055d4d8a97267517c5e50074c2c819941and the available space */
6ae232055d4d8a97267517c5e50074c2c819941and /* Append at the end of X-Keywords header,
6ae232055d4d8a97267517c5e50074c2c819941and or X-UID if it doesn't exist */
6ae232055d4d8a97267517c5e50074c2c819941and start_pos = ctx->hdr_pos[MBOX_HDR_X_KEYWORDS] != (size_t)-1 ?
6ae232055d4d8a97267517c5e50074c2c819941and /* possibly continues in next line */
6ae232055d4d8a97267517c5e50074c2c819941and /* pos points to end of header now, and start_pos to beginning
6ae232055d4d8a97267517c5e50074c2c819941and of whitespace. */
1d980e5489836e977ba59b419e27b0ec875c4bd3takashistatic void mbox_sync_header_remove_space(struct mbox_sync_mail_context *ctx,
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh const unsigned char *data;
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh /* find the end of the LWSP */
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh for (pos = last_line_pos = start_pos; pos < data_size; pos++) {
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh /* possibly continues in next line */
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh if (pos+1 == data_size || !IS_LWSP(data[pos+1])) {
b43f840409794ed298e8634f6284741f193b6c4ftakashi } else if (!IS_LWSP(data[pos]) && data[pos] != '\r') {
*size = 0;
&size);
} else if (move_diff < 0 &&
if (move_diff != 0) {
move_diff) < 0) {
unsigned int first_mail_expunge_extra;
padding);
unsigned int count;
int ret = 0;
expunged_space = 0;
idx--;
first_nonexpunged) < 0) {
padding_per_mail) < 0) {
return ret;