MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / parseblob

Function parseblob

lua/lparser.c:140–152  ·  view source on GitHub ↗

assumption: out is sufficiently big */

Source from the content-addressed store, hash-verified

138
139/* assumption: out is sufficiently big */
140int parseblob(const char *s, int len, char *out) {
141 if (len % 2 != 0) return 1;
142 int i;
143 for (i = 0; i < len; i += 2) {
144 char v1 = tolower(s[i]), v0 = tolower(s[i + 1]);
145 if (!isalnum(v1) || ! isalnum(v0)) return 1;
146 v1 = isalpha(v1) ? v1 - 'a' + 10 : v1 - '0';
147 v0 = isalpha(v0) ? v0 - 'a' + 10 : v0 - '0';
148 if (v1 > 0xf || v0 > 0xf) return 1;
149 out[i / 2] = (v1 << 4) | v0;
150 }
151 return 0;
152}
153
154
155static void codeblob(LexState *ls, expdesc *e, TString *s) {

Callers 2

getargFunction · 0.85
codeblobFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected