Shellminator  V1.2.0
Simple Terminal
Loading...
Searching...
No Matches
qrcodegen.c File Reference
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include "qrcodegen.h"

Go to the source code of this file.

Macros

#define testable   static
 
#define qrcodegen_REED_SOLOMON_DEGREE_MAX   30
 

Functions

testable void appendBitsToBuffer (unsigned int val, int numBits, uint8_t buffer[], int *bitLen)
 
testable void addEccAndInterleave (uint8_t data[], int version, enum qrcodegen_Ecc ecl, uint8_t result[])
 
testable int getNumDataCodewords (int version, enum qrcodegen_Ecc ecl)
 
testable int getNumRawDataModules (int ver)
 
testable void reedSolomonComputeDivisor (int degree, uint8_t result[])
 
testable void reedSolomonComputeRemainder (const uint8_t data[], int dataLen, const uint8_t generator[], int degree, uint8_t result[])
 
testable uint8_t reedSolomonMultiply (uint8_t x, uint8_t y)
 
testable void initializeFunctionModules (int version, uint8_t qrcode[])
 
testable int getAlignmentPatternPositions (int version, uint8_t result[7])
 
testable bool getModuleBounded (const uint8_t qrcode[], int x, int y)
 
testable void setModuleBounded (uint8_t qrcode[], int x, int y, bool isDark)
 
testable void setModuleUnbounded (uint8_t qrcode[], int x, int y, bool isDark)
 
testable int calcSegmentBitLength (enum qrcodegen_Mode mode, size_t numChars)
 
testable int getTotalBits (const struct qrcodegen_Segment segs[], size_t len, int version)
 
bool qrcodegen_encodeText (const char *text, uint8_t tempBuffer[], uint8_t qrcode[], enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, enum qrcodegen_Mask mask, bool boostEcl)
 
bool qrcodegen_encodeBinary (uint8_t dataAndTemp[], size_t dataLen, uint8_t qrcode[], enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, enum qrcodegen_Mask mask, bool boostEcl)
 
bool qrcodegen_encodeSegments (const struct qrcodegen_Segment segs[], size_t len, enum qrcodegen_Ecc ecl, uint8_t tempBuffer[], uint8_t qrcode[])
 
bool qrcodegen_encodeSegmentsAdvanced (const struct qrcodegen_Segment segs[], size_t len, enum qrcodegen_Ecc ecl, int minVersion, int maxVersion, enum qrcodegen_Mask mask, bool boostEcl, uint8_t tempBuffer[], uint8_t qrcode[])
 
int qrcodegen_getSize (const uint8_t qrcode[])
 
bool qrcodegen_getModule (const uint8_t qrcode[], int x, int y)
 
bool qrcodegen_isNumeric (const char *text)
 
bool qrcodegen_isAlphanumeric (const char *text)
 
size_t qrcodegen_calcSegmentBufferSize (enum qrcodegen_Mode mode, size_t numChars)
 
struct qrcodegen_Segment qrcodegen_makeBytes (const uint8_t data[], size_t len, uint8_t buf[])
 
struct qrcodegen_Segment qrcodegen_makeNumeric (const char *digits, uint8_t buf[])
 
struct qrcodegen_Segment qrcodegen_makeAlphanumeric (const char *text, uint8_t buf[])
 
struct qrcodegen_Segment qrcodegen_makeEci (long assignVal, uint8_t buf[])
 

Variables

testable const int8_t ECC_CODEWORDS_PER_BLOCK [4][41]
 
testable const int8_t NUM_ERROR_CORRECTION_BLOCKS [4][41]
 

Macro Definition Documentation

◆ qrcodegen_REED_SOLOMON_DEGREE_MAX

#define qrcodegen_REED_SOLOMON_DEGREE_MAX   30

Definition at line 106 of file qrcodegen.c.

◆ testable

#define testable   static

Definition at line 31 of file qrcodegen.c.

Function Documentation

◆ addEccAndInterleave()

testable void addEccAndInterleave ( uint8_t  data[],
int  version,
enum qrcodegen_Ecc  ecl,
uint8_t  result[] 
)

Definition at line 294 of file qrcodegen.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ appendBitsToBuffer()

testable void appendBitsToBuffer ( unsigned int  val,
int  numBits,
uint8_t  buffer[],
int *  bitLen 
)

Definition at line 185 of file qrcodegen.c.

Here is the caller graph for this function:

◆ calcSegmentBitLength()

testable int calcSegmentBitLength ( enum qrcodegen_Mode  mode,
size_t  numChars 
)

Definition at line 849 of file qrcodegen.c.

Here is the caller graph for this function:

◆ getAlignmentPatternPositions()

testable int getAlignmentPatternPositions ( int  version,
uint8_t  result[7] 
)

Definition at line 550 of file qrcodegen.c.

Here is the caller graph for this function:

◆ getModuleBounded()

testable bool getModuleBounded ( const uint8_t  qrcode[],
int  x,
int  y 
)

Definition at line 770 of file qrcodegen.c.

Here is the caller graph for this function:

◆ getNumDataCodewords()

testable int getNumDataCodewords ( int  version,
enum qrcodegen_Ecc  ecl 
)

Definition at line 327 of file qrcodegen.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNumRawDataModules()

testable int getNumRawDataModules ( int  ver)

Definition at line 339 of file qrcodegen.c.

Here is the caller graph for this function:

◆ getTotalBits()

testable int getTotalBits ( const struct qrcodegen_Segment  segs[],
size_t  len,
int  version 
)

Definition at line 988 of file qrcodegen.c.

Here is the caller graph for this function:

◆ initializeFunctionModules()

testable void initializeFunctionModules ( int  version,
uint8_t  qrcode[] 
)

Definition at line 418 of file qrcodegen.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ qrcodegen_calcSegmentBufferSize()

size_t qrcodegen_calcSegmentBufferSize ( enum qrcodegen_Mode  mode,
size_t  numChars 
)

Definition at line 832 of file qrcodegen.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ qrcodegen_encodeBinary()

bool qrcodegen_encodeBinary ( uint8_t  dataAndTemp[],
size_t  dataLen,
uint8_t  qrcode[],
enum qrcodegen_Ecc  ecl,
int  minVersion,
int  maxVersion,
enum qrcodegen_Mask  mask,
bool  boostEcl 
)

Definition at line 167 of file qrcodegen.c.

Here is the call graph for this function:

◆ qrcodegen_encodeSegments()

bool qrcodegen_encodeSegments ( const struct qrcodegen_Segment  segs[],
size_t  len,
enum qrcodegen_Ecc  ecl,
uint8_t  tempBuffer[],
uint8_t  qrcode[] 
)

Definition at line 196 of file qrcodegen.c.

Here is the call graph for this function:

◆ qrcodegen_encodeSegmentsAdvanced()

bool qrcodegen_encodeSegmentsAdvanced ( const struct qrcodegen_Segment  segs[],
size_t  len,
enum qrcodegen_Ecc  ecl,
int  minVersion,
int  maxVersion,
enum qrcodegen_Mask  mask,
bool  boostEcl,
uint8_t  tempBuffer[],
uint8_t  qrcode[] 
)

Definition at line 204 of file qrcodegen.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ qrcodegen_encodeText()

bool qrcodegen_encodeText ( const char *  text,
uint8_t  tempBuffer[],
uint8_t  qrcode[],
enum qrcodegen_Ecc  ecl,
int  minVersion,
int  maxVersion,
enum qrcodegen_Mask  mask,
bool  boostEcl 
)

Definition at line 129 of file qrcodegen.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ qrcodegen_getModule()

bool qrcodegen_getModule ( const uint8_t  qrcode[],
int  x,
int  y 
)

Definition at line 762 of file qrcodegen.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ qrcodegen_getSize()

int qrcodegen_getSize ( const uint8_t  qrcode[])

Definition at line 752 of file qrcodegen.c.

Here is the caller graph for this function:

◆ qrcodegen_isAlphanumeric()

bool qrcodegen_isAlphanumeric ( const char *  text)

Definition at line 821 of file qrcodegen.c.

Here is the caller graph for this function:

◆ qrcodegen_isNumeric()

bool qrcodegen_isNumeric ( const char *  text)

Definition at line 810 of file qrcodegen.c.

Here is the caller graph for this function:

◆ qrcodegen_makeAlphanumeric()

struct qrcodegen_Segment qrcodegen_makeAlphanumeric ( const char *  text,
uint8_t  buf[] 
)

Definition at line 925 of file qrcodegen.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ qrcodegen_makeBytes()

struct qrcodegen_Segment qrcodegen_makeBytes ( const uint8_t  data[],
size_t  len,
uint8_t  buf[] 
)

Definition at line 876 of file qrcodegen.c.

Here is the call graph for this function:

◆ qrcodegen_makeEci()

struct qrcodegen_Segment qrcodegen_makeEci ( long  assignVal,
uint8_t  buf[] 
)

Definition at line 959 of file qrcodegen.c.

Here is the call graph for this function:

◆ qrcodegen_makeNumeric()

struct qrcodegen_Segment qrcodegen_makeNumeric ( const char *  digits,
uint8_t  buf[] 
)

Definition at line 891 of file qrcodegen.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reedSolomonComputeDivisor()

testable void reedSolomonComputeDivisor ( int  degree,
uint8_t  result[] 
)

Definition at line 358 of file qrcodegen.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reedSolomonComputeRemainder()

testable void reedSolomonComputeRemainder ( const uint8_t  data[],
int  dataLen,
const uint8_t  generator[],
int  degree,
uint8_t  result[] 
)

Definition at line 384 of file qrcodegen.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reedSolomonMultiply()

testable uint8_t reedSolomonMultiply ( uint8_t  x,
uint8_t  y 
)

Definition at line 402 of file qrcodegen.c.

Here is the caller graph for this function:

◆ setModuleBounded()

testable void setModuleBounded ( uint8_t  qrcode[],
int  x,
int  y,
bool  isDark 
)

Definition at line 779 of file qrcodegen.c.

Here is the caller graph for this function:

◆ setModuleUnbounded()

testable void setModuleUnbounded ( uint8_t  qrcode[],
int  x,
int  y,
bool  isDark 
)

Definition at line 793 of file qrcodegen.c.

Here is the call graph for this function:

Variable Documentation

◆ ECC_CODEWORDS_PER_BLOCK

testable const int8_t ECC_CODEWORDS_PER_BLOCK[4][41]
Initial value:
= {
{-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30},
{-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28},
{-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30},
{-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30},
}

Definition at line 97 of file qrcodegen.c.

◆ NUM_ERROR_CORRECTION_BLOCKS

testable const int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41]
Initial value:
= {
{-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25},
{-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49},
{-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68},
{-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81},
}

Definition at line 109 of file qrcodegen.c.