From 5b10d056c2f6c5595c6cd4b76715ebfc7f04e811 Mon Sep 17 00:00:00 2001 From: hooper114 Date: Tue, 30 Sep 2008 15:05:53 +0000 Subject: [PATCH] Reduced warnings about signedness --- backend/2of5.c | 30 +++--- backend/auspost.c | 14 +-- backend/aztec.c | 11 +- backend/blockf.c | 13 +-- backend/code.c | 34 +++--- backend/code128.c | 6 +- backend/code16k.c | 4 +- backend/common.c | 14 ++- backend/common.h | 1 + backend/composite.c | 253 ++++++++++++++++++++++---------------------- backend/dmatrix.c | 2 +- backend/imail.c | 16 ++- backend/large.c | 1 + backend/large.h | 12 --- backend/maxicode.c | 7 +- backend/medical.c | 16 +-- backend/pdf417.c | 11 +- backend/pdf417.h | 1 + backend/plessey.c | 92 ++++++++-------- backend/png.c | 5 +- backend/postal.c | 28 ++--- backend/qr.c | 1 - backend/rss.c | 71 +++++++------ backend/telepen.c | 8 +- backend/upcean.c | 50 ++++----- backend/zint.h | 1 + 26 files changed, 358 insertions(+), 344 deletions(-) diff --git a/backend/2of5.c b/backend/2of5.c index f917ccd5..94b9dee9 100644 --- a/backend/2of5.c +++ b/backend/2of5.c @@ -44,7 +44,7 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; strcpy(dest, ""); - if(strlen(source) > 80) { + if(ustrlen(source) > 80) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -57,7 +57,7 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[]) /* start character */ concat (dest, "411111"); - for(i = 0; i <= strlen(source); i++) { + for(i = 0; i <= ustrlen(source); i++) { 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; strcpy(dest, ""); - if(strlen(source) > 45) { + if(ustrlen(source) > 45) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -91,7 +91,7 @@ int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[]) /* start character */ concat (dest, "313111"); - for(i = 0; i <= strlen(source); i++) { + for(i = 0; i <= ustrlen(source); i++) { 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; strcpy(dest, ""); - if(strlen(source) > 45) { + if(ustrlen(source) > 45) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -124,7 +124,7 @@ int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[]) /* start */ concat (dest, "1111"); - for(i = 0; i < strlen(source); i++) { + for(i = 0; i < ustrlen(source); i++) { 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; strcpy(dest, ""); - if(strlen(source) > 80) { + if(ustrlen(source) > 80) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -158,7 +158,7 @@ int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[]) /* start character */ concat (dest, "1111"); - for(i = 0; i <= strlen(source); i++) { + for(i = 0; i <= ustrlen(source); i++) { 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; strcpy(dest, ""); - if(strlen(source) > 90) { + if(ustrlen(source) > 90) { strcpy(symbol->errtxt, "error: input 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: 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 */ unsigned int length; char temp[100]; - length = strlen(source); + length = ustrlen(source); strcpy(temp, source); source[0] = '0'; @@ -211,7 +211,7 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[]) /* start character */ 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 */ strcpy(bars, ""); @@ -247,7 +247,7 @@ int itf14(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; count = 0; - h = strlen(source); + h = ustrlen(source); if(h != 13) { strcpy(symbol->errtxt, "error: input wrong length"); @@ -287,7 +287,7 @@ int dpleit(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; count = 0; - h = strlen(source); + h = ustrlen(source); if(h != 13) { strcpy(symbol->errtxt, "error: input wrong length"); return ERROR_TOO_LONG; @@ -322,7 +322,7 @@ int dpident(struct zint_symbol *symbol, unsigned char source[]) unsigned int h, count, check_digit; count = 0; - h = strlen(source); + h = ustrlen(source); if(h != 11) { strcpy(symbol->errtxt, "erro: input wrong length"); return ERROR_TOO_LONG; diff --git a/backend/auspost.c b/backend/auspost.c index 8bded24f..f820dbf6 100644 --- a/backend/auspost.c +++ b/backend/auspost.c @@ -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 */ if(symbol->symbology == BARCODE_AUSPOST) { /* Format control code (FCC) */ - switch(strlen(source)) + switch(ustrlen(source)) { case 8: strcpy(fcc, "11"); break; case 13: strcpy(fcc, "59"); break; @@ -134,7 +134,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[]) return errno; } } else { - if(strlen(source) != 8) { + if(ustrlen(source) != 8) { strcpy(symbol->errtxt, "error: auspost input is wrong length"); return ERROR_TOO_LONG; } @@ -181,15 +181,15 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[]) } /* Customer Information */ - if(strlen(source) > 8) + if(ustrlen(source) > 8) { - if((strlen(source) == 13) || (strlen(source) == 18)) { - for(reader = 8; reader < strlen(source); reader++) { + if((ustrlen(source) == 13) || (ustrlen(source) == 18)) { + for(reader = 8; reader < ustrlen(source); reader++) { lookup(GDSET, AusCTable, source[reader], data_pattern); } } - if((strlen(source) == 16) || (strlen(source) == 23)) { - for(reader = 8; reader < strlen(source); reader++) { + if((ustrlen(source) == 16) || (ustrlen(source) == 23)) { + for(reader = 8; reader < ustrlen(source); reader++) { lookup(NESET, AusNTable, source[reader], data_pattern); } } diff --git a/backend/aztec.c b/backend/aztec.c index 26a8e584..2763c97e 100644 --- a/backend/aztec.c +++ b/backend/aztec.c @@ -48,14 +48,14 @@ void insert(char binary_string[], int posn, char newbit) int aztec_text_process(unsigned char source[], char binary_string[]) { /* Encode input data into a binary string */ - int map_posn, i, j, k, bytes; - int charmap[strlen(source)], typemap[strlen(source)], maplength; + int i, j, k, bytes; + int charmap[ustrlen(source)], typemap[ustrlen(source)], maplength; int curtable, newtable, lasttable, chartype; - int blockmap[2][strlen(source)], blocks; + int blockmap[2][ustrlen(source)], blocks; /* Lookup input string in encoding table */ - for(i = 0; i < strlen(source); i++) { + for(i = 0; i < ustrlen(source); i++) { if(source[i] > 127) { charmap[i] = source[i]; typemap[i] = BINARY; @@ -64,7 +64,7 @@ int aztec_text_process(unsigned char source[], char binary_string[]) typemap[i] = AztecCodeSet[source[i]]; } } - maplength = strlen(source); + maplength = ustrlen(source); /* Look for double character encoding possibilities */ i = 0; @@ -151,7 +151,6 @@ int aztec_text_process(unsigned char source[], char binary_string[]) } /* Combine blocks of the same type */ - blocks; i = 0; do{ if(blockmap[0][i] == blockmap[0][i + 1]) { diff --git a/backend/blockf.c b/backend/blockf.c index 238fe611..ef588f4d 100644 --- a/backend/blockf.c +++ b/backend/blockf.c @@ -66,7 +66,8 @@ int a3_convert(unsigned char source) { if(source < 32) { return source + 64; } if((source >= 32) && (source <= 127)) { return source - 32; } 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) { @@ -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 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; error_number = 0; exit_status = 0; current_row = 0; current_mode = MODEA; - input_length = strlen(source); + input_length = ustrlen(source); column_position = 0; input_position = 0; done = 0; @@ -146,7 +147,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm column_position++; c--; } - done == 1; + done = 1; } 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++; c--; } - done == 1; + done = 1; } 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; error_number = 0; - input_length = strlen(source); + input_length = ustrlen(source); final_mode = MODEA; if(input_length > 5450) { diff --git a/backend/code.c b/backend/code.c index 4cbe2296..ca8ce69f 100644 --- a/backend/code.c +++ b/backend/code.c @@ -86,7 +86,7 @@ int code_11(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; strcpy(dest, ""); - if(strlen(source) > 80) { + if(ustrlen(source) > 80) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -104,13 +104,13 @@ int code_11(struct zint_symbol *symbol, unsigned char source[]) concat (dest, "112211"); /* 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); weight[i] = ctoi(source[i]); } /* 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_weight++; @@ -122,10 +122,10 @@ int code_11(struct zint_symbol *symbol, unsigned char source[]) /* Draw C checksum */ lookup(NASET, C11Table, itoc(c_digit), dest); - weight[strlen(source)] = c_digit; + weight[ustrlen(source)] = c_digit; /* Calculate K checksum */ - for(h = strlen(source); h >= 0; h--) { + for(h = ustrlen(source); h >= 0; h--) { k_count += (k_weight * weight[h]); k_weight++; @@ -141,7 +141,7 @@ int code_11(struct zint_symbol *symbol, unsigned char source[]) /* Stop character */ concat (dest, "11221"); - h = strlen(source); + h = ustrlen(source); source[h] = itoc(c_digit); source[h + 1] = itoc(k_digit); source[h + 2] = '\0'; @@ -167,7 +167,7 @@ int c39(struct zint_symbol *symbol, unsigned char source[]) } to_upper(source); - if(strlen(source) > 45) { + if(ustrlen(source) > 45) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -180,7 +180,7 @@ int c39(struct zint_symbol *symbol, unsigned char source[]) /* Start character */ concat(dest, "1211212111"); - for(i = 0; i < strlen(source); i++) { + for(i = 0; i < ustrlen(source); i++) { lookup(TCSET, C39Table, source[i], dest); counter += posn(TCSET, source[i]); } @@ -212,7 +212,7 @@ int c39(struct zint_symbol *symbol, unsigned char source[]) check_digit = '_'; } - h = strlen(source); + h = ustrlen(source); source[h] = check_digit; source[h + 1] = '\0'; } @@ -250,7 +250,7 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; count = 0; - h = strlen(source); + h = ustrlen(source); if(h != 6) { strcpy(symbol->errtxt, "error: input wrong length"); return ERROR_TOO_LONG; @@ -295,7 +295,7 @@ int ec39(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; - if(strlen(source) > 45) { + if(ustrlen(source) > 45) { /* 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 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) { /* Cannot encode extended ASCII */ 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 */ - for(i = 0; i < strlen(source); i++) { + for(i = 0; i < ustrlen(source); i++) { ascii_value = source[i]; concat(buffer, EC39Ctrl[ascii_value]); } @@ -345,14 +345,14 @@ int c93(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; strcpy(dest, ""); - if(strlen(source) > 45) { + if(ustrlen(source) > 45) { /* This stops rediculously long input - the actual length of the barcode depends on the type of data */ strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } - for(i = 0; i < strlen(source); i++) { + for(i = 0; i < ustrlen(source); i++) { if(source[i] > 127) { /* Cannot encode extended ASCII */ 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"); /* Message Content */ - for(i = 0; i < strlen(source); i++) { + for(i = 0; i < ustrlen(source); i++) { ascii_value = source[i]; concat(buffer, C93Ctrl[ascii_value]); } @@ -429,7 +429,7 @@ int c93(struct zint_symbol *symbol, unsigned char source[]) /* Stop character */ concat(dest, "1111411"); - h = strlen(source); + h = ustrlen(source); source[h] = set_copy[c]; source[h + 1] = set_copy[k]; source[h + 2] = '\0'; diff --git a/backend/code128.c b/backend/code128.c index 821628d2..f247b55a 100644 --- a/backend/code128.c +++ b/backend/code128.c @@ -194,7 +194,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[]) errornum = 0; strcpy(dest, ""); - sourcelen = strlen(source); + sourcelen = ustrlen(source); j = 0; e_count = 0; @@ -582,7 +582,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[]) errornum = 0; strcpy(dest, ""); linkage_flag = 0; - sourcelen = strlen(source); + sourcelen = ustrlen(source); j = 0; e_count = 0; @@ -907,7 +907,7 @@ int ean_14(struct zint_symbol *symbol, unsigned char source[]) char ean128_equiv[20]; strcpy(ean128_equiv, ""); - input_length = strlen(source); + input_length = ustrlen(source); if(input_length != 13) { strcpy(symbol->errtxt, "error: input wrong length"); diff --git a/backend/code16k.c b/backend/code16k.c index c1905c81..840eec19 100644 --- a/backend/code16k.c +++ b/backend/code16k.c @@ -121,7 +121,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[]) int input_length; errornum = 0; - input_length = strlen(source); + input_length = ustrlen(source); if(input_length > 157) { strcpy(symbol->errtxt, "error: input too long"); @@ -391,7 +391,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[]) read += 2; break; } - } while (read < strlen(source)); + } while (read < ustrlen(source)); pads_needed = 5 - ((bar_characters + 2) % 5); diff --git a/backend/common.c b/backend/common.c index 681af707..534c1bca 100644 --- a/backend/common.c +++ b/backend/common.c @@ -25,6 +25,16 @@ #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[]) { /* Concatinates dest[] with the contents of source[], copying /0 as well */ 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[] */ unsigned int i; - for (i = 0; i < strlen(source); i++) { + for (i = 0; i < ustrlen(source); i++) { if ((source[i] >= 'a') && (source[i] <= 'z')) { 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 */ unsigned int i, j, latch; - for(i = 0; i < strlen(source); i++) { + for(i = 0; i < ustrlen(source); i++) { latch = FALSE; for(j = 0; j < strlen(test_string); j++) { if (source[i] == test_string[j]) { latch = TRUE; } } diff --git a/backend/common.h b/backend/common.h index 40621aa2..dfabbeba 100644 --- a/backend/common.h +++ b/backend/common.h @@ -28,6 +28,7 @@ #include "zint.h" +int ustrlen(unsigned char source[]); void concat(char dest[], char source[]); int ctoi(char source); char itoc(int source); diff --git a/backend/composite.c b/backend/composite.c index 6246e084..d620487c 100644 --- a/backend/composite.c +++ b/backend/composite.c @@ -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) { /* CC-A 2D component */ - int temp; int i, strpos, segment, bitlen, cwCnt, variant, rows; int k, offset, j, total, rsCodeWords[8]; 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 < 28; i++) { codeWords[i] = 0; } - bitlen = strlen(source); + bitlen = ustrlen(source); for(i = bitlen; i < 197; i++) { 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) { /* CC-B 2D component */ 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 k, j, longueur, mccorrection[50], offset; 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 LeftRAP, CentreRAP, RightRAP, Cluster, writer, flip, loop; - length = strlen(source) / 8; + length = ustrlen(source) / 8; for(i = 0; i < length; i++) { 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) { /* CC-C 2D component - byte compressed PDF417 */ 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 offset, longueur, loop, total, j, mccorrection[520]; int c1, c2, c3, dummy[35]; char codebarre[100], pattern[580]; - length = strlen(source) / 8; + length = ustrlen(source) / 8; for(i = 0; i < length; i++) { 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 */ int encoding_method, read_posn, d1, d2, value, alpha_pad; 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 general_field[strlen(source)], general_field_type[strlen(source)]; + char general_field[ustrlen(source)], general_field_type[ustrlen(source)]; int target_bitsize; encoding_method = 1; @@ -703,7 +702,7 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi ai90_mode = 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) */ encoding_method = 2; } @@ -772,8 +771,8 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi if (encoding_method == 3) { /* Encodation Method field of "11" - AI 90 */ - char ninety[strlen(source)], numeric_part[4]; - int alpha, alphanum, numeric, test1, test2, test3, next_ai_posn, test4; + char ninety[ustrlen(source)], numeric_part[4]; + int alpha, alphanum, numeric, test1, test2, test3, next_ai_posn; int numeric_value, table3_letter, mask; /* "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 { ninety[i] = source[i + 2]; i++; - } while ((source[i + 2] != '[') && ((i + 2) < strlen(source))); + } while ((source[i + 2] != '[') && ((i + 2) < ustrlen(source))); ninety[i] = '\0'; /* 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++; } - for(i = read_posn; i < strlen(source); i++) { + for(i = read_posn; i < ustrlen(source); i++) { general_field[j] = source[i]; j++; } @@ -1334,34 +1333,35 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi } } while (i + latch < strlen(general_field)); + binary_length = strlen(binary_string); if(cc_mode == 1) { /* CC-A 2D component - calculate remaining space */ switch(*(cc_width)) { case 2: - if(strlen(binary_string) > 167) { return ERROR_TOO_LONG; } - if(strlen(binary_string) <= 167) { target_bitsize = 167; } - if(strlen(binary_string) <= 138) { target_bitsize = 138; } - if(strlen(binary_string) <= 118) { target_bitsize = 118; } - if(strlen(binary_string) <= 108) { target_bitsize = 108; } - if(strlen(binary_string) <= 88) { target_bitsize = 88; } - if(strlen(binary_string) <= 78) { target_bitsize = 78; } - if(strlen(binary_string) <= 59) { target_bitsize = 59; } + if(binary_length > 167) { return ERROR_TOO_LONG; } + if(binary_length <= 167) { target_bitsize = 167; } + if(binary_length <= 138) { target_bitsize = 138; } + if(binary_length <= 118) { target_bitsize = 118; } + if(binary_length <= 108) { target_bitsize = 108; } + if(binary_length <= 88) { target_bitsize = 88; } + if(binary_length <= 78) { target_bitsize = 78; } + if(binary_length <= 59) { target_bitsize = 59; } break; case 3: - if(strlen(binary_string) > 167) { return ERROR_TOO_LONG; } - if(strlen(binary_string) <= 167) { target_bitsize = 167; } - if(strlen(binary_string) <= 138) { target_bitsize = 138; } - if(strlen(binary_string) <= 118) { target_bitsize = 118; } - if(strlen(binary_string) <= 98) { target_bitsize = 98; } - if(strlen(binary_string) <= 78) { target_bitsize = 78; } + if(binary_length > 167) { return ERROR_TOO_LONG; } + if(binary_length <= 167) { target_bitsize = 167; } + if(binary_length <= 138) { target_bitsize = 138; } + if(binary_length <= 118) { target_bitsize = 118; } + if(binary_length <= 98) { target_bitsize = 98; } + if(binary_length <= 78) { target_bitsize = 78; } break; case 4: - if(strlen(binary_string) > 197) { return ERROR_TOO_LONG; } - if(strlen(binary_string) <= 197) { target_bitsize = 197; } - if(strlen(binary_string) <= 167) { target_bitsize = 167; } - if(strlen(binary_string) <= 138) { target_bitsize = 138; } - if(strlen(binary_string) <= 108) { target_bitsize = 108; } - if(strlen(binary_string) <= 78) { target_bitsize = 78; } + if(binary_length > 197) { return ERROR_TOO_LONG; } + if(binary_length <= 197) { target_bitsize = 197; } + if(binary_length <= 167) { target_bitsize = 167; } + if(binary_length <= 138) { target_bitsize = 138; } + if(binary_length <= 108) { target_bitsize = 108; } + if(binary_length <= 78) { target_bitsize = 78; } 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 */ switch(*(cc_width)) { case 2: - if(strlen(binary_string) > 336) { return ERROR_TOO_LONG; } - if(strlen(binary_string) <= 336) { target_bitsize = 336; } - if(strlen(binary_string) <= 296) { target_bitsize = 296; } - if(strlen(binary_string) <= 256) { target_bitsize = 256; } - if(strlen(binary_string) <= 208) { target_bitsize = 208; } - if(strlen(binary_string) <= 160) { target_bitsize = 160; } - if(strlen(binary_string) <= 104) { target_bitsize = 104; } - if(strlen(binary_string) <= 56) { target_bitsize = 56; } + if(binary_length > 336) { return ERROR_TOO_LONG; } + if(binary_length <= 336) { target_bitsize = 336; } + if(binary_length <= 296) { target_bitsize = 296; } + if(binary_length <= 256) { target_bitsize = 256; } + if(binary_length <= 208) { target_bitsize = 208; } + if(binary_length <= 160) { target_bitsize = 160; } + if(binary_length <= 104) { target_bitsize = 104; } + if(binary_length <= 56) { target_bitsize = 56; } break; case 3: - if(strlen(binary_string) > 768) { return ERROR_TOO_LONG; } - if(strlen(binary_string) <= 768) { target_bitsize = 768; } - if(strlen(binary_string) <= 648) { target_bitsize = 648; } - if(strlen(binary_string) <= 536) { target_bitsize = 536; } - if(strlen(binary_string) <= 416) { target_bitsize = 416; } - if(strlen(binary_string) <= 304) { target_bitsize = 304; } - if(strlen(binary_string) <= 208) { target_bitsize = 208; } - if(strlen(binary_string) <= 152) { target_bitsize = 152; } - if(strlen(binary_string) <= 112) { target_bitsize = 112; } - if(strlen(binary_string) <= 72) { target_bitsize = 72; } - if(strlen(binary_string) <= 32) { target_bitsize = 32; } + if(binary_length > 768) { return ERROR_TOO_LONG; } + if(binary_length <= 768) { target_bitsize = 768; } + if(binary_length <= 648) { target_bitsize = 648; } + if(binary_length <= 536) { target_bitsize = 536; } + if(binary_length <= 416) { target_bitsize = 416; } + if(binary_length <= 304) { target_bitsize = 304; } + if(binary_length <= 208) { target_bitsize = 208; } + if(binary_length <= 152) { target_bitsize = 152; } + if(binary_length <= 112) { target_bitsize = 112; } + if(binary_length <= 72) { target_bitsize = 72; } + if(binary_length <= 32) { target_bitsize = 32; } break; case 4: - if(strlen(binary_string) > 1184) { return ERROR_TOO_LONG; } - if(strlen(binary_string) <= 1184) { target_bitsize = 1184; } - if(strlen(binary_string) <= 1016) { target_bitsize = 1016; } - if(strlen(binary_string) <= 840) { target_bitsize = 840; } - if(strlen(binary_string) <= 672) { target_bitsize = 672; } - if(strlen(binary_string) <= 496) { target_bitsize = 496; } - if(strlen(binary_string) <= 352) { target_bitsize = 352; } - if(strlen(binary_string) <= 264) { target_bitsize = 264; } - if(strlen(binary_string) <= 208) { target_bitsize = 208; } - if(strlen(binary_string) <= 152) { target_bitsize = 152; } - if(strlen(binary_string) <= 96) { target_bitsize = 96; } - if(strlen(binary_string) <= 56) { target_bitsize = 56; } + if(binary_length > 1184) { return ERROR_TOO_LONG; } + if(binary_length <= 1184) { target_bitsize = 1184; } + if(binary_length <= 1016) { target_bitsize = 1016; } + if(binary_length <= 840) { target_bitsize = 840; } + if(binary_length <= 672) { target_bitsize = 672; } + if(binary_length <= 496) { target_bitsize = 496; } + if(binary_length <= 352) { target_bitsize = 352; } + if(binary_length <= 264) { target_bitsize = 264; } + if(binary_length <= 208) { target_bitsize = 208; } + if(binary_length <= 152) { target_bitsize = 152; } + if(binary_length <= 96) { target_bitsize = 96; } + if(binary_length <= 56) { target_bitsize = 56; } 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 codewords_total, target_codewords, target_bytesize; - byte_length = strlen(binary_string) / 8; - if(strlen(binary_string) % 8 != 0) { byte_length++; } + byte_length = binary_length / 8; + if(binary_length % 8 != 0) { byte_length++; } codewords_used = (byte_length / 6) * 5; 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; } - remainder = strlen(binary_string) - target_bitsize; + remainder = binary_length - target_bitsize; if(latch == 1) { 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 size of the symbol may have changed when adding data in the above sequence */ + binary_length = strlen(binary_string); if(cc_mode == 1) { /* CC-A 2D component - calculate padding required */ switch(*(cc_width)) { case 2: - if(strlen(binary_string) > 167) { return ERROR_TOO_LONG; } - if(strlen(binary_string) <= 167) { target_bitsize = 167; } - if(strlen(binary_string) <= 138) { target_bitsize = 138; } - if(strlen(binary_string) <= 118) { target_bitsize = 118; } - if(strlen(binary_string) <= 108) { target_bitsize = 108; } - if(strlen(binary_string) <= 88) { target_bitsize = 88; } - if(strlen(binary_string) <= 78) { target_bitsize = 78; } - if(strlen(binary_string) <= 59) { target_bitsize = 59; } + if(binary_length > 167) { return ERROR_TOO_LONG; } + if(binary_length <= 167) { target_bitsize = 167; } + if(binary_length <= 138) { target_bitsize = 138; } + if(binary_length <= 118) { target_bitsize = 118; } + if(binary_length <= 108) { target_bitsize = 108; } + if(binary_length <= 88) { target_bitsize = 88; } + if(binary_length <= 78) { target_bitsize = 78; } + if(binary_length <= 59) { target_bitsize = 59; } break; case 3: - if(strlen(binary_string) > 167) { return ERROR_TOO_LONG; } - if(strlen(binary_string) <= 167) { target_bitsize = 167; } - if(strlen(binary_string) <= 138) { target_bitsize = 138; } - if(strlen(binary_string) <= 118) { target_bitsize = 118; } - if(strlen(binary_string) <= 98) { target_bitsize = 98; } - if(strlen(binary_string) <= 78) { target_bitsize = 78; } + if(binary_length > 167) { return ERROR_TOO_LONG; } + if(binary_length <= 167) { target_bitsize = 167; } + if(binary_length <= 138) { target_bitsize = 138; } + if(binary_length <= 118) { target_bitsize = 118; } + if(binary_length <= 98) { target_bitsize = 98; } + if(binary_length <= 78) { target_bitsize = 78; } break; case 4: - if(strlen(binary_string) > 197) { return ERROR_TOO_LONG; } - if(strlen(binary_string) <= 197) { target_bitsize = 197; } - if(strlen(binary_string) <= 167) { target_bitsize = 167; } - if(strlen(binary_string) <= 138) { target_bitsize = 138; } - if(strlen(binary_string) <= 108) { target_bitsize = 108; } - if(strlen(binary_string) <= 78) { target_bitsize = 78; } + if(binary_length > 197) { return ERROR_TOO_LONG; } + if(binary_length <= 197) { target_bitsize = 197; } + if(binary_length <= 167) { target_bitsize = 167; } + if(binary_length <= 138) { target_bitsize = 138; } + if(binary_length <= 108) { target_bitsize = 108; } + if(binary_length <= 78) { target_bitsize = 78; } break; } } @@ -1543,41 +1544,41 @@ int cc_binary_string(struct zint_symbol *symbol, unsigned char source[], char bi /* CC-B 2D component */ switch(*(cc_width)) { case 2: - if(strlen(binary_string) > 336) { return ERROR_TOO_LONG; } - if(strlen(binary_string) <= 336) { target_bitsize = 336; } - if(strlen(binary_string) <= 296) { target_bitsize = 296; } - if(strlen(binary_string) <= 256) { target_bitsize = 256; } - if(strlen(binary_string) <= 208) { target_bitsize = 208; } - if(strlen(binary_string) <= 160) { target_bitsize = 160; } - if(strlen(binary_string) <= 104) { target_bitsize = 104; } - if(strlen(binary_string) <= 56) { target_bitsize = 56; } + if(binary_length > 336) { return ERROR_TOO_LONG; } + if(binary_length <= 336) { target_bitsize = 336; } + if(binary_length <= 296) { target_bitsize = 296; } + if(binary_length <= 256) { target_bitsize = 256; } + if(binary_length <= 208) { target_bitsize = 208; } + if(binary_length <= 160) { target_bitsize = 160; } + if(binary_length <= 104) { target_bitsize = 104; } + if(binary_length <= 56) { target_bitsize = 56; } break; case 3: - if(strlen(binary_string) > 768) { return ERROR_TOO_LONG; } - if(strlen(binary_string) <= 768) { target_bitsize = 768; } - if(strlen(binary_string) <= 648) { target_bitsize = 648; } - if(strlen(binary_string) <= 536) { target_bitsize = 536; } - if(strlen(binary_string) <= 416) { target_bitsize = 416; } - if(strlen(binary_string) <= 304) { target_bitsize = 304; } - if(strlen(binary_string) <= 208) { target_bitsize = 208; } - if(strlen(binary_string) <= 152) { target_bitsize = 152; } - if(strlen(binary_string) <= 112) { target_bitsize = 112; } - if(strlen(binary_string) <= 72) { target_bitsize = 72; } - if(strlen(binary_string) <= 32) { target_bitsize = 32; } + if(binary_length > 768) { return ERROR_TOO_LONG; } + if(binary_length <= 768) { target_bitsize = 768; } + if(binary_length <= 648) { target_bitsize = 648; } + if(binary_length <= 536) { target_bitsize = 536; } + if(binary_length <= 416) { target_bitsize = 416; } + if(binary_length <= 304) { target_bitsize = 304; } + if(binary_length <= 208) { target_bitsize = 208; } + if(binary_length <= 152) { target_bitsize = 152; } + if(binary_length <= 112) { target_bitsize = 112; } + if(binary_length <= 72) { target_bitsize = 72; } + if(binary_length <= 32) { target_bitsize = 32; } break; case 4: - if(strlen(binary_string) > 1184) { return ERROR_TOO_LONG; } - if(strlen(binary_string) <= 1184) { target_bitsize = 1184; } - if(strlen(binary_string) <= 1016) { target_bitsize = 1016; } - if(strlen(binary_string) <= 840) { target_bitsize = 840; } - if(strlen(binary_string) <= 672) { target_bitsize = 672; } - if(strlen(binary_string) <= 496) { target_bitsize = 496; } - if(strlen(binary_string) <= 352) { target_bitsize = 352; } - if(strlen(binary_string) <= 264) { target_bitsize = 264; } - if(strlen(binary_string) <= 208) { target_bitsize = 208; } - if(strlen(binary_string) <= 152) { target_bitsize = 152; } - if(strlen(binary_string) <= 96) { target_bitsize = 96; } - if(strlen(binary_string) <= 56) { target_bitsize = 56; } + if(binary_length > 1184) { return ERROR_TOO_LONG; } + if(binary_length <= 1184) { target_bitsize = 1184; } + if(binary_length <= 1016) { target_bitsize = 1016; } + if(binary_length <= 840) { target_bitsize = 840; } + if(binary_length <= 672) { target_bitsize = 672; } + if(binary_length <= 496) { target_bitsize = 496; } + if(binary_length <= 352) { target_bitsize = 352; } + if(binary_length <= 264) { target_bitsize = 264; } + if(binary_length <= 208) { target_bitsize = 208; } + if(binary_length <= 152) { target_bitsize = 152; } + if(binary_length <= 96) { target_bitsize = 96; } + if(binary_length <= 56) { target_bitsize = 56; } 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 codewords_total, target_codewords, target_bytesize; - byte_length = strlen(binary_string) / 8; - if(strlen(binary_string) % 8 != 0) { byte_length++; } + byte_length = binary_length / 8; + if(binary_length % 8 != 0) { byte_length++; } codewords_used = (byte_length / 6) * 5; 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; } - if(strlen(binary_string) < target_bitsize) { + if(binary_length < target_bitsize) { /* Now add padding to binary string */ if (alpha_pad == 1) { 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 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; int top_shift, bottom_shift; @@ -1674,7 +1675,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[]) return ERROR_INVALID_OPTION; } - if(strlen(source) > 2990) { + if(ustrlen(source) > 2990) { strcpy(symbol->errtxt, "error: 2D component input data too long"); return ERROR_TOO_LONG; } @@ -1684,7 +1685,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[]) 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] == '[')) { /* Can't have nested brackets - Quit */ 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] == ']')) { /* Can't have nested brackets - Quit */ 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; last_ai = 0; ai_latch = 1; - for(i = 0; i < strlen(source); i++) { + for(i = 0; i < ustrlen(source); i++) { if((source[i] != '[') && (source[i] != ']')) { reduced[j] = source[i]; j++; diff --git a/backend/dmatrix.c b/backend/dmatrix.c index 3fff9977..a7440bae 100644 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -79,7 +79,7 @@ int dmatrix(struct zint_symbol *symbol, unsigned char source[]) barcode[barcodelen] = 0; // null terminate anyway fclose(f); } else */ - barcodelen = strlen(source); + barcodelen = ustrlen(source); if(barcodelen > 780) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; diff --git a/backend/imail.c b/backend/imail.c index 3047f1b3..fe4cc6e8 100644 --- a/backend/imail.c +++ b/backend/imail.c @@ -22,6 +22,18 @@ /* The function "USPS_MSB_Math_CRC11GenerateFrameCheckSequence" 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 #include #include @@ -300,7 +312,7 @@ int imail(struct zint_symbol *symbol, unsigned char source[]) errno = 0; - if(strlen(source) > 32) { + if(ustrlen(source) > 32) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -325,7 +337,7 @@ int imail(struct zint_symbol *symbol, unsigned char source[]) read = 0; j = 0; - for(i = 0; i < strlen(source); i++) { + for(i = 0; i < ustrlen(source); i++) { if(source[i] == '-') { tracker[read] = '\0'; j = 1; diff --git a/backend/large.c b/backend/large.c index ca16e10a..606f598d 100644 --- a/backend/large.c +++ b/backend/large.c @@ -19,6 +19,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "common.h" #include #include diff --git a/backend/large.h b/backend/large.h index b7b8846e..742db823 100644 --- a/backend/large.h +++ b/backend/large.h @@ -19,18 +19,6 @@ 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_add(short int accumulator[], short int input_buffer[]); void binary_subtract(short int accumulator[], short int input_buffer[]); diff --git a/backend/maxicode.c b/backend/maxicode.c index 7b446588..03f76458 100644 --- a/backend/maxicode.c +++ b/backend/maxicode.c @@ -25,6 +25,7 @@ #include "maxicode.h" #include "reedsol.h" #include +#include int maxi_codeword[144]; @@ -97,7 +98,7 @@ void maxi_do_secondary_chk_even(int ecclen ) 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 */ 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; - length = strlen(source); + length = ustrlen(source); if(length > 138) { 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 */ if(set[length - 1] == 2) { set[i] = 2; diff --git a/backend/medical.c b/backend/medical.c index f4455d58..5c8046ca 100644 --- a/backend/medical.c +++ b/backend/medical.c @@ -55,7 +55,7 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; strcpy(dest, ""); - if(strlen(source) > 6) { + if(ustrlen(source) > 6) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -158,7 +158,7 @@ int pharma_two(struct zint_symbol *symbol, unsigned char source[]) int error_number = 0; strcpy(height_pattern, ""); - if(strlen(source) > 8) { + if(ustrlen(source) > 8) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -201,7 +201,7 @@ int codabar(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; 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"); return ERROR_TOO_LONG; } @@ -220,14 +220,14 @@ int codabar(struct zint_symbol *symbol, unsigned char source[]) return 6; } - if(((source[strlen(source) - 1] != 'A') && (source[strlen(source) - 1] != 'B')) && - ((source[strlen(source) - 1] != 'C') && (source[strlen(source) - 1] != 'D'))) + if(((source[ustrlen(source) - 1] != 'A') && (source[ustrlen(source) - 1] != 'B')) && + ((source[ustrlen(source) - 1] != 'C') && (source[ustrlen(source) - 1] != 'D'))) { strcpy(symbol->errtxt, "error: invalid characters in data"); return 6; } - for(i = 0; i <= strlen(source); i++) + for(i = 0; i <= ustrlen(source); i++) { lookup(CASET, CodaTable, source[i], dest); } @@ -246,7 +246,7 @@ int code32(struct zint_symbol *symbol, unsigned char source[]) char tabella[34]; /* Validate the input */ - if(strlen(source) > 8) { + if(ustrlen(source) > 8) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -258,7 +258,7 @@ int code32(struct zint_symbol *symbol, unsigned char source[]) /* Add leading zeros as required */ strcpy(localstr, ""); - zeroes = 8 - strlen(source); + zeroes = 8 - ustrlen(source); for(i = 0; i < zeroes; i++) { concat(localstr, "0"); } diff --git a/backend/pdf417.c b/backend/pdf417.c index 6d25239d..69dab2e9 100644 --- a/backend/pdf417.c +++ b/backend/pdf417.c @@ -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) { - int i, j, k, l, loop, longueur; - double multiple, total; + int i, j, k, l, longueur; short int accum[112], x_reg[112], y_reg[112]; if(length == 1) { @@ -476,13 +475,13 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[]) /* 463 */ do { liste[1][indexliste] = mode; - while ((liste[1][indexliste] == mode) && (indexchaine < strlen(chaine))) { + while ((liste[1][indexliste] == mode) && (indexchaine < ustrlen(chaine))) { liste[0][indexliste]++; indexchaine++; mode = quelmode(chaine[indexchaine]); } indexliste++; - } while (indexchaine < strlen(chaine)); + } while (indexchaine < ustrlen(chaine)); /* 474 */ pdfsmooth(&indexliste); @@ -761,13 +760,13 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[]) /* 463 */ do { liste[1][indexliste] = mode; - while ((liste[1][indexliste] == mode) && (indexchaine < strlen(chaine))) { + while ((liste[1][indexliste] == mode) && (indexchaine < ustrlen(chaine))) { liste[0][indexliste]++; indexchaine++; mode = quelmode(chaine[indexchaine]); } indexliste++; - } while (indexchaine < strlen(chaine)); + } while (indexchaine < ustrlen(chaine)); /* 474 */ pdfsmooth(&indexliste); diff --git a/backend/pdf417.h b/backend/pdf417.h index 8d2b4df9..da62c2b5 100644 --- a/backend/pdf417.h +++ b/backend/pdf417.h @@ -451,3 +451,4 @@ static char *RAPC[53] = {"", "112231", "121231", "122131", "131131", "131221", " "112213", "112222", "112312", "112321", "111421", "111331", "111322", "111232", "111223", "111133", "111124", "111214", "112114", "121114", "121123", "121132", "112132", "112141" }; +void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start, int length, int block); \ No newline at end of file diff --git a/backend/plessey.c b/backend/plessey.c index 3fdc0cde..a352c22a 100644 --- a/backend/plessey.c +++ b/backend/plessey.c @@ -46,7 +46,7 @@ int plessey(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; strcpy(dest, ""); - if(strlen(source) > 65) { + if(ustrlen(source) > 65) { strcpy(symbol->errtxt, "error: input 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"); return error_number; } - checkptr = calloc (1, strlen(source) * 4 + 8); + checkptr = calloc (1, ustrlen(source) * 4 + 8); /* Start character */ concat(dest, "31311331"); /* Data area */ - for(i = 0; i <= strlen(source); i++) + for(i = 0; i <= ustrlen(source); i++) { check = posn(SSET, source[i]); 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 used in GNU Barcode */ - for (i=0; i < 4*strlen(source); i++) { + for (i=0; i < 4*ustrlen(source); i++) { int j; if (checkptr[i]) 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++) { - switch(checkptr[strlen(source) * 4 + i]) + switch(checkptr[ustrlen(source) * 4 + i]) { case 0: concat(dest, "13"); break; case 1: concat(dest, "31"); break; @@ -107,7 +107,7 @@ int msi_plessey(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; strcpy(dest, ""); - if(strlen(source) > 55) { + if(ustrlen(source) > 55) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -120,7 +120,7 @@ int msi_plessey(struct zint_symbol *symbol, unsigned char source[]) /* start character */ concat (dest, "21"); - for(i = 0; i <= strlen(source); i++) + for(i = 0; i <= ustrlen(source); i++) { lookup(NESET, MSITable, source[i], dest); } @@ -145,7 +145,7 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; strcpy(dest, ""); - if(strlen(source) > 55) { + if(ustrlen(source) > 55) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -159,16 +159,16 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[]) concat (dest, "21"); /* draw data section */ - for(i = 0; i < strlen(source); i++) + for(i = 0; i < ustrlen(source); i++) { lookup(NESET, MSITable, source[i], dest); } /* caluculate check digit */ 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]; wright ++; @@ -176,7 +176,7 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[]) } else { - for(i = 0; i < strlen(source); i+=2) + for(i = 0; i < ustrlen(source); i+=2) { un[wright] = source[i]; 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]); } } else { - for(i = 1; i < strlen(source); i+=2) + for(i = 1; i < ustrlen(source); i+=2) { pedwar += ctoi(source[i]); } @@ -223,7 +223,7 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[]) /* Stop character */ concat (dest, "121"); - h = strlen(source); + h = ustrlen(source); source[h] = itoc(pump); source[h + 1] = '\0'; expand(symbol, dest); @@ -243,7 +243,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; 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"); return ERROR_TOO_LONG; } @@ -257,16 +257,16 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[]) concat (dest, "21"); /* draw data section */ - for(i = 0; i < strlen(source); i++) + for(i = 0; i < ustrlen(source); i++) { lookup(NESET, MSITable, source[i], dest); } /* calculate first check digit */ 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]; wright ++; @@ -274,7 +274,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[]) } else { - for(i = 0; i < strlen(source); i+=2) + for(i = 0; i < ustrlen(source); i+=2) { un[wright] = source[i]; 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]); } } else { - for(i = 1; i < strlen(source); i+=2) + for(i = 1; i < ustrlen(source); i+=2) { pedwar += ctoi(source[i]); } @@ -317,9 +317,9 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[]) /* calculate second check digit */ 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]; wright ++; @@ -327,7 +327,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[]) } else { - for(i = 1; i < strlen(source); i+=2) + for(i = 1; i < ustrlen(source); i+=2) { un[wright] = source[i]; 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]); } } else { - for(i = 0; i < strlen(source); i+=2) + for(i = 0; i < ustrlen(source); i+=2) { pedwar += ctoi(source[i]); } @@ -377,7 +377,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[]) /* Stop character */ concat (dest, "121"); - h = strlen(source); + h = ustrlen(source); source[h] = itoc(pump); source[h + 1] = itoc(chwech); source[h + 2] = '\0'; @@ -400,7 +400,7 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; strcpy(dest, ""); - if(strlen(source) > 55) { + if(ustrlen(source) > 55) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -414,7 +414,7 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[]) concat (dest, "21"); /* draw data section */ - for(i = 0; i < strlen(source); i++) + for(i = 0; i < ustrlen(source); i++) { lookup(NESET, MSITable, source[i], dest); } @@ -422,7 +422,7 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[]) /* calculate check digit */ x = 0; weight = 2; - for(i = (strlen(source) - 1); i >= 0; i--) { + for(i = (ustrlen(source) - 1); i >= 0; i--) { x += weight * ctoi(source[i]); weight++; if(weight > 7) { @@ -438,7 +438,7 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[]) lookup(NESET, MSITable, itoc(check), dest); } - h = strlen(source); + h = ustrlen(source); if(check == 10) { source[h] = '1'; source[h + 1] = '0'; @@ -470,7 +470,7 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; strcpy(dest, ""); - if(strlen(source) > 55) { + if(ustrlen(source) > 55) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -484,16 +484,16 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[]) concat (dest, "21"); /* draw data section */ - for(i = 0; i < strlen(source); i++) + for(i = 0; i < ustrlen(source); i++) { lookup(NESET, MSITable, source[i], dest); } /* calculate first (mod 11) digit */ - wright = strlen(source); + wright = ustrlen(source); x = 0; weight = 2; - for(i = (strlen(source) - 1); i >= 0; i--) { + for(i = (ustrlen(source) - 1); i >= 0; i--) { x += weight * ctoi(source[i]); weight++; if(weight > 7) { @@ -516,9 +516,9 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[]) /* caluculate second (mod 10) check digit */ 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]; wright ++; @@ -526,7 +526,7 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[]) } else { - for(i = 0; i < strlen(source); i+=2) + for(i = 0; i < ustrlen(source); i+=2) { un[wright] = source[i]; 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]); } } else { - for(i = 1; i < strlen(source); i+=2) + for(i = 1; i < ustrlen(source); i+=2) { pedwar += ctoi(source[i]); } @@ -573,7 +573,7 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[]) /* stop character */ concat (dest, "121"); - h = strlen(source); + h = ustrlen(source); source[h] = itoc(pump); source[h + 1] = '\0'; diff --git a/backend/png.c b/backend/png.c index e72f39b1..342fe643 100644 --- a/backend/png.c +++ b/backend/png.c @@ -61,10 +61,9 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c png_structp png_ptr; png_infop info_ptr; graphic = &wpng_info; - long j; unsigned long rowbytes; unsigned char *image_data; - int i, k, offset, row, column, errno; + int i, row, column, errno; int fgred, fggrn, fgblu, bgred, bggrn, bgblu; 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 */ 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); for(i = 0; i < string_length; i++) { diff --git a/backend/postal.c b/backend/postal.c index e712a233..d93821df 100644 --- a/backend/postal.c +++ b/backend/postal.c @@ -56,7 +56,7 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[]) error_number = 0; - if(strlen(source) > 90) { + if(ustrlen(source) > 90) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -70,7 +70,7 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* start character */ concat (dest, "L"); - for (i=0; i < strlen(source); i++) + for (i=0; i < ustrlen(source); i++) { lookup(NESET, PNTable, source[i], dest); sum += ctoi(source[i]); @@ -82,7 +82,7 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* stop character */ concat (dest, "L"); - h = strlen(source); + h = ustrlen(source); source[h] = itoc(check_digit); source[h + 1] = '\0'; strcpy(symbol->text, ""); @@ -132,7 +132,7 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[]) error_number = 0; - if(strlen(source) > 90) { + if(ustrlen(source) > 90) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -146,7 +146,7 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* start character */ concat (dest, "L"); - for (i=0; i < strlen(source); i++) + for (i=0; i < ustrlen(source); i++) { lookup(NESET, PLTable, source[i], dest); sum += ctoi(source[i]); @@ -158,7 +158,7 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* stop character */ concat (dest, "L"); - h = strlen(source); + h = ustrlen(source); source[h] = itoc(check_digit); source[h + 1] = '\0'; strcpy(symbol->text, ""); @@ -211,7 +211,7 @@ int fim(struct zint_symbol *symbol, unsigned char source[]) strcpy(dest, ""); to_upper(source); - if(strlen(source) > 1) { + if(ustrlen(source) > 1) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -274,7 +274,7 @@ int royal_plot(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; to_upper(source); - if(strlen(source) > 120) { + if(ustrlen(source) > 120) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -306,7 +306,7 @@ int royal_plot(struct zint_symbol *symbol, unsigned char source[]) symbol->rows = 3; symbol->width = writer - 1; - h = strlen(source); + h = ustrlen(source); source[h] = check; source[h + 1] = '\0'; strcpy(symbol->text, ""); @@ -328,7 +328,7 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; to_upper(source); - if(strlen(source) != 11) { + if(ustrlen(source) != 11) { strcpy(symbol->errtxt, "error: input 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"); return error_number; } - for (i = 0; i < strlen(source); i++) { + for (i = 0; i < ustrlen(source); i++) { lookup(KRSET, RoyalTable, source[i], height_pattern); } @@ -377,7 +377,7 @@ int daft_code(struct zint_symbol *symbol, unsigned char source[]) int writer, i; strcpy(height_pattern, ""); - input_length = strlen(source); + input_length = ustrlen(source); strcpy(local_source, source); if(input_length > 50) { strcpy(symbol->errtxt, "Input too long"); @@ -427,7 +427,7 @@ int flattermarken(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; strcpy(dest, ""); - if(strlen(source) > 90) { + if(ustrlen(source) > 90) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } @@ -437,7 +437,7 @@ int flattermarken(struct zint_symbol *symbol, unsigned char source[]) return error_number; } - for(loop = 0; loop < strlen(source); loop++) { + for(loop = 0; loop < ustrlen(source); loop++) { lookup(NESET, FlatTable, source[loop], dest); } diff --git a/backend/qr.c b/backend/qr.c index dc8cd0df..6ee35055 100644 --- a/backend/qr.c +++ b/backend/qr.c @@ -27,7 +27,6 @@ #include static int kanji = 0; -static QRecLevel level = QR_ECLEVEL_L; QRcode *encode(int security, int size, const unsigned char *intext) { diff --git a/backend/rss.c b/backend/rss.c index 6b2a7147..0b662677 100644 --- a/backend/rss.c +++ b/backend/rss.c @@ -94,7 +94,6 @@ void getRSSwidths(int val, int n, int elements, int maxWidth, int noNarrow) { int bar; int elmWidth; - int i; int mxwElement; int subVal, lessVal; 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[]) { /* 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]; 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; @@ -150,7 +149,7 @@ int rss14(struct zint_symbol *symbol, unsigned char source[]) separator_row = 0; - if(strlen(source) > 13) { + if(ustrlen(source) > 13) { strcpy(symbol->errtxt, "error: input 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++) { hrt[i] = '0'; } - for(i = 0; i < strlen(source); i++) { - hrt[12 - i] = source[strlen(source) - i - 1]; + for(i = 0; i < ustrlen(source); i++) { + hrt[12 - i] = source[ustrlen(source) - i - 1]; } hrt[14] = '\0'; @@ -647,7 +646,7 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[]) separator_row = 0; - if(strlen(source) > 13) { + if(ustrlen(source) > 13) { strcpy(symbol->errtxt, "error: input 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++) { hrt[i] = '0'; } - for(i = 0; i < strlen(source); i++) { - hrt[12 - i] = source[strlen(source) - i - 1]; + for(i = 0; i < ustrlen(source); i++) { + hrt[12 - i] = source[ustrlen(source) - i - 1]; } 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[]) { /* Handles all data encodation from section 7.2.5 of ISO/IEC 24724 */ 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; 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 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 */ encoding_method = 1; } else { @@ -1036,10 +1035,10 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b 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 */ - if((strlen(source) >= 26) && (source[17] == '1')) { + if((ustrlen(source) >= 26) && (source[17] == '1')) { /* Methods 3, 7, 9, 11 and 13 */ if(source[18] == '0') { @@ -1057,14 +1056,14 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b encoding_method = 7; - if((source[19] == '3') && (strlen(source) == 26)) { + if((source[19] == '3') && (ustrlen(source) == 26)) { /* (01) and (3103) */ weight = atof(weight_str) / 1000.0; if(weight <= 32.767) { encoding_method = 3; } } - if(strlen(source) == 34){ + if(ustrlen(source) == 34){ if((source[26] == '1') && (source[27] == '1')) { /* (01), (310x) and (11) - metric weight and production date */ 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 */ if(source[18] == '0') { @@ -1106,7 +1105,7 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b 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) */ 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')) { /* (01), (320x) and (11) - English weight and production date */ 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 */ case 1: concat(binary_string, "1XX"); read_posn = 16; break; case 2: concat(binary_string, "00XX"); read_posn = 0; break; - case 3: concat(binary_string, "0100"); read_posn = strlen(source); break; - case 4: concat(binary_string, "0101"); read_posn = strlen(source); break; + case 3: concat(binary_string, "0100"); read_posn = ustrlen(source); break; + case 4: concat(binary_string, "0101"); read_posn = ustrlen(source); break; case 5: concat(binary_string, "01100XX"); read_posn = 20; break; case 6: concat(binary_string, "01101XX"); read_posn = 23; break; - case 7: concat(binary_string, "0111000"); read_posn = strlen(source); break; - case 8: concat(binary_string, "0111001"); read_posn = strlen(source); break; - case 9: concat(binary_string, "0111010"); read_posn = strlen(source); break; - case 10: concat(binary_string, "0111011"); read_posn = strlen(source); break; - case 11: concat(binary_string, "0111100"); read_posn = strlen(source); break; - case 12: concat(binary_string, "0111101"); read_posn = strlen(source); break; - case 13: concat(binary_string, "0111110"); read_posn = strlen(source); break; - case 14: concat(binary_string, "0111111"); read_posn = strlen(source); break; + case 7: concat(binary_string, "0111000"); read_posn = ustrlen(source); break; + case 8: concat(binary_string, "0111001"); read_posn = ustrlen(source); break; + case 9: concat(binary_string, "0111010"); read_posn = ustrlen(source); break; + case 10: concat(binary_string, "0111011"); read_posn = ustrlen(source); break; + case 11: concat(binary_string, "0111100"); read_posn = ustrlen(source); break; + case 12: concat(binary_string, "0111101"); read_posn = ustrlen(source); break; + case 13: concat(binary_string, "0111110"); read_posn = ustrlen(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) @@ -1373,7 +1372,7 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b mask = mask >> 1; } - if(strlen(source) == 34) { + if(ustrlen(source) == 34) { /* Date information is included */ date_str[0] = source[28]; 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 */ j = 0; - for(i = read_posn; i < strlen(source); i++) { + for(i = read_posn; i < ustrlen(source); i++) { general_field[j] = source[i]; 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[]) { /* GS1 DataBar Expanded */ 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 check_char, c_odd, c_even, elements[235], pattern_width, reader, writer; 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; } - for(i = 0; i < strlen(source) - 1; i++) { + for(i = 0; i < ustrlen(source) - 1; i++) { if((source[i] == '[') && (source[i + 1] == '[')) { /* Can't have nested brackets - Quit */ 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] == ']')) { /* Can't have nested brackets - Quit */ 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; last_ai = 0; ai_latch = 1; - for(i = 0; i < strlen(source); i++) { + for(i = 0; i < ustrlen(source); i++) { if((source[i] != '[') && (source[i] != ']')) { reduced[j] = source[i]; j++; @@ -1963,6 +1962,9 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[]) 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; for(i = 0; i < data_chars; 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); if(check_char <= 347) { c_group = 1; } @@ -2072,7 +2073,7 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[]) } /* Add human readable text */ - for(i = 0; i <= strlen(source); i++) { + for(i = 0; i <= ustrlen(source); i++) { if((source[i] != '[') && (source[i] != ']')) { symbol->text[i] = source[i]; } else { diff --git a/backend/telepen.c b/backend/telepen.c index 348efd2b..0383520d 100644 --- a/backend/telepen.c +++ b/backend/telepen.c @@ -61,12 +61,12 @@ int telepen(struct zint_symbol *symbol, unsigned char source[]) count = 0; - if(strlen(source) > 30) { + if(ustrlen(source) > 30) { strcpy(symbol->errtxt, "error: input too long"); return ERROR_TOO_LONG; } - for(i = 0; i < strlen(source); i++) { + for(i = 0; i < ustrlen(source); i++) { if(source[i] > 127) { /* Cannot encode extended ASCII */ strcpy(symbol->errtxt, "error: invalid characters in input data"); @@ -77,7 +77,7 @@ int telepen(struct zint_symbol *symbol, unsigned char source[]) /* Start character */ concat(dest, TeleTable['_']); - for (i=0; i < strlen(source); i++) + for (i=0; i < ustrlen(source); i++) { ascii_value = source[i]; concat(dest, TeleTable[ascii_value]); @@ -105,7 +105,7 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[]) error_number = 0; strcpy(dest, ""); strcpy(local_source, source); - input_length = strlen(source); + input_length = ustrlen(source); count = 0; diff --git a/backend/upcean.c b/backend/upcean.c index 91448c6f..bac8254e 100644 --- a/backend/upcean.c +++ b/backend/upcean.c @@ -49,7 +49,7 @@ char upc_check(unsigned char source[]) count = 0; - for (i = 0; i < strlen(source); i++) + for (i = 0; i < ustrlen(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 */ unsigned int i, half_way; - half_way = strlen(source) / 2; + half_way = ustrlen(source) / 2; /* start character */ concat (dest, "111"); - for(i = 0; i <= strlen(source); i++) + for(i = 0; i <= ustrlen(source); i++) { 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 */ int length; - length = strlen(source); + length = ustrlen(source); source[length] = upc_check(source); source[length + 1] = '\0'; upca_draw(source, dest); @@ -107,7 +107,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) char hrt[8]; /* Two number systems can be used - system 0 and system 1 */ - if(strlen(source) == 7) { + if(ustrlen(source) == 7) { switch(source[0]) { case '0': num_system = 0; break; case '1': num_system = 1; break; @@ -195,7 +195,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* start character */ concat (dest, "111"); - for(i = 0; i <= strlen(source); i++) { + for(i = 0; i <= ustrlen(source); i++) { switch(parity[i]) { case 'A': lookup(NESET, EANsetA, 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"); /* Determine EAN2 or EAN5 add-on */ - if(strlen(source) == 2) + if(ustrlen(source) == 2) { code_type = EAN2; } @@ -261,7 +261,7 @@ void add_on(unsigned char source[], char dest[], int mode) strcpy(parity, EAN5Parity[parity_bit]); } - for(i = 0; i < strlen(source); i++) + for(i = 0; i < ustrlen(source); i++) { switch(parity[i]) { 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 */ - if(i != (strlen(source) - 1)) + if(i != (ustrlen(source) - 1)) { concat (dest, "11"); } @@ -286,7 +286,7 @@ char ean_check(unsigned char source[]) count = 0; - h = strlen(source); + h = ustrlen(source); for (i = h - 1; i >= 0; i--) { count += ctoi(source[i]); @@ -309,7 +309,7 @@ void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[]) strcpy(parity, ""); /* Add the appropriate check digit */ - length = strlen(source); + length = ustrlen(source); source[length] = ean_check(source); source[length + 1] = '\0'; @@ -322,7 +322,7 @@ void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* start character */ concat (dest, "111"); - for(i = 1; i <= strlen(source); i++) + for(i = 1; i <= ustrlen(source); i++) { 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 */ int length; - length = strlen(source); + length = ustrlen(source); source[length] = upc_check(source); source[length + 1] = '\0'; upca_draw(source, dest); @@ -366,7 +366,7 @@ char isbn13_check(unsigned char source[]) /* For ISBN(13) only */ sum = 0; weight = 1; - for(i = 0; i < (strlen(source) - 1); i++) + for(i = 0; i < (ustrlen(source) - 1); i++) { sum += ctoi(source[i]) * weight; 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; weight = 1; - for(i = 0; i < (strlen(source) - 1); i++) + for(i = 0; i < (ustrlen(source) - 1); i++) { sum += ctoi(source[i]) * 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 */ - 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"); 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')) && ((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); - if (source[strlen(source) - 1] != check_digit) + if (source[ustrlen(source) - 1] != check_digit) { strcpy(symbol->errtxt, "error: incorrect ISBN 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); } - if(strlen(source) == 10) /* Using 10 digit ISBN */ + if(ustrlen(source) == 10) /* Using 10 digit ISBN */ { 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"); return ERROR_INVALID_CHECK; @@ -454,7 +454,7 @@ int isbn(struct zint_symbol *symbol, unsigned char source[], char dest[]) /* Mak ean13(symbol, source, dest); } - if(strlen(source) == 9) /* Using 9 digit SBN */ + if(ustrlen(source) == 9) /* Using 9 digit SBN */ { /* Add leading zero */ 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 */ 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"); return ERROR_INVALID_CHECK; @@ -503,7 +503,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[]) latch = FALSE; writer = 0; - if(strlen(source) > 19) { + if(ustrlen(source) > 19) { strcpy(symbol->errtxt, "error: input 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; } } @@ -540,7 +540,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[]) reader++; writer++; } - } while (reader <= strlen(source)); + } while (reader <= ustrlen(source)); } else { strcpy(first_part, source); } diff --git a/backend/zint.h b/backend/zint.h index 64e6c03d..2244d584 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -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_Print(struct zint_symbol *symbol); 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 }