2019-12-13 20:50:50 +01:00
|
|
|
diff -uNr ./usr.old/include/stdio.h ./usr/include/stdio.h
|
|
|
|
--- ./usr.old/include/stdio.h 2019-05-22 12:49:28.000000000 +0300
|
|
|
|
+++ ./usr/include/stdio.h 2019-12-13 21:50:02.765565736 +0200
|
2019-02-08 13:28:08 +01:00
|
|
|
@@ -44,11 +44,12 @@
|
2017-06-18 20:57:16 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
+#include <string.h> /* For strcpy(3) used by ctermid() */
|
|
|
|
+#include <asm/fcntl.h> /* For O_RDWR and other O_* constants */
|
|
|
|
+
|
2017-11-15 16:48:35 +01:00
|
|
|
#include <bits/seek_constants.h>
|
2017-06-18 20:57:16 +02:00
|
|
|
|
2019-02-08 13:28:08 +01:00
|
|
|
-#if __ANDROID_API__ < __ANDROID_API_N__
|
|
|
|
#include <bits/struct_file.h>
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
|
|
|
@@ -165,7 +166,7 @@
|
|
|
|
__printflike(2, 0) __warnattr_strict("vsprintf is often misused; please use vsnprintf");
|
2017-11-15 16:48:35 +01:00
|
|
|
char* tmpnam(char* __s)
|
2017-06-18 20:57:16 +02:00
|
|
|
__warnattr("tempnam is unsafe, use mkstemp or tmpfile instead");
|
|
|
|
-#define P_tmpdir "/tmp/" /* deprecated */
|
|
|
|
+#define P_tmpdir "@TERMUX_PREFIX@/tmp/" /* deprecated */
|
2017-11-15 16:48:35 +01:00
|
|
|
char* tempnam(const char* __dir, const char* __prefix)
|
2017-06-18 20:57:16 +02:00
|
|
|
__warnattr("tempnam is unsafe, use mkstemp or tmpfile instead");
|
|
|
|
|
2019-02-08 13:28:08 +01:00
|
|
|
@@ -241,8 +242,6 @@
|
2017-11-15 16:48:35 +01:00
|
|
|
FILE* freopen64(const char* __path, const char* __mode, FILE* __fp) __INTRODUCED_IN(24);
|
2017-06-18 20:57:16 +02:00
|
|
|
#endif /* __ANDROID_API__ >= 24 */
|
|
|
|
|
|
|
|
-FILE* tmpfile(void);
|
|
|
|
-
|
|
|
|
#if __ANDROID_API__ >= 24
|
|
|
|
FILE* tmpfile64(void) __INTRODUCED_IN(24);
|
|
|
|
#endif /* __ANDROID_API__ >= 24 */
|
2019-02-08 13:28:08 +01:00
|
|
|
@@ -256,10 +255,15 @@
|
2017-06-18 20:57:16 +02:00
|
|
|
|
|
|
|
#define L_ctermid 1024 /* size for ctermid() */
|
|
|
|
|
|
|
|
-#if __ANDROID_API__ >= 26
|
2017-11-15 16:48:35 +01:00
|
|
|
-char* ctermid(char* __buf) __INTRODUCED_IN(26);
|
2017-06-18 20:57:16 +02:00
|
|
|
-#endif /* __ANDROID_API__ >= 26 */
|
2017-11-15 16:48:35 +01:00
|
|
|
+/* Needed by gnulibs freading(). */
|
2017-06-18 20:57:16 +02:00
|
|
|
+#define __sferror(p) (((p)->_flags & __SERR) != 0)
|
|
|
|
|
2017-11-15 16:48:35 +01:00
|
|
|
+/* Used by perl, fish, and others. */
|
2017-06-18 20:57:16 +02:00
|
|
|
+static __inline__ char* ctermid(char* s) {
|
2017-11-15 16:48:35 +01:00
|
|
|
+ if (s == 0) return (char*) "/dev/tty";
|
|
|
|
+ strcpy(s, "/dev/tty");
|
|
|
|
+ return s;
|
2017-06-18 20:57:16 +02:00
|
|
|
+}
|
|
|
|
|
2017-11-15 16:48:35 +01:00
|
|
|
FILE* fdopen(int __fd, const char* __mode);
|
|
|
|
int fileno(FILE* __fp);
|
2019-12-13 20:50:50 +01:00
|
|
|
@@ -328,6 +332,30 @@
|
2017-11-15 16:48:35 +01:00
|
|
|
#include <bits/fortify/stdio.h>
|
|
|
|
#endif
|
2017-06-18 20:57:16 +02:00
|
|
|
|
2018-05-27 14:55:20 +02:00
|
|
|
+int open(const char*, int, ...);
|
2017-06-18 20:57:16 +02:00
|
|
|
+extern pid_t getpid();
|
|
|
|
+extern int unlink(const char*);
|
|
|
|
+void free(void* p);
|
|
|
|
+uint32_t arc4random(void);
|
|
|
|
+static __inline__ FILE* tmpfile() {
|
|
|
|
+ int p = getpid();
|
|
|
|
+ char* path;
|
|
|
|
+ int i;
|
|
|
|
+ for (i = 0; i < 100; i++) {
|
|
|
|
+ unsigned int r = arc4random();
|
2017-07-07 03:29:49 +02:00
|
|
|
+ if (asprintf(&path, "@TERMUX_PREFIX@/tmp/tmpfile.%d-%u", p, r) == -1) return NULL;
|
2017-06-18 20:57:16 +02:00
|
|
|
+ int fd = open(path, O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE, 0600);
|
|
|
|
+ if (fd >= 0) {
|
|
|
|
+ FILE* result = fdopen(fd, "w+");
|
|
|
|
+ unlink(path);
|
2019-12-13 20:50:50 +01:00
|
|
|
+ free(path);
|
2017-06-18 20:57:16 +02:00
|
|
|
+ return result;
|
|
|
|
+ }
|
2019-12-13 20:50:50 +01:00
|
|
|
+ free(path);
|
2017-06-18 20:57:16 +02:00
|
|
|
+ }
|
|
|
|
+ return NULL;
|
|
|
|
+}
|
|
|
|
+
|
2017-11-15 16:48:35 +01:00
|
|
|
__END_DECLS
|
|
|
|
|
|
|
|
#endif
|