Commit 85bc741c 85bc741c0fb1adace8527a7da8c91efa6432a4c6 by Sergey Poznyakoff

Style fix.

* mailbox/attachment.c: Fix indentation.
1 parent 42f9e9d0
......@@ -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;
......@@ -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,14 +238,16 @@ 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);
*name = malloc (sz + 1);
if (!*name)
return ENOMEM;
if((ret = mu_message_get_attachment_name(msg, *name, sz + 1, NULL)) != 0)
if ((ret = mu_message_get_attachment_name (msg, *name, sz + 1, NULL)) != 0)
{
free(*name);
free (*name);
*name = NULL;
}
......@@ -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,10 +274,10 @@ 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)
if (ret == 0 && value != NULL)
{
/* FIXME: this is cheezy, it should check the value of the
Content-Disposition field, not strstr it. */
......@@ -289,8 +291,8 @@ mu_message_get_attachment_name (mu_message_t msg, char *buf, size_t bufsz,
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;
......@@ -338,7 +340,7 @@ mu_message_save_attachment (mu_message_t msg, const char *filename,
if (filename == NULL)
{
ret = mu_message_aget_attachment_name (msg, &partname);
if(partname)
if (partname)
fname = partname;
}
else
......@@ -381,8 +383,9 @@ 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)
......@@ -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,8 +453,9 @@ 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)
......@@ -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;
......@@ -494,8 +501,10 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
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",
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)
......@@ -538,4 +547,3 @@ mu_message_unencapsulate (mu_message_t msg, mu_message_t * newmsg, void **data)
_attachment_free (info, ret);
return ret;
}
......