1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| | #include <string.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <stdint.h>
#include "libc.h"
char *__randname(char *template)
{
struct timespec ts;
size_t i, l = strlen(template);
unsigned long r;
/* This assumes that a check for the template
size has alrady been made */
clock_gettime(CLOCK_REALTIME, &ts);
r = ts.tv_nsec + (uintptr_t)&ts / 16 + (uintptr_t)template;
for (i=1; i<=6; i++, r>>=4)
template[l-i] = 'A'+(r&15);
return template;
}
|