(mda): Changed prototype.
(struct mda_data): Replaced FILE *fp with message_t msg.
Showing
2 changed files
with
8 additions
and
28 deletions
... | @@ -102,18 +102,18 @@ extern int exit_code; | ... | @@ -102,18 +102,18 @@ extern int exit_code; |
102 | extern void setgroupquota __P((char *str)); | 102 | extern void setgroupquota __P((char *str)); |
103 | extern int check_quota __P((char *name, size_t size, size_t *rest)); | 103 | extern int check_quota __P((char *name, size_t size, size_t *rest)); |
104 | 104 | ||
105 | int mda __P((FILE *fp, char *username)); | 105 | int mda __P((message_t msg, char *username)); |
106 | int switch_user_id __P((struct mu_auth_data *auth, int user)); | 106 | int switch_user_id __P((struct mu_auth_data *auth, int user)); |
107 | void mailer_err __P((char *fmt, ...)); | 107 | void mailer_err __P((char *fmt, ...)); |
108 | 108 | ||
109 | #ifdef WITH_GUILE | 109 | #ifdef WITH_GUILE |
110 | struct mda_data | 110 | struct mda_data |
111 | { | 111 | { |
112 | FILE *fp; | 112 | message_t msg; |
113 | char *tempfile; | ||
113 | char *progfile; | 114 | char *progfile; |
114 | char *progfile_pattern; | 115 | char *progfile_pattern; |
115 | char **argv; | 116 | char **argv; |
116 | char *tempfile; | ||
117 | }; | 117 | }; |
118 | 118 | ||
119 | int prog_mda (struct mda_data *data); | 119 | int prog_mda (struct mda_data *data); | ... | ... |
... | @@ -34,11 +34,13 @@ prog_mda (struct mda_data *data) | ... | @@ -34,11 +34,13 @@ prog_mda (struct mda_data *data) |
34 | char *x_argv[2]; | 34 | char *x_argv[2]; |
35 | guimb_param_t param; | 35 | guimb_param_t param; |
36 | mailbox_t mbox; | 36 | mailbox_t mbox; |
37 | 37 | stream_t stream = NULL; | |
38 | |||
38 | x_argv[0] = "mail.local"; | 39 | x_argv[0] = "mail.local"; |
39 | x_argv[1] = NULL; | 40 | x_argv[1] = NULL; |
40 | 41 | ||
41 | fflush (data->fp); | 42 | message_get_stream (data->msg, &stream); |
43 | stream_flush (stream); | ||
42 | if (mailbox_create (&mbox, data->tempfile) | 44 | if (mailbox_create (&mbox, data->tempfile) |
43 | || mailbox_open (mbox, MU_STREAM_RDWR) != 0) | 45 | || mailbox_open (mbox, MU_STREAM_RDWR) != 0) |
44 | { | 46 | { |
... | @@ -97,7 +99,6 @@ mda_catch_body (void *data, mailbox_t mbox) | ... | @@ -97,7 +99,6 @@ mda_catch_body (void *data, mailbox_t mbox) |
97 | struct mda_data *md = data; | 99 | struct mda_data *md = data; |
98 | message_t mesg = NULL; | 100 | message_t mesg = NULL; |
99 | attribute_t attr = NULL; | 101 | attribute_t attr = NULL; |
100 | FILE *fp = md->fp; | ||
101 | 102 | ||
102 | if (access (md->progfile, R_OK)) | 103 | if (access (md->progfile, R_OK)) |
103 | { | 104 | { |
... | @@ -115,29 +116,8 @@ mda_catch_body (void *data, mailbox_t mbox) | ... | @@ -115,29 +116,8 @@ mda_catch_body (void *data, mailbox_t mbox) |
115 | if (attribute_is_deleted (attr)) | 116 | if (attribute_is_deleted (attr)) |
116 | return SCM_BOOL_F; | 117 | return SCM_BOOL_F; |
117 | 118 | ||
118 | if (message_is_modified (mesg)) | ||
119 | { | ||
120 | char *tname; | ||
121 | int fd = mu_tempfile (NULL, &tname); | ||
122 | mailbox_t tmp; | ||
123 | |||
124 | close (fd); | ||
125 | if (mailbox_create (&tmp, tname) == 0 | ||
126 | && mailbox_open (tmp, MU_STREAM_RDWR) == 0) | ||
127 | { | ||
128 | mailbox_append_message (tmp, mesg); | ||
129 | mailbox_close (tmp); | ||
130 | mailbox_destroy (&tmp); | ||
131 | |||
132 | fp = fopen (tname, "r"); | ||
133 | } | ||
134 | unlink (tname); | ||
135 | } | ||
136 | |||
137 | mda_switch_to_user (NULL); | 119 | mda_switch_to_user (NULL); |
138 | mda (fp, md->argv[0]); | 120 | mda (md->msg, md->argv[0]); |
139 | if (fp != md->fp) | ||
140 | fclose (fp); | ||
141 | return SCM_BOOL_F; | 121 | return SCM_BOOL_F; |
142 | } | 122 | } |
143 | 123 | ... | ... |
-
Please register or sign in to post a comment