Commit 9df63866 9df638667be69868851e0882eb172b1476ff962d by Sergey Poznyakoff

Remove obsolete function.

* include/mailutils/body.h (mu_body_get_filename): Remove proto.
* include/mailutils/sys/body.h (_mu_body) <filename>: Remove.
* libmailutils/mailbox/body.c (mu_body_get_filename): Remove
obsolete function.
(_body_get_stream): Use mu_temp_file_stream_create.
* libmailutils/stream/temp_file_stream.c (mu_temp_file_stream_create):
Return EINVAL if flags is set, but hints is NULL.
* libmu_scm/mu_body.c (mu_scm_body_print): Don't use mu_body_get_filename.
1 parent bf613ed8
......@@ -39,8 +39,6 @@ extern int mu_body_set_get_stream (mu_body_t,
int (*) (mu_body_t, mu_stream_t *),
void *owner);
extern int mu_body_get_filename (mu_body_t, char *, size_t, size_t *);
extern int mu_body_size (mu_body_t, size_t *);
extern int mu_body_set_size (mu_body_t,
int (*_size) (mu_body_t, size_t*), void *owner);
......
......@@ -32,7 +32,6 @@ extern "C" {
struct _mu_body
{
void *owner;
char *filename;
mu_stream_t stream;
mu_stream_t fstream;
int flags;
......
......@@ -79,13 +79,6 @@ mu_body_destroy (mu_body_t *pbody, void *owner)
mu_body_t body = *pbody;
if (body->owner == owner)
{
if (body->filename)
{
/* FIXME: should we do this? */
remove (body->filename);
free (body->filename);
}
if (body->stream)
mu_stream_destroy (&body->stream);
......@@ -123,26 +116,6 @@ mu_body_clear_modified (mu_body_t body)
return 0;
}
int
mu_body_get_filename (mu_body_t body, char *filename, size_t len, size_t *pn)
{
int n = 0;
if (body == NULL)
return EINVAL;
if (body->filename)
{
n = strlen (body->filename);
if (filename && len > 0)
{
len--; /* Space for the null. */
strncpy (filename, body->filename, len)[len] = '\0';
}
}
if (pn)
*pn = n;
return 0;
}
struct _mu_body_stream
{
......@@ -177,9 +150,8 @@ _body_get_stream (mu_body_t body, mu_stream_t *pstream, int ref)
return ENOMEM;
/* Create the temporary file. */
body->filename = mu_tempname (NULL);
status = mu_file_stream_create (&body->fstream,
body->filename, MU_STREAM_RDWR);
status = mu_temp_file_stream_create (&body->fstream, NULL, 0);
if (status != 0)
return status;
mu_stream_set_buffer (body->fstream, mu_buffer_full, 0);
......
......@@ -59,6 +59,9 @@ mu_temp_file_stream_create (mu_stream_t *pstream,
int rc;
struct _mu_file_stream *str;
mu_stream_t stream;
if (flags && !hints)
return EINVAL;
rc = _mu_file_stream_create (&str,
sizeof (struct _mu_temp_file_stream),
NULL,
......
......@@ -55,18 +55,13 @@ static int
mu_scm_body_print (SCM body_smob, SCM port, scm_print_state * pstate)
{
struct mu_body *mbp = (struct mu_body *) SCM_CDR (body_smob);
size_t b_size = 0, b_lines = 0, len = 0;
size_t b_size = 0, b_lines = 0;
char buffer[512];
mu_body_size (mbp->body, &b_size);
mu_body_lines (mbp->body, &b_lines);
buffer[0] = 0;
mu_body_get_filename (mbp->body, buffer, sizeof (buffer), &len);
scm_puts ("#<body \"", port);
scm_puts (buffer, port);
scm_puts ("\" ", port);
scm_puts ("#<body ", port);
snprintf (buffer, sizeof (buffer), "%3lu %-5lu",
(unsigned long) b_lines, (unsigned long) b_size);
scm_puts (buffer, port);
......