qrencode  4.1.1
About: libqrencode is a fast and compact library and command-line utility for encoding data in a QR Code symbol.
  Fossies Dox: qrencode-4.1.1.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

mqrspec.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "mqrspec.h"
Include dependency graph for mqrspec.c:

Go to the source code of this file.

Data Structures

struct  MQRspec_Capacity
 Version and capacity. More...
 

Functions

int MQRspec_getDataLengthBit (int version, QRecLevel level)
 Return maximum data code length (bits) for the version. More...
 
int MQRspec_getDataLength (int version, QRecLevel level)
 Return maximum data code length (bytes) for the version. More...
 
int MQRspec_getECCLength (int version, QRecLevel level)
 Return maximum error correction code length (bytes) for the version. More...
 
int MQRspec_getWidth (int version)
 Return the width of the symbol for the version. More...
 
int MQRspec_lengthIndicator (QRencodeMode mode, int version)
 Length indicator. More...
 
int MQRspec_maximumWords (QRencodeMode mode, int version)
 Return the maximum length for the mode and version. More...
 
unsigned int MQRspec_getFormatInfo (int mask, int version, QRecLevel level)
 Format information. More...
 
static void putFinderPattern (unsigned char *frame, int width, int ox, int oy)
 Frame. More...
 
static unsigned char * MQRspec_createFrame (int version)
 
unsigned char * MQRspec_newFrame (int version)
 Frame. More...
 

Variables

static const MQRspec_Capacity mqrspecCapacity [4+1]
 Table of the capacity of symbols See Table 1 (pp.106) and Table 8 (pp.113) of Appendix 1, JIS X0510:2004. More...
 
static const int lengthTableBits [4][4]
 Length indicator. More...
 
static const unsigned int formatInfo [4][8]
 Format information. More...
 
static const int typeTable [4+1][3]
 

Function Documentation

◆ MQRspec_createFrame()

static unsigned char * MQRspec_createFrame ( int  version)
static

Definition at line 187 of file mqrspec.c.

References mqrspecCapacity, putFinderPattern(), version, and MQRspec_Capacity::width.

Referenced by MQRspec_newFrame().

◆ MQRspec_getDataLength()

int MQRspec_getDataLength ( int  version,
QRecLevel  level 
)

Return maximum data code length (bytes) for the version.

Parameters
versionversion of the symbol
levelerror correction level
Returns
maximum size (bytes)

Definition at line 70 of file mqrspec.c.

References level, MQRspec_getDataLengthBit(), and version.

Referenced by MQRraw_new().

◆ MQRspec_getDataLengthBit()

int MQRspec_getDataLengthBit ( int  version,
QRecLevel  level 
)

Return maximum data code length (bits) for the version.

Parameters
versionversion of the symbol
levelerror correction level
Returns
maximum size (bits)

Definition at line 59 of file mqrspec.c.

References MQRspec_Capacity::ec, level, mqrspecCapacity, version, and MQRspec_Capacity::width.

Referenced by MQRraw_new(), MQRspec_getDataLength(), and QRinput_appendPaddingBitMQR().

◆ MQRspec_getECCLength()

int MQRspec_getECCLength ( int  version,
QRecLevel  level 
)

Return maximum error correction code length (bytes) for the version.

Parameters
versionversion of the symbol
levelerror correction level
Returns
ECC size (bytes)

Definition at line 75 of file mqrspec.c.

References MQRspec_Capacity::ec, level, mqrspecCapacity, and version.

Referenced by MQRraw_new(), QRinput_newMQR(), and QRinput_setVersionAndErrorCorrectionLevel().

◆ MQRspec_getFormatInfo()

unsigned int MQRspec_getFormatInfo ( int  mask,
int  version,
QRecLevel  level 
)

Format information.

Return BCH encoded format information pattern.

Parameters
maskmask number
versionversion of the symbol
levelerror correction level
Returns
BCH encoded format information pattern

Definition at line 139 of file mqrspec.c.

References formatInfo, level, MQRSPEC_VERSION_MAX, QR_ECLEVEL_H, typeTable, and version.

Referenced by MMask_writeFormatInformation().

◆ MQRspec_getWidth()

int MQRspec_getWidth ( int  version)

Return the width of the symbol for the version.

Parameters
versionversion of the symbol
Returns
width

Definition at line 80 of file mqrspec.c.

References mqrspecCapacity, version, and MQRspec_Capacity::width.

Referenced by MMask_makeMask(), MMask_mask(), and QRcode_encodeMaskMQR().

◆ MQRspec_lengthIndicator()

int MQRspec_lengthIndicator ( QRencodeMode  mode,
int  version 
)

Length indicator.

Return the size of length indicator for the mode and version.

Parameters
modeencode mode
versionvesion of the symbol
Returns
the size of the appropriate length indicator (bits).

Definition at line 99 of file mqrspec.c.

References lengthTableBits, and version.

Referenced by QRinput_encodeMode8(), QRinput_encodeModeAn(), QRinput_encodeModeKanji(), QRinput_encodeModeNum(), and QRinput_estimateBitStreamSizeOfEntry().

◆ MQRspec_maximumWords()

int MQRspec_maximumWords ( QRencodeMode  mode,
int  version 
)

Return the maximum length for the mode and version.

Parameters
modeencode mode
versionvesion of the symbol
Returns
the maximum length (bytes)

Definition at line 104 of file mqrspec.c.

References lengthTableBits, QR_MODE_KANJI, and version.

Referenced by QRinput_encodeBitStream().

◆ MQRspec_newFrame()

unsigned char * MQRspec_newFrame ( int  version)

Frame.

Return a copy of initialized frame.

Parameters
versionversion of the symbol
Returns
Array of unsigned char. You can free it by free().

Definition at line 227 of file mqrspec.c.

References MQRspec_createFrame(), MQRSPEC_VERSION_MAX, and version.

Referenced by QRcode_encodeMaskMQR().

◆ putFinderPattern()

static void putFinderPattern ( unsigned char *  frame,
int  width,
int  ox,
int  oy 
)
static

Frame.

Put a finder pattern.

Parameters
frame
width
ox,oyupper-left coordinate of the pattern

Definition at line 162 of file mqrspec.c.

Referenced by MQRspec_createFrame().

Variable Documentation

◆ formatInfo

const unsigned int formatInfo[4][8]
static
Initial value:
= {
{0x4445, 0x55ae, 0x6793, 0x7678, 0x06de, 0x1735, 0x2508, 0x34e3},
{0x4172, 0x5099, 0x62a4, 0x734f, 0x03e9, 0x1202, 0x203f, 0x31d4},
{0x4e2b, 0x5fc0, 0x6dfd, 0x7c16, 0x0cb0, 0x1d5b, 0x2f66, 0x3e8d},
{0x4b1c, 0x5af7, 0x68ca, 0x7921, 0x0987, 0x186c, 0x2a51, 0x3bba}
}

Format information.

Definition at line 123 of file mqrspec.c.

Referenced by MQRspec_getFormatInfo().

◆ lengthTableBits

const int lengthTableBits[4][4]
static
Initial value:
= {
{ 3, 4, 5, 6},
{ 0, 3, 4, 5},
{ 0, 0, 4, 5},
{ 0, 0, 3, 4}
}

Length indicator.

See Table 3 (pp.107) of Appendix 1, JIS X0510:2004.

Definition at line 92 of file mqrspec.c.

Referenced by MQRspec_lengthIndicator(), and MQRspec_maximumWords().

◆ mqrspecCapacity

const MQRspec_Capacity mqrspecCapacity[4+1]
static
Initial value:
= {
{ 0, {0, 0, 0, 0}},
{ 11, {2, 0, 0, 0}},
{ 13, {5, 6, 0, 0}},
{ 15, {6, 8, 0, 0}},
{ 17, {8, 10, 14, 0}}
}

Table of the capacity of symbols See Table 1 (pp.106) and Table 8 (pp.113) of Appendix 1, JIS X0510:2004.

Definition at line 51 of file mqrspec.c.

Referenced by MQRspec_createFrame(), MQRspec_getDataLengthBit(), MQRspec_getECCLength(), and MQRspec_getWidth().

◆ typeTable

const int typeTable[4+1][3]
static
Initial value:
= {
{-1, -1, -1},
{ 0, -1, -1},
{ 1, 2, -1},
{ 3, 4, -1},
{ 5, 6, 7}
}

Definition at line 131 of file mqrspec.c.

Referenced by MQRspec_getFormatInfo().