summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2018-12-07 21:00:23 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2018-12-07 21:00:23 +0000
commit2f017fbdd689e025437783cc8d675a7d304b37c3 (patch)
tree57645420ed02a56ab4e6abfc3b1ff9847ee96c8e
parent1af5a42e566da1e615abae7868ae7a10260ce0b8 (diff)
downloadskalibs-2f017fbdd689e025437783cc8d675a7d304b37c3.tar.xz
Add mk?temp and autosurf
-rw-r--r--NEWS2
-rw-r--r--doc/upgrade.html3
-rw-r--r--package/deps.mak13
-rw-r--r--src/include/skalibs/functypes.h4
-rw-r--r--src/include/skalibs/posixplz.h10
-rw-r--r--src/include/skalibs/surf.h2
-rw-r--r--src/librandom/random-internal.h1
-rw-r--r--src/librandom/random_name.c4
8 files changed, 33 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index 067ef85..bdbdc12 100644
--- a/NEWS
+++ b/NEWS
@@ -7,7 +7,7 @@ In 2.8.0.0
- avltreeb removed. (It used VLAs inside of structures, which is
GNU C, not C99.) The AVLTREEN_DECLARE_AND_INIT() macro should be
used instead.
- - New function: env_dump()
+ - New functions: env_dump(), mk?temp(), autosurf(), autosurf_name()
In 2.7.0.0
diff --git a/doc/upgrade.html b/doc/upgrade.html
index e341d4f..105ddba 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -21,7 +21,8 @@
<ul>
<li> The avltreeb macros have been removed. Instead, the
<tt>AVLTREEN_DECLARE_AND_INIT() macro has been added. </li>
- <li> New function: <tt>env_dump()</tt> </li>
+ <li> New functions: <tt>env_dump()</tt>, <tt>mk?temp()</tt>,
+<tt>autosurf()</tt>, <tt>autosurf_name()</tt> </li>
</ul>
<h2> in 2.7.0.0 </h2>
diff --git a/package/deps.mak b/package/deps.mak
index c55777c..60781e3 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -33,7 +33,7 @@ src/include/skalibs/iopause.h: src/include/skalibs/tai.h
src/include/skalibs/kolbak.h: src/include/skalibs/unixmessage.h
src/include/skalibs/lolstdio.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/strerr2.h
src/include/skalibs/netstring.h: src/include/skalibs/buffer.h src/include/skalibs/stralloc.h
-src/include/skalibs/posixplz.h: src/include/skalibs/gccattributes.h
+src/include/skalibs/posixplz.h: src/include/skalibs/functypes.h src/include/skalibs/gccattributes.h
src/include/skalibs/random.h: src/include/skalibs/stralloc.h
src/include/skalibs/setgroups.h: src/include/skalibs/sysdeps.h
src/include/skalibs/sha512.h: src/include/skalibs/uint64.h
@@ -144,15 +144,24 @@ src/libposixplz/execvep_internal.o src/libposixplz/execvep_internal.lo: src/libp
src/libposixplz/execvep_loose.o src/libposixplz/execvep_loose.lo: src/libposixplz/execvep_loose.c src/libposixplz/posixplz-internal.h src/include/skalibs/posixplz.h
src/libposixplz/getpeereid.o src/libposixplz/getpeereid.lo: src/libposixplz/getpeereid.c src/include/skalibs/nonposix.h src/include/skalibs/posixplz.h src/include/skalibs/sysdeps.h
src/libposixplz/memmem.o src/libposixplz/memmem.lo: src/libposixplz/memmem.c src/include/skalibs/posixplz.h src/include/skalibs/sysdeps.h
+src/libposixplz/mkLtemp.o src/libposixplz/mkLtemp.lo: src/libposixplz/mkLtemp.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h
+src/libposixplz/mkbtemp.o src/libposixplz/mkbtemp.lo: src/libposixplz/mkbtemp.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h
+src/libposixplz/mkctemp.o src/libposixplz/mkctemp.lo: src/libposixplz/mkctemp.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h
+src/libposixplz/mkfiletemp.o src/libposixplz/mkfiletemp.lo: src/libposixplz/mkfiletemp.c src/include/skalibs/posixplz.h src/include/skalibs/surf.h
+src/libposixplz/mkltemp.o src/libposixplz/mkltemp.lo: src/libposixplz/mkltemp.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h
+src/libposixplz/mkptemp.o src/libposixplz/mkptemp.lo: src/libposixplz/mkptemp.c src/include/skalibs/djbunix.h src/include/skalibs/posixplz.h
src/libposixplz/setgroups.o src/libposixplz/setgroups.lo: src/libposixplz/setgroups.c src/include/skalibs/nonposix.h src/include/skalibs/setgroups.h src/include/skalibs/sysdeps.h
src/libposixplz/strnlen.o src/libposixplz/strnlen.lo: src/libposixplz/strnlen.c src/include/skalibs/bytestr.h src/include/skalibs/posixplz.h src/include/skalibs/sysdeps.h
src/libposixplz/touch.o src/libposixplz/touch.lo: src/libposixplz/touch.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/posixplz.h src/include/skalibs/sysdeps.h
src/libposixplz/unlink_void.o src/libposixplz/unlink_void.lo: src/libposixplz/unlink_void.c src/include/skalibs/posixplz.h
+src/librandom/autosurf.o src/librandom/autosurf.lo: src/librandom/autosurf.c src/include/skalibs/random.h src/include/skalibs/surf.h
+src/librandom/autosurf_name.o src/librandom/autosurf_name.lo: src/librandom/autosurf_name.c src/librandom/random-internal.h src/include/skalibs/surf.h
src/librandom/random_char.o src/librandom/random_char.lo: src/librandom/random_char.c src/include/skalibs/random.h
src/librandom/random_finish.o src/librandom/random_finish.lo: src/librandom/random_finish.c src/include/skalibs/djbunix.h src/librandom/random-internal.h src/include/skalibs/random.h src/include/skalibs/sysdeps.h
src/librandom/random_init.o src/librandom/random_init.lo: src/librandom/random_init.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/librandom/random-internal.h src/include/skalibs/random.h src/include/skalibs/surf.h src/include/skalibs/sysdeps.h
src/librandom/random_makeseed.o src/librandom/random_makeseed.lo: src/librandom/random_makeseed.c src/include/skalibs/sha1.h src/include/skalibs/tai.h src/include/skalibs/uint32.h
-src/librandom/random_name.o src/librandom/random_name.lo: src/librandom/random_name.c src/include/skalibs/random.h
+src/librandom/random_name.o src/librandom/random_name.lo: src/librandom/random_name.c src/librandom/random-internal.h src/include/skalibs/random.h
+src/librandom/random_oklist.o src/librandom/random_oklist.lo: src/librandom/random_oklist.c src/librandom/random-internal.h
src/librandom/random_sauniquename.o src/librandom/random_sauniquename.lo: src/librandom/random_sauniquename.c src/include/skalibs/random.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h
src/librandom/random_string.o src/librandom/random_string.lo: src/librandom/random_string.c src/include/skalibs/allreadwrite.h src/include/skalibs/nonposix.h src/librandom/random-internal.h src/include/skalibs/random.h src/include/skalibs/sysdeps.h
src/librandom/random_uint32.o src/librandom/random_uint32.lo: src/librandom/random_uint32.c src/include/skalibs/nonposix.h src/include/skalibs/random.h src/include/skalibs/sysdeps.h src/include/skalibs/uint32.h
diff --git a/src/include/skalibs/functypes.h b/src/include/skalibs/functypes.h
index 8308fda..9c77f22 100644
--- a/src/include/skalibs/functypes.h
+++ b/src/include/skalibs/functypes.h
@@ -4,6 +4,7 @@
#define FUNCTYPES_H
#include <stdint.h>
+#include <sys/stat.h>
#include <sys/uio.h>
typedef int uintcmpfunc_t (unsigned int, unsigned int, void *) ;
@@ -45,4 +46,7 @@ typedef alliofunc_t *alliofunc_t_ref ;
typedef size_t alliovfunc_t (int, struct iovec const *, unsigned int) ;
typedef alliovfunc_t *alliovfunc_t_ref ;
+typedef int createfunc_t (char const *, mode_t, void *) ;
+typedef createfunc_t *createfunc_t_ref ;
+
#endif
diff --git a/src/include/skalibs/posixplz.h b/src/include/skalibs/posixplz.h
index 97c1ef1..b54faa0 100644
--- a/src/include/skalibs/posixplz.h
+++ b/src/include/skalibs/posixplz.h
@@ -4,7 +4,10 @@
#define SKALIBS_POSIXPLZ_H
#include <sys/types.h>
+#include <sys/stat.h>
+
#include <skalibs/gccattributes.h>
+#include <skalibs/functypes.h>
/*
@@ -44,4 +47,11 @@ extern void unlink_void (char const *) ;
extern pid_t doublefork (void) ;
extern int touch (char const *) ;
+extern int mkfiletemp (char *, createfunc_t_ref, mode_t, void *) ;
+extern int mkptemp (char *) ;
+extern int mkltemp (char const *, char *) ;
+extern int mkLtemp (char const *, char *) ;
+extern int mkctemp (char *, mode_t, dev_t) ;
+extern int mkbtemp (char *, mode_t, dev_t) ;
+
#endif
diff --git a/src/include/skalibs/surf.h b/src/include/skalibs/surf.h
index 99408ca..15e9215 100644
--- a/src/include/skalibs/surf.h
+++ b/src/include/skalibs/surf.h
@@ -19,5 +19,7 @@ struct SURFSchedule
extern void surf_init (SURFSchedule *, char const *) ; /* 160 chars */
extern void surf (SURFSchedule *, char *, size_t) ;
+extern void autosurf (char *, size_t) ;
+extern void autosurf_name (char *, size_t) ;
#endif
diff --git a/src/librandom/random-internal.h b/src/librandom/random-internal.h
index c915170..a8f8be9 100644
--- a/src/librandom/random-internal.h
+++ b/src/librandom/random-internal.h
@@ -5,6 +5,7 @@
#include <skalibs/surf.h>
+extern char const *random_oklist ;
extern int random_fd ;
extern SURFSchedule surf_here ;
diff --git a/src/librandom/random_name.c b/src/librandom/random_name.c
index bba1331..057a5db 100644
--- a/src/librandom/random_name.c
+++ b/src/librandom/random_name.c
@@ -1,10 +1,10 @@
/* ISC license. */
#include <skalibs/random.h>
+#include "random-internal.h"
void random_name (char *s, size_t n)
{
- static char const oklist[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz-_0123456789abcdef" ;
random_string(s, n) ;
- while (n--) s[n] = oklist[s[n] & 63] ;
+ while (n--) s[n] = random_oklist[s[n] & 63] ;
}