[Dovecot] Little Help with Plugin

Alex Baule alexwbaule at gmail.com
Fri Feb 26 20:20:22 EET 2010


Hi everyone.....


I Build a plugin to concat my body and header splited....

Its have 2 "versions".

One is with the body without modifications.

The second, is with the body with crypto, and this crypto increase a little
the size of email.

So, without crypto, works fine, but with crypto i got stuck in some
modifications.

Because the email is splited, to handle it, i made a copy from
istream-concat.c, and in i_stream_concat_read  i made this changes.

Every place that have the i_stream_get_data i get the index from concat (if
is the frist or second stream) and if is the second, (my body) the unsigned
char *data is the return from my function.

    if(cstream->cur_idx == 1){
        data = decrypt_data(cstream->cur_input, &data_size);
    }else{
        data = i_stream_get_data(cstream->cur_input, &data_size);
    }


In this part, i get the function i_stream_get_data and put in the function
too, to get the data in the same way, but i dont return the (_stream->buffer
+ _stream->skip;), i put this in a unsigned char * too, and work with this
variable.

The size_r, with the _stream->pos - _stream->skip, i update it, with the new
value get from my total length from the decrypted buffer.

In resume, every (inside istream_concat_read and istream_concat_read_next )

    i_stream_get_data(cstream->cur_input, &data_size); // (in
istream_concat_read is "pos" variable)


I change to

    if(cstream->cur_idx == 1){
        data = decrypt_data(cstream->cur_input, &data_size); //(in
istream_concat_read is "pos" variable)
    }else{
        data = i_stream_get_data(cstream->cur_input, &data_size); //(in
istream_concat_read is "pos" variable)
    }


Setting the unsigned char *data,  with my decrypted data and the pos or
data_size, with the length of buffer data , decrypted.

I Think there is Ok with this, and must be work, but i got some errors with
this, when the Email is read to get them, the total length read is diferent
from the W flag in header name.

FETCH [] for mailbox INBOX UID 2 got too little data: 1351 vs 1352
FETCH [] for mailbox INBOX UID 1 got too little data: 1357 vs 1360
FETCH [] for mailbox INBOX UID 3 got too little data: 691 vs 1303


There is some variable or something that i forgot to update with this news
values ? I use the Zlib plugin for exemple to do this.


Tks Guys !!!


More information about the dovecot mailing list