QRencode
Data Structures | Typedefs | Enumerations | Functions

qrencode.h File Reference

Go to the source code of this file.

Data Structures

struct  QRcode
 QRcode class. More...
struct  _QRcode_List

Typedefs

typedef struct _QRinput QRinput
 Singly linked list to contain input strings.
typedef struct _QRinput_Struct QRinput_Struct
 Set of QRinput for structured symbols.
typedef struct _QRcode_List QRcode_List
 Singly-linked list of QRcode.

Enumerations

enum  QRencodeMode {
  QR_MODE_NUL = -1, QR_MODE_NUM = 0, QR_MODE_AN, QR_MODE_8,
  QR_MODE_KANJI, QR_MODE_STRUCTURE
}
 

Encoding mode.

More...
enum  QRecLevel { QR_ECLEVEL_L = 0, QR_ECLEVEL_M, QR_ECLEVEL_Q, QR_ECLEVEL_H }
 

Level of error correction.

More...

Functions

QRinputQRinput_new (void)
 Instantiate an input data object.
QRinputQRinput_new2 (int version, QRecLevel level)
 Instantiate an input data object.
int QRinput_append (QRinput *input, QRencodeMode mode, int size, const unsigned char *data)
 Append data to an input object.
int QRinput_getVersion (QRinput *input)
 Get current version.
int QRinput_setVersion (QRinput *input, int version)
 Set version of the QR-code that is to be encoded.
QRecLevel QRinput_getErrorCorrectionLevel (QRinput *input)
 Get current error correction level.
int QRinput_setErrorCorrectionLevel (QRinput *input, QRecLevel level)
 Set error correction level of the QR-code that is to be encoded.
void QRinput_free (QRinput *input)
 Free the input object.
int QRinput_check (QRencodeMode mode, int size, const unsigned char *data)
 Validate the input data.
QRinput_StructQRinput_Struct_new (void)
 Instantiate a set of input data object.
void QRinput_Struct_setParity (QRinput_Struct *s, unsigned char parity)
 Set parity of structured symbols.
int QRinput_Struct_appendInput (QRinput_Struct *s, QRinput *input)
 Append a QRinput object to the set.
void QRinput_Struct_free (QRinput_Struct *s)
 Free all of QRinput in the set.
QRinput_StructQRinput_splitQRinputToStruct (QRinput *input)
 Split a QRinput to QRinput_Struct.
int QRinput_Struct_insertStructuredAppendHeaders (QRinput_Struct *s)
 Insert structured-append headers to the input structure.
QRcodeQRcode_encodeInput (QRinput *input)
 Create a symbol from the input data.
QRcodeQRcode_encodeString (const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
 Create a symbol from the string.
QRcodeQRcode_encodeString8bit (const char *string, int version, QRecLevel level)
 Same to QRcode_encodeString(), but encode whole data in 8-bit mode.
void QRcode_free (QRcode *qrcode)
 Free the instance of QRcode class.
QRcode_ListQRcode_encodeInputStructured (QRinput_Struct *s)
 Create structured symbols from the input data.
QRcode_ListQRcode_encodeStringStructured (const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
 Create structured symbols from the string.
QRcode_ListQRcode_encodeString8bitStructured (const char *string, int version, QRecLevel level)
 Same to QRcode_encodeStringStructured(), but encode whole data in 8-bit mode.
int QRcode_List_size (QRcode_List *qrlist)
 Return the number of symbols included in a QRcode_List.
void QRcode_List_free (QRcode_List *qrlist)
 Free the QRcode_List.

Typedef Documentation

typedef struct _QRinput QRinput

Singly linked list to contain input strings.

An instance of this class contains its version and error correction level too. It is required to set them by QRinput_setVersion() and QRinput_setErrorCorrectionLevel(), or use QRinput_new2() to instantiate an object.

typedef struct _QRinput_Struct QRinput_Struct

Set of QRinput for structured symbols.

typedef struct _QRcode_List QRcode_List

Singly-linked list of QRcode.

Used to represent a structured symbols. A list is terminated with NULL.


Enumeration Type Documentation

Encoding mode.

Enumerator:
QR_MODE_NUL 

Terminator (NUL character). Internal use only.

QR_MODE_NUM 

Numeric mode.

QR_MODE_AN 

Alphabet-numeric mode.

QR_MODE_8 

8-bit data mode

QR_MODE_KANJI 

Kanji (shift-jis) mode.

QR_MODE_STRUCTURE 

Internal use only.

enum QRecLevel

Level of error correction.

Enumerator:
QR_ECLEVEL_L 

lowest

QR_ECLEVEL_M 
QR_ECLEVEL_Q 
QR_ECLEVEL_H 

highest


Function Documentation

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.
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.
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.
int QRinput_getVersion ( QRinput input)

Get current version.

Parameters:
inputinput object.
Returns:
current version.
int QRinput_setVersion ( QRinput input,
int  version 
)

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

Parameters:
inputinput object.
versionversion number (0 = auto)
Return values:
0success.
-1invalid argument.
QRecLevel QRinput_getErrorCorrectionLevel ( QRinput input)

Get current error correction level.

Parameters:
inputinput object.
Returns:
Current error correcntion level.
int QRinput_setErrorCorrectionLevel ( QRinput input,
QRecLevel  level 
)

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

Parameters:
inputinput object.
levelError correction level.
Return values:
0success.
-1invalid argument.
void QRinput_free ( QRinput input)

Free the input object.

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

Parameters:
inputinput object.
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.
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.
void QRinput_Struct_setParity ( QRinput_Struct s,
unsigned char  parity 
)

Set parity of structured symbols.

Parameters:
sstructured input object.
parityparity of s.
int QRinput_Struct_appendInput ( QRinput_Struct s,
QRinput input 
)

Append a QRinput object to the set.

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.
void QRinput_Struct_free ( QRinput_Struct s)

Free all of QRinput in the set.

Parameters:
sa structured input object.
QRinput_Struct* QRinput_splitQRinputToStruct ( QRinput input)

Split a QRinput to QRinput_Struct.

It calculates a parity, set it, then insert structured-append headers.

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.
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.
QRcode* QRcode_encodeInput ( QRinput input)

Create a symbol from the input data.

Warning:
This function is THREAD UNSAFE.
Parameters:
inputinput data.
Returns:
an instance of QRcode class. The version of the result QRcode may be larger than the designated version. On error, NULL is returned, and errno is set to indicate the error. See Exceptions for the details.
Exceptions:
EINVALinvalid input object.
ENOMEMunable to allocate memory for input objects.
QRcode* QRcode_encodeString ( const char *  string,
int  version,
QRecLevel  level,
QRencodeMode  hint,
int  casesensitive 
)

Create a symbol from the string.

The library automatically parses the input string and encodes in a QR Code symbol.

Warning:
This function is THREAD UNSAFE.
Parameters:
stringinput string. It must be NULL terminated.
versionversion of the symbol. If 0, the library chooses the minimum version for the given input data.
levelerror correction level.
hinttell the library how non-alphanumerical characters should be encoded. If QR_MODE_KANJI is given, kanji characters will be encoded as Shif-JIS characters. If QR_MODE_8 is given, all of non-alphanumerical characters will be encoded as is. If you want to embed UTF-8 string, choose this.
casesensitivecase-sensitive(1) or not(0).
Returns:
an instance of QRcode class. The version of the result QRcode may be larger than the designated version. On error, NULL is returned, and errno is set to indicate the error. See Exceptions for the details.
Exceptions:
EINVALinvalid input object.
ENOMEMunable to allocate memory for input objects.
QRcode* QRcode_encodeString8bit ( const char *  string,
int  version,
QRecLevel  level 
)

Same to QRcode_encodeString(), but encode whole data in 8-bit mode.

Warning:
This function is THREAD UNSAFE.
void QRcode_free ( QRcode qrcode)

Free the instance of QRcode class.

Parameters:
qrcodean instance of QRcode class.
QRcode_List* QRcode_encodeInputStructured ( QRinput_Struct s)

Create structured symbols from the input data.

Warning:
This function is THREAD UNSAFE.
Parameters:
s
Returns:
a singly-linked list of QRcode.
QRcode_List* QRcode_encodeStringStructured ( const char *  string,
int  version,
QRecLevel  level,
QRencodeMode  hint,
int  casesensitive 
)

Create structured symbols from the string.

The library automatically parses the input string and encodes in a QR Code symbol.

Warning:
This function is THREAD UNSAFE.
Parameters:
stringinput string. It should be NULL terminated.
versionversion of the symbol.
levelerror correction level.
hinttell the library how non-alphanumerical characters should be encoded. If QR_MODE_KANJI is given, kanji characters will be encoded as Shif-JIS characters. If QR_MODE_8 is given, all of non-alphanumerical characters will be encoded as is. If you want to embed UTF-8 string, choose this.
casesensitivecase-sensitive(1) or not(0).
Returns:
a singly-linked list of QRcode. On error, NULL is returned, and errno is set to indicate the error. See Exceptions for the details.
Exceptions:
EINVALinvalid input object.
ENOMEMunable to allocate memory for input objects.
QRcode_List* QRcode_encodeString8bitStructured ( const char *  string,
int  version,
QRecLevel  level 
)

Same to QRcode_encodeStringStructured(), but encode whole data in 8-bit mode.

Warning:
This function is THREAD UNSAFE.
int QRcode_List_size ( QRcode_List qrlist)

Return the number of symbols included in a QRcode_List.

Parameters:
qrlista head entry of a QRcode_List.
Returns:
number of symbols in the list.
void QRcode_List_free ( QRcode_List qrlist)

Free the QRcode_List.

Parameters:
qrlista head entry of a QRcode_List.