diff --git a/db/mork/src/morkEnv.cpp b/db/mork/src/morkEnv.cpp index d490f2a2ff9..b62f912e916 100644 --- a/db/mork/src/morkEnv.cpp +++ b/db/mork/src/morkEnv.cpp @@ -28,6 +28,10 @@ #include "morkNode.h" #endif +#ifndef _MORKCH_ +#include "morkCh.h" +#endif + #ifndef _MORKENV_ #include "morkEnv.h" #endif @@ -182,6 +186,31 @@ morkEnv::OidAsHex(void* outBuf, const mdbOid& inOid) return idSize + scopeSize + 2; } + +mork_u1 +morkEnv::HexToByte(mork_ch inFirstHex, mork_ch inSecondHex) +{ + mork_u1 hi = 0; // high four hex bits + mork_flags f = morkCh_GetFlags(inFirstHex); + if ( morkFlags_IsDigit(f) ) + hi = inFirstHex - '0'; + else if ( morkFlags_IsUpper(f) ) + hi = (inFirstHex - 'A') + 10; + else if ( morkFlags_IsLower(f) ) + hi = (inFirstHex - 'a') + 10; + + mork_u1 lo = 0; // low four hex bits + f = morkCh_GetFlags(inSecondHex); + if ( morkFlags_IsDigit(f) ) + lo = inSecondHex - '0'; + else if ( morkFlags_IsUpper(f) ) + lo = (inSecondHex - 'A') + 10; + else if ( morkFlags_IsLower(f) ) + lo = (inSecondHex - 'a') + 10; + + return (mork_u1) ((hi << 4) | lo); +} + mork_size morkEnv::TokenAsHex(void* outBuf, mork_token inToken) // TokenAsHex() is the same as sprintf(outBuf, "%lX", (long) inToken); diff --git a/mailnews/db/mork/src/morkEnv.cpp b/mailnews/db/mork/src/morkEnv.cpp index d490f2a2ff9..b62f912e916 100644 --- a/mailnews/db/mork/src/morkEnv.cpp +++ b/mailnews/db/mork/src/morkEnv.cpp @@ -28,6 +28,10 @@ #include "morkNode.h" #endif +#ifndef _MORKCH_ +#include "morkCh.h" +#endif + #ifndef _MORKENV_ #include "morkEnv.h" #endif @@ -182,6 +186,31 @@ morkEnv::OidAsHex(void* outBuf, const mdbOid& inOid) return idSize + scopeSize + 2; } + +mork_u1 +morkEnv::HexToByte(mork_ch inFirstHex, mork_ch inSecondHex) +{ + mork_u1 hi = 0; // high four hex bits + mork_flags f = morkCh_GetFlags(inFirstHex); + if ( morkFlags_IsDigit(f) ) + hi = inFirstHex - '0'; + else if ( morkFlags_IsUpper(f) ) + hi = (inFirstHex - 'A') + 10; + else if ( morkFlags_IsLower(f) ) + hi = (inFirstHex - 'a') + 10; + + mork_u1 lo = 0; // low four hex bits + f = morkCh_GetFlags(inSecondHex); + if ( morkFlags_IsDigit(f) ) + lo = inSecondHex - '0'; + else if ( morkFlags_IsUpper(f) ) + lo = (inSecondHex - 'A') + 10; + else if ( morkFlags_IsLower(f) ) + lo = (inSecondHex - 'a') + 10; + + return (mork_u1) ((hi << 4) | lo); +} + mork_size morkEnv::TokenAsHex(void* outBuf, mork_token inToken) // TokenAsHex() is the same as sprintf(outBuf, "%lX", (long) inToken);