14 // Implementation based on GLIBC implementation.
16 static const char letters[] =
17 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
19 static uint64_t value;
21 const unsigned int ATTEMPTS_MIN = (62 * 62 * 62);
23 int save_errno = errno;
25 size_t len = strlen(tmpl);
26 if (len < 6 || strcmp(&tmpl[len - 6], "XXXXXX"))
32 char *XXXXXX = &tmpl[len - 6];
34 uint64_t random_time_bits = time(NULL);
36 value += (random_time_bits ^ getpid());
39 for (count = 0; count < ATTEMPTS_MIN; value += 7777, ++count)
43 XXXXXX[0] = letters[v % 62];
45 XXXXXX[1] = letters[v % 62];
47 XXXXXX[2] = letters[v % 62];
49 XXXXXX[3] = letters[v % 62];
51 XXXXXX[4] = letters[v % 62];
53 XXXXXX[5] = letters[v % 62];