MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / UTIL_DecodeHexString

Function UTIL_DecodeHexString

tools/gdc-psyfork/gdc.cpp:733–764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

731}
732
733size_t UTIL_DecodeHexString(unsigned char *buffer, size_t maxlength, const char *hexstr)
734{
735 size_t written = 0;
736 size_t length = strlen(hexstr);
737
738 for (size_t i = 0; i < length; i++)
739 {
740 if (written >= maxlength)
741 break;
742
743 buffer[written++] = hexstr[i];
744 if (hexstr[i] == '\\' && hexstr[i + 1] == 'x')
745 {
746 if (i + 3 >= length)
747 continue;
748 /* Get the hex part. */
749 char s_byte[3];
750 int r_byte;
751 s_byte[0] = hexstr[i + 2];
752 s_byte[1] = hexstr[i + 3];
753 s_byte[2] = '\0';
754 /* Read it as an integer */
755 sscanf(s_byte, "%x", &r_byte);
756 /* Save the value */
757 buffer[written - 1] = r_byte;
758 /* Adjust index */
759 i += 3;
760 }
761 }
762
763 return written;
764}
765

Callers 4

GetWindowsSigPtrFunction · 0.70
GetLinuxSigPtrFunction · 0.70
checkSigStringWFunction · 0.70
checkSigStringLFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected