mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
API overhaul part 1: removal of nullchar
This commit is contained in:
parent
4455c6a893
commit
04b9a99241
@ -35,7 +35,7 @@ static char *C25InterTable[10] = {"11331", "31113", "13113", "33111", "11313", "
|
|||||||
"31131", "13131"};
|
"31131", "13131"};
|
||||||
|
|
||||||
|
|
||||||
int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Code 2 of 5 Standard (Code 2 of 5 Matrix) */
|
{ /* Code 2 of 5 Standard (Code 2 of 5 Matrix) */
|
||||||
|
|
||||||
int i, error_number;
|
int i, error_number;
|
||||||
@ -44,11 +44,11 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 80) {
|
if(length > 80) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -57,7 +57,7 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
/* start character */
|
/* start character */
|
||||||
concat (dest, "411111");
|
concat (dest, "411111");
|
||||||
|
|
||||||
for(i = 0; i <= ustrlen(source); i++) {
|
for(i = 0; i <= length; i++) {
|
||||||
lookup(NESET, C25MatrixTable, source[i], dest);
|
lookup(NESET, C25MatrixTable, source[i], dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Code 2 of 5 Industrial */
|
{ /* Code 2 of 5 Industrial */
|
||||||
|
|
||||||
int i, error_number;
|
int i, error_number;
|
||||||
@ -78,11 +78,11 @@ int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 45) {
|
if(length > 45) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid character in data");
|
strcpy(symbol->errtxt, "Invalid character in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -91,7 +91,7 @@ int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
/* start character */
|
/* start character */
|
||||||
concat (dest, "313111");
|
concat (dest, "313111");
|
||||||
|
|
||||||
for(i = 0; i <= ustrlen(source); i++) {
|
for(i = 0; i <= length; i++) {
|
||||||
lookup(NESET, C25IndustTable, source[i], dest);
|
lookup(NESET, C25IndustTable, source[i], dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Code 2 of 5 IATA */
|
{ /* Code 2 of 5 IATA */
|
||||||
int i, error_number;
|
int i, error_number;
|
||||||
char dest[1000];
|
char dest[1000];
|
||||||
@ -111,11 +111,11 @@ int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 45) {
|
if(length > 45) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -124,7 +124,7 @@ int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
/* start */
|
/* start */
|
||||||
concat (dest, "1111");
|
concat (dest, "1111");
|
||||||
|
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < length; i++) {
|
||||||
lookup(NESET, C25IndustTable, source[i], dest);
|
lookup(NESET, C25IndustTable, source[i], dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Code 2 of 5 Data Logic */
|
{ /* Code 2 of 5 Data Logic */
|
||||||
|
|
||||||
int i, error_number;
|
int i, error_number;
|
||||||
@ -145,11 +145,11 @@ int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 80) {
|
if(length > 80) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -158,7 +158,7 @@ int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
/* start character */
|
/* start character */
|
||||||
concat (dest, "1111");
|
concat (dest, "1111");
|
||||||
|
|
||||||
for(i = 0; i <= ustrlen(source); i++) {
|
for(i = 0; i <= length; i++) {
|
||||||
lookup(NESET, C25MatrixTable, source[i], dest);
|
lookup(NESET, C25MatrixTable, source[i], dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Code 2 of 5 Interleaved */
|
{ /* Code 2 of 5 Interleaved */
|
||||||
|
|
||||||
int i, j, k, error_number;
|
int i, j, k, error_number;
|
||||||
@ -179,11 +179,11 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 90) {
|
if(length > 90) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if (error_number == ERROR_INVALID_DATA) {
|
if (error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -191,14 +191,11 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
/* Input must be an even number of characters for Interlaced 2 of 5 to work:
|
/* Input must be an even number of characters for Interlaced 2 of 5 to work:
|
||||||
if an odd number of characters has been entered then add a leading zero */
|
if an odd number of characters has been entered then add a leading zero */
|
||||||
if ((ustrlen(source)%2) != 0)
|
if ((length%2) != 0)
|
||||||
{
|
{
|
||||||
/* there are an odd number of input characters */
|
/* there are an odd number of input characters */
|
||||||
unsigned int length;
|
|
||||||
char temp[100];
|
char temp[100];
|
||||||
|
|
||||||
length = ustrlen(source);
|
|
||||||
|
|
||||||
strcpy(temp, (char*)source);
|
strcpy(temp, (char*)source);
|
||||||
source[0] = '0';
|
source[0] = '0';
|
||||||
|
|
||||||
@ -206,12 +203,13 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
{
|
{
|
||||||
source[i + 1] = temp[i];
|
source[i + 1] = temp[i];
|
||||||
}
|
}
|
||||||
|
length++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start character */
|
/* start character */
|
||||||
concat(dest, "1111");
|
concat(dest, "1111");
|
||||||
|
|
||||||
for(i = 0; i < ustrlen(source); i+=2 )
|
for(i = 0; i < length; i+=2 )
|
||||||
{
|
{
|
||||||
/* look up the bars and the spaces and put them in two strings */
|
/* look up the bars and the spaces and put them in two strings */
|
||||||
strcpy(bars, "");
|
strcpy(bars, "");
|
||||||
@ -239,9 +237,9 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int itf14(struct zint_symbol *symbol, unsigned char source[])
|
int itf14(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int i, error_number, h, zeroes;
|
int i, error_number, zeroes;
|
||||||
unsigned int count, check_digit;
|
unsigned int count, check_digit;
|
||||||
char localstr[15];
|
char localstr[15];
|
||||||
char checkstr[3];
|
char checkstr[3];
|
||||||
@ -249,14 +247,13 @@ int itf14(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
h = ustrlen(source);
|
|
||||||
|
|
||||||
if(h > 13) {
|
if(length > 13) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid character in data");
|
strcpy(symbol->errtxt, "Invalid character in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -264,7 +261,7 @@ int itf14(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
/* Add leading zeros as required */
|
/* Add leading zeros as required */
|
||||||
strcpy(localstr, "");
|
strcpy(localstr, "");
|
||||||
zeroes = 13 - ustrlen(source);
|
zeroes = 13 - length;
|
||||||
for(i = 0; i < zeroes; i++) {
|
for(i = 0; i < zeroes; i++) {
|
||||||
concat(localstr, "0");
|
concat(localstr, "0");
|
||||||
}
|
}
|
||||||
@ -286,33 +283,32 @@ int itf14(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
checkstr[0] = itoc(check_digit);
|
checkstr[0] = itoc(check_digit);
|
||||||
checkstr[1] = '\0';
|
checkstr[1] = '\0';
|
||||||
concat(localstr, checkstr);
|
concat(localstr, checkstr);
|
||||||
error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr);
|
error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr, strlen(localstr));
|
||||||
ustrcpy(symbol->text, (unsigned char*)localstr);
|
ustrcpy(symbol->text, (unsigned char*)localstr);
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dpleit(struct zint_symbol *symbol, unsigned char source[])
|
int dpleit(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Deutshe Post Leitcode */
|
{ /* Deutshe Post Leitcode */
|
||||||
int i, error_number;
|
int i, error_number;
|
||||||
unsigned int h, count, check_digit;
|
unsigned int count, check_digit;
|
||||||
char localstr[15], checkstr[3];
|
char localstr[15], checkstr[3];
|
||||||
int zeroes;
|
int zeroes;
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
h = ustrlen(source);
|
if(length > 13) {
|
||||||
if(h > 13) {
|
|
||||||
strcpy(symbol->errtxt, "Input wrong length");
|
strcpy(symbol->errtxt, "Input wrong length");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(localstr, "");
|
strcpy(localstr, "");
|
||||||
zeroes = 13 - h;
|
zeroes = 13 - length;
|
||||||
for(i = 0; i < zeroes; i++)
|
for(i = 0; i < zeroes; i++)
|
||||||
concat(localstr, "0");
|
concat(localstr, "0");
|
||||||
concat(localstr, (char *)source);
|
concat(localstr, (char *)source);
|
||||||
@ -331,31 +327,31 @@ int dpleit(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
checkstr[0] = itoc(check_digit);
|
checkstr[0] = itoc(check_digit);
|
||||||
checkstr[1] = '\0';
|
checkstr[1] = '\0';
|
||||||
concat(localstr, checkstr);
|
concat(localstr, checkstr);
|
||||||
error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr);
|
length = strlen(localstr);
|
||||||
|
error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr, length);
|
||||||
ustrcpy(symbol->text, (unsigned char*)localstr);
|
ustrcpy(symbol->text, (unsigned char*)localstr);
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dpident(struct zint_symbol *symbol, unsigned char source[])
|
int dpident(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Deutsche Post Identcode */
|
{ /* Deutsche Post Identcode */
|
||||||
int i, error_number, zeroes;
|
int i, error_number, zeroes;
|
||||||
unsigned int h, count, check_digit;
|
unsigned int count, check_digit;
|
||||||
char localstr[13], checkstr[3];
|
char localstr[13], checkstr[3];
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
h = ustrlen(source);
|
if(length > 11) {
|
||||||
if(h > 11) {
|
|
||||||
strcpy(symbol->errtxt, "Input wrong length");
|
strcpy(symbol->errtxt, "Input wrong length");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(localstr, "");
|
strcpy(localstr, "");
|
||||||
zeroes = 11 - h;
|
zeroes = 11 - length;
|
||||||
for(i = 0; i < zeroes; i++)
|
for(i = 0; i < zeroes; i++)
|
||||||
concat(localstr, "0");
|
concat(localstr, "0");
|
||||||
concat(localstr, (char *)source);
|
concat(localstr, (char *)source);
|
||||||
@ -374,7 +370,8 @@ int dpident(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
checkstr[0] = itoc(check_digit);
|
checkstr[0] = itoc(check_digit);
|
||||||
checkstr[1] = '\0';
|
checkstr[1] = '\0';
|
||||||
concat(localstr, checkstr);
|
concat(localstr, checkstr);
|
||||||
error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr);
|
length = strlen(localstr);
|
||||||
|
error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr, length);
|
||||||
ustrcpy(symbol->text, (unsigned char*)localstr);
|
ustrcpy(symbol->text, (unsigned char*)localstr);
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ project(zint)
|
|||||||
find_package(PNG)
|
find_package(PNG)
|
||||||
find_package(Qr)
|
find_package(Qr)
|
||||||
|
|
||||||
set(zint_COMMON_SRCS common.c library.c ps.c large.c reedsol.c gs1.c svg.c)
|
set(zint_COMMON_SRCS common.c library.c ps.c large.c reedsol.c gs1.c svg.c shiftjis.c)
|
||||||
set(zint_ONEDIM_SRCS code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c)
|
set(zint_ONEDIM_SRCS code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c)
|
||||||
set(zint_POSTAL_SRCS postal.c auspost.c imail.c)
|
set(zint_POSTAL_SRCS postal.c auspost.c imail.c)
|
||||||
set(zint_TWODIM_SRCS code16k.c blockf.c dmatrix.c dm200.c pdf417.c qr.c micqr.c maxicode.c composite.c aztec.c code49.c code1.c)
|
set(zint_TWODIM_SRCS code16k.c blockf.c dmatrix.c dm200.c pdf417.c qr.c micqr.c maxicode.c composite.c aztec.c code49.c code1.c gridmtx.c)
|
||||||
set(zint_SRCS ${zint_COMMON_SRCS} ${zint_ONEDIM_SRCS} ${zint_POSTAL_SRCS} ${zint_TWODIM_SRCS} )
|
set(zint_SRCS ${zint_COMMON_SRCS} ${zint_ONEDIM_SRCS} ${zint_POSTAL_SRCS} ${zint_TWODIM_SRCS} )
|
||||||
|
|
||||||
if(PNG_FOUND)
|
if(PNG_FOUND)
|
||||||
|
@ -19,14 +19,14 @@ includedir := $(prefix)/include
|
|||||||
libdir := $(prefix)/lib
|
libdir := $(prefix)/lib
|
||||||
DESTDIR :=
|
DESTDIR :=
|
||||||
|
|
||||||
COMMON:= common.c png.c library.c ps.c large.c reedsol.c gs1.c svg.c
|
COMMON:= common.c png.c library.c ps.c large.c reedsol.c gs1.c svg.c shiftjis.c
|
||||||
COMMON_OBJ:= common.o png.o library.o ps.o large.o reedsol.o gs1.o svg.o
|
COMMON_OBJ:= common.o png.o library.o ps.o large.o reedsol.o gs1.o svg.o shiftjis.o
|
||||||
ONEDIM:= code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c
|
ONEDIM:= code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c
|
||||||
ONEDIM_OBJ:= code.o code128.o 2of5.o upcean.o telepen.o medical.o plessey.o rss.o
|
ONEDIM_OBJ:= code.o code128.o 2of5.o upcean.o telepen.o medical.o plessey.o rss.o
|
||||||
POSTAL:= postal.c auspost.c imail.c
|
POSTAL:= postal.c auspost.c imail.c
|
||||||
POSTAL_OBJ:= postal.o auspost.o imail.o
|
POSTAL_OBJ:= postal.o auspost.o imail.o
|
||||||
TWODIM:= code16k.c blockf.c dmatrix.c dm200.c pdf417.c qr.c maxicode.c composite.c aztec.c micqr.c code49.c code1.c
|
TWODIM:= code16k.c blockf.c dmatrix.c dm200.c pdf417.c qr.c maxicode.c composite.c aztec.c micqr.c code49.c code1.c gridmtx.c
|
||||||
TWODIM_OBJ:= code16k.o blockf.o dmatrix.o dm200.o pdf417.o qr.o maxicode.o composite.o aztec.o micqr.o code49.o code1.o
|
TWODIM_OBJ:= code16k.o blockf.o dmatrix.o dm200.o pdf417.o qr.o maxicode.o composite.o aztec.o micqr.o code49.o code1.o gridmtx.o
|
||||||
LIBS:= `libpng12-config --I_opts --L_opts --ldflags` -lz -lm
|
LIBS:= `libpng12-config --I_opts --L_opts --ldflags` -lz -lm
|
||||||
|
|
||||||
ifeq ($(NO_QR),true)
|
ifeq ($(NO_QR),true)
|
||||||
@ -36,7 +36,7 @@ DEFINES:=
|
|||||||
LIBS+= -lqrencode
|
LIBS+= -lqrencode
|
||||||
endif
|
endif
|
||||||
|
|
||||||
libzint: code.c code128.c 2of5.c upcean.c medical.c telepen.c plessey.c postal.c auspost.c imail.c code16k.c dmatrix.c dm200.c reedsol.c pdf417.c maxicode.c rss.c common.c png.c library.c ps.c qr.c large.c composite.c aztec.c blockf.c micqr.c gs1.c svg.c code49.c code1.c
|
libzint: code.c code128.c 2of5.c upcean.c medical.c telepen.c plessey.c postal.c auspost.c imail.c code16k.c dmatrix.c dm200.c reedsol.c pdf417.c maxicode.c rss.c common.c png.c library.c ps.c qr.c large.c composite.c aztec.c blockf.c micqr.c gs1.c svg.c code49.c code1.c gridmtx.c
|
||||||
$(CC) -Wall -fPIC $(CFLAGS) $(ZINT_VERSION) -c $(ONEDIM)
|
$(CC) -Wall -fPIC $(CFLAGS) $(ZINT_VERSION) -c $(ONEDIM)
|
||||||
$(CC) -Wall -fPIC $(CFLAGS) $(ZINT_VERSION) -c $(POSTAL)
|
$(CC) -Wall -fPIC $(CFLAGS) $(ZINT_VERSION) -c $(POSTAL)
|
||||||
$(CC) -Wall -fPIC $(DEFINES) $(CFLAGS) $(ZINT_VERSION) -c $(TWODIM)
|
$(CC) -Wall -fPIC $(DEFINES) $(CFLAGS) $(ZINT_VERSION) -c $(TWODIM)
|
||||||
|
@ -25,10 +25,10 @@ APP:=zint
|
|||||||
DLL:=$(APP).dll
|
DLL:=$(APP).dll
|
||||||
STATLIB:=lib$(APP).a
|
STATLIB:=lib$(APP).a
|
||||||
|
|
||||||
COMMON_OBJ:= common.o png.o library.o ps.o large.o reedsol.o gs1.o svg.o
|
COMMON_OBJ:= common.o png.o library.o ps.o large.o reedsol.o gs1.o svg.o shiftjis.o
|
||||||
ONEDIM_OBJ:= code.o code128.o 2of5.o upcean.o telepen.o medical.o plessey.o rss.o
|
ONEDIM_OBJ:= code.o code128.o 2of5.o upcean.o telepen.o medical.o plessey.o rss.o
|
||||||
POSTAL_OBJ:= postal.o auspost.o imail.o
|
POSTAL_OBJ:= postal.o auspost.o imail.o
|
||||||
TWODIM_OBJ:= code16k.o blockf.o dmatrix.o dm200.o pdf417.o qr.o maxicode.o composite.o aztec.o micqr.o code49.o
|
TWODIM_OBJ:= code16k.o blockf.o dmatrix.o dm200.o pdf417.o qr.o maxicode.o composite.o aztec.o micqr.o code49.o code1.o gridmtx.o
|
||||||
|
|
||||||
LIB_OBJ:= $(COMMON_OBJ) $(ONEDIM_OBJ) $(TWODIM_OBJ) $(POSTAL_OBJ)
|
LIB_OBJ:= $(COMMON_OBJ) $(ONEDIM_OBJ) $(TWODIM_OBJ) $(POSTAL_OBJ)
|
||||||
DLL_OBJ:= $(LIB_OBJ:.o=.lo) dllversion.lo
|
DLL_OBJ:= $(LIB_OBJ:.o=.lo) dllversion.lo
|
||||||
|
@ -94,7 +94,7 @@ void rs_error(char data_pattern[])
|
|||||||
rs_free();
|
rs_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
int australia_post(struct zint_symbol *symbol, unsigned char source[])
|
int australia_post(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* Handles Australia Posts's 4 State Codes */
|
/* Handles Australia Posts's 4 State Codes */
|
||||||
/* Customer Standard Barcode, Barcode 2 or Barcode 3 system determined automatically
|
/* Customer Standard Barcode, Barcode 2 or Barcode 3 system determined automatically
|
||||||
@ -121,13 +121,13 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
/* Do all of the length checking first to avoid stack smashing */
|
/* Do all of the length checking first to avoid stack smashing */
|
||||||
if(symbol->symbology == BARCODE_AUSPOST) {
|
if(symbol->symbology == BARCODE_AUSPOST) {
|
||||||
/* Format control code (FCC) */
|
/* Format control code (FCC) */
|
||||||
switch(ustrlen(source))
|
switch(length)
|
||||||
{
|
{
|
||||||
case 8: strcpy(fcc, "11"); break;
|
case 8: strcpy(fcc, "11"); break;
|
||||||
case 13: strcpy(fcc, "59"); break;
|
case 13: strcpy(fcc, "59"); break;
|
||||||
case 16: strcpy(fcc, "59"); error_number = is_sane(NESET, source); break;
|
case 16: strcpy(fcc, "59"); error_number = is_sane(NESET, source, length); break;
|
||||||
case 18: strcpy(fcc, "62"); break;
|
case 18: strcpy(fcc, "62"); break;
|
||||||
case 23: strcpy(fcc, "62"); error_number = is_sane(NESET, source); break;
|
case 23: strcpy(fcc, "62"); error_number = is_sane(NESET, source, length); break;
|
||||||
default: strcpy(symbol->errtxt, "Auspost input is wrong length");
|
default: strcpy(symbol->errtxt, "Auspost input is wrong length");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
break;
|
break;
|
||||||
@ -148,14 +148,14 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add leading zeros as required */
|
/* Add leading zeros as required */
|
||||||
zeroes = 8 - ustrlen(source);
|
zeroes = 8 - length;
|
||||||
for(i = 0; i < zeroes; i++) {
|
for(i = 0; i < zeroes; i++) {
|
||||||
concat(localstr, "0");
|
concat(localstr, "0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
concat(localstr, (char*)source);
|
concat(localstr, (char*)source);
|
||||||
error_number = is_sane(GDSET, (unsigned char *)localstr);
|
error_number = is_sane(GDSET, (unsigned char *)localstr, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -166,7 +166,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
dpid[loopey] = localstr[loopey];
|
dpid[loopey] = localstr[loopey];
|
||||||
}
|
}
|
||||||
dpid[8] = '\0';
|
dpid[8] = '\0';
|
||||||
error_number = is_sane(NESET, (unsigned char *)dpid);
|
error_number = is_sane(NESET, (unsigned char *)dpid, 8);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in DPID");
|
strcpy(symbol->errtxt, "Invalid characters in DPID");
|
||||||
return error_number;
|
return error_number;
|
||||||
|
@ -655,7 +655,7 @@ int aztec_text_process(unsigned char source[], char binary_string[], int gs1)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int aztec(struct zint_symbol *symbol, unsigned char source[])
|
int aztec(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int x, y, i, j, data_blocks, ecc_blocks, layers, total_bits;
|
int x, y, i, j, data_blocks, ecc_blocks, layers, total_bits;
|
||||||
char binary_string[20000], bit_pattern[20045], descriptor[42];
|
char binary_string[20000], bit_pattern[20045], descriptor[42];
|
||||||
@ -669,11 +669,39 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
unsigned int* ecc_part;
|
unsigned int* ecc_part;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
unsigned char local_source[length];
|
||||||
|
#else
|
||||||
|
unsigned char local_source = (unsigned char*)_alloca(length);
|
||||||
|
#endif
|
||||||
|
|
||||||
memset(binary_string,0,20000);
|
memset(binary_string,0,20000);
|
||||||
memset(adjusted_string,0,20000);
|
memset(adjusted_string,0,20000);
|
||||||
|
|
||||||
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
|
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
|
||||||
err_code = aztec_text_process(source, binary_string, gs1);
|
/* The following to be replaced by ECI handling */
|
||||||
|
switch(symbol->input_mode) {
|
||||||
|
case DATA_MODE:
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
|
local_source[length] = '\0';
|
||||||
|
break;
|
||||||
|
case UNICODE_MODE:
|
||||||
|
err_code = latin1_process(symbol, source, local_source, &length);
|
||||||
|
if(err_code != 0) { return err_code; }
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Aztec code can't handle NULL characters */
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
if(local_source[i] == '\0') {
|
||||||
|
strcpy(symbol->errtxt, "Invalid character (NULL) in input data");
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err_code = aztec_text_process(local_source, binary_string, gs1);
|
||||||
|
|
||||||
if(err_code != 0) {
|
if(err_code != 0) {
|
||||||
strcpy(symbol->errtxt, "Input too long or too many extended ASCII characters");
|
strcpy(symbol->errtxt, "Input too long or too many extended ASCII characters");
|
||||||
@ -1209,26 +1237,24 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return err_code;
|
return err_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int aztec_runes(struct zint_symbol *symbol, unsigned char source[])
|
int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int input_length, error_number, i, y, x;
|
int input_value, error_number, i, y, x;
|
||||||
int input_value;
|
|
||||||
char binary_string[28];
|
char binary_string[28];
|
||||||
unsigned char data_codewords[3], ecc_codewords[6];
|
unsigned char data_codewords[3], ecc_codewords[6];
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
input_value = 0;
|
input_value = 0;
|
||||||
input_length = ustrlen(source);
|
if(length > 3) {
|
||||||
if(input_length > 3) {
|
|
||||||
strcpy(symbol->errtxt, "Input too large");
|
strcpy(symbol->errtxt, "Input too large");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number != 0) {
|
if(error_number != 0) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in input");
|
strcpy(symbol->errtxt, "Invalid characters in input");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
switch(input_length) {
|
switch(length) {
|
||||||
case 3: input_value = 100 * ctoi(source[0]);
|
case 3: input_value = 100 * ctoi(source[0]);
|
||||||
input_value += 10 * ctoi(source[1]);
|
input_value += 10 * ctoi(source[1]);
|
||||||
input_value += ctoi(source[2]);
|
input_value += ctoi(source[2]);
|
||||||
|
@ -59,13 +59,12 @@ static char *C128Table[107] = {"212222", "222122", "222221", "121223", "121322",
|
|||||||
"411113", "411311", "113141", "114131", "311141", "411131", "211412", "211214", "211232",
|
"411113", "411311", "113141", "114131", "311141", "411131", "211412", "211214", "211232",
|
||||||
"2331112"};
|
"2331112"};
|
||||||
|
|
||||||
int parunmodd(unsigned char llyth, char nullchar);
|
int parunmodd(unsigned char llyth);
|
||||||
void grwp(int *indexliste);
|
void grwp(int *indexliste);
|
||||||
void dxsmooth(int *indexliste);
|
void dxsmooth(int *indexliste);
|
||||||
|
|
||||||
int a3_convert(unsigned char source, char nullchar) {
|
int a3_convert(unsigned char source) {
|
||||||
/* Annex A section 3 */
|
/* Annex A section 3 */
|
||||||
if(source == nullchar) { return 64; }
|
|
||||||
if(source < 32) { return source + 64; }
|
if(source < 32) { return source + 64; }
|
||||||
if((source >= 32) && (source <= 127)) { return source - 32; }
|
if((source >= 32) && (source <= 127)) { return source - 32; }
|
||||||
if((source >= 128) && (source <= 159)) { return (source - 128) + 64; }
|
if((source >= 128) && (source <= 159)) { return (source - 128) + 64; }
|
||||||
@ -73,12 +72,8 @@ int a3_convert(unsigned char source, char nullchar) {
|
|||||||
return (source - 128) - 32;
|
return (source - 128) - 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
int character_subset_select(unsigned char source[], int input_position, char nullchar) {
|
int character_subset_select(unsigned char source[], int input_position) {
|
||||||
/* Section 4.5.2 - Determining the Character Subset Selector in a Row */
|
/* Section 4.5.2 - Determining the Character Subset Selector in a Row */
|
||||||
if(source[input_position] == nullchar) {
|
|
||||||
/* NULL character */
|
|
||||||
return MODEA;
|
|
||||||
}
|
|
||||||
|
|
||||||
if((source[input_position] >= '0') && (source[input_position + 1] <= '9')) {
|
if((source[input_position] >= '0') && (source[input_position + 1] <= '9')) {
|
||||||
/* Rule 1 */
|
/* Rule 1 */
|
||||||
@ -99,7 +94,7 @@ int character_subset_select(unsigned char source[], int input_position, char nul
|
|||||||
return MODEB;
|
return MODEB;
|
||||||
}
|
}
|
||||||
|
|
||||||
int data_encode_blockf(unsigned char source[], int subset_selector[], int blockmatrix[][62], int *columns_needed, int *rows_needed, int *final_mode, char nullchar, int gs1)
|
int data_encode_blockf(unsigned char source[], int subset_selector[], int blockmatrix[][62], int *columns_needed, int *rows_needed, int *final_mode, int gs1)
|
||||||
{
|
{
|
||||||
int i, j, input_position, input_length, current_mode, current_row, error_number;
|
int i, j, input_position, input_length, current_mode, current_row, error_number;
|
||||||
int column_position, c, done, exit_status;
|
int column_position, c, done, exit_status;
|
||||||
@ -120,7 +115,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
if(column_position == 0) {
|
if(column_position == 0) {
|
||||||
/* The Beginning of a row */
|
/* The Beginning of a row */
|
||||||
c = (*columns_needed);
|
c = (*columns_needed);
|
||||||
current_mode = character_subset_select(source, input_position, nullchar);
|
current_mode = character_subset_select(source, input_position);
|
||||||
subset_selector[current_row] = current_mode;
|
subset_selector[current_row] = current_mode;
|
||||||
if((current_row == 0) && gs1) {
|
if((current_row == 0) && gs1) {
|
||||||
/* Section 4.4.7.1 */
|
/* Section 4.4.7.1 */
|
||||||
@ -144,15 +139,15 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
/* Ensure that there is sufficient encodation capacity to continue (using the rules of Annex B.2). */
|
/* Ensure that there is sufficient encodation capacity to continue (using the rules of Annex B.2). */
|
||||||
switch(current_mode) {
|
switch(current_mode) {
|
||||||
case MODEA: /* Table B1 applies */
|
case MODEA: /* Table B1 applies */
|
||||||
if(parunmodd(source[input_position], nullchar) == ABORC) {
|
if(parunmodd(source[input_position]) == ABORC) {
|
||||||
blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
|
blockmatrix[current_row][column_position] = a3_convert(source[input_position]);
|
||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
input_position++;
|
input_position++;
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((parunmodd(source[input_position], nullchar) == SHIFTB) && (c == 1)) {
|
if((parunmodd(source[input_position]) == SHIFTB) && (c == 1)) {
|
||||||
/* Needs two symbols */
|
/* Needs two symbols */
|
||||||
blockmatrix[current_row][column_position] = 100; /* Code B */
|
blockmatrix[current_row][column_position] = 100; /* Code B */
|
||||||
column_position++;
|
column_position++;
|
||||||
@ -184,15 +179,15 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MODEB: /* Table B2 applies */
|
case MODEB: /* Table B2 applies */
|
||||||
if(parunmodd(source[input_position], nullchar) == ABORC) {
|
if(parunmodd(source[input_position]) == ABORC) {
|
||||||
blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
|
blockmatrix[current_row][column_position] = a3_convert(source[input_position]);
|
||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
input_position++;
|
input_position++;
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((parunmodd(source[input_position], nullchar) == SHIFTA) && (c == 1)) {
|
if((parunmodd(source[input_position]) == SHIFTA) && (c == 1)) {
|
||||||
/* Needs two symbols */
|
/* Needs two symbols */
|
||||||
blockmatrix[current_row][column_position] = 101; /* Code A */
|
blockmatrix[current_row][column_position] = 101; /* Code A */
|
||||||
column_position++;
|
column_position++;
|
||||||
@ -224,7 +219,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MODEC: /* Table B3 applies */
|
case MODEC: /* Table B3 applies */
|
||||||
if((parunmodd(source[input_position], nullchar) != ABORC) && (c == 1)) {
|
if((parunmodd(source[input_position]) != ABORC) && (c == 1)) {
|
||||||
/* Needs two symbols */
|
/* Needs two symbols */
|
||||||
blockmatrix[current_row][column_position] = 101; /* Code A */
|
blockmatrix[current_row][column_position] = 101; /* Code A */
|
||||||
column_position++;
|
column_position++;
|
||||||
@ -232,7 +227,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(((parunmodd(source[input_position], nullchar) == ABORC) && (parunmodd(source[input_position + 1], nullchar) != ABORC))
|
if(((parunmodd(source[input_position]) == ABORC) && (parunmodd(source[input_position + 1]) != ABORC))
|
||||||
&& (c == 1)) {
|
&& (c == 1)) {
|
||||||
/* Needs two symbols */
|
/* Needs two symbols */
|
||||||
blockmatrix[current_row][column_position] = 101; /* Code A */
|
blockmatrix[current_row][column_position] = 101; /* Code A */
|
||||||
@ -258,7 +253,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(done == 0) {
|
if(done == 0) {
|
||||||
if(((parunmodd(source[input_position], nullchar) == AORB) || (parunmodd(source[input_position], nullchar) == SHIFTA)) && (current_mode == MODEA)) {
|
if(((parunmodd(source[input_position]) == AORB) || (parunmodd(source[input_position]) == SHIFTA)) && (current_mode == MODEA)) {
|
||||||
/* Annex B section 1 rule 2 */
|
/* Annex B section 1 rule 2 */
|
||||||
/* If in Code Subset A and the next data character can be encoded in Subset A encode the next
|
/* If in Code Subset A and the next data character can be encoded in Subset A encode the next
|
||||||
character. */
|
character. */
|
||||||
@ -268,7 +263,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
|
blockmatrix[current_row][column_position] = a3_convert(source[input_position]);
|
||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
input_position++;
|
input_position++;
|
||||||
@ -277,7 +272,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(done == 0) {
|
if(done == 0) {
|
||||||
if(((parunmodd(source[input_position], nullchar) == AORB) || (parunmodd(source[input_position], nullchar) == SHIFTB)) && (current_mode == MODEB)) {
|
if(((parunmodd(source[input_position]) == AORB) || (parunmodd(source[input_position]) == SHIFTB)) && (current_mode == MODEB)) {
|
||||||
/* Annex B section 1 rule 3 */
|
/* Annex B section 1 rule 3 */
|
||||||
/* If in Code Subset B and the next data character can be encoded in subset B, encode the next
|
/* If in Code Subset B and the next data character can be encoded in subset B, encode the next
|
||||||
character. */
|
character. */
|
||||||
@ -287,7 +282,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
|
blockmatrix[current_row][column_position] = a3_convert(source[input_position]);
|
||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
input_position++;
|
input_position++;
|
||||||
@ -296,7 +291,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(done == 0) {
|
if(done == 0) {
|
||||||
if(((parunmodd(source[input_position], nullchar) == ABORC) && (parunmodd(source[input_position + 1], nullchar) == ABORC)) && (current_mode == MODEC)) {
|
if(((parunmodd(source[input_position]) == ABORC) && (parunmodd(source[input_position + 1]) == ABORC)) && (current_mode == MODEC)) {
|
||||||
/* Annex B section 1 rule 4 */
|
/* Annex B section 1 rule 4 */
|
||||||
/* If in Code Subset C and the next data are 2 digits, encode them. */
|
/* If in Code Subset C and the next data are 2 digits, encode them. */
|
||||||
blockmatrix[current_row][column_position] = (ctoi(source[input_position]) * 10) + ctoi(source[input_position + 1]);
|
blockmatrix[current_row][column_position] = (ctoi(source[input_position]) * 10) + ctoi(source[input_position + 1]);
|
||||||
@ -308,7 +303,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(done == 0) {
|
if(done == 0) {
|
||||||
if(((current_mode == MODEA) || (current_mode == MODEB)) && ((parunmodd(source[input_position], nullchar) == ABORC) || (gs1 && (source[input_position] == '[')))) {
|
if(((current_mode == MODEA) || (current_mode == MODEB)) && ((parunmodd(source[input_position])== ABORC) || (gs1 && (source[input_position] == '[')))) {
|
||||||
/* Count the number of numeric digits */
|
/* Count the number of numeric digits */
|
||||||
/* If 4 or more numeric data characters occur together when in subsets A or B:
|
/* If 4 or more numeric data characters occur together when in subsets A or B:
|
||||||
a. If there is an even number of numeric data characters, insert a Code C character before the
|
a. If there is an even number of numeric data characters, insert a Code C character before the
|
||||||
@ -321,7 +316,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
i++;
|
i++;
|
||||||
if(gs1 && (source[input_position + j] == '[')) { i++; }
|
if(gs1 && (source[input_position + j] == '[')) { i++; }
|
||||||
j++;
|
j++;
|
||||||
} while((parunmodd(source[input_position + j], nullchar) == ABORC) || (gs1 && (source[input_position + j] == '[')));
|
} while((parunmodd(source[input_position + j]) == ABORC) || (gs1 && (source[input_position + j] == '[')));
|
||||||
i--;
|
i--;
|
||||||
|
|
||||||
if(i >= 4) {
|
if(i >= 4) {
|
||||||
@ -338,14 +333,14 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
current_mode = MODEC;
|
current_mode = MODEC;
|
||||||
} else {
|
} else {
|
||||||
/* Annex B section 1 rule 5b */
|
/* Annex B section 1 rule 5b */
|
||||||
blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
|
blockmatrix[current_row][column_position] = a3_convert(source[input_position]);
|
||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
input_position++;
|
input_position++;
|
||||||
}
|
}
|
||||||
done = 1;
|
done = 1;
|
||||||
} else {
|
} else {
|
||||||
blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
|
blockmatrix[current_row][column_position] = a3_convert(source[input_position]);
|
||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
input_position++;
|
input_position++;
|
||||||
@ -355,7 +350,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(done == 0) {
|
if(done == 0) {
|
||||||
if((current_mode == MODEB) && (parunmodd(source[input_position], nullchar) == SHIFTA)) {
|
if((current_mode == MODEB) && (parunmodd(source[input_position]) == SHIFTA)) {
|
||||||
/* Annex B section 1 rule 6 */
|
/* Annex B section 1 rule 6 */
|
||||||
/* When in subset B and an ASCII control character occurs in the data:
|
/* When in subset B and an ASCII control character occurs in the data:
|
||||||
a. If there is a lower case character immediately following the control character, insert a Shift
|
a. If there is a lower case character immediately following the control character, insert a Shift
|
||||||
@ -372,7 +367,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
|
blockmatrix[current_row][column_position] = a3_convert(source[input_position]);
|
||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
input_position++;
|
input_position++;
|
||||||
@ -387,7 +382,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
|
blockmatrix[current_row][column_position] = a3_convert(source[input_position]);
|
||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
input_position++;
|
input_position++;
|
||||||
@ -398,14 +393,14 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(done == 0) {
|
if(done == 0) {
|
||||||
if((current_mode == MODEA) && (parunmodd(source[input_position], nullchar) == SHIFTB)) {
|
if((current_mode == MODEA) && (parunmodd(source[input_position]) == SHIFTB)) {
|
||||||
/* Annex B section 1 rule 7 */
|
/* Annex B section 1 rule 7 */
|
||||||
/* When in subset A and a lower case character occurs in the data:
|
/* When in subset A and a lower case character occurs in the data:
|
||||||
a. If following that character, a control character occurs in the data before the occurrence of
|
a. If following that character, a control character occurs in the data before the occurrence of
|
||||||
another lower case character, insert a Shift character before the lower case character.
|
another lower case character, insert a Shift character before the lower case character.
|
||||||
b. Otherwise, insert a Code B character before the lower case character to change to subset B. */
|
b. Otherwise, insert a Code B character before the lower case character to change to subset B. */
|
||||||
if((parunmodd(source[input_position + 1], nullchar) == SHIFTA) &&
|
if((parunmodd(source[input_position + 1]) == SHIFTA) &&
|
||||||
(parunmodd(source[input_position + 2], nullchar) == SHIFTB)) {
|
(parunmodd(source[input_position + 2]) == SHIFTB)) {
|
||||||
/* Annex B section 1 rule 7a */
|
/* Annex B section 1 rule 7a */
|
||||||
blockmatrix[current_row][column_position] = 98; /* Shift */
|
blockmatrix[current_row][column_position] = 98; /* Shift */
|
||||||
column_position++;
|
column_position++;
|
||||||
@ -416,7 +411,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
|
blockmatrix[current_row][column_position] = a3_convert(source[input_position]);
|
||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
input_position++;
|
input_position++;
|
||||||
@ -431,7 +426,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
|
blockmatrix[current_row][column_position] = a3_convert(source[input_position]);
|
||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
input_position++;
|
input_position++;
|
||||||
@ -442,8 +437,8 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(done == 0) {
|
if(done == 0) {
|
||||||
if((current_mode == MODEC) && ((parunmodd(source[input_position], nullchar) != ABORC) ||
|
if((current_mode == MODEC) && ((parunmodd(source[input_position]) != ABORC) ||
|
||||||
(parunmodd(source[input_position + 1], nullchar) != ABORC))) {
|
(parunmodd(source[input_position + 1]) != ABORC))) {
|
||||||
/* Annex B section 1 rule 8 */
|
/* Annex B section 1 rule 8 */
|
||||||
/* When in subset C and a non-numeric character (or a single digit) occurs in the data, insert a Code
|
/* When in subset C and a non-numeric character (or a single digit) occurs in the data, insert a Code
|
||||||
A or Code B character before that character, following rules 8a and 8b to determine between code
|
A or Code B character before that character, following rules 8a and 8b to determine between code
|
||||||
@ -451,7 +446,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
a. If an ASCII control character (eg NUL) occurs in the data before any lower case character, use
|
a. If an ASCII control character (eg NUL) occurs in the data before any lower case character, use
|
||||||
Code A.
|
Code A.
|
||||||
b. Otherwise use Code B. */
|
b. Otherwise use Code B. */
|
||||||
if(parunmodd(source[input_position], nullchar) == SHIFTA) {
|
if(parunmodd(source[input_position]) == SHIFTA) {
|
||||||
/* Annex B section 1 rule 8a */
|
/* Annex B section 1 rule 8a */
|
||||||
blockmatrix[current_row][column_position] = 101; /* Code A */
|
blockmatrix[current_row][column_position] = 101; /* Code A */
|
||||||
column_position++;
|
column_position++;
|
||||||
@ -462,7 +457,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
|
blockmatrix[current_row][column_position] = a3_convert(source[input_position]);
|
||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
input_position++;
|
input_position++;
|
||||||
@ -478,7 +473,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
|
blockmatrix[current_row][column_position] = a3_convert(source[input_position]);
|
||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
input_position++;
|
input_position++;
|
||||||
@ -573,7 +568,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int codablock(struct zint_symbol *symbol, unsigned char source[])
|
int codablock(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int error_number, input_length, i, j, k;
|
int error_number, input_length, i, j, k;
|
||||||
int rows_needed, columns_needed;
|
int rows_needed, columns_needed;
|
||||||
@ -588,7 +583,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
int gs1;
|
int gs1;
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
input_length = ustrlen(source);
|
input_length = length;
|
||||||
final_mode = MODEA;
|
final_mode = MODEA;
|
||||||
|
|
||||||
if(input_length > 5450) {
|
if(input_length > 5450) {
|
||||||
@ -602,7 +597,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
estimate_codelength = 0.0;
|
estimate_codelength = 0.0;
|
||||||
last_mode = AORB; /* Codablock always starts with Code A */
|
last_mode = AORB; /* Codablock always starts with Code A */
|
||||||
for(i = 0; i < input_length; i++) {
|
for(i = 0; i < input_length; i++) {
|
||||||
this_mode = parunmodd(source[i], symbol->nullchar);
|
this_mode = parunmodd(source[i]);
|
||||||
if(this_mode != last_mode) {
|
if(this_mode != last_mode) {
|
||||||
estimate_codelength += 1.0;
|
estimate_codelength += 1.0;
|
||||||
}
|
}
|
||||||
@ -629,7 +624,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Encode the data */
|
/* Encode the data */
|
||||||
error_number = data_encode_blockf(source, subset_selector, blockmatrix, &columns_needed, &rows_needed, &final_mode, symbol->nullchar, gs1);
|
error_number = data_encode_blockf(source, subset_selector, blockmatrix, &columns_needed, &rows_needed, &final_mode, gs1);
|
||||||
if(error_number > 0) {
|
if(error_number > 0) {
|
||||||
if(error_number == ERROR_TOO_LONG) {
|
if(error_number == ERROR_TOO_LONG) {
|
||||||
strcpy(symbol->errtxt, "Input data too long");
|
strcpy(symbol->errtxt, "Input data too long");
|
||||||
|
132
backend/code.c
132
backend/code.c
@ -85,7 +85,7 @@ void NextB(int Chan, int i, int MaxB, int MaxS);
|
|||||||
|
|
||||||
/* *********************** CODE 11 ******************** */
|
/* *********************** CODE 11 ******************** */
|
||||||
|
|
||||||
int code_11(struct zint_symbol *symbol, unsigned char source[])
|
int code_11(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Code 11 */
|
{ /* Code 11 */
|
||||||
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@ -97,11 +97,11 @@ int code_11(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 121) {
|
if(length > 121) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NASET, source);
|
error_number = is_sane(NASET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -115,7 +115,7 @@ int code_11(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
concat (dest, "112211");
|
concat (dest, "112211");
|
||||||
|
|
||||||
/* Draw main body of barcode */
|
/* Draw main body of barcode */
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < length; i++) {
|
||||||
lookup(NASET, C11Table, source[i], dest);
|
lookup(NASET, C11Table, source[i], dest);
|
||||||
if(source[i] == '-')
|
if(source[i] == '-')
|
||||||
weight[i] = 10;
|
weight[i] = 10;
|
||||||
@ -124,7 +124,7 @@ int code_11(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate C checksum */
|
/* Calculate C checksum */
|
||||||
for(h = (ustrlen(source) - 1); h >= 0; h--) {
|
for(h = (length - 1); h >= 0; h--) {
|
||||||
c_count += (c_weight * weight[h]);
|
c_count += (c_weight * weight[h]);
|
||||||
c_weight++;
|
c_weight++;
|
||||||
|
|
||||||
@ -134,10 +134,10 @@ int code_11(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
c_digit = c_count%11;
|
c_digit = c_count%11;
|
||||||
|
|
||||||
weight[ustrlen(source)] = c_digit;
|
weight[length] = c_digit;
|
||||||
|
|
||||||
/* Calculate K checksum */
|
/* Calculate K checksum */
|
||||||
for(h = ustrlen(source); h >= 0; h--) {
|
for(h = length; h >= 0; h--) {
|
||||||
k_count += (k_weight * weight[h]);
|
k_count += (k_weight * weight[h]);
|
||||||
k_weight++;
|
k_weight++;
|
||||||
|
|
||||||
@ -165,14 +165,15 @@ int code_11(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int c39(struct zint_symbol *symbol, unsigned char source[])
|
int c39(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Code 39 */
|
{ /* Code 39 */
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int counter;
|
unsigned int counter;
|
||||||
char check_digit;
|
char check_digit;
|
||||||
int h, error_number;
|
int error_number;
|
||||||
char dest[775];
|
char dest[775];
|
||||||
char localstr[3];
|
char localstr[3];
|
||||||
|
unsigned char local_source[75];
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
@ -183,19 +184,22 @@ int c39(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
symbol->option_2 = 0;
|
symbol->option_2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
to_upper(source);
|
|
||||||
if(symbol->symbology == BARCODE_LOGMARS) {
|
if(symbol->symbology == BARCODE_LOGMARS) {
|
||||||
if(ustrlen(source) > 59) {
|
if(length > 59) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(ustrlen(source) > 74) {
|
if(length > 74) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error_number = is_sane(TCSET , source);
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
|
to_upper(local_source);
|
||||||
|
error_number = is_sane(TCSET , local_source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -204,9 +208,9 @@ int c39(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
/* Start character */
|
/* Start character */
|
||||||
concat(dest, "1211212111");
|
concat(dest, "1211212111");
|
||||||
|
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < length; i++) {
|
||||||
lookup(TCSET, C39Table, source[i], dest);
|
lookup(TCSET, C39Table, local_source[i], dest);
|
||||||
counter += posn(TCSET, source[i]);
|
counter += posn(TCSET, local_source[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((symbol->symbology == BARCODE_LOGMARS) || (symbol->option_2 == 1)) {
|
if((symbol->symbology == BARCODE_LOGMARS) || (symbol->option_2 == 1)) {
|
||||||
@ -237,7 +241,6 @@ int c39(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
check_digit = '_';
|
check_digit = '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
h = ustrlen(source);
|
|
||||||
localstr[0] = check_digit;
|
localstr[0] = check_digit;
|
||||||
localstr[1] = '\0';
|
localstr[1] = '\0';
|
||||||
}
|
}
|
||||||
@ -258,40 +261,39 @@ int c39(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
if(symbol->symbology == BARCODE_CODE39) {
|
if(symbol->symbology == BARCODE_CODE39) {
|
||||||
ustrcpy(symbol->text, (unsigned char*)"*");
|
ustrcpy(symbol->text, (unsigned char*)"*");
|
||||||
uconcat(symbol->text, source);
|
uconcat(symbol->text, local_source);
|
||||||
uconcat(symbol->text, (unsigned char*)localstr);
|
uconcat(symbol->text, (unsigned char*)localstr);
|
||||||
uconcat(symbol->text, (unsigned char*)"*");
|
uconcat(symbol->text, (unsigned char*)"*");
|
||||||
} else {
|
} else {
|
||||||
ustrcpy(symbol->text, source);
|
ustrcpy(symbol->text, local_source);
|
||||||
uconcat(symbol->text, (unsigned char*)localstr);
|
uconcat(symbol->text, (unsigned char*)localstr);
|
||||||
}
|
}
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pharmazentral(struct zint_symbol *symbol, unsigned char source[])
|
int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Pharmazentral Nummer (PZN) */
|
{ /* Pharmazentral Nummer (PZN) */
|
||||||
|
|
||||||
int i, error_number;
|
int i, error_number;
|
||||||
unsigned int h, count, check_digit;
|
unsigned int count, check_digit;
|
||||||
char localstr[10], checkstr[3];
|
char localstr[10], checkstr[3];
|
||||||
int zeroes;
|
int zeroes;
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
h = ustrlen(source);
|
if(length > 6) {
|
||||||
if(h > 6) {
|
|
||||||
strcpy(symbol->errtxt, "Input wrong length");
|
strcpy(symbol->errtxt, "Input wrong length");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(localstr, "-");
|
strcpy(localstr, "-");
|
||||||
zeroes = 6 - h;
|
zeroes = 6 - length;
|
||||||
for(i = 0; i < zeroes; i++)
|
for(i = 0; i < zeroes; i++)
|
||||||
concat(localstr, "0");
|
concat(localstr, "0");
|
||||||
concat(localstr, (char *)source);
|
concat(localstr, (char *)source);
|
||||||
@ -310,7 +312,8 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
concat(localstr, checkstr);
|
concat(localstr, checkstr);
|
||||||
error_number = c39(symbol, (unsigned char *)localstr);
|
length = strlen(localstr);
|
||||||
|
error_number = c39(symbol, (unsigned char *)localstr, length);
|
||||||
ustrcpy(symbol->text, (unsigned char *)"PZN");
|
ustrcpy(symbol->text, (unsigned char *)"PZN");
|
||||||
uconcat(symbol->text, (unsigned char *)localstr);
|
uconcat(symbol->text, (unsigned char *)localstr);
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -319,24 +322,23 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
/* ************** EXTENDED CODE 39 *************** */
|
/* ************** EXTENDED CODE 39 *************** */
|
||||||
|
|
||||||
int ec39(struct zint_symbol *symbol, unsigned char source[])
|
int ec39(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Extended Code 39 - ISO/IEC 16388:2007 Annex A */
|
{ /* Extended Code 39 - ISO/IEC 16388:2007 Annex A */
|
||||||
|
|
||||||
unsigned char buffer[150];
|
unsigned char buffer[150];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int ascii_value;
|
|
||||||
int error_number;
|
int error_number;
|
||||||
|
|
||||||
memset(buffer,0,150);
|
memset(buffer,0,150);
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 74) {
|
if(length > 74) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < length; i++) {
|
||||||
if(source[i] > 127) {
|
if(source[i] > 127) {
|
||||||
/* Cannot encode extended ASCII */
|
/* Cannot encode extended ASCII */
|
||||||
strcpy(symbol->errtxt, "Invalid characters in input data");
|
strcpy(symbol->errtxt, "Invalid characters in input data");
|
||||||
@ -345,30 +347,27 @@ int ec39(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Creates a buffer string and places control characters into it */
|
/* Creates a buffer string and places control characters into it */
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < length; i++) {
|
||||||
ascii_value = source[i];
|
concat((char*)buffer, EC39Ctrl[source[i]]);
|
||||||
if(ascii_value == symbol->nullchar) {
|
|
||||||
concat((char*)buffer, EC39Ctrl[0]);
|
|
||||||
} else {
|
|
||||||
concat((char*)buffer, EC39Ctrl[ascii_value]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then sends the buffer to the C39 function */
|
/* Then sends the buffer to the C39 function */
|
||||||
error_number = c39(symbol, buffer);
|
error_number = c39(symbol, buffer, ustrlen(buffer));
|
||||||
|
|
||||||
ustrcpy(symbol->text, source);
|
for(i = 0; i < length; i++) {
|
||||||
for(i = 0; i < ustrlen(symbol->text); i++) {
|
if(source[i] == '\0') {
|
||||||
if(symbol->text[i] == symbol->nullchar) {
|
|
||||||
symbol->text[i] = ' ';
|
symbol->text[i] = ' ';
|
||||||
|
} else {
|
||||||
|
symbol->text[i] = source[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
symbol->text[length] = '\0';
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ******************** CODE 93 ******************* */
|
/* ******************** CODE 93 ******************* */
|
||||||
|
|
||||||
int c93(struct zint_symbol *symbol, unsigned char source[])
|
int c93(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Code 93 is an advancement on Code 39 and the definition is a lot tighter */
|
{ /* Code 93 is an advancement on Code 39 and the definition is a lot tighter */
|
||||||
|
|
||||||
/* TCSET includes the extra characters a, b, c and d to represent Code 93 specific
|
/* TCSET includes the extra characters a, b, c and d to represent Code 93 specific
|
||||||
@ -379,7 +378,6 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
int h, weight, c, k, values[100], error_number;
|
int h, weight, c, k, values[100], error_number;
|
||||||
char buffer[220], temp[2];
|
char buffer[220], temp[2];
|
||||||
char set_copy[] = TCSET;
|
char set_copy[] = TCSET;
|
||||||
int ascii_value;
|
|
||||||
char dest[670];
|
char dest[670];
|
||||||
unsigned char local_source[110];
|
unsigned char local_source[110];
|
||||||
|
|
||||||
@ -387,14 +385,16 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(buffer, "");
|
strcpy(buffer, "");
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 107) {
|
if(length > 107) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
ustrcpy(local_source, source);
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
|
|
||||||
for(i = 0; i < ustrlen(local_source); i++) {
|
for(i = 0; i < length; i++) {
|
||||||
if(local_source[i] > 127) {
|
if(local_source[i] > 127) {
|
||||||
/* Cannot encode extended ASCII */
|
/* Cannot encode extended ASCII */
|
||||||
strcpy(symbol->errtxt, "Invalid characters in input data");
|
strcpy(symbol->errtxt, "Invalid characters in input data");
|
||||||
@ -406,13 +406,8 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
concat(dest, "111141");
|
concat(dest, "111141");
|
||||||
|
|
||||||
/* Message Content */
|
/* Message Content */
|
||||||
for(i = 0; i < ustrlen(local_source); i++) {
|
for(i = 0; i < length; i++) {
|
||||||
ascii_value = local_source[i];
|
concat(buffer, C93Ctrl[local_source[i]]);
|
||||||
if(ascii_value == symbol->nullchar) {
|
|
||||||
concat(buffer, C93Ctrl[0]);
|
|
||||||
} else {
|
|
||||||
concat(buffer, C93Ctrl[ascii_value]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now we can check the true length of the barcode */
|
/* Now we can check the true length of the barcode */
|
||||||
@ -475,17 +470,19 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
/* Stop character */
|
/* Stop character */
|
||||||
concat(dest, "1111411");
|
concat(dest, "1111411");
|
||||||
|
|
||||||
h = ustrlen(local_source);
|
local_source[length] = set_copy[c];
|
||||||
local_source[h] = set_copy[c];
|
local_source[length + 1] = set_copy[k];
|
||||||
local_source[h + 1] = set_copy[k];
|
local_source[length + 2] = '\0';
|
||||||
local_source[h + 2] = '\0';
|
length += 2;
|
||||||
expand(symbol, dest);
|
expand(symbol, dest);
|
||||||
ustrcpy(symbol->text, local_source);
|
for(i = 0; i < length; i++) {
|
||||||
for(i = 0; i < ustrlen(symbol->text); i++) {
|
if(local_source[i] == '\0') {
|
||||||
if(symbol->text[i] == symbol->nullchar) {
|
|
||||||
symbol->text[i] = ' ';
|
symbol->text[i] = ' ';
|
||||||
|
} else {
|
||||||
|
symbol->text[i] = local_source[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
symbol->text[length] = '\0';
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,31 +537,30 @@ void NextS(int Chan, int i, int MaxS, int MaxB) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int channel_code(struct zint_symbol *symbol, unsigned char source[]) {
|
int channel_code(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||||
/* Channel Code - According to ANSI/AIM BC12-1998 */
|
/* Channel Code - According to ANSI/AIM BC12-1998 */
|
||||||
|
|
||||||
int input_length, channels, i;
|
int channels, i;
|
||||||
int error_number = 0, range = 0, zeroes;
|
int error_number = 0, range = 0, zeroes;
|
||||||
char hrt[9];
|
char hrt[9];
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
|
||||||
target_value = 0;
|
target_value = 0;
|
||||||
|
|
||||||
if(input_length > 7) {
|
if(length > 7) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((symbol->option_2 < 3) || (symbol->option_2 > 8)) { channels = 0; } else { channels = symbol->option_2; }
|
if((symbol->option_2 < 3) || (symbol->option_2 > 8)) { channels = 0; } else { channels = symbol->option_2; }
|
||||||
if(channels == 0) { channels = input_length + 1; }
|
if(channels == 0) { channels = length + 1; }
|
||||||
if(channels == 2) { channels = 3; }
|
if(channels == 2) { channels = 3; }
|
||||||
|
|
||||||
for(i = 0; i < input_length; i++) {
|
for(i = 0; i < length; i++) {
|
||||||
target_value *= 10;
|
target_value *= 10;
|
||||||
target_value += ctoi((char) source[i]);
|
target_value += ctoi((char) source[i]);
|
||||||
}
|
}
|
||||||
@ -589,7 +585,7 @@ int channel_code(struct zint_symbol *symbol, unsigned char source[]) {
|
|||||||
NextS(channels,3,channels,channels);
|
NextS(channels,3,channels,channels);
|
||||||
|
|
||||||
strcpy(hrt, "");
|
strcpy(hrt, "");
|
||||||
zeroes = channels - 1 - input_length;
|
zeroes = channels - 1 - length;
|
||||||
for(i = 0; i < zeroes; i++) {
|
for(i = 0; i < zeroes; i++) {
|
||||||
concat(hrt, "0");
|
concat(hrt, "0");
|
||||||
}
|
}
|
||||||
|
@ -273,9 +273,8 @@ int c1_look_ahead_test(unsigned char source[], int sourcelen, int position, int
|
|||||||
return best_scheme;
|
return best_scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int target[])
|
int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int target[], int length)
|
||||||
{
|
{
|
||||||
int inputlen = ustrlen(source);
|
|
||||||
int current_mode, next_mode;
|
int current_mode, next_mode;
|
||||||
int sp, tp, gs1, i, j, latch;
|
int sp, tp, gs1, i, j, latch;
|
||||||
int c40_buffer[6], c40_p;
|
int c40_buffer[6], c40_p;
|
||||||
@ -284,14 +283,6 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
char decimal_binary[40];
|
char decimal_binary[40];
|
||||||
int byte_start = 0;
|
int byte_start = 0;
|
||||||
|
|
||||||
if(symbol->nullchar != 0x00) {
|
|
||||||
for(i = 0; i < inputlen; i++) {
|
|
||||||
if(source[i] == symbol->nullchar) {
|
|
||||||
source[i] = 0x00;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sp = 0;
|
sp = 0;
|
||||||
tp = 0;
|
tp = 0;
|
||||||
latch = 0;
|
latch = 0;
|
||||||
@ -327,7 +318,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
if(current_mode == C1_ASCII) { /* Step B - ASCII encodation */
|
if(current_mode == C1_ASCII) { /* Step B - ASCII encodation */
|
||||||
next_mode = C1_ASCII;
|
next_mode = C1_ASCII;
|
||||||
|
|
||||||
if((inputlen - sp) >= 21) { /* Step B1 */
|
if((length - sp) >= 21) { /* Step B1 */
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
for(i = 0; i < 21; i++) {
|
for(i = 0; i < 21; i++) {
|
||||||
@ -340,7 +331,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((next_mode == C1_ASCII) && ((inputlen - sp) >= 13)) { /* Step B2 */
|
if((next_mode == C1_ASCII) && ((length - sp) >= 13)) { /* Step B2 */
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
for(i = 0; i < 13; i++) {
|
for(i = 0; i < 13; i++) {
|
||||||
@ -349,7 +340,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
|
|
||||||
if (j == 13) {
|
if (j == 13) {
|
||||||
latch = 0;
|
latch = 0;
|
||||||
for(i = sp + 13; i < inputlen; i++) {
|
for(i = sp + 13; i < length; i++) {
|
||||||
if(!((source[sp + i] >= '0') && (source[sp + i] <= '9'))) { latch = 1; }
|
if(!((source[sp + i] >= '0') && (source[sp + i] <= '9'))) { latch = 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,13 +352,13 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(next_mode == C1_ASCII) { /* Step B3 */
|
if(next_mode == C1_ASCII) { /* Step B3 */
|
||||||
if(istwodigits(source, sp) && ((sp + 1) != inputlen)) {
|
if(istwodigits(source, sp) && ((sp + 1) != length)) {
|
||||||
target[tp] = (10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130;
|
target[tp] = (10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130;
|
||||||
tp++;
|
tp++;
|
||||||
sp += 2;
|
sp += 2;
|
||||||
} else {
|
} else {
|
||||||
if((gs1) && (source[sp] == '[')) {
|
if((gs1) && (source[sp] == '[')) {
|
||||||
if((inputlen - sp) >= 15) { /* Step B4 */
|
if((length - sp) >= 15) { /* Step B4 */
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
for(i = 0; i < 15; i++) {
|
for(i = 0; i < 15; i++) {
|
||||||
@ -381,7 +372,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((inputlen - sp) >= 7) { /* Step B5 */
|
if((length - sp) >= 7) { /* Step B5 */
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
for(i = 0; i < 7; i++) {
|
for(i = 0; i < 7; i++) {
|
||||||
@ -390,7 +381,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
|
|
||||||
if (j == 7) {
|
if (j == 7) {
|
||||||
latch = 0;
|
latch = 0;
|
||||||
for(i = sp + 7; i < inputlen; i++) {
|
for(i = sp + 7; i < length; i++) {
|
||||||
if(!((source[sp + i] >= '0') && (source[sp + i] <= '9'))) { latch = 1; }
|
if(!((source[sp + i] >= '0') && (source[sp + i] <= '9'))) { latch = 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,7 +397,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
if(next_mode == C1_ASCII) {
|
if(next_mode == C1_ASCII) {
|
||||||
|
|
||||||
/* Step B6 */
|
/* Step B6 */
|
||||||
next_mode = c1_look_ahead_test(source, inputlen, sp, current_mode, gs1);
|
next_mode = c1_look_ahead_test(source, length, sp, current_mode, gs1);
|
||||||
|
|
||||||
if(next_mode == C1_ASCII) {
|
if(next_mode == C1_ASCII) {
|
||||||
if(source[sp] > 127) {
|
if(source[sp] > 127) {
|
||||||
@ -432,7 +423,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
|
|
||||||
next_mode = C1_C40;
|
next_mode = C1_C40;
|
||||||
if(c40_p == 0) {
|
if(c40_p == 0) {
|
||||||
if((inputlen - sp) >= 12) {
|
if((length - sp) >= 12) {
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
for(i = 0; i < 12; i++) {
|
for(i = 0; i < 12; i++) {
|
||||||
@ -444,18 +435,18 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((inputlen - sp) >= 8) {
|
if((length - sp) >= 8) {
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
for(i = 0; i < 8; i++) {
|
for(i = 0; i < 8; i++) {
|
||||||
if((source[sp + i] >= '0') && (source[sp + i] <= '9')) { j++; }
|
if((source[sp + i] >= '0') && (source[sp + i] <= '9')) { j++; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if((inputlen - sp) == 8) {
|
if((length - sp) == 8) {
|
||||||
latch = 1;
|
latch = 1;
|
||||||
} else {
|
} else {
|
||||||
latch = 1;
|
latch = 1;
|
||||||
for(j = sp + 8; j < inputlen; j++) {
|
for(j = sp + 8; j < length; j++) {
|
||||||
if((source[j] <= '0') || (source[j] >= '9')) { latch = 0; }
|
if((source[j] <= '0') || (source[j] >= '9')) { latch = 0; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -466,7 +457,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!(done)) {
|
if(!(done)) {
|
||||||
next_mode = c1_look_ahead_test(source, inputlen, sp, current_mode, gs1);
|
next_mode = c1_look_ahead_test(source, length, sp, current_mode, gs1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,7 +508,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
|
|
||||||
next_mode = C1_TEXT;
|
next_mode = C1_TEXT;
|
||||||
if(text_p == 0) {
|
if(text_p == 0) {
|
||||||
if((inputlen - sp) >= 12) {
|
if((length - sp) >= 12) {
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
for(i = 0; i < 12; i++) {
|
for(i = 0; i < 12; i++) {
|
||||||
@ -529,18 +520,18 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((inputlen - sp) >= 8) {
|
if((length - sp) >= 8) {
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
for(i = 0; i < 8; i++) {
|
for(i = 0; i < 8; i++) {
|
||||||
if((source[sp + i] >= '0') && (source[sp + i] <= '9')) { j++; }
|
if((source[sp + i] >= '0') && (source[sp + i] <= '9')) { j++; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if((inputlen - sp) == 8) {
|
if((length - sp) == 8) {
|
||||||
latch = 1;
|
latch = 1;
|
||||||
} else {
|
} else {
|
||||||
latch = 1;
|
latch = 1;
|
||||||
for(j = sp + 8; j < inputlen; j++) {
|
for(j = sp + 8; j < length; j++) {
|
||||||
if((source[j] <= '0') || (source[j] >= '9')) { latch = 0; }
|
if((source[j] <= '0') || (source[j] >= '9')) { latch = 0; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -551,7 +542,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!(done)) {
|
if(!(done)) {
|
||||||
next_mode = c1_look_ahead_test(source, inputlen, sp, current_mode, gs1);
|
next_mode = c1_look_ahead_test(source, length, sp, current_mode, gs1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,7 +593,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
|
|
||||||
next_mode = C1_EDI;
|
next_mode = C1_EDI;
|
||||||
if(edi_p == 0) {
|
if(edi_p == 0) {
|
||||||
if((inputlen - sp) >= 12) {
|
if((length - sp) >= 12) {
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
for(i = 0; i < 12; i++) {
|
for(i = 0; i < 12; i++) {
|
||||||
@ -614,18 +605,18 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((inputlen - sp) >= 8) {
|
if((length - sp) >= 8) {
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
for(i = 0; i < 8; i++) {
|
for(i = 0; i < 8; i++) {
|
||||||
if((source[sp + i] >= '0') && (source[sp + i] <= '9')) { j++; }
|
if((source[sp + i] >= '0') && (source[sp + i] <= '9')) { j++; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if((inputlen - sp) == 8) {
|
if((length - sp) == 8) {
|
||||||
latch = 1;
|
latch = 1;
|
||||||
} else {
|
} else {
|
||||||
latch = 1;
|
latch = 1;
|
||||||
for(j = sp + 8; j < inputlen; j++) {
|
for(j = sp + 8; j < length; j++) {
|
||||||
if((source[j] <= '0') || (source[j] >= '9')) { latch = 0; }
|
if((source[j] <= '0') || (source[j] >= '9')) { latch = 0; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -676,7 +667,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
|
|
||||||
next_mode = C1_DECIMAL;
|
next_mode = C1_DECIMAL;
|
||||||
|
|
||||||
data_left = inputlen - sp;
|
data_left = length - sp;
|
||||||
decimal_count = 0;
|
decimal_count = 0;
|
||||||
|
|
||||||
if(data_left >= 1) {
|
if(data_left >= 1) {
|
||||||
@ -831,7 +822,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
next_mode = C1_ASCII;
|
next_mode = C1_ASCII;
|
||||||
} else {
|
} else {
|
||||||
if(source[sp] <= 127) {
|
if(source[sp] <= 127) {
|
||||||
next_mode = c1_look_ahead_test(source, inputlen, sp, current_mode, gs1);
|
next_mode = c1_look_ahead_test(source, length, sp, current_mode, gs1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -863,7 +854,7 @@ int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int t
|
|||||||
strcpy(symbol->errtxt, "Input data too long");
|
strcpy(symbol->errtxt, "Input data too long");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} while (sp < inputlen);
|
} while (sp < length);
|
||||||
|
|
||||||
/* Empty buffers */
|
/* Empty buffers */
|
||||||
if(c40_p == 2) {
|
if(c40_p == 2) {
|
||||||
@ -1015,7 +1006,7 @@ void block_copy(struct zint_symbol *symbol, char grid[][120], int start_row, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int code_one(struct zint_symbol *symbol, unsigned char source[])
|
int code_one(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int size = 1, i, j, data_blocks;
|
int size = 1, i, j, data_blocks;
|
||||||
|
|
||||||
@ -1036,18 +1027,18 @@ int code_one(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
int stream[30];
|
int stream[30];
|
||||||
int block_width;
|
int block_width;
|
||||||
|
|
||||||
if(is_sane(NESET, source) == ERROR_INVALID_DATA) {
|
if(is_sane(NESET, source, length) == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid input data (Version S encodes numeric input only)");
|
strcpy(symbol->errtxt, "Invalid input data (Version S encodes numeric input only)");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
if(ustrlen(source) > 18) {
|
if(length > 18) {
|
||||||
strcpy(symbol->errtxt, "Input data too long");
|
strcpy(symbol->errtxt, "Input data too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub_version = 3; codewords = 12; block_width = 6; /* Version S-30 */
|
sub_version = 3; codewords = 12; block_width = 6; /* Version S-30 */
|
||||||
if(ustrlen(source) <= 12) { sub_version = 2; codewords = 8; block_width = 4; } /* Version S-20 */
|
if(length <= 12) { sub_version = 2; codewords = 8; block_width = 4; } /* Version S-20 */
|
||||||
if(ustrlen(source) <= 6) { sub_version = 1; codewords = 4; block_width = 2; } /* Version S-10 */
|
if(length <= 6) { sub_version = 1; codewords = 4; block_width = 2; } /* Version S-10 */
|
||||||
|
|
||||||
binary_load(elreg, (char *)source);
|
binary_load(elreg, (char *)source);
|
||||||
hex_dump(elreg);
|
hex_dump(elreg);
|
||||||
@ -1111,7 +1102,7 @@ int code_one(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
int data_cw, ecc_cw, block_width;
|
int data_cw, ecc_cw, block_width;
|
||||||
|
|
||||||
for(i = 0; i < 40; i++) { data[i] = 0; }
|
for(i = 0; i < 40; i++) { data[i] = 0; }
|
||||||
data_length = c1_encode(symbol, source, data);
|
data_length = c1_encode(symbol, source, data, length);
|
||||||
|
|
||||||
if(data_length == 0) {
|
if(data_length == 0) {
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
@ -1178,7 +1169,7 @@ int code_one(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
int data_length;
|
int data_length;
|
||||||
|
|
||||||
for(i = 0; i < 1500; i++) { data[i] = 0; }
|
for(i = 0; i < 1500; i++) { data[i] = 0; }
|
||||||
data_length = c1_encode(symbol, source, data);
|
data_length = c1_encode(symbol, source, data, length);
|
||||||
|
|
||||||
if(data_length == 0) {
|
if(data_length == 0) {
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
|
@ -61,12 +61,11 @@ static char *C128Table[107] = {"212222", "222122", "222221", "121223", "121322",
|
|||||||
"2331112"};
|
"2331112"};
|
||||||
/* Code 128 character encodation - Table 1 */
|
/* Code 128 character encodation - Table 1 */
|
||||||
|
|
||||||
int parunmodd(unsigned char llyth, char nullchar)
|
int parunmodd(unsigned char llyth)
|
||||||
{
|
{
|
||||||
int modd;
|
int modd;
|
||||||
modd = 0;
|
modd = 0;
|
||||||
|
|
||||||
if(llyth == nullchar) { return SHIFTA; }
|
|
||||||
if(llyth <= 31) { modd = SHIFTA; }
|
if(llyth <= 31) { modd = SHIFTA; }
|
||||||
if((llyth >= 32) && (llyth <= 95)) { modd = AORB; }
|
if((llyth >= 32) && (llyth <= 95)) { modd = AORB; }
|
||||||
if((llyth >= 48) && (llyth <= 57)) { modd = ABORC; }
|
if((llyth >= 48) && (llyth <= 57)) { modd = ABORC; }
|
||||||
@ -141,17 +140,10 @@ void dxsmooth(int *indexliste)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void c128_set_a(unsigned char source, char dest[], int values[], int *bar_chars, char nullchr)
|
void c128_set_a(unsigned char source, char dest[], int values[], int *bar_chars)
|
||||||
{ /* Translate Code 128 Set A characters into barcodes */
|
{ /* Translate Code 128 Set A characters into barcodes */
|
||||||
/* This set handles all control characters NULL to US */
|
/* This set handles all control characters NULL to US */
|
||||||
|
|
||||||
if(source == nullchr) { /* Handle NULL character substitution */
|
|
||||||
concat(dest, C128Table[64]);
|
|
||||||
values[(*bar_chars)] = 64;
|
|
||||||
(*bar_chars)++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(source > 127) {
|
if(source > 127) {
|
||||||
if(source < 160) {
|
if(source < 160) {
|
||||||
concat(dest, C128Table[(source - 128) + 64]);
|
concat(dest, C128Table[(source - 128) + 64]);
|
||||||
@ -197,7 +189,7 @@ void c128_set_c(unsigned char source_a, unsigned char source_b, char dest[], int
|
|||||||
(*bar_chars)++;
|
(*bar_chars)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int code_128(struct zint_symbol *symbol, unsigned char source[])
|
int code_128(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Handle Code 128 and NVE-18 */
|
{ /* Handle Code 128 and NVE-18 */
|
||||||
int i, j, k, e_count, values[170], bar_characters, read, total_sum, nve_check;
|
int i, j, k, e_count, values[170], bar_characters, read, total_sum, nve_check;
|
||||||
int error_number, indexchaine, indexliste, sourcelen, f_state;
|
int error_number, indexchaine, indexliste, sourcelen, f_state;
|
||||||
@ -208,7 +200,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
sourcelen = ustrlen(source);
|
sourcelen = length;
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
e_count = 0;
|
e_count = 0;
|
||||||
@ -282,7 +274,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
indexliste = 0;
|
indexliste = 0;
|
||||||
indexchaine = 0;
|
indexchaine = 0;
|
||||||
|
|
||||||
mode = parunmodd(source[indexchaine], symbol->nullchar);
|
mode = parunmodd(source[indexchaine]);
|
||||||
if((symbol->symbology == BARCODE_CODE128B) && (mode == ABORC)) {
|
if((symbol->symbology == BARCODE_CODE128B) && (mode == ABORC)) {
|
||||||
mode = AORB;
|
mode = AORB;
|
||||||
}
|
}
|
||||||
@ -296,7 +288,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
while ((list[1][indexliste] == mode) && (indexchaine < sourcelen)) {
|
while ((list[1][indexliste] == mode) && (indexchaine < sourcelen)) {
|
||||||
list[0][indexliste]++;
|
list[0][indexliste]++;
|
||||||
indexchaine++;
|
indexchaine++;
|
||||||
mode = parunmodd(source[indexchaine], symbol->nullchar);
|
mode = parunmodd(source[indexchaine]);
|
||||||
if((symbol->symbology == BARCODE_CODE128B) && (mode == ABORC)) {
|
if((symbol->symbology == BARCODE_CODE128B) && (mode == ABORC)) {
|
||||||
mode = AORB;
|
mode = AORB;
|
||||||
}
|
}
|
||||||
@ -539,7 +531,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
switch(set[read])
|
switch(set[read])
|
||||||
{ /* Encode data characters */
|
{ /* Encode data characters */
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'A': c128_set_a(source[read], dest, values, &bar_characters, symbol->nullchar);
|
case 'A': c128_set_a(source[read], dest, values, &bar_characters);
|
||||||
read++;
|
read++;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
@ -572,32 +564,33 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
/* Stop character */
|
/* Stop character */
|
||||||
concat(dest, C128Table[106]);
|
concat(dest, C128Table[106]);
|
||||||
expand(symbol, dest);
|
expand(symbol, dest);
|
||||||
ustrcpy(symbol->text, source);
|
for(i = 0; i < length; i++) {
|
||||||
for(i = 0; i < ustrlen(symbol->text); i++) {
|
if(source[i] == '\0') {
|
||||||
if(symbol->text[i] == symbol->nullchar) {
|
|
||||||
symbol->text[i] = ' ';
|
symbol->text[i] = ' ';
|
||||||
|
} else {
|
||||||
|
symbol->text[i] = source[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
symbol->text[length] = '\0';
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
int ean_128(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Handle EAN-128 (Now known as GS1-128) */
|
{ /* Handle EAN-128 (Now known as GS1-128) */
|
||||||
int i, j, e_count, values[170], bar_characters, read, total_sum;
|
int i, j, e_count, values[170], bar_characters, read, total_sum;
|
||||||
int error_number, indexchaine, indexliste, sourcelen;
|
int error_number, indexchaine, indexliste;
|
||||||
char set[170], mode, last_set;
|
char set[170], mode, last_set;
|
||||||
float glyph_count;
|
float glyph_count;
|
||||||
char dest[1000];
|
char dest[1000];
|
||||||
int separator_row, linkage_flag, c_count;
|
int separator_row, linkage_flag, c_count;
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
char reduced[ustrlen(source)];
|
char reduced[length];
|
||||||
#else
|
#else
|
||||||
char* reduced = (char*)_alloca(ustrlen(source));
|
char* reduced = (char*)_alloca(length);
|
||||||
#endif
|
#endif
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
linkage_flag = 0;
|
linkage_flag = 0;
|
||||||
sourcelen = ustrlen(source);
|
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
e_count = 0;
|
e_count = 0;
|
||||||
@ -609,12 +602,19 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
set[i] = ' ';
|
set[i] = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sourcelen > 160) {
|
if(length > 160) {
|
||||||
/* This only blocks rediculously long input - the actual length of the
|
/* This only blocks rediculously long input - the actual length of the
|
||||||
resulting barcode depends on the type of data, so this is trapped later */
|
resulting barcode depends on the type of data, so this is trapped later */
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
if(source[i] == '\0') {
|
||||||
|
/* Null characters not allowed! */
|
||||||
|
strcpy(symbol->errtxt, "NULL character in input data");
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* if part of a composite symbol make room for the separator pattern */
|
/* if part of a composite symbol make room for the separator pattern */
|
||||||
if(symbol->symbology == BARCODE_EAN128_CC) {
|
if(symbol->symbology == BARCODE_EAN128_CC) {
|
||||||
@ -633,7 +633,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
indexliste = 0;
|
indexliste = 0;
|
||||||
indexchaine = 0;
|
indexchaine = 0;
|
||||||
|
|
||||||
mode = parunmodd(reduced[indexchaine], 0x00);
|
mode = parunmodd(reduced[indexchaine]);
|
||||||
if(reduced[indexchaine] == '[') {
|
if(reduced[indexchaine] == '[') {
|
||||||
mode = ABORC;
|
mode = ABORC;
|
||||||
}
|
}
|
||||||
@ -647,7 +647,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
while ((list[1][indexliste] == mode) && (indexchaine < strlen(reduced))) {
|
while ((list[1][indexliste] == mode) && (indexchaine < strlen(reduced))) {
|
||||||
list[0][indexliste]++;
|
list[0][indexliste]++;
|
||||||
indexchaine++;
|
indexchaine++;
|
||||||
mode = parunmodd(reduced[indexchaine], 0x00);
|
mode = parunmodd(reduced[indexchaine]);
|
||||||
if(reduced[indexchaine] == '[') { mode = ABORC; }
|
if(reduced[indexchaine] == '[') { mode = ABORC; }
|
||||||
}
|
}
|
||||||
indexliste++;
|
indexliste++;
|
||||||
@ -797,7 +797,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
{ /* Encode data characters */
|
{ /* Encode data characters */
|
||||||
case 'A':
|
case 'A':
|
||||||
case 'a':
|
case 'a':
|
||||||
c128_set_a(reduced[read], dest, values, &bar_characters, 0x00);
|
c128_set_a(reduced[read], dest, values, &bar_characters);
|
||||||
read++;
|
read++;
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
@ -884,7 +884,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i <= sourcelen; i++) {
|
for(i = 0; i <= length; i++) {
|
||||||
if((source[i] != '[') && (source[i] != ']')) {
|
if((source[i] != '[') && (source[i] != ']')) {
|
||||||
symbol->text[i] = source[i];
|
symbol->text[i] = source[i];
|
||||||
}
|
}
|
||||||
@ -899,21 +899,21 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nve_18(struct zint_symbol *symbol, unsigned char source[])
|
int nve_18(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* Add check digit if encoding an NVE18 symbol */
|
/* Add check digit if encoding an NVE18 symbol */
|
||||||
int error_number, zeroes, i, j, nve_check, total_sum, sourcelen;
|
int error_number, zeroes, i, j, nve_check, total_sum, sourcelen;
|
||||||
unsigned char ean128_equiv[25];
|
unsigned char ean128_equiv[25];
|
||||||
|
|
||||||
memset(ean128_equiv, 0, 25);
|
memset(ean128_equiv, 0, 25);
|
||||||
sourcelen = ustrlen(source);
|
sourcelen = length;
|
||||||
|
|
||||||
if(sourcelen > 17) {
|
if(sourcelen > 17) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -942,34 +942,33 @@ int nve_18(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
ean128_equiv[21] = itoc(nve_check);
|
ean128_equiv[21] = itoc(nve_check);
|
||||||
ean128_equiv[22] = '\0';
|
ean128_equiv[22] = '\0';
|
||||||
|
|
||||||
error_number = ean_128(symbol, ean128_equiv);
|
error_number = ean_128(symbol, ean128_equiv, ustrlen(ean128_equiv));
|
||||||
|
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ean_14(struct zint_symbol *symbol, unsigned char source[])
|
int ean_14(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* EAN-14 - A version of EAN-128 */
|
/* EAN-14 - A version of EAN-128 */
|
||||||
int input_length, i, j, count, check_digit;
|
int i, j, count, check_digit;
|
||||||
int error_number, zeroes;
|
int error_number, zeroes;
|
||||||
unsigned char ean128_equiv[20];
|
unsigned char ean128_equiv[20];
|
||||||
|
|
||||||
memset(ean128_equiv, 0, 20);
|
memset(ean128_equiv, 0, 20);
|
||||||
input_length = ustrlen(source);
|
|
||||||
|
|
||||||
if(input_length > 13) {
|
if(length > 13) {
|
||||||
strcpy(symbol->errtxt, "Input wrong length");
|
strcpy(symbol->errtxt, "Input wrong length");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid character in data");
|
strcpy(symbol->errtxt, "Invalid character in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
concat((char*)ean128_equiv, "[01]");
|
concat((char*)ean128_equiv, "[01]");
|
||||||
zeroes = 13 - input_length;
|
zeroes = 13 - length;
|
||||||
for(i = 0; i < zeroes; i++) {
|
for(i = 0; i < zeroes; i++) {
|
||||||
j = ustrlen(ean128_equiv);
|
j = ustrlen(ean128_equiv);
|
||||||
ean128_equiv[j] = '0';
|
ean128_equiv[j] = '0';
|
||||||
@ -978,7 +977,7 @@ int ean_14(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
concat((char*)ean128_equiv, (char*)source);
|
concat((char*)ean128_equiv, (char*)source);
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
for (i = input_length - 1; i >= 0; i--)
|
for (i = length - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
count += ctoi(source[i]);
|
count += ctoi(source[i]);
|
||||||
|
|
||||||
@ -992,7 +991,7 @@ int ean_14(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
ean128_equiv[17] = itoc(check_digit);
|
ean128_equiv[17] = itoc(check_digit);
|
||||||
ean128_equiv[18] = '\0';
|
ean128_equiv[18] = '\0';
|
||||||
|
|
||||||
error_number = ean_128(symbol, ean128_equiv);
|
error_number = ean_128(symbol, ean128_equiv, ustrlen(ean128_equiv));
|
||||||
|
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ static char *C16KStartStop[8] = {"3211", "2221", "2122", "1411", "1132", "1231",
|
|||||||
static int C16KStartValues[16] = {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7};
|
static int C16KStartValues[16] = {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7};
|
||||||
static int C16KStopValues[16] = {0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3};
|
static int C16KStopValues[16] = {0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3};
|
||||||
|
|
||||||
int parunmodd(unsigned char llyth, char nullchar);
|
int parunmodd(unsigned char llyth);
|
||||||
|
|
||||||
void grwp16(int *indexliste)
|
void grwp16(int *indexliste)
|
||||||
{
|
{
|
||||||
@ -130,14 +130,8 @@ void dxsmooth16(int *indexliste)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void c16k_set_a(unsigned char source, unsigned int values[], unsigned int *bar_chars, char nullchar)
|
void c16k_set_a(unsigned char source, unsigned int values[], unsigned int *bar_chars)
|
||||||
{
|
{
|
||||||
if(source == nullchar) {
|
|
||||||
values[(*bar_chars)] = 64;
|
|
||||||
(*bar_chars)++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(source > 127) {
|
if(source > 127) {
|
||||||
if(source < 160) {
|
if(source < 160) {
|
||||||
values[(*bar_chars)] = source + 64 - 128;
|
values[(*bar_chars)] = source + 64 - 128;
|
||||||
@ -173,7 +167,7 @@ void c16k_set_c(unsigned char source_a, unsigned char source_b, unsigned int val
|
|||||||
(*bar_chars)++;
|
(*bar_chars)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int code16k(struct zint_symbol *symbol, unsigned char source[])
|
int code16k(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
char width_pattern[100];
|
char width_pattern[100];
|
||||||
int current_row, rows_needed, flip_flop, looper, first_check, second_check;
|
int current_row, rows_needed, flip_flop, looper, first_check, second_check;
|
||||||
@ -189,7 +183,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
errornum = 0;
|
errornum = 0;
|
||||||
strcpy(width_pattern, "");
|
strcpy(width_pattern, "");
|
||||||
input_length = ustrlen(source);
|
input_length = length;
|
||||||
|
|
||||||
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
|
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
|
||||||
|
|
||||||
@ -249,7 +243,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
indexliste = 0;
|
indexliste = 0;
|
||||||
indexchaine = 0;
|
indexchaine = 0;
|
||||||
|
|
||||||
mode = parunmodd(source[indexchaine], symbol->nullchar);
|
mode = parunmodd(source[indexchaine]);
|
||||||
if((gs1) && (source[indexchaine] == '[')) { mode = ABORC; } /* FNC1 */
|
if((gs1) && (source[indexchaine] == '[')) { mode = ABORC; } /* FNC1 */
|
||||||
|
|
||||||
for(i = 0; i < 160; i++) {
|
for(i = 0; i < 160; i++) {
|
||||||
@ -261,7 +255,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
while ((list[1][indexliste] == mode) && (indexchaine < input_length)) {
|
while ((list[1][indexliste] == mode) && (indexchaine < input_length)) {
|
||||||
list[0][indexliste]++;
|
list[0][indexliste]++;
|
||||||
indexchaine++;
|
indexchaine++;
|
||||||
mode = parunmodd(source[indexchaine], symbol->nullchar);
|
mode = parunmodd(source[indexchaine]);
|
||||||
if((gs1) && (source[indexchaine] == '[')) { mode = ABORC; } /* FNC1 */
|
if((gs1) && (source[indexchaine] == '[')) { mode = ABORC; } /* FNC1 */
|
||||||
}
|
}
|
||||||
indexliste++;
|
indexliste++;
|
||||||
@ -537,7 +531,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
{ /* Encode data characters */
|
{ /* Encode data characters */
|
||||||
case 'A':
|
case 'A':
|
||||||
case 'a':
|
case 'a':
|
||||||
c16k_set_a(source[read], values, &bar_characters, symbol->nullchar);
|
c16k_set_a(source[read], values, &bar_characters);
|
||||||
read++;
|
read++;
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#define INSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%!&*"
|
#define INSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%!&*"
|
||||||
/* "!" represents Shift 1 and "&" represents Shift 2, "*" represents FNC1 */
|
/* "!" represents Shift 1 and "&" represents Shift 2, "*" represents FNC1 */
|
||||||
|
|
||||||
int code_49(struct zint_symbol *symbol, unsigned char source[])
|
int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int i, j, rows, M, x_count, y_count, z_count, posn_val, local_value;
|
int i, j, rows, M, x_count, y_count, z_count, posn_val, local_value;
|
||||||
char intermediate[170];
|
char intermediate[170];
|
||||||
@ -39,14 +39,14 @@ int code_49(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
char pattern[40];
|
char pattern[40];
|
||||||
int gs1;
|
int gs1;
|
||||||
|
|
||||||
if(ustrlen(source) > 81) {
|
if(length > 81) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
|
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
|
||||||
|
|
||||||
strcpy(intermediate, "");
|
strcpy(intermediate, "");
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < length; i++) {
|
||||||
if(source[i] > 127) {
|
if(source[i] > 127) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in input data");
|
strcpy(symbol->errtxt, "Invalid characters in input data");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
@ -54,14 +54,11 @@ int code_49(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(gs1 && (i == 0)) {
|
if(gs1 && (i == 0)) {
|
||||||
concat(intermediate, "*"); /* FNC1 */
|
concat(intermediate, "*"); /* FNC1 */
|
||||||
}
|
}
|
||||||
if(source[i] == symbol->nullchar) {
|
|
||||||
concat(intermediate, c49_table7[0]);
|
if(gs1 && (source[i] == '[')) {
|
||||||
|
concat(intermediate, "*"); /* FNC1 */
|
||||||
} else {
|
} else {
|
||||||
if(gs1 && (source[i] == '[')) {
|
concat(intermediate, c49_table7[source[i]]);
|
||||||
concat(intermediate, "*"); /* FNC1 */
|
|
||||||
} else {
|
|
||||||
concat(intermediate, c49_table7[source[i]]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,11 +88,11 @@ void to_upper(unsigned char source[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_sane(char test_string[], unsigned char source[])
|
int is_sane(char test_string[], unsigned char source[], int length)
|
||||||
{ /* Verifies that a string only uses valid characters */
|
{ /* Verifies that a string only uses valid characters */
|
||||||
unsigned int i, j, latch;
|
unsigned int i, j, latch;
|
||||||
|
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < length; i++) {
|
||||||
latch = FALSE;
|
latch = FALSE;
|
||||||
for(j = 0; j < strlen(test_string); j++) {
|
for(j = 0; j < strlen(test_string); j++) {
|
||||||
if (source[i] == test_string[j]) { latch = TRUE; } }
|
if (source[i] == test_string[j]) { latch = TRUE; } }
|
||||||
@ -279,3 +279,41 @@ float froundup(float input)
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int latin1_process(struct zint_symbol *symbol, unsigned char source[], unsigned char preprocessed[], int *length)
|
||||||
|
{
|
||||||
|
int j, i, next;
|
||||||
|
|
||||||
|
/* Convert Unicode to Latin-1 for those symbologies which only support Latin-1 */
|
||||||
|
j = 0;
|
||||||
|
i = 0;
|
||||||
|
do {
|
||||||
|
next = -1;
|
||||||
|
if(source[i] < 128) {
|
||||||
|
preprocessed[j] = source[i];
|
||||||
|
j++;
|
||||||
|
next = i + 1;
|
||||||
|
} else {
|
||||||
|
if(source[i] == 0xC2) {
|
||||||
|
preprocessed[j] = source[i + 1];
|
||||||
|
j++;
|
||||||
|
next = i + 2;
|
||||||
|
}
|
||||||
|
if(source[i] == 0xC3) {
|
||||||
|
preprocessed[j] = source[i + 1] + 64;
|
||||||
|
j++;
|
||||||
|
next = i + 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(next == -1) {
|
||||||
|
strcpy(symbol->errtxt, "error: Invalid character in input string (only Latin-1 characters supported)");
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
i = next;
|
||||||
|
} while(i < *length);
|
||||||
|
preprocessed[j] = '\0';
|
||||||
|
*length = j;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ extern void uconcat(unsigned char dest[], unsigned char source[]);
|
|||||||
extern int ctoi(char source);
|
extern int ctoi(char source);
|
||||||
extern char itoc(int source);
|
extern char itoc(int source);
|
||||||
extern void to_upper(unsigned char source[]);
|
extern void to_upper(unsigned char source[]);
|
||||||
extern int is_sane(char test_string[], unsigned char source[]);
|
extern int is_sane(char test_string[], unsigned char source[], int length);
|
||||||
extern void lookup(char set_string[], char *table[], char data, char dest[]);
|
extern void lookup(char set_string[], char *table[], char data, char dest[]);
|
||||||
extern int posn(char set_string[], char data);
|
extern int posn(char set_string[], char data);
|
||||||
extern void expand(struct zint_symbol *symbol, char data[]);
|
extern void expand(struct zint_symbol *symbol, char data[]);
|
||||||
@ -60,6 +60,7 @@ extern void set_module(struct zint_symbol *symbol, int y_coord, int x_coord);
|
|||||||
extern void unset_module(struct zint_symbol *symbol, int y_coord, int x_coord);
|
extern void unset_module(struct zint_symbol *symbol, int y_coord, int x_coord);
|
||||||
extern int istwodigits(unsigned char source[], int position);
|
extern int istwodigits(unsigned char source[], int position);
|
||||||
extern float froundup(float input);
|
extern float froundup(float input);
|
||||||
|
extern int latin1_process(struct zint_symbol *symbol, unsigned char source[], unsigned char preprocessed[], int *length);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
@ -53,11 +53,11 @@
|
|||||||
#define UINT unsigned short
|
#define UINT unsigned short
|
||||||
|
|
||||||
int general_rules(char field[], char type[]);
|
int general_rules(char field[], char type[]);
|
||||||
int eanx(struct zint_symbol *symbol, unsigned char source[]);
|
int eanx(struct zint_symbol *symbol, unsigned char source[], int length);
|
||||||
int ean_128(struct zint_symbol *symbol, unsigned char source[]);
|
int ean_128(struct zint_symbol *symbol, unsigned char source[], int length);
|
||||||
int rss14(struct zint_symbol *symbol, unsigned char source[]);
|
int rss14(struct zint_symbol *symbol, unsigned char source[], int length);
|
||||||
int rsslimited(struct zint_symbol *symbol, unsigned char source[]);
|
int rsslimited(struct zint_symbol *symbol, unsigned char source[], int length);
|
||||||
int rssexpanded(struct zint_symbol *symbol, unsigned char source[]);
|
int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int length);
|
||||||
|
|
||||||
static UINT pwr928[69][7];
|
static UINT pwr928[69][7];
|
||||||
|
|
||||||
@ -368,7 +368,7 @@ int cc_b(struct zint_symbol *symbol, char source[], int cc_width)
|
|||||||
chainemc[mclength] = 920;
|
chainemc[mclength] = 920;
|
||||||
mclength++;
|
mclength++;
|
||||||
|
|
||||||
byteprocess(chainemc, &mclength, data_string, 0, length, 0, 0x00);
|
byteprocess(chainemc, &mclength, data_string, 0, length, 0);
|
||||||
|
|
||||||
/* Now figure out which variant of the symbol to use and load values accordingly */
|
/* Now figure out which variant of the symbol to use and load values accordingly */
|
||||||
|
|
||||||
@ -597,7 +597,7 @@ int cc_c(struct zint_symbol *symbol, char source[], int cc_width, int ecc_level)
|
|||||||
chainemc[mclength] = 920; /* CC-C identifier */
|
chainemc[mclength] = 920; /* CC-C identifier */
|
||||||
mclength++;
|
mclength++;
|
||||||
|
|
||||||
byteprocess(chainemc, &mclength, data_string, 0, length, 0, 0x00);
|
byteprocess(chainemc, &mclength, data_string, 0, length, 0);
|
||||||
|
|
||||||
chainemc[0] = mclength;
|
chainemc[0] = mclength;
|
||||||
|
|
||||||
@ -1752,16 +1752,16 @@ void add_leading_zeroes(struct zint_symbol *symbol)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int composite(struct zint_symbol *symbol, unsigned char source[])
|
int composite(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int error_number, cc_mode, cc_width, ecc_level;
|
int error_number, cc_mode, cc_width, ecc_level;
|
||||||
int j, i, k, separator_row;
|
int j, i, k, separator_row;
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
char reduced[ustrlen(source)];
|
char reduced[ustrlen(source)];
|
||||||
char binary_string[10 * ustrlen(source)];
|
char binary_string[10 * length];
|
||||||
#else
|
#else
|
||||||
char* reduced = (char*)_alloca(ustrlen(source) + 1);
|
char* reduced = (char*)_alloca(length + 1);
|
||||||
char* binary_string = (char*)_alloca(20 * (ustrlen(source) + 1));
|
char* binary_string = (char*)_alloca(20 * (length + 1));
|
||||||
#endif
|
#endif
|
||||||
struct zint_symbol *linear;
|
struct zint_symbol *linear;
|
||||||
int top_shift, bottom_shift;
|
int top_shift, bottom_shift;
|
||||||
@ -1778,7 +1778,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
add_leading_zeroes(symbol);
|
add_leading_zeroes(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ustrlen(source) > 2990) {
|
if(length > 2990) {
|
||||||
strcpy(symbol->errtxt, "2D component input data too long");
|
strcpy(symbol->errtxt, "2D component input data too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
@ -1807,16 +1807,16 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch(symbol->symbology) {
|
switch(symbol->symbology) {
|
||||||
case BARCODE_EANX_CC: error_number = eanx(linear, (unsigned char *)symbol->primary); break;
|
case BARCODE_EANX_CC: error_number = eanx(linear, (unsigned char *)symbol->primary, strlen(symbol->primary)); break;
|
||||||
case BARCODE_EAN128_CC: error_number = ean_128(linear, (unsigned char *)symbol->primary); break;
|
case BARCODE_EAN128_CC: error_number = ean_128(linear, (unsigned char *)symbol->primary, strlen(symbol->primary)); break;
|
||||||
case BARCODE_RSS14_CC: error_number = rss14(linear, (unsigned char *)symbol->primary); break;
|
case BARCODE_RSS14_CC: error_number = rss14(linear, (unsigned char *)symbol->primary, strlen(symbol->primary)); break;
|
||||||
case BARCODE_RSS_LTD_CC: error_number = rsslimited(linear, (unsigned char *)symbol->primary); break;
|
case BARCODE_RSS_LTD_CC: error_number = rsslimited(linear, (unsigned char *)symbol->primary, strlen(symbol->primary)); break;
|
||||||
case BARCODE_RSS_EXP_CC: error_number = rssexpanded(linear, (unsigned char *)symbol->primary); break;
|
case BARCODE_RSS_EXP_CC: error_number = rssexpanded(linear, (unsigned char *)symbol->primary, strlen(symbol->primary)); break;
|
||||||
case BARCODE_UPCA_CC: error_number = eanx(linear, (unsigned char *)symbol->primary); break;
|
case BARCODE_UPCA_CC: error_number = eanx(linear, (unsigned char *)symbol->primary, strlen(symbol->primary)); break;
|
||||||
case BARCODE_UPCE_CC: error_number = eanx(linear, (unsigned char *)symbol->primary); break;
|
case BARCODE_UPCE_CC: error_number = eanx(linear, (unsigned char *)symbol->primary, strlen(symbol->primary)); break;
|
||||||
case BARCODE_RSS14STACK_CC: error_number = rss14(linear, (unsigned char *)symbol->primary); break;
|
case BARCODE_RSS14STACK_CC: error_number = rss14(linear, (unsigned char *)symbol->primary, strlen(symbol->primary)); break;
|
||||||
case BARCODE_RSS14_OMNI_CC: error_number = rss14(linear, (unsigned char *)symbol->primary); break;
|
case BARCODE_RSS14_OMNI_CC: error_number = rss14(linear, (unsigned char *)symbol->primary, strlen(symbol->primary)); break;
|
||||||
case BARCODE_RSS_EXPSTACK_CC: error_number = rssexpanded(linear, (unsigned char *)symbol->primary); break;
|
case BARCODE_RSS_EXPSTACK_CC: error_number = rssexpanded(linear, (unsigned char *)symbol->primary, strlen(symbol->primary)); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(error_number != 0) {
|
if(error_number != 0) {
|
||||||
|
@ -326,14 +326,14 @@ int look_ahead_test(unsigned char source[], int sourcelen, int position, int cur
|
|||||||
return best_scheme;
|
return best_scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned char target[], int *last_mode)
|
int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned char target[], int *last_mode, int length)
|
||||||
{
|
{
|
||||||
/* Encodes data using ASCII, C40, Text, X12, EDIFACT or Base 256 modes as appropriate */
|
/* Encodes data using ASCII, C40, Text, X12, EDIFACT or Base 256 modes as appropriate */
|
||||||
/* Supports encoding FNC1 in supporting systems */
|
/* Supports encoding FNC1 in supporting systems */
|
||||||
|
|
||||||
int sp, tp, i, gs1;
|
int sp, tp, i, gs1;
|
||||||
int current_mode, next_mode;
|
int current_mode, next_mode;
|
||||||
int inputlen = ustrlen(source);
|
int inputlen = length;
|
||||||
int c40_buffer[6], c40_p;
|
int c40_buffer[6], c40_p;
|
||||||
int text_buffer[6], text_p;
|
int text_buffer[6], text_p;
|
||||||
int x12_buffer[6], x12_p;
|
int x12_buffer[6], x12_p;
|
||||||
@ -356,14 +356,6 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha
|
|||||||
edifact_p = 0;
|
edifact_p = 0;
|
||||||
strcpy(binary, "");
|
strcpy(binary, "");
|
||||||
|
|
||||||
if(symbol->nullchar != 0x00) {
|
|
||||||
for(i = 0; i < inputlen; i++) {
|
|
||||||
if(source[i] == symbol->nullchar) {
|
|
||||||
source[i] = 0x00;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* step (a) */
|
/* step (a) */
|
||||||
current_mode = DM_ASCII;
|
current_mode = DM_ASCII;
|
||||||
next_mode = DM_ASCII;
|
next_mode = DM_ASCII;
|
||||||
@ -768,7 +760,7 @@ void add_tail(unsigned char target[], int tp, int tail_length, int last_mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int data_matrix_200(struct zint_symbol *symbol, unsigned char source[])
|
int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int inputlen, i;
|
int inputlen, i;
|
||||||
unsigned char binary[2000];
|
unsigned char binary[2000];
|
||||||
@ -778,9 +770,30 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
int H, W, FH, FW, datablock, bytes, rsblock;
|
int H, W, FH, FW, datablock, bytes, rsblock;
|
||||||
int last_mode;
|
int last_mode;
|
||||||
unsigned char *grid = 0;
|
unsigned char *grid = 0;
|
||||||
inputlen = ustrlen(source);
|
inputlen = length;
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
unsigned char local_source[length];
|
||||||
|
#else
|
||||||
|
unsigned char local_source = (unsigned char*)_alloca(length);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The following to be replaced by ECI handling */
|
||||||
|
switch(symbol->input_mode) {
|
||||||
|
case DATA_MODE:
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
|
local_source[length] = '\0';
|
||||||
|
break;
|
||||||
|
case UNICODE_MODE:
|
||||||
|
error_number = latin1_process(symbol, source, local_source, &length);
|
||||||
|
if(error_number != 0) { return error_number; }
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
binlen = dm200encode(symbol, source, binary, &last_mode, length);
|
||||||
|
|
||||||
binlen = dm200encode(symbol, source, binary, &last_mode);
|
|
||||||
if(binlen == 0) {
|
if(binlen == 0) {
|
||||||
strcpy(symbol->errtxt, "Data too long to fit in symbol");
|
strcpy(symbol->errtxt, "Data too long to fit in symbol");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
|
@ -28,7 +28,7 @@ extern "C"
|
|||||||
{
|
{
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
extern int data_matrix_200(struct zint_symbol *symbol, unsigned char source[]);
|
extern int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int length);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include "dm200.h"
|
#include "dm200.h"
|
||||||
#else
|
#else
|
||||||
extern int data_matrix_200(struct zint_symbol *symbol, unsigned char source[]);
|
extern int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int length);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define B11SET " 0123456789"
|
#define B11SET " 0123456789"
|
||||||
@ -37,7 +37,7 @@ extern int data_matrix_200(struct zint_symbol *symbol, unsigned char source[]);
|
|||||||
#define B37SET " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
#define B37SET " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
#define B41SET " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-/"
|
#define B41SET " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,-/"
|
||||||
|
|
||||||
void crc_machine(char data_prefix_bitstream[], int scheme, unsigned char source[])
|
void crc_machine(char data_prefix_bitstream[], int scheme, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int input_length, i;
|
int input_length, i;
|
||||||
char xor_register[17];
|
char xor_register[17];
|
||||||
@ -48,7 +48,7 @@ void crc_machine(char data_prefix_bitstream[], int scheme, unsigned char source[
|
|||||||
char* precrc_bitstream_reversed;
|
char* precrc_bitstream_reversed;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
input_length = length;
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
char precrc_bitstream[(input_length * 8) + 18];
|
char precrc_bitstream[(input_length * 8) + 18];
|
||||||
@ -131,14 +131,14 @@ void crc_machine(char data_prefix_bitstream[], int scheme, unsigned char source[
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void i1_base11(char binary_string[], unsigned char source[])
|
void i1_base11(char binary_string[], unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int input_length, blocks, remainder, i, j;
|
int input_length, blocks, remainder, i, j;
|
||||||
char block_binary[22];
|
char block_binary[22];
|
||||||
int block_value, c[6], weight[6];
|
int block_value, c[6], weight[6];
|
||||||
int binary_posn;
|
int binary_posn;
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
input_length = length;
|
||||||
binary_posn = strlen(binary_string);
|
binary_posn = strlen(binary_string);
|
||||||
blocks = input_length / 6;
|
blocks = input_length / 6;
|
||||||
remainder = input_length % 6;
|
remainder = input_length % 6;
|
||||||
@ -235,14 +235,14 @@ void i1_base11(char binary_string[], unsigned char source[])
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void i2_base27(char binary_string[], unsigned char source[])
|
void i2_base27(char binary_string[], unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int input_length, blocks, remainder, i, j;
|
int input_length, blocks, remainder, i, j;
|
||||||
char block_binary[25];
|
char block_binary[25];
|
||||||
int block_value, c[5], weight[5];
|
int block_value, c[5], weight[5];
|
||||||
int binary_posn;
|
int binary_posn;
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
input_length = length;
|
||||||
blocks = input_length / 5;
|
blocks = input_length / 5;
|
||||||
remainder = input_length % 5;
|
remainder = input_length % 5;
|
||||||
binary_posn = strlen(binary_string);
|
binary_posn = strlen(binary_string);
|
||||||
@ -340,14 +340,14 @@ void i2_base27(char binary_string[], unsigned char source[])
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void i3_base37(char binary_string[], unsigned char source[])
|
void i3_base37(char binary_string[], unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int input_length, blocks, remainder, i, j;
|
int input_length, blocks, remainder, i, j;
|
||||||
char block_binary[22];
|
char block_binary[22];
|
||||||
int block_value, c[6], weight[6];
|
int block_value, c[6], weight[6];
|
||||||
int binary_posn;
|
int binary_posn;
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
input_length = length;
|
||||||
blocks = input_length / 4;
|
blocks = input_length / 4;
|
||||||
remainder = input_length % 4;
|
remainder = input_length % 4;
|
||||||
binary_posn = strlen(binary_string);
|
binary_posn = strlen(binary_string);
|
||||||
@ -436,14 +436,14 @@ void i3_base37(char binary_string[], unsigned char source[])
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void i4_base41(char binary_string[], unsigned char source[])
|
void i4_base41(char binary_string[], unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int input_length, blocks, remainder, i, j;
|
int input_length, blocks, remainder, i, j;
|
||||||
char block_binary[23];
|
char block_binary[23];
|
||||||
int block_value, c[6], weight[6];
|
int block_value, c[6], weight[6];
|
||||||
int binary_posn;
|
int binary_posn;
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
input_length = length;
|
||||||
blocks = input_length / 4;
|
blocks = input_length / 4;
|
||||||
remainder = input_length % 4;
|
remainder = input_length % 4;
|
||||||
binary_posn = strlen(binary_string);
|
binary_posn = strlen(binary_string);
|
||||||
@ -534,13 +534,13 @@ void i4_base41(char binary_string[], unsigned char source[])
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void base128(char binary_string[], unsigned char source[])
|
void base128(char binary_string[], unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int i, j, input_length;
|
int i, j, input_length;
|
||||||
char block_binary[9];
|
char block_binary[9];
|
||||||
int binary_posn;
|
int binary_posn;
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
input_length = length;
|
||||||
binary_posn = strlen(binary_string);
|
binary_posn = strlen(binary_string);
|
||||||
|
|
||||||
for(i = 0; i < input_length; i++) {
|
for(i = 0; i < input_length; i++) {
|
||||||
@ -1078,7 +1078,7 @@ void protect_ecc140(char protected_stream[], char unprotected_stream[])
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int matrix89(struct zint_symbol *symbol, unsigned char source[])
|
int matrix89(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int i, j, input_length, scheme;
|
int i, j, input_length, scheme;
|
||||||
char unprotected_stream[2210];
|
char unprotected_stream[2210];
|
||||||
@ -1091,7 +1091,7 @@ int matrix89(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
int symbol_size, hex_segment, width;
|
int symbol_size, hex_segment, width;
|
||||||
int error_number;
|
int error_number;
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
input_length = length;
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
symbol_size = 0;
|
symbol_size = 0;
|
||||||
@ -1104,10 +1104,10 @@ int matrix89(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
/* Decide which encoding scheme to use */
|
/* Decide which encoding scheme to use */
|
||||||
scheme = 128;
|
scheme = 128;
|
||||||
if(!(is_sane(B41SET, source))) { scheme = 41; }
|
if(!(is_sane(B41SET, source, length))) { scheme = 41; }
|
||||||
if(!(is_sane(B37SET, source))) { scheme = 37; }
|
if(!(is_sane(B37SET, source, length))) { scheme = 37; }
|
||||||
if(!(is_sane(B27SET, source))) { scheme = 27; }
|
if(!(is_sane(B27SET, source, length))) { scheme = 27; }
|
||||||
if(!(is_sane(B11SET, source))) { scheme = 11; }
|
if(!(is_sane(B11SET, source, length))) { scheme = 11; }
|
||||||
|
|
||||||
/* Data Prefix Bit Stream = Format ID + CRC + Data Length */
|
/* Data Prefix Bit Stream = Format ID + CRC + Data Length */
|
||||||
|
|
||||||
@ -1121,7 +1121,7 @@ int matrix89(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* CRC Value (16 bit) */
|
/* CRC Value (16 bit) */
|
||||||
crc_machine(data_prefix_bitstream, scheme, source);
|
crc_machine(data_prefix_bitstream, scheme, source, length);
|
||||||
|
|
||||||
/* Data length (9 bit) */
|
/* Data length (9 bit) */
|
||||||
if(input_length & 0x01) { concat(data_prefix_bitstream, "1"); } else { concat(data_prefix_bitstream, "0"); }
|
if(input_length & 0x01) { concat(data_prefix_bitstream, "1"); } else { concat(data_prefix_bitstream, "0"); }
|
||||||
@ -1167,11 +1167,11 @@ int matrix89(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch(scheme) {
|
switch(scheme) {
|
||||||
case 11: i1_base11(unprotected_stream, source); break;
|
case 11: i1_base11(unprotected_stream, source, length); break;
|
||||||
case 27: i2_base27(unprotected_stream, source); break;
|
case 27: i2_base27(unprotected_stream, source, length); break;
|
||||||
case 37: i3_base37(unprotected_stream, source); break;
|
case 37: i3_base37(unprotected_stream, source, length); break;
|
||||||
case 41: i4_base41(unprotected_stream, source); break;
|
case 41: i4_base41(unprotected_stream, source, length); break;
|
||||||
default: base128(unprotected_stream, source); break;
|
default: base128(unprotected_stream, source, length); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Header (ECC Bit field) LSB first */
|
/* Header (ECC Bit field) LSB first */
|
||||||
@ -1307,16 +1307,16 @@ int matrix89(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dmatrix(struct zint_symbol *symbol, unsigned char source[])
|
int dmatrix(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int error_number;
|
int error_number;
|
||||||
|
|
||||||
if(symbol->option_1 <= 1) {
|
if(symbol->option_1 <= 1) {
|
||||||
/* ECC 200 */
|
/* ECC 200 */
|
||||||
error_number = data_matrix_200(symbol, source);
|
error_number = data_matrix_200(symbol, source, length);
|
||||||
} else {
|
} else {
|
||||||
/* ECC 000 - 140 */
|
/* ECC 000 - 140 */
|
||||||
error_number = matrix89(symbol, source);
|
error_number = matrix89(symbol, source, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
return error_number;
|
return error_number;
|
||||||
|
39
backend/gridmtx.c
Normal file
39
backend/gridmtx.c
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/* gridmtx.c - Grid Matrix
|
||||||
|
|
||||||
|
libzint - the open source barcode library
|
||||||
|
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file impliments Grid Matrix as specified in
|
||||||
|
AIM Global Document Number AIMD014 Rev. 1.63 Revised 9 Dec 2008 */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <malloc.h>
|
||||||
|
#endif
|
||||||
|
#include "common.h"
|
||||||
|
#include "reedsol.h"
|
||||||
|
#include "gridmtx.h"
|
||||||
|
|
||||||
|
int grid_matrix(struct zint_symbol *symbol, unsigned char source[])
|
||||||
|
{
|
||||||
|
|
||||||
|
strcpy(symbol->errtxt, "Grid Matrix not yet implemented");
|
||||||
|
return ERROR_INVALID_OPTION;
|
||||||
|
}
|
19
backend/gridmtx.h
Normal file
19
backend/gridmtx.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* gridmtx.h - definitions for Grid Matrix
|
||||||
|
|
||||||
|
libzint - the open source barcode library
|
||||||
|
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
@ -24,15 +24,16 @@
|
|||||||
|
|
||||||
static short int BCD[40] = {
|
static short int BCD[40] = {
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
1, 0, 0, 0,
|
1, 0, 0, 0,
|
||||||
0, 1, 0, 0,
|
0, 1, 0, 0,
|
||||||
1, 1, 0, 0,
|
1, 1, 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
1, 0, 1, 0,
|
1, 0, 1, 0,
|
||||||
0, 1, 1, 0,
|
0, 1, 1, 0,
|
||||||
1, 1, 1, 0,
|
1, 1, 1, 0,
|
||||||
0, 0, 0, 1,
|
0, 0, 0, 1,
|
||||||
1, 0, 0, 1 };
|
1, 0, 0, 1
|
||||||
|
};
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -305,7 +306,7 @@ void breakup(short int fcs_bit[], unsigned short usps_crc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int imail(struct zint_symbol *symbol, unsigned char source[])
|
int imail(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
char data_pattern[200];
|
char data_pattern[200];
|
||||||
int error_number;
|
int error_number;
|
||||||
@ -320,11 +321,11 @@ int imail(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 32) {
|
if(length > 32) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NASET, source);
|
error_number = is_sane(NASET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -337,7 +338,7 @@ int imail(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
read = 0;
|
read = 0;
|
||||||
j = 0;
|
j = 0;
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < length; i++) {
|
||||||
if(source[i] == '-') {
|
if(source[i] == '-') {
|
||||||
tracker[read] = '\0';
|
tracker[read] = '\0';
|
||||||
j = 1;
|
j = 1;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -112,7 +112,7 @@ void maxi_bump(int set[], int character[], int bump_posn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxi_text_process(int mode, unsigned char source[], char nullchar)
|
int maxi_text_process(int mode, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* Format text according to Appendix A */
|
/* Format text according to Appendix A */
|
||||||
|
|
||||||
@ -120,9 +120,7 @@ int maxi_text_process(int mode, unsigned char source[], char nullchar)
|
|||||||
and [Lock in E] and so is not always the most efficient at
|
and [Lock in E] and so is not always the most efficient at
|
||||||
compressing data, but should suffice for most applications */
|
compressing data, but should suffice for most applications */
|
||||||
|
|
||||||
int set[144], character[144], i, j, done, count, length, current_set;
|
int set[144], character[144], i, j, done, count, current_set;
|
||||||
|
|
||||||
length = ustrlen(source);
|
|
||||||
|
|
||||||
if(length > 138) {
|
if(length > 138) {
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
@ -136,13 +134,8 @@ int maxi_text_process(int mode, unsigned char source[], char nullchar)
|
|||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
/* Look up characters in table from Appendix A - this gives
|
/* Look up characters in table from Appendix A - this gives
|
||||||
value and code set for most characters */
|
value and code set for most characters */
|
||||||
if(source[i] == nullchar) {
|
set[i] = maxiCodeSet[source[i]];
|
||||||
set[i] = maxiCodeSet[0];
|
character[i] = maxiSymbolChar[source[i]];
|
||||||
character[i] = maxiSymbolChar[0];
|
|
||||||
} else {
|
|
||||||
set[i] = maxiCodeSet[source[i]];
|
|
||||||
character[i] = maxiSymbolChar[source[i]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If a character can be represented in more than one code set,
|
/* If a character can be represented in more than one code set,
|
||||||
@ -551,16 +544,37 @@ void maxi_do_primary_3(char postcode[], int country, int service)
|
|||||||
maxi_codeword[9] = ((service & 0x3f0) >> 4);
|
maxi_codeword[9] = ((service & 0x3f0) >> 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxicode(struct zint_symbol *symbol, unsigned char source[])
|
int maxicode(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int i, j, block, bit, mode, countrycode = 0, service = 0;
|
int i, j, block, bit, mode, countrycode = 0, service = 0;
|
||||||
int bit_pattern[7], internal_error = 0, eclen;
|
int bit_pattern[7], internal_error = 0, eclen, error_number;
|
||||||
char postcode[12], countrystr[4], servicestr[4];
|
char postcode[12], countrystr[4], servicestr[4];
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
unsigned char local_source[length];
|
||||||
|
#else
|
||||||
|
unsigned char local_source = (unsigned char*)_alloca(length);
|
||||||
|
#endif
|
||||||
|
|
||||||
mode = symbol->option_1;
|
mode = symbol->option_1;
|
||||||
strcpy(postcode, "");
|
strcpy(postcode, "");
|
||||||
strcpy(countrystr, "");
|
strcpy(countrystr, "");
|
||||||
strcpy(servicestr, "");
|
strcpy(servicestr, "");
|
||||||
|
|
||||||
|
/* The following to be replaced by ECI handling */
|
||||||
|
switch(symbol->input_mode) {
|
||||||
|
case DATA_MODE:
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
|
local_source[length] = '\0';
|
||||||
|
break;
|
||||||
|
case UNICODE_MODE:
|
||||||
|
error_number = latin1_process(symbol, source, local_source, &length);
|
||||||
|
if(error_number != 0) { return error_number; }
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
for(i = 0; i < 145; i++) {
|
for(i = 0; i < 145; i++) {
|
||||||
maxi_codeword[i] = 0;
|
maxi_codeword[i] = 0;
|
||||||
}
|
}
|
||||||
@ -628,7 +642,7 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
maxi_codeword[0] = mode;
|
maxi_codeword[0] = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = maxi_text_process(mode, source, symbol->nullchar);
|
i = maxi_text_process(mode, local_source, length);
|
||||||
if(i == ERROR_TOO_LONG ) {
|
if(i == ERROR_TOO_LONG ) {
|
||||||
strcpy(symbol->errtxt, "Input data too long");
|
strcpy(symbol->errtxt, "Input data too long");
|
||||||
return i;
|
return i;
|
||||||
|
@ -32,9 +32,9 @@ static char *CodaTable[20] = {"11111221", "11112211", "11121121", "22111111", "1
|
|||||||
"12111121", "12112111", "12211111", "21121111", "11122111", "11221111", "21112121", "21211121",
|
"12111121", "12112111", "12211111", "21121111", "11122111", "11221111", "21112121", "21211121",
|
||||||
"21212111", "11212121", "11221211", "12121121", "11121221", "11122211"};
|
"21212111", "11212121", "11221211", "12121121", "11121221", "11122211"};
|
||||||
|
|
||||||
int c39(struct zint_symbol *symbol, unsigned char source[]);
|
int c39(struct zint_symbol *symbol, unsigned char source[], int length);
|
||||||
|
|
||||||
int pharma_one(struct zint_symbol *symbol, unsigned char source[])
|
int pharma_one(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* "Pharmacode can represent only a single integer from 3 to 131070. Unlike other
|
/* "Pharmacode can represent only a single integer from 3 to 131070. Unlike other
|
||||||
commonly used one-dimensional barcode schemes, pharmacode does not store the data in a
|
commonly used one-dimensional barcode schemes, pharmacode does not store the data in a
|
||||||
@ -57,11 +57,11 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 6) {
|
if(length > 6) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -151,7 +151,7 @@ int pharma_two_calc(struct zint_symbol *symbol, unsigned char source[], char des
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pharma_two(struct zint_symbol *symbol, unsigned char source[])
|
int pharma_two(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* Draws the patterns for two track pharmacode */
|
/* Draws the patterns for two track pharmacode */
|
||||||
char height_pattern[200];
|
char height_pattern[200];
|
||||||
@ -160,11 +160,11 @@ int pharma_two(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
int error_number = 0;
|
int error_number = 0;
|
||||||
strcpy(height_pattern, "");
|
strcpy(height_pattern, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 8) {
|
if(length > 8) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -194,52 +194,60 @@ int pharma_two(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int codabar(struct zint_symbol *symbol, unsigned char source[])
|
int codabar(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* The Codabar system consisting of simple substitution */
|
{ /* The Codabar system consisting of simple substitution */
|
||||||
|
|
||||||
int i, error_number;
|
int i, error_number;
|
||||||
char dest[1000];
|
char dest[1000];
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
unsigned char local_source[length];
|
||||||
|
#else
|
||||||
|
unsigned char local_source = (unsigned char*)_alloca(length);
|
||||||
|
#endif
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 60) { /* No stack smashing please */
|
if(length > 60) { /* No stack smashing please */
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
to_upper(source);
|
for(i = 0; i < length; i++) {
|
||||||
error_number = is_sane(CASET, source);
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
|
to_upper(local_source);
|
||||||
|
error_number = is_sane(CASET, local_source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Codabar must begin and end with the characters A, B, C or D */
|
/* Codabar must begin and end with the characters A, B, C or D */
|
||||||
if(((source[0] != 'A') && (source[0] != 'B')) &&
|
if(((local_source[0] != 'A') && (local_source[0] != 'B')) &&
|
||||||
((source[0] != 'C') && (source[0] != 'D')))
|
((local_source[0] != 'C') && (local_source[0] != 'D')))
|
||||||
{
|
{
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return 6;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(((source[ustrlen(source) - 1] != 'A') && (source[ustrlen(source) - 1] != 'B')) &&
|
if(((local_source[ustrlen(local_source) - 1] != 'A') && (local_source[ustrlen(local_source) - 1] != 'B')) &&
|
||||||
((source[ustrlen(source) - 1] != 'C') && (source[ustrlen(source) - 1] != 'D')))
|
((local_source[ustrlen(local_source) - 1] != 'C') && (local_source[ustrlen(local_source) - 1] != 'D')))
|
||||||
{
|
{
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return 6;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i <= ustrlen(source); i++)
|
for(i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
lookup(CASET, CodaTable, source[i], dest);
|
lookup(CASET, CodaTable, local_source[i], dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
expand(symbol, dest);
|
expand(symbol, dest);
|
||||||
ustrcpy(symbol->text, source);
|
ustrcpy(symbol->text, local_source);
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int code32(struct zint_symbol *symbol, unsigned char source[])
|
int code32(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Italian Pharmacode */
|
{ /* Italian Pharmacode */
|
||||||
int i, zeroes, error_number, checksum, checkpart, checkdigit;
|
int i, zeroes, error_number, checksum, checkpart, checkdigit;
|
||||||
char localstr[10], tempstr[2], risultante[7];
|
char localstr[10], tempstr[2], risultante[7];
|
||||||
@ -248,11 +256,11 @@ int code32(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
char tabella[34];
|
char tabella[34];
|
||||||
|
|
||||||
/* Validate the input */
|
/* Validate the input */
|
||||||
if(ustrlen(source) > 8) {
|
if(length > 8) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -260,7 +268,7 @@ int code32(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
/* Add leading zeros as required */
|
/* Add leading zeros as required */
|
||||||
strcpy(localstr, "");
|
strcpy(localstr, "");
|
||||||
zeroes = 8 - ustrlen(source);
|
zeroes = 8 - length;
|
||||||
for(i = 0; i < zeroes; i++) {
|
for(i = 0; i < zeroes; i++) {
|
||||||
concat(localstr, "0");
|
concat(localstr, "0");
|
||||||
}
|
}
|
||||||
@ -311,7 +319,7 @@ int code32(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Plot the barcode using Code 39 */
|
/* Plot the barcode using Code 39 */
|
||||||
error_number = c39(symbol, (unsigned char*)risultante);
|
error_number = c39(symbol, (unsigned char*)risultante, strlen(risultante));
|
||||||
if(error_number != 0) { return error_number; }
|
if(error_number != 0) { return error_number; }
|
||||||
|
|
||||||
/* Override the normal text output with the Pharmacode number */
|
/* Override the normal text output with the Pharmacode number */
|
||||||
|
180
backend/micqr.c
180
backend/micqr.c
@ -25,6 +25,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "reedsol.h"
|
#include "reedsol.h"
|
||||||
#include "micqr.h"
|
#include "micqr.h"
|
||||||
|
#include "shiftjis.h"
|
||||||
|
|
||||||
#define NUMERIC 1
|
#define NUMERIC 1
|
||||||
#define ALPHANUM 2
|
#define ALPHANUM 2
|
||||||
@ -36,14 +37,14 @@
|
|||||||
void qrnumeric_encode(char binary[], unsigned char source[])
|
void qrnumeric_encode(char binary[], unsigned char source[])
|
||||||
{ /* Encodes numeric data according to section 6.4.3 */
|
{ /* Encodes numeric data according to section 6.4.3 */
|
||||||
|
|
||||||
int input_length, blocks, remainder, i;
|
int length, blocks, remainder, i;
|
||||||
char block_binary[11];
|
char block_binary[11];
|
||||||
int block_value;
|
int block_value;
|
||||||
|
|
||||||
block_value = 0;
|
block_value = 0;
|
||||||
input_length = ustrlen(source);
|
length = ustrlen(source);
|
||||||
blocks = input_length / 3;
|
blocks = length / 3;
|
||||||
remainder = input_length % 3;
|
remainder = length % 3;
|
||||||
|
|
||||||
for(i = 0; i < blocks; i++) {
|
for(i = 0; i < blocks; i++) {
|
||||||
block_value = ctoi(source[(i * 3)]) * 100;
|
block_value = ctoi(source[(i * 3)]) * 100;
|
||||||
@ -93,13 +94,13 @@ void qrnumeric_encode(char binary[], unsigned char source[])
|
|||||||
void qralpha_encode(char binary[], unsigned char source[])
|
void qralpha_encode(char binary[], unsigned char source[])
|
||||||
{ /* Encodes alphanumeric data according to 6.4.4 */
|
{ /* Encodes alphanumeric data according to 6.4.4 */
|
||||||
|
|
||||||
int input_length, blocks, remainder, i;
|
int length, blocks, remainder, i;
|
||||||
char block_binary[12];
|
char block_binary[12];
|
||||||
int block_value;
|
int block_value;
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
length = ustrlen(source);
|
||||||
blocks = input_length / 2;
|
blocks = length / 2;
|
||||||
remainder = input_length % 2;
|
remainder = length % 2;
|
||||||
|
|
||||||
for(i = 0; i < blocks; i++) {
|
for(i = 0; i < blocks; i++) {
|
||||||
block_value = posn(QRSET, source[i * 2]) * 45;
|
block_value = posn(QRSET, source[i * 2]) * 45;
|
||||||
@ -139,11 +140,11 @@ void qralpha_encode(char binary[], unsigned char source[])
|
|||||||
void qrbyte_encode(char binary[], unsigned char source[])
|
void qrbyte_encode(char binary[], unsigned char source[])
|
||||||
{ /* Encodes byte mode data according to 6.4.5 */
|
{ /* Encodes byte mode data according to 6.4.5 */
|
||||||
|
|
||||||
int input_length, i;
|
int length, i;
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
length = ustrlen(source);
|
||||||
|
|
||||||
for(i = 0; i < input_length; i++) {
|
for(i = 0; i < length; i++) {
|
||||||
if(source[i] & 0x80) { concat(binary, "1"); } else { concat(binary, "0"); }
|
if(source[i] & 0x80) { concat(binary, "1"); } else { concat(binary, "0"); }
|
||||||
if(source[i] & 0x40) { concat(binary, "1"); } else { concat(binary, "0"); }
|
if(source[i] & 0x40) { concat(binary, "1"); } else { concat(binary, "0"); }
|
||||||
if(source[i] & 0x20) { concat(binary, "1"); } else { concat(binary, "0"); }
|
if(source[i] & 0x20) { concat(binary, "1"); } else { concat(binary, "0"); }
|
||||||
@ -195,19 +196,19 @@ int qrkanji_encode(char binary[], unsigned char source[])
|
|||||||
|
|
||||||
void versionm1(char binary_data[], unsigned char source[])
|
void versionm1(char binary_data[], unsigned char source[])
|
||||||
{
|
{
|
||||||
int input_length, i, latch;
|
int length, i, latch;
|
||||||
int bits_total, bits_left, remainder;
|
int bits_total, bits_left, remainder;
|
||||||
int data_codewords, ecc_codewords;
|
int data_codewords, ecc_codewords;
|
||||||
unsigned char data_blocks[4], ecc_blocks[3];
|
unsigned char data_blocks[4], ecc_blocks[3];
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
length = ustrlen(source);
|
||||||
bits_total = 20;
|
bits_total = 20;
|
||||||
latch = 0;
|
latch = 0;
|
||||||
|
|
||||||
/* Character count indicator */
|
/* Character count indicator */
|
||||||
if(input_length & 0x04) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x04) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
if(input_length & 0x02) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x02) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
if(input_length & 0x01) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x01) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
|
|
||||||
qrnumeric_encode(binary_data, source);
|
qrnumeric_encode(binary_data, source);
|
||||||
|
|
||||||
@ -297,12 +298,12 @@ void versionm1(char binary_data[], unsigned char source[])
|
|||||||
|
|
||||||
void versionm2(char binary_data[], unsigned char source[], int char_system, int ecc_mode)
|
void versionm2(char binary_data[], unsigned char source[], int char_system, int ecc_mode)
|
||||||
{
|
{
|
||||||
int input_length, i, latch;
|
int length, i, latch;
|
||||||
int bits_total, bits_left, remainder;
|
int bits_total, bits_left, remainder;
|
||||||
int data_codewords, ecc_codewords;
|
int data_codewords, ecc_codewords;
|
||||||
unsigned char data_blocks[6], ecc_blocks[7];
|
unsigned char data_blocks[6], ecc_blocks[7];
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
length = ustrlen(source);
|
||||||
latch = 0;
|
latch = 0;
|
||||||
|
|
||||||
if(ecc_mode == 1) { bits_total = 40; }
|
if(ecc_mode == 1) { bits_total = 40; }
|
||||||
@ -314,11 +315,11 @@ void versionm2(char binary_data[], unsigned char source[], int char_system, int
|
|||||||
|
|
||||||
/* Character count indicator */
|
/* Character count indicator */
|
||||||
if(char_system == NUMERIC) {
|
if(char_system == NUMERIC) {
|
||||||
if(input_length & 0x08) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x08) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
}
|
}
|
||||||
if(input_length & 0x04) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x04) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
if(input_length & 0x02) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x02) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
if(input_length & 0x01) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x01) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
|
|
||||||
if(char_system == NUMERIC) { qrnumeric_encode(binary_data, source); }
|
if(char_system == NUMERIC) { qrnumeric_encode(binary_data, source); }
|
||||||
if(char_system == ALPHANUM) { qralpha_encode(binary_data, source); }
|
if(char_system == ALPHANUM) { qralpha_encode(binary_data, source); }
|
||||||
@ -390,13 +391,13 @@ void versionm2(char binary_data[], unsigned char source[], int char_system, int
|
|||||||
|
|
||||||
void versionm3(char binary_data[], unsigned char source[], int char_system, int ecc_mode)
|
void versionm3(char binary_data[], unsigned char source[], int char_system, int ecc_mode)
|
||||||
{
|
{
|
||||||
int input_length, i, latch;
|
int length, i, latch;
|
||||||
int bits_total, bits_left, remainder;
|
int bits_total, bits_left, remainder;
|
||||||
int data_codewords, ecc_codewords;
|
int data_codewords, ecc_codewords;
|
||||||
unsigned char data_blocks[12], ecc_blocks[9];
|
unsigned char data_blocks[12], ecc_blocks[9];
|
||||||
int sjis_count;
|
int sjis_count;
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
length = ustrlen(source);
|
||||||
latch = 0;
|
latch = 0;
|
||||||
|
|
||||||
if(ecc_mode == 1) { bits_total = 84; }
|
if(ecc_mode == 1) { bits_total = 84; }
|
||||||
@ -413,12 +414,12 @@ void versionm3(char binary_data[], unsigned char source[], int char_system, int
|
|||||||
concat(binary_data, "XXX"); /* Place holder */
|
concat(binary_data, "XXX"); /* Place holder */
|
||||||
} else {
|
} else {
|
||||||
if(char_system == NUMERIC) {
|
if(char_system == NUMERIC) {
|
||||||
if(input_length & 0x10) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x10) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
}
|
}
|
||||||
if(input_length & 0x08) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x08) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
if(input_length & 0x04) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x04) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
if(input_length & 0x02) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x02) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
if(input_length & 0x01) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x01) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
if(char_system == NUMERIC) { qrnumeric_encode(binary_data, source); }
|
if(char_system == NUMERIC) { qrnumeric_encode(binary_data, source); }
|
||||||
@ -529,13 +530,13 @@ void versionm3(char binary_data[], unsigned char source[], int char_system, int
|
|||||||
|
|
||||||
void versionm4(char binary_data[], unsigned char source[], int char_system, int ecc_mode)
|
void versionm4(char binary_data[], unsigned char source[], int char_system, int ecc_mode)
|
||||||
{
|
{
|
||||||
int input_length, i, latch;
|
int length, i, latch;
|
||||||
int bits_total, bits_left, remainder;
|
int bits_total, bits_left, remainder;
|
||||||
int data_codewords, ecc_codewords;
|
int data_codewords, ecc_codewords;
|
||||||
unsigned char data_blocks[17], ecc_blocks[15];
|
unsigned char data_blocks[17], ecc_blocks[15];
|
||||||
int sjis_count;
|
int sjis_count;
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
length = ustrlen(source);
|
||||||
latch = 0;
|
latch = 0;
|
||||||
|
|
||||||
if(ecc_mode == 1) { bits_total = 128; }
|
if(ecc_mode == 1) { bits_total = 128; }
|
||||||
@ -553,13 +554,13 @@ void versionm4(char binary_data[], unsigned char source[], int char_system, int
|
|||||||
concat(binary_data, "XXXX"); /* Place holder */
|
concat(binary_data, "XXXX"); /* Place holder */
|
||||||
} else {
|
} else {
|
||||||
if(char_system == NUMERIC) {
|
if(char_system == NUMERIC) {
|
||||||
if(input_length & 0x20) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x20) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
}
|
}
|
||||||
if(input_length & 0x10) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x10) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
if(input_length & 0x08) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x08) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
if(input_length & 0x04) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x04) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
if(input_length & 0x02) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x02) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
if(input_length & 0x01) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
if(length & 0x01) { concat(binary_data, "1"); } else { concat(binary_data, "0"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
if(char_system == NUMERIC) { qrnumeric_encode(binary_data, source); }
|
if(char_system == NUMERIC) { qrnumeric_encode(binary_data, source); }
|
||||||
@ -640,10 +641,10 @@ void versionm4(char binary_data[], unsigned char source[], int char_system, int
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int microqr(struct zint_symbol *symbol, unsigned char source[])
|
int microqr(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int symbol_size;
|
int symbol_size;
|
||||||
int char_system, input_length;
|
int char_system;
|
||||||
char binary_data[200];
|
char binary_data[200];
|
||||||
int latch;
|
int latch;
|
||||||
char bitmask[17][17];
|
char bitmask[17][17];
|
||||||
@ -651,19 +652,50 @@ int microqr(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
char candidate[17][17];
|
char candidate[17][17];
|
||||||
char pattern_bit;
|
char pattern_bit;
|
||||||
int width, i, j, pattern_no;
|
int width, i, j, pattern_no;
|
||||||
int sum1, sum2, evaluation[4], format, format_full;
|
int sum1, sum2, evaluation[4], format, format_full, kanji;
|
||||||
|
int error_number;
|
||||||
char formatstr[16];
|
char formatstr[16];
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
unsigned char local_source[length];
|
||||||
|
#else
|
||||||
|
unsigned char local_source = (unsigned char*)_alloca(length);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Analise input data and select encoding method - zint does not attempt to
|
/* Analise input data and select encoding method - zint does not attempt to
|
||||||
optimise the symbol by switching encoding method part way through the symbol,
|
optimise the symbol by switching encoding method part way through the symbol,
|
||||||
but merely chooses an encoding method for the whole symbol */
|
but merely chooses an encoding method for the whole symbol */
|
||||||
input_length = ustrlen(source);
|
|
||||||
char_system = BYTE;
|
char_system = BYTE;
|
||||||
symbol_size = 0;
|
symbol_size = 0;
|
||||||
if(is_sane(QRSET, source) == 0) { char_system = ALPHANUM; }
|
|
||||||
if(is_sane(NESET, source) == 0) { char_system = NUMERIC; }
|
for(i = 0; i < length; i++) {
|
||||||
if(symbol->input_mode == KANJI_MODE) { char_system = KANJI; }
|
if(source[i] == '\0') {
|
||||||
if(symbol->input_mode == SJIS_MODE) { char_system = KANJI; }
|
strcpy(symbol->errtxt, "QR Code not yet able to handle NULL characters");
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kanji = 0;
|
||||||
|
/* The following to be replaced by ECI handling */
|
||||||
|
switch(symbol->input_mode) {
|
||||||
|
case DATA_MODE:
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
|
local_source[length] = '\0';
|
||||||
|
break;
|
||||||
|
case UNICODE_MODE:
|
||||||
|
error_number = shiftJIS(symbol, source, local_source, &length, &kanji);
|
||||||
|
if(error_number != 0) { return error_number; }
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(kanji) {
|
||||||
|
char_system = KANJI;
|
||||||
|
} else {
|
||||||
|
if(is_sane(QRSET, local_source, length) == 0) { char_system = ALPHANUM; }
|
||||||
|
if(is_sane(NESET, local_source, length) == 0) { char_system = NUMERIC; }
|
||||||
|
}
|
||||||
width = 0;
|
width = 0;
|
||||||
format = 0;
|
format = 0;
|
||||||
|
|
||||||
@ -683,27 +715,27 @@ int microqr(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
switch(symbol->option_1) {
|
switch(symbol->option_1) {
|
||||||
case 1: /* ECC Level L */
|
case 1: /* ECC Level L */
|
||||||
switch(char_system) {
|
switch(char_system) {
|
||||||
case NUMERIC: if(input_length > 35) latch = 1; break;
|
case NUMERIC: if(length > 35) latch = 1; break;
|
||||||
case ALPHANUM: if(input_length > 21) latch = 1; break;
|
case ALPHANUM: if(length > 21) latch = 1; break;
|
||||||
case BYTE: if(input_length > 15) latch = 1; break;
|
case BYTE: if(length > 15) latch = 1; break;
|
||||||
case KANJI: if(input_length > 18) latch = 1; break;
|
case KANJI: if(length > 18) latch = 1; break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: /* ECC Level M */
|
case 2: /* ECC Level M */
|
||||||
switch(char_system) {
|
switch(char_system) {
|
||||||
case NUMERIC: if(input_length > 30) latch = 1; break;
|
case NUMERIC: if(length > 30) latch = 1; break;
|
||||||
case ALPHANUM: if(input_length > 18) latch = 1; break;
|
case ALPHANUM: if(length > 18) latch = 1; break;
|
||||||
case BYTE: if(input_length > 13) latch = 1; break;
|
case BYTE: if(length > 13) latch = 1; break;
|
||||||
case KANJI: if(input_length > 16) latch = 1; break;
|
case KANJI: if(length > 16) latch = 1; break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3: /* ECC Level Q */
|
case 3: /* ECC Level Q */
|
||||||
symbol_size = 4; /* Only size M4 supports level Q */
|
symbol_size = 4; /* Only size M4 supports level Q */
|
||||||
switch(char_system) {
|
switch(char_system) {
|
||||||
case NUMERIC: if(input_length > 21) latch = 1; break;
|
case NUMERIC: if(length > 21) latch = 1; break;
|
||||||
case ALPHANUM: if(input_length > 13) latch = 1; break;
|
case ALPHANUM: if(length > 13) latch = 1; break;
|
||||||
case BYTE: if(input_length > 9) latch = 1; break;
|
case BYTE: if(length > 9) latch = 1; break;
|
||||||
case KANJI: if(input_length > 10) latch = 1; break;
|
case KANJI: if(length > 10) latch = 1; break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -725,52 +757,52 @@ int microqr(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
switch(char_system) {
|
switch(char_system) {
|
||||||
case NUMERIC:
|
case NUMERIC:
|
||||||
symbol_size = 4;
|
symbol_size = 4;
|
||||||
if(input_length <= 23) { symbol_size = 3; }
|
if(length <= 23) { symbol_size = 3; }
|
||||||
if(input_length <= 10) { symbol_size = 2; }
|
if(length <= 10) { symbol_size = 2; }
|
||||||
if(input_length <= 5) { symbol_size = 1; }
|
if(length <= 5) { symbol_size = 1; }
|
||||||
break;
|
break;
|
||||||
case ALPHANUM:
|
case ALPHANUM:
|
||||||
symbol_size = 4;
|
symbol_size = 4;
|
||||||
if(input_length <= 14) { symbol_size = 3; }
|
if(length <= 14) { symbol_size = 3; }
|
||||||
if(input_length <= 6) { symbol_size = 2; }
|
if(length <= 6) { symbol_size = 2; }
|
||||||
break;
|
break;
|
||||||
case BYTE:
|
case BYTE:
|
||||||
symbol_size = 4;
|
symbol_size = 4;
|
||||||
if(input_length <= 9) { symbol_size = 3; }
|
if(length <= 9) { symbol_size = 3; }
|
||||||
break;
|
break;
|
||||||
case KANJI:
|
case KANJI:
|
||||||
symbol_size = 4;
|
symbol_size = 4;
|
||||||
if(input_length <= 12) { symbol_size = 3; }
|
if(length <= 12) { symbol_size = 3; }
|
||||||
}
|
}
|
||||||
} else { /* ECC Level M */
|
} else { /* ECC Level M */
|
||||||
switch(char_system) {
|
switch(char_system) {
|
||||||
case NUMERIC:
|
case NUMERIC:
|
||||||
symbol_size = 4;
|
symbol_size = 4;
|
||||||
if(input_length <= 18) { symbol_size = 3; }
|
if(length <= 18) { symbol_size = 3; }
|
||||||
if(input_length <= 8) { symbol_size = 2; }
|
if(length <= 8) { symbol_size = 2; }
|
||||||
break;
|
break;
|
||||||
case ALPHANUM:
|
case ALPHANUM:
|
||||||
symbol_size = 4;
|
symbol_size = 4;
|
||||||
if(input_length <= 11) { symbol_size = 3; }
|
if(length <= 11) { symbol_size = 3; }
|
||||||
if(input_length <= 5) { symbol_size = 2; }
|
if(length <= 5) { symbol_size = 2; }
|
||||||
break;
|
break;
|
||||||
case BYTE:
|
case BYTE:
|
||||||
symbol_size = 4;
|
symbol_size = 4;
|
||||||
if(input_length <= 7) { symbol_size = 3; }
|
if(length <= 7) { symbol_size = 3; }
|
||||||
break;
|
break;
|
||||||
case KANJI:
|
case KANJI:
|
||||||
symbol_size = 4;
|
symbol_size = 4;
|
||||||
if(input_length <= 8) { symbol_size = 3; }
|
if(length <= 8) { symbol_size = 3; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(binary_data, "");
|
strcpy(binary_data, "");
|
||||||
switch(symbol_size) {
|
switch(symbol_size) {
|
||||||
case 1: versionm1(binary_data, source); break;
|
case 1: versionm1(binary_data, local_source); break;
|
||||||
case 2: versionm2(binary_data, source, char_system, symbol->option_1); break;
|
case 2: versionm2(binary_data, local_source, char_system, symbol->option_1); break;
|
||||||
case 3: versionm3(binary_data, source, char_system, symbol->option_1); break;
|
case 3: versionm3(binary_data, local_source, char_system, symbol->option_1); break;
|
||||||
case 4: versionm4(binary_data, source, char_system, symbol->option_1); break;
|
case 4: versionm4(binary_data, local_source, char_system, symbol->option_1); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(symbol_size) {
|
switch(symbol_size) {
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
symbol->option_2 is used to adjust the width of the resulting symbol (i.e. the
|
symbol->option_2 is used to adjust the width of the resulting symbol (i.e. the
|
||||||
number of codeword columns not including row start and end data) */
|
number of codeword columns not including row start and end data) */
|
||||||
|
|
||||||
/* @(#) $Id: pdf417.c,v 1.12 2009/09/19 08:16:21 hooper114 Exp $ */
|
/* @(#) $Id: pdf417.c,v 1.13 2009/09/29 09:45:47 hooper114 Exp $ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -70,15 +70,11 @@ static int MicroAutosize[56] =
|
|||||||
int liste[2][1000]; /* global - okay, so I got _almost_ everything local! */
|
int liste[2][1000]; /* global - okay, so I got _almost_ everything local! */
|
||||||
|
|
||||||
/* 866 */
|
/* 866 */
|
||||||
int quelmode(char codeascii, char nullchar)
|
int quelmode(char codeascii)
|
||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
mode = BYT;
|
mode = BYT;
|
||||||
|
|
||||||
if(codeascii == nullchar) {
|
|
||||||
return BYT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if((codeascii >= ' ') && (codeascii <= '~')) { mode = TEX; }
|
if((codeascii >= ' ') && (codeascii <= '~')) { mode = TEX; }
|
||||||
if(codeascii == '\t') { mode = TEX; }
|
if(codeascii == '\t') { mode = TEX; }
|
||||||
if(codeascii == '\n') { mode = TEX; }
|
if(codeascii == '\n') { mode = TEX; }
|
||||||
@ -315,7 +311,7 @@ void textprocess(int *chainemc, int *mclength, char chaine[], int start, int len
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 671 */
|
/* 671 */
|
||||||
void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start, int length, int block, char nullchar)
|
void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start, int length, int block)
|
||||||
{
|
{
|
||||||
int debug = 0;
|
int debug = 0;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
@ -441,7 +437,7 @@ void numbprocess(int *chainemc, int *mclength, char chaine[], int start, int len
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 366 */
|
/* 366 */
|
||||||
int pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
int pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length)
|
||||||
{
|
{
|
||||||
int i, k, j, indexchaine, indexliste, mode, longueur, loop, mccorrection[520], offset;
|
int i, k, j, indexchaine, indexliste, mode, longueur, loop, mccorrection[520], offset;
|
||||||
int total, chainemc[2700], mclength, c1, c2, c3, dummy[35], codeerr;
|
int total, chainemc[2700], mclength, c1, c2, c3, dummy[35], codeerr;
|
||||||
@ -454,7 +450,7 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
|||||||
indexliste = 0;
|
indexliste = 0;
|
||||||
indexchaine = 0;
|
indexchaine = 0;
|
||||||
|
|
||||||
mode = quelmode(chaine[indexchaine], symbol->nullchar);
|
mode = quelmode(chaine[indexchaine]);
|
||||||
|
|
||||||
for(i = 0; i < 1000; i++) {
|
for(i = 0; i < 1000; i++) {
|
||||||
liste[0][i] = 0;
|
liste[0][i] = 0;
|
||||||
@ -463,13 +459,13 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
|||||||
/* 463 */
|
/* 463 */
|
||||||
do {
|
do {
|
||||||
liste[1][indexliste] = mode;
|
liste[1][indexliste] = mode;
|
||||||
while ((liste[1][indexliste] == mode) && (indexchaine < ustrlen(chaine))) {
|
while ((liste[1][indexliste] == mode) && (indexchaine < length)) {
|
||||||
liste[0][indexliste]++;
|
liste[0][indexliste]++;
|
||||||
indexchaine++;
|
indexchaine++;
|
||||||
mode = quelmode(chaine[indexchaine], symbol->nullchar);
|
mode = quelmode(chaine[indexchaine]);
|
||||||
}
|
}
|
||||||
indexliste++;
|
indexliste++;
|
||||||
} while (indexchaine < ustrlen(chaine));
|
} while (indexchaine < length);
|
||||||
|
|
||||||
/* 474 */
|
/* 474 */
|
||||||
pdfsmooth(&indexliste);
|
pdfsmooth(&indexliste);
|
||||||
@ -496,7 +492,7 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
|||||||
textprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i);
|
textprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i);
|
||||||
break;
|
break;
|
||||||
case BYT: /* 670 - octet stream mode */
|
case BYT: /* 670 - octet stream mode */
|
||||||
byteprocess(chainemc, &mclength, chaine, indexchaine, liste[0][i], i, symbol->nullchar);
|
byteprocess(chainemc, &mclength, chaine, indexchaine, liste[0][i], i);
|
||||||
break;
|
break;
|
||||||
case NUM: /* 712 - numeric mode */
|
case NUM: /* 712 - numeric mode */
|
||||||
numbprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i);
|
numbprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i);
|
||||||
@ -686,58 +682,78 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 345 */
|
/* 345 */
|
||||||
int pdf417enc(struct zint_symbol *symbol, unsigned char source[])
|
int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int codeerr, errno;
|
int codeerr, error_number, i;
|
||||||
|
|
||||||
errno = 0;
|
#ifndef _MSC_VER
|
||||||
|
unsigned char local_source[length];
|
||||||
|
#else
|
||||||
|
unsigned char local_source = (unsigned char*)_alloca(length);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
error_number = 0;
|
||||||
|
|
||||||
if((symbol->option_1 < -1) || (symbol->option_1 > 8)) {
|
if((symbol->option_1 < -1) || (symbol->option_1 > 8)) {
|
||||||
strcpy(symbol->errtxt, "Security value out of range");
|
strcpy(symbol->errtxt, "Security value out of range");
|
||||||
symbol->option_1 = -1;
|
symbol->option_1 = -1;
|
||||||
errno = WARN_INVALID_OPTION;
|
error_number = WARN_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
if((symbol->option_2 < 0) || (symbol->option_2 > 30)) {
|
if((symbol->option_2 < 0) || (symbol->option_2 > 30)) {
|
||||||
strcpy(symbol->errtxt, "Number of columns out of range");
|
strcpy(symbol->errtxt, "Number of columns out of range");
|
||||||
symbol->option_2 = 0;
|
symbol->option_2 = 0;
|
||||||
errno = WARN_INVALID_OPTION;
|
error_number = WARN_INVALID_OPTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The following to be replaced by ECI handling */
|
||||||
|
switch(symbol->input_mode) {
|
||||||
|
case DATA_MODE:
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
|
local_source[length] = '\0';
|
||||||
|
break;
|
||||||
|
case UNICODE_MODE:
|
||||||
|
error_number = latin1_process(symbol, source, local_source, &length);
|
||||||
|
if(error_number != 0) { return error_number; }
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 349 */
|
/* 349 */
|
||||||
codeerr = pdf417(symbol, source);
|
codeerr = pdf417(symbol, local_source, length);
|
||||||
|
|
||||||
/* 352 */
|
/* 352 */
|
||||||
if(codeerr != 0) {
|
if(codeerr != 0) {
|
||||||
switch(codeerr) {
|
switch(codeerr) {
|
||||||
case 1:
|
case 1:
|
||||||
strcpy(symbol->errtxt, "No such file or file unreadable");
|
strcpy(symbol->errtxt, "No such file or file unreadable");
|
||||||
errno = ERROR_INVALID_OPTION;
|
error_number = ERROR_INVALID_OPTION;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
strcpy(symbol->errtxt, "Input string too long");
|
strcpy(symbol->errtxt, "Input string too long");
|
||||||
errno = ERROR_TOO_LONG;
|
error_number = ERROR_TOO_LONG;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
strcpy(symbol->errtxt, "Number of codewords per row too small");
|
strcpy(symbol->errtxt, "Number of codewords per row too small");
|
||||||
errno = WARN_INVALID_OPTION;
|
error_number = WARN_INVALID_OPTION;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
strcpy(symbol->errtxt, "Data too long for specified number of columns");
|
strcpy(symbol->errtxt, "Data too long for specified number of columns");
|
||||||
errno = ERROR_TOO_LONG;
|
error_number = ERROR_TOO_LONG;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strcpy(symbol->errtxt, "Something strange happened");
|
strcpy(symbol->errtxt, "Something strange happened");
|
||||||
errno = ERROR_ENCODING_PROBLEM;
|
error_number = ERROR_ENCODING_PROBLEM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 364 */
|
/* 364 */
|
||||||
return errno;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
int micro_pdf417(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* like PDF417 only much smaller! */
|
{ /* like PDF417 only much smaller! */
|
||||||
|
|
||||||
int i, k, j, indexchaine, indexliste, mode, longueur, mccorrection[50], offset;
|
int i, k, j, indexchaine, indexliste, mode, longueur, mccorrection[50], offset;
|
||||||
@ -747,6 +763,12 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
|||||||
int LeftRAP, CentreRAP, RightRAP, Cluster, writer, flip, loop;
|
int LeftRAP, CentreRAP, RightRAP, Cluster, writer, flip, loop;
|
||||||
int debug = 0;
|
int debug = 0;
|
||||||
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
unsigned char chaine[length];
|
||||||
|
#else
|
||||||
|
unsigned char chaine = (unsigned char*)_alloca(length);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Encoding starts out the same as PDF417, so use the same code */
|
/* Encoding starts out the same as PDF417, so use the same code */
|
||||||
codeerr = 0;
|
codeerr = 0;
|
||||||
|
|
||||||
@ -754,7 +776,21 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
|||||||
indexliste = 0;
|
indexliste = 0;
|
||||||
indexchaine = 0;
|
indexchaine = 0;
|
||||||
|
|
||||||
mode = quelmode(chaine[indexchaine], symbol->nullchar);
|
/* The following to be replaced by ECI handling */
|
||||||
|
switch(symbol->input_mode) {
|
||||||
|
case DATA_MODE:
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
chaine[i] = source[i];
|
||||||
|
}
|
||||||
|
chaine[length] = '\0';
|
||||||
|
break;
|
||||||
|
case UNICODE_MODE:
|
||||||
|
codeerr = latin1_process(symbol, source, chaine, &length);
|
||||||
|
if(codeerr != 0) { return codeerr; }
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mode = quelmode(chaine[indexchaine]);
|
||||||
|
|
||||||
for(i = 0; i < 1000; i++) {
|
for(i = 0; i < 1000; i++) {
|
||||||
liste[0][i] = 0;
|
liste[0][i] = 0;
|
||||||
@ -763,13 +799,13 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
|||||||
/* 463 */
|
/* 463 */
|
||||||
do {
|
do {
|
||||||
liste[1][indexliste] = mode;
|
liste[1][indexliste] = mode;
|
||||||
while ((liste[1][indexliste] == mode) && (indexchaine < ustrlen(chaine))) {
|
while ((liste[1][indexliste] == mode) && (indexchaine < length)) {
|
||||||
liste[0][indexliste]++;
|
liste[0][indexliste]++;
|
||||||
indexchaine++;
|
indexchaine++;
|
||||||
mode = quelmode(chaine[indexchaine], symbol->nullchar);
|
mode = quelmode(chaine[indexchaine]);
|
||||||
}
|
}
|
||||||
indexliste++;
|
indexliste++;
|
||||||
} while (indexchaine < ustrlen(chaine));
|
} while (indexchaine < length);
|
||||||
|
|
||||||
/* 474 */
|
/* 474 */
|
||||||
pdfsmooth(&indexliste);
|
pdfsmooth(&indexliste);
|
||||||
@ -796,7 +832,7 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[])
|
|||||||
textprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i);
|
textprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i);
|
||||||
break;
|
break;
|
||||||
case BYT: /* 670 - octet stream mode */
|
case BYT: /* 670 - octet stream mode */
|
||||||
byteprocess(chainemc, &mclength, chaine, indexchaine, liste[0][i], i, symbol->nullchar);
|
byteprocess(chainemc, &mclength, chaine, indexchaine, liste[0][i], i);
|
||||||
break;
|
break;
|
||||||
case NUM: /* 712 - numeric mode */
|
case NUM: /* 712 - numeric mode */
|
||||||
numbprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i);
|
numbprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i);
|
||||||
|
@ -435,4 +435,4 @@ static char *RAPC[53] = {"", "112231", "121231", "122131", "131131", "131221", "
|
|||||||
"112213", "112222", "112312", "112321", "111421", "111331", "111322", "111232", "111223",
|
"112213", "112222", "112312", "112321", "111421", "111331", "111322", "111232", "111223",
|
||||||
"111133", "111124", "111214", "112114", "121114", "121123", "121132", "112132", "112141" };
|
"111133", "111124", "111214", "112114", "121114", "121123", "121132", "112132", "112141" };
|
||||||
|
|
||||||
void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start, int length, int block, char nullchar);
|
void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start, int length, int block);
|
@ -34,7 +34,7 @@ static char *MSITable[10] = {"12121212", "12121221", "12122112", "12122121", "12
|
|||||||
"12212112", "12212121", "21121212", "21121221"};
|
"12212112", "12212121", "21121212", "21121221"};
|
||||||
|
|
||||||
|
|
||||||
int plessey(struct zint_symbol *symbol, unsigned char source[])
|
int plessey(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Not MSI/Plessey but the older Plessey standard */
|
{ /* Not MSI/Plessey but the older Plessey standard */
|
||||||
|
|
||||||
unsigned int i, check;
|
unsigned int i, check;
|
||||||
@ -46,22 +46,22 @@ int plessey(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 65) {
|
if(length > 65) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(SSET, source);
|
error_number = is_sane(SSET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
checkptr = (unsigned char *)calloc (1, ustrlen(source) * 4 + 8);
|
checkptr = (unsigned char *)calloc (1, length * 4 + 8);
|
||||||
|
|
||||||
/* Start character */
|
/* Start character */
|
||||||
concat(dest, "31311331");
|
concat(dest, "31311331");
|
||||||
|
|
||||||
/* Data area */
|
/* Data area */
|
||||||
for(i = 0; i <= ustrlen(source); i++)
|
for(i = 0; i <= length; i++)
|
||||||
{
|
{
|
||||||
check = posn(SSET, source[i]);
|
check = posn(SSET, source[i]);
|
||||||
lookup(SSET, PlessTable, source[i], dest);
|
lookup(SSET, PlessTable, source[i], dest);
|
||||||
@ -74,7 +74,7 @@ int plessey(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
/* CRC check digit code adapted from code by Leonid A. Broukhis
|
/* CRC check digit code adapted from code by Leonid A. Broukhis
|
||||||
used in GNU Barcode */
|
used in GNU Barcode */
|
||||||
|
|
||||||
for (i=0; i < 4*ustrlen(source); i++) {
|
for (i = 0; i < (4 * length); i++) {
|
||||||
int j;
|
int j;
|
||||||
if (checkptr[i])
|
if (checkptr[i])
|
||||||
for (j = 0; j < 9; j++)
|
for (j = 0; j < 9; j++)
|
||||||
@ -82,7 +82,7 @@ int plessey(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
switch(checkptr[ustrlen(source) * 4 + i])
|
switch(checkptr[length * 4 + i])
|
||||||
{
|
{
|
||||||
case 0: concat(dest, "13"); break;
|
case 0: concat(dest, "13"); break;
|
||||||
case 1: concat(dest, "31"); break;
|
case 1: concat(dest, "31"); break;
|
||||||
@ -112,11 +112,6 @@ int msi_plessey(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
|
||||||
return error_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* start character */
|
/* start character */
|
||||||
concat (dest, "21");
|
concat (dest, "21");
|
||||||
@ -150,11 +145,6 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
|
||||||
return error_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* start character */
|
/* start character */
|
||||||
concat (dest, "21");
|
concat (dest, "21");
|
||||||
@ -248,11 +238,6 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
|
||||||
if (error_number == ERROR_INVALID_DATA) {
|
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
|
||||||
return error_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* start character */
|
/* start character */
|
||||||
concat (dest, "21");
|
concat (dest, "21");
|
||||||
@ -405,11 +390,6 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
|
||||||
return error_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* start character */
|
/* start character */
|
||||||
concat (dest, "21");
|
concat (dest, "21");
|
||||||
@ -475,11 +455,6 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
|
||||||
if (error_number == ERROR_INVALID_DATA) {
|
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
|
||||||
return error_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* start character */
|
/* start character */
|
||||||
concat (dest, "21");
|
concat (dest, "21");
|
||||||
@ -583,10 +558,14 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int msi_handle(struct zint_symbol *symbol, unsigned char source[]) {
|
int msi_handle(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||||
int error_number;
|
int error_number;
|
||||||
|
|
||||||
error_number=0;
|
error_number = is_sane(NESET, source, length);
|
||||||
|
if(error_number != 0) {
|
||||||
|
strcpy(symbol->errtxt, "Invalid characters in input data");
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
if((symbol->option_2 < 0) || (symbol->option_2 > 4)) {
|
if((symbol->option_2 < 0) || (symbol->option_2 > 4)) {
|
||||||
symbol->option_2 = 0;
|
symbol->option_2 = 0;
|
||||||
|
@ -65,6 +65,7 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
|
|||||||
{
|
{
|
||||||
struct mainprog_info_type wpng_info;
|
struct mainprog_info_type wpng_info;
|
||||||
struct mainprog_info_type *graphic;
|
struct mainprog_info_type *graphic;
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
unsigned char outdata[image_width * 3];
|
unsigned char outdata[image_width * 3];
|
||||||
#else
|
#else
|
||||||
@ -103,12 +104,12 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
|
|||||||
strcpy(symbol->errtxt, "Malformed background colour target");
|
strcpy(symbol->errtxt, "Malformed background colour target");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
errno = is_sane(SSET, (unsigned char*)symbol->fgcolour);
|
errno = is_sane(SSET, (unsigned char*)symbol->fgcolour, 6);
|
||||||
if (errno == ERROR_INVALID_DATA) {
|
if (errno == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Malformed foreground colour target");
|
strcpy(symbol->errtxt, "Malformed foreground colour target");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
errno = is_sane(SSET, (unsigned char*)symbol->bgcolour);
|
errno = is_sane(SSET, (unsigned char*)symbol->bgcolour, 6);
|
||||||
if (errno == ERROR_INVALID_DATA) {
|
if (errno == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Malformed background colour target");
|
strcpy(symbol->errtxt, "Malformed background colour target");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
@ -533,10 +534,12 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
|
|||||||
large_bar_count++;
|
large_bar_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
large_bar_height = (symbol->height - preset_height) / large_bar_count;
|
|
||||||
|
|
||||||
if (large_bar_count == 0) {
|
if (large_bar_count == 0) {
|
||||||
symbol->height = preset_height;
|
symbol->height = preset_height;
|
||||||
|
large_bar_height = 10;
|
||||||
|
} else {
|
||||||
|
large_bar_height = (symbol->height - preset_height) / large_bar_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!(module_is_set(symbol, symbol->rows - 1, comp_offset))) {
|
while(!(module_is_set(symbol, symbol->rows - 1, comp_offset))) {
|
||||||
|
148
backend/postal.c
148
backend/postal.c
@ -27,7 +27,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#define BESET "ABCD"
|
|
||||||
#define DAFTSET "DAFT"
|
#define DAFTSET "DAFT"
|
||||||
#define KRSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
#define KRSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
#define KASUTSET "1234567890-abcdefgh"
|
#define KASUTSET "1234567890-abcdefgh"
|
||||||
@ -40,8 +39,6 @@ static char *PNTable[10] = {"LLSSS", "SSSLL", "SSLSL", "SSLLS", "SLSSL", "SLSLS"
|
|||||||
static char *PLTable[10] = {"SSLLL", "LLLSS", "LLSLS", "LLSSL", "LSLLS", "LSLSL", "LSSLL", "SLLLS",
|
static char *PLTable[10] = {"SSLLL", "LLLSS", "LLSLS", "LLSSL", "LSLLS", "LSLSL", "LSSLL", "SLLLS",
|
||||||
"SLLSL", "SLSLL"};
|
"SLLSL", "SLSLL"};
|
||||||
|
|
||||||
static char *FIMTable[4] = {"111515111", "13111311131", "11131313111", "1111131311111"};
|
|
||||||
|
|
||||||
static char *RoyalValues[36] = {"11", "12", "13", "14", "15", "10", "21", "22", "23", "24", "25",
|
static char *RoyalValues[36] = {"11", "12", "13", "14", "15", "10", "21", "22", "23", "24", "25",
|
||||||
"20", "31", "32", "33", "34", "35", "30", "41", "42", "43", "44", "45", "40", "51", "52",
|
"20", "31", "32", "33", "34", "35", "30", "41", "42", "43", "44", "45", "40", "51", "52",
|
||||||
"53", "54", "55", "50", "01", "02", "03", "04", "05", "00"};
|
"53", "54", "55", "50", "01", "02", "03", "04", "05", "00"};
|
||||||
@ -61,7 +58,7 @@ static char *KoreaTable[10] = {"1313150613", "0713131313", "0417131313", "150613
|
|||||||
static char *JapanTable[19] = {"114", "132", "312", "123", "141", "321", "213", "231", "411", "144",
|
static char *JapanTable[19] = {"114", "132", "312", "123", "141", "321", "213", "231", "411", "144",
|
||||||
"414", "324", "342", "234", "432", "243", "423", "441", "111"};
|
"414", "324", "342", "234", "432", "243", "423", "441", "111"};
|
||||||
|
|
||||||
int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[], int length)
|
||||||
{
|
{
|
||||||
/* Handles the PostNet system used for Zip codes in the US */
|
/* Handles the PostNet system used for Zip codes in the US */
|
||||||
unsigned int i, sum, check_digit;
|
unsigned int i, sum, check_digit;
|
||||||
@ -69,11 +66,11 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 38) {
|
if(length > 38) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -83,7 +80,7 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
/* start character */
|
/* start character */
|
||||||
concat (dest, "L");
|
concat (dest, "L");
|
||||||
|
|
||||||
for (i=0; i < ustrlen(source); i++)
|
for (i=0; i < length; i++)
|
||||||
{
|
{
|
||||||
lookup(NESET, PNTable, source[i], dest);
|
lookup(NESET, PNTable, source[i], dest);
|
||||||
sum += ctoi(source[i]);
|
sum += ctoi(source[i]);
|
||||||
@ -98,7 +95,7 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int post_plot(struct zint_symbol *symbol, unsigned char source[])
|
int post_plot(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* Puts PostNet barcodes into the pattern matrix */
|
/* Puts PostNet barcodes into the pattern matrix */
|
||||||
char height_pattern[200];
|
char height_pattern[200];
|
||||||
@ -109,7 +106,7 @@ int post_plot(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
error_number = postnet(symbol, source, height_pattern);
|
error_number = postnet(symbol, source, height_pattern, length);
|
||||||
if(error_number != 0) {
|
if(error_number != 0) {
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
@ -132,7 +129,7 @@ int post_plot(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int planet(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
int planet(struct zint_symbol *symbol, unsigned char source[], char dest[], int length)
|
||||||
{
|
{
|
||||||
/* Handles the PLANET system used for item tracking in the US */
|
/* Handles the PLANET system used for item tracking in the US */
|
||||||
unsigned int i, sum, check_digit;
|
unsigned int i, sum, check_digit;
|
||||||
@ -140,11 +137,11 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 38) {
|
if(length > 38) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -154,7 +151,7 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
/* start character */
|
/* start character */
|
||||||
concat (dest, "L");
|
concat (dest, "L");
|
||||||
|
|
||||||
for (i=0; i < ustrlen(source); i++)
|
for (i=0; i < length; i++)
|
||||||
{
|
{
|
||||||
lookup(NESET, PLTable, source[i], dest);
|
lookup(NESET, PLTable, source[i], dest);
|
||||||
sum += ctoi(source[i]);
|
sum += ctoi(source[i]);
|
||||||
@ -169,7 +166,7 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int planet_plot(struct zint_symbol *symbol, unsigned char source[])
|
int planet_plot(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* Puts PLANET barcodes into the pattern matrix */
|
/* Puts PLANET barcodes into the pattern matrix */
|
||||||
char height_pattern[200];
|
char height_pattern[200];
|
||||||
@ -180,7 +177,7 @@ int planet_plot(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
error_number = planet(symbol, source, height_pattern);
|
error_number = planet(symbol, source, height_pattern, length);
|
||||||
if(error_number != 0) {
|
if(error_number != 0) {
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
@ -202,25 +199,24 @@ int planet_plot(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int korea_post(struct zint_symbol *symbol, unsigned char source[])
|
int korea_post(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Korean Postal Authority */
|
{ /* Korean Postal Authority */
|
||||||
|
|
||||||
int total, h, loop, check, zeroes, error_number;
|
int total, loop, check, zeroes, error_number;
|
||||||
char localstr[8], checkstr[3], dest[80];
|
char localstr[8], checkstr[3], dest[80];
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
h = ustrlen(source);
|
if(length > 6) {
|
||||||
if(h > 6) {
|
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
strcpy(localstr, "");
|
strcpy(localstr, "");
|
||||||
zeroes = 6 - h;
|
zeroes = 6 - length;
|
||||||
for(loop = 0; loop < zeroes; loop++)
|
for(loop = 0; loop < zeroes; loop++)
|
||||||
concat(localstr, "0");
|
concat(localstr, "0");
|
||||||
concat(localstr, (char *)source);
|
concat(localstr, (char *)source);
|
||||||
@ -245,31 +241,42 @@ int korea_post(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fim(struct zint_symbol *symbol, unsigned char source[])
|
int fim(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* The simplest barcode symbology ever! Supported by MS Word, so here it is! */
|
/* The simplest barcode symbology ever! Supported by MS Word, so here it is! */
|
||||||
/* glyphs from http://en.wikipedia.org/wiki/Facing_Identification_Mark */
|
/* glyphs from http://en.wikipedia.org/wiki/Facing_Identification_Mark */
|
||||||
|
|
||||||
int error_number;
|
|
||||||
char dest[17];
|
char dest[17];
|
||||||
|
|
||||||
error_number = 0;
|
if(length > 1) {
|
||||||
strcpy(dest, "");
|
|
||||||
|
|
||||||
to_upper(source);
|
|
||||||
if(ustrlen(source) > 1) {
|
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(BESET, source);
|
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
switch((char)source[0]) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
case 'a':
|
||||||
return error_number;
|
case 'A':
|
||||||
|
strcpy(dest, "111515111");
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
case 'B':
|
||||||
|
strcpy(dest, "13111311131");
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
case 'C':
|
||||||
|
strcpy(dest, "11131313111");
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
case 'D':
|
||||||
|
strcpy(dest, "1111131311111");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
lookup(BESET, FIMTable, source[0], dest);
|
|
||||||
|
|
||||||
expand(symbol, dest);
|
expand(symbol, dest);
|
||||||
return error_number;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char rm4scc(char source[], unsigned char dest[])
|
char rm4scc(char source[], unsigned char dest[])
|
||||||
@ -307,28 +314,32 @@ char rm4scc(char source[], unsigned char dest[])
|
|||||||
return set_copy[check_digit];
|
return set_copy[check_digit];
|
||||||
}
|
}
|
||||||
|
|
||||||
int royal_plot(struct zint_symbol *symbol, unsigned char source[])
|
int royal_plot(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* Puts RM4SCC into the data matrix */
|
/* Puts RM4SCC into the data matrix */
|
||||||
char height_pattern[200], check;
|
char height_pattern[200], check;
|
||||||
unsigned int loopey;
|
unsigned int loopey;
|
||||||
int writer;
|
int writer, i;
|
||||||
int error_number;
|
int error_number;
|
||||||
strcpy(height_pattern, "");
|
strcpy(height_pattern, "");
|
||||||
|
unsigned char local_source[120];
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
to_upper(source);
|
if(length > 120) {
|
||||||
if(ustrlen(source) > 120) {
|
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(KRSET, source);
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
|
to_upper(local_source);
|
||||||
|
error_number = is_sane(KRSET, local_source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
check = rm4scc((char*)source, (unsigned char*)height_pattern);
|
check = rm4scc((char*)local_source, (unsigned char*)height_pattern);
|
||||||
|
|
||||||
writer = 0;
|
writer = 0;
|
||||||
for(loopey = 0; loopey < strlen(height_pattern); loopey++)
|
for(loopey = 0; loopey < strlen(height_pattern); loopey++)
|
||||||
@ -354,7 +365,7 @@ int royal_plot(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kix_code(struct zint_symbol *symbol, unsigned char source[])
|
int kix_code(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* Handles Dutch Post TNT KIX symbols */
|
/* Handles Dutch Post TNT KIX symbols */
|
||||||
/* The same as RM4SCC but without check digit */
|
/* The same as RM4SCC but without check digit */
|
||||||
@ -364,15 +375,19 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
int writer, i;
|
int writer, i;
|
||||||
int error_number, zeroes;
|
int error_number, zeroes;
|
||||||
strcpy(height_pattern, "");
|
strcpy(height_pattern, "");
|
||||||
|
unsigned char local_source[13];
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
to_upper(source);
|
if(length > 11) {
|
||||||
if(ustrlen(source) > 11) {
|
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(KRSET, source);
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
|
to_upper(local_source);
|
||||||
|
error_number = is_sane(KRSET, local_source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -380,10 +395,10 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
/* Add leading zeroes */
|
/* Add leading zeroes */
|
||||||
strcpy(localstr, "");
|
strcpy(localstr, "");
|
||||||
zeroes = 11 - ustrlen(source);
|
zeroes = 11 - length;
|
||||||
for(i = 0; i < zeroes; i++)
|
for(i = 0; i < zeroes; i++)
|
||||||
concat(localstr, "0");
|
concat(localstr, "0");
|
||||||
concat(localstr, (char *)source);
|
concat(localstr, (char *)local_source);
|
||||||
|
|
||||||
/* Encode data */
|
/* Encode data */
|
||||||
for (i = 0; i < 11; i++) {
|
for (i = 0; i < 11; i++) {
|
||||||
@ -414,31 +429,31 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int daft_code(struct zint_symbol *symbol, unsigned char source[])
|
int daft_code(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* Handles DAFT Code symbols */
|
/* Handles DAFT Code symbols */
|
||||||
/* Presumably 'daft' doesn't mean the same thing in Germany as it does in the UK! */
|
/* Presumably 'daft' doesn't mean the same thing in Germany as it does in the UK! */
|
||||||
int input_length;
|
|
||||||
char height_pattern[100], local_source[55];
|
char height_pattern[100], local_source[55];
|
||||||
unsigned int loopey;
|
unsigned int loopey;
|
||||||
int writer, i, error_number;
|
int writer, i, error_number;
|
||||||
strcpy(height_pattern, "");
|
strcpy(height_pattern, "");
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
input_length = ustrlen(source);
|
if(length > 50) {
|
||||||
strcpy(local_source, (char*)source);
|
|
||||||
if(input_length > 50) {
|
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
to_upper((unsigned char*)local_source);
|
to_upper((unsigned char*)local_source);
|
||||||
error_number = is_sane(DAFTSET, (unsigned char*)local_source);
|
error_number = is_sane(DAFTSET, (unsigned char*)local_source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < input_length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
if(local_source[i] == 'D') { concat(height_pattern, "2"); }
|
if(local_source[i] == 'D') { concat(height_pattern, "2"); }
|
||||||
if(local_source[i] == 'A') { concat(height_pattern, "1"); }
|
if(local_source[i] == 'A') { concat(height_pattern, "1"); }
|
||||||
if(local_source[i] == 'F') { concat(height_pattern, "0"); }
|
if(local_source[i] == 'F') { concat(height_pattern, "0"); }
|
||||||
@ -469,7 +484,7 @@ int daft_code(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int flattermarken(struct zint_symbol *symbol, unsigned char source[])
|
int flattermarken(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Flattermarken - Not really a barcode symbology and (in my opinion) probably not much use
|
{ /* Flattermarken - Not really a barcode symbology and (in my opinion) probably not much use
|
||||||
but it's supported by TBarCode so it's supported by Zint! */
|
but it's supported by TBarCode so it's supported by Zint! */
|
||||||
int loop, error_number;
|
int loop, error_number;
|
||||||
@ -478,17 +493,17 @@ int flattermarken(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
error_number = 0;
|
error_number = 0;
|
||||||
strcpy(dest, "");
|
strcpy(dest, "");
|
||||||
|
|
||||||
if(ustrlen(source) > 90) {
|
if(length > 90) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(loop = 0; loop < ustrlen(source); loop++) {
|
for(loop = 0; loop < length; loop++) {
|
||||||
lookup(NESET, FlatTable, source[loop], dest);
|
lookup(NESET, FlatTable, source[loop], dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,9 +511,9 @@ int flattermarken(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int japan_post(struct zint_symbol *symbol, unsigned char source[])
|
int japan_post(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* Japanese Postal Code (Kasutama Barcode) */
|
{ /* Japanese Postal Code (Kasutama Barcode) */
|
||||||
int input_length, error_number;
|
int error_number;
|
||||||
char pattern[69];
|
char pattern[69];
|
||||||
int writer, loopey, inter_posn, i, sum, check;
|
int writer, loopey, inter_posn, i, sum, check;
|
||||||
char check_char;
|
char check_char;
|
||||||
@ -506,19 +521,22 @@ int japan_post(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
char* local_source;
|
char* local_source;
|
||||||
#endif
|
#endif
|
||||||
input_length = ustrlen(source);
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
char local_source[input_length + 1];
|
char local_source[length + 1];
|
||||||
#else
|
#else
|
||||||
local_source = (char*)_alloca(input_length + 1);
|
local_source = (char*)_alloca(length + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inter_posn = 0;
|
inter_posn = 0;
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
|
|
||||||
strcpy(local_source, (char*)source);
|
strcpy(local_source, (char*)source);
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
to_upper((unsigned char*)local_source);
|
to_upper((unsigned char*)local_source);
|
||||||
error_number = is_sane(SHKASUTSET, (unsigned char*)local_source);
|
error_number = is_sane(SHKASUTSET, (unsigned char*)local_source, length);
|
||||||
|
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
@ -554,7 +572,7 @@ int japan_post(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}while((i < input_length) && (inter_posn < 20));
|
}while((i < length) && (inter_posn < 20));
|
||||||
inter[20] = '\0';
|
inter[20] = '\0';
|
||||||
|
|
||||||
strcpy(pattern, "13"); /* Start */
|
strcpy(pattern, "13"); /* Start */
|
||||||
|
@ -74,12 +74,12 @@ int ps_plot(struct zint_symbol *symbol)
|
|||||||
strcpy(symbol->errtxt, "Malformed background colour target");
|
strcpy(symbol->errtxt, "Malformed background colour target");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
error_number = is_sane(SSET, (unsigned char*)symbol->fgcolour);
|
error_number = is_sane(SSET, (unsigned char*)symbol->fgcolour, 6);
|
||||||
if (error_number == ERROR_INVALID_DATA) {
|
if (error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Malformed foreground colour target");
|
strcpy(symbol->errtxt, "Malformed foreground colour target");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
error_number = is_sane(SSET, (unsigned char*)symbol->bgcolour);
|
error_number = is_sane(SSET, (unsigned char*)symbol->bgcolour, 6);
|
||||||
if (error_number == ERROR_INVALID_DATA) {
|
if (error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Malformed background colour target");
|
strcpy(symbol->errtxt, "Malformed background colour target");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
|
62
backend/qr.c
62
backend/qr.c
@ -26,8 +26,9 @@
|
|||||||
#ifndef NO_QR
|
#ifndef NO_QR
|
||||||
#include <qrencode.h>
|
#include <qrencode.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "shiftjis.h"
|
||||||
|
|
||||||
QRcode *encode(int security, int size, const unsigned char *intext, int kanji, int gs1, char nullchar, int input_length)
|
QRcode *encode(int security, int size, const unsigned char *intext, int kanji, int gs1, int input_length)
|
||||||
{
|
{
|
||||||
int version;
|
int version;
|
||||||
QRecLevel level;
|
QRecLevel level;
|
||||||
@ -62,49 +63,54 @@ QRcode *encode(int security, int size, const unsigned char *intext, int kanji, i
|
|||||||
version = 0;
|
version = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nullchar == '\0') {
|
code = QRcode_encodeString((char*)intext, version, level, hint, 1);
|
||||||
/* No NULL characters in data */
|
|
||||||
code = QRcode_encodeString((char*)intext, version, level, hint, 1);
|
|
||||||
} else {
|
|
||||||
/* NULL characters in data */
|
|
||||||
code = QRcode_encodeString8bit((char*)intext, version, level);
|
|
||||||
/* code = QRcode_encodeString8bit((char*)intext, version, level, input_length); */
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qr_code(struct zint_symbol *symbol, unsigned char source[])
|
int qr_code(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
QRcode *code;
|
QRcode *code;
|
||||||
/*int errno = 0;*/
|
|
||||||
int i, j;
|
int i, j;
|
||||||
int kanji, gs1;
|
int kanji, gs1;
|
||||||
int input_length;
|
int error_number;
|
||||||
char nullify;
|
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
unsigned char local_source[length];
|
||||||
|
#else
|
||||||
|
unsigned char local_source = (unsigned char*)_alloca(length);
|
||||||
|
#endif
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
|
||||||
nullify = symbol->nullchar;
|
|
||||||
if((symbol->input_mode == KANJI_MODE) || (symbol->input_mode == SJIS_MODE)) { kanji = 1; } else { kanji = 0; }
|
|
||||||
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
|
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
|
||||||
|
|
||||||
/* Null character handling */
|
if(gs1) {
|
||||||
j = 0;
|
strcpy(symbol->errtxt, "GS1 mode not yet supported in QR Code");
|
||||||
if(nullify != '\0') {
|
return ERROR_INVALID_OPTION;
|
||||||
for(i = 0; i < input_length; i++) {
|
}
|
||||||
if(source[i] == nullify) {
|
|
||||||
source[i] = '\0';
|
for(i = 0; i < length; i++) {
|
||||||
j++;
|
if(source[i] == '\0') {
|
||||||
}
|
strcpy(symbol->errtxt, "QR Code not yet able to handle NULL characters");
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(j == 0) {
|
/* The following to be replaced by ECI handling */
|
||||||
/* nullchar was set but there are no NULL characters in the input data */
|
switch(symbol->input_mode) {
|
||||||
nullify = '\0';
|
case DATA_MODE:
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
|
local_source[length] = '\0';
|
||||||
|
kanji = 0;
|
||||||
|
break;
|
||||||
|
case UNICODE_MODE:
|
||||||
|
error_number = shiftJIS(symbol, source, local_source, &length, &kanji);
|
||||||
|
if(error_number != 0) { return error_number; }
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = encode(symbol->option_1, symbol->option_2, source, kanji, gs1, nullify, input_length);
|
code = encode(symbol->option_1, symbol->option_2, local_source, kanji, gs1, length);
|
||||||
if(code == NULL) {
|
if(code == NULL) {
|
||||||
strcpy(symbol->errtxt, "libqrencode failed to encode the input data");
|
strcpy(symbol->errtxt, "libqrencode failed to encode the input data");
|
||||||
return ERROR_ENCODING_PROBLEM;
|
return ERROR_ENCODING_PROBLEM;
|
||||||
|
@ -142,7 +142,7 @@ void getRSSwidths(int val, int n, int elements, int maxWidth, int noNarrow)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rss14(struct zint_symbol *symbol, unsigned char source[])
|
int rss14(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* GS1 DataBar-14 */
|
{ /* GS1 DataBar-14 */
|
||||||
int error_number = 0, i, j, mask;
|
int error_number = 0, i, j, mask;
|
||||||
short int accum[112], left_reg[112], right_reg[112], x_reg[112], y_reg[112];
|
short int accum[112], left_reg[112], right_reg[112], x_reg[112], y_reg[112];
|
||||||
@ -153,11 +153,11 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
separator_row = 0;
|
separator_row = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 13) {
|
if(length > 13) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
@ -651,7 +651,7 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rsslimited(struct zint_symbol *symbol, unsigned char source[])
|
int rsslimited(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* GS1 DataBar Limited */
|
{ /* GS1 DataBar Limited */
|
||||||
int error_number = 0, i, mask;
|
int error_number = 0, i, mask;
|
||||||
short int accum[112], left_reg[112], right_reg[112], x_reg[112], y_reg[112];
|
short int accum[112], left_reg[112], right_reg[112], x_reg[112], y_reg[112];
|
||||||
@ -663,16 +663,16 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
separator_row = 0;
|
separator_row = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 13) {
|
if(length > 13) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
error_number = is_sane(NESET, source);
|
error_number = is_sane(NESET, source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
if(ustrlen(source) == 13) {
|
if(length == 13) {
|
||||||
if((source[0] != '0') && (source[0] != '1')) {
|
if((source[0] != '0') && (source[0] != '1')) {
|
||||||
strcpy(symbol->errtxt, "Input out of range");
|
strcpy(symbol->errtxt, "Input out of range");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
@ -1858,7 +1858,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
|
int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{ /* GS1 DataBar Expanded */
|
{ /* GS1 DataBar Expanded */
|
||||||
int i, j, k, l, data_chars, vs[21], group[21], v_odd[21], v_even[21];
|
int i, j, k, l, data_chars, vs[21], group[21], v_odd[21], v_even[21];
|
||||||
char substring[21][14], latch;
|
char substring[21][14], latch;
|
||||||
@ -1868,10 +1868,10 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
int codeblocks, sub_elements[235], stack_rows, current_row, current_block;
|
int codeblocks, sub_elements[235], stack_rows, current_row, current_block;
|
||||||
int separator_row;
|
int separator_row;
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
char reduced[ustrlen(source)], binary_string[7 * ustrlen(source)];
|
char reduced[length], binary_string[7 * length];
|
||||||
#else
|
#else
|
||||||
char* reduced = (char*)_alloca(ustrlen(source));
|
char* reduced = (char*)_alloca(length);
|
||||||
char* binary_string = (char*)_alloca(7 * ustrlen(source));
|
char* binary_string = (char*)_alloca(7 * length);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
separator_row = 0;
|
separator_row = 0;
|
||||||
|
118
backend/shiftjis.c
Normal file
118
backend/shiftjis.c
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/* shiftjis.c - Handle conversion to Shift-JIS */
|
||||||
|
|
||||||
|
/*
|
||||||
|
libzint - the open source barcode library
|
||||||
|
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "common.h"
|
||||||
|
#include "sjis.h"
|
||||||
|
|
||||||
|
int shiftJIS(struct zint_symbol *symbol, unsigned char source[], unsigned char preprocessed[], int *length, int *kanji)
|
||||||
|
{ /* QR Code supports compression of Shift-JIS data using "Kanji" mode - this function
|
||||||
|
attempts to convert Unicode characters to Shift-JIS to allow this */
|
||||||
|
int bpos, jpos, error_number, i, done;
|
||||||
|
int next;
|
||||||
|
unsigned long int uval, jval;
|
||||||
|
|
||||||
|
bpos = 0;
|
||||||
|
jpos = 0;
|
||||||
|
error_number = 0;
|
||||||
|
next = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
uval = 0;
|
||||||
|
jval = 0;
|
||||||
|
done = 0;
|
||||||
|
|
||||||
|
if(source[bpos] <= 0x7f) {
|
||||||
|
/* 1 byte mode (7-bit ASCII) */
|
||||||
|
uval = source[bpos];
|
||||||
|
next = bpos + 1;
|
||||||
|
preprocessed[jpos] = uval;
|
||||||
|
jpos++;
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(done == 0) {
|
||||||
|
if((source[bpos] >= 0x80) && (source[bpos] <= 0xbf)) {
|
||||||
|
strcpy(symbol->errtxt, "Corrupt Unicode data");
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(done == 0) {
|
||||||
|
if((source[bpos] >= 0xc0) && (source[bpos] <= 0xc1)) {
|
||||||
|
strcpy(symbol->errtxt, "Overlong encoding not supported");
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(done == 0) {
|
||||||
|
if((source[bpos] >= 0xc2) && (source[bpos] <= 0xdf)) {
|
||||||
|
/* 2 byte mode (Latin 1) */
|
||||||
|
uval = ((source[bpos] & 0x1f) << 6) + (source[bpos + 1] & 0x3f);
|
||||||
|
next = bpos + 2;
|
||||||
|
preprocessed[jpos] = uval;
|
||||||
|
jpos++;
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(done == 0) {
|
||||||
|
if((source[bpos] >= 0xe0) && (source[bpos] <= 0xef)) {
|
||||||
|
/* 3 byte mode (Japanese) */
|
||||||
|
uval = ((source[bpos] & 0x0f) << 12) + ((source[bpos + 1] & 0x3f) << 6) + (source[bpos + 2] & 0x3f);
|
||||||
|
next = bpos + 3;
|
||||||
|
*kanji = 1;
|
||||||
|
|
||||||
|
for(i = 0; i < 6843; i++) {
|
||||||
|
if(sjis_lookup[i * 2] == uval) {
|
||||||
|
jval = sjis_lookup[(i * 2) + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(jval == 0) {
|
||||||
|
strcpy(symbol->errtxt, "Invalid Shift JIS character");
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
preprocessed[jpos] = (jval & 0xff00) >> 8;
|
||||||
|
preprocessed[jpos + 1] = (jval & 0xff);
|
||||||
|
|
||||||
|
/* printf("Unicode value U+%04X = Shift JIS value 0x%04X\n", uval, jval); */
|
||||||
|
|
||||||
|
jpos += 2;
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(done == 0) {
|
||||||
|
if(source[bpos] >= 0xf0) {
|
||||||
|
strcpy(symbol->errtxt, "Unicode sequences of more than 3 bytes not supported");
|
||||||
|
return ERROR_INVALID_DATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bpos = next;
|
||||||
|
|
||||||
|
} while(bpos < *length);
|
||||||
|
*length = jpos;
|
||||||
|
|
||||||
|
return error_number;
|
||||||
|
}
|
27
backend/shiftjis.h
Normal file
27
backend/shiftjis.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/* shiftjis.h - Handle conversion to Shift-JIS */
|
||||||
|
|
||||||
|
/*
|
||||||
|
libzint - the open source barcode library
|
||||||
|
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __SHIFTJIS_H
|
||||||
|
#define __SHIFTJIS_H
|
||||||
|
|
||||||
|
int shiftJIS(struct zint_symbol *symbol, unsigned char source[], unsigned char preprocessed[], int *length, int *kanji);
|
||||||
|
|
||||||
|
#endif
|
@ -70,12 +70,12 @@ int svg_plot(struct zint_symbol *symbol)
|
|||||||
strcpy(symbol->errtxt, "Malformed background colour target");
|
strcpy(symbol->errtxt, "Malformed background colour target");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
error_number = is_sane(SSET, (unsigned char*)symbol->fgcolour);
|
error_number = is_sane(SSET, (unsigned char*)symbol->fgcolour, 6);
|
||||||
if (error_number == ERROR_INVALID_DATA) {
|
if (error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Malformed foreground colour target");
|
strcpy(symbol->errtxt, "Malformed foreground colour target");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
error_number = is_sane(SSET, (unsigned char*)symbol->bgcolour);
|
error_number = is_sane(SSET, (unsigned char*)symbol->bgcolour, 6);
|
||||||
if (error_number == ERROR_INVALID_DATA) {
|
if (error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Malformed background colour target");
|
strcpy(symbol->errtxt, "Malformed background colour target");
|
||||||
return ERROR_INVALID_OPTION;
|
return ERROR_INVALID_OPTION;
|
||||||
|
@ -49,10 +49,9 @@ static char *TeleTable[] = { "1111111111111111", "1131313111", "33313111", "1111
|
|||||||
"11311111111111", "331111111111", "111113111113", "31111111111111", "111311111113",
|
"11311111111111", "331111111111", "111113111113", "31111111111111", "111311111113",
|
||||||
"131111111113"};
|
"131111111113"};
|
||||||
|
|
||||||
int telepen(struct zint_symbol *symbol, unsigned char source[])
|
int telepen(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
unsigned int i, count, check_digit;
|
unsigned int i, count, check_digit;
|
||||||
int ascii_value;
|
|
||||||
int error_number;
|
int error_number;
|
||||||
char dest[1000];
|
char dest[1000];
|
||||||
|
|
||||||
@ -61,12 +60,12 @@ int telepen(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 30) {
|
if(length > 30) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < length; i++) {
|
||||||
if(source[i] > 127) {
|
if(source[i] > 127) {
|
||||||
/* Cannot encode extended ASCII */
|
/* Cannot encode extended ASCII */
|
||||||
strcpy(symbol->errtxt, "Invalid characters in input data");
|
strcpy(symbol->errtxt, "Invalid characters in input data");
|
||||||
@ -77,14 +76,9 @@ int telepen(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
/* Start character */
|
/* Start character */
|
||||||
concat(dest, TeleTable['_']);
|
concat(dest, TeleTable['_']);
|
||||||
|
|
||||||
for (i=0; i < ustrlen(source); i++)
|
for (i=0; i < length; i++)
|
||||||
{
|
{
|
||||||
ascii_value = source[i];
|
concat(dest, TeleTable[source[i]]);
|
||||||
if(ascii_value == symbol->nullchar) {
|
|
||||||
concat(dest, TeleTable[0]);
|
|
||||||
} else {
|
|
||||||
concat(dest, TeleTable[ascii_value]);
|
|
||||||
}
|
|
||||||
count += source[i];
|
count += source[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,55 +90,63 @@ int telepen(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
concat(dest, TeleTable['z']);
|
concat(dest, TeleTable['z']);
|
||||||
|
|
||||||
expand(symbol, dest);
|
expand(symbol, dest);
|
||||||
ustrcpy(symbol->text, source);
|
for(i = 0; i < length; i++) {
|
||||||
|
if(source[i] == '\0') {
|
||||||
|
symbol->text[i] = ' ';
|
||||||
|
} else {
|
||||||
|
symbol->text[i] = source[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
symbol->text[length] = '\0';
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int telepen_num(struct zint_symbol *symbol, unsigned char source[])
|
int telepen_num(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
unsigned int i, count, check_digit, glyph;
|
unsigned int i, count, check_digit, glyph;
|
||||||
int error_number, input_length;
|
int error_number;
|
||||||
unsigned char dest[1000];
|
unsigned char dest[1000];
|
||||||
unsigned char local_source[100];
|
unsigned char local_source[100];
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
memset(dest, 0, 1000);
|
memset(dest, 0, 1000);
|
||||||
memset(local_source, 0, 100);
|
memset(local_source, 0, 100);
|
||||||
strcpy((char*)local_source, (char*)source);
|
|
||||||
input_length = ustrlen(source);
|
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
if(input_length > 60) {
|
if(length > 60) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
for(i = 0; i < length; i++) {
|
||||||
|
local_source[i] = source[i];
|
||||||
|
}
|
||||||
to_upper(local_source);
|
to_upper(local_source);
|
||||||
error_number = is_sane(NASET, local_source);
|
error_number = is_sane(NASET, local_source, length);
|
||||||
if(error_number == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a leading zero if required */
|
/* Add a leading zero if required */
|
||||||
if ((input_length % 2) != 0)
|
if ((length % 2) != 0)
|
||||||
{
|
{
|
||||||
char temp[200];
|
char temp[200];
|
||||||
|
|
||||||
strcpy(temp, (char*)local_source);
|
strcpy(temp, (char*)local_source);
|
||||||
local_source[0] = '0';
|
local_source[0] = '0';
|
||||||
|
|
||||||
for(i = 0; i <= input_length; i++)
|
for(i = 0; i <= length; i++)
|
||||||
{
|
{
|
||||||
local_source[i + 1] = temp[i];
|
local_source[i + 1] = temp[i];
|
||||||
}
|
}
|
||||||
input_length++;
|
length++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start character */
|
/* Start character */
|
||||||
concat((char*)dest, TeleTable['_']);
|
concat((char*)dest, TeleTable['_']);
|
||||||
|
|
||||||
for (i=0; i < input_length; i+=2)
|
for (i=0; i < length; i+=2)
|
||||||
{
|
{
|
||||||
if(local_source[i] == 'X') {
|
if(local_source[i] == 'X') {
|
||||||
strcpy(symbol->errtxt, "Invalid position of X in Telepen data");
|
strcpy(symbol->errtxt, "Invalid position of X in Telepen data");
|
||||||
|
@ -402,18 +402,9 @@ char isbn_check(unsigned char source[]) /* For ISBN(10) and SBN only */
|
|||||||
|
|
||||||
int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Make an EAN-13 barcode from an SBN or ISBN */
|
int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Make an EAN-13 barcode from an SBN or ISBN */
|
||||||
{
|
{
|
||||||
int i, errno;
|
int i;
|
||||||
char check_digit;
|
char check_digit;
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
|
|
||||||
to_upper(source);
|
|
||||||
errno = is_sane("0123456789X", source);
|
|
||||||
if(errno == ERROR_INVALID_DATA) {
|
|
||||||
strcpy(symbol->errtxt, "Invalid characters in input");
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Input must be 9, 10 or 13 characters */
|
/* Input must be 9, 10 or 13 characters */
|
||||||
if(((ustrlen(source) < 9) || (ustrlen(source) > 13)) || ((ustrlen(source) > 10) && (ustrlen(source) < 13)))
|
if(((ustrlen(source) < 9) || (ustrlen(source) > 13)) || ((ustrlen(source) > 10) && (ustrlen(source) < 13)))
|
||||||
{
|
{
|
||||||
@ -491,7 +482,7 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Mak
|
|||||||
ean13(symbol, source, dest);
|
ean13(symbol, source, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return errno;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ean_leading_zeroes(struct zint_symbol *symbol, unsigned char source[], unsigned char local_source[]) {
|
void ean_leading_zeroes(struct zint_symbol *symbol, unsigned char source[], unsigned char local_source[]) {
|
||||||
@ -575,15 +566,15 @@ void ean_leading_zeroes(struct zint_symbol *symbol, unsigned char source[], unsi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int eanx(struct zint_symbol *symbol, unsigned char source[])
|
int eanx(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
/* splits string to parts before and after '+' parts */
|
/* splits string to parts before and after '+' parts */
|
||||||
unsigned char first_part[20], second_part[20], dest[1000];
|
unsigned char first_part[20], second_part[20], dest[1000];
|
||||||
unsigned char local_source[20];
|
unsigned char local_source[20];
|
||||||
unsigned int latch, reader, writer, with_addon;
|
unsigned int latch, reader, writer, with_addon;
|
||||||
int errno, i;
|
int error_number, i;
|
||||||
|
|
||||||
errno = 0;
|
error_number = 0;
|
||||||
memset(dest,0,1000);
|
memset(dest,0,1000);
|
||||||
memset(first_part,0,20);
|
memset(first_part,0,20);
|
||||||
memset(second_part,0,20);
|
memset(second_part,0,20);
|
||||||
@ -592,21 +583,32 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
latch = FALSE;
|
latch = FALSE;
|
||||||
writer = 0;
|
writer = 0;
|
||||||
|
|
||||||
if(ustrlen(source) > 19) {
|
if(length > 19) {
|
||||||
strcpy(symbol->errtxt, "Input too long");
|
strcpy(symbol->errtxt, "Input too long");
|
||||||
return ERROR_TOO_LONG;
|
return ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
if(symbol->symbology != BARCODE_ISBNX) {
|
if(symbol->symbology != BARCODE_ISBNX) {
|
||||||
/* ISBN has it's own checking routine */
|
/* ISBN has it's own checking routine */
|
||||||
errno = is_sane(NASET, source);
|
error_number = is_sane(NASET, source, length);
|
||||||
if(errno == ERROR_INVALID_DATA) {
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Invalid characters in data");
|
strcpy(symbol->errtxt, "Invalid characters in data");
|
||||||
return errno;
|
return error_number;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error_number = is_sane("0123456789Xx", source, length);
|
||||||
|
if(error_number == ERROR_INVALID_DATA) {
|
||||||
|
strcpy(symbol->errtxt, "Invalid characters in input");
|
||||||
|
return error_number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Add leading zeroes */
|
/* Add leading zeroes */
|
||||||
ustrcpy(local_source, (unsigned char *)"");
|
ustrcpy(local_source, (unsigned char *)"");
|
||||||
|
if(symbol->symbology == BARCODE_ISBNX) {
|
||||||
|
to_upper(local_source);
|
||||||
|
}
|
||||||
|
|
||||||
ean_leading_zeroes(symbol, source, local_source);
|
ean_leading_zeroes(symbol, source, local_source);
|
||||||
|
|
||||||
for(reader = 0; reader <= ustrlen(local_source); reader++)
|
for(reader = 0; reader <= ustrlen(local_source); reader++)
|
||||||
@ -732,9 +734,9 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARCODE_ISBNX:
|
case BARCODE_ISBNX:
|
||||||
errno = isbn(symbol, first_part, (char*)dest);
|
error_number = isbn(symbol, first_part, (char*)dest);
|
||||||
if(errno > 4) {
|
if(error_number > 4) {
|
||||||
return errno;
|
return error_number;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -777,10 +779,10 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if((symbol->errtxt[0] == 'w') && (errno == 0)) {
|
if((symbol->errtxt[0] == 'w') && (error_number == 0)) {
|
||||||
errno = 1; /* flag UPC-E warnings */
|
error_number = 1; /* flag UPC-E warnings */
|
||||||
}
|
}
|
||||||
return errno;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,6 +139,7 @@ struct zint_symbol {
|
|||||||
#define BARCODE_RSS_EXPSTACK_CC 139
|
#define BARCODE_RSS_EXPSTACK_CC 139
|
||||||
#define BARCODE_CHANNEL 140
|
#define BARCODE_CHANNEL 140
|
||||||
#define BARCODE_CODEONE 141
|
#define BARCODE_CODEONE 141
|
||||||
|
#define BARCODE_GRIDMATRIX 142
|
||||||
|
|
||||||
#define BARCODE_NO_ASCII 1
|
#define BARCODE_NO_ASCII 1
|
||||||
#define BARCODE_BIND 2
|
#define BARCODE_BIND 2
|
||||||
@ -176,13 +177,18 @@ struct zint_symbol {
|
|||||||
|
|
||||||
ZINT_EXTERN struct zint_symbol *ZBarcode_Create(void);
|
ZINT_EXTERN struct zint_symbol *ZBarcode_Create(void);
|
||||||
ZINT_EXTERN int ZBarcode_Delete(struct zint_symbol *symbol);
|
ZINT_EXTERN int ZBarcode_Delete(struct zint_symbol *symbol);
|
||||||
ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input);
|
|
||||||
ZINT_EXTERN int ZBarcode_Encode_from_File(struct zint_symbol *symbol, char *filename);
|
ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input, int length);
|
||||||
ZINT_EXTERN int ZBarcode_Print(struct zint_symbol *symbol);
|
ZINT_EXTERN int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename);
|
||||||
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input);
|
ZINT_EXTERN int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);
|
||||||
|
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle);
|
||||||
|
ZINT_EXTERN int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle);
|
||||||
|
|
||||||
|
ZINT_EXTERN int ZBarcode_ValidID(int symbol_id);
|
||||||
|
|
||||||
|
/* Depreciated */
|
||||||
|
ZINT_EXTERN int ZBarcode_Print_Rotated(struct zint_symbol *symbol, int rotate_angle);
|
||||||
ZINT_EXTERN int ZBarcode_Encode_and_Print_Rotated(struct zint_symbol *symbol, unsigned char *input, int rotate_angle);
|
ZINT_EXTERN int ZBarcode_Encode_and_Print_Rotated(struct zint_symbol *symbol, unsigned char *input, int rotate_angle);
|
||||||
ZINT_EXTERN int ZBarcode_Encode_from_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle);
|
|
||||||
ZINT_EXTERN int ZBarcode_Check_Supported(int symbol_id);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ void QZint::encode()
|
|||||||
QByteArray bstr=m_text.toAscii();
|
QByteArray bstr=m_text.toAscii();
|
||||||
QByteArray pstr=m_primaryMessage.left(99).toAscii();
|
QByteArray pstr=m_primaryMessage.left(99).toAscii();
|
||||||
strcpy(m_zintSymbol->primary,pstr.data());
|
strcpy(m_zintSymbol->primary,pstr.data());
|
||||||
int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data());
|
int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length());
|
||||||
if (error > WARN_INVALID_OPTION)
|
if (error > WARN_INVALID_OPTION)
|
||||||
m_lastError=m_zintSymbol->errtxt;
|
m_lastError=m_zintSymbol->errtxt;
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ bool QZint::save_to_file(QString filename)
|
|||||||
QByteArray bgcol=bg_colour_hash.right(6).toAscii();
|
QByteArray bgcol=bg_colour_hash.right(6).toAscii();
|
||||||
strcpy(m_zintSymbol->fgcolour,fgcol.data());
|
strcpy(m_zintSymbol->fgcolour,fgcol.data());
|
||||||
strcpy(m_zintSymbol->bgcolour,bgcol.data());
|
strcpy(m_zintSymbol->bgcolour,bgcol.data());
|
||||||
int error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char*)bstr.data());
|
int error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length(), 0);
|
||||||
if (error > WARN_INVALID_OPTION)
|
if (error > WARN_INVALID_OPTION)
|
||||||
m_lastError=m_zintSymbol->errtxt;
|
m_lastError=m_zintSymbol->errtxt;
|
||||||
if(error == 0) { return true; } else { return false; }
|
if(error == 0) { return true; } else { return false; }
|
||||||
|
@ -338,11 +338,7 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd': /* we have some data! */
|
case 'd': /* we have some data! */
|
||||||
if(rotate_angle == 0) {
|
error_number = ZBarcode_Encode_and_Print(my_symbol, (unsigned char*)optarg, strlen(optarg), rotate_angle);
|
||||||
error_number = ZBarcode_Encode_and_Print(my_symbol, (unsigned char*)optarg);
|
|
||||||
} else {
|
|
||||||
error_number = ZBarcode_Encode_and_Print_Rotated(my_symbol, (unsigned char*)optarg, rotate_angle);
|
|
||||||
}
|
|
||||||
generated = 1;
|
generated = 1;
|
||||||
if(error_number != 0) {
|
if(error_number != 0) {
|
||||||
fprintf(stderr, "%s\n", my_symbol->errtxt);
|
fprintf(stderr, "%s\n", my_symbol->errtxt);
|
||||||
@ -352,7 +348,7 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'i': /* Take data from file */
|
case 'i': /* Take data from file */
|
||||||
error_number = ZBarcode_Encode_from_File_and_Print(my_symbol, optarg, rotate_angle);
|
error_number = ZBarcode_Encode_File_and_Print(my_symbol, optarg, rotate_angle);
|
||||||
generated = 1;
|
generated = 1;
|
||||||
if(error_number != 0) {
|
if(error_number != 0) {
|
||||||
fprintf(stderr, "%s\n", my_symbol->errtxt);
|
fprintf(stderr, "%s\n", my_symbol->errtxt);
|
||||||
|
@ -158,7 +158,7 @@ bool MainWindow::save()
|
|||||||
|
|
||||||
QString fileName = QFileDialog::getSaveFileName(this,
|
QString fileName = QFileDialog::getSaveFileName(this,
|
||||||
tr("Save Barcode Image"), ".",
|
tr("Save Barcode Image"), ".",
|
||||||
tr("Barcode Images (*.png *.eps *.svg)"));
|
tr("Portable Network Graphic (*.png);;Encapsulated Post Script (*.eps);;Scalable Vector Graphic (*.svg)"));
|
||||||
|
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user