From 73f46bbd3b40d4f867601839a5f6aa8fb5a9c739 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 17 Mar 2015 22:21:32 +0000 Subject: [PATCH] tmpfile/mkstemp: Add all the other bits --- Library/include/stdio.h | 2 ++ Library/include/stdlib.h | 4 ++++ Library/libs/Makefile | 2 +- Library/libs/Makefile.6502 | 2 +- Library/libs/tmpfile.c | 11 +++++++++++ 5 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 Library/libs/tmpfile.c diff --git a/Library/include/stdio.h b/Library/include/stdio.h index 975f2199..82295396 100644 --- a/Library/include/stdio.h +++ b/Library/include/stdio.h @@ -109,6 +109,8 @@ extern FILE *__fopen __P((const char*, int, FILE*, const char*)); #define freopen(__file, __mode, __fp) __fopen((__file), -1, (__fp), (__mode)) #define fdopen(__file, __mode) __fopen((char*)0, (__file), (FILE*)0, (__mode)) +extern FILE *tmpfile __P((void)); + extern int fputs __P((const void *, FILE*)); extern int puts __P((const void *)); diff --git a/Library/include/stdlib.h b/Library/include/stdlib.h index afec743c..2dac44c0 100644 --- a/Library/include/stdlib.h +++ b/Library/include/stdlib.h @@ -51,6 +51,10 @@ extern char *__ltostr __P((long value, int radix)); extern long strtol __P ((const char * nptr, char ** endptr, int base)); extern unsigned long strtoul __P ((const char * nptr, char ** endptr, int base)); + +extern int mkstemp(char *template); +extern int mkstemps(char *template, int suffix); + #ifndef __HAS_NO_DOUBLES__ extern double strtod __P ((const char * nptr, char ** endptr)); #endif diff --git a/Library/libs/Makefile b/Library/libs/Makefile index dfa8855a..92b8b911 100644 --- a/Library/libs/Makefile +++ b/Library/libs/Makefile @@ -37,7 +37,7 @@ SRC_C += setlocale.c setvbuf.c settimeofday.c sleep.c sprintf.c SRC_C += stat.c stdio0.c stime.c SRC_C += strcasecmp.c strcasestr.c strdup.c stricmp.c strlcpy.c strncasecmp.c SRC_C += strnlen.c strnicmp.c strsep.c strxfrm.c strcoll.c -SRC_C += strtod.c strtol.c system.c time.c tmpnam.c ttyname.c +SRC_C += strtod.c strtol.c system.c time.c tmpfile.c tmpnam.c ttyname.c SRC_C += tzset.c ungetc.c utent.c utimes.c utsname.c SRC_C += vfprintf.c vprintf.c wait.c xitoa.c pathconf.c SRC_C += gethostname.c sysconf.c confstr.c memccpy.c getpass.c diff --git a/Library/libs/Makefile.6502 b/Library/libs/Makefile.6502 index 6484e1a8..76857023 100644 --- a/Library/libs/Makefile.6502 +++ b/Library/libs/Makefile.6502 @@ -51,7 +51,7 @@ SRC_C += setlocale.c setvbuf.c settimeofday.c sleep.c sprintf.c SRC_C += stat.c stdio0.c stime.c SRC_C += strcasecmp.c strcasestr.c strdup.c stricmp.c strlcpy.c strncasecmp.c SRC_C += strnicmp.c strnlen.c strsep.c -SRC_C += system.c time.c tmpnam.c ttyname.c +SRC_C += system.c time.c tmpfile.c tmpnam.c ttyname.c SRC_C += tzset.c ungetc.c utent.c utimes.c utsname.c SRC_C += vfprintf.c vprintf.c wait.c xitoa.c pathconf.c SRC_C += gethostname.c sysconf.c confstr.c memccpy.c getpass.c diff --git a/Library/libs/tmpfile.c b/Library/libs/tmpfile.c new file mode 100644 index 00000000..ca2da44e --- /dev/null +++ b/Library/libs/tmpfile.c @@ -0,0 +1,11 @@ +#include +#include + +FILE *tmpfile(void) +{ + int fd = mkstemp("/tmp/tmpfileXXXXXX"); + if (fd == -1) + return; + return fdopen(fd, "r+"); +} + -- 2.34.1