Rewritten using Guile 1.8 API.
Throw 'mailutils-error instead of returning #f on error.
Showing
9 changed files
with
286 additions
and
197 deletions
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2005 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2005, 2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -29,39 +29,47 @@ _get_address_part (const char *func_name, address_get_fp fun, | ... | @@ -29,39 +29,47 @@ _get_address_part (const char *func_name, address_get_fp fun, |
29 | char *str; | 29 | char *str; |
30 | SCM ret; | 30 | SCM ret; |
31 | int num; | 31 | int num; |
32 | int status; | ||
32 | 33 | ||
33 | SCM_ASSERT (SCM_NIMP (ADDRESS) && SCM_STRINGP (ADDRESS), | 34 | SCM_ASSERT (scm_is_string (ADDRESS), ADDRESS, SCM_ARG1, func_name); |
34 | ADDRESS, SCM_ARG1, func_name); | ||
35 | 35 | ||
36 | if (!SCM_UNBNDP (NUM)) | 36 | if (!SCM_UNBNDP (NUM)) |
37 | { | 37 | { |
38 | SCM_ASSERT (SCM_IMP (NUM) && SCM_INUMP (NUM), | 38 | SCM_ASSERT (scm_is_integer (NUM), NUM, SCM_ARG1, func_name); |
39 | NUM, SCM_ARG1, func_name); | 39 | num = scm_to_int (NUM); |
40 | num = SCM_INUM (NUM); | ||
41 | } | 40 | } |
42 | else | 41 | else |
43 | num = 1; | 42 | num = 1; |
44 | 43 | ||
45 | str = SCM_STRING_CHARS (ADDRESS); | 44 | length = strlen (scm_i_string_chars (ADDRESS)); |
46 | length = strlen (str); | ||
47 | if (length == 0) | 45 | if (length == 0) |
48 | return scm_makfrom0str(""); | 46 | mu_scm_error (func_name, 0, |
47 | "Empty address", SCM_BOOL_F); | ||
49 | 48 | ||
50 | if (mu_address_create (&addr, SCM_STRING_CHARS (ADDRESS))) | 49 | status = mu_address_create (&addr, scm_i_string_chars (ADDRESS)); |
51 | return SCM_BOOL_F; | 50 | if (status) |
51 | mu_scm_error (func_name, status, "Cannot create address", SCM_BOOL_F); | ||
52 | 52 | ||
53 | str = malloc (length + 1); | 53 | str = malloc (length + 1); |
54 | if (!str) | 54 | if (!str) |
55 | { | 55 | { |
56 | mu_address_destroy (&addr); | 56 | mu_address_destroy (&addr); |
57 | return SCM_BOOL_F; | 57 | mu_scm_error (func_name, ENOMEM, |
58 | "Cannot allocate memory", SCM_BOOL_F); | ||
58 | } | 59 | } |
59 | 60 | ||
60 | if ((*fun) (addr, num, str, length + 1, NULL) == 0) | 61 | status = (*fun) (addr, num, str, length + 1, NULL); |
62 | mu_address_destroy (&addr); | ||
63 | |||
64 | if (status == 0) | ||
61 | ret = scm_makfrom0str (str); | 65 | ret = scm_makfrom0str (str); |
62 | else | 66 | else |
63 | ret = SCM_BOOL_F; | 67 | { |
64 | mu_address_destroy (&addr); | 68 | free (str); |
69 | mu_scm_error (func_name, status, | ||
70 | "Underlying function failed", SCM_BOOL_F); | ||
71 | } | ||
72 | |||
65 | free (str); | 73 | free (str); |
66 | return ret; | 74 | return ret; |
67 | } | 75 | } |
... | @@ -123,12 +131,15 @@ SCM_DEFINE (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0, | ... | @@ -123,12 +131,15 @@ SCM_DEFINE (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0, |
123 | { | 131 | { |
124 | mu_address_t addr; | 132 | mu_address_t addr; |
125 | size_t count = 0; | 133 | size_t count = 0; |
134 | int status; | ||
126 | 135 | ||
127 | SCM_ASSERT (SCM_NIMP (ADDRESS) && SCM_STRINGP (ADDRESS), | 136 | SCM_ASSERT (scm_is_string (ADDRESS), ADDRESS, SCM_ARG1, FUNC_NAME); |
128 | ADDRESS, SCM_ARG1, FUNC_NAME); | ||
129 | 137 | ||
130 | if (mu_address_create (&addr, SCM_STRING_CHARS (ADDRESS))) | 138 | status = mu_address_create (&addr, scm_i_string_chars (ADDRESS)); |
131 | return SCM_MAKINUM(0); | 139 | if (status) |
140 | mu_scm_error (FUNC_NAME, status, | ||
141 | "Cannot create address for ~A", | ||
142 | scm_list_1 (ADDRESS)); | ||
132 | 143 | ||
133 | mu_address_get_count (addr, &count); | 144 | mu_address_get_count (addr, &count); |
134 | mu_address_destroy (&addr); | 145 | mu_address_destroy (&addr); |
... | @@ -142,21 +153,24 @@ SCM_DEFINE (scm_mu_username_to_email, "mu-username->email", 0, 1, 0, | ... | @@ -142,21 +153,24 @@ SCM_DEFINE (scm_mu_username_to_email, "mu-username->email", 0, 1, 0, |
142 | "is assumed\n") | 153 | "is assumed\n") |
143 | #define FUNC_NAME s_scm_mu_username_to_email | 154 | #define FUNC_NAME s_scm_mu_username_to_email |
144 | { | 155 | { |
145 | char *name; | 156 | const char *name; |
146 | char *email; | 157 | char *email; |
147 | SCM ret; | 158 | SCM ret; |
148 | 159 | ||
149 | if (SCM_UNBNDP (NAME)) | 160 | if (SCM_UNBNDP (NAME)) |
150 | name = NULL; | 161 | name = NULL; |
151 | else { | 162 | else |
152 | SCM_ASSERT (SCM_NIMP (NAME) && SCM_STRINGP (NAME), | 163 | { |
153 | NAME, SCM_ARG1, FUNC_NAME); | 164 | SCM_ASSERT (scm_is_string (NAME), NAME, SCM_ARG1, FUNC_NAME); |
154 | name = SCM_STRING_CHARS (NAME); | 165 | name = scm_i_string_chars (NAME); |
155 | } | 166 | } |
156 | 167 | ||
157 | email = mu_get_user_email (name); | 168 | email = mu_get_user_email (name); |
158 | if (!email) | 169 | if (!email) |
159 | return SCM_BOOL_F; | 170 | mu_scm_error (FUNC_NAME, 0, |
171 | "Cannot get user email for ~A", | ||
172 | scm_list_1 (scm_makfrom0str (name))); | ||
173 | |||
160 | ret = scm_makfrom0str (email); | 174 | ret = scm_makfrom0str (email); |
161 | free (email); | 175 | free (email); |
162 | return ret; | 176 | return ret; | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2005 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2005, 2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -88,7 +88,7 @@ mu_scm_body_create (SCM msg, mu_body_t body) | ... | @@ -88,7 +88,7 @@ mu_scm_body_create (SCM msg, mu_body_t body) |
88 | { | 88 | { |
89 | struct mu_body *mbp; | 89 | struct mu_body *mbp; |
90 | 90 | ||
91 | mbp = scm_must_malloc (sizeof (struct mu_body), "body"); | 91 | mbp = scm_gc_malloc (sizeof (struct mu_body), "body"); |
92 | mbp->msg = msg; | 92 | mbp->msg = msg; |
93 | mbp->body = body; | 93 | mbp->body = body; |
94 | mbp->stream = NULL; | 94 | mbp->stream = NULL; |
... | @@ -108,14 +108,18 @@ SCM_DEFINE (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0, | ... | @@ -108,14 +108,18 @@ SCM_DEFINE (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0, |
108 | { | 108 | { |
109 | struct mu_body *mbp; | 109 | struct mu_body *mbp; |
110 | int n, nread; | 110 | int n, nread; |
111 | 111 | int status; | |
112 | |||
112 | SCM_ASSERT (mu_scm_is_body (BODY), BODY, SCM_ARG1, FUNC_NAME); | 113 | SCM_ASSERT (mu_scm_is_body (BODY), BODY, SCM_ARG1, FUNC_NAME); |
113 | mbp = (struct mu_body *) SCM_CDR (BODY); | 114 | mbp = (struct mu_body *) SCM_CDR (BODY); |
114 | 115 | ||
115 | if (!mbp->stream) | 116 | if (!mbp->stream) |
116 | { | 117 | { |
117 | if (mu_body_get_stream (mbp->body, &mbp->stream)) | 118 | status = mu_body_get_stream (mbp->body, &mbp->stream); |
118 | return SCM_BOOL_F; | 119 | if (status) |
120 | mu_scm_error (FUNC_NAME, status, | ||
121 | "Cannot get body stream", | ||
122 | SCM_BOOL_F); | ||
119 | } | 123 | } |
120 | 124 | ||
121 | if (!mbp->buffer) | 125 | if (!mbp->buffer) |
... | @@ -123,16 +127,18 @@ SCM_DEFINE (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0, | ... | @@ -123,16 +127,18 @@ SCM_DEFINE (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0, |
123 | mbp->bufsize = BUF_SIZE; | 127 | mbp->bufsize = BUF_SIZE; |
124 | mbp->buffer = malloc (mbp->bufsize); | 128 | mbp->buffer = malloc (mbp->bufsize); |
125 | if (!mbp->buffer) | 129 | if (!mbp->buffer) |
126 | return SCM_BOOL_F; | 130 | mu_scm_error (FUNC_NAME, ENOMEM, "Cannot allocate memory", SCM_BOOL_F); |
127 | } | 131 | } |
128 | 132 | ||
129 | nread = 0; | 133 | nread = 0; |
130 | while (1) | 134 | while (1) |
131 | { | 135 | { |
132 | if (mu_stream_readline (mbp->stream, mbp->buffer + nread, | 136 | status = mu_stream_readline (mbp->stream, mbp->buffer + nread, |
133 | mbp->bufsize - nread, | 137 | mbp->bufsize - nread, |
134 | mbp->offset, &n)) | 138 | mbp->offset, &n); |
135 | return SCM_BOOL_F; | 139 | if (status) |
140 | mu_scm_error (FUNC_NAME, status, | ||
141 | "Error reading from stream", SCM_BOOL_F); | ||
136 | if (n == 0) | 142 | if (n == 0) |
137 | break; | 143 | break; |
138 | nread += n; | 144 | nread += n; |
... | @@ -164,24 +170,25 @@ SCM_DEFINE (scm_mu_body_write, "mu-body-write", 2, 0, 0, | ... | @@ -164,24 +170,25 @@ SCM_DEFINE (scm_mu_body_write, "mu-body-write", 2, 0, 0, |
164 | char *ptr; | 170 | char *ptr; |
165 | size_t len, n; | 171 | size_t len, n; |
166 | struct mu_body *mbp; | 172 | struct mu_body *mbp; |
167 | 173 | int status; | |
174 | |||
168 | SCM_ASSERT (mu_scm_is_body (BODY), BODY, SCM_ARG1, FUNC_NAME); | 175 | SCM_ASSERT (mu_scm_is_body (BODY), BODY, SCM_ARG1, FUNC_NAME); |
169 | mbp = (struct mu_body *) SCM_CDR (BODY); | 176 | mbp = (struct mu_body *) SCM_CDR (BODY); |
170 | SCM_ASSERT (SCM_NIMP (TEXT) && SCM_STRINGP (TEXT), | 177 | SCM_ASSERT (scm_is_string (TEXT), TEXT, SCM_ARG2, FUNC_NAME); |
171 | TEXT, SCM_ARG2, FUNC_NAME); | ||
172 | 178 | ||
173 | if (!mbp->stream) | 179 | if (!mbp->stream) |
174 | { | 180 | { |
175 | if (mu_body_get_stream (mbp->body, &mbp->stream)) | 181 | status = mu_body_get_stream (mbp->body, &mbp->stream); |
176 | return SCM_BOOL_F; | 182 | if (status) |
183 | mu_scm_error (FUNC_NAME, status, | ||
184 | "Cannot get body stream", SCM_BOOL_F); | ||
177 | } | 185 | } |
178 | 186 | ||
179 | ptr = SCM_STRING_CHARS (TEXT); | 187 | ptr = SCM_STRING_CHARS (TEXT); |
180 | len = strlen (ptr); | 188 | len = strlen (ptr); |
181 | if (mu_stream_write (mbp->stream, ptr, len, mbp->offset, &n)) | 189 | status = mu_stream_write (mbp->stream, ptr, len, mbp->offset, &n); |
182 | { | 190 | mu_scm_error (FUNC_NAME, status, |
183 | return SCM_BOOL_F; | 191 | "Error writing to stream", SCM_BOOL_F); |
184 | } | ||
185 | mbp->offset += n; | 192 | mbp->offset += n; |
186 | return SCM_BOOL_T; | 193 | return SCM_BOOL_T; |
187 | } | 194 | } | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -25,27 +25,26 @@ SCM_DEFINE (scm_mu_openlog, "mu-openlog", 3, 0, 0, | ... | @@ -25,27 +25,26 @@ SCM_DEFINE (scm_mu_openlog, "mu-openlog", 3, 0, 0, |
25 | "Opens a connection to the system logger for Guile program.") | 25 | "Opens a connection to the system logger for Guile program.") |
26 | #define FUNC_NAME s_scm_mu_openlog | 26 | #define FUNC_NAME s_scm_mu_openlog |
27 | { | 27 | { |
28 | char *ident; | 28 | const char *ident; |
29 | int option, facility; | 29 | int option, facility; |
30 | 30 | ||
31 | if (IDENT == SCM_BOOL_F) | 31 | if (IDENT == SCM_BOOL_F) |
32 | ident = "libmu_scm"; | 32 | ident = "libmu_scm"; |
33 | else | 33 | else |
34 | { | 34 | { |
35 | SCM_ASSERT (SCM_NIMP (IDENT) && SCM_STRINGP (IDENT), | 35 | SCM_ASSERT (scm_is_string (IDENT), IDENT, SCM_ARG1, FUNC_NAME); |
36 | IDENT, SCM_ARG1, FUNC_NAME); | 36 | ident = scm_i_string_chars (IDENT); |
37 | ident = SCM_STRING_CHARS (IDENT); | ||
38 | } | 37 | } |
39 | 38 | ||
40 | if (SCM_IMP (OPTION) && SCM_INUMP (OPTION)) | 39 | if (scm_is_integer (OPTION)) |
41 | option = SCM_INUM (OPTION); | 40 | option = scm_to_int32 (OPTION); |
42 | else if (SCM_BIGP (OPTION)) | 41 | else if (SCM_BIGP (OPTION)) |
43 | option = (int) scm_i_big2dbl (OPTION); | 42 | option = (int) scm_i_big2dbl (OPTION); |
44 | else | 43 | else |
45 | SCM_ASSERT (0, OPTION, SCM_ARG2, FUNC_NAME); | 44 | SCM_ASSERT (0, OPTION, SCM_ARG2, FUNC_NAME); |
46 | 45 | ||
47 | if (SCM_IMP (FACILITY) && SCM_INUMP (FACILITY)) | 46 | if (scm_is_integer (FACILITY)) |
48 | facility = SCM_INUM (FACILITY); | 47 | facility = scm_to_int32 (FACILITY); |
49 | else if (SCM_BIGP (FACILITY)) | 48 | else if (SCM_BIGP (FACILITY)) |
50 | facility = (int) scm_i_big2dbl (FACILITY); | 49 | facility = (int) scm_i_big2dbl (FACILITY); |
51 | else | 50 | else |
... | @@ -65,16 +64,15 @@ SCM_DEFINE (scm_mu_logger, "mu-logger", 2, 0, 0, | ... | @@ -65,16 +64,15 @@ SCM_DEFINE (scm_mu_logger, "mu-logger", 2, 0, 0, |
65 | 64 | ||
66 | if (PRIO == SCM_BOOL_F) | 65 | if (PRIO == SCM_BOOL_F) |
67 | prio = LOG_INFO; | 66 | prio = LOG_INFO; |
68 | else if (SCM_IMP (PRIO) && SCM_INUMP (PRIO)) | 67 | else if (scm_is_integer (PRIO)) |
69 | prio = SCM_INUM (PRIO); | 68 | prio = scm_to_int32 (PRIO); |
70 | else if (SCM_BIGP (PRIO)) | 69 | else if (SCM_BIGP (PRIO)) |
71 | prio = (int) scm_i_big2dbl (PRIO); | 70 | prio = (int) scm_i_big2dbl (PRIO); |
72 | else | 71 | else |
73 | SCM_ASSERT (0, PRIO, SCM_ARG1, FUNC_NAME); | 72 | SCM_ASSERT (0, PRIO, SCM_ARG1, FUNC_NAME); |
74 | 73 | ||
75 | SCM_ASSERT (SCM_NIMP (TEXT) && SCM_STRINGP (TEXT), | 74 | SCM_ASSERT (scm_is_string (TEXT), TEXT, SCM_ARG2, FUNC_NAME); |
76 | TEXT, SCM_ARG2, FUNC_NAME); | 75 | syslog (prio, "%s", scm_i_string_chars (TEXT)); |
77 | syslog (prio, "%s", SCM_STRING_CHARS (TEXT)); | ||
78 | return SCM_UNSPECIFIED; | 76 | return SCM_UNSPECIFIED; |
79 | } | 77 | } |
80 | #undef FUNC_NAME | 78 | #undef FUNC_NAME |
... | @@ -127,6 +125,6 @@ mu_scm_logger_init () | ... | @@ -127,6 +125,6 @@ mu_scm_logger_init () |
127 | int i; | 125 | int i; |
128 | 126 | ||
129 | for (i = 0; i < sizeof (syslog_kw)/sizeof (syslog_kw[0]); i++) | 127 | for (i = 0; i < sizeof (syslog_kw)/sizeof (syslog_kw[0]); i++) |
130 | scm_c_define (syslog_kw[i].name, SCM_MAKINUM (syslog_kw[i].facility)); | 128 | scm_c_define (syslog_kw[i].name, scm_from_int (syslog_kw[i].facility)); |
131 | #include <mu_logger.x> | 129 | #include <mu_logger.x> |
132 | } | 130 | } | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -90,7 +90,7 @@ mu_scm_mailbox_create (mu_mailbox_t mbox) | ... | @@ -90,7 +90,7 @@ mu_scm_mailbox_create (mu_mailbox_t mbox) |
90 | { | 90 | { |
91 | struct mu_mailbox *mum; | 91 | struct mu_mailbox *mum; |
92 | 92 | ||
93 | mum = scm_must_malloc (sizeof (struct mu_mailbox), "mailbox"); | 93 | mum = scm_gc_malloc (sizeof (struct mu_mailbox), "mailbox"); |
94 | mum->mbox = mbox; | 94 | mum->mbox = mbox; |
95 | SCM_RETURN_NEWSMOB (mailbox_tag, mum); | 95 | SCM_RETURN_NEWSMOB (mailbox_tag, mum); |
96 | } | 96 | } |
... | @@ -111,9 +111,8 @@ SCM_DEFINE (scm_mu_mail_directory, "mu-mail-directory", 0, 1, 0, | ... | @@ -111,9 +111,8 @@ SCM_DEFINE (scm_mu_mail_directory, "mu-mail-directory", 0, 1, 0, |
111 | { | 111 | { |
112 | if (!SCM_UNBNDP (URL)) | 112 | if (!SCM_UNBNDP (URL)) |
113 | { | 113 | { |
114 | SCM_ASSERT (SCM_NIMP (URL) && SCM_STRINGP (URL), | 114 | SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME); |
115 | URL, SCM_ARG1, FUNC_NAME); | 115 | mu_set_mail_directory (scm_i_string_chars (URL)); |
116 | mu_set_mail_directory (SCM_STRING_CHARS (URL)); | ||
117 | } | 116 | } |
118 | return scm_makfrom0str (mu_mail_directory ()); | 117 | return scm_makfrom0str (mu_mail_directory ()); |
119 | } | 118 | } |
... | @@ -126,9 +125,8 @@ SCM_DEFINE (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0, | ... | @@ -126,9 +125,8 @@ SCM_DEFINE (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0, |
126 | { | 125 | { |
127 | if (!SCM_UNBNDP (URL)) | 126 | if (!SCM_UNBNDP (URL)) |
128 | { | 127 | { |
129 | SCM_ASSERT (SCM_NIMP (URL) && SCM_STRINGP (URL), | 128 | SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME); |
130 | URL, SCM_ARG1, FUNC_NAME); | 129 | mu_set_folder_directory (scm_i_string_chars (URL)); |
131 | mu_set_folder_directory (SCM_STRING_CHARS (URL)); | ||
132 | } | 130 | } |
133 | return scm_makfrom0str (mu_folder_directory ()); | 131 | return scm_makfrom0str (mu_folder_directory ()); |
134 | } | 132 | } |
... | @@ -140,14 +138,14 @@ SCM_DEFINE (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, | ... | @@ -140,14 +138,14 @@ SCM_DEFINE (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, |
140 | #define FUNC_NAME s_scm_mu_mailbox_open | 138 | #define FUNC_NAME s_scm_mu_mailbox_open |
141 | { | 139 | { |
142 | mu_mailbox_t mbox = NULL; | 140 | mu_mailbox_t mbox = NULL; |
143 | char *mode_str; | 141 | const char *mode_str; |
144 | int mode = 0; | 142 | int mode = 0; |
143 | int status; | ||
144 | |||
145 | SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME); | ||
146 | SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME); | ||
145 | 147 | ||
146 | SCM_ASSERT (SCM_NIMP (URL) && SCM_STRINGP (URL), URL, SCM_ARG1, FUNC_NAME); | 148 | for (mode_str = scm_i_string_chars (MODE); *mode_str; mode_str++) |
147 | SCM_ASSERT (SCM_NIMP (MODE) && SCM_STRINGP (MODE), | ||
148 | MODE, SCM_ARG2, FUNC_NAME); | ||
149 | |||
150 | for (mode_str = SCM_STRING_CHARS (MODE); *mode_str; mode_str++) | ||
151 | switch (*mode_str) | 149 | switch (*mode_str) |
152 | { | 150 | { |
153 | case 'r': | 151 | case 'r': |
... | @@ -167,15 +165,22 @@ SCM_DEFINE (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, | ... | @@ -167,15 +165,22 @@ SCM_DEFINE (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, |
167 | if (mode & MU_STREAM_READ && mode & MU_STREAM_WRITE) | 165 | if (mode & MU_STREAM_READ && mode & MU_STREAM_WRITE) |
168 | mode = (mode & ~(MU_STREAM_READ | MU_STREAM_WRITE)) | MU_STREAM_RDWR; | 166 | mode = (mode & ~(MU_STREAM_READ | MU_STREAM_WRITE)) | MU_STREAM_RDWR; |
169 | 167 | ||
170 | if (mu_mailbox_create_default (&mbox, SCM_STRING_CHARS (URL)) != 0) | 168 | status = mu_mailbox_create_default (&mbox, scm_i_string_chars (URL)); |
171 | return SCM_BOOL_F; | 169 | if (status) |
170 | mu_scm_error (FUNC_NAME, status, | ||
171 | "Cannot create default mailbox ~A", | ||
172 | scm_list_1 (URL)); | ||
172 | 173 | ||
173 | if (mu_mailbox_open (mbox, mode) != 0) | 174 | |
175 | status = mu_mailbox_open (mbox, mode); | ||
176 | if (status) | ||
174 | { | 177 | { |
175 | mu_mailbox_destroy (&mbox); | 178 | mu_mailbox_destroy (&mbox); |
176 | return SCM_BOOL_F; | 179 | mu_scm_error (FUNC_NAME, status, |
180 | "Cannot open default mailbox ~A", | ||
181 | scm_list_1 (URL)); | ||
177 | } | 182 | } |
178 | 183 | ||
179 | return mu_scm_mailbox_create (mbox); | 184 | return mu_scm_mailbox_create (mbox); |
180 | } | 185 | } |
181 | #undef FUNC_NAME | 186 | #undef FUNC_NAME |
... | @@ -219,15 +224,18 @@ SCM_DEFINE (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0, | ... | @@ -219,15 +224,18 @@ SCM_DEFINE (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0, |
219 | { | 224 | { |
220 | struct mu_mailbox *mum; | 225 | struct mu_mailbox *mum; |
221 | mu_stream_t stream; | 226 | mu_stream_t stream; |
227 | int status; | ||
222 | 228 | ||
223 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); | 229 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); |
224 | SCM_ASSERT (SCM_NIMP (MODE) && SCM_STRINGP (MODE), | 230 | SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME); |
225 | MODE, SCM_ARG2, FUNC_NAME); | ||
226 | mum = (struct mu_mailbox *) SCM_CDR (MBOX); | 231 | mum = (struct mu_mailbox *) SCM_CDR (MBOX); |
227 | if (mu_mailbox_get_stream (mum->mbox, &stream)) | 232 | status = mu_mailbox_get_stream (mum->mbox, &stream); |
228 | return SCM_BOOL_F; | 233 | if (status) |
234 | mu_scm_error (FUNC_NAME, status, | ||
235 | "Cannot get mailbox stream", | ||
236 | scm_list_1 (MBOX)); | ||
229 | return mu_port_make_from_stream (MBOX, stream, | 237 | return mu_port_make_from_stream (MBOX, stream, |
230 | scm_mode_bits (SCM_STRING_CHARS (MODE))); | 238 | scm_mode_bits ((char*)scm_i_string_chars (MODE))); |
231 | } | 239 | } |
232 | #undef FUNC_NAME | 240 | #undef FUNC_NAME |
233 | 241 | ||
... | @@ -238,17 +246,20 @@ SCM_DEFINE (scm_mu_mailbox_get_message, "mu-mailbox-get-message", 2, 0, 0, | ... | @@ -238,17 +246,20 @@ SCM_DEFINE (scm_mu_mailbox_get_message, "mu-mailbox-get-message", 2, 0, 0, |
238 | size_t msgno; | 246 | size_t msgno; |
239 | struct mu_mailbox *mum; | 247 | struct mu_mailbox *mum; |
240 | mu_message_t msg; | 248 | mu_message_t msg; |
241 | 249 | int status; | |
250 | |||
242 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); | 251 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); |
243 | SCM_ASSERT ((SCM_IMP (MSGNO) && SCM_INUMP (MSGNO)), | 252 | SCM_ASSERT (scm_is_integer (MSGNO), MSGNO, SCM_ARG2, FUNC_NAME); |
244 | MSGNO, SCM_ARG2, FUNC_NAME); | ||
245 | 253 | ||
246 | mum = (struct mu_mailbox *) SCM_CDR (MBOX); | 254 | mum = (struct mu_mailbox *) SCM_CDR (MBOX); |
247 | msgno = SCM_INUM (MSGNO); | 255 | msgno = scm_to_int32 (MSGNO); |
248 | 256 | ||
249 | if (mu_mailbox_get_message (mum->mbox, msgno, &msg)) | 257 | status = mu_mailbox_get_message (mum->mbox, msgno, &msg); |
250 | return SCM_BOOL_F; | 258 | if (status) |
251 | 259 | mu_scm_error (FUNC_NAME, status, | |
260 | "Cannot get message ~A from mailbox ~A", | ||
261 | scm_list_2 (MSGNO, MBOX)); | ||
262 | |||
252 | return mu_scm_message_create (MBOX, msg); | 263 | return mu_scm_message_create (MBOX, msg); |
253 | } | 264 | } |
254 | #undef FUNC_NAME | 265 | #undef FUNC_NAME |
... | @@ -259,12 +270,16 @@ SCM_DEFINE (scm_mu_mailbox_messages_count, "mu-mailbox-messages-count", 1, 0, 0, | ... | @@ -259,12 +270,16 @@ SCM_DEFINE (scm_mu_mailbox_messages_count, "mu-mailbox-messages-count", 1, 0, 0, |
259 | { | 270 | { |
260 | struct mu_mailbox *mum; | 271 | struct mu_mailbox *mum; |
261 | size_t nmesg; | 272 | size_t nmesg; |
262 | 273 | int status; | |
274 | |||
263 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); | 275 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); |
264 | mum = (struct mu_mailbox *) SCM_CDR (MBOX); | 276 | mum = (struct mu_mailbox *) SCM_CDR (MBOX); |
265 | 277 | ||
266 | if (mu_mailbox_messages_count (mum->mbox, &nmesg)) | 278 | status = mu_mailbox_messages_count (mum->mbox, &nmesg); |
267 | return SCM_BOOL_F; | 279 | if (status) |
280 | mu_scm_error (FUNC_NAME, status, | ||
281 | "Cannot count messages in mailbox ~A", | ||
282 | scm_list_1 (MBOX)); | ||
268 | return mu_scm_makenum (nmesg); | 283 | return mu_scm_makenum (nmesg); |
269 | } | 284 | } |
270 | #undef FUNC_NAME | 285 | #undef FUNC_NAME |
... | @@ -274,11 +289,15 @@ SCM_DEFINE (scm_mu_mailbox_expunge, "mu-mailbox-expunge", 1, 0, 0, | ... | @@ -274,11 +289,15 @@ SCM_DEFINE (scm_mu_mailbox_expunge, "mu-mailbox-expunge", 1, 0, 0, |
274 | #define FUNC_NAME s_scm_mu_mailbox_expunge | 289 | #define FUNC_NAME s_scm_mu_mailbox_expunge |
275 | { | 290 | { |
276 | struct mu_mailbox *mum; | 291 | struct mu_mailbox *mum; |
277 | 292 | int status; | |
293 | |||
278 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); | 294 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); |
279 | mum = (struct mu_mailbox *) SCM_CDR (MBOX); | 295 | mum = (struct mu_mailbox *) SCM_CDR (MBOX); |
280 | if (mu_mailbox_expunge (mum->mbox)) | 296 | status = mu_mailbox_expunge (mum->mbox); |
281 | return SCM_BOOL_F; | 297 | if (status) |
298 | mu_scm_error (FUNC_NAME, status, | ||
299 | "Cannot expunge messages in mailbox ~A", | ||
300 | scm_list_1 (MBOX)); | ||
282 | return SCM_BOOL_T; | 301 | return SCM_BOOL_T; |
283 | } | 302 | } |
284 | #undef FUNC_NAME | 303 | #undef FUNC_NAME |
... | @@ -289,10 +308,15 @@ SCM_DEFINE (scm_mu_mailbox_url, "mu-mailbox-url", 1, 0, 0, | ... | @@ -289,10 +308,15 @@ SCM_DEFINE (scm_mu_mailbox_url, "mu-mailbox-url", 1, 0, 0, |
289 | { | 308 | { |
290 | struct mu_mailbox *mum; | 309 | struct mu_mailbox *mum; |
291 | mu_url_t url; | 310 | mu_url_t url; |
292 | 311 | int status; | |
312 | |||
293 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); | 313 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); |
294 | mum = (struct mu_mailbox *) SCM_CDR (MBOX); | 314 | mum = (struct mu_mailbox *) SCM_CDR (MBOX); |
295 | mu_mailbox_get_url (mum->mbox, &url); | 315 | mu_mailbox_get_url (mum->mbox, &url); |
316 | if (status) | ||
317 | mu_scm_error (FUNC_NAME, status, | ||
318 | "Cannot get mailbox URL", | ||
319 | SCM_BOOL_F); | ||
296 | return scm_makfrom0str (mu_url_to_string (url)); | 320 | return scm_makfrom0str (mu_url_to_string (url)); |
297 | } | 321 | } |
298 | #undef FUNC_NAME | 322 | #undef FUNC_NAME |
... | @@ -303,13 +327,17 @@ SCM_DEFINE (scm_mu_mailbox_append_message, "mu-mailbox-append-message", 2, 0, 0, | ... | @@ -303,13 +327,17 @@ SCM_DEFINE (scm_mu_mailbox_append_message, "mu-mailbox-append-message", 2, 0, 0, |
303 | { | 327 | { |
304 | struct mu_mailbox *mum; | 328 | struct mu_mailbox *mum; |
305 | mu_message_t msg; | 329 | mu_message_t msg; |
306 | 330 | int status; | |
331 | |||
307 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); | 332 | SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); |
308 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG2, FUNC_NAME); | 333 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG2, FUNC_NAME); |
309 | mum = (struct mu_mailbox *) SCM_CDR (MBOX); | 334 | mum = (struct mu_mailbox *) SCM_CDR (MBOX); |
310 | msg = mu_scm_message_get (MESG); | 335 | msg = mu_scm_message_get (MESG); |
311 | if (mu_mailbox_append_message (mum->mbox, msg)) | 336 | status = mu_mailbox_append_message (mum->mbox, msg); |
312 | return SCM_BOOL_F; | 337 | if (status) |
338 | mu_scm_error (FUNC_NAME, status, | ||
339 | "Cannot append message ~A to mailbox ~A", | ||
340 | scm_list_2 (MESG, MBOX)); | ||
313 | return SCM_BOOL_T; | 341 | return SCM_BOOL_T; |
314 | } | 342 | } |
315 | #undef FUNC_NAME | 343 | #undef FUNC_NAME | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -125,7 +125,7 @@ mu_scm_message_create (SCM owner, mu_message_t msg) | ... | @@ -125,7 +125,7 @@ mu_scm_message_create (SCM owner, mu_message_t msg) |
125 | { | 125 | { |
126 | struct mu_message *mum; | 126 | struct mu_message *mum; |
127 | 127 | ||
128 | mum = scm_must_malloc (sizeof (struct mu_message), "message"); | 128 | mum = scm_gc_malloc (sizeof (struct mu_message), "message"); |
129 | mum->msg = msg; | 129 | mum->msg = msg; |
130 | mum->mbox = owner; | 130 | mum->mbox = owner; |
131 | SCM_RETURN_NEWSMOB (message_tag, mum); | 131 | SCM_RETURN_NEWSMOB (message_tag, mum); |
... | @@ -258,21 +258,19 @@ SCM_DEFINE (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0, | ... | @@ -258,21 +258,19 @@ SCM_DEFINE (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0, |
258 | 258 | ||
259 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | 259 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
260 | msg = mu_scm_message_get (MESG); | 260 | msg = mu_scm_message_get (MESG); |
261 | SCM_ASSERT (SCM_NIMP (HEADER) && SCM_STRINGP (HEADER), | 261 | SCM_ASSERT (scm_is_string (HEADER), HEADER, SCM_ARG2, FUNC_NAME); |
262 | HEADER, SCM_ARG2, FUNC_NAME); | ||
263 | 262 | ||
264 | if (SCM_IMP (VALUE) && SCM_BOOLP (VALUE)) | 263 | if (SCM_IMP (VALUE) && SCM_BOOLP (VALUE)) |
265 | return SCM_UNSPECIFIED; | 264 | return SCM_UNSPECIFIED; |
266 | 265 | ||
267 | SCM_ASSERT (SCM_NIMP (VALUE) && SCM_STRINGP (VALUE), | 266 | SCM_ASSERT (scm_is_string (VALUE), VALUE, SCM_ARG2, FUNC_NAME); |
268 | VALUE, SCM_ARG2, FUNC_NAME); | ||
269 | if (!SCM_UNBNDP (REPLACE)) | 267 | if (!SCM_UNBNDP (REPLACE)) |
270 | { | 268 | { |
271 | replace = REPLACE == SCM_BOOL_T; | 269 | replace = REPLACE == SCM_BOOL_T; |
272 | } | 270 | } |
273 | 271 | ||
274 | mu_message_get_header (msg, &hdr); | 272 | mu_message_get_header (msg, &hdr); |
275 | mu_header_set_value (hdr, SCM_STRING_CHARS (HEADER), SCM_STRING_CHARS (VALUE), | 273 | mu_header_set_value (hdr, scm_i_string_chars (HEADER), scm_i_string_chars (VALUE), |
276 | replace); | 274 | replace); |
277 | return SCM_UNSPECIFIED; | 275 | return SCM_UNSPECIFIED; |
278 | } | 276 | } |
... | @@ -335,14 +333,13 @@ SCM_DEFINE (scm_mu_message_get_header, "mu-message-get-header", 2, 0, 0, | ... | @@ -335,14 +333,13 @@ SCM_DEFINE (scm_mu_message_get_header, "mu-message-get-header", 2, 0, 0, |
335 | mu_message_t msg; | 333 | mu_message_t msg; |
336 | mu_header_t hdr; | 334 | mu_header_t hdr; |
337 | char *value = NULL; | 335 | char *value = NULL; |
338 | char *header_string; | 336 | const char *header_string; |
339 | SCM ret = SCM_BOOL_F; | 337 | SCM ret = SCM_BOOL_F; |
340 | 338 | ||
341 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | 339 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
342 | msg = mu_scm_message_get (MESG); | 340 | msg = mu_scm_message_get (MESG); |
343 | SCM_ASSERT (SCM_NIMP (HEADER) && SCM_STRINGP (HEADER), | 341 | SCM_ASSERT (scm_is_string (HEADER), HEADER, SCM_ARG2, FUNC_NAME); |
344 | HEADER, SCM_ARG2, FUNC_NAME); | 342 | header_string = scm_i_string_chars (HEADER); |
345 | header_string = SCM_STRING_CHARS (HEADER); | ||
346 | mu_message_get_header (msg, &hdr); | 343 | mu_message_get_header (msg, &hdr); |
347 | if (mu_header_aget_value (hdr, header_string, &value) == 0) | 344 | if (mu_header_aget_value (hdr, header_string, &value) == 0) |
348 | { | 345 | { |
... | @@ -359,8 +356,8 @@ string_sloppy_member (SCM lst, char *name) | ... | @@ -359,8 +356,8 @@ string_sloppy_member (SCM lst, char *name) |
359 | for(; SCM_CONSP (lst); lst = SCM_CDR(lst)) | 356 | for(; SCM_CONSP (lst); lst = SCM_CDR(lst)) |
360 | { | 357 | { |
361 | SCM car = SCM_CAR (lst); | 358 | SCM car = SCM_CAR (lst); |
362 | if ((SCM_NIMP (car) && SCM_STRINGP (car)) | 359 | if (scm_is_string (car) |
363 | && strcasecmp (SCM_STRING_CHARS (car), name) == 0) | 360 | && strcasecmp (scm_i_string_chars (car), name) == 0) |
364 | return 1; | 361 | return 1; |
365 | } | 362 | } |
366 | return 0; | 363 | return 0; |
... | @@ -459,11 +456,9 @@ SCM_DEFINE (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2, | ... | @@ -459,11 +456,9 @@ SCM_DEFINE (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2, |
459 | cell, SCM_ARGn, FUNC_NAME); | 456 | cell, SCM_ARGn, FUNC_NAME); |
460 | car = SCM_CAR (cell); | 457 | car = SCM_CAR (cell); |
461 | cdr = SCM_CDR (cell); | 458 | cdr = SCM_CDR (cell); |
462 | SCM_ASSERT (SCM_NIMP (car) && SCM_STRINGP (car), | 459 | SCM_ASSERT (scm_is_string (car), car, SCM_ARGn, FUNC_NAME); |
463 | car, SCM_ARGn, FUNC_NAME); | 460 | SCM_ASSERT (scm_is_string (cdr), cdr, SCM_ARGn, FUNC_NAME); |
464 | SCM_ASSERT (SCM_NIMP (cdr) && SCM_STRINGP (cdr), | 461 | mu_header_set_value (hdr, scm_i_string_chars (car), scm_i_string_chars (cdr), replace); |
465 | cdr, SCM_ARGn, FUNC_NAME); | ||
466 | mu_header_set_value (hdr, SCM_STRING_CHARS (car), SCM_STRING_CHARS (cdr), replace); | ||
467 | } | 462 | } |
468 | return SCM_UNSPECIFIED; | 463 | return SCM_UNSPECIFIED; |
469 | } | 464 | } |
... | @@ -507,10 +502,10 @@ SCM_DEFINE (scm_mu_message_get_flag, "mu-message-get-flag", 2, 0, 0, | ... | @@ -507,10 +502,10 @@ SCM_DEFINE (scm_mu_message_get_flag, "mu-message-get-flag", 2, 0, 0, |
507 | 502 | ||
508 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | 503 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
509 | msg = mu_scm_message_get (MESG); | 504 | msg = mu_scm_message_get (MESG); |
510 | SCM_ASSERT (SCM_IMP (FLAG) && SCM_INUMP (FLAG), FLAG, SCM_ARG2, FUNC_NAME); | 505 | SCM_ASSERT (scm_is_integer (FLAG), FLAG, SCM_ARG2, FUNC_NAME); |
511 | 506 | ||
512 | mu_message_get_attribute (msg, &attr); | 507 | mu_message_get_attribute (msg, &attr); |
513 | switch (SCM_INUM (FLAG)) | 508 | switch (scm_to_int32 (FLAG)) |
514 | { | 509 | { |
515 | case MU_ATTRIBUTE_ANSWERED: | 510 | case MU_ATTRIBUTE_ANSWERED: |
516 | ret = mu_attribute_is_answered (attr); | 511 | ret = mu_attribute_is_answered (attr); |
... | @@ -538,7 +533,7 @@ SCM_DEFINE (scm_mu_message_get_flag, "mu-message-get-flag", 2, 0, 0, | ... | @@ -538,7 +533,7 @@ SCM_DEFINE (scm_mu_message_get_flag, "mu-message-get-flag", 2, 0, 0, |
538 | break; | 533 | break; |
539 | default: | 534 | default: |
540 | mu_attribute_get_flags (attr, &ret); | 535 | mu_attribute_get_flags (attr, &ret); |
541 | ret &= SCM_INUM (FLAG); | 536 | ret &= scm_to_int32 (FLAG); |
542 | } | 537 | } |
543 | return ret ? SCM_BOOL_T : SCM_BOOL_F; | 538 | return ret ? SCM_BOOL_T : SCM_BOOL_F; |
544 | } | 539 | } |
... | @@ -556,7 +551,7 @@ SCM_DEFINE (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0, | ... | @@ -556,7 +551,7 @@ SCM_DEFINE (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0, |
556 | 551 | ||
557 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | 552 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
558 | msg = mu_scm_message_get (MESG); | 553 | msg = mu_scm_message_get (MESG); |
559 | SCM_ASSERT (SCM_IMP (FLAG) && SCM_INUMP (FLAG), FLAG, SCM_ARG2, FUNC_NAME); | 554 | SCM_ASSERT (scm_is_integer (FLAG), FLAG, SCM_ARG2, FUNC_NAME); |
560 | 555 | ||
561 | if (!SCM_UNBNDP (VALUE)) | 556 | if (!SCM_UNBNDP (VALUE)) |
562 | { | 557 | { |
... | @@ -566,7 +561,7 @@ SCM_DEFINE (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0, | ... | @@ -566,7 +561,7 @@ SCM_DEFINE (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0, |
566 | } | 561 | } |
567 | 562 | ||
568 | mu_message_get_attribute (msg, &attr); | 563 | mu_message_get_attribute (msg, &attr); |
569 | switch (SCM_INUM (FLAG)) | 564 | switch (scm_to_int32 (FLAG)) |
570 | { | 565 | { |
571 | case MU_ATTRIBUTE_ANSWERED: | 566 | case MU_ATTRIBUTE_ANSWERED: |
572 | if (value) | 567 | if (value) |
... | @@ -618,7 +613,7 @@ SCM_DEFINE (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0, | ... | @@ -618,7 +613,7 @@ SCM_DEFINE (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0, |
618 | break; | 613 | break; |
619 | default: | 614 | default: |
620 | if (value) | 615 | if (value) |
621 | mu_attribute_set_flags (attr, SCM_INUM (FLAG)); | 616 | mu_attribute_set_flags (attr, scm_to_int32 (FLAG)); |
622 | } | 617 | } |
623 | return SCM_UNSPECIFIED; | 618 | return SCM_UNSPECIFIED; |
624 | } | 619 | } |
... | @@ -634,9 +629,9 @@ SCM_DEFINE (scm_mu_message_get_user_flag, "mu-message-get-user-flag", 2, 0, 0, | ... | @@ -634,9 +629,9 @@ SCM_DEFINE (scm_mu_message_get_user_flag, "mu-message-get-user-flag", 2, 0, 0, |
634 | 629 | ||
635 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | 630 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
636 | msg = mu_scm_message_get (MESG); | 631 | msg = mu_scm_message_get (MESG); |
637 | SCM_ASSERT (SCM_IMP (FLAG) && SCM_INUMP (FLAG), FLAG, SCM_ARG2, FUNC_NAME); | 632 | SCM_ASSERT (scm_is_integer (FLAG), FLAG, SCM_ARG2, FUNC_NAME); |
638 | mu_message_get_attribute (msg, &attr); | 633 | mu_message_get_attribute (msg, &attr); |
639 | return mu_attribute_is_userflag (attr, SCM_INUM (FLAG)) ? | 634 | return mu_attribute_is_userflag (attr, scm_to_int32 (FLAG)) ? |
640 | SCM_BOOL_T : SCM_BOOL_F; | 635 | SCM_BOOL_T : SCM_BOOL_F; |
641 | } | 636 | } |
642 | #undef FUNC_NAME | 637 | #undef FUNC_NAME |
... | @@ -654,7 +649,7 @@ SCM_DEFINE (scm_mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0, | ... | @@ -654,7 +649,7 @@ SCM_DEFINE (scm_mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0, |
654 | 649 | ||
655 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | 650 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
656 | msg = mu_scm_message_get (MESG); | 651 | msg = mu_scm_message_get (MESG); |
657 | SCM_ASSERT (SCM_IMP (FLAG) && SCM_INUMP (FLAG), FLAG, SCM_ARG2, FUNC_NAME); | 652 | SCM_ASSERT (scm_is_integer (FLAG), FLAG, SCM_ARG2, FUNC_NAME); |
658 | 653 | ||
659 | if (!SCM_UNBNDP (VALUE)) | 654 | if (!SCM_UNBNDP (VALUE)) |
660 | { | 655 | { |
... | @@ -665,9 +660,9 @@ SCM_DEFINE (scm_mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0, | ... | @@ -665,9 +660,9 @@ SCM_DEFINE (scm_mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0, |
665 | 660 | ||
666 | mu_message_get_attribute (msg, &attr); | 661 | mu_message_get_attribute (msg, &attr); |
667 | if (set) | 662 | if (set) |
668 | mu_attribute_set_userflag (attr, SCM_INUM (FLAG)); | 663 | mu_attribute_set_userflag (attr, scm_to_int32 (FLAG)); |
669 | else | 664 | else |
670 | mu_attribute_unset_userflag (attr, SCM_INUM (FLAG)); | 665 | mu_attribute_unset_userflag (attr, scm_to_int32 (FLAG)); |
671 | return SCM_UNSPECIFIED; | 666 | return SCM_UNSPECIFIED; |
672 | } | 667 | } |
673 | #undef FUNC_NAME | 668 | #undef FUNC_NAME |
... | @@ -687,8 +682,7 @@ SCM_DEFINE (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, | ... | @@ -687,8 +682,7 @@ SCM_DEFINE (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, |
687 | mu_stream_t stream = NULL; | 682 | mu_stream_t stream = NULL; |
688 | 683 | ||
689 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | 684 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
690 | SCM_ASSERT (SCM_NIMP (MODE) && SCM_STRINGP (MODE), | 685 | SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME); |
691 | MODE, SCM_ARG2, FUNC_NAME); | ||
692 | 686 | ||
693 | msg = mu_scm_message_get (MESG); | 687 | msg = mu_scm_message_get (MESG); |
694 | 688 | ||
... | @@ -710,7 +704,7 @@ SCM_DEFINE (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, | ... | @@ -710,7 +704,7 @@ SCM_DEFINE (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, |
710 | } | 704 | } |
711 | 705 | ||
712 | return mu_port_make_from_stream (MESG, stream, | 706 | return mu_port_make_from_stream (MESG, stream, |
713 | scm_mode_bits (SCM_STRING_CHARS (MODE))); | 707 | scm_mode_bits ((char*)scm_i_string_chars (MODE))); |
714 | } | 708 | } |
715 | #undef FUNC_NAME | 709 | #undef FUNC_NAME |
716 | 710 | ||
... | @@ -776,14 +770,14 @@ SCM_DEFINE (scm_mu_message_get_part, "mu-message-get-part", 2, 0, 0, | ... | @@ -776,14 +770,14 @@ SCM_DEFINE (scm_mu_message_get_part, "mu-message-get-part", 2, 0, 0, |
776 | int ismime = 0; | 770 | int ismime = 0; |
777 | 771 | ||
778 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | 772 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); |
779 | SCM_ASSERT (SCM_IMP (PART) && SCM_INUMP (PART), PART, SCM_ARG2, FUNC_NAME); | 773 | SCM_ASSERT (scm_is_integer (PART), PART, SCM_ARG2, FUNC_NAME); |
780 | 774 | ||
781 | msg = mu_scm_message_get (MESG); | 775 | msg = mu_scm_message_get (MESG); |
782 | mu_message_is_multipart (msg, &ismime); | 776 | mu_message_is_multipart (msg, &ismime); |
783 | if (!ismime) | 777 | if (!ismime) |
784 | return SCM_BOOL_F; | 778 | return SCM_BOOL_F; |
785 | 779 | ||
786 | if (mu_message_get_part (msg, SCM_INUM (PART), &submsg)) | 780 | if (mu_message_get_part (msg, scm_to_int32 (PART), &submsg)) |
787 | return SCM_BOOL_F; | 781 | return SCM_BOOL_F; |
788 | return mu_scm_message_create (MESG, submsg); | 782 | return mu_scm_message_create (MESG, submsg); |
789 | } | 783 | } |
... | @@ -796,7 +790,7 @@ SCM_DEFINE (scm_mu_message_send, "mu-message-send", 1, 3, 0, | ... | @@ -796,7 +790,7 @@ SCM_DEFINE (scm_mu_message_send, "mu-message-send", 1, 3, 0, |
796 | "Optional FROM and TO are sender and recever addresses\n") | 790 | "Optional FROM and TO are sender and recever addresses\n") |
797 | #define FUNC_NAME s_scm_mu_message_send | 791 | #define FUNC_NAME s_scm_mu_message_send |
798 | { | 792 | { |
799 | char *mailer_name; | 793 | const char *mailer_name; |
800 | mu_address_t from = NULL; | 794 | mu_address_t from = NULL; |
801 | mu_address_t to = NULL; | 795 | mu_address_t to = NULL; |
802 | mu_mailer_t mailer = NULL; | 796 | mu_mailer_t mailer = NULL; |
... | @@ -808,27 +802,26 @@ SCM_DEFINE (scm_mu_message_send, "mu-message-send", 1, 3, 0, | ... | @@ -808,27 +802,26 @@ SCM_DEFINE (scm_mu_message_send, "mu-message-send", 1, 3, 0, |
808 | 802 | ||
809 | if (!SCM_UNBNDP (MAILER) && MAILER != SCM_BOOL_F) | 803 | if (!SCM_UNBNDP (MAILER) && MAILER != SCM_BOOL_F) |
810 | { | 804 | { |
811 | SCM_ASSERT (SCM_NIMP (MAILER) && SCM_STRINGP (MAILER), | 805 | SCM_ASSERT (scm_is_string (MAILER), MAILER, SCM_ARG2, FUNC_NAME); |
812 | MAILER, SCM_ARG2, FUNC_NAME); | 806 | mailer_name = scm_i_string_chars (MAILER); |
813 | mailer_name = SCM_STRING_CHARS (MAILER); | ||
814 | } | 807 | } |
815 | else | 808 | else |
816 | { | 809 | { |
817 | SCM val = MU_SCM_SYMBOL_VALUE("mu-mailer"); | 810 | SCM val = MU_SCM_SYMBOL_VALUE("mu-mailer"); |
818 | mailer_name = SCM_STRING_CHARS(val); | 811 | mailer_name = scm_i_string_chars(val); |
819 | } | 812 | } |
820 | 813 | ||
821 | if (!SCM_UNBNDP (FROM) && FROM != SCM_BOOL_F) | 814 | if (!SCM_UNBNDP (FROM) && FROM != SCM_BOOL_F) |
822 | { | 815 | { |
823 | SCM_ASSERT (SCM_NIMP (FROM) && SCM_STRINGP (FROM) | 816 | SCM_ASSERT (scm_is_string (FROM) |
824 | && mu_address_create (&from, SCM_STRING_CHARS (FROM)) == 0, | 817 | && mu_address_create (&from, scm_i_string_chars (FROM)) == 0, |
825 | FROM, SCM_ARG3, FUNC_NAME); | 818 | FROM, SCM_ARG3, FUNC_NAME); |
826 | } | 819 | } |
827 | 820 | ||
828 | if (!SCM_UNBNDP (TO) && TO != SCM_BOOL_F) | 821 | if (!SCM_UNBNDP (TO) && TO != SCM_BOOL_F) |
829 | { | 822 | { |
830 | SCM_ASSERT (SCM_NIMP (TO) && SCM_STRINGP (TO) | 823 | SCM_ASSERT (scm_is_string (TO) |
831 | && mu_address_create (&to, SCM_STRING_CHARS (TO)) == 0, | 824 | && mu_address_create (&to, scm_i_string_chars (TO)) == 0, |
832 | TO, SCM_ARG4, FUNC_NAME); | 825 | TO, SCM_ARG4, FUNC_NAME); |
833 | } | 826 | } |
834 | 827 | ||
... | @@ -837,7 +830,7 @@ SCM_DEFINE (scm_mu_message_send, "mu-message-send", 1, 3, 0, | ... | @@ -837,7 +830,7 @@ SCM_DEFINE (scm_mu_message_send, "mu-message-send", 1, 3, 0, |
837 | return SCM_BOOL_F; | 830 | return SCM_BOOL_F; |
838 | } | 831 | } |
839 | 832 | ||
840 | if (SCM_INUM(MU_SCM_SYMBOL_VALUE("mu-debug"))) | 833 | if (scm_to_int32 (MU_SCM_SYMBOL_VALUE("mu-debug"))) |
841 | { | 834 | { |
842 | mu_debug_t debug = NULL; | 835 | mu_debug_t debug = NULL; |
843 | mu_mailer_get_debug (mailer, &debug); | 836 | mu_mailer_get_debug (mailer, &debug); | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -66,7 +66,7 @@ mu_scm_mime_create (SCM owner, mu_mime_t mime) | ... | @@ -66,7 +66,7 @@ mu_scm_mime_create (SCM owner, mu_mime_t mime) |
66 | { | 66 | { |
67 | struct mu_mime *mum; | 67 | struct mu_mime *mum; |
68 | 68 | ||
69 | mum = scm_must_malloc (sizeof (struct mu_mime), "mime"); | 69 | mum = scm_gc_malloc (sizeof (struct mu_mime), "mime"); |
70 | mum->owner = owner; | 70 | mum->owner = owner; |
71 | mum->mime = mime; | 71 | mum->mime = mime; |
72 | SCM_RETURN_NEWSMOB (mime_tag, mum); | 72 | SCM_RETURN_NEWSMOB (mime_tag, mum); |
... | @@ -96,7 +96,8 @@ SCM_DEFINE (scm_mu_mime_create, "mu-mime-create", 0, 2, 0, | ... | @@ -96,7 +96,8 @@ SCM_DEFINE (scm_mu_mime_create, "mu-mime-create", 0, 2, 0, |
96 | mu_message_t msg = NULL; | 96 | mu_message_t msg = NULL; |
97 | mu_mime_t mime; | 97 | mu_mime_t mime; |
98 | int flags; | 98 | int flags; |
99 | 99 | int status; | |
100 | |||
100 | if (SCM_IMP (FLAGS) && SCM_BOOLP (FLAGS)) | 101 | if (SCM_IMP (FLAGS) && SCM_BOOLP (FLAGS)) |
101 | { | 102 | { |
102 | /*if (FLAGS == SCM_BOOL_F)*/ | 103 | /*if (FLAGS == SCM_BOOL_F)*/ |
... | @@ -104,9 +105,8 @@ SCM_DEFINE (scm_mu_mime_create, "mu-mime-create", 0, 2, 0, | ... | @@ -104,9 +105,8 @@ SCM_DEFINE (scm_mu_mime_create, "mu-mime-create", 0, 2, 0, |
104 | } | 105 | } |
105 | else | 106 | else |
106 | { | 107 | { |
107 | SCM_ASSERT (SCM_IMP (FLAGS) && SCM_INUMP (FLAGS), | 108 | SCM_ASSERT (scm_is_integer (FLAGS), FLAGS, SCM_ARG1, FUNC_NAME); |
108 | FLAGS, SCM_ARG1, FUNC_NAME); | 109 | flags = scm_to_int32 (FLAGS); |
109 | flags = SCM_INUM (FLAGS); | ||
110 | } | 110 | } |
111 | 111 | ||
112 | if (!SCM_UNBNDP (MESG)) | 112 | if (!SCM_UNBNDP (MESG)) |
... | @@ -115,8 +115,10 @@ SCM_DEFINE (scm_mu_mime_create, "mu-mime-create", 0, 2, 0, | ... | @@ -115,8 +115,10 @@ SCM_DEFINE (scm_mu_mime_create, "mu-mime-create", 0, 2, 0, |
115 | msg = mu_scm_message_get (MESG); | 115 | msg = mu_scm_message_get (MESG); |
116 | } | 116 | } |
117 | 117 | ||
118 | if (mu_mime_create (&mime, msg, flags)) | 118 | status = mu_mime_create (&mime, msg, flags); |
119 | return SCM_BOOL_F; | 119 | if (status) |
120 | mu_scm_error (FUNC_NAME, status, | ||
121 | "Cannot create MIME object", SCM_BOOL_F); | ||
120 | 122 | ||
121 | return mu_scm_mime_create (MESG, mime); | 123 | return mu_scm_mime_create (MESG, mime); |
122 | } | 124 | } |
... | @@ -139,11 +141,14 @@ SCM_DEFINE (scm_mu_mime_get_num_parts, "mu-mime-get-num-parts", 1, 0, 0, | ... | @@ -139,11 +141,14 @@ SCM_DEFINE (scm_mu_mime_get_num_parts, "mu-mime-get-num-parts", 1, 0, 0, |
139 | { | 141 | { |
140 | mu_mime_t mime; | 142 | mu_mime_t mime; |
141 | size_t nparts; | 143 | size_t nparts; |
144 | int status; | ||
142 | 145 | ||
143 | SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME); | 146 | SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME); |
144 | mime = mu_scm_mime_get (MIME); | 147 | mime = mu_scm_mime_get (MIME); |
145 | if (mu_mime_get_num_parts (mime, &nparts)) | 148 | status = mu_mime_get_num_parts (mime, &nparts); |
146 | return SCM_BOOL_F; | 149 | if (status) |
150 | mu_scm_error (FUNC_NAME, status, | ||
151 | "Cannot count MIME parts", SCM_BOOL_F); | ||
147 | return mu_scm_makenum (nparts); | 152 | return mu_scm_makenum (nparts); |
148 | } | 153 | } |
149 | #undef FUNC_NAME | 154 | #undef FUNC_NAME |
... | @@ -154,13 +159,18 @@ SCM_DEFINE (scm_mu_mime_get_part, "mu-mime-get-part", 2, 0, 0, | ... | @@ -154,13 +159,18 @@ SCM_DEFINE (scm_mu_mime_get_part, "mu-mime-get-part", 2, 0, 0, |
154 | #define FUNC_NAME s_scm_mu_mime_get_part | 159 | #define FUNC_NAME s_scm_mu_mime_get_part |
155 | { | 160 | { |
156 | mu_message_t msg = NULL; | 161 | mu_message_t msg = NULL; |
157 | 162 | int status; | |
163 | |||
158 | SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME); | 164 | SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME); |
159 | SCM_ASSERT (SCM_IMP (PART) && SCM_INUMP (PART), | 165 | SCM_ASSERT (scm_is_integer (PART), PART, SCM_ARG2, FUNC_NAME); |
160 | PART, SCM_ARG2, FUNC_NAME); | 166 | |
167 | status = mu_mime_get_part (mu_scm_mime_get (MIME), | ||
168 | scm_to_int32 (PART), &msg); | ||
169 | if (status) | ||
170 | mu_scm_error (FUNC_NAME, status, | ||
171 | "Cannot get part ~A from MIME object ~A", | ||
172 | scm_list_2 (PART, MIME)); | ||
161 | 173 | ||
162 | if (mu_mime_get_part (mu_scm_mime_get (MIME), SCM_INUM (PART), &msg)) | ||
163 | return SCM_BOOL_F; | ||
164 | return mu_scm_message_create (MIME, msg); | 174 | return mu_scm_message_create (MIME, msg); |
165 | } | 175 | } |
166 | #undef FUNC_NAME | 176 | #undef FUNC_NAME |
... | @@ -172,15 +182,19 @@ SCM_DEFINE (scm_mu_mime_add_part, "mu-mime-add-part", 2, 0, 0, | ... | @@ -172,15 +182,19 @@ SCM_DEFINE (scm_mu_mime_add_part, "mu-mime-add-part", 2, 0, 0, |
172 | { | 182 | { |
173 | mu_mime_t mime; | 183 | mu_mime_t mime; |
174 | mu_message_t msg; | 184 | mu_message_t msg; |
175 | 185 | int status; | |
186 | |||
176 | SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME); | 187 | SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME); |
177 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG2, FUNC_NAME); | 188 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG2, FUNC_NAME); |
178 | mime = mu_scm_mime_get (MIME); | 189 | mime = mu_scm_mime_get (MIME); |
179 | msg = mu_scm_message_get (MESG); | 190 | msg = mu_scm_message_get (MESG); |
180 | 191 | ||
181 | if (mu_mime_add_part (mime, msg)) | 192 | status = mu_mime_add_part (mime, msg); |
182 | return SCM_BOOL_F; | 193 | if (status) |
183 | 194 | mu_scm_error (FUNC_NAME, status, | |
195 | "Cannot add new part to MIME object ~A", | ||
196 | scm_list_1 (MIME)); | ||
197 | |||
184 | mu_scm_message_add_owner (MESG, MIME); | 198 | mu_scm_message_add_owner (MESG, MIME); |
185 | 199 | ||
186 | return SCM_BOOL_T; | 200 | return SCM_BOOL_T; |
... | @@ -194,11 +208,16 @@ SCM_DEFINE (scm_mu_mime_get_message, "mu-mime-get-message", 1, 0, 0, | ... | @@ -194,11 +208,16 @@ SCM_DEFINE (scm_mu_mime_get_message, "mu-mime-get-message", 1, 0, 0, |
194 | { | 208 | { |
195 | mu_mime_t mime; | 209 | mu_mime_t mime; |
196 | mu_message_t msg; | 210 | mu_message_t msg; |
211 | int status; | ||
197 | 212 | ||
198 | SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME); | 213 | SCM_ASSERT (mu_scm_is_mime (MIME), MIME, SCM_ARG1, FUNC_NAME); |
199 | mime = mu_scm_mime_get (MIME); | 214 | mime = mu_scm_mime_get (MIME); |
200 | if (mu_mime_get_message (mime, &msg)) | 215 | status = mu_mime_get_message (mime, &msg); |
201 | return SCM_BOOL_F; | 216 | if (status) |
217 | mu_scm_error (FUNC_NAME, status, | ||
218 | "Cannot get message from MIME object ~A", | ||
219 | scm_list_1 (MIME)); | ||
220 | |||
202 | return mu_scm_message_create (MIME, msg); | 221 | return mu_scm_message_create (MIME, msg); |
203 | } | 222 | } |
204 | #undef FUNC_NAME | 223 | #undef FUNC_NAME | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -81,7 +81,7 @@ mu_port_make_from_stream (SCM msg, mu_stream_t stream, long mode) | ... | @@ -81,7 +81,7 @@ mu_port_make_from_stream (SCM msg, mu_stream_t stream, long mode) |
81 | SCM port; | 81 | SCM port; |
82 | scm_port *pt; | 82 | scm_port *pt; |
83 | 83 | ||
84 | mp = scm_must_malloc (sizeof (struct mu_port), "mu-port"); | 84 | mp = scm_gc_malloc (sizeof (struct mu_port), "mu-port"); |
85 | mp->msg = msg; | 85 | mp->msg = msg; |
86 | mp->stream = stream; | 86 | mp->stream = stream; |
87 | mp->offset = 0; | 87 | mp->offset = 0; |
... | @@ -159,10 +159,13 @@ mu_port_fill_input (SCM port) | ... | @@ -159,10 +159,13 @@ mu_port_fill_input (SCM port) |
159 | struct mu_port *mp = MU_PORT (port); | 159 | struct mu_port *mp = MU_PORT (port); |
160 | scm_port *pt = SCM_PTAB_ENTRY (port); | 160 | scm_port *pt = SCM_PTAB_ENTRY (port); |
161 | size_t nread = 0; | 161 | size_t nread = 0; |
162 | int status; | ||
162 | 163 | ||
163 | if (mu_stream_read (mp->stream, pt->read_buf, pt->read_buf_size, | 164 | status = mu_stream_read (mp->stream, pt->read_buf, pt->read_buf_size, |
164 | mp->offset, &nread)) | 165 | mp->offset, &nread); |
165 | scm_syserror ("mu_port_fill_input"); | 166 | if (status) |
167 | mu_scm_error ("mu_port_fill_input", status, | ||
168 | "Error reading from stream", SCM_BOOL_F); | ||
166 | 169 | ||
167 | if (nread == 0) | 170 | if (nread == 0) |
168 | return EOF; | 171 | return EOF; |
... | @@ -255,8 +258,11 @@ static void | ... | @@ -255,8 +258,11 @@ static void |
255 | mu_port_truncate (SCM port, mu_off_t length) | 258 | mu_port_truncate (SCM port, mu_off_t length) |
256 | { | 259 | { |
257 | struct mu_port *mp = MU_PORT (port); | 260 | struct mu_port *mp = MU_PORT (port); |
258 | if (mu_stream_truncate (mp->stream, length)) | 261 | int status; |
259 | scm_syserror ("mu_stream_truncate"); | 262 | status = mu_stream_truncate (mp->stream, length); |
263 | if (status) | ||
264 | mu_scm_error ("mu_stream_truncate", status, | ||
265 | "Error truncating stream", SCM_BOOL_F); | ||
260 | } | 266 | } |
261 | 267 | ||
262 | static int | 268 | static int | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2005 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2005, 2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -22,12 +22,23 @@ | ... | @@ -22,12 +22,23 @@ |
22 | # define _PATH_SENDMAIL "/usr/lib/sendmail" | 22 | # define _PATH_SENDMAIL "/usr/lib/sendmail" |
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | void | ||
26 | mu_scm_error (const char *func_name, int status, | ||
27 | const char *fmt, SCM args) | ||
28 | { | ||
29 | scm_error_scm (scm_from_locale_symbol ("mailutils-error"), | ||
30 | func_name ? scm_from_locale_string (func_name) : SCM_BOOL_F, | ||
31 | scm_makfrom0str (fmt), | ||
32 | args, | ||
33 | scm_list_1 (scm_from_int (status))); | ||
34 | } | ||
35 | |||
25 | SCM | 36 | SCM |
26 | mu_scm_makenum (unsigned long val) | 37 | mu_scm_makenum (unsigned long val) |
27 | #ifndef HAVE_SCM_LONG2NUM | 38 | #ifndef HAVE_SCM_LONG2NUM |
28 | { | 39 | { |
29 | if (SCM_FIXABLE ((long) val)) | 40 | if (SCM_FIXABLE ((long) val)) |
30 | return SCM_MAKINUM (val); | 41 | return scm_from_int (val); |
31 | 42 | ||
32 | #ifdef SCM_BIGDIG | 43 | #ifdef SCM_BIGDIG |
33 | return scm_long2big (val); | 44 | return scm_long2big (val); |
... | @@ -115,26 +126,30 @@ SCM_DEFINE (scm_mu_register_format, "mu-register-format", 0, 0, 1, | ... | @@ -115,26 +126,30 @@ SCM_DEFINE (scm_mu_register_format, "mu-register-format", 0, 0, 1, |
115 | "If called without arguments, registers all available formats\n") | 126 | "If called without arguments, registers all available formats\n") |
116 | #define FUNC_NAME s_scm_mu_register_format | 127 | #define FUNC_NAME s_scm_mu_register_format |
117 | { | 128 | { |
118 | SCM status; | 129 | int status; |
119 | 130 | ||
120 | if (REST == SCM_EOL) | 131 | if (REST == SCM_EOL) |
121 | { | 132 | { |
122 | register_format (NULL); | 133 | status = register_format (NULL); |
123 | status = SCM_BOOL_T; | 134 | if (status) |
135 | mu_scm_error (FUNC_NAME, status, | ||
136 | "Cannot register formats", | ||
137 | SCM_BOOL_F); | ||
124 | } | 138 | } |
125 | else | 139 | else |
126 | { | 140 | { |
127 | status = SCM_BOOL_T; | ||
128 | for (; REST != SCM_EOL; REST = SCM_CDR (REST)) | 141 | for (; REST != SCM_EOL; REST = SCM_CDR (REST)) |
129 | { | 142 | { |
130 | SCM scm = SCM_CAR (REST); | 143 | SCM scm = SCM_CAR (REST); |
131 | SCM_ASSERT (SCM_NIMP (scm) && SCM_STRINGP (scm), | 144 | SCM_ASSERT (scm_is_string (scm), scm, SCM_ARGn, FUNC_NAME); |
132 | scm, SCM_ARGn, FUNC_NAME); | 145 | status = register_format (scm_i_string_chars (scm)); |
133 | if (register_format (SCM_STRING_CHARS (scm))) | 146 | if (status) |
134 | status = SCM_BOOL_F; | 147 | mu_scm_error (FUNC_NAME, status, |
148 | "Cannot register format ~A", | ||
149 | scm_list_1 (scm)); | ||
135 | } | 150 | } |
136 | } | 151 | } |
137 | return status; | 152 | return SCM_UNSPECIFIED; |
138 | } | 153 | } |
139 | #undef FUNC_NAME | 154 | #undef FUNC_NAME |
140 | 155 | ||
... | @@ -177,7 +192,7 @@ mu_scm_init () | ... | @@ -177,7 +192,7 @@ mu_scm_init () |
177 | 192 | ||
178 | /* Create MU- attribute names */ | 193 | /* Create MU- attribute names */ |
179 | for (i = 0; attr_kw[i].name; i++) | 194 | for (i = 0; attr_kw[i].name; i++) |
180 | scm_c_define(attr_kw[i].name, SCM_MAKINUM(attr_kw[i].value)); | 195 | scm_c_define(attr_kw[i].name, scm_from_int(attr_kw[i].value)); |
181 | 196 | ||
182 | mu_scm_mutil_init (); | 197 | mu_scm_mutil_init (); |
183 | mu_scm_mailbox_init (); | 198 | mu_scm_mailbox_init (); | ... | ... |
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public | 5 | modify it under the terms of the GNU Lesser General Public |
... | @@ -30,22 +30,28 @@ SCM_DEFINE (scm_mu_getpwuid, "mu-getpwuid", 1, 0, 0, | ... | @@ -30,22 +30,28 @@ SCM_DEFINE (scm_mu_getpwuid, "mu-getpwuid", 1, 0, 0, |
30 | SCM result; | 30 | SCM result; |
31 | struct mu_auth_data *entry; | 31 | struct mu_auth_data *entry; |
32 | SCM *ve; | 32 | SCM *ve; |
33 | 33 | DECL_SCM_T_ARRAY_HANDLE(handle); | |
34 | result = scm_make_vector (SCM_MAKINUM (8), SCM_UNSPECIFIED); | 34 | |
35 | ve = SCM_VELTS (result); | 35 | result = scm_c_make_vector (8, SCM_UNSPECIFIED); |
36 | if (SCM_INUMP (USER)) | 36 | ve = scm_vector_writable_elements (result, |
37 | SCM_T_ARRAY_HANDLE_PTR(handle), | ||
38 | NULL, NULL); | ||
39 | |||
40 | if (scm_is_integer (USER)) | ||
37 | { | 41 | { |
38 | entry = mu_get_auth_by_uid (SCM_INUM (USER)); | 42 | entry = mu_get_auth_by_uid (scm_to_int32 (USER)); |
39 | } | 43 | } |
40 | else | 44 | else |
41 | { | 45 | { |
42 | SCM_VALIDATE_ROSTRING (1, USER); | 46 | SCM_VALIDATE_STRING (1, USER); |
43 | if (SCM_SUBSTRP (USER)) | 47 | if (scm_is_string (USER)) |
44 | USER = scm_makfromstr (SCM_ROCHARS (USER), SCM_ROLENGTH (USER), 0); | 48 | USER = scm_from_locale_stringn (scm_i_string_chars (USER), |
45 | entry = mu_get_auth_by_name (SCM_ROCHARS (USER)); | 49 | scm_i_string_length (USER)); |
50 | entry = mu_get_auth_by_name (scm_i_string_chars (USER)); | ||
46 | } | 51 | } |
47 | if (!entry) | 52 | if (!entry) |
48 | return SCM_BOOL_F; | 53 | mu_scm_error (FUNC_NAME, errno, |
54 | "Cannot get user credentials", SCM_BOOL_F); | ||
49 | 55 | ||
50 | ve[0] = scm_makfrom0str (entry->name); | 56 | ve[0] = scm_makfrom0str (entry->name); |
51 | ve[1] = scm_makfrom0str (entry->passwd); | 57 | ve[1] = scm_makfrom0str (entry->passwd); |
... | @@ -61,6 +67,9 @@ SCM_DEFINE (scm_mu_getpwuid, "mu-getpwuid", 1, 0, 0, | ... | @@ -61,6 +67,9 @@ SCM_DEFINE (scm_mu_getpwuid, "mu-getpwuid", 1, 0, 0, |
61 | else | 67 | else |
62 | ve[6] = scm_makfrom0str (entry->shell); | 68 | ve[6] = scm_makfrom0str (entry->shell); |
63 | ve[7] = scm_makfrom0str (entry->mailbox); | 69 | ve[7] = scm_makfrom0str (entry->mailbox); |
70 | |||
71 | scm_array_handle_release (SCM_T_ARRAY_HANDLE_PTR (handle)); | ||
72 | |||
64 | mu_auth_data_free (entry); | 73 | mu_auth_data_free (entry); |
65 | return result; | 74 | return result; |
66 | } | 75 | } | ... | ... |
-
Please register or sign in to post a comment