Show fingerprints with colons

This commit is contained in:
Alexey Sokolov
2014-12-23 00:58:59 +00:00
parent 72ca970731
commit 5c72c8232f
4 changed files with 45 additions and 4 deletions

View File

@@ -184,6 +184,8 @@ CString::EEscape CString::ToEscape(const CString& sEsc) {
return EDEBUG;
} else if (sEsc.Equals("MSGTAG")) {
return EMSGTAG;
} else if (sEsc.Equals("HEXCOLON")) {
return EHEXCOLON;
}
return EASCII;
@@ -350,6 +352,35 @@ CString CString::Escape_n(EEscape eFrom, EEscape eTo) const {
}
}
break;
case EHEXCOLON: {
while (!isxdigit(*p) && a < iLength) {
a++;
p++;
}
if (a == iLength) {
continue;
}
if (isdigit(*p)) {
ch = (unsigned char)((*p - '0') << 4);
} else {
ch = (unsigned char)((tolower(*p) - 'a' +10) << 4);
}
a++;
p++;
while (!isxdigit(*p) && a < iLength) {
a++;
p++;
}
if (a == iLength) {
continue;
}
if (isdigit(*p)) {
ch |= (unsigned char)(*p - '0');
} else {
ch |= (unsigned char)(tolower(*p) - 'a' +10);
}
}
break;
}
@@ -419,11 +450,20 @@ CString CString::Escape_n(EEscape eFrom, EEscape eTo) const {
} else if (ch == '\n') { sRet += '\\'; sRet += 'n';
} else { sRet += ch; }
break;
case EHEXCOLON: {
sRet += tolower(szHex[ch >> 4]);
sRet += tolower(szHex[ch & 0xf]);
sRet += ":";
}
break;
}
}
sRet.reserve(0);
if (eTo == EHEXCOLON) {
sRet.TrimRight(":");
}
return sRet;
}