Convert a QP encoded cstr, back to it's original form.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | QPDecode | (hzString&,const char*,) |
Declared in file: hzCodec.h
Defined in file : hzCodec.cpp
Function Logic:
Function body:
hzEcode QPDecode (hzString& Decoded)const char* pRaw,
{
// Category: Codec
//
// Convert a QP encoded cstr, back to it's original form.
//
// Arguments: 1) Decoded The hzString reference that will contain the result. Any pre-existing contents of this are cleared at the outset.
// 2) pRaw The encoded cstr.
//
// Returns: E_NODATA If the encoded cstr is empty
// E_FORMAT If there is an error in conversion
// E_OK If the operation is successful
_hzfunc("QPDecode") ;
hzChain R ; // Result
const char* i ; // Iterator
int32_t val ; // Holds 24 bit value to be written as 3 bytes
if (!pRaw || !pRaw[0])
return E_NODATA ;
// Interate the input. On the occurence of '=', the next two bytes are hex for the actual char.
i = pRaw ;
for (; *i ;)
{
if (*i == ''='')
{
i++ ;
if (*i == CHAR_CR || *i == CHAR_NL)
{
// Just skip to next line
if (*i == CHAR_CR) i++ ;
if (*i == CHAR_NL) i++ ;
continue ;
}
if (!IsHex(*i))
return E_FORMAT ;
val = _get1hex(*i) ;
i++ ;
if (!IsHex(*i))
return E_FORMAT ;
val *= 16;
val += _get1hex(*i) ;
R.AddByte(val) ;
i++ ;
continue ;
}
R.AddByte(*i) ;
i++ ;
}
Decoded = R ;
// threadLog("decoded=[%s]\n", *Decoded) ;
return E_OK ;
}