MCPcopy Create free account
hub / github.com/acl-dev/acl / encode

Function encode

lib_acl_cpp/samples/mqtt/mqtt_length/main.cpp:24–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24static int encode(unsigned n, unsigned char *buf) {
25 int len = 0;
26 if (n < 128) {
27 buf[len++] = n & 0x7f;
28 } else if (n < 16384) {
29 buf[len++] = ((unsigned char) n & 0x7f) | 0x80;
30 buf[len++] = ((unsigned char) (n >> 7) & 0x7f);
31 } else if (n < 2097152) {
32 buf[len++] = ((unsigned char) n & 0x7f) | 0x80;
33 buf[len++] = ((unsigned char) (n >> 7 ) & 0x7f) | 0x80;
34 buf[len++] = ((unsigned char) (n >> 14) & 0x7f);
35 } else if (n < 268435456) {
36 buf[len++] = ((unsigned char) n & 0x7f) | 0x80;
37 buf[len++] = ((unsigned char) (n >> 7 ) & 0x7f) | 0x80;
38 buf[len++] = ((unsigned char) (n >> 14) & 0x7f) | 0x80;
39 buf[len++] = ((unsigned char) (n >> 21) & 0x7f);
40 } else {
41 printf("invalid dlen_=%u\n", n);
42 return -1;
43 }
44
45 return len;
46}
47
48int main(void) {
49 unsigned char buf[4];

Callers 13

mainFunction · 0.85
url_coder.cppFile · 0.85
rfc2047_encodeMethod · 0.85
append_addrMethod · 0.85
append_subjectMethod · 0.85
encode_updateMethod · 0.85
encode_finishMethod · 0.85
encode_updateMethod · 0.85
encode_finishMethod · 0.85
upload.cppFile · 0.85
add_bodyMethod · 0.85
add_attachMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…