Reduced warnings about signedness

This commit is contained in:
hooper114 2008-09-30 15:05:53 +00:00
parent 020843b430
commit 5b10d056c2
26 changed files with 358 additions and 344 deletions

View File

@ -44,7 +44,7 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 80) { if(ustrlen(source) > 80) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -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 <= strlen(source); i++) { for(i = 0; i <= ustrlen(source); i++) {
lookup(NESET, C25MatrixTable, source[i], dest); lookup(NESET, C25MatrixTable, source[i], dest);
} }
@ -78,7 +78,7 @@ int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 45) { if(ustrlen(source) > 45) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -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 <= strlen(source); i++) { for(i = 0; i <= ustrlen(source); i++) {
lookup(NESET, C25IndustTable, source[i], dest); lookup(NESET, C25IndustTable, source[i], dest);
} }
@ -111,7 +111,7 @@ int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 45) { if(ustrlen(source) > 45) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -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 < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
lookup(NESET, C25IndustTable, source[i], dest); lookup(NESET, C25IndustTable, source[i], dest);
} }
@ -145,7 +145,7 @@ int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 80) { if(ustrlen(source) > 80) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -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 <= strlen(source); i++) { for(i = 0; i <= ustrlen(source); i++) {
lookup(NESET, C25MatrixTable, source[i], dest); lookup(NESET, C25MatrixTable, source[i], dest);
} }
@ -179,7 +179,7 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 90) { if(ustrlen(source) > 90) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -191,13 +191,13 @@ 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 ((strlen(source)%2) != 0) if ((ustrlen(source)%2) != 0)
{ {
/* there are an odd number of input characters */ /* there are an odd number of input characters */
unsigned int length; unsigned int length;
char temp[100]; char temp[100];
length = strlen(source); length = ustrlen(source);
strcpy(temp, source); strcpy(temp, source);
source[0] = '0'; source[0] = '0';
@ -211,7 +211,7 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[])
/* start character */ /* start character */
concat(dest, "1111"); concat(dest, "1111");
for(i = 0; i < strlen(source); i+=2 ) for(i = 0; i < ustrlen(source); 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, "");
@ -247,7 +247,7 @@ int itf14(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
count = 0; count = 0;
h = strlen(source); h = ustrlen(source);
if(h != 13) { if(h != 13) {
strcpy(symbol->errtxt, "error: input wrong length"); strcpy(symbol->errtxt, "error: input wrong length");
@ -287,7 +287,7 @@ int dpleit(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
count = 0; count = 0;
h = strlen(source); h = ustrlen(source);
if(h != 13) { if(h != 13) {
strcpy(symbol->errtxt, "error: input wrong length"); strcpy(symbol->errtxt, "error: input wrong length");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
@ -322,7 +322,7 @@ int dpident(struct zint_symbol *symbol, unsigned char source[])
unsigned int h, count, check_digit; unsigned int h, count, check_digit;
count = 0; count = 0;
h = strlen(source); h = ustrlen(source);
if(h != 11) { if(h != 11) {
strcpy(symbol->errtxt, "erro: input wrong length"); strcpy(symbol->errtxt, "erro: input wrong length");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;

View File

@ -118,7 +118,7 @@ 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(strlen(source)) switch(ustrlen(source))
{ {
case 8: strcpy(fcc, "11"); break; case 8: strcpy(fcc, "11"); break;
case 13: strcpy(fcc, "59"); break; case 13: strcpy(fcc, "59"); break;
@ -134,7 +134,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[])
return errno; return errno;
} }
} else { } else {
if(strlen(source) != 8) { if(ustrlen(source) != 8) {
strcpy(symbol->errtxt, "error: auspost input is wrong length"); strcpy(symbol->errtxt, "error: auspost input is wrong length");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -181,15 +181,15 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[])
} }
/* Customer Information */ /* Customer Information */
if(strlen(source) > 8) if(ustrlen(source) > 8)
{ {
if((strlen(source) == 13) || (strlen(source) == 18)) { if((ustrlen(source) == 13) || (ustrlen(source) == 18)) {
for(reader = 8; reader < strlen(source); reader++) { for(reader = 8; reader < ustrlen(source); reader++) {
lookup(GDSET, AusCTable, source[reader], data_pattern); lookup(GDSET, AusCTable, source[reader], data_pattern);
} }
} }
if((strlen(source) == 16) || (strlen(source) == 23)) { if((ustrlen(source) == 16) || (ustrlen(source) == 23)) {
for(reader = 8; reader < strlen(source); reader++) { for(reader = 8; reader < ustrlen(source); reader++) {
lookup(NESET, AusNTable, source[reader], data_pattern); lookup(NESET, AusNTable, source[reader], data_pattern);
} }
} }

View File

@ -48,14 +48,14 @@ void insert(char binary_string[], int posn, char newbit)
int aztec_text_process(unsigned char source[], char binary_string[]) int aztec_text_process(unsigned char source[], char binary_string[])
{ /* Encode input data into a binary string */ { /* Encode input data into a binary string */
int map_posn, i, j, k, bytes; int i, j, k, bytes;
int charmap[strlen(source)], typemap[strlen(source)], maplength; int charmap[ustrlen(source)], typemap[ustrlen(source)], maplength;
int curtable, newtable, lasttable, chartype; int curtable, newtable, lasttable, chartype;
int blockmap[2][strlen(source)], blocks; int blockmap[2][ustrlen(source)], blocks;
/* Lookup input string in encoding table */ /* Lookup input string in encoding table */
for(i = 0; i < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
if(source[i] > 127) { if(source[i] > 127) {
charmap[i] = source[i]; charmap[i] = source[i];
typemap[i] = BINARY; typemap[i] = BINARY;
@ -64,7 +64,7 @@ int aztec_text_process(unsigned char source[], char binary_string[])
typemap[i] = AztecCodeSet[source[i]]; typemap[i] = AztecCodeSet[source[i]];
} }
} }
maplength = strlen(source); maplength = ustrlen(source);
/* Look for double character encoding possibilities */ /* Look for double character encoding possibilities */
i = 0; i = 0;
@ -151,7 +151,6 @@ int aztec_text_process(unsigned char source[], char binary_string[])
} }
/* Combine blocks of the same type */ /* Combine blocks of the same type */
blocks;
i = 0; i = 0;
do{ do{
if(blockmap[0][i] == blockmap[0][i + 1]) { if(blockmap[0][i] == blockmap[0][i + 1]) {

View File

@ -66,7 +66,8 @@ int a3_convert(unsigned char source) {
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; }
if(source >= 160) { return (source - 128) - 32; } /* if source >= 160 */
return (source - 128) - 32;
} }
int character_subset_select(unsigned char source[], int input_position) { int character_subset_select(unsigned char source[], int input_position) {
@ -92,14 +93,14 @@ int character_subset_select(unsigned char source[], int input_position) {
int data_encode_blockf(unsigned char source[], int subset_selector[], int blockmatrix[][62], int *columns_needed, int *rows_needed, int *final_mode) int data_encode_blockf(unsigned char source[], int subset_selector[], int blockmatrix[][62], int *columns_needed, int *rows_needed, int *final_mode)
{ {
int i, j, input_position, input_length, current_mode, current_row, error_number; int i, input_position, input_length, current_mode, current_row, error_number;
int column_position, c, done, exit_status; int column_position, c, done, exit_status;
error_number = 0; error_number = 0;
exit_status = 0; exit_status = 0;
current_row = 0; current_row = 0;
current_mode = MODEA; current_mode = MODEA;
input_length = strlen(source); input_length = ustrlen(source);
column_position = 0; column_position = 0;
input_position = 0; input_position = 0;
done = 0; done = 0;
@ -146,7 +147,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
column_position++; column_position++;
c--; c--;
} }
done == 1; done = 1;
} }
if((source[input_position] >= 128) && (done == 0)) { if((source[input_position] >= 128) && (done == 0)) {
@ -186,7 +187,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
column_position++; column_position++;
c--; c--;
} }
done == 1; done = 1;
} }
if((source[input_position] >= 160) && (done == 0)) { if((source[input_position] >= 160) && (done == 0)) {
@ -532,7 +533,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
int k1_check, k2_check; int k1_check, k2_check;
error_number = 0; error_number = 0;
input_length = strlen(source); input_length = ustrlen(source);
final_mode = MODEA; final_mode = MODEA;
if(input_length > 5450) { if(input_length > 5450) {

View File

@ -86,7 +86,7 @@ int code_11(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 80) { if(ustrlen(source) > 80) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -104,13 +104,13 @@ 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 < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
lookup(NASET, C11Table, source[i], dest); lookup(NASET, C11Table, source[i], dest);
weight[i] = ctoi(source[i]); weight[i] = ctoi(source[i]);
} }
/* Calculate C checksum */ /* Calculate C checksum */
for(h = (strlen(source) - 1); h >= 0; h--) { for(h = (ustrlen(source) - 1); h >= 0; h--) {
c_count += (c_weight * weight[h]); c_count += (c_weight * weight[h]);
c_weight++; c_weight++;
@ -122,10 +122,10 @@ int code_11(struct zint_symbol *symbol, unsigned char source[])
/* Draw C checksum */ /* Draw C checksum */
lookup(NASET, C11Table, itoc(c_digit), dest); lookup(NASET, C11Table, itoc(c_digit), dest);
weight[strlen(source)] = c_digit; weight[ustrlen(source)] = c_digit;
/* Calculate K checksum */ /* Calculate K checksum */
for(h = strlen(source); h >= 0; h--) { for(h = ustrlen(source); h >= 0; h--) {
k_count += (k_weight * weight[h]); k_count += (k_weight * weight[h]);
k_weight++; k_weight++;
@ -141,7 +141,7 @@ int code_11(struct zint_symbol *symbol, unsigned char source[])
/* Stop character */ /* Stop character */
concat (dest, "11221"); concat (dest, "11221");
h = strlen(source); h = ustrlen(source);
source[h] = itoc(c_digit); source[h] = itoc(c_digit);
source[h + 1] = itoc(k_digit); source[h + 1] = itoc(k_digit);
source[h + 2] = '\0'; source[h + 2] = '\0';
@ -167,7 +167,7 @@ int c39(struct zint_symbol *symbol, unsigned char source[])
} }
to_upper(source); to_upper(source);
if(strlen(source) > 45) { if(ustrlen(source) > 45) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -180,7 +180,7 @@ int c39(struct zint_symbol *symbol, unsigned char source[])
/* Start character */ /* Start character */
concat(dest, "1211212111"); concat(dest, "1211212111");
for(i = 0; i < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
lookup(TCSET, C39Table, source[i], dest); lookup(TCSET, C39Table, source[i], dest);
counter += posn(TCSET, source[i]); counter += posn(TCSET, source[i]);
} }
@ -212,7 +212,7 @@ int c39(struct zint_symbol *symbol, unsigned char source[])
check_digit = '_'; check_digit = '_';
} }
h = strlen(source); h = ustrlen(source);
source[h] = check_digit; source[h] = check_digit;
source[h + 1] = '\0'; source[h + 1] = '\0';
} }
@ -250,7 +250,7 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
count = 0; count = 0;
h = strlen(source); h = ustrlen(source);
if(h != 6) { if(h != 6) {
strcpy(symbol->errtxt, "error: input wrong length"); strcpy(symbol->errtxt, "error: input wrong length");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
@ -295,7 +295,7 @@ int ec39(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
if(strlen(source) > 45) { if(ustrlen(source) > 45) {
/* only stops strings which are far too long - actual length of the barcode /* only stops strings which are far too long - actual length of the barcode
depends on the type of data being encoded - if it's too long it's picked up depends on the type of data being encoded - if it's too long it's picked up
by c39() */ by c39() */
@ -304,7 +304,7 @@ int ec39(struct zint_symbol *symbol, unsigned char source[])
} }
for(i = 0; i < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
if(source[i] > 127) { if(source[i] > 127) {
/* Cannot encode extended ASCII */ /* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "error: invalid characters in input data"); strcpy(symbol->errtxt, "error: invalid characters in input data");
@ -313,7 +313,7 @@ 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 < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
ascii_value = source[i]; ascii_value = source[i];
concat(buffer, EC39Ctrl[ascii_value]); concat(buffer, EC39Ctrl[ascii_value]);
} }
@ -345,14 +345,14 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 45) { if(ustrlen(source) > 45) {
/* This stops rediculously long input - the actual length of the barcode /* This stops rediculously long input - the actual length of the barcode
depends on the type of data */ depends on the type of data */
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
for(i = 0; i < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
if(source[i] > 127) { if(source[i] > 127) {
/* Cannot encode extended ASCII */ /* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "error: invalid characters in input data"); strcpy(symbol->errtxt, "error: invalid characters in input data");
@ -364,7 +364,7 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
concat(dest, "111141"); concat(dest, "111141");
/* Message Content */ /* Message Content */
for(i = 0; i < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
ascii_value = source[i]; ascii_value = source[i];
concat(buffer, C93Ctrl[ascii_value]); concat(buffer, C93Ctrl[ascii_value]);
} }
@ -429,7 +429,7 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
/* Stop character */ /* Stop character */
concat(dest, "1111411"); concat(dest, "1111411");
h = strlen(source); h = ustrlen(source);
source[h] = set_copy[c]; source[h] = set_copy[c];
source[h + 1] = set_copy[k]; source[h + 1] = set_copy[k];
source[h + 2] = '\0'; source[h + 2] = '\0';

View File

@ -194,7 +194,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
errornum = 0; errornum = 0;
strcpy(dest, ""); strcpy(dest, "");
sourcelen = strlen(source); sourcelen = ustrlen(source);
j = 0; j = 0;
e_count = 0; e_count = 0;
@ -582,7 +582,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
errornum = 0; errornum = 0;
strcpy(dest, ""); strcpy(dest, "");
linkage_flag = 0; linkage_flag = 0;
sourcelen = strlen(source); sourcelen = ustrlen(source);
j = 0; j = 0;
e_count = 0; e_count = 0;
@ -907,7 +907,7 @@ int ean_14(struct zint_symbol *symbol, unsigned char source[])
char ean128_equiv[20]; char ean128_equiv[20];
strcpy(ean128_equiv, ""); strcpy(ean128_equiv, "");
input_length = strlen(source); input_length = ustrlen(source);
if(input_length != 13) { if(input_length != 13) {
strcpy(symbol->errtxt, "error: input wrong length"); strcpy(symbol->errtxt, "error: input wrong length");

View File

@ -121,7 +121,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
int input_length; int input_length;
errornum = 0; errornum = 0;
input_length = strlen(source); input_length = ustrlen(source);
if(input_length > 157) { if(input_length > 157) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
@ -391,7 +391,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
read += 2; read += 2;
break; break;
} }
} while (read < strlen(source)); } while (read < ustrlen(source));
pads_needed = 5 - ((bar_characters + 2) % 5); pads_needed = 5 - ((bar_characters + 2) % 5);

View File

@ -25,6 +25,16 @@
#define SSET "0123456789ABCDEF" #define SSET "0123456789ABCDEF"
int ustrlen(unsigned char data[]) {
/* Local replacement for strlen() with unsigned char strings */
int i;
i = -1;
do { i++; } while (data[i] != '\0');
return i;
}
void concat(char dest[], char source[]) void concat(char dest[], char source[])
{ /* Concatinates dest[] with the contents of source[], copying /0 as well */ { /* Concatinates dest[] with the contents of source[], copying /0 as well */
unsigned int i, j; unsigned int i, j;
@ -53,7 +63,7 @@ void to_upper(unsigned char source[])
{ /* Converts lower case characters to upper case in a string source[] */ { /* Converts lower case characters to upper case in a string source[] */
unsigned int i; unsigned int i;
for (i = 0; i < strlen(source); i++) { for (i = 0; i < ustrlen(source); i++) {
if ((source[i] >= 'a') && (source[i] <= 'z')) { if ((source[i] >= 'a') && (source[i] <= 'z')) {
source [i] = (source[i] - 'a') + 'A'; } source [i] = (source[i] - 'a') + 'A'; }
} }
@ -63,7 +73,7 @@ int is_sane(char test_string[], unsigned char source[])
{ /* 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 < strlen(source); i++) { for(i = 0; i < ustrlen(source); 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; } }

View File

@ -28,6 +28,7 @@
#include "zint.h" #include "zint.h"
int ustrlen(unsigned char source[]);
void concat(char dest[], char source[]); void concat(char dest[], char source[]);
int ctoi(char source); int ctoi(char source);
char itoc(int source); char itoc(int source);

View File

@ -109,7 +109,6 @@ int encode928(UINT bitString[], UINT codeWords[], int bitLng) {
int cc_a(struct zint_symbol *symbol, unsigned char source[], int cc_width) int cc_a(struct zint_symbol *symbol, unsigned char source[], int cc_width)
{ /* CC-A 2D component */ { /* CC-A 2D component */
int temp;
int i, strpos, segment, bitlen, cwCnt, variant, rows; int i, strpos, segment, bitlen, cwCnt, variant, rows;
int k, offset, j, total, rsCodeWords[8]; int k, offset, j, total, rsCodeWords[8];
int LeftRAPStart, RightRAPStart, CentreRAPStart, StartCluster; int LeftRAPStart, RightRAPStart, CentreRAPStart, StartCluster;
@ -122,7 +121,7 @@ int cc_a(struct zint_symbol *symbol, unsigned char source[], int cc_width)
for(i = 0; i < 13; i++) { bitStr[i] = 0; } for(i = 0; i < 13; i++) { bitStr[i] = 0; }
for(i = 0; i < 28; i++) { codeWords[i] = 0; } for(i = 0; i < 28; i++) { codeWords[i] = 0; }
bitlen = strlen(source); bitlen = ustrlen(source);
for(i = bitlen; i < 197; i++) { for(i = bitlen; i < 197; i++) {
source[i] = '0'; source[i] = '0';
@ -322,7 +321,7 @@ int cc_a(struct zint_symbol *symbol, unsigned char source[], int cc_width)
int cc_b(struct zint_symbol *symbol, unsigned char source[], int cc_width) int cc_b(struct zint_symbol *symbol, unsigned char source[], int cc_width)
{ /* CC-B 2D component */ { /* CC-B 2D component */
int length, i, binloc; int length, i, binloc;
unsigned char data_string[(strlen(source) / 8) + 3]; unsigned char data_string[(ustrlen(source) / 8) + 3];
int chainemc[180], mclength; int chainemc[180], mclength;
int k, j, longueur, mccorrection[50], offset; int k, j, longueur, mccorrection[50], offset;
int total, dummy[5]; int total, dummy[5];
@ -330,7 +329,7 @@ int cc_b(struct zint_symbol *symbol, unsigned char source[], int cc_width)
int variant, LeftRAPStart, CentreRAPStart, RightRAPStart, StartCluster; int variant, LeftRAPStart, CentreRAPStart, RightRAPStart, StartCluster;
int LeftRAP, CentreRAP, RightRAP, Cluster, writer, flip, loop; int LeftRAP, CentreRAP, RightRAP, Cluster, writer, flip, loop;
length = strlen(source) / 8; length = ustrlen(source) / 8;
for(i = 0; i < length; i++) { for(i = 0; i < length; i++) {
binloc = i * 8; binloc = i * 8;
@ -549,13 +548,13 @@ int cc_b(struct zint_symbol *symbol, unsigned char source[], int cc_width)
int cc_c(struct zint_symbol *symbol, unsigned char source[], int cc_width, int ecc_level) int cc_c(struct zint_symbol *symbol, unsigned char source[], int cc_width, int ecc_level)
{ /* CC-C 2D component - byte compressed PDF417 */ { /* CC-C 2D component - byte compressed PDF417 */
int length, i, binloc; int length, i, binloc;
unsigned char data_string[(strlen(source) / 8) + 4]; unsigned char data_string[(ustrlen(source) / 8) + 4];
int chainemc[1000], mclength, k; int chainemc[1000], mclength, k;
int offset, longueur, loop, total, j, mccorrection[520]; int offset, longueur, loop, total, j, mccorrection[520];
int c1, c2, c3, dummy[35]; int c1, c2, c3, dummy[35];
char codebarre[100], pattern[580]; char codebarre[100], pattern[580];
length = strlen(source) / 8; length = ustrlen(source) / 8;
for(i = 0; i < length; i++) { for(i = 0; i < length; i++) {
binloc = i * 8; binloc = i * 8;
@ -689,9 +688,9 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
{ /* Handles all data encodation from section 5 of ISO/IEC 24723 */ { /* Handles all data encodation from section 5 of ISO/IEC 24723 */
int encoding_method, read_posn, d1, d2, value, alpha_pad; int encoding_method, read_posn, d1, d2, value, alpha_pad;
int group_val, i, j, mask, ai_crop, ai_crop_posn, fnc1_latch; int group_val, i, j, mask, ai_crop, ai_crop_posn, fnc1_latch;
int ai90_mode, latch, remainder; int ai90_mode, latch, remainder, binary_length;
char date_str[4]; char date_str[4];
char general_field[strlen(source)], general_field_type[strlen(source)]; char general_field[ustrlen(source)], general_field_type[ustrlen(source)];
int target_bitsize; int target_bitsize;
encoding_method = 1; encoding_method = 1;
@ -703,7 +702,7 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
ai90_mode = 0; ai90_mode = 0;
*(ecc) = 0; *(ecc) = 0;
if((source[0] == '1') && ((source[1] == '0') || (source[1] == '1') || (source[1] == '7')) && (strlen(source) > 8)) { if((source[0] == '1') && ((source[1] == '0') || (source[1] == '1') || (source[1] == '7')) && (ustrlen(source) > 8)) {
/* Source starts (10), (11) or (17) */ /* Source starts (10), (11) or (17) */
encoding_method = 2; encoding_method = 2;
} }
@ -772,8 +771,8 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
if (encoding_method == 3) { if (encoding_method == 3) {
/* Encodation Method field of "11" - AI 90 */ /* Encodation Method field of "11" - AI 90 */
char ninety[strlen(source)], numeric_part[4]; char ninety[ustrlen(source)], numeric_part[4];
int alpha, alphanum, numeric, test1, test2, test3, next_ai_posn, test4; int alpha, alphanum, numeric, test1, test2, test3, next_ai_posn;
int numeric_value, table3_letter, mask; int numeric_value, table3_letter, mask;
/* "This encodation method may be used if an element string with an AI /* "This encodation method may be used if an element string with an AI
@ -785,7 +784,7 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
do { do {
ninety[i] = source[i + 2]; ninety[i] = source[i + 2];
i++; i++;
} while ((source[i + 2] != '[') && ((i + 2) < strlen(source))); } while ((source[i + 2] != '[') && ((i + 2) < ustrlen(source)));
ninety[i] = '\0'; ninety[i] = '\0';
/* Find out if the AI 90 data is alphabetic or numeric or both */ /* Find out if the AI 90 data is alphabetic or numeric or both */
@ -1071,7 +1070,7 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
j++; j++;
} }
for(i = read_posn; i < strlen(source); i++) { for(i = read_posn; i < ustrlen(source); i++) {
general_field[j] = source[i]; general_field[j] = source[i];
j++; j++;
} }
@ -1334,34 +1333,35 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
} }
} while (i + latch < strlen(general_field)); } while (i + latch < strlen(general_field));
binary_length = strlen(binary_string);
if(cc_mode == 1) { if(cc_mode == 1) {
/* CC-A 2D component - calculate remaining space */ /* CC-A 2D component - calculate remaining space */
switch(*(cc_width)) { switch(*(cc_width)) {
case 2: case 2:
if(strlen(binary_string) > 167) { return ERROR_TOO_LONG; } if(binary_length > 167) { return ERROR_TOO_LONG; }
if(strlen(binary_string) <= 167) { target_bitsize = 167; } if(binary_length <= 167) { target_bitsize = 167; }
if(strlen(binary_string) <= 138) { target_bitsize = 138; } if(binary_length <= 138) { target_bitsize = 138; }
if(strlen(binary_string) <= 118) { target_bitsize = 118; } if(binary_length <= 118) { target_bitsize = 118; }
if(strlen(binary_string) <= 108) { target_bitsize = 108; } if(binary_length <= 108) { target_bitsize = 108; }
if(strlen(binary_string) <= 88) { target_bitsize = 88; } if(binary_length <= 88) { target_bitsize = 88; }
if(strlen(binary_string) <= 78) { target_bitsize = 78; } if(binary_length <= 78) { target_bitsize = 78; }
if(strlen(binary_string) <= 59) { target_bitsize = 59; } if(binary_length <= 59) { target_bitsize = 59; }
break; break;
case 3: case 3:
if(strlen(binary_string) > 167) { return ERROR_TOO_LONG; } if(binary_length > 167) { return ERROR_TOO_LONG; }
if(strlen(binary_string) <= 167) { target_bitsize = 167; } if(binary_length <= 167) { target_bitsize = 167; }
if(strlen(binary_string) <= 138) { target_bitsize = 138; } if(binary_length <= 138) { target_bitsize = 138; }
if(strlen(binary_string) <= 118) { target_bitsize = 118; } if(binary_length <= 118) { target_bitsize = 118; }
if(strlen(binary_string) <= 98) { target_bitsize = 98; } if(binary_length <= 98) { target_bitsize = 98; }
if(strlen(binary_string) <= 78) { target_bitsize = 78; } if(binary_length <= 78) { target_bitsize = 78; }
break; break;
case 4: case 4:
if(strlen(binary_string) > 197) { return ERROR_TOO_LONG; } if(binary_length > 197) { return ERROR_TOO_LONG; }
if(strlen(binary_string) <= 197) { target_bitsize = 197; } if(binary_length <= 197) { target_bitsize = 197; }
if(strlen(binary_string) <= 167) { target_bitsize = 167; } if(binary_length <= 167) { target_bitsize = 167; }
if(strlen(binary_string) <= 138) { target_bitsize = 138; } if(binary_length <= 138) { target_bitsize = 138; }
if(strlen(binary_string) <= 108) { target_bitsize = 108; } if(binary_length <= 108) { target_bitsize = 108; }
if(strlen(binary_string) <= 78) { target_bitsize = 78; } if(binary_length <= 78) { target_bitsize = 78; }
break; break;
} }
} }
@ -1370,41 +1370,41 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
/* CC-B 2D component - calculated from ISO/IEC 24728 Table 1 */ /* CC-B 2D component - calculated from ISO/IEC 24728 Table 1 */
switch(*(cc_width)) { switch(*(cc_width)) {
case 2: case 2:
if(strlen(binary_string) > 336) { return ERROR_TOO_LONG; } if(binary_length > 336) { return ERROR_TOO_LONG; }
if(strlen(binary_string) <= 336) { target_bitsize = 336; } if(binary_length <= 336) { target_bitsize = 336; }
if(strlen(binary_string) <= 296) { target_bitsize = 296; } if(binary_length <= 296) { target_bitsize = 296; }
if(strlen(binary_string) <= 256) { target_bitsize = 256; } if(binary_length <= 256) { target_bitsize = 256; }
if(strlen(binary_string) <= 208) { target_bitsize = 208; } if(binary_length <= 208) { target_bitsize = 208; }
if(strlen(binary_string) <= 160) { target_bitsize = 160; } if(binary_length <= 160) { target_bitsize = 160; }
if(strlen(binary_string) <= 104) { target_bitsize = 104; } if(binary_length <= 104) { target_bitsize = 104; }
if(strlen(binary_string) <= 56) { target_bitsize = 56; } if(binary_length <= 56) { target_bitsize = 56; }
break; break;
case 3: case 3:
if(strlen(binary_string) > 768) { return ERROR_TOO_LONG; } if(binary_length > 768) { return ERROR_TOO_LONG; }
if(strlen(binary_string) <= 768) { target_bitsize = 768; } if(binary_length <= 768) { target_bitsize = 768; }
if(strlen(binary_string) <= 648) { target_bitsize = 648; } if(binary_length <= 648) { target_bitsize = 648; }
if(strlen(binary_string) <= 536) { target_bitsize = 536; } if(binary_length <= 536) { target_bitsize = 536; }
if(strlen(binary_string) <= 416) { target_bitsize = 416; } if(binary_length <= 416) { target_bitsize = 416; }
if(strlen(binary_string) <= 304) { target_bitsize = 304; } if(binary_length <= 304) { target_bitsize = 304; }
if(strlen(binary_string) <= 208) { target_bitsize = 208; } if(binary_length <= 208) { target_bitsize = 208; }
if(strlen(binary_string) <= 152) { target_bitsize = 152; } if(binary_length <= 152) { target_bitsize = 152; }
if(strlen(binary_string) <= 112) { target_bitsize = 112; } if(binary_length <= 112) { target_bitsize = 112; }
if(strlen(binary_string) <= 72) { target_bitsize = 72; } if(binary_length <= 72) { target_bitsize = 72; }
if(strlen(binary_string) <= 32) { target_bitsize = 32; } if(binary_length <= 32) { target_bitsize = 32; }
break; break;
case 4: case 4:
if(strlen(binary_string) > 1184) { return ERROR_TOO_LONG; } if(binary_length > 1184) { return ERROR_TOO_LONG; }
if(strlen(binary_string) <= 1184) { target_bitsize = 1184; } if(binary_length <= 1184) { target_bitsize = 1184; }
if(strlen(binary_string) <= 1016) { target_bitsize = 1016; } if(binary_length <= 1016) { target_bitsize = 1016; }
if(strlen(binary_string) <= 840) { target_bitsize = 840; } if(binary_length <= 840) { target_bitsize = 840; }
if(strlen(binary_string) <= 672) { target_bitsize = 672; } if(binary_length <= 672) { target_bitsize = 672; }
if(strlen(binary_string) <= 496) { target_bitsize = 496; } if(binary_length <= 496) { target_bitsize = 496; }
if(strlen(binary_string) <= 352) { target_bitsize = 352; } if(binary_length <= 352) { target_bitsize = 352; }
if(strlen(binary_string) <= 264) { target_bitsize = 264; } if(binary_length <= 264) { target_bitsize = 264; }
if(strlen(binary_string) <= 208) { target_bitsize = 208; } if(binary_length <= 208) { target_bitsize = 208; }
if(strlen(binary_string) <= 152) { target_bitsize = 152; } if(binary_length <= 152) { target_bitsize = 152; }
if(strlen(binary_string) <= 96) { target_bitsize = 96; } if(binary_length <= 96) { target_bitsize = 96; }
if(strlen(binary_string) <= 56) { target_bitsize = 56; } if(binary_length <= 56) { target_bitsize = 56; }
break; break;
} }
} }
@ -1414,8 +1414,8 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
int byte_length, codewords_used, ecc_level, ecc_codewords, rows; int byte_length, codewords_used, ecc_level, ecc_codewords, rows;
int codewords_total, target_codewords, target_bytesize; int codewords_total, target_codewords, target_bytesize;
byte_length = strlen(binary_string) / 8; byte_length = binary_length / 8;
if(strlen(binary_string) % 8 != 0) { byte_length++; } if(binary_length % 8 != 0) { byte_length++; }
codewords_used = (byte_length / 6) * 5; codewords_used = (byte_length / 6) * 5;
codewords_used += byte_length % 6; codewords_used += byte_length % 6;
@ -1461,7 +1461,7 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
target_bitsize = 8 * target_bytesize; target_bitsize = 8 * target_bytesize;
} }
remainder = strlen(binary_string) - target_bitsize; remainder = binary_length - target_bitsize;
if(latch == 1) { if(latch == 1) {
i = 0; i = 0;
@ -1507,34 +1507,35 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
/* all the code below is repeated from above - it needs to be calculated again because the /* all the code below is repeated from above - it needs to be calculated again because the
size of the symbol may have changed when adding data in the above sequence */ size of the symbol may have changed when adding data in the above sequence */
binary_length = strlen(binary_string);
if(cc_mode == 1) { if(cc_mode == 1) {
/* CC-A 2D component - calculate padding required */ /* CC-A 2D component - calculate padding required */
switch(*(cc_width)) { switch(*(cc_width)) {
case 2: case 2:
if(strlen(binary_string) > 167) { return ERROR_TOO_LONG; } if(binary_length > 167) { return ERROR_TOO_LONG; }
if(strlen(binary_string) <= 167) { target_bitsize = 167; } if(binary_length <= 167) { target_bitsize = 167; }
if(strlen(binary_string) <= 138) { target_bitsize = 138; } if(binary_length <= 138) { target_bitsize = 138; }
if(strlen(binary_string) <= 118) { target_bitsize = 118; } if(binary_length <= 118) { target_bitsize = 118; }
if(strlen(binary_string) <= 108) { target_bitsize = 108; } if(binary_length <= 108) { target_bitsize = 108; }
if(strlen(binary_string) <= 88) { target_bitsize = 88; } if(binary_length <= 88) { target_bitsize = 88; }
if(strlen(binary_string) <= 78) { target_bitsize = 78; } if(binary_length <= 78) { target_bitsize = 78; }
if(strlen(binary_string) <= 59) { target_bitsize = 59; } if(binary_length <= 59) { target_bitsize = 59; }
break; break;
case 3: case 3:
if(strlen(binary_string) > 167) { return ERROR_TOO_LONG; } if(binary_length > 167) { return ERROR_TOO_LONG; }
if(strlen(binary_string) <= 167) { target_bitsize = 167; } if(binary_length <= 167) { target_bitsize = 167; }
if(strlen(binary_string) <= 138) { target_bitsize = 138; } if(binary_length <= 138) { target_bitsize = 138; }
if(strlen(binary_string) <= 118) { target_bitsize = 118; } if(binary_length <= 118) { target_bitsize = 118; }
if(strlen(binary_string) <= 98) { target_bitsize = 98; } if(binary_length <= 98) { target_bitsize = 98; }
if(strlen(binary_string) <= 78) { target_bitsize = 78; } if(binary_length <= 78) { target_bitsize = 78; }
break; break;
case 4: case 4:
if(strlen(binary_string) > 197) { return ERROR_TOO_LONG; } if(binary_length > 197) { return ERROR_TOO_LONG; }
if(strlen(binary_string) <= 197) { target_bitsize = 197; } if(binary_length <= 197) { target_bitsize = 197; }
if(strlen(binary_string) <= 167) { target_bitsize = 167; } if(binary_length <= 167) { target_bitsize = 167; }
if(strlen(binary_string) <= 138) { target_bitsize = 138; } if(binary_length <= 138) { target_bitsize = 138; }
if(strlen(binary_string) <= 108) { target_bitsize = 108; } if(binary_length <= 108) { target_bitsize = 108; }
if(strlen(binary_string) <= 78) { target_bitsize = 78; } if(binary_length <= 78) { target_bitsize = 78; }
break; break;
} }
} }
@ -1543,41 +1544,41 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
/* CC-B 2D component */ /* CC-B 2D component */
switch(*(cc_width)) { switch(*(cc_width)) {
case 2: case 2:
if(strlen(binary_string) > 336) { return ERROR_TOO_LONG; } if(binary_length > 336) { return ERROR_TOO_LONG; }
if(strlen(binary_string) <= 336) { target_bitsize = 336; } if(binary_length <= 336) { target_bitsize = 336; }
if(strlen(binary_string) <= 296) { target_bitsize = 296; } if(binary_length <= 296) { target_bitsize = 296; }
if(strlen(binary_string) <= 256) { target_bitsize = 256; } if(binary_length <= 256) { target_bitsize = 256; }
if(strlen(binary_string) <= 208) { target_bitsize = 208; } if(binary_length <= 208) { target_bitsize = 208; }
if(strlen(binary_string) <= 160) { target_bitsize = 160; } if(binary_length <= 160) { target_bitsize = 160; }
if(strlen(binary_string) <= 104) { target_bitsize = 104; } if(binary_length <= 104) { target_bitsize = 104; }
if(strlen(binary_string) <= 56) { target_bitsize = 56; } if(binary_length <= 56) { target_bitsize = 56; }
break; break;
case 3: case 3:
if(strlen(binary_string) > 768) { return ERROR_TOO_LONG; } if(binary_length > 768) { return ERROR_TOO_LONG; }
if(strlen(binary_string) <= 768) { target_bitsize = 768; } if(binary_length <= 768) { target_bitsize = 768; }
if(strlen(binary_string) <= 648) { target_bitsize = 648; } if(binary_length <= 648) { target_bitsize = 648; }
if(strlen(binary_string) <= 536) { target_bitsize = 536; } if(binary_length <= 536) { target_bitsize = 536; }
if(strlen(binary_string) <= 416) { target_bitsize = 416; } if(binary_length <= 416) { target_bitsize = 416; }
if(strlen(binary_string) <= 304) { target_bitsize = 304; } if(binary_length <= 304) { target_bitsize = 304; }
if(strlen(binary_string) <= 208) { target_bitsize = 208; } if(binary_length <= 208) { target_bitsize = 208; }
if(strlen(binary_string) <= 152) { target_bitsize = 152; } if(binary_length <= 152) { target_bitsize = 152; }
if(strlen(binary_string) <= 112) { target_bitsize = 112; } if(binary_length <= 112) { target_bitsize = 112; }
if(strlen(binary_string) <= 72) { target_bitsize = 72; } if(binary_length <= 72) { target_bitsize = 72; }
if(strlen(binary_string) <= 32) { target_bitsize = 32; } if(binary_length <= 32) { target_bitsize = 32; }
break; break;
case 4: case 4:
if(strlen(binary_string) > 1184) { return ERROR_TOO_LONG; } if(binary_length > 1184) { return ERROR_TOO_LONG; }
if(strlen(binary_string) <= 1184) { target_bitsize = 1184; } if(binary_length <= 1184) { target_bitsize = 1184; }
if(strlen(binary_string) <= 1016) { target_bitsize = 1016; } if(binary_length <= 1016) { target_bitsize = 1016; }
if(strlen(binary_string) <= 840) { target_bitsize = 840; } if(binary_length <= 840) { target_bitsize = 840; }
if(strlen(binary_string) <= 672) { target_bitsize = 672; } if(binary_length <= 672) { target_bitsize = 672; }
if(strlen(binary_string) <= 496) { target_bitsize = 496; } if(binary_length <= 496) { target_bitsize = 496; }
if(strlen(binary_string) <= 352) { target_bitsize = 352; } if(binary_length <= 352) { target_bitsize = 352; }
if(strlen(binary_string) <= 264) { target_bitsize = 264; } if(binary_length <= 264) { target_bitsize = 264; }
if(strlen(binary_string) <= 208) { target_bitsize = 208; } if(binary_length <= 208) { target_bitsize = 208; }
if(strlen(binary_string) <= 152) { target_bitsize = 152; } if(binary_length <= 152) { target_bitsize = 152; }
if(strlen(binary_string) <= 96) { target_bitsize = 96; } if(binary_length <= 96) { target_bitsize = 96; }
if(strlen(binary_string) <= 56) { target_bitsize = 56; } if(binary_length <= 56) { target_bitsize = 56; }
break; break;
} }
} }
@ -1587,8 +1588,8 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
int byte_length, codewords_used, ecc_level, ecc_codewords, rows; int byte_length, codewords_used, ecc_level, ecc_codewords, rows;
int codewords_total, target_codewords, target_bytesize; int codewords_total, target_codewords, target_bytesize;
byte_length = strlen(binary_string) / 8; byte_length = binary_length / 8;
if(strlen(binary_string) % 8 != 0) { byte_length++; } if(binary_length % 8 != 0) { byte_length++; }
codewords_used = (byte_length / 6) * 5; codewords_used = (byte_length / 6) * 5;
codewords_used += byte_length % 6; codewords_used += byte_length % 6;
@ -1634,7 +1635,7 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi
target_bitsize = 8 * target_bytesize; target_bitsize = 8 * target_bytesize;
} }
if(strlen(binary_string) < target_bitsize) { if(binary_length < target_bitsize) {
/* Now add padding to binary string */ /* Now add padding to binary string */
if (alpha_pad == 1) { if (alpha_pad == 1) {
concat(binary_string, "11111"); concat(binary_string, "11111");
@ -1662,7 +1663,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
{ {
int errno, cc_mode, cc_width, ecc_level; int errno, cc_mode, cc_width, ecc_level;
int j, last_ai, ai_latch, i, k, separator_row; int j, last_ai, ai_latch, i, k, separator_row;
char reduced[3000], binary_string[10 * strlen(source)], ai_string[4]; char reduced[3000], binary_string[10 * ustrlen(source)], ai_string[4];
struct zint_symbol *linear; struct zint_symbol *linear;
int top_shift, bottom_shift; int top_shift, bottom_shift;
@ -1674,7 +1675,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
return ERROR_INVALID_OPTION; return ERROR_INVALID_OPTION;
} }
if(strlen(source) > 2990) { if(ustrlen(source) > 2990) {
strcpy(symbol->errtxt, "error: 2D component input data too long"); strcpy(symbol->errtxt, "error: 2D component input data too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -1684,7 +1685,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
return ERROR_INVALID_DATA; return ERROR_INVALID_DATA;
} }
for(i = 0; i < strlen(source) - 1; i++) { for(i = 0; i < ustrlen(source) - 1; i++) {
if((source[i] == '[') && (source[i + 1] == '[')) { if((source[i] == '[') && (source[i + 1] == '[')) {
/* Can't have nested brackets - Quit */ /* Can't have nested brackets - Quit */
strcpy(symbol->errtxt, "Nested AI detected (two or more open brackets)"); strcpy(symbol->errtxt, "Nested AI detected (two or more open brackets)");
@ -1692,7 +1693,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
} }
} }
for(i = 0; i < strlen(source) - 1; i++) { for(i = 0; i < ustrlen(source) - 1; i++) {
if((source[i] == ']') && (source[i + 1] == ']')) { if((source[i] == ']') && (source[i + 1] == ']')) {
/* Can't have nested brackets - Quit */ /* Can't have nested brackets - Quit */
strcpy(symbol->errtxt, "Nested AI detected (two or more close brackets)"); strcpy(symbol->errtxt, "Nested AI detected (two or more close brackets)");
@ -1706,7 +1707,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
j = 0; j = 0;
last_ai = 0; last_ai = 0;
ai_latch = 1; ai_latch = 1;
for(i = 0; i < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
if((source[i] != '[') && (source[i] != ']')) { if((source[i] != '[') && (source[i] != ']')) {
reduced[j] = source[i]; reduced[j] = source[i];
j++; j++;

View File

@ -79,7 +79,7 @@ int dmatrix(struct zint_symbol *symbol, unsigned char source[])
barcode[barcodelen] = 0; // null terminate anyway barcode[barcodelen] = 0; // null terminate anyway
fclose(f); fclose(f);
} else */ } else */
barcodelen = strlen(source); barcodelen = ustrlen(source);
if(barcodelen > 780) { if(barcodelen > 780) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;

View File

@ -22,6 +22,18 @@
/* The function "USPS_MSB_Math_CRC11GenerateFrameCheckSequence" /* The function "USPS_MSB_Math_CRC11GenerateFrameCheckSequence"
is Copyright (C) 2006 United States Postal Service */ is Copyright (C) 2006 United States Postal Service */
static short int BCD[40] = {
0, 0, 0, 0,
1, 0, 0, 0,
0, 1, 0, 0,
1, 1, 0, 0,
0, 0, 1, 0,
1, 0, 1, 0,
0, 1, 1, 0,
1, 1, 1, 0,
0, 0, 0, 1,
1, 0, 0, 1 };
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -300,7 +312,7 @@ int imail(struct zint_symbol *symbol, unsigned char source[])
errno = 0; errno = 0;
if(strlen(source) > 32) { if(ustrlen(source) > 32) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -325,7 +337,7 @@ int imail(struct zint_symbol *symbol, unsigned char source[])
read = 0; read = 0;
j = 0; j = 0;
for(i = 0; i < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
if(source[i] == '-') { if(source[i] == '-') {
tracker[read] = '\0'; tracker[read] = '\0';
j = 1; j = 1;

View File

@ -19,6 +19,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include "common.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View File

@ -19,18 +19,6 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
static short int BCD[40] = {
0, 0, 0, 0,
1, 0, 0, 0,
0, 1, 0, 0,
1, 1, 0, 0,
0, 0, 1, 0,
1, 0, 1, 0,
0, 1, 1, 0,
1, 1, 1, 0,
0, 0, 0, 1,
1, 0, 0, 1 };
void binary_load(short int reg[], char data[]); void binary_load(short int reg[], char data[]);
void binary_add(short int accumulator[], short int input_buffer[]); void binary_add(short int accumulator[], short int input_buffer[]);
void binary_subtract(short int accumulator[], short int input_buffer[]); void binary_subtract(short int accumulator[], short int input_buffer[]);

View File

@ -25,6 +25,7 @@
#include "maxicode.h" #include "maxicode.h"
#include "reedsol.h" #include "reedsol.h"
#include <string.h> #include <string.h>
#include <stdlib.h>
int maxi_codeword[144]; int maxi_codeword[144];
@ -97,7 +98,7 @@ void maxi_do_secondary_chk_even(int ecclen )
maxi_codeword[ datalen + (2 *j) + 20] = results[j]; maxi_codeword[ datalen + (2 *j) + 20] = results[j];
} }
int maxi_bump(int set[], int character[], int bump_posn) void maxi_bump(int set[], int character[], int bump_posn)
{ {
/* Moves everything up so that a shift or latch can be inserted */ /* Moves everything up so that a shift or latch can be inserted */
int i; int i;
@ -118,7 +119,7 @@ int maxi_text_process(int mode, unsigned char source[])
int set[144], character[144], i, j, done, count, length, current_set; int set[144], character[144], i, j, done, count, length, current_set;
length = strlen(source); length = ustrlen(source);
if(length > 138) { if(length > 138) {
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
@ -297,7 +298,7 @@ int maxi_text_process(int mode, unsigned char source[])
} }
} }
for(i = strlen(source); i < 144; i++) { for(i = ustrlen(source); i < 144; i++) {
/* Add the padding */ /* Add the padding */
if(set[length - 1] == 2) { if(set[length - 1] == 2) {
set[i] = 2; set[i] = 2;

View File

@ -55,7 +55,7 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 6) { if(ustrlen(source) > 6) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -158,7 +158,7 @@ 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(strlen(source) > 8) { if(ustrlen(source) > 8) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -201,7 +201,7 @@ int codabar(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 60) { /* No stack smashing please */ if(ustrlen(source) > 60) { /* No stack smashing please */
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -220,14 +220,14 @@ int codabar(struct zint_symbol *symbol, unsigned char source[])
return 6; return 6;
} }
if(((source[strlen(source) - 1] != 'A') && (source[strlen(source) - 1] != 'B')) && if(((source[ustrlen(source) - 1] != 'A') && (source[ustrlen(source) - 1] != 'B')) &&
((source[strlen(source) - 1] != 'C') && (source[strlen(source) - 1] != 'D'))) ((source[ustrlen(source) - 1] != 'C') && (source[ustrlen(source) - 1] != 'D')))
{ {
strcpy(symbol->errtxt, "error: invalid characters in data"); strcpy(symbol->errtxt, "error: invalid characters in data");
return 6; return 6;
} }
for(i = 0; i <= strlen(source); i++) for(i = 0; i <= ustrlen(source); i++)
{ {
lookup(CASET, CodaTable, source[i], dest); lookup(CASET, CodaTable, source[i], dest);
} }
@ -246,7 +246,7 @@ int code32(struct zint_symbol *symbol, unsigned char source[])
char tabella[34]; char tabella[34];
/* Validate the input */ /* Validate the input */
if(strlen(source) > 8) { if(ustrlen(source) > 8) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -258,7 +258,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 - strlen(source); zeroes = 8 - ustrlen(source);
for(i = 0; i < zeroes; i++) { for(i = 0; i < zeroes; i++) {
concat(localstr, "0"); concat(localstr, "0");
} }

View File

@ -292,8 +292,7 @@ void textprocess(int *chainemc, int *mclength, char chaine[], int start, int len
void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start, int length, int block) void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start, int length, int block)
{ {
int i, j, k, l, loop, longueur; int i, j, k, l, longueur;
double multiple, total;
short int accum[112], x_reg[112], y_reg[112]; short int accum[112], x_reg[112], y_reg[112];
if(length == 1) { if(length == 1) {
@ -476,13 +475,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 < strlen(chaine))) { while ((liste[1][indexliste] == mode) && (indexchaine < ustrlen(chaine))) {
liste[0][indexliste]++; liste[0][indexliste]++;
indexchaine++; indexchaine++;
mode = quelmode(chaine[indexchaine]); mode = quelmode(chaine[indexchaine]);
} }
indexliste++; indexliste++;
} while (indexchaine < strlen(chaine)); } while (indexchaine < ustrlen(chaine));
/* 474 */ /* 474 */
pdfsmooth(&indexliste); pdfsmooth(&indexliste);
@ -761,13 +760,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 < strlen(chaine))) { while ((liste[1][indexliste] == mode) && (indexchaine < ustrlen(chaine))) {
liste[0][indexliste]++; liste[0][indexliste]++;
indexchaine++; indexchaine++;
mode = quelmode(chaine[indexchaine]); mode = quelmode(chaine[indexchaine]);
} }
indexliste++; indexliste++;
} while (indexchaine < strlen(chaine)); } while (indexchaine < ustrlen(chaine));
/* 474 */ /* 474 */
pdfsmooth(&indexliste); pdfsmooth(&indexliste);

View File

@ -451,3 +451,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);

View File

@ -46,7 +46,7 @@ int plessey(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 65) { if(ustrlen(source) > 65) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -55,13 +55,13 @@ int plessey(struct zint_symbol *symbol, unsigned char source[])
strcpy(symbol->errtxt, "error: invalid characters in data"); strcpy(symbol->errtxt, "error: invalid characters in data");
return error_number; return error_number;
} }
checkptr = calloc (1, strlen(source) * 4 + 8); checkptr = calloc (1, ustrlen(source) * 4 + 8);
/* Start character */ /* Start character */
concat(dest, "31311331"); concat(dest, "31311331");
/* Data area */ /* Data area */
for(i = 0; i <= strlen(source); i++) for(i = 0; i <= ustrlen(source); 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*strlen(source); i++) { for (i=0; i < 4*ustrlen(source); 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[strlen(source) * 4 + i]) switch(checkptr[ustrlen(source) * 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;
@ -107,7 +107,7 @@ int msi_plessey(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 55) { if(ustrlen(source) > 55) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -120,7 +120,7 @@ int msi_plessey(struct zint_symbol *symbol, unsigned char source[])
/* start character */ /* start character */
concat (dest, "21"); concat (dest, "21");
for(i = 0; i <= strlen(source); i++) for(i = 0; i <= ustrlen(source); i++)
{ {
lookup(NESET, MSITable, source[i], dest); lookup(NESET, MSITable, source[i], dest);
} }
@ -145,7 +145,7 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 55) { if(ustrlen(source) > 55) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -159,16 +159,16 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[])
concat (dest, "21"); concat (dest, "21");
/* draw data section */ /* draw data section */
for(i = 0; i < strlen(source); i++) for(i = 0; i < ustrlen(source); i++)
{ {
lookup(NESET, MSITable, source[i], dest); lookup(NESET, MSITable, source[i], dest);
} }
/* caluculate check digit */ /* caluculate check digit */
wright = 0; wright = 0;
if((strlen(source)%2) == 0) if((ustrlen(source)%2) == 0)
{ {
for(i = 1; i < strlen(source); i+=2) for(i = 1; i < ustrlen(source); i+=2)
{ {
un[wright] = source[i]; un[wright] = source[i];
wright ++; wright ++;
@ -176,7 +176,7 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[])
} }
else else
{ {
for(i = 0; i < strlen(source); i+=2) for(i = 0; i < ustrlen(source); i+=2)
{ {
un[wright] = source[i]; un[wright] = source[i];
wright ++; wright ++;
@ -196,16 +196,16 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[])
} }
if((strlen(source)%2) == 0) if((ustrlen(source)%2) == 0)
{ {
for(i = 0; i < strlen(source); i+=2) for(i = 0; i < ustrlen(source); i+=2)
{ {
pedwar += ctoi(source[i]); pedwar += ctoi(source[i]);
} }
} }
else else
{ {
for(i = 1; i < strlen(source); i+=2) for(i = 1; i < ustrlen(source); i+=2)
{ {
pedwar += ctoi(source[i]); pedwar += ctoi(source[i]);
} }
@ -223,7 +223,7 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[])
/* Stop character */ /* Stop character */
concat (dest, "121"); concat (dest, "121");
h = strlen(source); h = ustrlen(source);
source[h] = itoc(pump); source[h] = itoc(pump);
source[h + 1] = '\0'; source[h + 1] = '\0';
expand(symbol, dest); expand(symbol, dest);
@ -243,7 +243,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 55) { /* No Entry Stack Smashers! */ if(ustrlen(source) > 55) { /* No Entry Stack Smashers! */
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -257,16 +257,16 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[])
concat (dest, "21"); concat (dest, "21");
/* draw data section */ /* draw data section */
for(i = 0; i < strlen(source); i++) for(i = 0; i < ustrlen(source); i++)
{ {
lookup(NESET, MSITable, source[i], dest); lookup(NESET, MSITable, source[i], dest);
} }
/* calculate first check digit */ /* calculate first check digit */
wright = 0; wright = 0;
if((strlen(source)%2) == 0) if((ustrlen(source)%2) == 0)
{ {
for(i = 1; i < strlen(source); i+=2) for(i = 1; i < ustrlen(source); i+=2)
{ {
un[wright] = source[i]; un[wright] = source[i];
wright ++; wright ++;
@ -274,7 +274,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[])
} }
else else
{ {
for(i = 0; i < strlen(source); i+=2) for(i = 0; i < ustrlen(source); i+=2)
{ {
un[wright] = source[i]; un[wright] = source[i];
wright ++; wright ++;
@ -294,16 +294,16 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[])
} }
if((strlen(source)%2) == 0) if((ustrlen(source)%2) == 0)
{ {
for(i = 0; i < strlen(source); i+=2) for(i = 0; i < ustrlen(source); i+=2)
{ {
pedwar += ctoi(source[i]); pedwar += ctoi(source[i]);
} }
} }
else else
{ {
for(i = 1; i < strlen(source); i+=2) for(i = 1; i < ustrlen(source); i+=2)
{ {
pedwar += ctoi(source[i]); pedwar += ctoi(source[i]);
} }
@ -317,9 +317,9 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[])
/* calculate second check digit */ /* calculate second check digit */
wright = 0; wright = 0;
if((strlen(source)%2) == 0) if((ustrlen(source)%2) == 0)
{ {
for(i = 0; i < strlen(source); i+=2) for(i = 0; i < ustrlen(source); i+=2)
{ {
un[wright] = source[i]; un[wright] = source[i];
wright ++; wright ++;
@ -327,7 +327,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[])
} }
else else
{ {
for(i = 1; i < strlen(source); i+=2) for(i = 1; i < ustrlen(source); i+=2)
{ {
un[wright] = source[i]; un[wright] = source[i];
wright ++; wright ++;
@ -349,16 +349,16 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[])
} }
if((strlen(source)%2) == 0) if((ustrlen(source)%2) == 0)
{ {
for(i = 1; i < strlen(source); i+=2) for(i = 1; i < ustrlen(source); i+=2)
{ {
pedwar += ctoi(source[i]); pedwar += ctoi(source[i]);
} }
} }
else else
{ {
for(i = 0; i < strlen(source); i+=2) for(i = 0; i < ustrlen(source); i+=2)
{ {
pedwar += ctoi(source[i]); pedwar += ctoi(source[i]);
} }
@ -377,7 +377,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[])
/* Stop character */ /* Stop character */
concat (dest, "121"); concat (dest, "121");
h = strlen(source); h = ustrlen(source);
source[h] = itoc(pump); source[h] = itoc(pump);
source[h + 1] = itoc(chwech); source[h + 1] = itoc(chwech);
source[h + 2] = '\0'; source[h + 2] = '\0';
@ -400,7 +400,7 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 55) { if(ustrlen(source) > 55) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -414,7 +414,7 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[])
concat (dest, "21"); concat (dest, "21");
/* draw data section */ /* draw data section */
for(i = 0; i < strlen(source); i++) for(i = 0; i < ustrlen(source); i++)
{ {
lookup(NESET, MSITable, source[i], dest); lookup(NESET, MSITable, source[i], dest);
} }
@ -422,7 +422,7 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[])
/* calculate check digit */ /* calculate check digit */
x = 0; x = 0;
weight = 2; weight = 2;
for(i = (strlen(source) - 1); i >= 0; i--) { for(i = (ustrlen(source) - 1); i >= 0; i--) {
x += weight * ctoi(source[i]); x += weight * ctoi(source[i]);
weight++; weight++;
if(weight > 7) { if(weight > 7) {
@ -438,7 +438,7 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[])
lookup(NESET, MSITable, itoc(check), dest); lookup(NESET, MSITable, itoc(check), dest);
} }
h = strlen(source); h = ustrlen(source);
if(check == 10) { if(check == 10) {
source[h] = '1'; source[h] = '1';
source[h + 1] = '0'; source[h + 1] = '0';
@ -470,7 +470,7 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 55) { if(ustrlen(source) > 55) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -484,16 +484,16 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[])
concat (dest, "21"); concat (dest, "21");
/* draw data section */ /* draw data section */
for(i = 0; i < strlen(source); i++) for(i = 0; i < ustrlen(source); i++)
{ {
lookup(NESET, MSITable, source[i], dest); lookup(NESET, MSITable, source[i], dest);
} }
/* calculate first (mod 11) digit */ /* calculate first (mod 11) digit */
wright = strlen(source); wright = ustrlen(source);
x = 0; x = 0;
weight = 2; weight = 2;
for(i = (strlen(source) - 1); i >= 0; i--) { for(i = (ustrlen(source) - 1); i >= 0; i--) {
x += weight * ctoi(source[i]); x += weight * ctoi(source[i]);
weight++; weight++;
if(weight > 7) { if(weight > 7) {
@ -516,9 +516,9 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[])
/* caluculate second (mod 10) check digit */ /* caluculate second (mod 10) check digit */
wright = 0; wright = 0;
if((strlen(source)%2) == 0) if((ustrlen(source)%2) == 0)
{ {
for(i = 1; i < strlen(source); i+=2) for(i = 1; i < ustrlen(source); i+=2)
{ {
un[wright] = source[i]; un[wright] = source[i];
wright ++; wright ++;
@ -526,7 +526,7 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[])
} }
else else
{ {
for(i = 0; i < strlen(source); i+=2) for(i = 0; i < ustrlen(source); i+=2)
{ {
un[wright] = source[i]; un[wright] = source[i];
wright ++; wright ++;
@ -546,16 +546,16 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[])
} }
if((strlen(source)%2) == 0) if((ustrlen(source)%2) == 0)
{ {
for(i = 0; i < strlen(source); i+=2) for(i = 0; i < ustrlen(source); i+=2)
{ {
pedwar += ctoi(source[i]); pedwar += ctoi(source[i]);
} }
} }
else else
{ {
for(i = 1; i < strlen(source); i+=2) for(i = 1; i < ustrlen(source); i+=2)
{ {
pedwar += ctoi(source[i]); pedwar += ctoi(source[i]);
} }
@ -573,7 +573,7 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[])
/* stop character */ /* stop character */
concat (dest, "121"); concat (dest, "121");
h = strlen(source); h = ustrlen(source);
source[h] = itoc(pump); source[h] = itoc(pump);
source[h + 1] = '\0'; source[h + 1] = '\0';

View File

@ -61,10 +61,9 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
png_structp png_ptr; png_structp png_ptr;
png_infop info_ptr; png_infop info_ptr;
graphic = &wpng_info; graphic = &wpng_info;
long j;
unsigned long rowbytes; unsigned long rowbytes;
unsigned char *image_data; unsigned char *image_data;
int i, k, offset, row, column, errno; int i, row, column, errno;
int fgred, fggrn, fgblu, bgred, bggrn, bgblu; int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
switch(rotate_angle) { switch(rotate_angle) {
@ -356,7 +355,7 @@ void draw_string(char *pixbuf, unsigned char input_string[], int xposn, int ypos
/* Plot a string into the pixel buffer */ /* Plot a string into the pixel buffer */
int i, string_length, string_left_hand; int i, string_length, string_left_hand;
string_length = strlen(input_string); string_length = ustrlen(input_string);
string_left_hand = xposn - ((7 * string_length) / 2); string_left_hand = xposn - ((7 * string_length) / 2);
for(i = 0; i < string_length; i++) { for(i = 0; i < string_length; i++) {

View File

@ -56,7 +56,7 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[])
error_number = 0; error_number = 0;
if(strlen(source) > 90) { if(ustrlen(source) > 90) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -70,7 +70,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 < strlen(source); i++) for (i=0; i < ustrlen(source); i++)
{ {
lookup(NESET, PNTable, source[i], dest); lookup(NESET, PNTable, source[i], dest);
sum += ctoi(source[i]); sum += ctoi(source[i]);
@ -82,7 +82,7 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* stop character */ /* stop character */
concat (dest, "L"); concat (dest, "L");
h = strlen(source); h = ustrlen(source);
source[h] = itoc(check_digit); source[h] = itoc(check_digit);
source[h + 1] = '\0'; source[h + 1] = '\0';
strcpy(symbol->text, ""); strcpy(symbol->text, "");
@ -132,7 +132,7 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[])
error_number = 0; error_number = 0;
if(strlen(source) > 90) { if(ustrlen(source) > 90) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -146,7 +146,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 < strlen(source); i++) for (i=0; i < ustrlen(source); i++)
{ {
lookup(NESET, PLTable, source[i], dest); lookup(NESET, PLTable, source[i], dest);
sum += ctoi(source[i]); sum += ctoi(source[i]);
@ -158,7 +158,7 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* stop character */ /* stop character */
concat (dest, "L"); concat (dest, "L");
h = strlen(source); h = ustrlen(source);
source[h] = itoc(check_digit); source[h] = itoc(check_digit);
source[h + 1] = '\0'; source[h + 1] = '\0';
strcpy(symbol->text, ""); strcpy(symbol->text, "");
@ -211,7 +211,7 @@ int fim(struct zint_symbol *symbol, unsigned char source[])
strcpy(dest, ""); strcpy(dest, "");
to_upper(source); to_upper(source);
if(strlen(source) > 1) { if(ustrlen(source) > 1) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -274,7 +274,7 @@ int royal_plot(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
to_upper(source); to_upper(source);
if(strlen(source) > 120) { if(ustrlen(source) > 120) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -306,7 +306,7 @@ int royal_plot(struct zint_symbol *symbol, unsigned char source[])
symbol->rows = 3; symbol->rows = 3;
symbol->width = writer - 1; symbol->width = writer - 1;
h = strlen(source); h = ustrlen(source);
source[h] = check; source[h] = check;
source[h + 1] = '\0'; source[h + 1] = '\0';
strcpy(symbol->text, ""); strcpy(symbol->text, "");
@ -328,7 +328,7 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
to_upper(source); to_upper(source);
if(strlen(source) != 11) { if(ustrlen(source) != 11) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -337,7 +337,7 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[])
strcpy(symbol->errtxt, "error: invalid characters in data"); strcpy(symbol->errtxt, "error: invalid characters in data");
return error_number; return error_number;
} }
for (i = 0; i < strlen(source); i++) { for (i = 0; i < ustrlen(source); i++) {
lookup(KRSET, RoyalTable, source[i], height_pattern); lookup(KRSET, RoyalTable, source[i], height_pattern);
} }
@ -377,7 +377,7 @@ int daft_code(struct zint_symbol *symbol, unsigned char source[])
int writer, i; int writer, i;
strcpy(height_pattern, ""); strcpy(height_pattern, "");
input_length = strlen(source); input_length = ustrlen(source);
strcpy(local_source, source); strcpy(local_source, source);
if(input_length > 50) { if(input_length > 50) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
@ -427,7 +427,7 @@ int flattermarken(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
if(strlen(source) > 90) { if(ustrlen(source) > 90) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -437,7 +437,7 @@ int flattermarken(struct zint_symbol *symbol, unsigned char source[])
return error_number; return error_number;
} }
for(loop = 0; loop < strlen(source); loop++) { for(loop = 0; loop < ustrlen(source); loop++) {
lookup(NESET, FlatTable, source[loop], dest); lookup(NESET, FlatTable, source[loop], dest);
} }

View File

@ -27,7 +27,6 @@
#include <qrencode.h> #include <qrencode.h>
static int kanji = 0; static int kanji = 0;
static QRecLevel level = QR_ECLEVEL_L;
QRcode *encode(int security, int size, const unsigned char *intext) QRcode *encode(int security, int size, const unsigned char *intext)
{ {

View File

@ -94,7 +94,6 @@ void getRSSwidths(int val, int n, int elements, int maxWidth, int noNarrow)
{ {
int bar; int bar;
int elmWidth; int elmWidth;
int i;
int mxwElement; int mxwElement;
int subVal, lessVal; int subVal, lessVal;
int narrowMask = 0; int narrowMask = 0;
@ -141,7 +140,7 @@ void getRSSwidths(int val, int n, int elements, int maxWidth, int noNarrow)
int rss14(struct zint_symbol *symbol, unsigned char source[]) int rss14(struct zint_symbol *symbol, unsigned char source[])
{ /* GS1 DataBar-14 */ { /* GS1 DataBar-14 */
int error_number = 0, i, j, read, 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];
int data_character[4], data_group[4], v_odd[4], v_even[4]; int data_character[4], data_group[4], v_odd[4], v_even[4];
int data_widths[8][4], checksum, c_left, c_right, total_widths[46], writer; int data_widths[8][4], checksum, c_left, c_right, total_widths[46], writer;
@ -150,7 +149,7 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
separator_row = 0; separator_row = 0;
if(strlen(source) > 13) { if(ustrlen(source) > 13) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -427,8 +426,8 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
for(i = 0; i < 14; i++) { for(i = 0; i < 14; i++) {
hrt[i] = '0'; hrt[i] = '0';
} }
for(i = 0; i < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
hrt[12 - i] = source[strlen(source) - i - 1]; hrt[12 - i] = source[ustrlen(source) - i - 1];
} }
hrt[14] = '\0'; hrt[14] = '\0';
@ -647,7 +646,7 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[])
separator_row = 0; separator_row = 0;
if(strlen(source) > 13) { if(ustrlen(source) > 13) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -876,8 +875,8 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[])
for(i = 0; i < 14; i++) { for(i = 0; i < 14; i++) {
hrt[i] = '0'; hrt[i] = '0';
} }
for(i = 0; i < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
hrt[12 - i] = source[strlen(source) - i - 1]; hrt[12 - i] = source[ustrlen(source) - i - 1];
} }
for (i = 0; i < 13; i++) for (i = 0; i < 13; i++)
@ -1020,7 +1019,7 @@ int general_rules(char field[], char type[])
int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char binary_string[]) int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char binary_string[])
{ /* Handles all data encodation from section 7.2.5 of ISO/IEC 24724 */ { /* Handles all data encodation from section 7.2.5 of ISO/IEC 24724 */
int encoding_method, i, mask, j, read_posn, latch; int encoding_method, i, mask, j, read_posn, latch;
char general_field[strlen(source)], general_field_type[strlen(source)]; char general_field[ustrlen(source)], general_field_type[ustrlen(source)];
int remainder, d1, d2, value; int remainder, d1, d2, value;
char padstring[14]; char padstring[14];
@ -1028,7 +1027,7 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
/* Decide whether a compressed data field is required and if so what /* Decide whether a compressed data field is required and if so what
method to use - method 2 = no compressed data field */ method to use - method 2 = no compressed data field */
if((strlen(source) >= 16) && ((source[0] == '0') && (source[1] == '1'))) { if((ustrlen(source) >= 16) && ((source[0] == '0') && (source[1] == '1'))) {
/* (01) and other AIs */ /* (01) and other AIs */
encoding_method = 1; encoding_method = 1;
} else { } else {
@ -1036,10 +1035,10 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
encoding_method = 2; encoding_method = 2;
} }
if(((strlen(source) >= 20) && (encoding_method == 1)) && ((source[2] == '9') && (source[16] == '3'))) { if(((ustrlen(source) >= 20) && (encoding_method == 1)) && ((source[2] == '9') && (source[16] == '3'))) {
/* Possibly encoding method > 2 */ /* Possibly encoding method > 2 */
if((strlen(source) >= 26) && (source[17] == '1')) { if((ustrlen(source) >= 26) && (source[17] == '1')) {
/* Methods 3, 7, 9, 11 and 13 */ /* Methods 3, 7, 9, 11 and 13 */
if(source[18] == '0') { if(source[18] == '0') {
@ -1057,14 +1056,14 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
encoding_method = 7; encoding_method = 7;
if((source[19] == '3') && (strlen(source) == 26)) { if((source[19] == '3') && (ustrlen(source) == 26)) {
/* (01) and (3103) */ /* (01) and (3103) */
weight = atof(weight_str) / 1000.0; weight = atof(weight_str) / 1000.0;
if(weight <= 32.767) { encoding_method = 3; } if(weight <= 32.767) { encoding_method = 3; }
} }
if(strlen(source) == 34){ if(ustrlen(source) == 34){
if((source[26] == '1') && (source[27] == '1')) { if((source[26] == '1') && (source[27] == '1')) {
/* (01), (310x) and (11) - metric weight and production date */ /* (01), (310x) and (11) - metric weight and production date */
encoding_method = 7; encoding_method = 7;
@ -1089,7 +1088,7 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
} }
} }
if((strlen(source) >= 26) && (source[17] == '2')) { if((ustrlen(source) >= 26) && (source[17] == '2')) {
/* Methods 4, 8, 10, 12 and 14 */ /* Methods 4, 8, 10, 12 and 14 */
if(source[18] == '0') { if(source[18] == '0') {
@ -1106,7 +1105,7 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
encoding_method = 8; encoding_method = 8;
if(((source[19] == '2') || (source[19] == '3')) && (strlen(source) == 26)) { if(((source[19] == '2') || (source[19] == '3')) && (ustrlen(source) == 26)) {
/* (01) and (3202)/(3203) */ /* (01) and (3202)/(3203) */
if(source[19] == '3') { if(source[19] == '3') {
@ -1123,7 +1122,7 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
} }
if(strlen(source) == 34){ if(ustrlen(source) == 34){
if((source[26] == '1') && (source[27] == '1')) { if((source[26] == '1') && (source[27] == '1')) {
/* (01), (320x) and (11) - English weight and production date */ /* (01), (320x) and (11) - English weight and production date */
encoding_method = 8; encoding_method = 8;
@ -1165,18 +1164,18 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
switch(encoding_method) { /* Encoding method - Table 10 */ switch(encoding_method) { /* Encoding method - Table 10 */
case 1: concat(binary_string, "1XX"); read_posn = 16; break; case 1: concat(binary_string, "1XX"); read_posn = 16; break;
case 2: concat(binary_string, "00XX"); read_posn = 0; break; case 2: concat(binary_string, "00XX"); read_posn = 0; break;
case 3: concat(binary_string, "0100"); read_posn = strlen(source); break; case 3: concat(binary_string, "0100"); read_posn = ustrlen(source); break;
case 4: concat(binary_string, "0101"); read_posn = strlen(source); break; case 4: concat(binary_string, "0101"); read_posn = ustrlen(source); break;
case 5: concat(binary_string, "01100XX"); read_posn = 20; break; case 5: concat(binary_string, "01100XX"); read_posn = 20; break;
case 6: concat(binary_string, "01101XX"); read_posn = 23; break; case 6: concat(binary_string, "01101XX"); read_posn = 23; break;
case 7: concat(binary_string, "0111000"); read_posn = strlen(source); break; case 7: concat(binary_string, "0111000"); read_posn = ustrlen(source); break;
case 8: concat(binary_string, "0111001"); read_posn = strlen(source); break; case 8: concat(binary_string, "0111001"); read_posn = ustrlen(source); break;
case 9: concat(binary_string, "0111010"); read_posn = strlen(source); break; case 9: concat(binary_string, "0111010"); read_posn = ustrlen(source); break;
case 10: concat(binary_string, "0111011"); read_posn = strlen(source); break; case 10: concat(binary_string, "0111011"); read_posn = ustrlen(source); break;
case 11: concat(binary_string, "0111100"); read_posn = strlen(source); break; case 11: concat(binary_string, "0111100"); read_posn = ustrlen(source); break;
case 12: concat(binary_string, "0111101"); read_posn = strlen(source); break; case 12: concat(binary_string, "0111101"); read_posn = ustrlen(source); break;
case 13: concat(binary_string, "0111110"); read_posn = strlen(source); break; case 13: concat(binary_string, "0111110"); read_posn = ustrlen(source); break;
case 14: concat(binary_string, "0111111"); read_posn = strlen(source); break; case 14: concat(binary_string, "0111111"); read_posn = ustrlen(source); break;
} }
/* Variable length symbol bit field is just given a place holder (XX) /* Variable length symbol bit field is just given a place holder (XX)
@ -1373,7 +1372,7 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
mask = mask >> 1; mask = mask >> 1;
} }
if(strlen(source) == 34) { if(ustrlen(source) == 34) {
/* Date information is included */ /* Date information is included */
date_str[0] = source[28]; date_str[0] = source[28];
date_str[1] = source[29]; date_str[1] = source[29];
@ -1490,7 +1489,7 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
rest of the data (if any) goes into a general-purpose data compaction field */ rest of the data (if any) goes into a general-purpose data compaction field */
j = 0; j = 0;
for(i = read_posn; i < strlen(source); i++) { for(i = read_posn; i < ustrlen(source); i++) {
general_field[j] = source[i]; general_field[j] = source[i];
j++; j++;
} }
@ -1828,7 +1827,7 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
int rssexpanded(struct zint_symbol *symbol, unsigned char source[]) int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
{ /* 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 binary_string[7 * strlen(source)], substring[21][14], latch; char binary_string[7 * ustrlen(source)], substring[21][14], latch;
int char_widths[21][8], checksum, check_widths[8], c_group; int char_widths[21][8], checksum, check_widths[8], c_group;
int check_char, c_odd, c_even, elements[235], pattern_width, reader, writer; int check_char, c_odd, c_even, elements[235], pattern_width, reader, writer;
int row, elements_in_sub, special_case_row, left_to_right; int row, elements_in_sub, special_case_row, left_to_right;
@ -1843,7 +1842,7 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
return ERROR_INVALID_DATA; return ERROR_INVALID_DATA;
} }
for(i = 0; i < strlen(source) - 1; i++) { for(i = 0; i < ustrlen(source) - 1; i++) {
if((source[i] == '[') && (source[i + 1] == '[')) { if((source[i] == '[') && (source[i + 1] == '[')) {
/* Can't have nested brackets - Quit */ /* Can't have nested brackets - Quit */
strcpy(symbol->errtxt, "Nested AI detected (two or more open brackets)"); strcpy(symbol->errtxt, "Nested AI detected (two or more open brackets)");
@ -1851,7 +1850,7 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
} }
} }
for(i = 0; i < strlen(source) - 1; i++) { for(i = 0; i < ustrlen(source) - 1; i++) {
if((source[i] == ']') && (source[i + 1] == ']')) { if((source[i] == ']') && (source[i + 1] == ']')) {
/* Can't have nested brackets - Quit */ /* Can't have nested brackets - Quit */
strcpy(symbol->errtxt, "Nested AI detected (two or more close brackets)"); strcpy(symbol->errtxt, "Nested AI detected (two or more close brackets)");
@ -1878,7 +1877,7 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
j = 0; j = 0;
last_ai = 0; last_ai = 0;
ai_latch = 1; ai_latch = 1;
for(i = 0; i < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
if((source[i] != '[') && (source[i] != ']')) { if((source[i] != '[') && (source[i] != ']')) {
reduced[j] = source[i]; reduced[j] = source[i];
j++; j++;
@ -1963,6 +1962,9 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
char_widths[i][7] = widths[3]; char_widths[i][7] = widths[3];
} }
/* 7.2.6 Check character */
/* The checksum value is equal to the mod 211 residue of the weighted sum of the widths of the
elements in the data characters. */
checksum = 0; checksum = 0;
for(i = 0; i < data_chars; i++) { for(i = 0; i < data_chars; i++) {
row = weight_rows[(((data_chars - 3) / 2) * 21) + i]; row = weight_rows[(((data_chars - 3) / 2) * 21) + i];
@ -1972,7 +1974,6 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
} }
} }
checksum;
check_char = (211 * ((data_chars + 1) - 4)) + (checksum % 211); check_char = (211 * ((data_chars + 1) - 4)) + (checksum % 211);
if(check_char <= 347) { c_group = 1; } if(check_char <= 347) { c_group = 1; }
@ -2072,7 +2073,7 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[])
} }
/* Add human readable text */ /* Add human readable text */
for(i = 0; i <= strlen(source); i++) { for(i = 0; i <= ustrlen(source); i++) {
if((source[i] != '[') && (source[i] != ']')) { if((source[i] != '[') && (source[i] != ']')) {
symbol->text[i] = source[i]; symbol->text[i] = source[i];
} else { } else {

View File

@ -61,12 +61,12 @@ int telepen(struct zint_symbol *symbol, unsigned char source[])
count = 0; count = 0;
if(strlen(source) > 30) { if(ustrlen(source) > 30) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
for(i = 0; i < strlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
if(source[i] > 127) { if(source[i] > 127) {
/* Cannot encode extended ASCII */ /* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "error: invalid characters in input data"); strcpy(symbol->errtxt, "error: invalid characters in input data");
@ -77,7 +77,7 @@ int telepen(struct zint_symbol *symbol, unsigned char source[])
/* Start character */ /* Start character */
concat(dest, TeleTable['_']); concat(dest, TeleTable['_']);
for (i=0; i < strlen(source); i++) for (i=0; i < ustrlen(source); i++)
{ {
ascii_value = source[i]; ascii_value = source[i];
concat(dest, TeleTable[ascii_value]); concat(dest, TeleTable[ascii_value]);
@ -105,7 +105,7 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[])
error_number = 0; error_number = 0;
strcpy(dest, ""); strcpy(dest, "");
strcpy(local_source, source); strcpy(local_source, source);
input_length = strlen(source); input_length = ustrlen(source);
count = 0; count = 0;

View File

@ -49,7 +49,7 @@ char upc_check(unsigned char source[])
count = 0; count = 0;
for (i = 0; i < strlen(source); i++) for (i = 0; i < ustrlen(source); i++)
{ {
count += ctoi(source[i]); count += ctoi(source[i]);
@ -68,12 +68,12 @@ void upca_draw(unsigned char source[], char dest[])
{ /* UPC A is usually used for 12 digit numbers, but this function takes a source of any length */ { /* UPC A is usually used for 12 digit numbers, but this function takes a source of any length */
unsigned int i, half_way; unsigned int i, half_way;
half_way = strlen(source) / 2; half_way = ustrlen(source) / 2;
/* start character */ /* start character */
concat (dest, "111"); concat (dest, "111");
for(i = 0; i <= strlen(source); i++) for(i = 0; i <= ustrlen(source); i++)
{ {
if (i == half_way) if (i == half_way)
{ {
@ -93,7 +93,7 @@ void upca(struct zint_symbol *symbol, unsigned char source[], char dest[])
{ /* Make a UPC A barcode when we haven't been given the check digit */ { /* Make a UPC A barcode when we haven't been given the check digit */
int length; int length;
length = strlen(source); length = ustrlen(source);
source[length] = upc_check(source); source[length] = upc_check(source);
source[length + 1] = '\0'; source[length + 1] = '\0';
upca_draw(source, dest); upca_draw(source, dest);
@ -107,7 +107,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
char hrt[8]; char hrt[8];
/* Two number systems can be used - system 0 and system 1 */ /* Two number systems can be used - system 0 and system 1 */
if(strlen(source) == 7) { if(ustrlen(source) == 7) {
switch(source[0]) { switch(source[0]) {
case '0': num_system = 0; break; case '0': num_system = 0; break;
case '1': num_system = 1; break; case '1': num_system = 1; break;
@ -195,7 +195,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* start character */ /* start character */
concat (dest, "111"); concat (dest, "111");
for(i = 0; i <= strlen(source); i++) { for(i = 0; i <= ustrlen(source); i++) {
switch(parity[i]) { switch(parity[i]) {
case 'A': lookup(NESET, EANsetA, source[i], dest); break; case 'A': lookup(NESET, EANsetA, source[i], dest); break;
case 'B': lookup(NESET, EANsetB, source[i], dest); break; case 'B': lookup(NESET, EANsetB, source[i], dest); break;
@ -226,7 +226,7 @@ void add_on(unsigned char source[], char dest[], int mode)
concat (dest, "112"); concat (dest, "112");
/* Determine EAN2 or EAN5 add-on */ /* Determine EAN2 or EAN5 add-on */
if(strlen(source) == 2) if(ustrlen(source) == 2)
{ {
code_type = EAN2; code_type = EAN2;
} }
@ -261,7 +261,7 @@ void add_on(unsigned char source[], char dest[], int mode)
strcpy(parity, EAN5Parity[parity_bit]); strcpy(parity, EAN5Parity[parity_bit]);
} }
for(i = 0; i < strlen(source); i++) for(i = 0; i < ustrlen(source); i++)
{ {
switch(parity[i]) { switch(parity[i]) {
case 'A': lookup(NESET, EANsetA, source[i], dest); break; case 'A': lookup(NESET, EANsetA, source[i], dest); break;
@ -269,7 +269,7 @@ void add_on(unsigned char source[], char dest[], int mode)
} }
/* Glyph separator */ /* Glyph separator */
if(i != (strlen(source) - 1)) if(i != (ustrlen(source) - 1))
{ {
concat (dest, "11"); concat (dest, "11");
} }
@ -286,7 +286,7 @@ char ean_check(unsigned char source[])
count = 0; count = 0;
h = strlen(source); h = ustrlen(source);
for (i = h - 1; i >= 0; i--) for (i = h - 1; i >= 0; i--)
{ {
count += ctoi(source[i]); count += ctoi(source[i]);
@ -309,7 +309,7 @@ void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[])
strcpy(parity, ""); strcpy(parity, "");
/* Add the appropriate check digit */ /* Add the appropriate check digit */
length = strlen(source); length = ustrlen(source);
source[length] = ean_check(source); source[length] = ean_check(source);
source[length + 1] = '\0'; source[length + 1] = '\0';
@ -322,7 +322,7 @@ void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* start character */ /* start character */
concat (dest, "111"); concat (dest, "111");
for(i = 1; i <= strlen(source); i++) for(i = 1; i <= ustrlen(source); i++)
{ {
if (i == half_way) if (i == half_way)
{ {
@ -352,7 +352,7 @@ void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* EAN-8 is basically the same as UPC-A but with fewer digits */ /* EAN-8 is basically the same as UPC-A but with fewer digits */
int length; int length;
length = strlen(source); length = ustrlen(source);
source[length] = upc_check(source); source[length] = upc_check(source);
source[length + 1] = '\0'; source[length + 1] = '\0';
upca_draw(source, dest); upca_draw(source, dest);
@ -366,7 +366,7 @@ char isbn13_check(unsigned char source[]) /* For ISBN(13) only */
sum = 0; sum = 0;
weight = 1; weight = 1;
for(i = 0; i < (strlen(source) - 1); i++) for(i = 0; i < (ustrlen(source) - 1); i++)
{ {
sum += ctoi(source[i]) * weight; sum += ctoi(source[i]) * weight;
if(weight == 1) weight = 3; else weight = 1; if(weight == 1) weight = 3; else weight = 1;
@ -383,7 +383,7 @@ char isbn_check(unsigned char source[]) /* For ISBN(10) and SBN only */
sum = 0; sum = 0;
weight = 1; weight = 1;
for(i = 0; i < (strlen(source) - 1); i++) for(i = 0; i < (ustrlen(source) - 1); i++)
{ {
sum += ctoi(source[i]) * weight; sum += ctoi(source[i]) * weight;
weight++; weight++;
@ -408,13 +408,13 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Mak
} }
/* Input must be 9, 10 or 13 characters */ /* Input must be 9, 10 or 13 characters */
if(((strlen(source) < 9) || (strlen(source) > 13)) || ((strlen(source) > 10) && (strlen(source) < 13))) if(((ustrlen(source) < 9) || (ustrlen(source) > 13)) || ((ustrlen(source) > 10) && (ustrlen(source) < 13)))
{ {
strcpy(symbol->errtxt, "error: input wrong length"); strcpy(symbol->errtxt, "error: input wrong length");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
if(strlen(source) == 13) /* Using 13 character ISBN */ if(ustrlen(source) == 13) /* Using 13 character ISBN */
{ {
if(!(((source[0] == '9') && (source[1] == '7')) && if(!(((source[0] == '9') && (source[1] == '7')) &&
((source[2] == '8') || (source[2] == '9')))) ((source[2] == '8') || (source[2] == '9'))))
@ -424,7 +424,7 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Mak
} }
check_digit = isbn13_check(source); check_digit = isbn13_check(source);
if (source[strlen(source) - 1] != check_digit) if (source[ustrlen(source) - 1] != check_digit)
{ {
strcpy(symbol->errtxt, "error: incorrect ISBN check"); strcpy(symbol->errtxt, "error: incorrect ISBN check");
return ERROR_INVALID_CHECK; return ERROR_INVALID_CHECK;
@ -434,10 +434,10 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Mak
ean13(symbol, source, dest); ean13(symbol, source, dest);
} }
if(strlen(source) == 10) /* Using 10 digit ISBN */ if(ustrlen(source) == 10) /* Using 10 digit ISBN */
{ {
check_digit = isbn_check(source); check_digit = isbn_check(source);
if(check_digit != source[strlen(source) - 1]) if(check_digit != source[ustrlen(source) - 1])
{ {
strcpy(symbol->errtxt, "error: incorrect ISBN check"); strcpy(symbol->errtxt, "error: incorrect ISBN check");
return ERROR_INVALID_CHECK; return ERROR_INVALID_CHECK;
@ -454,7 +454,7 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Mak
ean13(symbol, source, dest); ean13(symbol, source, dest);
} }
if(strlen(source) == 9) /* Using 9 digit SBN */ if(ustrlen(source) == 9) /* Using 9 digit SBN */
{ {
/* Add leading zero */ /* Add leading zero */
for(i = 10; i > 0; i--) for(i = 10; i > 0; i--)
@ -465,7 +465,7 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Mak
/* Verify check digit */ /* Verify check digit */
check_digit = isbn_check(source); check_digit = isbn_check(source);
if(check_digit != source[strlen(source) - 1]) if(check_digit != source[ustrlen(source) - 1])
{ {
strcpy(symbol->errtxt, "error: incorrect SBN check"); strcpy(symbol->errtxt, "error: incorrect SBN check");
return ERROR_INVALID_CHECK; return ERROR_INVALID_CHECK;
@ -503,7 +503,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
latch = FALSE; latch = FALSE;
writer = 0; writer = 0;
if(strlen(source) > 19) { if(ustrlen(source) > 19) {
strcpy(symbol->errtxt, "error: input too long"); strcpy(symbol->errtxt, "error: input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
@ -516,7 +516,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
} }
} }
for(reader = 0; reader <= strlen(source); reader++) for(reader = 0; reader <= ustrlen(source); reader++)
{ {
if(source[reader] == '+') { with_addon = TRUE; } if(source[reader] == '+') { with_addon = TRUE; }
} }
@ -540,7 +540,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
reader++; reader++;
writer++; writer++;
} }
} while (reader <= strlen(source)); } while (reader <= ustrlen(source));
} else { } else {
strcpy(first_part, source); strcpy(first_part, source);
} }

View File

@ -142,6 +142,7 @@ extern int ZBarcode_Delete(struct zint_symbol *symbol);
extern int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input); extern int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *input);
extern int ZBarcode_Print(struct zint_symbol *symbol); extern int ZBarcode_Print(struct zint_symbol *symbol);
extern int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input); extern int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input);
extern int ZBarcode_Encode_and_Print_Rotated(struct zint_symbol *symbol, unsigned char *input, int rotate_angle);
#ifdef __cplusplus #ifdef __cplusplus
} }