[Dovecot] Creating and interacting with array inside plugin
Hi Timo....
I Follow your instruction to look inside quota plugin to get the notification from dovecot that expunged a message, that's Ok.
Follow the quota, it's use a array to keep all uids from a email expunged, to compare with uid that is got in notify_sync, that's OK too, but to me i need to keep uid and a char* with my body name, to erase it too.
I made this:
struct emexis_ids_x_uis{ uint32_t ids; char *uis_file; };
struct emexis_mailbox { union mailbox_module_context module_ctx; ARRAY_DEFINE(expunge_uids, struct emexis_ids_x_uis); };
ok, inside my expunged rewrite function i create the array like quota does, and append it to my array.
struct emexis_ids_x_uis append_uis; append_uis.ids = _mail->uid; append_uis.uis_file = bodyFile;
array_append(&ebox->expunge_uids, &append_uis, 1);
But when i do a foreach in this Array, my ids is OK, but my uis_file has tha same value every time (the value is the lasted value inserted).
Append to UID array (156) --> (/storage/gss/emexis/common/t/33/88/t33889eb1bccd28fd6643ebc3ecf548b12a1ad095) Append to UID array (157) --> (/storage/gss/emexis/common/t/e3/35/te335c20e978e12d37ad0a35ae009245cd34080c0) Append to UID array (158) --> (/storage/gss/emexis/common/t/0b/83/t0b83efc253c34db35843fc89b655586d628cccaf) Calling Sync Expunged --> (156) Sync Expunged (156 == 156) --> (/storage/gss/emexis/common/t/0b/83/t0b83efc253c34db35843fc89b655586d628cccaf) Sync Expunged Match (156 == 156) --> (/storage/gss/emexis/common/t/0b/83/t0b83efc253c34db35843fc89b655586d628cccaf) Sync Expunged (157 == 156) --> (/storage/gss/emexis/common/t/0b/83/t0b83efc253c34db35843fc89b655586d628cccaf) Sync Expunged (158 == 156) --> (/storage/gss/emexis/common/t/0b/83/t0b83efc253c34db35843fc89b655586d628cccaf) Finish Calling Sync Expunged --> (156)
Can i use a struct as a array Item ?? something is wrong with my array creation, append and etc ?
Tks Timo !!
On 23.2.2012, at 18.19, Alex Baule wrote:
ok, inside my expunged rewrite function i create the array like quota does, and append it to my array.
struct emexis_ids_x_uis append_uis; append_uis.ids = _mail->uid; append_uis.uis_file = bodyFile; .. But when i do a foreach in this Array, my ids is OK, but my uis_file has tha same value every time (the value is the lasted value inserted).
I guess the memory isn't permanently allocated for it, so you need to do:
append_uis.uis_file = i_strdup(bodyFile);
Note that you'll also need to later i_free() it to avoid leaking memory.
Tks Timo...
Em 23 de fevereiro de 2012 21:34, Timo Sirainen <tss@iki.fi> escreveu:
On 23.2.2012, at 18.19, Alex Baule wrote:
ok, inside my expunged rewrite function i create the array like quota does, and append it to my array.
struct emexis_ids_x_uis append_uis; append_uis.ids = _mail->uid; append_uis.uis_file = bodyFile; .. But when i do a foreach in this Array, my ids is OK, but my uis_file has tha same value every time (the value is the lasted value inserted).
I guess the memory isn't permanently allocated for it, so you need to do:
append_uis.uis_file = i_strdup(bodyFile);
Note that you'll also need to later i_free() it to avoid leaking memory.
participants (2)
-
Alex Baule
-
Timo Sirainen