3 * @author Michal Sojka <sojkam1@fel.cvut.cz>
4 * @date Tue Aug 26 09:17:31 2008
6 * @brief Unix version of UUID generator
12 #include <sys/types.h>
16 * Generates universally unique ID.
18 * @param dest Where to store the newly generated UUID.
20 * @return Same as @a dest.
22 forb_uuid_t *forb_uuid_generate(forb_uuid_t *dest)
27 unsigned char digest[20];
30 SHA1Update(&ctx, (unsigned char*)&t, sizeof(t));
31 SHA1Update(&ctx, (unsigned char*)&pid, sizeof(pid));
32 /* This should be enough for localhost process.
33 * TODO: Add network addresses for distributed operation! */
34 SHA1Final(digest, &ctx);
35 memcpy(dest, digest, sizeof(forb_uuid_t));