diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-04-14 11:36:52 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-04-14 11:38:41 +0300 |
commit | 94adc8f49244e0abfd3ac47e0cfb2af2a063adc5 (patch) | |
tree | a58a72081ee281f55bedf322e0f77b90da13ad4a | |
parent | 49e121acc32a38b2d618cfd0544de349618c2bb1 (diff) | |
download | mailutils-94adc8f49244e0abfd3ac47e0cfb2af2a063adc5.tar.gz mailutils-94adc8f49244e0abfd3ac47e0cfb2af2a063adc5.tar.bz2 |
Further improvements in the Guile-related code.
* gint: Upgrade.
* libmu_scm/Makefile.am: Initialize BUILT_SOURCES.
* libmu_scm/mu_address.c (address_get_fp): Change
signature to match those of mu_address_aget family.
(all functions): Use functions from mu_address_aget family.
Downcase argument names. Refer to them in the docstring
using @var notation.
* libmu_scm/mu_body.c: Downcase argument names. Refer to them
in the docstring using @var notation.
* libmu_scm/mu_logger.c: Likewise.
* libmu_scm/mu_mailbox.c: Likewise.
* libmu_scm/mu_message.c: Likewise.
* libmu_scm/mu_mime.c: Likewise.
* libmu_scm/mu_scm.c: Likewise.
* libmu_scm/mu_util.c: Likewise.
m--------- | gint | 0 | ||||
-rw-r--r-- | libmu_scm/Makefile.am | 1 | ||||
-rw-r--r-- | libmu_scm/mu_address.c | 89 | ||||
-rw-r--r-- | libmu_scm/mu_body.c | 21 | ||||
-rw-r--r-- | libmu_scm/mu_logger.c | 30 | ||||
-rw-r--r-- | libmu_scm/mu_mailbox.c | 187 | ||||
-rw-r--r-- | libmu_scm/mu_message.c | 427 | ||||
-rw-r--r-- | libmu_scm/mu_mime.c | 101 | ||||
-rw-r--r-- | libmu_scm/mu_scm.c | 16 | ||||
-rw-r--r-- | libmu_scm/mu_util.c | 12 |
10 files changed, 440 insertions, 444 deletions
diff --git a/gint b/gint -Subproject c6a7620deb7e3e139329e2daad31d4071f01b43 +Subproject 4254b0590e609b82dac3d688ecb401c9eefb7e2 diff --git a/libmu_scm/Makefile.am b/libmu_scm/Makefile.am index f317bba2d..a65df2847 100644 --- a/libmu_scm/Makefile.am +++ b/libmu_scm/Makefile.am @@ -98,4 +98,5 @@ install-data-hook: sitedir = @GUILE_SITE@/$(PACKAGE) site_DATA = mailutils.scm SUFFIXES= +BUILT_SOURCES= include ../gint/gint.mk diff --git a/libmu_scm/mu_address.c b/libmu_scm/mu_address.c index 9ced92c8c..2df7dcb51 100644 --- a/libmu_scm/mu_address.c +++ b/libmu_scm/mu_address.c @@ -19,30 +19,29 @@ #include "mu_scm.h" -typedef int (*address_get_fp) (mu_address_t, size_t, char *, size_t, size_t *); +typedef int (*address_get_fp) (mu_address_t, size_t, char **); static SCM _get_address_part (const char *func_name, address_get_fp fun, - SCM ADDRESS, SCM NUM) + SCM address, SCM num) { mu_address_t addr; - int length; char *str; SCM ret; - int num; + int n; int status; - SCM_ASSERT (scm_is_string (ADDRESS), ADDRESS, SCM_ARG1, func_name); + SCM_ASSERT (scm_is_string (address), address, SCM_ARG1, func_name); - if (!SCM_UNBNDP (NUM)) + if (!SCM_UNBNDP (num)) { - SCM_ASSERT (scm_is_integer (NUM), NUM, SCM_ARG1, func_name); - num = scm_to_int (NUM); + SCM_ASSERT (scm_is_integer (num), num, SCM_ARG1, func_name); + n = scm_to_int (num); } else - num = 1; + n = 1; - str = scm_to_locale_string (ADDRESS); + str = scm_to_locale_string (address); if (!str[0]) { free (str); @@ -54,15 +53,7 @@ _get_address_part (const char *func_name, address_get_fp fun, if (status) mu_scm_error (func_name, status, "Cannot create address", SCM_BOOL_F); - str = malloc (length + 1); - if (!str) - { - mu_address_destroy (&addr); - mu_scm_error (func_name, ENOMEM, - "Cannot allocate memory", SCM_BOOL_F); - } - - status = (*fun) (addr, num, str, length + 1, NULL); + status = (*fun) (addr, n, &str); mu_address_destroy (&addr); if (status == 0) @@ -79,58 +70,58 @@ _get_address_part (const char *func_name, address_get_fp fun, } SCM_DEFINE_PUBLIC (scm_mu_address_get_personal, "mu-address-get-personal", 1, 1, 0, - (SCM ADDRESS, SCM NUM), - "Return personal part of the NUMth email address from ADDRESS.\n") + (SCM address, SCM num), + "Return personal part of the @var{num}th email address from @var{address}.\n") #define FUNC_NAME s_scm_mu_address_get_personal { return _get_address_part (FUNC_NAME, - mu_address_get_personal, ADDRESS, NUM); + mu_address_aget_personal, address, num); } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_address_get_comments, "mu-address-get-comments", 1, 1, 0, - (SCM ADDRESS, SCM NUM), - "Return comment part of the NUMth email address from ADDRESS.\n") + (SCM address, SCM num), + "Return comment part of the @var{num}th email address from @var{address}.\n") #define FUNC_NAME s_scm_mu_address_get_comments { return _get_address_part (FUNC_NAME, - mu_address_get_comments, ADDRESS, NUM); + mu_address_aget_comments, address, num); } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_address_get_email, "mu-address-get-email", 1, 1, 0, - (SCM ADDRESS, SCM NUM), - "Return email part of the NUMth email address from ADDRESS.\n") + (SCM address, SCM num), + "Return email part of the @var{num}th email address from @var{address}.\n") #define FUNC_NAME s_scm_mu_address_get_email { return _get_address_part (FUNC_NAME, - mu_address_get_email, ADDRESS, NUM); + mu_address_aget_email, address, num); } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_address_get_domain, "mu-address-get-domain", 1, 1, 0, - (SCM ADDRESS, SCM NUM), - "Return domain part of the NUMth email address from ADDRESS.\n") + (SCM address, SCM num), + "Return domain part of the @var{num}th email address from @var{address}.\n") #define FUNC_NAME s_scm_mu_address_get_domain { return _get_address_part (FUNC_NAME, - mu_address_get_domain, ADDRESS, NUM); + mu_address_aget_domain, address, num); } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_address_get_local, "mu-address-get-local", 1, 1, 0, - (SCM ADDRESS, SCM NUM), - "Return local part of the NUMth email address from ADDRESS.\n") + (SCM address, SCM num), + "Return local part of the @var{num}th email address from @var{address}.\n") #define FUNC_NAME s_scm_mu_address_get_local { return _get_address_part (FUNC_NAME, - mu_address_get_local_part, ADDRESS, NUM); + mu_address_aget_local_part, address, num); } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0, - (SCM ADDRESS), - "Return number of parts in email address ADDRESS.\n") + (SCM address), + "Return number of parts in email address @var{address}.\n") #define FUNC_NAME s_scm_mu_address_get_count { mu_address_t addr; @@ -138,15 +129,15 @@ SCM_DEFINE_PUBLIC (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0, int status; char *str; - SCM_ASSERT (scm_is_string (ADDRESS), ADDRESS, SCM_ARG1, FUNC_NAME); + SCM_ASSERT (scm_is_string (address), address, SCM_ARG1, FUNC_NAME); - str = scm_to_locale_string (ADDRESS); + str = scm_to_locale_string (address); status = mu_address_create (&addr, str); free (str); if (status) mu_scm_error (FUNC_NAME, status, "Cannot create address for ~A", - scm_list_1 (ADDRESS)); + scm_list_1 (address)); mu_address_get_count (addr, &count); mu_address_destroy (&addr); @@ -155,29 +146,29 @@ SCM_DEFINE_PUBLIC (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0, #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_username_to_email, "mu-username->email", 0, 1, 0, - (SCM NAME), -"Deduce user's email address from his username. If NAME is omitted, \n" + (SCM name), +"Deduce user's email address from his username. If @var{name} is omitted, \n" "current username is assumed\n") #define FUNC_NAME s_scm_mu_username_to_email { - char *name; + char *username; char *email; SCM ret; - if (SCM_UNBNDP (NAME)) - name = NULL; + if (SCM_UNBNDP (name)) + username = NULL; else { - SCM_ASSERT (scm_is_string (NAME), NAME, SCM_ARG1, FUNC_NAME); - name = scm_to_locale_string (NAME); + SCM_ASSERT (scm_is_string (name), name, SCM_ARG1, FUNC_NAME); + username = scm_to_locale_string (name); } - email = mu_get_user_email (name); - free (name); + email = mu_get_user_email (username); + free (username); if (!email) mu_scm_error (FUNC_NAME, 0, "Cannot get user email for ~A", - scm_list_1 (NAME)); + scm_list_1 (name)); ret = scm_from_locale_string (email); free (email); diff --git a/libmu_scm/mu_body.c b/libmu_scm/mu_body.c index a2597171b..ff88759ec 100644 --- a/libmu_scm/mu_body.c +++ b/libmu_scm/mu_body.c @@ -103,16 +103,16 @@ mu_scm_body_create (SCM msg, mu_body_t body) /* Guile primitives */ SCM_DEFINE_PUBLIC (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0, - (SCM BODY), - "Read next line from the BODY.") + (SCM body), + "Read next line from the @var{body}.") #define FUNC_NAME s_scm_mu_body_read_line { struct mu_body *mbp; size_t n, nread; int status; - SCM_ASSERT (mu_scm_is_body (BODY), BODY, SCM_ARG1, FUNC_NAME); - mbp = (struct mu_body *) SCM_CDR (BODY); + SCM_ASSERT (mu_scm_is_body (body), body, SCM_ARG1, FUNC_NAME); + mbp = (struct mu_body *) SCM_CDR (body); if (!mbp->stream) { @@ -164,8 +164,8 @@ SCM_DEFINE_PUBLIC (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0, #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_body_write, "mu-body-write", 2, 0, 0, - (SCM BODY, SCM TEXT), - "Append TEXT to message BODY.") + (SCM body, SCM text), + "Append @var{text} to message @var{body}.") #define FUNC_NAME s_scm_mu_body_write { char *ptr; @@ -173,9 +173,9 @@ SCM_DEFINE_PUBLIC (scm_mu_body_write, "mu-body-write", 2, 0, 0, struct mu_body *mbp; int status; - SCM_ASSERT (mu_scm_is_body (BODY), BODY, SCM_ARG1, FUNC_NAME); - mbp = (struct mu_body *) SCM_CDR (BODY); - SCM_ASSERT (scm_is_string (TEXT), TEXT, SCM_ARG2, FUNC_NAME); + SCM_ASSERT (mu_scm_is_body (body), body, SCM_ARG1, FUNC_NAME); + mbp = (struct mu_body *) SCM_CDR (body); + SCM_ASSERT (scm_is_string (text), text, SCM_ARG2, FUNC_NAME); if (!mbp->stream) { @@ -185,9 +185,10 @@ SCM_DEFINE_PUBLIC (scm_mu_body_write, "mu-body-write", 2, 0, 0, "Cannot get body stream", SCM_BOOL_F); } - ptr = SCM_STRING_CHARS (TEXT); + ptr = scm_to_locale_string (text); len = strlen (ptr); status = mu_stream_write (mbp->stream, ptr, len, mbp->offset, &n); + free (ptr); mu_scm_error (FUNC_NAME, status, "Error writing to stream", SCM_BOOL_F); mbp->offset += n; diff --git a/libmu_scm/mu_logger.c b/libmu_scm/mu_logger.c index ab6ee87be..01ebe0041 100644 --- a/libmu_scm/mu_logger.c +++ b/libmu_scm/mu_logger.c @@ -24,37 +24,37 @@ static char *log_tag; SCM_DEFINE_PUBLIC (scm_mu_openlog, "mu-openlog", 3, 0, 0, - (SCM IDENT, SCM OPTION, SCM FACILITY), + (SCM ident, SCM option, SCM facility), "Opens a connection to the system logger for Guile program.\n" -"IDENT, OPTION and FACILITY have the same meaning as in openlog(3)") +"@var{ident}, @var{option} and @var{facility} have the same meaning as in openlog(3)") #define FUNC_NAME s_scm_mu_openlog { - SCM_ASSERT (scm_is_string (IDENT), IDENT, SCM_ARG1, FUNC_NAME); + SCM_ASSERT (scm_is_string (ident), ident, SCM_ARG1, FUNC_NAME); if (log_tag) free (log_tag); - log_tag = scm_to_locale_string(IDENT); + log_tag = scm_to_locale_string (ident); - SCM_ASSERT (scm_is_integer (OPTION), OPTION, SCM_ARG2, FUNC_NAME); - SCM_ASSERT (scm_is_integer (FACILITY), FACILITY, SCM_ARG3, FUNC_NAME); - openlog (log_tag, scm_to_int (OPTION), scm_to_int (FACILITY)); + SCM_ASSERT (scm_is_integer (option), option, SCM_ARG2, FUNC_NAME); + SCM_ASSERT (scm_is_integer (facility), facility, SCM_ARG3, FUNC_NAME); + openlog (log_tag, scm_to_int (option), scm_to_int (facility)); return SCM_UNSPECIFIED; } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_logger, "mu-logger", 2, 0, 0, - (SCM PRIO, SCM TEXT), - "Distributes TEXT via syslogd priority PRIO.") + (SCM prio, SCM text), + "Distributes @var{text} via the syslog priority @var{prio}.") #define FUNC_NAME s_scm_mu_logger { - int prio; + int nprio; char *str; - SCM_ASSERT (scm_is_integer (PRIO), PRIO, SCM_ARG1, FUNC_NAME); - prio = scm_to_int (PRIO); + SCM_ASSERT (scm_is_integer (prio), prio, SCM_ARG1, FUNC_NAME); + nprio = scm_to_int (prio); - SCM_ASSERT (scm_is_string (TEXT), TEXT, SCM_ARG2, FUNC_NAME); - str = scm_to_locale_string (TEXT); - syslog (prio, "%s", str); + SCM_ASSERT (scm_is_string (text), text, SCM_ARG2, FUNC_NAME); + str = scm_to_locale_string (text); + syslog (nprio, "%s", str); free (str); return SCM_UNSPECIFIED; } diff --git a/libmu_scm/mu_mailbox.c b/libmu_scm/mu_mailbox.c index f58fbad9e..dce05e8db 100644 --- a/libmu_scm/mu_mailbox.c +++ b/libmu_scm/mu_mailbox.c @@ -138,34 +138,34 @@ mu_scm_is_mailbox (SCM scm) /* Guile primitives */ SCM_DEFINE_PUBLIC (scm_mu_mail_directory, "mu-mail-directory", 0, 1, 0, - (SCM URL), + (SCM url), "Do not use this function. Use mu-user-mailbox-url instead.") #define FUNC_NAME s_scm_mu_mail_directory { mu_scm_error (FUNC_NAME, ENOSYS, "This function is deprecated. Use mu-user-mailbox-url instead.", - scm_list_1 (URL)); + scm_list_1 (url)); return SCM_EOL; } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0, - (SCM USER), - "") + (SCM user), + "Return URL of the default mailbox for user @var{user}.") #define FUNC_NAME s_scm_mu_user_mailbox_url { int rc; char *p, *str; SCM ret; - SCM_ASSERT (scm_is_string (USER), USER, SCM_ARG1, FUNC_NAME); - str = scm_to_locale_string (USER); + SCM_ASSERT (scm_is_string (user), user, SCM_ARG1, FUNC_NAME); + str = scm_to_locale_string (user); rc = mu_construct_user_mailbox_url (&p, str); free (str); if (rc) mu_scm_error (FUNC_NAME, rc, "Cannot construct mailbox URL for ~A", - scm_list_1 (USER)); + scm_list_1 (user)); ret = scm_from_locale_string (p); free (p); return ret; @@ -173,17 +173,17 @@ SCM_DEFINE_PUBLIC (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0, #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0, - (SCM URL), -"If URL is given, sets it as a name of the user's folder directory.\n" + (SCM url), +"If @var{url} is given, sets it as a name of the user's folder directory.\n" "Returns the current value of the folder directory.") #define FUNC_NAME s_scm_mu_folder_directory { - if (!SCM_UNBNDP (URL)) + if (!SCM_UNBNDP (url)) { char *s; - SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME); - s = scm_to_locale_string (URL); + SCM_ASSERT (scm_is_string (url), url, SCM_ARG1, FUNC_NAME); + s = scm_to_locale_string (url); mu_set_folder_directory (s); free (s); } @@ -192,12 +192,12 @@ SCM_DEFINE_PUBLIC (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0, #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, - (SCM URL, SCM MODE), -"Opens the mailbox specified by URL. MODE is a string, consisting of\n" + (SCM url, SCM mode), +"Opens the mailbox specified by @var{url}. @var{mode} is a string, consisting of\n" "the characters described below, giving the access mode for the mailbox\n" "\n" "@multitable @columnfractions 0.20 0.70\n" -"@headitem MODE @tab Meaning\n" +"@headitem @var{mode} @tab Meaning\n" "@item r @tab Open for reading.\n" "@item w @tab Open for writing.\n" "@item a @tab Open for appending to the end of the mailbox.\n" @@ -208,54 +208,54 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, { mu_mailbox_t mbox = NULL; char *mode_str; - int mode = 0; + int mode_bits = 0; int status; SCM ret; - SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME); - SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME); + SCM_ASSERT (scm_is_string (url), url, SCM_ARG1, FUNC_NAME); + SCM_ASSERT (scm_is_string (mode), mode, SCM_ARG2, FUNC_NAME); scm_dynwind_begin (0); - mode_str = scm_to_locale_string (MODE); + mode_str = scm_to_locale_string (mode); scm_dynwind_free (mode_str); for (; *mode_str; mode_str++) switch (*mode_str) { case 'r': - mode |= MU_STREAM_READ; + mode_bits |= MU_STREAM_READ; break; case 'w': - mode |= MU_STREAM_WRITE; + mode_bits |= MU_STREAM_WRITE; break; case 'a': - mode |= MU_STREAM_APPEND; + mode_bits |= MU_STREAM_APPEND; break; case 'c': - mode |= MU_STREAM_CREAT; + mode_bits |= MU_STREAM_CREAT; break; } - if (mode & MU_STREAM_READ && mode & MU_STREAM_WRITE) - mode = (mode & ~(MU_STREAM_READ | MU_STREAM_WRITE)) | MU_STREAM_RDWR; + if (mode_bits & MU_STREAM_READ && mode_bits & MU_STREAM_WRITE) + mode_bits = (mode_bits & ~(MU_STREAM_READ | MU_STREAM_WRITE)) | MU_STREAM_RDWR; - mode_str = scm_to_locale_string (URL); + mode_str = scm_to_locale_string (url); scm_dynwind_free (mode_str); status = mu_mailbox_create_default (&mbox, mode_str); if (status) mu_scm_error (FUNC_NAME, status, "Cannot create default mailbox ~A", - scm_list_1 (URL)); + scm_list_1 (url)); - status = mu_mailbox_open (mbox, mode); + status = mu_mailbox_open (mbox, mode_bits); if (status) { mu_mailbox_destroy (&mbox); mu_scm_error (FUNC_NAME, status, "Cannot open default mailbox ~A", - scm_list_1 (URL)); + scm_list_1 (url)); } ret = mu_scm_mailbox_create (mbox); scm_dynwind_end (); @@ -264,13 +264,14 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_open, "mu-mailbox-open", 2, 0, 0, #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_mailbox_close, "mu-mailbox-close", 1, 0, 0, - (SCM MBOX), "Closes mailbox MBOX.") + (SCM mbox), + "Closes mailbox @var{mbox}.") #define FUNC_NAME s_scm_mu_mailbox_close { struct mu_mailbox *mum; - SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); - mum = (struct mu_mailbox *) SCM_CDR (MBOX); + SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME); + mum = (struct mu_mailbox *) SCM_CDR (mbox); mu_mailbox_close (mum->mbox); mu_mailbox_destroy (&mum->mbox); return SCM_UNSPECIFIED; @@ -278,16 +279,16 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_close, "mu-mailbox-close", 1, 0, 0, #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_url, "mu-mailbox-get-url", 1, 0, 0, - (SCM MBOX), - "Returns url of the mailbox MBOX.") + (SCM mbox), + "Returns URL of the mailbox @var{MBOX}.") #define FUNC_NAME s_scm_mu_mailbox_get_url { struct mu_mailbox *mum; mu_url_t url; int status; - SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); - mum = (struct mu_mailbox *) SCM_CDR (MBOX); + SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME); + mum = (struct mu_mailbox *) SCM_CDR (mbox); status = mu_mailbox_get_url (mum->mbox, &url); if (status) mu_scm_error (FUNC_NAME, status, @@ -299,9 +300,9 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_url, "mu-mailbox-get-url", 1, 0, 0, #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0, - (SCM MBOX, SCM MODE), -"Returns a port associated with the contents of the MBOX.\n" -"MODE is a string defining operation mode of the stream. It may\n" + (SCM mbox, SCM mode), +"Returns a port associated with the contents of the @var{mbox},\n" +"which is a string defining operation mode of the stream. It may\n" "contain any of the two characters: @samp{r} for reading, @samp{w} for\n" "writing.\n") #define FUNC_NAME s_scm_mu_mailbox_get_port @@ -312,105 +313,105 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_port, "mu-mailbox-get-port", 2, 0, 0, char *s; SCM ret; - SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); - SCM_ASSERT (scm_is_string (MODE), MODE, SCM_ARG2, FUNC_NAME); - mum = (struct mu_mailbox *) SCM_CDR (MBOX); + SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME); + SCM_ASSERT (scm_is_string (mode), mode, SCM_ARG2, FUNC_NAME); + mum = (struct mu_mailbox *) SCM_CDR (mbox); status = mu_mailbox_get_stream (mum->mbox, &stream); if (status) mu_scm_error (FUNC_NAME, status, "Cannot get mailbox stream", - scm_list_1 (MBOX)); - s = scm_to_locale_string (MODE); - ret = mu_port_make_from_stream (MBOX, stream, scm_mode_bits (s)); + scm_list_1 (mbox)); + s = scm_to_locale_string (mode); + ret = mu_port_make_from_stream (mbox, stream, scm_mode_bits (s)); free (s); return ret; } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_mailbox_get_message, "mu-mailbox-get-message", 2, 0, 0, - (SCM MBOX, SCM MSGNO), -"Retrieve from message #MSGNO from the mailbox MBOX.") + (SCM mbox, SCM msgno), +"Retrieve from message #@var{msgno} from the mailbox @var{mbox}.") #define FUNC_NAME s_scm_mu_mailbox_get_message { - size_t msgno; + size_t n; struct mu_mailbox *mum; mu_message_t msg; int status; - SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); - SCM_ASSERT (scm_is_integer (MSGNO), MSGNO, SCM_ARG2, FUNC_NAME); + SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME); + SCM_ASSERT (scm_is_integer (msgno), msgno, SCM_ARG2, FUNC_NAME); - mum = (struct mu_mailbox *) SCM_CDR (MBOX); - msgno = scm_to_int32 (MSGNO); + mum = (struct mu_mailbox *) SCM_CDR (mbox); + n = scm_to_size_t (msgno); - status = mu_mailbox_get_message (mum->mbox, msgno, &msg); + status = mu_mailbox_get_message (mum->mbox, n, &msg); if (status) mu_scm_error (FUNC_NAME, status, "Cannot get message ~A from mailbox ~A", - scm_list_2 (MSGNO, MBOX)); + scm_list_2 (msgno, mbox)); - return mu_scm_message_create (MBOX, msg); + return mu_scm_message_create (mbox, msg); } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_mailbox_messages_count, "mu-mailbox-messages-count", 1, 0, 0, - (SCM MBOX), -"Returns number of messages in the mailbox MBOX.") + (SCM mbox), +"Returns number of messages in the mailbox @var{mbox}.") #define FUNC_NAME s_scm_mu_mailbox_messages_count { struct mu_mailbox *mum; size_t nmesg; int status; - SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); - mum = (struct mu_mailbox *) SCM_CDR (MBOX); + SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME); + mum = (struct mu_mailbox *) SCM_CDR (mbox); status = mu_mailbox_messages_count (mum->mbox, &nmesg); if (status) mu_scm_error (FUNC_NAME, status, "Cannot count messages in mailbox ~A", - scm_list_1 (MBOX)); + scm_list_1 (mbox)); return scm_from_size_t (nmesg); } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_mailbox_expunge, "mu-mailbox-expunge", 1, 0, 0, - (SCM MBOX), -"Expunges deleted messages from the mailbox MBOX.") + (SCM mbox), +"Expunges deleted messages from the mailbox @var{mbox}.") #define FUNC_NAME s_scm_mu_mailbox_expunge { struct mu_mailbox *mum; int status; - SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); - mum = (struct mu_mailbox *) SCM_CDR (MBOX); + SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME); + mum = (struct mu_mailbox *) SCM_CDR (mbox); status = mu_mailbox_expunge (mum->mbox); if (status) mu_scm_error (FUNC_NAME, status, "Cannot expunge messages in mailbox ~A", - scm_list_1 (MBOX)); + scm_list_1 (mbox)); return SCM_BOOL_T; } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_mailbox_append_message, "mu-mailbox-append-message", 2, 0, 0, - (SCM MBOX, SCM MESG), -"Appends message MESG to the mailbox MBOX.") + (SCM mbox, SCM mesg), + "Appends message @var{mesg} to the mailbox @var{mbox}.") #define FUNC_NAME s_scm_mu_mailbox_append_message { struct mu_mailbox *mum; mu_message_t msg; int status; - SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); - SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG2, FUNC_NAME); - mum = (struct mu_mailbox *) SCM_CDR (MBOX); - msg = mu_scm_message_get (MESG); + SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME); + SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG2, FUNC_NAME); + mum = (struct mu_mailbox *) SCM_CDR (mbox); + msg = mu_scm_message_get (mesg); status = mu_mailbox_append_message (mum->mbox, msg); if (status) mu_scm_error (FUNC_NAME, status, "Cannot append message ~A to mailbox ~A", - scm_list_2 (MESG, MBOX)); + scm_list_2 (mesg, mbox)); return SCM_BOOL_T; } #undef FUNC_NAME @@ -425,56 +426,56 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_append_message, "mu-mailbox-append-message", 2 if (status) \ mu_scm_error (FUNC_NAME, status, \ "~A: " descr ": ~A", \ - scm_list_2 (MBOX, \ + scm_list_2 (mbox, \ scm_from_locale_string (mu_strerror (status)))); \ } \ while (0) SCM_DEFINE_PUBLIC (scm_mu_mailbox_first_message, "mu-mailbox-first-message", 1, 0, 0, - (SCM MBOX), - "Returns first message from the mailbox.") + (SCM mbox), + "Returns first message from the mailbox @var{mbox}.") #define FUNC_NAME s_scm_mu_mailbox_first_message { struct mu_mailbox *mum; int status; mu_message_t msg; - SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); - mum = (struct mu_mailbox *) SCM_CDR (MBOX); + SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME); + mum = (struct mu_mailbox *) SCM_CDR (mbox); if (!mum->itr) { status = mu_mailbox_get_iterator (mum->mbox, &mum->itr); if (status) mu_scm_error (FUNC_NAME, status, "~A: cannot create iterator: ~A", - scm_list_2 (MBOX, + scm_list_2 (mbox, scm_from_locale_string (mu_strerror (status)))); } ITROP (mu_iterator_first (mum->itr), "moving to the first message"); ITROP (mu_iterator_current (mum->itr, (void**)&msg), "getting current message"); - return mu_scm_message_create (MBOX, msg); + return mu_scm_message_create (mbox, msg); } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_mailbox_next_message, "mu-mailbox-next-message", 1, 0, 0, - (SCM MBOX), - "Returns next message from the mailbox.") + (SCM mbox), + "Returns next message from the mailbox @var{mbox}.") #define FUNC_NAME s_scm_mu_mailbox_next_message { struct mu_mailbox *mum; int status; mu_message_t msg; - SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); - mum = (struct mu_mailbox *) SCM_CDR (MBOX); + SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME); + mum = (struct mu_mailbox *) SCM_CDR (mbox); if (!mum->itr) { status = mu_mailbox_get_iterator (mum->mbox, &mum->itr); if (status) mu_scm_error (FUNC_NAME, status, "~A: cannot create iterator: ~A", - scm_list_2 (MBOX, + scm_list_2 (mbox, scm_from_locale_string (mu_strerror (status)))); ITROP (mu_iterator_first (mum->itr), "moving to the first message"); } @@ -483,27 +484,31 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_next_message, "mu-mailbox-next-message", 1, 0, ITROP (mu_iterator_current (mum->itr, (void**)&msg), "getting current message"); - return mu_scm_message_create (MBOX, msg); + return mu_scm_message_create (mbox, msg); } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_mailbox_more_messages_p, "mu-mailbox-more-messages?", 1, 0, 0, - (SCM MBOX), - "Returns next message from the mailbox.") + (SCM mbox), +"Returns @samp{#t} if there are more messages in the mailbox @var{mbox}\n" +"ahead of current iterator position. Usually this function is used after\n" +"a call to @samp{mu-mailbox-first-message} or @samp{mu-mailbox-next-message}.\n" +"If not, it initializes the iterator and points it to the first message inn" +"the mailbox.") #define FUNC_NAME s_scm_mu_mailbox_more_messages_p { struct mu_mailbox *mum; int status; - SCM_ASSERT (mu_scm_is_mailbox (MBOX), MBOX, SCM_ARG1, FUNC_NAME); - mum = (struct mu_mailbox *) SCM_CDR (MBOX); + SCM_ASSERT (mu_scm_is_mailbox (mbox), mbox, SCM_ARG1, FUNC_NAME); + mum = (struct mu_mailbox *) SCM_CDR (mbox); if (!mum->itr) { status = mu_mailbox_get_iterator (mum->mbox, &mum->itr); if (status) mu_scm_error (FUNC_NAME, status, "~A: cannot create iterator: ~A", - scm_list_2 (MBOX, + scm_list_2 (mbox, scm_from_locale_string (mu_strerror (status)))); status = mu_iterator_first (mum->itr); if (status == MU_ERR_NOENT) @@ -511,7 +516,7 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_more_messages_p, "mu-mailbox-more-messages?", if (status) mu_scm_error (FUNC_NAME, status, "~A: cannot set iterator to the first message: ~A", - scm_list_2 (MBOX, + scm_list_2 (mbox, scm_from_locale_string (mu_strerror (status)))); } return scm_from_bool (!!mu_iterator_is_done (mum->itr)); diff --git a/libmu_scm/mu_message.c b/libmu_scm/mu_message.c index d9e338630..27c96be43 100644 --- a/libmu_scm/mu_message.c +++ b/libmu_scm/mu_message.c @@ -177,8 +177,8 @@ mu_scm_is_message (SCM scm) /* Guile primitives */ SCM_DEFINE_PUBLIC (scm_mu_message_create, "mu-message-create", 0, 0, 0, - (), - "Creates an empty message.\n") + (), + "Creates an empty message.\n") #define FUNC_NAME s_scm_mu_message_create { mu_message_t msg; @@ -189,8 +189,8 @@ SCM_DEFINE_PUBLIC (scm_mu_message_create, "mu-message-create", 0, 0, 0, /* FIXME: This changes envelope date */ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0, - (SCM MESG), - "Creates the copy of the message MESG.\n") + (SCM mesg), + "Creates a copy of the message @var{mesg}.\n") #define FUNC_NAME s_scm_mu_message_copy { mu_message_t msg, newmsg; @@ -199,14 +199,14 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0, size_t off, n; int status; - SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); - msg = mu_scm_message_get (MESG); + SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME); + msg = mu_scm_message_get (mesg); status = mu_message_get_stream (msg, &in); if (status) mu_scm_error (FUNC_NAME, status, "Cannot get input stream from message ~A", - scm_list_1 (MESG)); + scm_list_1 (mesg)); status = mu_message_create (&newmsg, NULL); if (status) @@ -250,44 +250,44 @@ SCM_DEFINE_PUBLIC (scm_mu_message_copy, "mu-message-copy", 1, 0, 0, #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_message_destroy, "mu-message-destroy", 1, 0, 0, - (SCM MESG), - "Destroys the message MESG.") + (SCM mesg), + "Destroys the message @var{mesg}.") #define FUNC_NAME s_scm_mu_message_destroy { struct mu_message *mum; - SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); - mum = (struct mu_message *) SCM_CDR (MESG); + SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME); + mum = (struct mu_message *) SCM_CDR (mesg); mu_message_destroy (&mum->msg, mu_message_get_owner (mum->msg)); return SCM_UNSPECIFIED; } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0, - (SCM MESG, SCM HEADER, SCM VALUE, SCM REPLACE), -"Sets new VALUE to the header HEADER of the message MESG.\n" -"If HEADER is already present in the message its value\n" -"is replaced with the suplied one iff the optional REPLACE is\n" -"#t. Otherwise, a new header is created and appended.") + (SCM mesg, SCM header, SCM value, SCM replace), +"Sets header @var{header} of the message @var{mesg} to new @var{value}.\n" +"If @var{header} is already present in the message, its value\n" +"is replaced with the suplied one iff the optional @var{replace} is\n" +"@code{#t}. Otherwise, a new header is created and appended.") #define FUNC_NAME s_scm_mu_message_set_header { mu_message_t msg; mu_header_t hdr; - int replace = 0; + int repl = 0; int status; char *hdr_c, *val_c; - SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); - msg = mu_scm_message_get (MESG); - SCM_ASSERT (scm_is_string (HEADER), HEADER, SCM_ARG2, FUNC_NAME); + SCM_ASSERT (mu_scm_is_message (mesg), mesg, SCM_ARG1, FUNC_NAME); + msg = mu_scm_message_get (mesg); + SCM_ASSERT (scm_is_string (header), header, SCM_ARG2, FUNC_NAME); - if (scm_is_bool (VALUE)) - return SCM_UNSPECIFIED; + if (scm_is_bool (value)) + return SCM_UNSPECIFIED;/*FIXME: Exception*/ - SCM_ASSERT (scm_is_string (VALUE), VALUE, SCM_ARG3, FUNC_NAME); - if (!SCM_UNBNDP (REPLACE)) + SCM_ASSERT (scm_is_string (value), value, SCM_ARG3, FUNC_NAME); + if (!SCM_UNBNDP (replace)) { - replace = REPLACE == SCM_BOOL_T; + repl = replace == SCM_BOOL_T; } status = mu_message_get_header (msg, &hdr); @@ -295,52 +295,52 @@ SCM_DEFINE_PUBLIC (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0, mu_scm_error (FUNC_NAME, status, "Cannot get message headers", SCM_BOOL_F); - hdr_c = scm_to_locale_string (HEADER); - val_c = scm_to_locale_string (VALUE); - status = mu_header_set_value (hdr, hdr_c, val_c, replace); + hdr_c = scm_to_locale_string (header); + val_c = scm_to_locale_string (value); + status = mu_header_set_value (hdr, hdr_c, val_c, repl); free (hdr_c); free (val_c); if (status) mu_scm_error (FUNC_NAME, status, "Cannot set header \"~A: ~A\" in message ~A", - scm_list_3 (HEADER, VALUE, MESG)); + scm_list_3 (header, value, mesg)); return SCM_UNSPECIFIED; } #undef FUNC_NAME SCM_DEFINE_PUBLIC (scm_mu_message_get_size, "mu-message-get-size", 1, 0, 0, - (SCM MESG), - "Returns the size of the message MESG\n.") + (SCM mesg), + "Returns size of the message @var{mesg}\n.") #define FUNC_NAME s_scm_mu_message_get_size { mu_message_t msg; size_t size; |