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)  

qrinput.c File Reference
#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"
Include dependency graph for qrinput.c:

Go to the source code of this file.

Functions

int QRinput_isSplittableMode (QRencodeMode mode)
 Utilities. More...
 
static QRinput_ListQRinput_List_newEntry (QRencodeMode mode, int size, const unsigned char *data)
 Entry of input data. More...
 
static void QRinput_List_freeEntry (QRinput_List *entry)
 
static QRinput_ListQRinput_List_dup (QRinput_List *entry)
 
QRinputQRinput_new (void)
 Input Data. 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)
 Numeric 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)
 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)
 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)
 Structured Symbol. More...
 
static int QRinput_checkModeFNC1Second (int size)
 FNC1. More...
 
static int QRinput_encodeModeFNC1Second (QRinput_List *entry, BitStream *bstream)
 
static unsigned int QRinput_decodeECIfromByteArray (unsigned char *data)
 ECI header. More...
 
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)
 Validation. More...
 
static int QRinput_estimateBitStreamSizeOfEntry (QRinput_List *entry, int version, int mqr)
 Estimation of the bit length. 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)
 Data conversion. 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)
 Structured input data. More...
 
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)
 Extended encoding mode (FNC1 and ECI) 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]
 Alphabet-numeric data. More...
 

Function Documentation

◆ QRinput_append()

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 223 of file qrinput.c.

References QRinput_appendEntry(), QRinput_List_newEntry(), and size.

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

◆ QRinput_appendECIheader()

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 276 of file qrinput.c.

References QR_MODE_ECI, and QRinput_append().

◆ QRinput_appendEntry()

static void QRinput_appendEntry ( QRinput input,
QRinput_List entry 
)
static

Definition at line 211 of file qrinput.c.

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

Referenced by QRinput_append(), and QRinput_dup().

◆ QRinput_appendPaddingBit()

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 1147 of file qrinput.c.

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

Referenced by QRinput_getBitStream().

◆ QRinput_appendPaddingBitMQR()

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 1196 of file qrinput.c.

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

Referenced by QRinput_getBitStream().

◆ QRinput_calcParity()

static unsigned char QRinput_calcParity ( QRinput input)
static

◆ QRinput_check()

int QRinput_check ( QRencodeMode  mode,
int  size,
const unsigned char *  data 
)

◆ QRinput_checkModeAn()

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

Check the input data.

Parameters
size
data
Returns
result

Definition at line 476 of file qrinput.c.

References QRinput_lookAnTable, and size.

Referenced by QRinput_check().

◆ QRinput_checkModeFNC1Second()

static int QRinput_checkModeFNC1Second ( int  size)
static

FNC1.

Definition at line 732 of file qrinput.c.

References size.

Referenced by QRinput_check().

◆ QRinput_checkModeKanji()

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

Check the input data.

Parameters
size
data
Returns
result

Definition at line 627 of file qrinput.c.

References size.

Referenced by QRinput_check().

◆ QRinput_checkModeNum()

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

Numeric data.

Check the input data.

Parameters
size
data
Returns
result

Definition at line 364 of file qrinput.c.

References size.

Referenced by QRinput_check().

◆ QRinput_convertData()

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 1112 of file qrinput.c.

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

Referenced by QRinput_mergeBitStream().

◆ QRinput_createBitStream()

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 1084 of file qrinput.c.

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

Referenced by QRinput_convertData(), and QRinput_mergeBitStream().

◆ QRinput_decodeECIfromByteArray()

static unsigned int QRinput_decodeECIfromByteArray ( unsigned char *  data)
static

ECI header.

Definition at line 757 of file qrinput.c.

Referenced by QRinput_encodeModeECI(), and QRinput_estimateBitsModeECI().

◆ QRinput_dup()

◆ QRinput_encodeBitStream()

◆ QRinput_encodeMode8()

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 580 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, _QRinput_List::size, and version.

Referenced by QRinput_encodeBitStream().

◆ QRinput_encodeModeAn()

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 517 of file qrinput.c.

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

Referenced by QRinput_encodeBitStream().

◆ QRinput_encodeModeECI()

static int QRinput_encodeModeECI ( QRinput_List entry,
BitStream bstream 
)
static

◆ QRinput_encodeModeFNC1Second()

static int QRinput_encodeModeFNC1Second ( QRinput_List entry,
BitStream bstream 
)
static

◆ QRinput_encodeModeKanji()

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 655 of file qrinput.c.

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

Referenced by QRinput_encodeBitStream().

◆ QRinput_encodeModeNum()

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 411 of file qrinput.c.

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

Referenced by QRinput_encodeBitStream().

◆ QRinput_encodeModeStructure()

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

Structured Symbol.

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 707 of file qrinput.c.

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

Referenced by QRinput_encodeBitStream().

◆ QRinput_estimateBitsMode8()

int QRinput_estimateBitsMode8 ( int  size)

8 bit data

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

Parameters
size
Returns
number of bits

Definition at line 566 of file qrinput.c.

References size.

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

◆ QRinput_estimateBitsModeAn()

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 493 of file qrinput.c.

References size.

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

◆ QRinput_estimateBitsModeECI()

static int QRinput_estimateBitsModeECI ( unsigned char *  data)
static

◆ QRinput_estimateBitsModeKanji()

int QRinput_estimateBitsModeKanji ( int  size)

Kanji data.

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

Parameters
size
Returns
number of bits

Definition at line 616 of file qrinput.c.

References size.

Referenced by QRinput_estimateBitStreamSizeOfEntry().

◆ QRinput_estimateBitsModeNum()

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 381 of file qrinput.c.

References size.

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

◆ QRinput_estimateBitStreamSize()

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 917 of file qrinput.c.

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

Referenced by QRinput_estimateVersion().

◆ QRinput_estimateBitStreamSizeOfEntry()

static int QRinput_estimateBitStreamSizeOfEntry ( QRinput_List entry,
int  version,
int  mqr 
)
static

◆ QRinput_estimateVersion()

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 936 of file qrinput.c.

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

Referenced by QRinput_convertData().

◆ QRinput_free()

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 294 of file qrinput.c.

References _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().

◆ QRinput_getBitStream()

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 1303 of file qrinput.c.

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

Referenced by QRinput_getByteStream().

◆ 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 1326 of file qrinput.c.

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

Referenced by MQRraw_new(), and QRraw_new().

◆ QRinput_getErrorCorrectionLevel()

QRecLevel QRinput_getErrorCorrectionLevel ( QRinput input)

Get current error correction level.

Parameters
inputinput object.
Returns
Current error correcntion level.

Definition at line 174 of file qrinput.c.

References _QRinput::level.

◆ QRinput_getVersion()

int QRinput_getVersion ( QRinput input)

Get current version.

Parameters
inputinput object.
Returns
current version.

Definition at line 157 of file qrinput.c.

References _QRinput::version.

Referenced by QRinput_convertData().

◆ QRinput_InputList_freeEntry()

static void QRinput_InputList_freeEntry ( QRinput_InputList entry)
static

Definition at line 1365 of file qrinput.c.

References _QRinput_InputList::input, and QRinput_free().

Referenced by QRinput_Struct_free().

◆ QRinput_InputList_newEntry()

static QRinput_InputList * QRinput_InputList_newEntry ( QRinput input)
static

Structured input data.

Definition at line 1352 of file qrinput.c.

References _QRinput_InputList::input, and _QRinput_InputList::next.

Referenced by QRinput_Struct_appendInput().

◆ QRinput_insertFNC1Header()

◆ QRinput_insertStructuredAppendHeader()

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 248 of file qrinput.c.

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

Referenced by QRinput_Struct_insertStructuredAppendHeaders().

◆ QRinput_isSplittableMode()

int QRinput_isSplittableMode ( QRencodeMode  mode)

Utilities.

Definition at line 39 of file qrinput.c.

References QR_MODE_KANJI, and QR_MODE_NUM.

Referenced by QRspec_lengthIndicator(), and QRspec_maximumWords().

◆ QRinput_lengthOfCode()

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 961 of file qrinput.c.

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

Referenced by QRinput_splitQRinputToStruct().

◆ QRinput_List_dup()

static QRinput_List * QRinput_List_dup ( QRinput_List entry)
static

◆ QRinput_List_freeEntry()

static void QRinput_List_freeEntry ( QRinput_List entry)
static

◆ QRinput_List_newEntry()

static QRinput_List * QRinput_List_newEntry ( QRencodeMode  mode,
int  size,
const unsigned char *  data 
)
static

◆ QRinput_List_shrinkEntry()

static int QRinput_List_shrinkEntry ( QRinput_List entry,
int  bytes 
)
static

Definition at line 1448 of file qrinput.c.

References _QRinput_List::data, and _QRinput_List::size.

Referenced by QRinput_splitEntry().

◆ QRinput_mergeBitStream()

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 1277 of file qrinput.c.

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

Referenced by QRinput_getBitStream().

◆ QRinput_new()

QRinput * QRinput_new ( void  )

Input Data.

Instantiate an input data object.

Definition at line 111 of file qrinput.c.

References QR_ECLEVEL_L, and QRinput_new2().

◆ 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 116 of file qrinput.c.

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

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

◆ QRinput_newMQR()

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 138 of file qrinput.c.

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

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

◆ QRinput_setErrorCorrectionLevel()

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 179 of file qrinput.c.

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

◆ QRinput_setFNC1First()

int QRinput_setFNC1First ( QRinput input)

Extended encoding mode (FNC1 and ECI)

Set FNC1-1st position flag.

Definition at line 1618 of file qrinput.c.

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

◆ QRinput_setFNC1Second()

int QRinput_setFNC1Second ( QRinput input,
unsigned char  appid 
)

Set FNC1-2nd position flag and application identifier.

Definition at line 1629 of file qrinput.c.

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

◆ QRinput_setVersion()

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 162 of file qrinput.c.

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

Referenced by QRinput_convertData().

◆ QRinput_setVersionAndErrorCorrectionLevel()

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 191 of file qrinput.c.

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

◆ QRinput_splitEntry()

STATIC_IN_RELEASE int QRinput_splitEntry ( QRinput_List entry,
int  bytes 
)

◆ QRinput_splitQRinputToStruct()

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 1485 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().

◆ QRinput_Struct_appendInput()

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 1393 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().

◆ QRinput_Struct_calcParity()

static unsigned char QRinput_Struct_calcParity ( QRinput_Struct s)
static

◆ QRinput_Struct_free()

void QRinput_Struct_free ( QRinput_Struct s)

Free all of QRinput in the set.

Parameters
sa structured input object.

Definition at line 1417 of file qrinput.c.

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

Referenced by QRcode_encodeInputToStructured(), and QRinput_splitQRinputToStruct().

◆ QRinput_Struct_insertStructuredAppendHeaders()

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 1590 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_new()

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 1373 of file qrinput.c.

References _QRinput_Struct::head, _QRinput_Struct::parity, _QRinput_Struct::size, and _QRinput_Struct::tail.

Referenced by QRinput_splitQRinputToStruct().

◆ QRinput_Struct_setParity()

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 1388 of file qrinput.c.

References _QRinput_Struct::parity.

Referenced by QRinput_splitQRinputToStruct(), and QRinput_Struct_calcParity().

Variable Documentation

◆ QRinput_anTable

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
}

Alphabet-numeric data.

Definition at line 459 of file qrinput.c.