50 |
#include <mailutils/header.h> |
#include <mailutils/header.h> |
51 |
#include <mailutils/attribute.h> |
#include <mailutils/attribute.h> |
52 |
#include <mailutils/error.h> |
#include <mailutils/error.h> |
53 |
|
#include <mailutils/mutil.h> |
54 |
#include <registrar0.h> |
#include <registrar0.h> |
55 |
#include <mailbox0.h> |
#include <mailbox0.h> |
56 |
|
|
448 |
static FILE * |
static FILE * |
449 |
_mh_tempfile(struct _mh_data *mhd, char **namep) |
_mh_tempfile(struct _mh_data *mhd, char **namep) |
450 |
{ |
{ |
451 |
char *filename; |
int fd = mu_tempfile (mhd->name, namep); |
|
int fd; |
|
|
|
|
|
filename = malloc (strlen (mhd->name) + /*'/'*/1 + /* "muXXXXXX" */8 + 1); |
|
|
if (!filename) |
|
|
return NULL; |
|
|
sprintf (filename, "%s/muXXXXXX", mhd->name); |
|
|
|
|
|
#ifdef HAVE_MKSTEMP |
|
|
{ |
|
|
int save_mask = umask (077); |
|
|
fd = mkstemp (filename); |
|
|
umask (save_mask); |
|
|
} |
|
|
#else |
|
|
if (mktemp (filename)) |
|
|
fd = open (filename, O_CREAT|O_EXCL|O_RDWR, 0600); |
|
|
else |
|
|
fd = -1; |
|
|
#endif |
|
|
|
|
452 |
if (fd == -1) |
if (fd == -1) |
|
{ |
|
|
free (filename); |
|
453 |
return NULL; |
return NULL; |
|
} |
|
|
|
|
|
*namep = filename; |
|
454 |
return fdopen (fd, "w"); |
return fdopen (fd, "w"); |
455 |
} |
} |
456 |
|
|