elks-enhanced
public
Read
Owner: themaster
Branch: master
Commits: 6893
Updated: 2026-04-19 00:15
Git CLI clone URL
git clone https://www.xt-emporium.com/git/elks-enhanced.git
Fullscreen desktop URL
Code
Commits
History
Branches
Bug Reports
Discussions
Compare
Settings
elks-enhanced
/
libc
/
misc
/
tmpnam.c
File editor
/* * (C) Shane Kerr <kerr@wizard.net> under terms of LGPL */ #include <unistd.h> #include <sys/stat.h> #include <errno.h> #include <string.h> #include <stdio.h> #include <paths.h> #ifndef P_tmpdir #define P_tmpdir _PATH_TMP #endif #ifndef L_tmpnam #define L_tmpnam 20 #endif char *tmpnam(char *s) { static char ret_val[L_tmpnam]; static char c1 = 0; static char c2 = 0; static char c3 = 0; static char uniq_ch[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; struct stat stbuf; pid_t pid = getpid(); do { sprintf(ret_val, "%s/%05d%c%c%c", P_tmpdir, pid, uniq_ch[(int)c1], uniq_ch[(int)c2], uniq_ch[(int)c3]); if (++c1 >= 62) { c1 = 0; if (++c2 >= 62) { c2 = 0; if (++c3 >= 62) { errno = EEXIST; return 0; } } } } while (stat(ret_val, &stbuf) == 0); if (s != 0) { strcpy(s, ret_val); return s; } else { return ret_val; } }
Commit message
This repository is read-only for this account.
Repository snapshot
Current branch
master
Visibility
public
Your access
Read
Remote
Configured
File activity
View file history