- add mkstemp replacement function and S_I???? defines when not present

This commit is contained in:
Christophe Bothamy 2003-05-06 20:28:13 +00:00
parent a547dd8703
commit 758b28c9f8
2 changed files with 30 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: osdep.cc,v 1.13 2003-03-11 17:30:20 vruppert Exp $
// $Id: osdep.cc,v 1.14 2003-05-06 20:28:12 cbothamy Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -235,6 +235,18 @@ char *bx_strrev(char *str)
}
#endif /* !BX_HAVE_STRREV */
#if !BX_HAVE_MKSTEMP
int bx_mkstemp(char *tpl)
{
mktemp(tpl);
return ::open(tpl, O_RDWR | O_CREAT | O_TRUNC
# ifdef O_BINARY
| O_BINARY
# endif
, S_IWUSR | S_IRUSR | S_IRGRP | S_IWGRP);
}
#endif // !BX_HAVE_MKSTEMP
//////////////////////////////////////////////////////////////////////
// Missing library functions, implemented for MacOS only
//////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: osdep.h,v 1.15 2003-01-10 22:32:46 cbothamy Exp $
// $Id: osdep.h,v 1.16 2003-05-06 20:28:13 cbothamy Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -62,8 +62,19 @@ extern "C" {
// win32 has snprintf though with different name.
#define snprintf _snprintf
#endif /* ifnndef __MINGW32__ */
#endif /* WIN32 */
// Missing defines for open
#ifndef S_IRUSR
#define S_IRUSR 0400
#define S_IWUSR 0200
#define S_IRGRP 0040
#define S_IWGRP 0020
#define S_IROTH 0004
#define S_IWOTH 0002
#endif /* S_IRUSR */
//////////////////////////////////////////////////////////////////////
// Missing library functions.
// These should work on any platform that needs them.
@ -107,6 +118,11 @@ extern "C" {
typedef int socklen_t;
#endif
#if !BX_HAVE_MKSTEMP
#define mkstemp bx_mkstemp
extern int bx_mkstemp(char *tpl);
#endif
//////////////////////////////////////////////////////////////////////
// Missing library functions, implemented for MacOS only
//////////////////////////////////////////////////////////////////////