Do not use deprecated Guile functions.
* libmu_scm/mu_address.c: Use scm_to_locale_string instead of relying on scm_i_string_chars. * libmu_scm/mu_logger.c: Likewise. * libmu_scm/mu_mailbox.c: Likewise. * libmu_scm/mu_scm.c: Likewise. * libmu_scm/mu_util.c: Likewise. * libmu_scm/mu_message.c: Likewise. (mu_scm_message_add_owner): Don't use SCM_NEWCELL. (mu-message-get-envelope) (mu-message-get-envelope-date): New functions. (string_sloppy_member): Compare scm_i_string_length bytes from the car. (mu-message-get-header-fields): Don't use SCM_NEWCELL. * libmu_scm/mu_port.c (mu_port_make_from_stream): Don't use SCM_NEWCELL.
Showing
7 changed files
with
212 additions
and
80 deletions
... | @@ -42,12 +42,15 @@ _get_address_part (const char *func_name, address_get_fp fun, | ... | @@ -42,12 +42,15 @@ _get_address_part (const char *func_name, address_get_fp fun, |
42 | else | 42 | else |
43 | num = 1; | 43 | num = 1; |
44 | 44 | ||
45 | length = strlen (scm_i_string_chars (ADDRESS)); | 45 | str = scm_to_locale_string (ADDRESS); |
46 | if (length == 0) | 46 | if (!str[0]) |
47 | mu_scm_error (func_name, 0, | 47 | { |
48 | "Empty address", SCM_BOOL_F); | 48 | free (str); |
49 | mu_scm_error (func_name, 0, "Empty address", SCM_BOOL_F); | ||
50 | } | ||
49 | 51 | ||
50 | status = mu_address_create (&addr, scm_i_string_chars (ADDRESS)); | 52 | status = mu_address_create (&addr, str); |
53 | free (str); | ||
51 | if (status) | 54 | if (status) |
52 | mu_scm_error (func_name, status, "Cannot create address", SCM_BOOL_F); | 55 | mu_scm_error (func_name, status, "Cannot create address", SCM_BOOL_F); |
53 | 56 | ||
... | @@ -133,10 +136,13 @@ SCM_DEFINE (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0, | ... | @@ -133,10 +136,13 @@ SCM_DEFINE (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0, |
133 | mu_address_t addr; | 136 | mu_address_t addr; |
134 | size_t count = 0; | 137 | size_t count = 0; |
135 | int status; | 138 | int status; |
139 | char *str; | ||
136 | 140 | ||
137 | SCM_ASSERT (scm_is_string (ADDRESS), ADDRESS, SCM_ARG1, FUNC_NAME); | 141 | SCM_ASSERT (scm_is_string (ADDRESS), ADDRESS, SCM_ARG1, FUNC_NAME); |
138 | 142 | ||
139 | status = mu_address_create (&addr, scm_i_string_chars (ADDRESS)); | 143 | str = scm_to_locale_string (ADDRESS); |
144 | status = mu_address_create (&addr, str); | ||
145 | free (str); | ||
140 | if (status) | 146 | if (status) |
141 | mu_scm_error (FUNC_NAME, status, | 147 | mu_scm_error (FUNC_NAME, status, |
142 | "Cannot create address for ~A", | 148 | "Cannot create address for ~A", |
... | @@ -154,7 +160,7 @@ SCM_DEFINE (scm_mu_username_to_email, "mu-username->email", 0, 1, 0, | ... | @@ -154,7 +160,7 @@ SCM_DEFINE (scm_mu_username_to_email, "mu-username->email", 0, 1, 0, |
154 | "current username is assumed\n") | 160 | "current username is assumed\n") |
155 | #define FUNC_NAME s_scm_mu_username_to_email | 161 | #define FUNC_NAME s_scm_mu_username_to_email |
156 | { | 162 | { |
157 | const char *name; | 163 | char *name; |
158 | char *email; | 164 | char *email; |
159 | SCM ret; | 165 | SCM ret; |
160 | 166 | ||
... | @@ -163,14 +169,15 @@ SCM_DEFINE (scm_mu_username_to_email, "mu-username->email", 0, 1, 0, | ... | @@ -163,14 +169,15 @@ SCM_DEFINE (scm_mu_username_to_email, "mu-username->email", 0, 1, 0, |
163 | else | 169 | else |
164 | { | 170 | { |
165 | SCM_ASSERT (scm_is_string (NAME), NAME, SCM_ARG1, FUNC_NAME); | 171 | SCM_ASSERT (scm_is_string (NAME), NAME, SCM_ARG1, FUNC_NAME); |
166 | name = scm_i_string_chars (NAME); | 172 | name = scm_to_locale_string (NAME); |
167 | } | 173 | } |
168 | 174 | ||
169 | email = mu_get_user_email (name); | 175 | email = mu_get_user_email (name); |
176 | free (name); | ||
170 | if (!email) | 177 | if (!email) |
171 | mu_scm_error (FUNC_NAME, 0, | 178 | mu_scm_error (FUNC_NAME, 0, |
172 | "Cannot get user email for ~A", | 179 | "Cannot get user email for ~A", |
173 | scm_list_1 (scm_makfrom0str (name))); | 180 | scm_list_1 (NAME)); |
174 | 181 | ||
175 | ret = scm_makfrom0str (email); | 182 | ret = scm_makfrom0str (email); |
176 | free (email); | 183 | free (email); | ... | ... |
... | @@ -27,7 +27,7 @@ SCM_DEFINE (scm_mu_openlog, "mu-openlog", 3, 0, 0, | ... | @@ -27,7 +27,7 @@ SCM_DEFINE (scm_mu_openlog, "mu-openlog", 3, 0, 0, |
27 | "IDENT, OPTION and FACILITY have the same meaning as in openlog(3)") | 27 | "IDENT, OPTION and FACILITY have the same meaning as in openlog(3)") |
28 | #define FUNC_NAME s_scm_mu_openlog | 28 | #define FUNC_NAME s_scm_mu_openlog |
29 | { | 29 | { |
30 | const char *ident; | 30 | char *ident, *ident_mem = NULL; |
31 | int option, facility; | 31 | int option, facility; |
32 | 32 | ||
33 | if (IDENT == SCM_BOOL_F) | 33 | if (IDENT == SCM_BOOL_F) |
... | @@ -35,7 +35,7 @@ SCM_DEFINE (scm_mu_openlog, "mu-openlog", 3, 0, 0, | ... | @@ -35,7 +35,7 @@ SCM_DEFINE (scm_mu_openlog, "mu-openlog", 3, 0, 0, |
35 | else | 35 | else |
36 | { | 36 | { |
37 | SCM_ASSERT (scm_is_string (IDENT), IDENT, SCM_ARG1, FUNC_NAME); | 37 | SCM_ASSERT (scm_is_string (IDENT), IDENT, SCM_ARG1, FUNC_NAME); |
38 | ident = scm_i_string_chars (IDENT); | 38 | ident = ident_mem = scm_to_locale_string (IDENT); |
39 | } | 39 | } |
40 | 40 | ||
41 | if (scm_is_integer (OPTION)) | 41 | if (scm_is_integer (OPTION)) |
... | @@ -53,6 +53,7 @@ SCM_DEFINE (scm_mu_openlog, "mu-openlog", 3, 0, 0, | ... | @@ -53,6 +53,7 @@ SCM_DEFINE (scm_mu_openlog, "mu-openlog", 3, 0, 0, |
53 | SCM_ASSERT (0, FACILITY, SCM_ARG3, FUNC_NAME); | 53 | SCM_ASSERT (0, FACILITY, SCM_ARG3, FUNC_NAME); |
54 | 54 | ||
55 | openlog (ident, option, facility); | 55 | openlog (ident, option, facility); |
56 | free (ident_mem); | ||
56 | return SCM_UNSPECIFIED; | 57 | return SCM_UNSPECIFIED; |
57 | } | 58 | } |
58 | #undef FUNC_NAME | 59 | #undef FUNC_NAME |
... | @@ -63,6 +64,7 @@ SCM_DEFINE (scm_mu_logger, "mu-logger", 2, 0, 0, | ... | @@ -63,6 +64,7 @@ SCM_DEFINE (scm_mu_logger, "mu-logger", 2, 0, 0, |
63 | #define FUNC_NAME s_scm_mu_logger | 64 | #define FUNC_NAME s_scm_mu_logger |
64 | { | 65 | { |
65 | int prio; | 66 | int prio; |
67 | char *str; | ||
66 | 68 | ||
67 | if (PRIO == SCM_BOOL_F) | 69 | if (PRIO == SCM_BOOL_F) |
68 | prio = LOG_INFO; | 70 | prio = LOG_INFO; |
... | @@ -74,7 +76,8 @@ SCM_DEFINE (scm_mu_logger, "mu-logger", 2, 0, 0, | ... | @@ -74,7 +76,8 @@ SCM_DEFINE (scm_mu_logger, "mu-logger", 2, 0, 0, |
74 | SCM_ASSERT (0, PRIO, SCM_ARG1, FUNC_NAME); | 76 | SCM_ASSERT (0, PRIO, SCM_ARG1, FUNC_NAME); |
75 | 77 | ||
76 | SCM_ASSERT (scm_is_string (TEXT), TEXT, SCM_ARG2, FUNC_NAME); | 78 | SCM_ASSERT (scm_is_string (TEXT), TEXT, SCM_ARG2, FUNC_NAME); |
77 | syslog (prio, "%s", scm_i_string_chars (TEXT)); | 79 | str = scm_to_locale_string (TEXT); |
80 | syslog (prio, "%s", str); | ||
78 | return SCM_UNSPECIFIED; | 81 | return SCM_UNSPECIFIED; |
79 | } | 82 | } |
80 | #undef FUNC_NAME | 83 | #undef FUNC_NAME | ... | ... |
... | @@ -149,11 +149,13 @@ SCM_DEFINE (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0, | ... | @@ -149,11 +149,13 @@ SCM_DEFINE (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0, |
149 | #define FUNC_NAME s_scm_mu_user_mailbox_url | 149 | #define FUNC_NAME s_scm_mu_user_mailbox_url |
150 | { | 150 | { |
151 | int rc; | 151 | int rc; |
152 | char *p; | 152 | char *p, *str; |
153 | SCM ret; | 153 | SCM ret; |
154 | 154 | ||
155 | SCM_ASSERT (scm_is_string (USER), USER, SCM_ARG1, FUNC_NAME); | 155 | SCM_ASSERT (scm_is_string (USER), USER, SCM_ARG1, FUNC_NAME); |
156 | rc = mu_construct_user_mailbox_url (&p, scm_i_string_chars (USER)); | 156 | str = scm_to_locale_string (USER); |
157 | rc = mu_construct_user_mailbox_url (&p, str); | ||
158 | free (str); | ||
157 | if (rc) | 159 | if (rc) |
158 | mu_scm_error (FUNC_NAME, rc, | 160 | mu_scm_error (FUNC_NAME, rc, |
159 | "Cannot construct mailbox URL for ~A", | 161 | "Cannot construct mailbox URL for ~A", |
... | @@ -172,8 +174,12 @@ SCM_DEFINE (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0, | ... | @@ -172,8 +174,12 @@ SCM_DEFINE (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0, |
172 | { | 174 | { |
173 | if (!SCM_UNBNDP (URL)) | 175 | if (!SCM_UNBNDP (URL)) |
174 | { | 176 | { |
177 | char *s; | ||
178 | |||
175 | SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME); | 179 | SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME); |
176 | mu_set_folder_directory (scm_i_string_chars (URL)); | 180 | s = scm_to_locale_string (URL); |
181 | mu_set_folder_directory (s); | ||
182 | free (s); | ||
177 | } | 183 | } |
178 | return scm_makfrom0str (mu_folder_directory ()); | 184 | return scm_makfrom0str (mu_folder_directory ()); |
179 | } | 185 | } |
... | @@ -195,14 +201,19 @@ SCM_DEFINE (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, | ... | @@ -195,14 +201,19 @@ SCM_DEFINE (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, |
195 | #define FUNC_NAME s_scm_mu_mailbox_open | 201 | #define FUNC_NAME s_scm_mu_mailbox_open |
196 | { | 202 | { |
197 | mu_mailbox_t mbox = NULL; | 203 | mu_mailbox_t mbox = NULL; |
198 | const char *mode_str; | 204 | char *mode_str; |
199 | int mode = 0; | 205 | int mode = 0; |
200 | int status; | 206 | int status; |
201 | 207 | SCM ret; | |
208 | |||
202 | SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME); | 209 | SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME); |
203 | SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME); | 210 | SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME); |
204 | 211 | ||
205 | for (mode_str = scm_i_string_chars (MODE); *mode_str; mode_str++) | 212 | scm_dynwind_begin (0); |
213 | |||
214 | mode_str = scm_to_locale_string (MODE); | ||
215 | scm_dynwind_free (mode_str); | ||
216 | for (; *mode_str; mode_str++) | ||
206 | switch (*mode_str) | 217 | switch (*mode_str) |
207 | { | 218 | { |
208 | case 'r': | 219 | case 'r': |
... | @@ -218,11 +229,14 @@ SCM_DEFINE (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, | ... | @@ -218,11 +229,14 @@ SCM_DEFINE (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, |
218 | mode |= MU_STREAM_CREAT; | 229 | mode |= MU_STREAM_CREAT; |
219 | break; | 230 | break; |
220 | } | 231 | } |
221 | 232 | ||
222 | if (mode & MU_STREAM_READ && mode & MU_STREAM_WRITE) | 233 | if (mode & MU_STREAM_READ && mode & MU_STREAM_WRITE) |
223 | mode = (mode & ~(MU_STREAM_READ | MU_STREAM_WRITE)) | MU_STREAM_RDWR; | 234 | mode = (mode & ~(MU_STREAM_READ | MU_STREAM_WRITE)) | MU_STREAM_RDWR; |
224 | 235 | ||
225 | status = mu_mailbox_create_default (&mbox, scm_i_string_chars (URL)); | 236 | mode_str = scm_to_locale_string (URL); |
237 | scm_dynwind_free (mode_str); | ||
238 | |||
239 | status = mu_mailbox_create_default (&mbox, mode_str); | ||
226 | if (status) | 240 | if (status) |
227 | mu_scm_error (FUNC_NAME, status, | 241 | mu_scm_error (FUNC_NAME, status, |
228 | "Cannot create default mailbox ~A", | 242 | "Cannot create default mailbox ~A", |
... | @@ -237,8 +251,9 @@ SCM_DEFINE (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, | ... | @@ -237,8 +251,9 @@ SCM_DEFINE (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, |
237 | "Cannot open default mailbox ~A", | 251 | "Cannot open default mailbox ~A", |
238 | scm_list_1 (URL)); | 252 | scm_list_1 (URL)); |
239 | } | 253 | } |
240 | 254 | ret = mu_scm_mailbox_create (mbox); | |
241 | return mu_scm_mailbox_create (mbox); | 255 | scm_dynwind_end (); |
256 | return ret; | ||
242 | } | 257 | } |
243 | #undef FUNC_NAME | 258 | #undef FUNC_NAME |
244 | 259 | ||
... | @@ -288,6 +303,7 @@ SCM_DEFINE (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0, | ... | @@ -288,6 +303,7 @@ SCM_DEFINE (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0, |
288 | struct mu_mailbox *mum; | 303 | struct mu_mailbox *mum; |
289 | mu_stream_t stream; | 304 | mu_stream_t stream; |
290 | int status; | 305 | int status; |
306 | char *s; | ||
291 | 307 | ||
292 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); | 308 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); |
293 | SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME); | 309 | SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME); |
... | @@ -297,8 +313,10 @@ SCM_DEFINE (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0, | ... | @@ -297,8 +313,10 @@ SCM_DEFINE (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0, |
297 | mu_scm_error (FUNC_NAME, status, | 313 | mu_scm_error (FUNC_NAME, status, |
298 | "Cannot get mailbox stream", | 314 | "Cannot get mailbox stream", |
299 | scm_list_1 (MBOX)); | 315 | scm_list_1 (MBOX)); |
300 | return mu_port_make_from_stream (MBOX, stream, | 316 | s = scm_to_locale_string (MODE); |
301 | scm_mode_bits ((char*)scm_i_string_chars (MODE))); | 317 | status = mu_port_make_from_stream (MBOX, stream, scm_mode_bits (s)); |
318 | free (s); | ||
319 | return status; | ||
302 | } | 320 | } |
303 | #undef FUNC_NAME | 321 | #undef FUNC_NAME |
304 | 322 | ... | ... |
... | @@ -153,18 +153,10 @@ mu_scm_message_add_owner (SCM MESG, SCM owner) | ... | @@ -153,18 +153,10 @@ mu_scm_message_add_owner (SCM MESG, SCM owner) |
153 | return; | 153 | return; |
154 | } | 154 | } |
155 | 155 | ||
156 | SCM_NEWCELL (cell); | ||
157 | SCM_SETCAR (cell, owner); | ||
158 | if (SCM_NIMP (mum->mbox) && SCM_CONSP (mum->mbox)) | 156 | if (SCM_NIMP (mum->mbox) && SCM_CONSP (mum->mbox)) |
159 | SCM_SETCDR (cell, mum->mbox); | 157 | cell = scm_cons (owner, mum->mbox); |
160 | else | 158 | else |
161 | { | 159 | cell = scm_cons (owner, scm_cons (mum->mbox, SCM_EOL)); |
162 | SCM scm; | ||
163 | SCM_NEWCELL (scm); | ||
164 | SCM_SETCAR (scm, mum->mbox); | ||
165 | SCM_SETCDR (scm, SCM_EOL); | ||
166 | SCM_SETCDR (cell, scm); | ||
167 | } | ||
168 | mum->mbox = cell; | 160 | mum->mbox = cell; |
169 | } | 161 | } |
170 | 162 | ||
... | @@ -283,6 +275,7 @@ SCM_DEFINE (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0, | ... | @@ -283,6 +275,7 @@ SCM_DEFINE (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0, |
283 | mu_header_t hdr; | 275 | mu_header_t hdr; |
284 | int replace = 0; | 276 | int replace = 0; |
285 | int status; | 277 | int status; |
278 | char *hdr_c, *val_c; | ||
286 | 279 | ||
287 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | 280 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
288 | msg = mu_scm_message_get (MESG); | 281 | msg = mu_scm_message_get (MESG); |
... | @@ -302,9 +295,12 @@ SCM_DEFINE (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0, | ... | @@ -302,9 +295,12 @@ SCM_DEFINE (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0, |
302 | mu_scm_error (FUNC_NAME, status, | 295 | mu_scm_error (FUNC_NAME, status, |
303 | "Cannot get message headers", SCM_BOOL_F); | 296 | "Cannot get message headers", SCM_BOOL_F); |
304 | 297 | ||
305 | status = mu_header_set_value (hdr, scm_i_string_chars (HEADER), | 298 | hdr_c = scm_to_locale_string (HEADER); |
306 | scm_i_string_chars (VALUE), | 299 | val_c = scm_to_locale_string (VALUE); |
307 | replace); | 300 | status = mu_header_set_value (hdr, hdr_c, val_c, replace); |
301 | free (hdr_c); | ||
302 | free (val_c); | ||
303 | |||
308 | if (status) | 304 | if (status) |
309 | mu_scm_error (FUNC_NAME, status, | 305 | mu_scm_error (FUNC_NAME, status, |
310 | "Cannot set header \"~A: ~A\" in message ~A", | 306 | "Cannot set header \"~A: ~A\" in message ~A", |
... | @@ -349,6 +345,92 @@ SCM_DEFINE (scm_mu_message_get_lines, "mu-message-get-lines", 1, 0, 0, | ... | @@ -349,6 +345,92 @@ SCM_DEFINE (scm_mu_message_get_lines, "mu-message-get-lines", 1, 0, 0, |
349 | } | 345 | } |
350 | #undef FUNC_NAME | 346 | #undef FUNC_NAME |
351 | 347 | ||
348 | static SCM | ||
349 | filltime (struct tm *bd_time, int zoff, const char *zname) | ||
350 | { | ||
351 | SCM result = scm_c_make_vector (11, SCM_UNDEFINED); | ||
352 | |||
353 | SCM_SIMPLE_VECTOR_SET (result,0, scm_from_int (bd_time->tm_sec)); | ||
354 | SCM_SIMPLE_VECTOR_SET (result,1, scm_from_int (bd_time->tm_min)); | ||
355 | SCM_SIMPLE_VECTOR_SET (result,2, scm_from_int (bd_time->tm_hour)); | ||
356 | SCM_SIMPLE_VECTOR_SET (result,3, scm_from_int (bd_time->tm_mday)); | ||
357 | SCM_SIMPLE_VECTOR_SET (result,4, scm_from_int (bd_time->tm_mon)); | ||
358 | SCM_SIMPLE_VECTOR_SET (result,5, scm_from_int (bd_time->tm_year)); | ||
359 | SCM_SIMPLE_VECTOR_SET (result,6, scm_from_int (bd_time->tm_wday)); | ||
360 | SCM_SIMPLE_VECTOR_SET (result,7, scm_from_int (bd_time->tm_yday)); | ||
361 | SCM_SIMPLE_VECTOR_SET (result,8, scm_from_int (bd_time->tm_isdst)); | ||
362 | SCM_SIMPLE_VECTOR_SET (result,9, scm_from_int (zoff)); | ||
363 | SCM_SIMPLE_VECTOR_SET (result,10, (zname | ||
364 | ? scm_from_locale_string (zname) | ||
365 | : SCM_BOOL_F)); | ||
366 | return result; | ||
367 | } | ||
368 | |||
369 | SCM_DEFINE (scm_mu_message_get_envelope, "mu-message-get-envelope", 1, 0, 0, | ||
370 | (SCM MESG), | ||
371 | "Returns envelope date of the message MESG.\n") | ||
372 | #define FUNC_NAME s_scm_mu_message_get_envelope | ||
373 | { | ||
374 | mu_message_t msg; | ||
375 | mu_envelope_t env = NULL; | ||
376 | int status; | ||
377 | const char *sender; | ||
378 | const char *date; | ||
379 | size_t dlen; | ||
380 | |||
381 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | ||
382 | msg = mu_scm_message_get (MESG); | ||
383 | status = mu_message_get_envelope (msg, &env); | ||
384 | if (status) | ||
385 | mu_scm_error (FUNC_NAME, status, "cannot get envelope", | ||
386 | scm_list_1 (MESG)); | ||
387 | status = mu_envelope_sget_sender (env, &sender); | ||
388 | if (status) | ||
389 | mu_scm_error (FUNC_NAME, status, "cannot get envelope sender", | ||
390 | scm_list_1 (MESG)); | ||
391 | status = mu_envelope_sget_date (env, &date); | ||
392 | if (status) | ||
393 | mu_scm_error (FUNC_NAME, status, "cannot get envelope date", | ||
394 | scm_list_1 (MESG)); | ||
395 | dlen = strlen (date); | ||
396 | if (date[dlen-1] == '\n') | ||
397 | dlen--; | ||
398 | return scm_string_append (scm_list_3 (scm_from_locale_string (sender), | ||
399 | scm_from_locale_string (" "), | ||
400 | scm_from_locale_stringn (date, dlen))); | ||
401 | } | ||
402 | #undef FUNC_NAME | ||
403 | |||
404 | SCM_DEFINE (scm_mu_message_get_envelope_date, "mu-message-get-envelope-date", 1, 0, 0, | ||
405 | (SCM MESG), | ||
406 | "Returns envelope date of the message MESG.\n") | ||
407 | #define FUNC_NAME s_scm_mu_message_get_envelope_date | ||
408 | { | ||
409 | mu_message_t msg; | ||
410 | mu_envelope_t env = NULL; | ||
411 | int status; | ||
412 | const char *sdate; | ||
413 | struct tm tm; | ||
414 | mu_timezone tz; | ||
415 | |||
416 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | ||
417 | msg = mu_scm_message_get (MESG); | ||
418 | status = mu_message_get_envelope (msg, &env); | ||
419 | if (status) | ||
420 | mu_scm_error (FUNC_NAME, status, "cannot get envelope", | ||
421 | scm_list_1 (MESG)); | ||
422 | status = mu_envelope_sget_date (env, &sdate); | ||
423 | if (status) | ||
424 | mu_scm_error (FUNC_NAME, status, "cannot get envelope date", | ||
425 | scm_list_1 (MESG)); | ||
426 | status = mu_parse_ctime_date_time (&sdate, &tm, &tz); | ||
427 | if (status) | ||
428 | mu_scm_error (FUNC_NAME, status, "invalid envelope date", | ||
429 | scm_list_1 (scm_makfrom0str (sdate))); | ||
430 | return filltime (&tm, tz.utc_offset, tz.tz_name); | ||
431 | } | ||
432 | #undef FUNC_NAME | ||
433 | |||
352 | SCM_DEFINE (scm_mu_message_get_sender, "mu-message-get-sender", 1, 0, 0, | 434 | SCM_DEFINE (scm_mu_message_get_sender, "mu-message-get-sender", 1, 0, 0, |
353 | (SCM MESG), | 435 | (SCM MESG), |
354 | "Returns email address of the sender of the message MESG.\n") | 436 | "Returns email address of the sender of the message MESG.\n") |
... | @@ -384,20 +466,21 @@ SCM_DEFINE (scm_mu_message_get_header, "mu-message-get-header", 2, 0, 0, | ... | @@ -384,20 +466,21 @@ SCM_DEFINE (scm_mu_message_get_header, "mu-message-get-header", 2, 0, 0, |
384 | mu_message_t msg; | 466 | mu_message_t msg; |
385 | mu_header_t hdr; | 467 | mu_header_t hdr; |
386 | char *value = NULL; | 468 | char *value = NULL; |
387 | const char *header_string; | 469 | char *header_string; |
388 | SCM ret; | 470 | SCM ret; |
389 | int status; | 471 | int status; |
390 | 472 | ||
391 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | 473 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
392 | msg = mu_scm_message_get (MESG); | 474 | msg = mu_scm_message_get (MESG); |
393 | SCM_ASSERT (scm_is_string (HEADER), HEADER, SCM_ARG2, FUNC_NAME); | 475 | SCM_ASSERT (scm_is_string (HEADER), HEADER, SCM_ARG2, FUNC_NAME); |
394 | header_string = scm_i_string_chars (HEADER); | ||
395 | status = mu_message_get_header (msg, &hdr); | 476 | status = mu_message_get_header (msg, &hdr); |
396 | if (status) | 477 | if (status) |
397 | mu_scm_error (FUNC_NAME, status, | 478 | mu_scm_error (FUNC_NAME, status, |
398 | "Cannot get message headers", SCM_BOOL_F); | 479 | "Cannot get message headers", SCM_BOOL_F); |
399 | 480 | ||
481 | header_string = scm_to_locale_string (HEADER); | ||
400 | status = mu_header_aget_value (hdr, header_string, &value); | 482 | status = mu_header_aget_value (hdr, header_string, &value); |
483 | free (header_string); | ||
401 | switch (status) | 484 | switch (status) |
402 | { | 485 | { |
403 | case 0: | 486 | case 0: |
... | @@ -426,7 +509,8 @@ string_sloppy_member (SCM lst, char *name) | ... | @@ -426,7 +509,8 @@ string_sloppy_member (SCM lst, char *name) |
426 | { | 509 | { |
427 | SCM car = SCM_CAR (lst); | 510 | SCM car = SCM_CAR (lst); |
428 | if (scm_is_string (car) | 511 | if (scm_is_string (car) |
429 | && mu_c_strcasecmp (scm_i_string_chars (car), name) == 0) | 512 | && mu_c_strncasecmp (scm_i_string_chars (car), name, |
513 | scm_i_string_length (car)) == 0) | ||
430 | return 1; | 514 | return 1; |
431 | } | 515 | } |
432 | return 0; | 516 | return 0; |
... | @@ -441,7 +525,7 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1, | ... | @@ -441,7 +525,7 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1, |
441 | size_t i, nfields = 0; | 525 | size_t i, nfields = 0; |
442 | mu_message_t msg; | 526 | mu_message_t msg; |
443 | mu_header_t hdr = NULL; | 527 | mu_header_t hdr = NULL; |
444 | SCM scm_first = SCM_EOL, scm_last; | 528 | SCM scm_first = SCM_EOL, scm_last = SCM_EOL; |
445 | SCM headers = SCM_EOL; | 529 | SCM headers = SCM_EOL; |
446 | int status; | 530 | int status; |
447 | 531 | ||
... | @@ -465,7 +549,7 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1, | ... | @@ -465,7 +549,7 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1, |
465 | 549 | ||
466 | for (i = 1; i <= nfields; i++) | 550 | for (i = 1; i <= nfields; i++) |
467 | { | 551 | { |
468 | SCM new_cell, scm_name, scm_value; | 552 | SCM scm_name, scm_value, scm_new; |
469 | char *name, *value; | 553 | char *name, *value; |
470 | 554 | ||
471 | status = mu_header_aget_field_name (hdr, i, &name); | 555 | status = mu_header_aget_field_name (hdr, i, &name); |
... | @@ -485,22 +569,16 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1, | ... | @@ -485,22 +569,16 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1, |
485 | scm_name = scm_makfrom0str (name); | 569 | scm_name = scm_makfrom0str (name); |
486 | scm_value = scm_makfrom0str (value); | 570 | scm_value = scm_makfrom0str (value); |
487 | 571 | ||
488 | SCM_NEWCELL(new_cell); | 572 | scm_new = scm_cons (scm_cons (scm_name, scm_value), SCM_EOL); |
489 | SCM_SETCAR(new_cell, scm_cons(scm_name, scm_value)); | ||
490 | 573 | ||
491 | if (scm_first == SCM_EOL) | 574 | if (scm_first == SCM_EOL) |
492 | { | 575 | scm_first = scm_last = scm_new; |
493 | scm_first = new_cell; | ||
494 | scm_last = scm_first; | ||
495 | } | ||
496 | else | 576 | else |
497 | { | 577 | { |
498 | SCM_SETCDR(scm_last, new_cell); | 578 | SCM_SETCDR (scm_last, scm_new); |
499 | scm_last = new_cell; | 579 | scm_last = scm_new; |
500 | } | 580 | } |
501 | } | 581 | } |
502 | if (scm_first != SCM_EOL) | ||
503 | SCM_SETCDR(scm_last, SCM_EOL); | ||
504 | return scm_first; | 582 | return scm_first; |
505 | } | 583 | } |
506 | #undef FUNC_NAME | 584 | #undef FUNC_NAME |
... | @@ -542,6 +620,7 @@ SCM_DEFINE (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2, | ... | @@ -542,6 +620,7 @@ SCM_DEFINE (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2, |
542 | { | 620 | { |
543 | SCM cell = SCM_CAR (list); | 621 | SCM cell = SCM_CAR (list); |
544 | SCM car, cdr; | 622 | SCM car, cdr; |
623 | char *hdr_c, *val_c; | ||
545 | 624 | ||
546 | SCM_ASSERT (SCM_NIMP (cell) && SCM_CONSP (cell), | 625 | SCM_ASSERT (SCM_NIMP (cell) && SCM_CONSP (cell), |
547 | cell, SCM_ARGn, FUNC_NAME); | 626 | cell, SCM_ARGn, FUNC_NAME); |
... | @@ -549,9 +628,11 @@ SCM_DEFINE (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2, | ... | @@ -549,9 +628,11 @@ SCM_DEFINE (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2, |
549 | cdr = SCM_CDR (cell); | 628 | cdr = SCM_CDR (cell); |
550 | SCM_ASSERT (scm_is_string (car), car, SCM_ARGn, FUNC_NAME); | 629 | SCM_ASSERT (scm_is_string (car), car, SCM_ARGn, FUNC_NAME); |
551 | SCM_ASSERT (scm_is_string (cdr), cdr, SCM_ARGn, FUNC_NAME); | 630 | SCM_ASSERT (scm_is_string (cdr), cdr, SCM_ARGn, FUNC_NAME); |
552 | status = mu_header_set_value (hdr, | 631 | hdr_c = scm_to_locale_string (car); |
553 | scm_i_string_chars (car), | 632 | val_c = scm_to_locale_string (cdr); |
554 | scm_i_string_chars (cdr), replace); | 633 | status = mu_header_set_value (hdr, hdr_c, val_c, replace); |
634 | free (hdr_c); | ||
635 | free (val_c); | ||
555 | if (status) | 636 | if (status) |
556 | mu_scm_error (FUNC_NAME, status, | 637 | mu_scm_error (FUNC_NAME, status, |
557 | "Cannot set header value: message ~A, header ~A, value ~A", | 638 | "Cannot set header value: message ~A, header ~A, value ~A", |
... | @@ -831,7 +912,9 @@ SCM_DEFINE (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, | ... | @@ -831,7 +912,9 @@ SCM_DEFINE (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, |
831 | mu_message_t msg; | 912 | mu_message_t msg; |
832 | mu_stream_t stream = NULL; | 913 | mu_stream_t stream = NULL; |
833 | int status; | 914 | int status; |
834 | 915 | char *str; | |
916 | SCM ret; | ||
917 | |||
835 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | 918 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
836 | SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME); | 919 | SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME); |
837 | 920 | ||
... | @@ -863,9 +946,11 @@ SCM_DEFINE (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, | ... | @@ -863,9 +946,11 @@ SCM_DEFINE (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, |
863 | mu_scm_error (FUNC_NAME, status, "Cannot get message body stream", | 946 | mu_scm_error (FUNC_NAME, status, "Cannot get message body stream", |
864 | SCM_BOOL_F); | 947 | SCM_BOOL_F); |
865 | } | 948 | } |
866 | 949 | ||
867 | return mu_port_make_from_stream (MESG, stream, | 950 | str = scm_to_locale_string (MODE); |
868 | scm_mode_bits ((char*)scm_i_string_chars (MODE))); | 951 | ret = mu_port_make_from_stream (MESG, stream, scm_mode_bits (str)); |
952 | free (str); | ||
953 | return ret; | ||
869 | } | 954 | } |
870 | #undef FUNC_NAME | 955 | #undef FUNC_NAME |
871 | 956 | ||
... | @@ -962,42 +1047,57 @@ SCM_DEFINE (scm_mu_message_send, "mu-message-send", 1, 3, 0, | ... | @@ -962,42 +1047,57 @@ SCM_DEFINE (scm_mu_message_send, "mu-message-send", 1, 3, 0, |
962 | "in mu-mailer. Optional FROM and TO give sender and recever addresses.\n") | 1047 | "in mu-mailer. Optional FROM and TO give sender and recever addresses.\n") |
963 | #define FUNC_NAME s_scm_mu_message_send | 1048 | #define FUNC_NAME s_scm_mu_message_send |
964 | { | 1049 | { |
965 | const char *mailer_name; | 1050 | char *mailer_name; |
966 | mu_address_t from = NULL; | 1051 | mu_address_t from = NULL; |
967 | mu_address_t to = NULL; | 1052 | mu_address_t to = NULL; |
968 | mu_mailer_t mailer = NULL; | 1053 | mu_mailer_t mailer = NULL; |
969 | mu_message_t msg; | 1054 | mu_message_t msg; |
970 | int status; | 1055 | int status; |
971 | 1056 | ||
972 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | 1057 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
973 | msg = mu_scm_message_get (MESG); | 1058 | msg = mu_scm_message_get (MESG); |
974 | 1059 | ||
975 | if (!SCM_UNBNDP (MAILER) && MAILER != SCM_BOOL_F) | 1060 | if (!SCM_UNBNDP (MAILER) && MAILER != SCM_BOOL_F) |
976 | { | 1061 | { |
977 | SCM_ASSERT (scm_is_string (MAILER), MAILER, SCM_ARG2, FUNC_NAME); | 1062 | SCM_ASSERT (scm_is_string (MAILER), MAILER, SCM_ARG2, FUNC_NAME); |
978 | mailer_name = scm_i_string_chars (MAILER); | 1063 | mailer_name = scm_to_locale_string (MAILER); |
979 | } | 1064 | } |
980 | else | 1065 | else |
981 | { | 1066 | { |
982 | SCM val = MU_SCM_SYMBOL_VALUE("mu-mailer"); | 1067 | SCM val = MU_SCM_SYMBOL_VALUE ("mu-mailer"); |
983 | mailer_name = scm_i_string_chars(val); | 1068 | mailer_name = scm_to_locale_string (val); |
984 | } | 1069 | } |
985 | 1070 | ||
986 | if (!SCM_UNBNDP (FROM) && FROM != SCM_BOOL_F) | 1071 | if (!SCM_UNBNDP (FROM) && FROM != SCM_BOOL_F) |
987 | { | 1072 | { |
988 | SCM_ASSERT (scm_is_string (FROM) | 1073 | char *s; |
989 | && mu_address_create (&from, scm_i_string_chars (FROM)) == 0, | 1074 | int rc; |
990 | FROM, SCM_ARG3, FUNC_NAME); | 1075 | |
1076 | SCM_ASSERT (scm_is_string (FROM), FROM, SCM_ARG3, FUNC_NAME); | ||
1077 | s = scm_to_locale_string (FROM); | ||
1078 | rc = mu_address_create (&from, s); | ||
1079 | free (s); | ||
1080 | if (rc) | ||
1081 | mu_scm_error (FUNC_NAME, rc, "cannot create address", | ||
1082 | scm_list_1 (FROM)); | ||
991 | } | 1083 | } |
992 | 1084 | ||
993 | if (!SCM_UNBNDP (TO) && TO != SCM_BOOL_F) | 1085 | if (!SCM_UNBNDP (TO) && TO != SCM_BOOL_F) |
994 | { | 1086 | { |
995 | SCM_ASSERT (scm_is_string (TO) | 1087 | char *s; |
996 | && mu_address_create (&to, scm_i_string_chars (TO)) == 0, | 1088 | int rc; |
997 | TO, SCM_ARG4, FUNC_NAME); | 1089 | |
1090 | SCM_ASSERT (scm_is_string (TO), TO, SCM_ARG4, FUNC_NAME); | ||
1091 | s = scm_to_locale_string (TO); | ||
1092 | rc = mu_address_create (&to, s); | ||
1093 | free (s); | ||
1094 | if (rc) | ||
1095 | mu_scm_error (FUNC_NAME, rc, "cannot create address", | ||
1096 | scm_list_1 (TO)); | ||
998 | } | 1097 | } |
999 | 1098 | ||
1000 | status = mu_mailer_create (&mailer, mailer_name); | 1099 | status = mu_mailer_create (&mailer, mailer_name); |
1100 | free (mailer_name); | ||
1001 | if (status) | 1101 | if (status) |
1002 | mu_scm_error (FUNC_NAME, status, "Cannot get create mailer", SCM_BOOL_F); | 1102 | mu_scm_error (FUNC_NAME, status, "Cannot get create mailer", SCM_BOOL_F); |
1003 | 1103 | ... | ... |
... | @@ -87,15 +87,15 @@ mu_port_make_from_stream (SCM msg, mu_stream_t stream, long mode) | ... | @@ -87,15 +87,15 @@ mu_port_make_from_stream (SCM msg, mu_stream_t stream, long mode) |
87 | mp->stream = stream; | 87 | mp->stream = stream; |
88 | mp->offset = 0; | 88 | mp->offset = 0; |
89 | 89 | ||
90 | SCM_NEWCELL (port); | 90 | port = scm_cell (scm_tc16_smuport | mode, 0); |
91 | SCM_DEFER_INTS; | 91 | |
92 | pt = scm_add_to_port_table (port); | 92 | pt = scm_add_to_port_table (port); |
93 | SCM_SETPTAB_ENTRY (port, pt); | 93 | SCM_SETPTAB_ENTRY (port, pt); |
94 | pt->rw_random = mu_stream_is_seekable (stream); | 94 | pt->rw_random = mu_stream_is_seekable (stream); |
95 | SCM_SET_CELL_TYPE (port, (scm_tc16_smuport | mode)); | 95 | |
96 | SCM_SETSTREAM (port, mp); | 96 | SCM_SETSTREAM (port, mp); |
97 | mu_port_alloc_buffer (port, 0, 0); | 97 | mu_port_alloc_buffer (port, 0, 0); |
98 | SCM_ALLOW_INTS; | 98 | |
99 | /* SCM_PTAB_ENTRY (port)->file_name = "name";FIXME*/ | 99 | /* SCM_PTAB_ENTRY (port)->file_name = "name";FIXME*/ |
100 | return port; | 100 | return port; |
101 | } | 101 | } | ... | ... |
... | @@ -145,9 +145,12 @@ SCM_DEFINE (scm_mu_register_format, "mu-register-format", 0, 0, 1, | ... | @@ -145,9 +145,12 @@ SCM_DEFINE (scm_mu_register_format, "mu-register-format", 0, 0, 1, |
145 | { | 145 | { |
146 | for (; REST != SCM_EOL; REST = SCM_CDR (REST)) | 146 | for (; REST != SCM_EOL; REST = SCM_CDR (REST)) |
147 | { | 147 | { |
148 | char *s; | ||
148 | SCM scm = SCM_CAR (REST); | 149 | SCM scm = SCM_CAR (REST); |
149 | SCM_ASSERT (scm_is_string (scm), scm, SCM_ARGn, FUNC_NAME); | 150 | SCM_ASSERT (scm_is_string (scm), scm, SCM_ARGn, FUNC_NAME); |
150 | status = register_format (scm_i_string_chars (scm)); | 151 | s = scm_to_locale_string (scm); |
152 | status = register_format (s); | ||
153 | free (scm); | ||
151 | if (status) | 154 | if (status) |
152 | mu_scm_error (FUNC_NAME, status, | 155 | mu_scm_error (FUNC_NAME, status, |
153 | "Cannot register format ~A", | 156 | "Cannot register format ~A", | ... | ... |
... | @@ -45,11 +45,12 @@ SCM_DEFINE (scm_mu_getpwuid, "mu-getpwuid", 1, 0, 0, | ... | @@ -45,11 +45,12 @@ SCM_DEFINE (scm_mu_getpwuid, "mu-getpwuid", 1, 0, 0, |
45 | } | 45 | } |
46 | else | 46 | else |
47 | { | 47 | { |
48 | char *s; | ||
49 | |||
48 | SCM_VALIDATE_STRING (1, USER); | 50 | SCM_VALIDATE_STRING (1, USER); |
49 | if (scm_is_string (USER)) | 51 | s = scm_to_locale_string (USER); |
50 | USER = scm_from_locale_stringn (scm_i_string_chars (USER), | 52 | entry = mu_get_auth_by_name (s); |
51 | scm_i_string_length (USER)); | 53 | free (s); |
52 | entry = mu_get_auth_by_name (scm_i_string_chars (USER)); | ||
53 | } | 54 | } |
54 | if (!entry) | 55 | if (!entry) |
55 | mu_scm_error (FUNC_NAME, errno, | 56 | mu_scm_error (FUNC_NAME, errno, | ... | ... |
-
Please register or sign in to post a comment