X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=platform%2Fposix%2Ffunctions%2Fstdio%2Ftmpfile.c;h=07b18ceec9bd769f751ea48eed38a7f194b79ad4;hp=deb992ccbc80e2133e6eb1a102823ba838c06784;hb=da0f3f353d417fed71f358a48d5d5394145e460d;hpb=1aba8d4e33b2a020709f81182709c7de7a728c76 diff --git a/platform/posix/functions/stdio/tmpfile.c b/platform/posix/functions/stdio/tmpfile.c index deb992c..07b18ce 100644 --- a/platform/posix/functions/stdio/tmpfile.c +++ b/platform/posix/functions/stdio/tmpfile.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /* tmpfile( void ) This file is part of the Public Domain C Library (PDCLib). @@ -13,13 +11,15 @@ #include #include #include - -#include <_PDCLIB_glue.h> - -#include -#include -#include +#include "_PDCLIB_glue.h" #include +#ifdef __linux__ +/* get O_CLOEXEC without sys/types.h being awful */ +#include +int open(const char *fname, int flags, ...); +#else +#include +#endif extern const _PDCLIB_fileops_t _PDCLIB_fileops; @@ -52,7 +52,7 @@ FILE* _PDCLIB_nothrow tmpfile( void ) (file might exist but not readable). Replace with something more appropriate. */ - fd = open( filename, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR ); + fd = open( filename, O_CREAT | O_EXCL | O_RDWR, 0600 ); if ( fd != -1 ) { break; @@ -61,9 +61,9 @@ FILE* _PDCLIB_nothrow tmpfile( void ) close( urandom ); FILE* rc = _PDCLIB_fvopen(((_PDCLIB_fd_t){ .sval = fd}), &_PDCLIB_fileops, - _PDCLIB_FWRITE | _PDCLIB_FRW | + _PDCLIB_FWRITE | _PDCLIB_FRW | _PDCLIB_DELONCLOSE, filename); - if( rc == NULL ) + if( rc == NULL ) { close( fd ); return NULL; @@ -75,7 +75,7 @@ FILE* _PDCLIB_nothrow tmpfile( void ) #endif #ifdef TEST -#include <_PDCLIB_test.h> +#include "_PDCLIB_test.h" #include int main( void )