34 |
|
|
35 |
#define BODY_MODIFIED 0x10000 |
#define BODY_MODIFIED 0x10000 |
36 |
|
|
|
static int lazy_create __P ((body_t)); |
|
37 |
static int _body_flush __P ((stream_t)); |
static int _body_flush __P ((stream_t)); |
38 |
static int _body_get_fd __P ((stream_t, int *)); |
static int _body_get_fd __P ((stream_t, int *)); |
39 |
static int _body_read __P ((stream_t, char *, size_t, off_t, size_t *)); |
static int _body_read __P ((stream_t, char *, size_t, off_t, size_t *)); |
146 |
|
|
147 |
if (body->stream == NULL) |
if (body->stream == NULL) |
148 |
{ |
{ |
|
int fd; |
|
149 |
int status = stream_create (&body->stream, MU_STREAM_RDWR, body); |
int status = stream_create (&body->stream, MU_STREAM_RDWR, body); |
150 |
if (status != 0) |
if (status != 0) |
151 |
return status; |
return status; |
152 |
/* Create the temporary file. */ |
/* Create the temporary file. */ |
153 |
fd = lazy_create (body); |
body->filename = mu_tempname (NULL); |
154 |
if (fd == -1) |
status = file_stream_create (&body->fstream, |
155 |
return errno; |
body->filename, MU_STREAM_RDWR); |
|
status = file_stream_create (&body->fstream, body->filename, MU_STREAM_RDWR); |
|
156 |
if (status != 0) |
if (status != 0) |
157 |
return status; |
return status; |
158 |
status = stream_open (body->fstream); |
status = stream_open (body->fstream); |
|
close (fd); |
|
159 |
if (status != 0) |
if (status != 0) |
160 |
return status; |
return status; |
161 |
stream_set_fd (body->stream, _body_get_fd, body); |
stream_set_fd (body->stream, _body_get_fd, body); |
336 |
return status; |
return status; |
337 |
} |
} |
338 |
|
|
|
#ifndef P_tmpdir |
|
|
# define P_tmpdir "/tmp" |
|
|
#endif |
|
|
|
|
339 |
static int |
static int |
340 |
lazy_create (body_t body) |
lazy_create (body_t body) |
341 |
{ |
{ |