Check for mkstemp, added a port implementation if it is not
present. Use mkstemp() in various places needing tmp files.
This commit is contained in:
parent
6ecade7c84
commit
786d24903b
|
@ -11197,6 +11197,7 @@ fi
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for ac_func in \
|
||||
|
@ -11226,6 +11227,7 @@ for ac_func in \
|
|||
lseek64 \
|
||||
lstat \
|
||||
memmove \
|
||||
mkstemp \
|
||||
mmap \
|
||||
pclose \
|
||||
popen \
|
||||
|
|
|
@ -879,6 +879,7 @@ AC_CHECK_FUNCS(\
|
|||
lseek64 \
|
||||
lstat \
|
||||
memmove \
|
||||
mkstemp \
|
||||
mmap \
|
||||
pclose \
|
||||
popen \
|
||||
|
|
|
@ -1812,11 +1812,15 @@ static BOOL gdb_startup(struct gdb_context* gdbctx, DEBUG_EVENT* de, unsigned fl
|
|||
case 0: /* in child... and alive */
|
||||
{
|
||||
char buf[MAX_PATH];
|
||||
int fd;
|
||||
char* gdb_path;
|
||||
FILE* f;
|
||||
|
||||
if (!(gdb_path = getenv("WINE_GDB"))) gdb_path = "gdb";
|
||||
if (!tmpnam(buf) || (f = fopen(buf, "w+")) == NULL) return FALSE;
|
||||
strcpy(buf,"/tmp/winegdb.XXXXXX");
|
||||
fd = mkstemp(buf);
|
||||
if (fd == -1) return FALSE;
|
||||
if ((f = fdopen(fd, "w+")) == NULL) return FALSE;
|
||||
fprintf(f, "file %s\n", wine_path);
|
||||
fprintf(f, "target remote localhost:%d\n", ntohs(s_addr.sin_port));
|
||||
fprintf(f, "monitor trace=0\n");
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
# include <sys/wait.h>
|
||||
#endif
|
||||
#include "wine/debug.h"
|
||||
#include "wine/port.h"
|
||||
#include "winerror.h"
|
||||
#include "winbase.h"
|
||||
#include "winnls.h"
|
||||
|
@ -551,8 +552,15 @@ static BOOL create_default_icon( const char *filename )
|
|||
/* extract an icon from an exe or icon file; helper for IPersistFile_fnSave */
|
||||
static char *extract_icon( const char *path, int index)
|
||||
{
|
||||
int nodefault = 1;
|
||||
char *filename = heap_strdup( tmpnam(NULL) );
|
||||
int fd, nodefault = 1;
|
||||
char *filename, tmpfn[25];
|
||||
|
||||
strcpy(tmpfn,"/tmp/icon.XXXXXX");
|
||||
fd = mkstemp( tmpfn );
|
||||
if (fd == -1)
|
||||
return NULL;
|
||||
filename = heap_strdup( tmpfn );
|
||||
close(fd); /* not needed */
|
||||
|
||||
/* If icon path begins with a '*' then this is a deferred call */
|
||||
if (path[0] == '*')
|
||||
|
|
|
@ -290,6 +290,9 @@
|
|||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `mkstemp' function. */
|
||||
#undef HAVE_MKSTEMP
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
|
|
|
@ -222,6 +222,10 @@ unsigned long inet_network(const char *cp);
|
|||
int lstat(const char *file_name, struct stat *buf);
|
||||
#endif /* HAVE_LSTAT */
|
||||
|
||||
#ifndef HAVE_MKSTEMP
|
||||
int mkstemp(char *tmpfn);
|
||||
#endif /* HAVE_MKSTEMP */
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
void *memmove(void *dest, const void *src, unsigned int len);
|
||||
#endif /* !defined(HAVE_MEMMOVE) */
|
||||
|
|
|
@ -340,6 +340,35 @@ int lstat(const char *file_name, struct stat *buf)
|
|||
}
|
||||
#endif /* HAVE_LSTAT */
|
||||
|
||||
/***********************************************************************
|
||||
* mkstemp
|
||||
*/
|
||||
#ifndef HAVE_MKSTEMP
|
||||
int mkstemp(char *tmpfn)
|
||||
{
|
||||
int tries;
|
||||
char *xstart;
|
||||
|
||||
xstart = tmpfn+strlen(tmpfn)-1;
|
||||
while ((xstart > tmpfn) && (*xstart == 'X'))
|
||||
xstart--;
|
||||
tries = 10;
|
||||
while (tries--) {
|
||||
char *newfn = mktemp(tmpfn);
|
||||
int fd;
|
||||
if (!newfn) /* something else broke horribly */
|
||||
return -1;
|
||||
fd = open(newfn,O_CREAT|O_RDWR|O_EXCL,0600);
|
||||
if (fd!=-1)
|
||||
return fd;
|
||||
newfn = xstart;
|
||||
/* fill up with X and try again ... */
|
||||
while (*newfn) *newfn++ = 'X';
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif /* HAVE_MKSTEMP */
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* pread
|
||||
|
|
|
@ -230,24 +230,17 @@ int get_file_drive_type( struct file *file )
|
|||
/* Create an anonymous Unix file */
|
||||
int create_anonymous_file(void)
|
||||
{
|
||||
char *name;
|
||||
char tmpfn[21];
|
||||
int fd;
|
||||
|
||||
do
|
||||
{
|
||||
if (!(name = tmpnam(NULL)))
|
||||
{
|
||||
set_error( STATUS_TOO_MANY_OPENED_FILES );
|
||||
return -1;
|
||||
}
|
||||
fd = open( name, O_CREAT | O_EXCL | O_RDWR, 0600 );
|
||||
} while ((fd == -1) && (errno == EEXIST));
|
||||
sprintf(tmpfn,"/tmp/anonmap.XXXXXX");
|
||||
fd = mkstemp(tmpfn);
|
||||
if (fd == -1)
|
||||
{
|
||||
file_set_error();
|
||||
return -1;
|
||||
}
|
||||
unlink( name );
|
||||
unlink( tmpfn );
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -109,20 +112,22 @@ int wpp_parse( const char *input, FILE *output )
|
|||
/* parse into a temporary file */
|
||||
int wpp_parse_temp( const char *input, char **output_name )
|
||||
{
|
||||
char *temp_name;
|
||||
FILE *output;
|
||||
int ret;
|
||||
int ret, fd;
|
||||
char tmpfn[20], *temp_name;
|
||||
|
||||
if(!(temp_name = tmpnam(NULL)))
|
||||
strcpy(tmpfn,"/tmp/wpp.XXXXXX");
|
||||
|
||||
if((fd = mkstemp(tmpfn)) == -1)
|
||||
{
|
||||
fprintf(stderr, "Could not generate a temp-name\n");
|
||||
exit(2);
|
||||
}
|
||||
temp_name = pp_xstrdup(temp_name);
|
||||
temp_name = pp_xstrdup(tmpfn);
|
||||
|
||||
if (!(output = fopen(temp_name, "wt")))
|
||||
if (!(output = fdopen(fd, "wt")))
|
||||
{
|
||||
fprintf(stderr,"Could not open %s for writing\n", temp_name);
|
||||
fprintf(stderr,"Could not open fd %s for writing\n", temp_name);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue