summaryrefslogtreecommitdiff
path: root/src/libposixplz/mkptemp.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2018-12-08 15:10:09 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2018-12-08 15:10:09 +0000
commit30d0c173d87b92a9ad2f3c1b643463a894abb1d9 (patch)
tree544c0917404a5ee3bf1c5f4faceeb51cff084b8d /src/libposixplz/mkptemp.c
parent2f017fbdd689e025437783cc8d675a7d304b37c3 (diff)
downloadskalibs-30d0c173d87b92a9ad2f3c1b643463a894abb1d9.tar.xz
Really add mkfootemp and autosurf, I guess ?
Diffstat (limited to 'src/libposixplz/mkptemp.c')
-rw-r--r--src/libposixplz/mkptemp.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libposixplz/mkptemp.c b/src/libposixplz/mkptemp.c
new file mode 100644
index 0000000..42bc715
--- /dev/null
+++ b/src/libposixplz/mkptemp.c
@@ -0,0 +1,20 @@
+/* ISC license. */
+
+#include <sys/stat.h>
+
+#include <skalibs/djbunix.h>
+#include <skalibs/posixplz.h>
+
+static int f (char const *fn, mode_t mode, void *data)
+{
+ int r = mkfifo(fn, mode) ;
+ if (r == -1) return -1 ;
+ r = open_readb(fn) ;
+ if (r == -1) unlink_void(fn) ;
+ return r ;
+}
+
+int mkptemp (char *s)
+{
+ return mkfiletemp(s, &f, 0600, 0) ;
+}