MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / output_hex_blob

Function output_hex_blob

modules/dasSQLITE/sqlite/shell.c:16802–16821  ·  view source on GitHub ↗

** Output the given string as a hex-encoded blob (eg. X'1234' ) */

Source from the content-addressed store, hash-verified

16800** Output the given string as a hex-encoded blob (eg. X'1234' )
16801*/
16802static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
16803 int i;
16804 unsigned char *aBlob = (unsigned char*)pBlob;
16805
16806 char *zStr = sqlite3_malloc(nBlob*2 + 1);
16807 shell_check_oom(zStr);
16808
16809 for(i=0; i<nBlob; i++){
16810 static const char aHex[] = {
16811 '0', '1', '2', '3', '4', '5', '6', '7',
16812 '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
16813 };
16814 zStr[i*2] = aHex[ (aBlob[i] >> 4) ];
16815 zStr[i*2+1] = aHex[ (aBlob[i] & 0x0F) ];
16816 }
16817 zStr[i*2] = '\0';
16818
16819 raw_printf(out,"X'%s'", zStr);
16820 sqlite3_free(zStr);
16821}
16822
16823/*
16824** Find a string that is not found anywhere in z[]. Return a pointer

Callers 1

shell_callbackFunction · 0.85

Calls 1

shell_check_oomFunction · 0.85

Tested by

no test coverage detected