guid.h revision de62ce819d59a529530da4b57be1b8d6dad13d6b
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose#ifndef GUID_H
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose#define GUID_H
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose#define GUID_128_SIZE 16
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bosetypedef uint8_t guid_128_t[GUID_128_SIZE];
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose/* Generate a GUID (contains host name) */
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Boseconst char *guid_generate(void);
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose/* Generate 128 bit GUID */
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bosevoid guid_128_generate(guid_128_t guid_r);
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose/* Returns TRUE if GUID is empty (not set / unknown). */
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bosebool guid_128_is_empty(const guid_128_t guid);
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose/* Returns GUID as a hex string. */
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Boseconst char *guid_128_to_string(const guid_128_t guid);
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose/* Parse GUID from a string. Returns 0 if ok, -1 if GUID isn't valid. */
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Boseint guid_128_from_string(const char *str, guid_128_t guid_r);
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose/* guid_128 hash/cmp functions for hash.h */
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Boseunsigned int guid_128_hash(const void *p);
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Boseint guid_128_cmp(const void *p1, const void *p2);
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose#endif
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose