guid.c revision 74f436ccd2887395bd61ab6f43ce70b7b85bf2c5
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/* Copyright (c) 2011 Dovecot authors, see the included COPYING file */
6cc0546c058f3e6253c6f99727b28dd602712974Timo Sirainenconst char *guid_generate(void)
0ce5f96804e81cb0f857e7df32c0272f1eed9377Timo Sirainen static unsigned int pid = 0;
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen /* we'll use the current time in nanoseconds as the initial 64bit
211ed7806d8715ec2280ffbf5d10f0d6e4f1beb2Timo Sirainen } else if ((uint32_t)ts.tv_nsec < (uint32_t)-1) {
8cb72c59d5ea4e9e5f638d7ec840bb853f5a188eTimo Sirainen unsigned char hostdomain_hash[SHA1_RESULTLEN];
8b247780e911909a9fdc47f69ce6d1478902ad98Timo Sirainen /* we'll use the current time in nanoseconds as the initial 64bit
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen sha1_get_digest(hostdomain, strlen(hostdomain),
211ed7806d8715ec2280ffbf5d10f0d6e4f1beb2Timo Sirainen hostdomain_hash+sizeof(hostdomain_hash)-4, 4);
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen } else if ((uint32_t)ts.tv_nsec < (uint32_t)-1) {
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen unsigned int i;
de954ff15b495be13007a8aca2c09fd1d356a283Timo Sirainen for (i = 0; i < GUID_128_SIZE; i++) {
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainenint guid_128_from_string(const char *str, guid_128_t guid_r)
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen buffer_create_data(&buf, guid_r, GUID_128_SIZE);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainenconst char *guid_128_to_string(const guid_128_t guid)
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainenunsigned int guid_128_hash(const void *p)
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainenint guid_128_cmp(const void *p1, const void *p2)