summaryrefslogtreecommitdiff
path: root/mailbox
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2007-07-05 20:02:22 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2007-07-05 20:02:22 +0000
commit0fd294c05edfabd567056c78d8a191d4d117c5c8 (patch)
tree464c373f4cda21fc91af7e7fdfe2403e3df0bc98 /mailbox
parentcf831892e4500bba6cb34019f5ba295fcdefc8f5 (diff)
downloadmailutils-0fd294c05edfabd567056c78d8a191d4d117c5c8.tar.gz
mailutils-0fd294c05edfabd567056c78d8a191d4d117c5c8.tar.bz2
use mu_url_sget or mu_url_aget accessors
Diffstat (limited to 'mailbox')
-rw-r--r--mailbox/amd.c13
-rw-r--r--mailbox/sendmail.c7
-rw-r--r--mailbox/smtp.c17
-rw-r--r--mailbox/wicket.c60
4 files changed, 34 insertions, 63 deletions
diff --git a/mailbox/amd.c b/mailbox/amd.c
index 75e74ee57..67a9f34e4 100644
--- a/mailbox/amd.c
+++ b/mailbox/amd.c
@@ -242,10 +242,11 @@ amd_array_shrink (struct _amd_data *amd, size_t index)
int
-amd_init_mailbox (mu_mailbox_t mailbox, size_t amd_size, struct _amd_data **pamd)
+amd_init_mailbox (mu_mailbox_t mailbox, size_t amd_size,
+ struct _amd_data **pamd)
{
+ int status;
struct _amd_data *amd;
- size_t name_len;
if (mailbox == NULL)
return MU_ERR_MBX_NULL;
@@ -259,15 +260,13 @@ amd_init_mailbox (mu_mailbox_t mailbox, size_t amd_size, struct _amd_data **pamd
/* Back pointer. */
amd->mailbox = mailbox;
- mu_url_get_path (mailbox->url, NULL, 0, &name_len);
- amd->name = calloc (name_len + 1, sizeof (char));
- if (amd->name == NULL)
+ status = mu_url_aget_path (mailbox->url, &amd->name);
+ if (status)
{
free (amd);
mailbox->data = NULL;
- return ENOMEM;
+ return status;
}
- mu_url_get_path (mailbox->url, amd->name, name_len + 1, NULL);
/* Overloading the defaults. */
mailbox->_destroy = amd_destroy;
diff --git a/mailbox/sendmail.c b/mailbox/sendmail.c
index 62fb6bfb2..75308461d 100644
--- a/mailbox/sendmail.c
+++ b/mailbox/sendmail.c
@@ -125,7 +125,6 @@ sendmail_open (mu_mailer_t mailer, int flags)
{
sendmail_t sendmail = mailer->data;
int status;
- size_t pathlen = 0;
char *path;
/* Sanity checks. */
@@ -134,13 +133,9 @@ sendmail_open (mu_mailer_t mailer, int flags)
mailer->flags = flags;
- if ((status = mu_url_get_path (mailer->url, NULL, 0, &pathlen)) != 0
- || pathlen == 0)
+ if ((status = mu_url_aget_path (mailer->url, &path)))
return status;
- path = calloc (pathlen + 1, sizeof (char));
- mu_url_get_path (mailer->url, path, pathlen + 1, NULL);
-
if (access (path, X_OK) == -1)
{
free (path);
diff --git a/mailbox/smtp.c b/mailbox/smtp.c
index 06697ffa5..4fe4f9aa1 100644
--- a/mailbox/smtp.c
+++ b/mailbox/smtp.c
@@ -297,7 +297,6 @@ smtp_open (mu_mailer_t mailer, int flags)
smtp_t smtp = mailer->data;
int status;
long port;
- size_t buf_len = 0;
/* Sanity checks. */
if (!smtp)
@@ -305,27 +304,21 @@ smtp_open (mu_mailer_t mailer, int flags)
mailer->flags = flags;
- /* Fetch the mailer server name and the port in the mu_url_t. */
- if ((status = mu_url_get_host (mailer->url, NULL, 0, &buf_len)) != 0
- || buf_len == 0 || (status = mu_url_get_port (mailer->url, &port)) != 0)
- return status;
+ if ((status = mu_url_get_port (mailer->url, &port)) != 0)
+ return status;
switch (smtp->state)
{
case SMTP_NO_STATE:
- /* Set up the mailer, open the stream, etc. */
- /* Get the mailhost. */
if (smtp->mailhost)
{
free (smtp->mailhost);
smtp->mailhost = NULL;
}
- smtp->mailhost = calloc (buf_len + 1, sizeof (char));
-
- if (smtp->mailhost == NULL)
- return ENOMEM;
- mu_url_get_host (mailer->url, smtp->mailhost, buf_len + 1, NULL);
+ /* Fetch the mailer server name and the port in the mu_url_t. */
+ if ((status = mu_url_aget_host (mailer->url, &smtp->mailhost)) != 0)
+ return status;
if (smtp->localhost)
{
diff --git a/mailbox/wicket.c b/mailbox/wicket.c
index 0d88f7921..21e01c7dd 100644
--- a/mailbox/wicket.c
+++ b/mailbox/wicket.c
@@ -378,35 +378,27 @@ static int
get_user (mu_url_t url, const char *filename, char **user)
{
char *u = 0;
+ int status;
if (url)
{
- size_t n = 0;
- mu_url_get_user (url, NULL, 0, &n);
-
- if (n)
- {
- u = calloc (1, n + 1);
- mu_url_get_user (url, u, n + 1, NULL);
- }
+ status = mu_url_aget_user (url, &u);
+ if (status && status != MU_ERR_NOENT)
+ return status;
}
+
if (!u && filename)
{
mu_url_t ticket = 0;
- int e = get_ticket (url, NULL, filename, &ticket);
- if (e)
- return e;
+ status = get_ticket (url, NULL, filename, &ticket);
+ if (status)
+ return status;
if (ticket)
{
- size_t n = 0;
- mu_url_get_user (ticket, NULL, 0, &n);
-
- if (n)
- {
- u = calloc (1, n + 1);
- mu_url_get_user (ticket, u, n + 1, NULL);
- }
+ status = mu_url_aget_user (ticket, &u);
+ if (status && status != MU_ERR_NOENT)
+ return status;
mu_url_destroy (&ticket);
}
}
@@ -428,36 +420,28 @@ get_user (mu_url_t url, const char *filename, char **user)
static int
get_pass (mu_url_t url, const char *user, const char *filename, char **pass)
{
+ int status;
char *u = 0;
if (url)
{
- size_t n = 0;
- mu_url_get_passwd (url, NULL, 0, &n);
-
- if (n)
- {
- u = calloc (1, n + 1);
- mu_url_get_passwd (url, u, n + 1, NULL);
- }
+ status = mu_url_aget_passwd (url, &u);
+ if (status && status != MU_ERR_NOENT)
+ return status;
}
+
if (!u && filename)
{
mu_url_t ticket = 0;
- int e = get_ticket (url, user, filename, &ticket);
- if (e)
- return e;
+ status = get_ticket (url, user, filename, &ticket);
+ if (status)
+ return status;
if (ticket)
{
- size_t n = 0;
- mu_url_get_passwd (ticket, NULL, 0, &n);
-
- if (n)
- {
- u = calloc (1, n + 1);
- mu_url_get_passwd (ticket, u, n + 1, NULL);
- }
+ status = mu_url_aget_passwd (ticket, &u);
+ if (status && status != MU_ERR_NOENT)
+ return status;
mu_url_destroy (&ticket);
}
}

Return to:

Send suggestions and report system problems to the System administrator.