Index: ossp-pkg/uuid/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/ChangeLog,v rcsdiff -q -kk '-r1.25' '-r1.26' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/ChangeLog,v' 2>/dev/null --- ChangeLog 2004/01/18 11:31:09 1.25 +++ ChangeLog 2004/01/18 19:22:54 1.26 @@ -13,6 +13,13 @@ Changes between 0.9.3 and 0.9.4 (16-Jan-2004 to xx-Jan-2004) + o Cleanup the C code to also pass warning-free a C++ compiler. + [Ralf S. Engelschall] + + o Support C++ by enclosing the C API declarations in + 'extern "C" {...}' within uuid.h. + [Guerry Semones ] + o Improvide decoding in uuid_dump() by at least hex-dumping the binary representation in case of v3, v4 and Nil UUIDs. Also, annotate with better hints. Index: ossp-pkg/uuid/uuid.c RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.c,v rcsdiff -q -kk '-r1.34' '-r1.35' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.c,v' 2>/dev/null --- uuid.c 2004/01/18 11:31:10 1.34 +++ uuid.c 2004/01/18 19:22:54 1.35 @@ -218,7 +218,7 @@ const uuid_uint8_t *in; uuid_uint32_t tmp32; uuid_uint16_t tmp16; - int i; + unsigned int i; /* sanity check argument(s) */ if (uuid == NULL || buf == NULL) @@ -264,7 +264,7 @@ uuid_uint8_t *out; uuid_uint32_t tmp32; uuid_uint16_t tmp16; - int i; + unsigned int i; /* sanity check argument(s) */ if (uuid == NULL || buf == NULL) @@ -343,7 +343,7 @@ uuid_uint16_t tmp16; const char *cp; char hexbuf[3]; - int i; + unsigned int i; /* sanity check argument(s) */ if (uuid == NULL || str == NULL) @@ -649,7 +649,7 @@ void *uuid_octets; uuid_t *uuid_object; uuid_rc_t rc; - int i; + unsigned int i; /* determine namespace UUID name and argument name string */ if ((ns = (char *)va_arg(ap, char *)) == NULL) @@ -774,7 +774,7 @@ uuid_uint32_t tmp32; char string[UUID_LEN_STR+1]; char *s; - int i; + unsigned int i; ui64_t t; ui64_t offset; int t_nsec; Index: ossp-pkg/uuid/uuid.h RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.h,v rcsdiff -q -kk '-r1.11' '-r1.12' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.h,v' 2>/dev/null --- uuid.h 2004/01/15 12:32:26 1.11 +++ uuid.h 2004/01/18 19:22:54 1.12 @@ -30,6 +30,17 @@ #ifndef __UUID_H__ #define __UUID_H__ +/* minimum C++ support */ +#ifdef __cplusplus +#define DECLARATION_BEGIN extern "C" { +#define DECLARATION_END } +#else +#define DECLARATION_BEGIN /*nop*/ +#define DECLARATION_END /*nop*/ +#endif + +DECLARATION_BEGIN + /* encoding octet stream lengths */ #define UUID_LEN_BIN (128 / 8 /*bytes*/) #define UUID_LEN_STR (128 / 4 /*nibbles*/ + 4 /*hyphens*/) @@ -79,5 +90,7 @@ /* error handling */ extern char *uuid_error (uuid_rc_t _rc); +DECLARATION_END + #endif /* __UUID_H__ */ Index: ossp-pkg/uuid/uuid_md5.c RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_md5.c,v rcsdiff -q -kk '-r1.4' '-r1.5' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_md5.c,v' 2>/dev/null --- uuid_md5.c 2004/01/10 12:16:03 1.4 +++ uuid_md5.c 2004/01/18 19:22:54 1.5 @@ -420,7 +420,7 @@ if (md5 == NULL || data_ptr == NULL) return MD5_RC_ARG; if (*data_ptr == NULL) { - if ((*data_ptr = malloc(MD5_LEN_STR+1)) == NULL) + if ((*data_ptr = (char *)malloc(MD5_LEN_STR+1)) == NULL) return MD5_RC_MEM; if (data_len != NULL) *data_len = MD5_LEN_STR+1; @@ -435,10 +435,10 @@ bufptr = buf; buflen = sizeof(buf); - if ((rc = md5_store(md5, (void *)(&bufptr), &buflen)) != MD5_RC_OK) + if ((rc = md5_store(md5, (void **)&bufptr, &buflen)) != MD5_RC_OK) return rc; - for (i = 0; i < buflen; i++) { + for (i = 0; i < (int)buflen; i++) { (*data_ptr)[(i*2)+0] = hex[(int)(bufptr[i] >> 4)]; (*data_ptr)[(i*2)+1] = hex[(int)(bufptr[i] & 0x0f)]; } Index: ossp-pkg/uuid/uuid_prng.c RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_prng.c,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_prng.c,v' 2>/dev/null --- uuid_prng.c 2004/01/10 12:16:03 1.1 +++ uuid_prng.c 2004/01/18 19:22:54 1.2 @@ -94,7 +94,7 @@ /* try to gather data from the system PRNG device */ if (prng->devfd != -1) { - p = data_ptr; + p = (unsigned char *)data_ptr; n = data_len; cnt = 0; while (n > 0) { @@ -112,7 +112,7 @@ /* always also apply the weaker PRNG. In case the stronger PRNG device based source failed, this is the only remaining randomness, of course */ - for (p = data_ptr, n = 0; n < data_len; n++) + for (p = (unsigned char *)data_ptr, n = 0; n < data_len; n++) *p++ ^= (unsigned char)(((unsigned int)rand() >> 7) & 0xFF); return PRNG_RC_OK; Index: ossp-pkg/uuid/uuid_str.c RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_str.c,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_str.c,v' 2>/dev/null --- uuid_str.c 2004/01/13 19:43:15 1.1 +++ uuid_str.c 2004/01/18 19:22:54 1.2 @@ -557,7 +557,7 @@ if (fracpart >= pow10(max)) { intpart++; - fracpart -= pow10(max); + fracpart -= (long)pow10(max); } /* convert integer part */ @@ -689,7 +689,7 @@ char *rv; int n; - n = str_vsnprintf(NULL, -1, fmt, ap); + n = str_vsnprintf(NULL, 0, fmt, ap); if ((rv = (char *)malloc(n+1)) == NULL) return NULL; str_vsnprintf(rv, n+1, fmt, ap); @@ -727,7 +727,7 @@ } else { n = strlen(*str); - rv = str_vsnprintf(NULL, -1, fmt, ap); + rv = str_vsnprintf(NULL, 0, fmt, ap); if ((*str = (char *)realloc(*str, n+rv+1)) == NULL) return -1; str_vsnprintf((*str)+n, rv+1, fmt, ap); Index: ossp-pkg/uuid/uuid_ui64.c RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_ui64.c,v rcsdiff -q -kk '-r1.1' '-r1.2' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid_ui64.c,v' 2>/dev/null --- uuid_ui64.c 2004/01/09 11:32:06 1.1 +++ uuid_ui64.c 2004/01/18 19:22:55 1.2 @@ -149,7 +149,7 @@ str[i++] = map[r]; while (n > 1 && x.x[n-1] == 0) n--; - } while (i < (len-1) && (n > 1 || x.x[0] != 0)); + } while (i < ((int)len-1) && (n > 1 || x.x[0] != 0)); str[i] = '\0'; for (j = 0; j < --i; j++) { c = str[j];