Split mh_init() in two. The second part,
mh_init2(), gets called after parsing the arguments. (mh_open_folder): New function. Open current folder.
Showing
1 changed file
with
29 additions
and
2 deletions
... | @@ -24,7 +24,7 @@ | ... | @@ -24,7 +24,7 @@ |
24 | #include <stdarg.h> | 24 | #include <stdarg.h> |
25 | 25 | ||
26 | char *current_folder = NULL; | 26 | char *current_folder = NULL; |
27 | size_t current_message; | 27 | size_t current_message = 0; |
28 | char *ctx_name; | 28 | char *ctx_name; |
29 | header_t ctx_header; | 29 | header_t ctx_header; |
30 | header_t profile_header; | 30 | header_t profile_header; |
... | @@ -42,7 +42,6 @@ void | ... | @@ -42,7 +42,6 @@ void |
42 | mh_init () | 42 | mh_init () |
43 | { | 43 | { |
44 | list_t bookie; | 44 | list_t bookie; |
45 | char *mh_sequences_name; | ||
46 | 45 | ||
47 | /* Register mailbox formats */ | 46 | /* Register mailbox formats */ |
48 | registrar_get_list (&bookie); | 47 | registrar_get_list (&bookie); |
... | @@ -57,6 +56,12 @@ mh_init () | ... | @@ -57,6 +56,12 @@ mh_init () |
57 | 56 | ||
58 | /* Read user's profile */ | 57 | /* Read user's profile */ |
59 | mh_read_profile (); | 58 | mh_read_profile (); |
59 | } | ||
60 | |||
61 | void | ||
62 | mh_init2 () | ||
63 | { | ||
64 | char *mh_sequences_name; | ||
60 | 65 | ||
61 | /* Set MH context */ | 66 | /* Set MH context */ |
62 | if (current_folder) | 67 | if (current_folder) |
... | @@ -424,3 +429,25 @@ mh_message_number (message_t msg, size_t *pnum) | ... | @@ -424,3 +429,25 @@ mh_message_number (message_t msg, size_t *pnum) |
424 | { | 429 | { |
425 | return message_get_uid (msg, pnum); | 430 | return message_get_uid (msg, pnum); |
426 | } | 431 | } |
432 | |||
433 | mailbox_t | ||
434 | mh_open_folder () | ||
435 | { | ||
436 | mailbox_t mbox = NULL; | ||
437 | |||
438 | if (mailbox_create_default (&mbox, current_folder)) | ||
439 | { | ||
440 | mh_error ("Can't create mailbox %s: %s", | ||
441 | current_folder, strerror (errno)); | ||
442 | exit (1); | ||
443 | } | ||
444 | |||
445 | if (mailbox_open (mbox, MU_STREAM_READ)) | ||
446 | { | ||
447 | mh_error ("Can't open mailbox %s: %s", current_folder, strerror (errno)); | ||
448 | exit (1); | ||
449 | } | ||
450 | |||
451 | return mbox; | ||
452 | } | ||
453 | ... | ... |
-
Please register or sign in to post a comment