MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / util_ConvertOctal

Function util_ConvertOctal

src/twparser/parserhelper.cpp:940–955  ·  view source on GitHub ↗

only 3 octal chars allowed

Source from the content-addressed store, hash-verified

938
939// only 3 octal chars allowed
940int util_ConvertOctal(const char* psz, int* const pnCharsRead)
941{
942 ASSERT(util_AsciiCharsActLikeTheyShould());
943 ASSERT(psz && pnCharsRead);
944 ASSERT(util_IsOctal(*psz)); // at least one oct char
945
946 int iValue;
947 for (iValue = 0, *pnCharsRead = 0; *psz && util_IsOctal(*psz) && *pnCharsRead < 3; // limit of 3 octal chars
948 psz++, (*pnCharsRead)++)
949 {
950 iValue *= 010;
951 iValue += (*psz - '0');
952 }
953
954 return (iValue);
955}
956
957bool util_IsOctal(const char ch)
958{

Callers 1

Calls 2

util_IsOctalFunction · 0.85

Tested by

no test coverage detected