-
Notifications
You must be signed in to change notification settings - Fork 0
/
d_etpan.d
5585 lines (4706 loc) · 244 KB
/
d_etpan.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import std.file;
import std.stdio;
import std.concurrency;
import core.stdc.time;
import std.c.linux.linux;
import std.c.linux.pthread;
//import core.time;
/**
Port of libetpan IMAP library to the D programming Language
written in 2014 by Laeeth Isharc
see end of file for COPYRIGHT etc
*/
extern(C)
{
/**
following aliases are checked and correct
*/
alias pid_t=int;
mailmime_content * mailmime_get_content(char * mime_type);
alias mailmime_content_new_with_str= mailmime_get_content;
alias chashiter=chashcell;
alias timeval=time_t;
/**
following are not correct
missing - mailmime_fields_new_encoding, mailmime_param_new_with_data, mailmime_new_empty, mailmime_set_body_text
*/
enum PATH_MAX=32000;
/**
====================
*/
alias uint8_t=ubyte;
alias uint16_t=ushort;
alias uint32_t=uint;
alias uint64_t=ulong;
alias int16_t=short;
alias int32_t=int;
alias ssize_t=size_t;
enum no_argument =0;
enum required_argument =1;
enum optional_argument =2;
struct option {
/*const */char *name;
int has_arg;
int *flag;
int val;
}
enum LIBETPAN_REENTRANT=1;
enum HAVE_PTHREAD_H=1;
enum IGNORE_PTHREAD_H=0;
enum USE_SSL=1;
enum USE_GNUTLS=0;
struct mailstream_ssl_context
{
int fd;
static if(USE_SSL==1)
{
static if(USE_GNUTLS!=1)
{
//SSL_CTX * openssl_ssl_ctx;
void *openssl_ssl_ctx;
//X509* client_x509;
void* client_x509;
//EVP_PKEY *client_pkey;
void* *client_pkey;
}
else
{
gnutls_session session;
gnutls_x509_crt client_x509;
gnutls_x509_privkey client_pkey;
gnutls_certificate_credentials_t gnutls_credentials;
}
}
}
struct mailengine
{
mailprivacy * privacy;
static if (LIBETPAN_REENTRANT==1)
{
static if( (HAVE_PTHREAD_H==1) && (IGNORE_PTHREAD_H!=1))
{
pthread_mutex_t storage_hash_lock;
}
}
chash * storage_hash;
}
int getopt_long(int, char **,char *, option *, int *);
// int getopt_long(int, (char * /*const*/) *, (/*const */char) *, (/*const*/ option) *, int *);
int getopt_long_only(int, char **, char *, option *, int *);
// int getopt_long_only(int, char * const *, const char *, const option *, int *);
int getopt(int, char ** , char *);
// int getopt(int, char ** const , const char *);
__gshared char *optarg; /* getopt(3) external variables */
__gshared int optind, opterr, optopt;
__gshared int optreset; /* getopt(3) external variable */
struct db_session_state_data {
char db_filename[PATH_MAX];
mail_flags_store * db_flags_store;
}
struct db_mailstorage {
char * db_pathname;
};
__gshared mailsession_driver * db_session_driver;
int db_mailstorage_init(mailstorage * storage, char * db_pathname);
int maildirdriver_maildir_error_to_mail_error(int error);
uint32_t maildirdriver_maildir_flags_to_flags(uint32_t md_flags);
uint32_t maildirdriver_flags_to_maildir_flags(uint32_t flags);
//int maildir_get_messages_list(mailsession * session, maildir * md, mailmessage_driver * message_driver, mailmessage_list ** result); mailsession_driver * maildir_cached_session_driver;
int maildir_mailstorage_init(mailstorage * storage, const char * md_pathname, int md_cached, const char * md_cache_directory, const char * md_flags_directory);
struct maildir_session_state_data {
maildir * md_session;
mail_flags_store * md_flags_store;
}
enum {
MAILDIRDRIVER_CACHED_SET_CACHE_DIRECTORY = 1,
MAILDIRDRIVER_CACHED_SET_FLAGS_DIRECTORY
};
struct maildir_cached_session_state_data {
mailsession * md_ancestor;
char * md_quoted_mb;
mail_flags_store * md_flags_store;
char[PATH_MAX] md_cache_directory;
char[PATH_MAX] md_flags_directory;
}
struct maildir_mailstorage {
char * md_pathname;
int md_cached;
char * md_cache_directory;
char * md_flags_directory;
}
int pop3_mailstorage_init(mailstorage * storage, const char * pop3_servername, uint16_t pop3_port, const char * pop3_command, int pop3_connection_type, int pop3_auth_type, const char * pop3_login, const char * pop3_password, int pop3_cached, const char * pop3_cache_directory, const char * pop3_flags_directory);
int pop3_mailstorage_init_sasl(mailstorage * storage, const char * pop3_servername, uint16_t pop3_port, const char * pop3_command, int pop3_connection_type, const char * auth_type, const char * server_fqdn, const char * local_ip_port, const char * remote_ip_port, const char * login, const char * auth_name, const char * password, const char * realm, int pop3_cached, const char * pop3_cache_directory, const char * pop3_flags_directory);
int pop3_mailstorage_init_sasl_with_local_address(mailstorage * storage, const char * pop3_servername, uint16_t pop3_port, const char * imap_local_address, uint16_t imap_local_port, const char * pop3_command, int pop3_connection_type, const char * auth_type, const char * server_fqdn, const char * local_ip_port, const char * remote_ip_port, const char * login, const char * auth_name, const char * password, const char * realm, int pop3_cached, const char * pop3_cache_directory, const char * pop3_flags_directory);
__gshared mailsession_driver * pop3_session_driver;
int pop3driver_pop3_error_to_mail_error(int error);
int pop3driver_retr(mailsession * session, uint32_t indx, char ** result, size_t * result_len);
int pop3driver_header(mailsession * session, uint32_t indx, char ** result, size_t * result_len);
int pop3driver_size(mailsession * session, uint32_t indx, size_t * result);
int pop3driver_get_cached_flags(mail_cache_db * cache_db, MMAPString * mmapstr, mailsession * session, uint32_t num, mail_flags ** result);
int pop3driver_write_cached_flags(mail_cache_db * cache_db, MMAPString * mmapstr, char * uid, mail_flags * flags);
int pop3_get_messages_list(mailpop3 * pop3, mailsession * session, mailmessage_driver * driver, mailmessage_list ** result);
__gshared mailsession_driver * pop3_cached_session_driver;
enum {
POP3DRIVER_SET_AUTH_TYPE = 1
}
enum {
POP3DRIVER_AUTH_TYPE_PLAIN = 0,
POP3DRIVER_AUTH_TYPE_APOP,
POP3DRIVER_AUTH_TYPE_TRY_APOP
}
struct pop3_session_state_data
{
int pop3_auth_type;
mailpop3 * pop3_session;
void function(mailstream_ssl_context * ssl_context, void * data) pop3_ssl_callback;
void * pop3_ssl_cb_data;
}
enum {
/* the mapping of the parameters should be the same as for pop3 */
POP3DRIVER_CACHED_SET_AUTH_TYPE = 1,
POP3DRIVER_CACHED_SET_SSL_CALLBACK = 2,
POP3DRIVER_CACHED_SET_SSL_CALLBACK_DATA = 3,
/* cache specific */
POP3DRIVER_CACHED_SET_CACHE_DIRECTORY = 1001,
POP3DRIVER_CACHED_SET_FLAGS_DIRECTORY = 1002
}
struct pop3_cached_session_state_data {
mailsession * pop3_ancestor;
char pop3_cache_directory[PATH_MAX];
char pop3_flags_directory[PATH_MAX];
chash * pop3_flags_hash;
carray * pop3_flags_array;
mail_flags_store * pop3_flags_store;
}
struct pop3_mailstorage {
char * pop3_servername;
uint16_t pop3_port;
char * pop3_command;
int pop3_connection_type;
int pop3_auth_type;
char * pop3_login; /* deprecated */
char * pop3_password; /* deprecated */
int pop3_cached;
char * pop3_cache_directory;
char * pop3_flags_directory;
struct pop3_sasl_t {
int sasl_enabled;
char * sasl_auth_type;
char * sasl_server_fqdn;
char * sasl_local_ip_port;
char * sasl_remote_ip_port;
char * sasl_login;
char * sasl_auth_name;
char * sasl_password;
char * sasl_realm;
}
pop3_sasl_t pop3_sasl;
char * pop3_local_address;
uint16_t pop3_local_port;
}
/* this is the type of POP3 authentication */
enum {
POP3_AUTH_TYPE_PLAIN, /* plain text authentication */
POP3_AUTH_TYPE_APOP, /* APOP authentication */
POP3_AUTH_TYPE_TRY_APOP, /* first, try APOP, if it fails,
try plain text */
POP3_AUTH_TYPE_SASL_ANONYMOUS, /* SASL anonymous */
POP3_AUTH_TYPE_SASL_CRAM_MD5, /* SASL CRAM MD5 */
POP3_AUTH_TYPE_SASL_KERBEROS_V4, /* SASL KERBEROS V4 */
POP3_AUTH_TYPE_SASL_PLAIN, /* SASL plain */
POP3_AUTH_TYPE_SASL_SCRAM_MD5, /* SASL SCRAM MD5 */
POP3_AUTH_TYPE_SASL_GSSAPI, /* SASL GSSAPI */
POP3_AUTH_TYPE_SASL_DIGEST_MD5 /* SASL digest MD5 */
};
enum POP3_SASL_AUTH_TYPE_APOP="X-LIBETPAN-APOP";
enum POP3_SASL_AUTH_TYPE_TRY_APOP="X-LIBETPAN-TRY-APOP";
int mh_mailstorage_init(mailstorage * storage,
const char * mh_pathname, int mh_cached,
const char * mh_cache_directory, const char * mh_flags_directory);
struct mh_session_state_data {
mailmh * mh_session;
mailmh_folder * mh_cur_folder;
clist * mh_subscribed_list;
}
enum {
MHDRIVER_CACHED_SET_CACHE_DIRECTORY = 1,
MHDRIVER_CACHED_SET_FLAGS_DIRECTORY
}
struct mh_cached_session_state_data {
mailsession * mh_ancestor;
char * mh_quoted_mb;
char mh_cache_directory[PATH_MAX];
char mh_flags_directory[PATH_MAX];
mail_flags_store * mh_flags_store;
}
struct mh_mailstorage {
char * mh_pathname;
int mh_cached;
char * mh_cache_directory;
char * mh_flags_directory;
}
__gshared mailmessage_driver * mh_message_driver;
__gshared mailmessage_driver * mh_cached_message_driver;
__gshared mailsession_driver * mh_cached_session_driver;
int mhdriver_mh_error_to_mail_error(int error);
int mhdriver_fetch_message(mailsession * session, uint32_t indx, char ** result, size_t * result_len);
int mhdriver_fetch_header(mailsession * session, uint32_t indx, char ** result, size_t * result_len);
int mhdriver_fetch_size(mailsession * session, uint32_t indx, size_t * result);
int mhdriver_get_cached_flags(mail_cache_db * cache_db, MMAPString * mmapstr, mailsession * session,
uint32_t num, mail_flags ** result);
int mhdriver_write_cached_flags(mail_cache_db * cache_db, MMAPString * mmapstr, char * uid, mail_flags * flags);
int mh_get_messages_list(mailmh_folder * folder, mailsession * session, mailmessage_driver * driver, mailmessage_list ** result);
__gshared mailmessage_driver * nntp_message_driver;
__gshared mailmessage_driver * nntp_cached_message_driver;
__gshared mailsession_driver * nntp_session_driver;
__gshared mailsession_driver * nntp_cached_session_driver;
int nntpdriver_nntp_error_to_mail_error(int error);
int nntpdriver_authenticate_password(mailsession * session);
int nntpdriver_authenticate_user(mailsession * session);
int nntpdriver_article(mailsession * session, uint32_t indx, char ** result, size_t * result_len);
int nntpdriver_head(mailsession * session, uint32_t indx, char ** result, size_t * result_len);
int nntpdriver_size(mailsession * session, uint32_t indx, size_t * result);
int nntpdriver_get_cached_flags(mail_cache_db * cache_db, MMAPString * mmapstr, uint32_t num, mail_flags ** result);
int nntpdriver_write_cached_flags(mail_cache_db * cache_db, MMAPString * mmapstr, uint32_t num, mail_flags * flags);
int nntpdriver_select_folder(mailsession * session, const char * mb);
int nntp_get_messages_list(mailsession * nntp_session, mailsession * session, mailmessage_driver * driver, mailmessage_list ** result);
int nntpdriver_mode_reader(mailsession * session);
int nntp_mailstorage_init(mailstorage * storage, const char * nntp_servername, uint16_t nntp_port,
const char * nntp_command, int nntp_connection_type, int nntp_auth_type, const char * nntp_login, const char * nntp_password,
int nntp_cached, const char * nntp_cache_directory, const char * nntp_flags_directory);
int nntp_mailstorage_init_with_local_address(mailstorage * storage, const char * nntp_servername, uint16_t nntp_port,
const char * nntp_local_servername, uint16_t nntp_local_port, const char * nntp_command, int nntp_connection_type, int nntp_auth_type,
const char * nntp_login, const char * nntp_password, int nntp_cached, const char * nntp_cache_directory, const char * nntp_flags_directory);
enum {
NNTPDRIVER_SET_MAX_ARTICLES = 1
};
struct nntp_session_state_data {
newsnntp * nntp_session;
char * nntp_userid;
char * nntp_password;
newsnntp_group_info * nntp_group_info;
char * nntp_group_name;
clist * nntp_subscribed_list;
uint32_t nntp_max_articles;
int nntp_mode_reader;
};
enum {
NNTPDRIVER_CACHED_SET_MAX_ARTICLES = 1,
NNTPDRIVER_CACHED_SET_CACHE_DIRECTORY,
NNTPDRIVER_CACHED_SET_FLAGS_DIRECTORY
};
struct nntp_cached_session_state_data {
mailsession * nntp_ancestor;
char nntp_cache_directory[PATH_MAX];
char nntp_flags_directory[PATH_MAX];
mail_flags_store * nntp_flags_store;
}
struct nntp_mailstorage {
char * nntp_servername;
uint16_t nntp_port;
char * nntp_command;
int nntp_connection_type;
int nntp_auth_type;
char * nntp_login;
char * nntp_password;
int nntp_cached;
char * nntp_cache_directory;
char * nntp_flags_directory;
char * nntp_local_address;
uint16_t nntp_local_port;
};
/* this is the type of NNTP authentication */
enum {
NNTP_AUTH_TYPE_PLAIN /* plain text authentication */
};
__gshared mailmessage_driver * mime_message_driver;
__gshared mailmessage * mime_message_init(mailmime * mime);
void mime_message_detach_mime(mailmessage * msg);
int mime_message_set_tmpdir(mailmessage * msg, char * tmpdir);
__gshared mailsession_driver * imap_cached_session_driver;
int imap_mailstorage_init(mailstorage * storage, const char * imap_servername, uint16_t imap_port, const char * imap_command, int imap_connection_type, int imap_auth_type, const char * imap_login, const char * imap_password, int imap_cached, const char * imap_cache_directory);
int imap_mailstorage_init_sasl(mailstorage * storage, const char * imap_servername, uint16_t imap_port, const char * imap_command, int imap_connection_type, const char * auth_type, const char * server_fqdn, const char * local_ip_port, const char * remote_ip_port, const char * login, const char * auth_name, const char * password, const char * realm, int imap_cached, const char * imap_cache_directory);
int imap_mailstorage_init_sasl_with_local_address(mailstorage * storage, const char * imap_servername, uint16_t imap_port, const char * imap_local_address, uint16_t imap_local_port, const char * imap_command, int imap_connection_type, const char * auth_type, const char * server_fqdn, const char * local_ip_port, const char * remote_ip_port, const char * login, const char * auth_name, const char * password, const char * realm, int imap_cached, const char * imap_cache_directory);
struct imap_session_state_data {
mailimap * imap_session;
char * imap_mailbox;
mail_flags_store * imap_flags_store;
void function(mailstream_ssl_context * ssl_context, void * data) imap_ssl_callback;
void * imap_ssl_cb_data;
};
enum {
IMAP_SECTION_MESSAGE,
IMAP_SECTION_HEADER,
IMAP_SECTION_MIME,
IMAP_SECTION_BODY
};
/* cached IMAP driver for session */
enum {
IMAPDRIVER_CACHED_SET_SSL_CALLBACK = 1,
IMAPDRIVER_CACHED_SET_SSL_CALLBACK_DATA = 2,
/* cache */
IMAPDRIVER_CACHED_SET_CACHE_DIRECTORY = 1001
};
struct imap_cached_session_state_data {
mailsession * imap_ancestor;
char * imap_quoted_mb;
char imap_cache_directory[PATH_MAX];
carray * imap_uid_list;
uint32_t imap_uidvalidity;
};
struct imap_mailstorage {
char * imap_servername;
uint16_t imap_port;
char * imap_command;
int imap_connection_type;
int imap_auth_type;
char * imap_login; /* deprecated */
char * imap_password; /* deprecated */
int imap_cached;
char * imap_cache_directory;
struct imap_sasl_t
{
int sasl_enabled;
char * sasl_auth_type;
char * sasl_server_fqdn;
char * sasl_local_ip_port;
char * sasl_remote_ip_port;
char * sasl_login;
char * sasl_auth_name;
char * sasl_password;
char * sasl_realm;
}
imap_sasl_t imap_sasl;
char * imap_local_address;
uint16_t imap_local_port;
};
/* this is the type of IMAP4rev1 authentication */
enum {
IMAP_AUTH_TYPE_PLAIN, /* plain text authentication */
IMAP_AUTH_TYPE_SASL_ANONYMOUS, /* SASL anonymous */
IMAP_AUTH_TYPE_SASL_CRAM_MD5, /* SASL CRAM MD5 */
IMAP_AUTH_TYPE_SASL_KERBEROS_V4, /* SASL KERBEROS V4 */
IMAP_AUTH_TYPE_SASL_PLAIN, /* SASL plain */
IMAP_AUTH_TYPE_SASL_SCRAM_MD5, /* SASL SCRAM MD5 */
IMAP_AUTH_TYPE_SASL_GSSAPI, /* SASL GSSAPI */
IMAP_AUTH_TYPE_SASL_DIGEST_MD5 /* SASL digest MD5 */
};
__gshared mailsession_driver * imap_session_driver;
__gshared mailmessage_driver * imap_cached_message_driver;
__gshared mailmessage_driver * imap_message_driver;
int imapdriver_get_cached_envelope(mail_cache_db * cache_db, MMAPString * mmapstr, mailsession * session, mailmessage * msg, mailimf_fields ** result);
int imapdriver_write_cached_envelope(mail_cache_db * cache_db, MMAPString * mmapstr, mailsession * session, mailmessage * msg, mailimf_fields * fields);
int imap_error_to_mail_error(int error);
int imap_store_flags(mailimap * imap, uint32_t first, uint32_t last, mail_flags * flags);
int imap_fetch_flags(mailimap * imap, uint32_t indx, mail_flags ** result);
int imap_get_messages_list(mailimap * imap, mailsession * session, mailmessage_driver * driver, uint32_t first_index, mailmessage_list ** result);
int imap_list_to_list(clist * imap_list, mail_list ** result);
int imap_section_to_imap_section(mailmime_section * section, int type, mailimap_section ** result);
int imap_get_msg_att_info(mailimap_msg_att * msg_att, uint32_t * puid, mailimap_envelope ** pimap_envelope, char ** preferences,
size_t * pref_size, mailimap_msg_att_dynamic ** patt_dyn, mailimap_body ** pimap_body);
int imap_add_envelope_fetch_att(mailimap_fetch_type * fetch_type);
int imap_env_to_fields(mailimap_envelope * env, char * ref_str, size_t ref_size, mailimf_fields ** result);
int imap_fetch_result_to_envelop_list(clist * fetch_result, mailmessage_list * env_list);
int imap_body_to_body(mailimap_body * imap_body, mailmime ** result);
int imap_msg_list_to_imap_set(clist * msg_list, mailimap_set ** result);
int imap_flags_to_imap_flags(mail_flags * flags, mailimap_flag_list ** result);
int imap_flags_to_flags(mailimap_msg_att_dynamic * att_dyn, mail_flags ** result);
int feed_mailstorage_init(mailstorage * storage, const char * feed_url, int feed_cached, const char * feed_cache_directory, const char * feed_flags_directory);
__gshared mailsession_driver * feed_session_driver;
struct feed_session_state_data {
time_t feed_last_update;
newsfeed * feed_session;
int feed_error;
};
struct feed_mailstorage {
char * feed_url;
int feed_cached;
char * feed_cache_directory;
char * feed_flags_directory;
}
__gshared mailmessage_driver * feed_message_driver;
__gshared mailmessage_driver * mbox_cached_message_driver;
int mbox_mailstorage_init(mailstorage * storage, const char * mb_pathname, int mb_cached,
const char * mb_cache_directory, const char * mb_flags_directory);
enum {
MBOXDRIVER_SET_READ_ONLY = 1,
MBOXDRIVER_SET_NO_UID
}
struct mbox_session_state_data {
mailmbox_folder * mbox_folder;
int mbox_force_read_only;
int mbox_force_no_uid;
}
/* cached version */
enum {
/* the mapping of the parameters should be the same as for mbox */
MBOXDRIVER_CACHED_SET_READ_ONLY = 1,
MBOXDRIVER_CACHED_SET_NO_UID,
/* cache specific */
MBOXDRIVER_CACHED_SET_CACHE_DIRECTORY,
MBOXDRIVER_CACHED_SET_FLAGS_DIRECTORY
}
struct mbox_cached_session_state_data {
mailsession * mbox_ancestor;
char * mbox_quoted_mb;
char mbox_cache_directory[PATH_MAX];
char mbox_flags_directory[PATH_MAX];
mail_flags_store * mbox_flags_store;
}
struct mbox_mailstorage {
char * mbox_pathname;
int mbox_cached;
char * mbox_cache_directory;
char * mbox_flags_directory;
}
__gshared mailsession_driver * mbox_session_driver;
__gshared mailsession_driver * mbox_cached_session_driver;
int mboxdriver_mbox_error_to_mail_error(int error);
int mboxdriver_fetch_msg(mailsession * session, uint32_t indx, char ** result, size_t * result_len);
int mboxdriver_fetch_size(mailsession * session, uint32_t indx, size_t * result);
int mboxdriver_get_cached_flags(mail_cache_db * cache_db, MMAPString * mmapstr, mailsession * session,
uint32_t num, mail_flags ** result);
int mboxdriver_write_cached_flags(mail_cache_db * cache_db, MMAPString * mmapstr, char * uid, mail_flags * flags);
int mbox_get_uid_messages_list(mailmbox_folder * folder, mailsession * session, mailmessage_driver * driver, mailmessage_list ** result);
int mbox_get_messages_list(mailmbox_folder * folder, mailsession * session, mailmessage_driver * driver, mailmessage_list ** result);
int mboxdriver_fetch_header(mailsession * session, uint32_t indx, char ** result, size_t * result_len);
int hotmail_mailstorage_init(mailstorage * storage, char * hotmail_login, char * hotmail_password, int hotmail_cached, char * hotmail_cache_directory, char * hotmail_flags_directory);
__gshared mailmessage_driver * data_message_driver;
__gshared mailmessage * data_message_init(char * data, size_t len);
void data_message_detach_mime(mailmessage * msg);
enum {
MAIL_THREAD_REFERENCES, /* this is threading using
References fields only) */
MAIL_THREAD_REFERENCES_NO_SUBJECT, /* this is threading using References
fields, then subject */
MAIL_THREAD_ORDEREDSUBJECT, /* this is threading using only subject */
MAIL_THREAD_NONE /* no thread */
}
int generic_cache_create_dir(char * dirname);
int generic_cache_store(char * filename, char * content, size_t length);
int generic_cache_read(char * filename, char ** result, size_t * result_len);
int generic_cache_fields_read(mail_cache_db * cache_db, MMAPString * mmapstr, char * keyname, mailimf_fields ** result);
int generic_cache_fields_write(mail_cache_db * cache_db, MMAPString * mmapstr, char * keyname, mailimf_fields * fields);
int generic_cache_flags_read(mail_cache_db * cache_db, MMAPString * mmapstr, char * keyname, mail_flags ** result);
int generic_cache_flags_write( mail_cache_db * cache_db, MMAPString * mmapstr, char * keyname, mail_flags * flags);
int generic_cache_delete( mail_cache_db * cache_db, char * keyname);
mail_flags_store * mail_flags_store_new();
void mail_flags_store_clear( mail_flags_store * flags_store);
void mail_flags_store_free( mail_flags_store * flags_store);
int mail_flags_store_set( mail_flags_store * flags_store, mailmessage * msg);
void mail_flags_store_sort( mail_flags_store * flags_store);
mail_flags * mail_flags_store_get( mail_flags_store * flags_store, uint32_t indx);
int mail_flags_compare( mail_flags * flags1, mail_flags * flags2);
struct mail_flags_store {
carray * fls_tab;
chash * fls_hash;
};
int mail_serialize_clear(MMAPString * mmapstr, size_t * indx);
int mail_serialize_write(MMAPString * mmapstr, size_t * indx, char * buf, size_t size);
int mail_serialize_read(MMAPString * mmapstr, size_t * indx, char * buf, size_t size);
int mailimf_cache_int_write(MMAPString * mmapstr, size_t * indx, uint32_t value);
int mailimf_cache_string_write(MMAPString * mmapstr, size_t * indx, char * str, size_t length);
int mailimf_cache_int_read(MMAPString * mmapstr, size_t * indx, uint32_t * result);
int mailimf_cache_string_read(MMAPString * mmapstr, size_t * indx, char ** result);
int mailimf_cache_fields_write(MMAPString * mmapstr, size_t * indx, mailimf_fields * fields);
int mailimf_cache_fields_read(MMAPString * mmapstr, size_t * indx, mailimf_fields ** result);
int mail_build_thread(int type, char * default_from, mailmessage_list * env_list, mailmessage_tree ** result, int function( mailmessage_tree **, mailmessage_tree **) comp_func);
int mail_thread_sort( mailmessage_tree * tree, int function( mailmessage_tree **, mailmessage_tree **) comp_func, int sort_sub);
int mailthread_tree_timecomp( mailmessage_tree ** ptree1, mailmessage_tree ** ptree2);
struct mailstorage_driver {
char * sto_name;
int function(mailstorage * storage) sto_connect;
int function(mailstorage * storage, char * pathname, mailsession ** result) sto_get_folder_session;
void function(mailstorage * storage) sto_uninitialize;
}
struct mailstorage {
char * sto_id;
void * sto_data;
mailsession * sto_session;
mailstorage_driver * sto_driver;
clist * sto_shared_folders; /* list of (struct mailfolder *) */
void * sto_user_data;
}
struct mailfolder {
char * fld_pathname;
char * fld_virtual_name;
mailstorage * fld_storage;
mailsession * fld_session;
int fld_shared_session;
clistiter * fld_pos;
mailfolder * fld_parent;
uint fld_sibling_index;
carray * fld_children; /* array of (struct mailfolder *) */
void * fld_user_data;
}
enum {
CONNECTION_TYPE_PLAIN, /* when the connection is plain text */
CONNECTION_TYPE_STARTTLS, /* when the connection is first plain,
then, we want to switch to
TLS (secure connection) */
CONNECTION_TYPE_TRY_STARTTLS, /* the connection is first plain,
then, we will try to switch to TLS */
CONNECTION_TYPE_TLS, /* the connection is over TLS */
CONNECTION_TYPE_COMMAND, /* the connection is over a shell command */
CONNECTION_TYPE_COMMAND_STARTTLS, /* the connection is over a shell
command and STARTTLS will be used */
CONNECTION_TYPE_COMMAND_TRY_STARTTLS, /* the connection is over
a shell command and STARTTLS will
be tried */
CONNECTION_TYPE_COMMAND_TLS /* the connection is over a shell
command in TLS */
}
int mailfolder_noop( mailfolder * folder);
int mailfolder_check( mailfolder * folder);
int mailfolder_expunge( mailfolder * folder);
int mailfolder_status( mailfolder * folder, uint32_t * result_messages, uint32_t * result_recent, uint32_t * result_unseen);
int mailfolder_append_message( mailfolder * folder, char * message, size_t size);
int mailfolder_append_message_flags( mailfolder * folder, char * message, size_t size, mail_flags * flags);
int mailfolder_get_messages_list( mailfolder * folder, mailmessage_list ** result);
int mailfolder_get_envelopes_list( mailfolder * folder, mailmessage_list * result);
int mailfolder_get_message( mailfolder * folder, uint32_t num, mailmessage ** result);
int mailfolder_get_message_by_uid( mailfolder * folder, const char * uid, mailmessage ** result);
enum {
MAIL_NO_ERROR = 0,
MAIL_NO_ERROR_AUTHENTICATED,
MAIL_NO_ERROR_NON_AUTHENTICATED,
MAIL_ERROR_NOT_IMPLEMENTED,
MAIL_ERROR_UNKNOWN,
MAIL_ERROR_CONNECT,
MAIL_ERROR_BAD_STATE,
MAIL_ERROR_FILE,
MAIL_ERROR_STREAM,
MAIL_ERROR_LOGIN,
MAIL_ERROR_CREATE, /* 10 */
MAIL_ERROR_DELETE,
MAIL_ERROR_LOGOUT,
MAIL_ERROR_NOOP,
MAIL_ERROR_RENAME,
MAIL_ERROR_CHECK,
MAIL_ERROR_EXAMINE,
MAIL_ERROR_SELECT,
MAIL_ERROR_MEMORY,
MAIL_ERROR_STATUS,
MAIL_ERROR_SUBSCRIBE, /* 20 */
MAIL_ERROR_UNSUBSCRIBE,
MAIL_ERROR_LIST,
MAIL_ERROR_LSUB,
MAIL_ERROR_APPEND,
MAIL_ERROR_COPY,
MAIL_ERROR_FETCH,
MAIL_ERROR_STORE,
MAIL_ERROR_SEARCH,
MAIL_ERROR_DISKSPACE,
MAIL_ERROR_MSG_NOT_FOUND, /* 30 */
MAIL_ERROR_PARSE,
MAIL_ERROR_INVAL,
MAIL_ERROR_PART_NOT_FOUND,
MAIL_ERROR_REMOVE,
MAIL_ERROR_FOLDER_NOT_FOUND,
MAIL_ERROR_MOVE,
MAIL_ERROR_STARTTLS,
MAIL_ERROR_CACHE_MISS,
MAIL_ERROR_NO_TLS,
MAIL_ERROR_EXPUNGE, /* 40 */
/* misc errors */
MAIL_ERROR_MISC,
MAIL_ERROR_PROTOCOL,
MAIL_ERROR_CAPABILITY,
MAIL_ERROR_CLOSE,
MAIL_ERROR_FATAL,
MAIL_ERROR_READONLY,
MAIL_ERROR_NO_APOP,
MAIL_ERROR_COMMAND_NOT_SUPPORTED,
MAIL_ERROR_NO_PERMISSION,
MAIL_ERROR_PROGRAM_ERROR, /* 50 */
MAIL_ERROR_SUBJECT_NOT_FOUND,
MAIL_ERROR_CHAR_ENCODING_FAILED,
MAIL_ERROR_SEND,
MAIL_ERROR_COMMAND,
MAIL_ERROR_SYSTEM,
MAIL_ERROR_UNABLE,
MAIL_ERROR_FOLDER,
MAIL_ERROR_SSL
}
int mail_flags_add_extension(mail_flags * flags, char * ext_flag);
int mail_flags_remove_extension( mail_flags * flags, char * ext_flag);
int mail_flags_has_extension( mail_flags * flags, char * ext_flag);
struct mailmessage_list {
carray * msg_tab; /* elements are (mailmessage *) */
}
mailmessage_list * mailmessage_list_new(carray * msg_tab);
void mailmessage_list_free(mailmessage_list * env_list);
struct mail_list {
clist * mb_list; /* elements are (char *) */
};
mail_list * mail_list_new(clist * mb_list);
void mail_list_free(mail_list * resp);
enum {
MAIL_FLAG_NEW = 1 << 0,
MAIL_FLAG_SEEN = 1 << 1,
MAIL_FLAG_FLAGGED = 1 << 2,
MAIL_FLAG_DELETED = 1 << 3,
MAIL_FLAG_ANSWERED = 1 << 4,
MAIL_FLAG_FORWARDED = 1 << 5,
MAIL_FLAG_CANCELLED = 1 << 6
}
struct mail_flags {
uint32_t fl_flags;
clist * fl_extension; /* elements are (char *) */
}
mail_flags * mail_flags_new(uint32_t fl_flags, clist * fl_ext);
void mail_flags_free(mail_flags * flags);
mail_flags * mail_flags_new_empty();
int32_t mailimf_date_time_comp( mailimf_date_time * date1, mailimf_date_time * date2);
enum {
MAIL_SEARCH_KEY_ALL, /* all messages correspond */
MAIL_SEARCH_KEY_ANSWERED, /* messages with flag \Answered */
MAIL_SEARCH_KEY_BCC, /* messages which Bcc field contains
a given string */
MAIL_SEARCH_KEY_BEFORE, /* messages which internal date is earlier
than the specified date */
MAIL_SEARCH_KEY_BODY, /* message that contains the given string
(in header and text parts) */
MAIL_SEARCH_KEY_CC, /* messages whose Cc field contains the
given string */
MAIL_SEARCH_KEY_DELETED, /* messages with the flag \Deleted */
MAIL_SEARCH_KEY_FLAGGED, /* messages with the flag \Flagged */
MAIL_SEARCH_KEY_FROM, /* messages whose From field contains the
given string */
MAIL_SEARCH_KEY_NEW, /* messages with the flag \Recent and not
the \Seen flag */
MAIL_SEARCH_KEY_OLD, /* messages that do not have the
\Recent flag set */
MAIL_SEARCH_KEY_ON, /* messages whose internal date is the
specified date */
MAIL_SEARCH_KEY_RECENT, /* messages with the flag \Recent */
MAIL_SEARCH_KEY_SEEN, /* messages with the flag \Seen */
MAIL_SEARCH_KEY_SINCE, /* messages whose internal date is later
than specified date */
MAIL_SEARCH_KEY_SUBJECT, /* messages whose Subject field contains the
given string */
MAIL_SEARCH_KEY_TEXT, /* messages whose text part contains the
given string */
MAIL_SEARCH_KEY_TO, /* messages whose To field contains the
given string */
MAIL_SEARCH_KEY_UNANSWERED, /* messages with no flag \Answered */
MAIL_SEARCH_KEY_UNDELETED, /* messages with no flag \Deleted */
MAIL_SEARCH_KEY_UNFLAGGED, /* messages with no flag \Flagged */
MAIL_SEARCH_KEY_UNSEEN, /* messages with no flag \Seen */
MAIL_SEARCH_KEY_HEADER, /* messages whose given field
contains the given string */
MAIL_SEARCH_KEY_LARGER, /* messages whose size is larger then
the given size */
MAIL_SEARCH_KEY_NOT, /* not operation of the condition */
MAIL_SEARCH_KEY_OR, /* or operation between two conditions */
MAIL_SEARCH_KEY_SMALLER, /* messages whose size is smaller than
the given size */
MAIL_SEARCH_KEY_MULTIPLE /* the boolean operator between the
conditions is AND */
}
struct mailsession_driver {
char * sess_name;
int function(mailsession * session) sess_initialize;
void function(mailsession * session) sess_uninitialize;
int function(mailsession * session, int id, void * value) sess_parameters;
int function(mailsession * session, mailstream * s) sess_connect_stream;
int function(mailsession * session, const char * path) sess_connect_path;
int function(mailsession * session) sess_starttls;
int function(mailsession * session, const char * userid, const char * password) sess_login;
int function(mailsession * session) sess_logout;
int function(mailsession * session) sess_noop;
int function(mailsession * session, const char * mb, const char * name, char ** result) sess_build_folder_name;
int function(mailsession * session, const char * mb) sess_create_folder;
int function(mailsession * session, const char * mb) sess_delete_folder;
int function(mailsession * session, const char * mb, const char * new_name) sess_rename_folder;
int function(mailsession * session) sess_check_folder;
int function(mailsession * session, const char * mb) sess_examine_folder;
int function(mailsession * session, const char * mb) sess_select_folder;
int function(mailsession * session) sess_expunge_folder;
int function(mailsession * session, const char * mb, uint32_t * result_num, uint32_t * result_recent, uint32_t * result_unseen) sess_status_folder;
int function(mailsession * session, const char * mb, uint32_t * result) sess_messages_number;
int function(mailsession * session, const char * mb, uint32_t * result) sess_recent_number;
int function(mailsession * session, const char * mb, uint32_t * result) sess_unseen_number;
int function(mailsession * session, const char * mb, mail_list ** result) sess_list_folders;
int function(mailsession * session, const char * mb, mail_list ** result) sess_lsub_folders;
int function(mailsession * session, const char * mb) sess_subscribe_folder;
int function(mailsession * session, const char * mb) sess_unsubscribe_folder;
int function(mailsession * session, const char * message, size_t size) sess_append_message;
int function(mailsession * session, const char * message, size_t size, mail_flags * flags) sess_append_message_flags;
int function(mailsession * session, uint32_t num, const char * mb) sess_copy_message;
int function(mailsession * session, uint32_t num, const char * mb) sess_move_message;
int function(mailsession * session, uint32_t num, mailmessage ** result) sess_get_message;
int function(mailsession * session, const char * uid, mailmessage ** result) sess_get_message_by_uid;
int function(mailsession * session, mailmessage_list ** result) sess_get_messages_list;
int function(mailsession * session, mailmessage_list * env_list) sess_get_envelopes_list;
int function(mailsession * session, uint32_t num) sess_remove_message;
int function(mailsession * session, const char * auth_type, const char * server_fqdn, const char * local_ip_port, const char * remote_ip_port, const char * login, const char * auth_name, const char * password, const char * realm) sess_login_sasl;
}
struct mailsession {
void * sess_data;
mailsession_driver * sess_driver;
}
struct mailmessage_driver
{
char * msg_name;
int function(mailmessage * msg_info) msg_initialize;
void function(mailmessage * msg_info) msg_uninitialize;
void function(mailmessage * msg_info) msg_flush;
void function(mailmessage * msg_info) msg_check;
void function(mailmessage * msg_info, char * msg) msg_fetch_result_free;
int function(mailmessage * msg_info, char ** result, size_t * result_len) msg_fetch;
int function(mailmessage * msg_info, char ** result, size_t * result_len) msg_fetch_header;
int function(mailmessage * msg_info, char ** result, size_t * result_len) msg_fetch_body;
int function(mailmessage * msg_info, size_t * result) msg_fetch_size;
int function(mailmessage * msg_info, mailmime ** result) msg_get_bodystructure;
int function(mailmessage * msg_info, mailmime * mime, char ** result, size_t * result_len) msg_fetch_section;
int function(mailmessage * msg_info, mailmime * mime, char ** result, size_t * result_len) msg_fetch_section_header;
int function(mailmessage * msg_info, mailmime * mime, char ** result, size_t * result_len) msg_fetch_section_mime;
int function(mailmessage * msg_info, mailmime * mime, char ** result, size_t * result_len) msg_fetch_section_body;
int function(mailmessage * msg_info, mailimf_fields ** result) msg_fetch_envelope;
int function(mailmessage * msg_info, mail_flags ** result) msg_get_flags;
}
struct mailmessage {
mailsession * msg_session;
mailmessage_driver * msg_driver;
uint32_t msg_index;
char * msg_uid;
size_t msg_size;
mailimf_fields * msg_fields;
mail_flags * msg_flags;
int msg_resolved;
mailimf_single_fields msg_single_fields;
mailmime * msg_mime;
int msg_cached;
void * msg_data;
void * msg_folder;
void * msg_user_data;
}
struct mailmessage_tree {
mailmessage_tree * node_parent;
char * node_msgid;
time_t node_date;
mailmessage * node_msg;
carray * node_children; /* array of (struct mailmessage_tree *) */
int node_is_reply;
char * node_base_subject;
}
mailmessage_tree * mailmessage_tree_new(char * node_msgid, time_t node_date, mailmessage * node_msg);
void mailmessage_tree_free(mailmessage_tree *tree);
void mailmessage_tree_free_recursive(mailmessage_tree * tree);
struct generic_message_t {
int function(mailmessage * msg_info) msg_prefetch;
void function(generic_message_t * msg) * msg_prefetch_free;
int msg_fetched;
char * msg_message;
size_t msg_length;
void * msg_data;
};
char * maildriver_strerror(int err);
void *libetpan_malloc(size_t length);
void libetpan_free(void* data);
int mailstorage_generic_connect(mailsession_driver * driver, char * servername, uint16_t port, char * command, int connection_type, int cache_function_id, char * cache_directory, int flags_function_id, char * flags_directory, mailsession ** result);
int mailstorage_generic_connect_with_local_address(mailsession_driver * driver, char * servername, uint16_t port, char * local_address, uint16_t local_port, char * command, int connection_type, int cache_function_id, char * cache_directory, int flags_function_id, char * flags_directory, mailsession ** result);
int mailstorage_generic_auth(mailsession * session, int connect_result, int auth_type, char * login, char * password);
int mailstorage_generic_auth_sasl(mailsession * session, int connect_result, const char * auth_type, const char * server_fqdn, const char * local_ip_port, const char * remote_ip_port, const char * login, const char * auth_name, const char * password, const char * realm);
mailstorage * mailstorage_new(const char * sto_id);
void mailstorage_free(mailstorage * storage);
int mailstorage_connect(mailstorage * storage);
void mailstorage_disconnect(mailstorage * storage);
int mailstorage_noop(mailstorage * storage);
mailfolder * mailfolder_new( mailstorage * fld_storage, const char * fld_pathname, const char * fld_virtual_name);
void mailfolder_free( mailfolder * folder);
int mailfolder_add_child( mailfolder * parent, mailfolder * child);
int mailfolder_detach_parent( mailfolder * folder);
int mailfolder_connect( mailfolder * folder);
void mailfolder_disconnect( mailfolder * folder);
mailsession * mailsession_new(mailsession_driver * sess_driver);
void mailsession_free(mailsession * session);
int mailsession_parameters(mailsession * session, int id, void * value);
int mailsession_connect_stream(mailsession * session, mailstream * s);
int mailsession_connect_path(mailsession * session, const char * path);
int mailsession_starttls(mailsession * session);
int mailsession_login(mailsession * session, const char * userid, const char * password);
int mailsession_logout(mailsession * session);
int mailsession_noop(mailsession * session);
int mailsession_build_folder_name(mailsession * session, const char * mb, const char * name, char ** result);
int mailsession_create_folder(mailsession * session, const char * mb);
int mailsession_delete_folder(mailsession * session, const char * mb);
int mailsession_rename_folder(mailsession * session, const char * mb, const char * new_name);
int mailsession_check_folder(mailsession * session);
int mailsession_examine_folder(mailsession * session, const char * mb);
int mailsession_select_folder(mailsession * session, const char * mb);
int mailsession_expunge_folder(mailsession * session);
int mailsession_status_folder(mailsession * session, const char * mb, uint32_t * result_messages, uint32_t * result_recent, uint32_t * result_unseen);
int mailsession_messages_number(mailsession * session, const char * mb, uint32_t * result);
int mailsession_recent_number(mailsession * session, const char * mb, uint32_t * result);
int mailsession_unseen_number(mailsession * session, const char * mb, uint32_t * result);
int mailsession_list_folders(mailsession * session, const char * mb, mail_list ** result);
int mailsession_lsub_folders(mailsession * session, const char * mb, mail_list ** result);
int mailsession_subscribe_folder(mailsession * session, const char * mb);
int mailsession_unsubscribe_folder(mailsession * session, const char * mb);
int mailsession_append_message(mailsession * session, const char * message, size_t size);
int mailsession_append_message_flags(mailsession * session, const char * message, size_t size, mail_flags * flags);
int mailsession_copy_message(mailsession * session, uint32_t num, const char * mb);
int mailsession_move_message(mailsession * session, uint32_t num, const char * mb);
int mailsession_get_messages_list(mailsession * session, mailmessage_list ** result);
int mailsession_get_envelopes_list(mailsession * session, mailmessage_list * result);
int mailsession_remove_message(mailsession * session, uint32_t num);
int mailsession_get_message(mailsession * session, uint32_t num, mailmessage ** result);
int mailsession_get_message_by_uid(mailsession * session, const char * uid, mailmessage ** result);
int mailsession_login_sasl(mailsession * session, const char * auth_type, const char * server_fqdn, const char * local_ip_port, const char * remote_ip_port, const char * login, const char * auth_name, const char * password, const char * realm);
int mailmessage_generic_initialize(mailmessage * msg_info);
void mailmessage_generic_uninitialize(mailmessage * msg_info);
void mailmessage_generic_flush(mailmessage * msg_info);
void mailmessage_generic_fetch_result_free(mailmessage * msg_info, char * msg);
int mailmessage_generic_fetch(mailmessage * msg_info, char ** result, size_t * result_len);
int mailmessage_generic_fetch_header(mailmessage * msg_info, char ** result, size_t * result_len);
int mailmessage_generic_fetch_body(mailmessage * msg_info, char ** result, size_t * result_len);
int mailmessage_generic_get_bodystructure(mailmessage * msg_info, mailmime ** result);
int mailmessage_generic_fetch_section(mailmessage * msg_info, mailmime * mime, char ** result, size_t * result_len);
int mailmessage_generic_fetch_section_header(mailmessage * msg_info, mailmime * mime, char ** result, size_t * result_len);
int mailmessage_generic_fetch_section_mime(mailmessage * msg_info, mailmime * mime, char ** result, size_t * result_len);
int mailmessage_generic_fetch_section_body(mailmessage * msg_info, mailmime * mime, char ** result, size_t * result_len);
int mailmessage_generic_fetch_envelope(mailmessage * msg_info, mailimf_fields ** result);
int maildriver_generic_get_envelopes_list(mailsession * session, mailmessage_list * env_list);
int maildriver_env_list_to_msg_list(mailmessage_list * env_list, clist ** result);
int maildriver_imf_error_to_mail_error(int error);
char * maildriver_quote_mailbox(const char * mb);
int maildriver_env_list_to_msg_list_no_flags( mailmessage_list * env_list, clist ** result);
int maildriver_cache_clean_up(mail_cache_db * cache_db_env, mail_cache_db * cache_db_flags, mailmessage_list * env_list);
int maildriver_message_cache_clean_up(char * cache_dir, mailmessage_list * env_list, void function(char *) get_uid_from_filename);
mailmessage * mailmessage_new();
void mailmessage_free(mailmessage * info);