ref: 7a7012783c528091cb49dcc04028429daceab390
parent: f6222378396c27f05a70b6ac7424ddd09fde33a5
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Wed Aug 16 21:04:19 EDT 2023
forgot to add the file
--- /dev/null
+++ b/libnpe/mkstemp.c
@@ -1,0 +1,24 @@
+#include <stdlib.h>
+
+int
+mkstemp(char *t)
+{
+ int i, l, n, f;
+ char *s;
+
+ s = t;
+ n = 0;
+ l = strlen(t);
+ for(i = l-1; i >= 0 && t[i] == 'X'; i--, n++);
+ if(n < 11){
+ s = malloc(l+11-n+1);
+ strcpy(s, t);
+ for(i = l; i < l+11-n; i++)
+ s[i] = 'X';
+ s[i] = 0;
+ }
+ f = create(mktemp(s), ORDWR|OEXCL, 0600);
+ if(s != t)
+ free(s);
+ return f;
+}