summaryrefslogtreecommitdiff
path: root/src/stdio/tmpnam.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-08 18:42:39 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-08 18:42:39 -0500
commit7ef8a7379f7f7d09e71ccae2a0b688c3cd80423f (patch)
tree092ab0aed1769117fd7b28b8592f6f96b0e0d5af /src/stdio/tmpnam.c
parent6acf19370e8adff79cd83b257d3f04aeaf2a59dd (diff)
merge sources into single tree
Diffstat (limited to 'src/stdio/tmpnam.c')
-rw-r--r--src/stdio/tmpnam.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/stdio/tmpnam.c b/src/stdio/tmpnam.c
new file mode 100644
index 00000000..b4b5d932
--- /dev/null
+++ b/src/stdio/tmpnam.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+
+/** generate a temporary file name **/
+char * tmpnam(char *s)
+{
+ static int ntimescalled = 0;
+ static char path[L_tmpnam];
+
+ if (ntimescalled >= TMP_MAX) {
+ return NULL;
+ }
+ ntimescalled++;
+
+ if (s == NULL) {
+ s = path;
+ }
+
+ /*
+ RETURN_SUCCESS(a pointer to the temporary file name);
+ */
+ return s;
+}
+
+/***
+generates a unique file name that can be used as a
+temporary file. A new file name is generated every time the function is called
+up to CONSTANT(TMP_MAX) times.
+
+If ARGUMENT(s) is CONSTANT(NULL), the temporary name is stored in a static
+internal buffer. This buffer may be overwritten by additional calls to
+THIS().
+
+If ARGUMENT(s) is not CONSTANT(NULL), it should point to a TYPE(char) array of
+at least CONSTANT(L_tmpnam) characters. The temporary name will be copied to
+this array.
+***/
+
+/*
+IMPLEMENTATION(Behavior if THIS() is called more than CONSTANT(TMP_MAX) times)
+*/
+/*
+STDC(1)
+*/