MCPcopy Create free account
hub / github.com/antirez/ds4 / web_url_encode

Function web_url_encode

ds4_web.c:305–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303static char *web_json_get_string(const char *json, const char *key);
304
305static char *web_url_encode(const char *s) {
306 static const char hex[] = "0123456789ABCDEF";
307 web_buf b = {0};
308 for (const unsigned char *p = (const unsigned char *)s; p && *p; p++) {
309 unsigned char c = *p;
310 if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') {
311 web_buf_append(&b, (const char *)&c, 1);
312 } else {
313 char e[3] = {'%', hex[c >> 4], hex[c & 15]};
314 web_buf_append(&b, e, 3);
315 }
316 }
317 return web_buf_take(&b);
318}
319
320static void web_random_bytes(unsigned char *buf, size_t len) {
321 int fd = open("/dev/urandom", O_RDONLY);

Callers 2

web_close_tabFunction · 0.85
ds4_web_google_searchFunction · 0.85

Calls 2

web_buf_appendFunction · 0.85
web_buf_takeFunction · 0.85

Tested by

no test coverage detected