Index: ossp-pkg/uuid/uuid.c RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.c,v rcsdiff -q -kk '-r1.7' '-r1.8' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.c,v' 2>/dev/null --- uuid.c 2004/01/09 16:11:40 1.7 +++ uuid.c 2004/01/09 21:01:04 1.8 @@ -317,7 +317,6 @@ uuid_rc_t uuid_parse(uuid_t *uuid, const char *str) { - uuid_t uuid_tmp; uuid_uint16_t tmp16; const char *cp; char hexbuf[3]; @@ -353,18 +352,18 @@ /* * pass 2: parse hex values of string representation syntax */ - uuid_tmp.time_low = (uuid_uint32_t)strtoul(str, NULL, 16); - uuid_tmp.time_mid = (uuid_uint16_t)strtoul(str+9, NULL, 16); - uuid_tmp.time_hi_and_version = (uuid_uint16_t)strtoul(str+14, NULL, 16); + uuid->time_low = (uuid_uint32_t)strtoul(str, NULL, 16); + uuid->time_mid = (uuid_uint16_t)strtoul(str+9, NULL, 16); + uuid->time_hi_and_version = (uuid_uint16_t)strtoul(str+14, NULL, 16); tmp16 = (uuid_uint16_t)strtoul(str+19, NULL, 16); - uuid_tmp.clock_seq_low = (uuid_uint8_t)(tmp16 & 0xff); tmp16 >>= 8; - uuid_tmp.clock_seq_hi_and_reserved = (uuid_uint8_t)(tmp16 & 0xff); + uuid->clock_seq_low = (uuid_uint8_t)(tmp16 & 0xff); tmp16 >>= 8; + uuid->clock_seq_hi_and_reserved = (uuid_uint8_t)(tmp16 & 0xff); cp = str+24; hexbuf[2] = '\0'; - for (i = 0; i < sizeof(uuid_tmp.node); i++) { + for (i = 0; i < sizeof(uuid->node); i++) { hexbuf[0] = *cp++; hexbuf[1] = *cp++; - uuid_tmp.node[i] = strtoul(hexbuf, NULL, 16); + uuid->node[i] = strtoul(hexbuf, NULL, 16); } return UUID_RC_OK; @@ -372,8 +371,6 @@ uuid_rc_t uuid_format(uuid_t *uuid, char **str) { - uuid_t uuid_tmp; - /* sanity check argument(s) */ if (uuid == NULL || str == NULL) return UUID_RC_ARG; @@ -386,17 +383,17 @@ /* format UUID into string representation */ sprintf(*str, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - (unsigned long)uuid_tmp.time_low, - (unsigned int)uuid_tmp.time_mid, - (unsigned int)uuid_tmp.time_hi_and_version, - (unsigned int)uuid_tmp.clock_seq_hi_and_reserved, - (unsigned int)uuid_tmp.clock_seq_low, - (unsigned int)uuid_tmp.node[0], - (unsigned int)uuid_tmp.node[1], - (unsigned int)uuid_tmp.node[2], - (unsigned int)uuid_tmp.node[3], - (unsigned int)uuid_tmp.node[4], - (unsigned int)uuid_tmp.node[5]); + (unsigned long)uuid->time_low, + (unsigned int)uuid->time_mid, + (unsigned int)uuid->time_hi_and_version, + (unsigned int)uuid->clock_seq_hi_and_reserved, + (unsigned int)uuid->clock_seq_low, + (unsigned int)uuid->node[0], + (unsigned int)uuid->node[1], + (unsigned int)uuid->node[2], + (unsigned int)uuid->node[3], + (unsigned int)uuid->node[4], + (unsigned int)uuid->node[5]); return UUID_RC_OK; } Index: ossp-pkg/uuid/uuid_cli.c RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_cli.c,v rcsdiff -q -kk '-r1.5' '-r1.6' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_cli.c,v' 2>/dev/null --- uuid_cli.c 2004/01/09 16:11:40 1.5 +++ uuid_cli.c 2004/01/09 21:01:04 1.6 @@ -78,7 +78,7 @@ int count; int i; int iterate; - int ascii; + int raw; int decode; char *cp; void *vp; @@ -88,10 +88,10 @@ count = -1; /* no count yet */ fp = stdout; /* default output file */ iterate = 0; /* not one at a time */ - ascii = 0; /* default is binary output */ + raw = 0; /* default is ASCII output */ decode = 0; /* default is to encode */ version = UUID_VERSION1; - while ((ch = getopt(argc, argv, "1n:ado:v:")) != -1) { + while ((ch = getopt(argc, argv, "1n:rdo:v:")) != -1) { switch (ch) { case '1': iterate = 1; @@ -103,8 +103,8 @@ if (*p != '\0' || count < 1) usage("invalid argument to option 'n'"); break; - case 'a': - ascii = 1; + case 'r': + raw = 1; break; case 'd': decode = 1; @@ -165,20 +165,20 @@ rc = uuid_generate(uuid, version); if (rc != UUID_RC_OK) error(1, "uuid_generate: %s", uuid_error(rc)); - if (ascii) { + if (raw) { + vp = NULL; + if ((rc = uuid_pack(uuid, &vp)) != UUID_RC_OK) + error(1, "uuid_pack: %s", uuid_error(rc)); + fwrite(vp, UUID_LEN_BIN, 1, fp); + free(vp); + } + else { cp = NULL; if ((rc = uuid_format(uuid, &cp)) != UUID_RC_OK) - error(1, "uuid_unparse: %s", uuid_error(rc)); + error(1, "uuid_format: %s", uuid_error(rc)); fprintf(fp, "%s\n", cp); free(cp); } - else { - vp = NULL; - if ((rc = uuid_pack(uuid, &vp)) != UUID_RC_OK) - error(1, "uuid_unpack: %s", uuid_error(rc)); - fwrite(vp, UUID_LEN_BIN, 1, vp); - free(vp); - } } if ((rc = uuid_destroy(uuid)) != UUID_RC_OK) error(1, "uuid_destroy: %s", uuid_error(rc));