flag Xer_DecodeOctetString(ByteStream* pByteStrm, const char* elementTag, byte value[], long* nCount, int *pErrCode) { char tmp[1024]; int len=0; int i; int j=0; memset(tmp,0x0, sizeof(tmp)); if (!Xer_DecodePrimitiveElement(pByteStrm, elementTag, tmp, pErrCode)) return FALSE; len = strlen(tmp); for(i=0; i<len; i++) { if (isspace(tmp[i])) continue; tmp[j++] = tmp[i]; } len = j; for(i=0; i<len; i++) { byte nibble; if (!CharToNibble(tmp[i], &nibble)) return FALSE; if (i%2 ==0) { value[i/2] = nibble<<4; } else { value[i/2] |= nibble; } } if (nCount != NULL) *nCount = len/2 + len%2; return TRUE; }
bool UUID::isValid(const char *str) { ///\bug Crashes if the uuid is valid otherwise but is too long and has unvalid chars at the very end. if (!str) return false; int valid_nibbles = 0; while (*str) { // If it looks anything like a url, can't be UUID if ((*str == '/') || (*str == ':')) return false; if (CharToNibble(*str) <= 0xf) valid_nibbles++; str++; } return (valid_nibbles == SIZE * 2); }