diff --git a/c/qrcodegen.c b/c/qrcodegen.c index 2caa09a..f0ba258 100644 --- a/c/qrcodegen.c +++ b/c/qrcodegen.c @@ -84,7 +84,7 @@ static const int PENALTY_N4 = 10; -/*---- Function implementations ----*/ +/*---- Top-level QR Code encoding functions ----*/ // Public function - see documentation comment in header file. int qrcodegen_encodeText(const char *text, uint8_t tempBuffer[], uint8_t qrcode[], @@ -395,6 +395,9 @@ static int getNumDataCodewords(int version, enum qrcodegen_Ecc ecl) { } + +/*---- Basic QR Code information functions ----*/ + // Public function - see documentation comment in header file. int qrcodegen_getSize(int version) { assert(1 <= version && version <= 40); @@ -439,6 +442,9 @@ static void setModuleBounded(uint8_t qrcode[], int size, int x, int y, bool isBl } + +/*---- QR Code drawing functions ----*/ + // Fills the given QR Code grid with white modules for the given version's size, // then marks every function module in the QR Code as black. static void initializeFunctionalModules(int version, uint8_t qrcode[]) { @@ -707,6 +713,9 @@ static void drawCodewords(const uint8_t data[], int dataLen, uint8_t qrcode[], i } + +/*---- Reed-Solomon ECC generator functions ----*/ + // XORs the data modules in this QR Code with the given mask pattern. Due to XOR's mathematical // properties, calling applyMask(m) twice with the same value is equivalent to no change at all. // This means it is possible to apply a mask, undo it, and try another mask. Note that a final diff --git a/c/qrcodegen.h b/c/qrcodegen.h index 4d3bebe..069f836 100644 --- a/c/qrcodegen.h +++ b/c/qrcodegen.h @@ -28,6 +28,8 @@ #include +/*---- Enumeration types and constants ----*/ + /* * Represents the error correction level used in a QR Code symbol. */ @@ -55,6 +57,9 @@ enum qrcodegen_Mask { }; + +/*---- Macro constants and functions ----*/ + // Calculates the number of bytes needed to store any QR Code up to and including the given version number, // as a compile-time constant. For example, 'uint8_t buffer[qrcodegen_BUFFER_LEN_FOR_VERSION(25)];' // can store any single QR Code from version 1 to 25, inclusive. @@ -64,6 +69,9 @@ enum qrcodegen_Mask { #define qrcodegen_BUFFER_LEN_MAX qrcodegen_BUFFER_LEN_FOR_VERSION(40) + +/*---- Top-level QR Code functions ----*/ + /* * Encodes the given text data to a QR Code symbol, returning the actual version number used. * If the data is too long to fit in any version in the given range at the given ECC level, @@ -85,6 +93,9 @@ int 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); + +/*---- Low-level QR Code functions ----*/ + /* * Returns the side length of any QR Code of the given version. * The version must be in the range [1, 40]. The result is in the range [21, 177].