diff options
author | Jakob Kaivo <jkk@ung.org> | 2020-08-16 15:55:19 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2020-08-16 15:55:19 -0400 |
commit | e223e635cc53fa11e473cdbc864eb69a3da5f290 (patch) | |
tree | d481ca6fb0b7f4184f3ec259a6f9c37d76e56a26 /src/stdio/tmpnam_s.c | |
parent | 700fbd205a1a428677876d322606b9a354221892 (diff) |
add skeleton of symbols from C11 LIB_EXT1
Diffstat (limited to 'src/stdio/tmpnam_s.c')
-rw-r--r-- | src/stdio/tmpnam_s.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/stdio/tmpnam_s.c b/src/stdio/tmpnam_s.c new file mode 100644 index 00000000..176eb982 --- /dev/null +++ b/src/stdio/tmpnam_s.c @@ -0,0 +1,43 @@ +#include "stdio.h" + +/** generate a temporary file name **/ +errno_t tmpnam_s(char *s, rsize_t maxsize) +{ + __C_EXT(1, 201112L); + static int ntimescalled = 0; + static char path[L_tmpnam]; + + if (ntimescalled >= TMP_MAX) { + return 0; + } + ntimescalled++; + + if (s == NULL) { + s = path; + } + + return 0; +} + +/*** +The fn(tmpnam) function 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 macro(TMP_MAX) times. + +If arg(s) is macro(NULL), the temporary name is stored in a static internal +buffer. This buffer may be overwritten by additional calls to fn(tmpnam). + +If arg(s) is not macro(NULL), it should point to a type(char) array of at least +macro(L_tmpnam) characters. The temporary name will be copied to this array. +***/ + +/* UNSPECIFIED: - */ +/* UNDEFINED: - */ +/* IMPLEMENTATION: behavior if fn(tmpnam) is called more than macro(TMP_MAX) times */ +/* LOCALE: - */ + +/* RETURN: a pointer to the temporary file name */ + +/* +CEXT1(201112) +*/ |