MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / qrcodegen_makeEci

Function qrcodegen_makeEci

modules/data/qrcode/qrcodegen.c:858–879  ·  view source on GitHub ↗

Public function - see documentation comment in header file.

Source from the content-addressed store, hash-verified

856
857// Public function - see documentation comment in header file.
858struct qrcodegen_Segment qrcodegen_makeEci(long assignVal, uint8_t buf[]) {
859 struct qrcodegen_Segment result;
860 result.mode = qrcodegen_Mode_ECI;
861 result.numChars = 0;
862 result.bitLength = 0;
863 if (0 <= assignVal && assignVal < (1 << 7)) {
864 memset(buf, 0, 1 * sizeof(buf[0]));
865 appendBitsToBuffer(assignVal, 8, buf, &result.bitLength);
866 } else if ((1 << 7) <= assignVal && assignVal < (1 << 14)) {
867 memset(buf, 0, 2 * sizeof(buf[0]));
868 appendBitsToBuffer(2, 2, buf, &result.bitLength);
869 appendBitsToBuffer(assignVal, 14, buf, &result.bitLength);
870 } else if ((1 << 14) <= assignVal && assignVal < 1000000L) {
871 memset(buf, 0, 3 * sizeof(buf[0]));
872 appendBitsToBuffer(6, 3, buf, &result.bitLength);
873 appendBitsToBuffer(assignVal >> 10, 11, buf, &result.bitLength);
874 appendBitsToBuffer(assignVal & 0x3FF, 10, buf, &result.bitLength);
875 } else
876 assert(false);
877 result.data = buf;
878 return result;
879}
880
881
882// Public function - see documentation comment in header file.

Callers

nothing calls this directly

Calls 2

appendBitsToBufferFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected