TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
Functions | Variables
qrinput.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "qrencode.h"
#include "qrspec.h"
#include "mqrspec.h"
#include "bitstream.h"
#include "qrinput.h"

Go to the source code of this file.

Functions

int QRinput_isSplittableMode (QRencodeMode mode)
 
static QRinput_ListQRinput_List_newEntry (QRencodeMode mode, int size, const unsigned char *data)
 
static void QRinput_List_freeEntry (QRinput_List *entry)
 
static QRinput_ListQRinput_List_dup (QRinput_List *entry)
 
QRinputQRinput_new (void)
 Instantiate an input data object. More...
 
QRinputQRinput_new2 (int version, QRecLevel level)
 Instantiate an input data object. More...
 
QRinputQRinput_newMQR (int version, QRecLevel level)
 Instantiate an input data object. More...
 
int QRinput_getVersion (QRinput *input)
 Get current version. More...
 
int QRinput_setVersion (QRinput *input, int version)
 Set version of the QR code that is to be encoded. More...
 
QRecLevel QRinput_getErrorCorrectionLevel (QRinput *input)
 Get current error correction level. More...
 
int QRinput_setErrorCorrectionLevel (QRinput *input, QRecLevel level)
 Set error correction level of the QR code that is to be encoded. More...
 
int QRinput_setVersionAndErrorCorrectionLevel (QRinput *input, int version, QRecLevel level)
 Set version and error correction level of the QR code at once. More...
 
static void QRinput_appendEntry (QRinput *input, QRinput_List *entry)
 
int QRinput_append (QRinput *input, QRencodeMode mode, int size, const unsigned char *data)
 Append data to an input object. More...
 
STATIC_IN_RELEASE int QRinput_insertStructuredAppendHeader (QRinput *input, int size, int number, unsigned char parity)
 Insert a structured-append header to the head of the input data. More...
 
int QRinput_appendECIheader (QRinput *input, unsigned int ecinum)
 Append ECI header. More...
 
void QRinput_free (QRinput *input)
 Free the input object. More...
 
static unsigned char QRinput_calcParity (QRinput *input)
 
QRinputQRinput_dup (QRinput *input)
 
static int QRinput_checkModeNum (int size, const char *data)
 Check the input data. More...
 
int QRinput_estimateBitsModeNum (int size)
 Estimate the length of the encoded bit stream of numeric data. More...
 
static int QRinput_encodeModeNum (QRinput_List *entry, BitStream *bstream, int version, int mqr)
 Convert the number data and append to a bit stream. More...
 
static int QRinput_checkModeAn (int size, const char *data)
 Check the input data. More...
 
int QRinput_estimateBitsModeAn (int size)
 Estimate the length of the encoded bit stream of alphabet-numeric data. More...
 
static int QRinput_encodeModeAn (QRinput_List *entry, BitStream *bstream, int version, int mqr)
 Convert the alphabet-numeric data and append to a bit stream. More...
 
int QRinput_estimateBitsMode8 (int size)
 Estimate the length of the encoded bit stream of 8 bit data. More...
 
static int QRinput_encodeMode8 (QRinput_List *entry, BitStream *bstream, int version, int mqr)
 Convert the 8bits data and append to a bit stream. More...
 
int QRinput_estimateBitsModeKanji (int size)
 Estimate the length of the encoded bit stream of kanji data. More...
 
static int QRinput_checkModeKanji (int size, const unsigned char *data)
 Check the input data. More...
 
static int QRinput_encodeModeKanji (QRinput_List *entry, BitStream *bstream, int version, int mqr)
 Convert the kanji data and append to a bit stream. More...
 
static int QRinput_encodeModeStructure (QRinput_List *entry, BitStream *bstream, int mqr)
 Convert a structure symbol code and append to a bit stream. More...
 
static int QRinput_checkModeFNC1Second (int size)
 
static int QRinput_encodeModeFNC1Second (QRinput_List *entry, BitStream *bstream)
 
static unsigned int QRinput_decodeECIfromByteArray (unsigned char *data)
 
static int QRinput_estimateBitsModeECI (unsigned char *data)
 
static int QRinput_encodeModeECI (QRinput_List *entry, BitStream *bstream)
 
int QRinput_check (QRencodeMode mode, int size, const unsigned char *data)
 Validate the input data. More...
 
static int QRinput_estimateBitStreamSizeOfEntry (QRinput_List *entry, int version, int mqr)
 Estimate the length of the encoded bit stream on the current version. More...
 
STATIC_IN_RELEASE int QRinput_estimateBitStreamSize (QRinput *input, int version)
 Estimate the length of the encoded bit stream of the data. More...
 
STATIC_IN_RELEASE int QRinput_estimateVersion (QRinput *input)
 Estimate the required version number of the symbol. More...
 
STATIC_IN_RELEASE int QRinput_lengthOfCode (QRencodeMode mode, int version, int bits)
 Return required length in bytes for specified mode, version and bits. More...
 
static int QRinput_encodeBitStream (QRinput_List *entry, BitStream *bstream, int version, int mqr)
 Convert the input data in the data chunk and append to a bit stream. More...
 
static int QRinput_createBitStream (QRinput *input, BitStream *bstream)
 Convert the input data to a bit stream. More...
 
static int QRinput_convertData (QRinput *input, BitStream *bstream)
 Convert the input data to a bit stream. More...
 
static int QRinput_appendPaddingBit (BitStream *bstream, QRinput *input)
 Append padding bits for the input data. More...
 
static int QRinput_appendPaddingBitMQR (BitStream *bstream, QRinput *input)
 Append padding bits for the input data - Micro QR Code version. More...
 
static int QRinput_insertFNC1Header (QRinput *input)
 
STATIC_IN_RELEASE int QRinput_mergeBitStream (QRinput *input, BitStream *bstream)
 Merge all bit streams in the input data. More...
 
STATIC_IN_RELEASE int QRinput_getBitStream (QRinput *input, BitStream *bstream)
 Merge all bit streams in the input data and append padding bits. More...
 
unsigned char * QRinput_getByteStream (QRinput *input)
 Pack all bit streams padding bits into a byte array. More...
 
static QRinput_InputListQRinput_InputList_newEntry (QRinput *input)
 
static void QRinput_InputList_freeEntry (QRinput_InputList *entry)
 
QRinput_StructQRinput_Struct_new (void)
 Instantiate a set of input data object. More...
 
void QRinput_Struct_setParity (QRinput_Struct *s, unsigned char parity)
 Set parity of structured symbols. More...
 
int QRinput_Struct_appendInput (QRinput_Struct *s, QRinput *input)
 Append a QRinput object to the set. More...
 
void QRinput_Struct_free (QRinput_Struct *s)
 Free all of QRinput in the set. More...
 
static unsigned char QRinput_Struct_calcParity (QRinput_Struct *s)
 
static int QRinput_List_shrinkEntry (QRinput_List *entry, int bytes)
 
STATIC_IN_RELEASE int QRinput_splitEntry (QRinput_List *entry, int bytes)
 
QRinput_StructQRinput_splitQRinputToStruct (QRinput *input)
 Split a QRinput to QRinput_Struct. More...
 
int QRinput_Struct_insertStructuredAppendHeaders (QRinput_Struct *s)
 Insert structured-append headers to the input structure. More...
 
int QRinput_setFNC1First (QRinput *input)
 Set FNC1-1st position flag. More...
 
int QRinput_setFNC1Second (QRinput *input, unsigned char appid)
 Set FNC1-2nd position flag and application identifier. More...
 

Variables

const signed char QRinput_anTable [128]
 

Function Documentation

int QRinput_append ( QRinput input,
QRencodeMode  mode,
int  size,
const unsigned char *  data 
)

Append data to an input object.

The data is copied and appended to the input object.

Parameters
inputinput object.
modeencoding mode.
sizesize of data (byte).
dataa pointer to the memory area of the input data.
Return values
0success.
-1an error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
ENOMEMunable to allocate memory.
EINVALinput data is invalid.

Definition at line 221 of file qrinput.c.

References QRinput_appendEntry(), and QRinput_List_newEntry().

Referenced by QRcode_encodeDataReal(), QRcode_encodeDataStructuredReal(), QRinput_appendECIheader(), Split_eat8(), Split_eatAn(), Split_eatKanji(), and Split_eatNum().

int QRinput_appendECIheader ( QRinput input,
unsigned int  ecinum 
)

Append ECI header.

Parameters
inputinput object.
ecinumECI indicator number (0 - 999999)
Return values
0success.
-1an error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
ENOMEMunable to allocate memory.
EINVALinput data is invalid.

Definition at line 274 of file qrinput.c.

References QR_MODE_ECI, and QRinput_append().

static void QRinput_appendEntry ( QRinput input,
QRinput_List entry 
)
static

Definition at line 209 of file qrinput.c.

References _QRinput::head, _QRinput_List::next, and _QRinput::tail.

Referenced by QRinput_append(), and QRinput_dup().

static int QRinput_appendPaddingBit ( BitStream bstream,
QRinput input 
)
static

Append padding bits for the input data.

Parameters
bstreamBitstream to be appended.
inputinput data.
Return values
0success
-1an error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
ERANGEinput data is too large.
ENOMEMunable to allocate memory.

Definition at line 1145 of file qrinput.c.

References BitStream_appendNum(), BitStream_size, int(), _QRinput::level, QRspec_getDataLength(), and _QRinput::version.

Referenced by QRinput_getBitStream().

static int QRinput_appendPaddingBitMQR ( BitStream bstream,
QRinput input 
)
static

Append padding bits for the input data - Micro QR Code version.

Parameters
bstreamBitstream to be appended.
inputinput data.
Return values
0success
-1an error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
ERANGEinput data is too large.
ENOMEMunable to allocate memory.

Definition at line 1194 of file qrinput.c.

References BitStream_appendNum(), BitStream_size, int(), _QRinput::level, MQRspec_getDataLengthBit(), and _QRinput::version.

Referenced by QRinput_getBitStream().

static unsigned char QRinput_calcParity ( QRinput input)
static
int QRinput_check ( QRencodeMode  mode,
int  size,
const unsigned char *  data 
)

Validate the input data.

Parameters
modeencoding mode.
sizesize of data (byte).
dataa pointer to the memory area of the input data.
Return values
0success.
-1invalid arguments.

Definition at line 817 of file qrinput.c.

References QR_MODE_8, QR_MODE_AN, QR_MODE_ECI, QR_MODE_FNC1FIRST, QR_MODE_FNC1SECOND, QR_MODE_KANJI, QR_MODE_NUL, QR_MODE_NUM, QR_MODE_STRUCTURE, QRinput_checkModeAn(), QRinput_checkModeFNC1Second(), QRinput_checkModeKanji(), and QRinput_checkModeNum().

Referenced by QRinput_List_newEntry().

static int QRinput_checkModeAn ( int  size,
const char *  data 
)
static

Check the input data.

Parameters
size
data
Returns
result

Definition at line 474 of file qrinput.c.

References QRinput_lookAnTable.

Referenced by QRinput_check().

static int QRinput_checkModeFNC1Second ( int  size)
static

Definition at line 730 of file qrinput.c.

Referenced by QRinput_check().

static int QRinput_checkModeKanji ( int  size,
const unsigned char *  data 
)
static

Check the input data.

Parameters
size
data
Returns
result

Definition at line 625 of file qrinput.c.

References int().

Referenced by QRinput_check().

static int QRinput_checkModeNum ( int  size,
const char *  data 
)
static

Check the input data.

Parameters
size
data
Returns
result

Definition at line 362 of file qrinput.c.

Referenced by QRinput_check().

static int QRinput_convertData ( QRinput input,
BitStream bstream 
)
static

Convert the input data to a bit stream.

When the version number is given and that is not sufficient, it is increased automatically.

Parameters
inputinput data.
bstreamwhere the converted data is stored.
Return values
0success
-1an error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
ENOMEMunable to allocate memory.
ERANGEinput data is too large.

Definition at line 1110 of file qrinput.c.

References BitStream_reset, _QRinput::level, QRinput_createBitStream(), QRinput_estimateVersion(), QRinput_getVersion(), QRinput_setVersion(), and QRspec_getMinimumVersion().

Referenced by QRinput_mergeBitStream().

static int QRinput_createBitStream ( QRinput input,
BitStream bstream 
)
static

Convert the input data to a bit stream.

Parameters
inputinput data.
Return values
0success
-1an error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
ENOMEMunable to allocate memory.

Definition at line 1082 of file qrinput.c.

References _QRinput::head, _QRinput::mqr, _QRinput_List::next, QRinput_encodeBitStream(), and _QRinput::version.

Referenced by QRinput_convertData(), and QRinput_mergeBitStream().

static unsigned int QRinput_decodeECIfromByteArray ( unsigned char *  data)
static

Definition at line 755 of file qrinput.c.

Referenced by QRinput_encodeModeECI(), and QRinput_estimateBitsModeECI().

QRinput* QRinput_dup ( QRinput input)
static int QRinput_encodeBitStream ( QRinput_List entry,
BitStream bstream,
int  version,
int  mqr 
)
static
static int QRinput_encodeMode8 ( QRinput_List entry,
BitStream bstream,
int  version,
int  mqr 
)
static

Convert the 8bits data and append to a bit stream.

Parameters
entry
mqr
Return values
0success
-1an error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
ENOMEMunable to allocate memory.

Definition at line 578 of file qrinput.c.

References BitStream_appendBytes(), BitStream_appendNum(), _QRinput_List::data, MQRspec_lengthIndicator(), MQRSPEC_MODEID_8, QR_MODE_8, QRspec_lengthIndicator(), QRSPEC_MODEID_8, and _QRinput_List::size.

Referenced by QRinput_encodeBitStream().

static int QRinput_encodeModeAn ( QRinput_List entry,
BitStream bstream,
int  version,
int  mqr 
)
static

Convert the alphabet-numeric data and append to a bit stream.

Parameters
entry
mqr
Return values
0success
-1an error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
ENOMEMunable to allocate memory.
EINVALinvalid version.

Definition at line 515 of file qrinput.c.

References BitStream_appendNum(), _QRinput_List::data, int(), MQRspec_lengthIndicator(), MQRSPEC_MODEID_AN, QR_MODE_AN, QRinput_lookAnTable, QRspec_lengthIndicator(), QRSPEC_MODEID_AN, and _QRinput_List::size.

Referenced by QRinput_encodeBitStream().

static int QRinput_encodeModeECI ( QRinput_List entry,
BitStream bstream 
)
static
static int QRinput_encodeModeFNC1Second ( QRinput_List entry,
BitStream bstream 
)
static
static int QRinput_encodeModeKanji ( QRinput_List entry,
BitStream bstream,
int  version,
int  mqr 
)
static

Convert the kanji data and append to a bit stream.

Parameters
entry
mqr
Return values
0success
-1an error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
ENOMEMunable to allocate memory.
EINVALinvalid version.

Definition at line 653 of file qrinput.c.

References BitStream_appendNum(), _QRinput_List::data, int(), MQRspec_lengthIndicator(), MQRSPEC_MODEID_KANJI, QR_MODE_KANJI, QRspec_lengthIndicator(), QRSPEC_MODEID_KANJI, and _QRinput_List::size.

Referenced by QRinput_encodeBitStream().

static int QRinput_encodeModeNum ( QRinput_List entry,
BitStream bstream,
int  version,
int  mqr 
)
static

Convert the number data and append to a bit stream.

Parameters
entry
mqr
Return values
0success
-1an error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
ENOMEMunable to allocate memory.

Definition at line 409 of file qrinput.c.

References BitStream_appendNum(), _QRinput_List::data, int(), MQRspec_lengthIndicator(), MQRSPEC_MODEID_NUM, QR_MODE_NUM, QRspec_lengthIndicator(), QRSPEC_MODEID_NUM, and _QRinput_List::size.

Referenced by QRinput_encodeBitStream().

static int QRinput_encodeModeStructure ( QRinput_List entry,
BitStream bstream,
int  mqr 
)
static

Convert a structure symbol code and append to a bit stream.

Parameters
entry
mqr
Return values
0success
-1an error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
ENOMEMunable to allocate memory.
EINVALinvalid entry.

Definition at line 705 of file qrinput.c.

References BitStream_appendNum(), _QRinput_List::data, and QRSPEC_MODEID_STRUCTURE.

Referenced by QRinput_encodeBitStream().

int QRinput_estimateBitsMode8 ( int  size)

Estimate the length of the encoded bit stream of 8 bit data.

Parameters
size
Returns
number of bits

Definition at line 564 of file qrinput.c.

Referenced by QRinput_estimateBitStreamSizeOfEntry(), Split_eat8(), Split_eatAn(), and Split_eatNum().

int QRinput_estimateBitsModeAn ( int  size)

Estimate the length of the encoded bit stream of alphabet-numeric data.

Parameters
size
Returns
number of bits

Definition at line 491 of file qrinput.c.

Referenced by QRinput_estimateBitStreamSizeOfEntry(), Split_eat8(), Split_eatAn(), and Split_eatNum().

static int QRinput_estimateBitsModeECI ( unsigned char *  data)
static
int QRinput_estimateBitsModeKanji ( int  size)

Estimate the length of the encoded bit stream of kanji data.

Parameters
size
Returns
number of bits

Definition at line 614 of file qrinput.c.

Referenced by QRinput_estimateBitStreamSizeOfEntry().

int QRinput_estimateBitsModeNum ( int  size)

Estimate the length of the encoded bit stream of numeric data.

Parameters
size
Returns
number of bits

Definition at line 379 of file qrinput.c.

Referenced by QRinput_estimateBitStreamSizeOfEntry(), Split_eat8(), Split_eatAn(), and Split_eatNum().

STATIC_IN_RELEASE int QRinput_estimateBitStreamSize ( QRinput input,
int  version 
)

Estimate the length of the encoded bit stream of the data.

Parameters
inputinput data
versionversion of the symbol
Returns
number of bits

Definition at line 915 of file qrinput.c.

References _QRinput::head, _QRinput::mqr, _QRinput_List::next, and QRinput_estimateBitStreamSizeOfEntry().

Referenced by QRinput_estimateVersion().

static int QRinput_estimateBitStreamSizeOfEntry ( QRinput_List entry,
int  version,
int  mqr 
)
static
STATIC_IN_RELEASE int QRinput_estimateVersion ( QRinput input)

Estimate the required version number of the symbol.

Parameters
inputinput data
Returns
required version number or -1 for failure.

Definition at line 934 of file qrinput.c.

References _QRinput::level, QRinput_estimateBitStreamSize(), and QRspec_getMinimumVersion().

Referenced by QRinput_convertData().

void QRinput_free ( QRinput input)

Free the input object.

All of data chunks in the input object are freed too.

Parameters
inputinput object.

Definition at line 292 of file qrinput.c.

References free(), _QRinput::head, _QRinput_List::next, and QRinput_List_freeEntry().

Referenced by QRcode_encodeDataReal(), QRcode_encodeDataStructuredReal(), QRcode_encodeStringReal(), QRinput_dup(), QRinput_InputList_freeEntry(), and QRinput_splitQRinputToStruct().

STATIC_IN_RELEASE int QRinput_getBitStream ( QRinput input,
BitStream bstream 
)

Merge all bit streams in the input data and append padding bits.

Parameters
inputinput data.
Returns
padded merged bit stream

Definition at line 1301 of file qrinput.c.

References _QRinput::mqr, QRinput_appendPaddingBit(), QRinput_appendPaddingBitMQR(), and QRinput_mergeBitStream().

Referenced by QRinput_getByteStream().

unsigned char* QRinput_getByteStream ( QRinput input)

Pack all bit streams padding bits into a byte array.

Parameters
inputinput data.
Returns
padded merged byte stream

Definition at line 1324 of file qrinput.c.

References BitStream_free(), BitStream_new(), BitStream_toByte(), and QRinput_getBitStream().

Referenced by MQRraw_new(), and QRraw_new().

QRecLevel QRinput_getErrorCorrectionLevel ( QRinput input)

Get current error correction level.

Parameters
inputinput object.
Returns
Current error correcntion level.

Definition at line 172 of file qrinput.c.

References _QRinput::level.

int QRinput_getVersion ( QRinput input)

Get current version.

Parameters
inputinput object.
Returns
current version.

Definition at line 155 of file qrinput.c.

References _QRinput::version.

Referenced by QRinput_convertData().

static void QRinput_InputList_freeEntry ( QRinput_InputList entry)
static

Definition at line 1363 of file qrinput.c.

References free(), _QRinput_InputList::input, and QRinput_free().

Referenced by QRinput_Struct_free().

static QRinput_InputList* QRinput_InputList_newEntry ( QRinput input)
static

Definition at line 1350 of file qrinput.c.

References _QRinput_InputList::input, malloc(), and _QRinput_InputList::next.

Referenced by QRinput_Struct_appendInput().

static int QRinput_insertFNC1Header ( QRinput input)
static
STATIC_IN_RELEASE int QRinput_insertStructuredAppendHeader ( QRinput input,
int  size,
int  number,
unsigned char  parity 
)

Insert a structured-append header to the head of the input data.

Parameters
inputinput data.
sizenumber of structured symbols.
numberindex number of the symbol. (1 <= number <= size)
parityparity among input data. (NOTE: each symbol of a set of structured symbols has the same parity data)
Return values
0success.
-1error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
EINVALinvalid parameter.
ENOMEMunable to allocate memory.

Definition at line 246 of file qrinput.c.

References _QRinput::head, MAX_STRUCTURED_SYMBOLS, _QRinput_List::next, QR_MODE_STRUCTURE, and QRinput_List_newEntry().

Referenced by QRinput_Struct_insertStructuredAppendHeaders().

int QRinput_isSplittableMode ( QRencodeMode  mode)

Definition at line 37 of file qrinput.c.

References QR_MODE_KANJI, and QR_MODE_NUM.

Referenced by QRspec_lengthIndicator(), and QRspec_maximumWords().

STATIC_IN_RELEASE int QRinput_lengthOfCode ( QRencodeMode  mode,
int  version,
int  bits 
)

Return required length in bytes for specified mode, version and bits.

Parameters
mode
version
bits
Returns
required length of code words in bytes.

Definition at line 959 of file qrinput.c.

References QR_MODE_8, QR_MODE_AN, QR_MODE_KANJI, QR_MODE_NUM, QR_MODE_STRUCTURE, QRspec_lengthIndicator(), and QRspec_maximumWords().

Referenced by QRinput_splitQRinputToStruct().

static QRinput_List* QRinput_List_dup ( QRinput_List entry)
static
static void QRinput_List_freeEntry ( QRinput_List entry)
static
static QRinput_List* QRinput_List_newEntry ( QRencodeMode  mode,
int  size,
const unsigned char *  data 
)
static
static int QRinput_List_shrinkEntry ( QRinput_List entry,
int  bytes 
)
static

Definition at line 1446 of file qrinput.c.

References _QRinput_List::data, free(), malloc(), and _QRinput_List::size.

Referenced by QRinput_splitEntry().

STATIC_IN_RELEASE int QRinput_mergeBitStream ( QRinput input,
BitStream bstream 
)

Merge all bit streams in the input data.

Parameters
inputinput data.
Returns
merged bit stream

Definition at line 1275 of file qrinput.c.

References _QRinput::fnc1, _QRinput::mqr, QRinput_convertData(), QRinput_createBitStream(), and QRinput_insertFNC1Header().

Referenced by QRinput_getBitStream().

QRinput* QRinput_new ( void  )

Instantiate an input data object.

The version is set to 0 (auto-select) and the error correction level is set to QR_ECLEVEL_L.

Returns
an input object (initialized). On error, NULL is returned and errno is set to indicate the error.
Exceptions
ENOMEMunable to allocate memory.

Definition at line 109 of file qrinput.c.

References QR_ECLEVEL_L, and QRinput_new2().

QRinput* QRinput_new2 ( int  version,
QRecLevel  level 
)

Instantiate an input data object.

Parameters
versionversion number.
levelError correction level.
Returns
an input object (initialized). On error, NULL is returned and errno is set to indicate the error.
Exceptions
ENOMEMunable to allocate memory for input objects.
EINVALinvalid arguments.

Definition at line 114 of file qrinput.c.

References _QRinput::fnc1, _QRinput::head, _QRinput::level, malloc(), _QRinput::mqr, QR_ECLEVEL_H, QRSPEC_VERSION_MAX, _QRinput::tail, and _QRinput::version.

Referenced by QRcode_encodeDataReal(), QRcode_encodeDataStructuredReal(), QRcode_encodeStringReal(), QRinput_dup(), QRinput_new(), QRinput_newMQR(), and QRinput_splitQRinputToStruct().

QRinput* QRinput_newMQR ( int  version,
QRecLevel  level 
)

Instantiate an input data object.

Object's Micro QR Code flag is set. Unlike with full-sized QR Code, version number must be specified (>0).

Parameters
versionversion number (1–4).
levelError correction level.
Returns
an input object (initialized). On error, NULL is returned and errno is set to indicate the error.
Exceptions
ENOMEMunable to allocate memory for input objects.
EINVALinvalid arguments.

Definition at line 136 of file qrinput.c.

References _QRinput::mqr, MQRspec_getECCLength(), MQRSPEC_VERSION_MAX, and QRinput_new2().

Referenced by QRcode_encodeDataReal(), QRcode_encodeStringReal(), and QRinput_dup().

int QRinput_setErrorCorrectionLevel ( QRinput input,
QRecLevel  level 
)

Set error correction level of the QR code that is to be encoded.

This function cannot be applied to Micro QR Code.

Parameters
inputinput object.
levelError correction level.
Return values
0success.
-1invalid argument.

Definition at line 177 of file qrinput.c.

References _QRinput::level, _QRinput::mqr, and QR_ECLEVEL_H.

int QRinput_setFNC1First ( QRinput input)

Set FNC1-1st position flag.

Definition at line 1616 of file qrinput.c.

References _QRinput::fnc1, and _QRinput::mqr.

int QRinput_setFNC1Second ( QRinput input,
unsigned char  appid 
)

Set FNC1-2nd position flag and application identifier.

Definition at line 1627 of file qrinput.c.

References _QRinput::appid, _QRinput::fnc1, and _QRinput::mqr.

int QRinput_setVersion ( QRinput input,
int  version 
)

Set version of the QR code that is to be encoded.

This function cannot be applied to Micro QR Code.

Parameters
inputinput object.
versionversion number (0 = auto)
Return values
0success.
-1invalid argument.

Definition at line 160 of file qrinput.c.

References _QRinput::mqr, QRSPEC_VERSION_MAX, and _QRinput::version.

Referenced by QRinput_convertData().

int QRinput_setVersionAndErrorCorrectionLevel ( QRinput input,
int  version,
QRecLevel  level 
)

Set version and error correction level of the QR code at once.

This function is recommened for Micro QR Code.

Parameters
inputinput object.
versionversion number (0 = auto)
levelError correction level.
Return values
0success.
-1invalid argument.

Definition at line 189 of file qrinput.c.

References _QRinput::level, _QRinput::mqr, MQRspec_getECCLength(), MQRSPEC_VERSION_MAX, QR_ECLEVEL_H, QRSPEC_VERSION_MAX, and _QRinput::version.

STATIC_IN_RELEASE int QRinput_splitEntry ( QRinput_List entry,
int  bytes 
)
QRinput_Struct* QRinput_splitQRinputToStruct ( QRinput input)

Split a QRinput to QRinput_Struct.

It calculates a parity, set it, then insert structured-append headers. QRinput created by QRinput_newMQR() will be rejected.

Parameters
inputinput object. Version number and error correction level must be set.
Returns
a set of input data. On error, NULL is returned, and errno is set to indicate the error. See Exceptions for the details.
Exceptions
ERANGEinput data is too large.
EINVALinvalid input data.
ENOMEMunable to allocate memory.

Definition at line 1483 of file qrinput.c.

References BitStream_free(), BitStream_new(), BitStream_reset, _QRinput::head, _QRinput::level, MAX_STRUCTURED_SYMBOLS, _QRinput_List::mode, _QRinput::mqr, _QRinput_List::next, QRinput_calcParity(), QRinput_dup(), QRinput_encodeBitStream(), QRinput_estimateBitStreamSizeOfEntry(), QRinput_free(), QRinput_lengthOfCode(), QRinput_new2(), QRinput_splitEntry(), QRinput_Struct_appendInput(), QRinput_Struct_free(), QRinput_Struct_insertStructuredAppendHeaders(), QRinput_Struct_new(), QRinput_Struct_setParity(), QRspec_getDataLength(), _QRinput_Struct::size, STRUCTURE_HEADER_SIZE, _QRinput::tail, and _QRinput::version.

Referenced by QRcode_encodeInputToStructured().

int QRinput_Struct_appendInput ( QRinput_Struct s,
QRinput input 
)

Append a QRinput object to the set.

QRinput created by QRinput_newMQR() will be rejected.

Warning
never append the same QRinput object twice or more.
Parameters
sstructured input object.
inputan input object.
Return values
>0number of input objects in the structure.
-1an error occurred. See Exceptions for the details.
Exceptions
ENOMEMunable to allocate memory.
EINVALinvalid arguments.

Definition at line 1391 of file qrinput.c.

References _QRinput_Struct::head, _QRinput::mqr, _QRinput_InputList::next, QRinput_InputList_newEntry(), _QRinput_Struct::size, and _QRinput_Struct::tail.

Referenced by QRinput_splitQRinputToStruct().

static unsigned char QRinput_Struct_calcParity ( QRinput_Struct s)
static
void QRinput_Struct_free ( QRinput_Struct s)

Free all of QRinput in the set.

Parameters
sa structured input object.

Definition at line 1415 of file qrinput.c.

References free(), _QRinput_Struct::head, _QRinput_InputList::next, and QRinput_InputList_freeEntry().

Referenced by QRcode_encodeInputToStructured(), and QRinput_splitQRinputToStruct().

int QRinput_Struct_insertStructuredAppendHeaders ( QRinput_Struct s)

Insert structured-append headers to the input structure.

It calculates a parity and set it if the parity is not set yet.

Parameters
sinput structure
Return values
0success.
-1an error occurred and errno is set to indeicate the error. See Execptions for the details.
Exceptions
EINVALinvalid input object.
ENOMEMunable to allocate memory.

Definition at line 1588 of file qrinput.c.

References _QRinput_Struct::head, _QRinput_InputList::input, _QRinput_InputList::next, _QRinput_Struct::parity, QRinput_insertStructuredAppendHeader(), QRinput_Struct_calcParity(), and _QRinput_Struct::size.

Referenced by QRinput_splitQRinputToStruct().

QRinput_Struct* QRinput_Struct_new ( void  )

Instantiate a set of input data object.

Returns
an instance of QRinput_Struct. On error, NULL is returned and errno is set to indicate the error.
Exceptions
ENOMEMunable to allocate memory.

Definition at line 1371 of file qrinput.c.

References _QRinput_Struct::head, malloc(), _QRinput_Struct::parity, _QRinput_Struct::size, and _QRinput_Struct::tail.

Referenced by QRinput_splitQRinputToStruct().

void QRinput_Struct_setParity ( QRinput_Struct s,
unsigned char  parity 
)

Set parity of structured symbols.

Parameters
sstructured input object.
parityparity of s.

Definition at line 1386 of file qrinput.c.

References int(), and _QRinput_Struct::parity.

Referenced by QRinput_splitQRinputToStruct(), and QRinput_Struct_calcParity().

Variable Documentation

const signed char QRinput_anTable[128]
Initial value:
= {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
}

Definition at line 457 of file qrinput.c.