--- uuid_cli.c 2004/01/19 09:11:00 1.12
+++ uuid_cli.c 2004/01/19 12:15:05 1.13
@@ -71,6 +71,7 @@
int main(int argc, char *argv[])
{
uuid_t *uuid;
+ uuid_t *uuid_ns;
uuid_rc_t rc;
FILE *fp;
char *p;
@@ -149,10 +150,10 @@
if (strlen(argv[0]) != UUID_LEN_STR)
error(1, "invalid length of UUID string representation");
if ((rc = uuid_import(uuid, UUID_FMT_STR, argv[0], strlen(argv[0]))) != UUID_RC_OK)
- error(1, "uuid_parse: %s", uuid_error(rc));
+ error(1, "uuid_import: %s", uuid_error(rc));
vp = NULL;
if ((rc = uuid_export(uuid, UUID_FMT_TXT, &vp, NULL)) != UUID_RC_OK)
- error(1, "uuid_dump: %s", uuid_error(rc));
+ error(1, "uuid_export: %s", uuid_error(rc));
fprintf(stdout, "%s", (char *)vp);
free(vp);
if ((rc = uuid_destroy(uuid)) != UUID_RC_OK)
@@ -171,19 +172,29 @@
if (strlen(argv[0]) != UUID_LEN_STR)
error(1, "invalid length of UUID string representation");
if ((rc = uuid_import(uuid, UUID_FMT_STR, argv[0], strlen(argv[0]))) != UUID_RC_OK)
- error(1, "uuid_parse: %s", uuid_error(rc));
+ error(1, "uuid_import: %s", uuid_error(rc));
}
for (i = 0; i < count; i++) {
if (iterate) {
- if ((rc = uuid_nil(uuid)) != UUID_RC_OK)
- error(1, "uuid_nil: %s", uuid_error(rc));
+ if ((rc = uuid_load(uuid, "nil")) != UUID_RC_OK)
+ error(1, "uuid_load: %s", uuid_error(rc));
+ }
+ if (version == UUID_VERSION3) {
+ if ((rc = uuid_create(&uuid_ns)) != UUID_RC_OK)
+ error(1, "uuid_create: %s", uuid_error(rc));
+ if ((rc = uuid_load(uuid_ns, argv[0])) != UUID_RC_OK) {
+ if ((rc = uuid_import(uuid_ns, UUID_FMT_STR, argv[0], strlen(argv[0]))) != UUID_RC_OK)
+ error(1, "uuid_import: %s", uuid_error(rc));
+ }
+ if ((rc = uuid_make(uuid, version, uuid_ns, argv[1])) != UUID_RC_OK)
+ error(1, "uuid_make: %s", uuid_error(rc));
+ if ((rc = uuid_destroy(uuid_ns)) != UUID_RC_OK)
+ error(1, "uuid_destroy: %s", uuid_error(rc));
+ }
+ else {
+ if ((rc = uuid_make(uuid, version)) != UUID_RC_OK)
+ error(1, "uuid_make: %s", uuid_error(rc));
}
- if (version == UUID_VERSION3)
- rc = uuid_generate(uuid, version, argv[0], argv[1]);
- else
- rc = uuid_generate(uuid, version);
- if (rc != UUID_RC_OK)
- error(1, "uuid_generate: %s", uuid_error(rc));
if (raw) {
vp = NULL;
if ((rc = uuid_export(uuid, UUID_FMT_BIN, &vp, &n)) != UUID_RC_OK)
@@ -194,7 +205,7 @@
else {
vp = NULL;
if ((rc = uuid_export(uuid, UUID_FMT_STR, &vp, &n)) != UUID_RC_OK)
- error(1, "uuid_format: %s", uuid_error(rc));
+ error(1, "uuid_export: %s", uuid_error(rc));
fprintf(fp, "%s\n", (char *)vp);
free(vp);
}
|