summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-04-01 19:32:09 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-04-01 19:33:55 +0300
commit85bc741c0fb1adace8527a7da8c91efa6432a4c6 (patch)
tree4537835e1cad7ead232605a0a906514974453afd
parent42f9e9d0e3c73059048934e385074d78a023e6e4 (diff)
downloadmailutils-85bc741c0fb1adace8527a7da8c91efa6432a4c6.tar.gz
mailutils-85bc741c0fb1adace8527a7da8c91efa6432a4c6.tar.bz2
Style fix.
* mailbox/attachment.c: Fix indentation.
-rw-r--r--mailbox/attachment.c130
1 files changed, 69 insertions, 61 deletions
diff --git a/mailbox/attachment.c b/mailbox/attachment.c
index 34332d4b6..349f281e1 100644
--- a/mailbox/attachment.c
+++ b/mailbox/attachment.c
@@ -66,7 +66,7 @@ struct _msg_info
int
mu_message_create_attachment (const char *content_type, const char *encoding,
- const char *filename, mu_message_t * newmsg)
+ const char *filename, mu_message_t *newmsg)
{
mu_header_t hdr;
mu_body_t body;
@@ -75,7 +75,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
int ret;
if (newmsg == NULL)
- return MU_ERR_OUT_PTR_NULL;
+ return MU_ERR_OUT_PTR_NULL;
if (filename == NULL)
return EINVAL;
@@ -101,19 +101,19 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
sprintf (header, MSG_HDR, content_type, name, encoding, name);
if ((ret =
mu_header_create (&hdr, header, strlen (header),
- *newmsg)) == 0)
+ *newmsg)) == 0)
{
mu_message_get_body (*newmsg, &body);
if ((ret =
mu_file_stream_create (&fstream, filename,
- MU_STREAM_READ)) == 0)
+ MU_STREAM_READ)) == 0)
{
if ((ret = mu_stream_open (fstream)) == 0)
{
if ((ret =
mu_filter_create (&tstream, fstream, encoding,
- MU_FILTER_ENCODE,
- MU_STREAM_READ)) == 0)
+ MU_FILTER_ENCODE,
+ MU_STREAM_READ)) == 0)
{
mu_body_set_stream (body, tstream, *newmsg);
mu_message_set_header (*newmsg, hdr, NULL);
@@ -121,7 +121,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
}
}
}
- free (header);
+ free (header);
}
}
}
@@ -142,7 +142,7 @@ mu_message_create_attachment (const char *content_type, const char *encoding,
static int
_attachment_setup (struct _msg_info **info, mu_message_t msg,
- mu_stream_t * stream, void **data)
+ mu_stream_t *stream, void **data)
{
int sfl, ret;
mu_body_t body;
@@ -192,7 +192,7 @@ _attachment_free (struct _msg_info *info, int free_message)
|| ((c) == ']') )
static char *
-_header_get_param (char *field_body, const char *param, size_t * len)
+_header_get_param (char *field_body, const char *param, size_t *len)
{
char *str, *p, *v, *e;
int quoted = 0, was_quoted = 0;
@@ -230,7 +230,7 @@ _header_get_param (char *field_body, const char *param, size_t * len)
}
int
-mu_message_aget_attachment_name(mu_message_t msg, char **name)
+mu_message_aget_attachment_name (mu_message_t msg, char **name)
{
size_t sz = 0;
int ret = 0;
@@ -238,16 +238,18 @@ mu_message_aget_attachment_name(mu_message_t msg, char **name)
if (name == NULL)
return MU_ERR_OUT_PTR_NULL;
- if((ret = mu_message_get_attachment_name(msg, NULL, 0, &sz)) != 0)
+ if ((ret = mu_message_get_attachment_name (msg, NULL, 0, &sz)) != 0)
return ret;
- *name = malloc(sz + 1);
-
- if((ret = mu_message_get_attachment_name(msg, *name, sz + 1, NULL)) != 0)
- {
- free(*name);
- *name = NULL;
- }
+ *name = malloc (sz + 1);
+ if (!*name)
+ return ENOMEM;
+
+ if ((ret = mu_message_get_attachment_name (msg, *name, sz + 1, NULL)) != 0)
+ {
+ free (*name);
+ *name = NULL;
+ }
return ret;
}
@@ -262,7 +264,7 @@ mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
char *name = NULL;
size_t namesz = 0;
- if(!msg)
+ if (!msg)
return ret;
if ((ret = mu_message_get_header (msg, &hdr)) != 0)
@@ -272,25 +274,25 @@ mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
/* If the header wasn't there, we'll fall back to Content-Type, but
other errors are fatal. */
- if(ret != 0 && ret != MU_ERR_NOENT)
+ if (ret != 0 && ret != MU_ERR_NOENT)
return ret;
- if(ret == 0 && value != NULL)
- {
- /* FIXME: this is cheezy, it should check the value of the
- Content-Disposition field, not strstr it. */
+ if (ret == 0 && value != NULL)
+ {
+ /* FIXME: this is cheezy, it should check the value of the
+ Content-Disposition field, not strstr it. */
if (strstr (value, "attachment") != NULL)
name = _header_get_param (value, "filename", &namesz);
- }
+ }
/* If we didn't get the name, we fall back on the Content-Type name
parameter. */
if (name == NULL)
{
- if(value)
- free(value);
+ if (value)
+ free (value);
ret = mu_header_aget_value (hdr, "Content-Type", &value);
name = _header_get_param (value, "name", &namesz);
@@ -302,11 +304,11 @@ mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
name[namesz] = '\0';
- if(sz)
+ if (sz)
*sz = namesz;
- if(buf)
- strncpy(buf, name, bufsz);
+ if (buf)
+ strncpy (buf, name, bufsz);
}
else
ret = MU_ERR_NOENT;
@@ -336,40 +338,40 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
if (ret == 0 && (ret = mu_message_get_header (msg, &hdr)) == 0)
{
if (filename == NULL)
- {
- ret = mu_message_aget_attachment_name (msg, &partname);
- if(partname)
- fname = partname;
- }
+ {
+ ret = mu_message_aget_attachment_name (msg, &partname);
+ if (partname)
+ fname = partname;
+ }
else
fname = filename;
if (fname
&& (ret =
mu_file_stream_create (&info->fstream, fname,
- MU_STREAM_WRITE | MU_STREAM_CREAT)) == 0)
+ MU_STREAM_WRITE | MU_STREAM_CREAT)) == 0)
{
if ((ret = mu_stream_open (info->fstream)) == 0)
{
- char *content_encoding;
+ char *content_encoding;
char *content_encoding_mem = NULL;
mu_header_get_value (hdr, "Content-Transfer-Encoding", NULL, 0,
- &size);
+ &size);
if (size)
{
content_encoding_mem = malloc (size + 1);
if (content_encoding_mem == NULL)
ret = ENOMEM;
- content_encoding = content_encoding_mem;
+ content_encoding = content_encoding_mem;
mu_header_get_value (hdr, "Content-Transfer-Encoding",
- content_encoding, size + 1, 0);
+ content_encoding, size + 1, 0);
}
else
content_encoding = "7bit";
ret =
mu_filter_create (&info->stream, istream, content_encoding,
- MU_FILTER_DECODE, MU_STREAM_READ);
- free (content_encoding_mem);
+ MU_FILTER_DECODE, MU_STREAM_READ);
+ free (content_encoding_mem);
}
}
}
@@ -381,15 +383,16 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
while ((ret == 0 && info->nbytes)
||
((ret =
- mu_stream_read (info->stream, info->buf, BUF_SIZE, info->ioffset,
- &info->nbytes)) == 0 && info->nbytes))
+ mu_stream_read (info->stream, info->buf, BUF_SIZE,
+ info->ioffset, &info->nbytes)) == 0
+ && info->nbytes))
{
info->ioffset += info->nbytes;
while (info->nbytes)
{
if ((ret =
mu_stream_write (info->fstream, info->buf, info->nbytes,
- info->ooffset, &nbytes)) != 0)
+ info->ooffset, &nbytes)) != 0)
break;
info->nbytes -= nbytes;
info->ooffset += nbytes;
@@ -412,7 +415,7 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
}
int
-mu_message_encapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
+mu_message_encapsulate (mu_message_t msg, mu_message_t *newmsg, void **data)
{
mu_stream_t istream, ostream;
const char *header;
@@ -429,12 +432,14 @@ mu_message_encapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
if ((ret = _attachment_setup (&info, msg, &ostream, data)) != 0)
return ret;
- if (info->msg == NULL && (ret = mu_message_create (&(info->msg), NULL)) == 0)
+ if (info->msg == NULL
+ && (ret = mu_message_create (&(info->msg), NULL)) == 0)
{
header =
"Content-Type: message/rfc822\nContent-Transfer-Encoding: 7bit\n\n";
if ((ret =
- mu_header_create (&(info->hdr), header, strlen (header), msg)) == 0)
+ mu_header_create (&(info->hdr), header, strlen (header),
+ msg)) == 0)
ret = mu_message_set_header (info->msg, info->hdr, NULL);
}
if (ret == 0 && (ret = mu_message_get_stream (msg, &istream)) == 0)
@@ -448,15 +453,16 @@ mu_message_encapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
while ((ret == 0 && info->nbytes)
||
((ret =
- mu_stream_read (istream, info->buf, BUF_SIZE, info->ioffset,
- &info->nbytes)) == 0 && info->nbytes))
+ mu_stream_read (istream, info->buf, BUF_SIZE,
+ info->ioffset, &info->nbytes)) == 0
+ && info->nbytes))
{
info->ioffset += info->nbytes;
while (info->nbytes)
{
if ((ret =
mu_stream_write (ostream, info->buf, info->nbytes,
- info->ooffset, &nbytes)) != 0)
+ info->ooffset, &nbytes)) != 0)
break;
info->nbytes -= nbytes;
info->ooffset += nbytes;
@@ -472,7 +478,8 @@ mu_message_encapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
}
int
-mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
+mu_message_unencapsulate (mu_message_t msg, mu_message_t *newmsg,
+ void **data)
{
size_t size, nbytes;
int ret = 0;
@@ -491,14 +498,16 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
mu_header_get_value (hdr, "Content-Type", NULL, 0, &size);
if (size)
{
- char *content_type;
+ char *content_type;
if ((content_type = malloc (size + 1)) == NULL)
return ENOMEM;
- mu_header_get_value (hdr, "Content-Type", content_type, size + 1, 0);
- ret = mu_c_strncasecmp (content_type, "message/rfc822",
- strlen ("message/rfc822"));
- free (content_type);
- if (ret != 0)
+ mu_header_get_value (hdr, "Content-Type", content_type, size + 1,
+ 0);
+ ret =
+ mu_c_strncasecmp (content_type, "message/rfc822",
+ strlen ("message/rfc822"));
+ free (content_type);
+ if (ret != 0)
return EINVAL;
}
else
@@ -518,14 +527,14 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
||
((ret =
mu_stream_read (istream, info->buf, BUF_SIZE, info->ioffset,
- &info->nbytes)) == 0 && info->nbytes))
+ &info->nbytes)) == 0 && info->nbytes))
{
info->ioffset += info->nbytes;
while (info->nbytes)
{
if ((ret =
mu_stream_write (ostream, info->buf, info->nbytes,
- info->ooffset, &nbytes)) != 0)
+ info->ooffset, &nbytes)) != 0)
break;
info->nbytes -= nbytes;
info->ooffset += nbytes;
@@ -538,4 +547,3 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
_attachment_free (info, ret);
return ret;
}
-

Return to:

Send suggestions and report system problems to the System administrator.