8 #define uuid_t __darwin_uuid_t
23 int rpmuuidMake(
int version,
const char *
ns,
const char *
data,
char *buf_str,
unsigned char *buf_bin)
34 if (!(version == 1 || (version >= 3 && version <= 5))) {
38 if ((version == 3 || version == 5) && (ns == NULL || data == NULL)) {
42 if (buf_str == NULL && buf_bin == NULL) {
48 if ((rc = uuid_create(&uuid)) != UUID_RC_OK) {
54 if (version == 3 || version == 5) {
55 if ((rc = uuid_create(&uuid_ns)) != UUID_RC_OK) {
56 rpmlog(
RPMLOG_ERR,
_(
"failed to create UUID namespace object: %s\n"), uuid_error(rc));
59 if ((rc = uuid_load(uuid_ns, ns)) != UUID_RC_OK) {
60 if ((rc = uuid_import(uuid_ns, UUID_FMT_STR, ns, strlen(ns))) != UUID_RC_OK) {
61 rpmlog(
RPMLOG_ERR,
_(
"failed to import UUID namespace object: %s\n"), uuid_error(rc));
69 rc = uuid_make(uuid, UUID_MAKE_V1);
70 else if (version == 3)
71 rc = uuid_make(uuid, UUID_MAKE_V3, uuid_ns, data);
72 else if (version == 4)
73 rc = uuid_make(uuid, UUID_MAKE_V4);
74 else if (version == 5)
75 rc = uuid_make(uuid, UUID_MAKE_V5, uuid_ns, data);
76 if (rc != UUID_RC_OK) {
82 if (buf_str != NULL) {
84 result_len = UUID_LEN_STR+1;
85 if ((rc = uuid_export(uuid, UUID_FMT_STR, &result_ptr, &result_len)) != UUID_RC_OK) {
86 rpmlog(
RPMLOG_ERR,
_(
"failed to export UUID object as string representation: %s\n"), uuid_error(rc));
90 if (buf_bin != NULL) {
91 result_ptr = (
char *)buf_bin;
92 result_len = UUID_LEN_BIN;
93 if ((rc = uuid_export(uuid, UUID_FMT_BIN, &result_ptr, &result_len)) != UUID_RC_OK) {
94 rpmlog(
RPMLOG_ERR,
_(
"failed to export UUID object as binary representation: %s\n"), uuid_error(rc));
102 (void) uuid_destroy(uuid);
104 (void) uuid_destroy(uuid_ns);
int rpmuuidMake(int version, const char *ns, const char *data, char *buf_str, unsigned char *buf_bin)
Generate a Universally Unique Identifier (UUID).
static const char uuid_ns[]
static void rpmlog(int code, const char *fmt,...)
Yet Another syslog(3) API clone.
const char const bson * data