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)
33 if (!(version == 1 || (version >= 3 && version <= 5))) {
37 if ((version == 3 || version == 5) && (ns == NULL || data == NULL)) {
41 if (buf_str == NULL && buf_bin == NULL) {
47 if ((rc = uuid_create(&uuid)) != UUID_RC_OK) {
53 if (version == 3 || version == 5) {
54 if ((rc = uuid_create(&uuid_ns)) != UUID_RC_OK) {
55 rpmlog(
RPMLOG_ERR,
_(
"failed to create UUID namespace object: %s\n"), uuid_error(rc));
58 if ((rc = uuid_load(uuid_ns, ns)) != UUID_RC_OK) {
59 if ((rc = uuid_import(uuid_ns, UUID_FMT_STR, ns, strlen(ns))) != UUID_RC_OK) {
60 rpmlog(
RPMLOG_ERR,
_(
"failed to import UUID namespace object: %s\n"), uuid_error(rc));
68 rc = uuid_make(uuid, UUID_MAKE_V1);
69 else if (version == 3)
70 rc = uuid_make(uuid, UUID_MAKE_V3, uuid_ns, data);
71 else if (version == 4)
72 rc = uuid_make(uuid, UUID_MAKE_V4);
73 else if (version == 5)
74 rc = uuid_make(uuid, UUID_MAKE_V5, uuid_ns, data);
75 if (rc != UUID_RC_OK) {
76 (void) uuid_destroy(uuid);
78 (void) uuid_destroy(uuid_ns);
84 if (buf_str != NULL) {
86 result_len = UUID_LEN_STR+1;
87 if ((rc = uuid_export(uuid, UUID_FMT_STR, &result_ptr, &result_len)) != UUID_RC_OK) {
88 (void) uuid_destroy(uuid);
90 (void) uuid_destroy(uuid_ns);
91 rpmlog(
RPMLOG_ERR,
_(
"failed to export UUID object as string representation: %s\n"), uuid_error(rc));
95 if (buf_bin != NULL) {
96 result_ptr = (
char *)buf_bin;
97 result_len = UUID_LEN_BIN;
98 if ((rc = uuid_export(uuid, UUID_FMT_BIN, &result_ptr, &result_len)) != UUID_RC_OK) {
99 (void) uuid_destroy(uuid);
101 (void) uuid_destroy(uuid_ns);
102 rpmlog(
RPMLOG_ERR,
_(
"failed to export UUID object as binary representation: %s\n"), uuid_error(rc));
108 (void) uuid_destroy(uuid);
110 (void) uuid_destroy(uuid_ns);