mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Add verbose mode to output debug info without recompiling
This commit is contained in:
parent
5acbffff0d
commit
6f4610aa98
@ -68,9 +68,9 @@ static void insert(char binary_string[], const size_t posn, const char newbit) {
|
||||
/**
|
||||
* Encode input data into a binary string
|
||||
*/
|
||||
static int aztec_text_process(const unsigned char source[], const unsigned int src_len, char binary_string[], const int gs1, const int eci) {
|
||||
static int aztec_text_process(const unsigned char source[], const unsigned int src_len, char binary_string[], const int gs1, const int eci, int debug) {
|
||||
int i, j, k, p, bytes;
|
||||
int curtable, newtable, lasttable, chartype, maplength, blocks, debug;
|
||||
int curtable, newtable, lasttable, chartype, maplength, blocks;
|
||||
#ifndef _MSC_VER
|
||||
int charmap[src_len * 2], typemap[src_len * 2];
|
||||
int blockmap[2][src_len];
|
||||
@ -83,7 +83,6 @@ static int aztec_text_process(const unsigned char source[], const unsigned int s
|
||||
#endif
|
||||
/* Lookup input string in encoding table */
|
||||
maplength = 0;
|
||||
debug = 0;
|
||||
|
||||
if (gs1) {
|
||||
/* Add FNC1 to beginning of GS1 messages */
|
||||
@ -886,7 +885,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
unsigned char desc_data[4], desc_ecc[6];
|
||||
int err_code, ecc_level, compact, data_length, data_maxsize, codeword_size, adjusted_length;
|
||||
int remainder, padbits, count, gs1, adjustment_size;
|
||||
int debug = 0, reader = 0;
|
||||
int debug = symbol->debug, reader = 0;
|
||||
int comp_loop = 4;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@ -913,7 +912,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
||||
populate_map();
|
||||
|
||||
err_code = aztec_text_process(source, length, binary_string, gs1, symbol->eci);
|
||||
err_code = aztec_text_process(source, length, binary_string, gs1, symbol->eci, symbol->debug);
|
||||
|
||||
if (err_code != 0) {
|
||||
strcpy(symbol->errtxt, "Input too long or too many extended ASCII characters (E02)");
|
||||
|
@ -536,7 +536,7 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
|
||||
int sp, tp, i, gs1;
|
||||
int current_mode, next_mode;
|
||||
int inputlen = *length_p;
|
||||
int debug = 0;
|
||||
int debug = symbol->debug;
|
||||
#ifndef _MSC_VER
|
||||
char binary[2 * inputlen];
|
||||
#else
|
||||
|
@ -367,7 +367,7 @@ int dotcode_encode_message(struct zint_symbol *symbol, const unsigned char sourc
|
||||
int input_position, array_length, i;
|
||||
char encoding_mode;
|
||||
int inside_macro, done;
|
||||
int debug = 0;
|
||||
int debug = symbol->debug;
|
||||
int binary_buffer_size = 0;
|
||||
int lawrencium[6]; // Reversed radix 103 values
|
||||
|
||||
@ -1088,7 +1088,7 @@ int dotcode(struct zint_symbol *symbol, const unsigned char source[], int length
|
||||
#else
|
||||
char* dot_stream;
|
||||
char* dot_array;
|
||||
unsigned char* masked_codeword_array;
|
||||
unsigned char* masked_codeword_array;
|
||||
unsigned char* codeword_array = (unsigned char *) _alloca(length * 3 * sizeof (unsigned char));
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
|
@ -348,7 +348,7 @@ void add_shift_char(char binary[], int shifty) {
|
||||
}
|
||||
}
|
||||
|
||||
int gm_encode(int gbdata[], int length, char binary[], int reader, int eci) {
|
||||
int gm_encode(int gbdata[], int length, char binary[], int reader, int eci, int debug) {
|
||||
/* Create a binary stream representation of the input data.
|
||||
7 sets are defined - Chinese characters, Numerals, Lower case letters, Upper case letters,
|
||||
Mixed numerals and latters, Control characters and 8-bit binary data */
|
||||
@ -357,7 +357,7 @@ int gm_encode(int gbdata[], int length, char binary[], int reader, int eci) {
|
||||
int p = 0, ppos;
|
||||
int numbuf[3], punt = 0;
|
||||
size_t number_pad_posn, byte_count_posn = 0;
|
||||
int byte_count = 0, debug = 0;
|
||||
int byte_count = 0;
|
||||
int shift, i;
|
||||
|
||||
strcpy(binary, "");
|
||||
@ -1098,7 +1098,7 @@ int grid_matrix(struct zint_symbol *symbol, const unsigned char source[], int le
|
||||
|
||||
if (symbol->output_options & READER_INIT) reader = 1;
|
||||
|
||||
error_number = gm_encode(gbdata, length, binary, reader, symbol->eci);
|
||||
error_number = gm_encode(gbdata, length, binary, reader, symbol->eci, symbol->debug);
|
||||
if (error_number != 0) {
|
||||
strcpy(symbol->errtxt, "Input data too long (E31)");
|
||||
return error_number;
|
||||
|
@ -328,11 +328,10 @@ int lookup_text2(char input) {
|
||||
}
|
||||
|
||||
/* Convert input data to binary stream */
|
||||
void calculate_binary(char binary[], char mode[], int source[], int length, int eci) {
|
||||
void calculate_binary(char binary[], char mode[], int source[], int length, int eci, int debug) {
|
||||
int block_length;
|
||||
int position = 0;
|
||||
int i, p, count, encoding_value;
|
||||
int debug = 0;
|
||||
int first_byte, second_byte;
|
||||
int third_byte, fourth_byte;
|
||||
int glyph;
|
||||
@ -1396,7 +1395,7 @@ int han_xin(struct zint_symbol *symbol, const unsigned char source[], int length
|
||||
ecc_level = 1;
|
||||
}
|
||||
|
||||
calculate_binary(binary, mode, gbdata, length, symbol->eci);
|
||||
calculate_binary(binary, mode, gbdata, length, symbol->eci, symbol->debug);
|
||||
bin_len = strlen(binary);
|
||||
codewords = bin_len / 8;
|
||||
if (bin_len % 8 != 0) {
|
||||
|
@ -72,6 +72,7 @@ struct zint_symbol *ZBarcode_Create() {
|
||||
symbol->bitmap_height = 0;
|
||||
symbol->eci = 3;
|
||||
symbol->dot_size = 4.0 / 5.0;
|
||||
symbol->debug = 0;
|
||||
return symbol;
|
||||
}
|
||||
|
||||
|
@ -561,7 +561,7 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length) {
|
||||
int i, k, j, indexchaine, indexliste, mode, longueur, loop, mccorrection[520], offset;
|
||||
int total, chainemc[2700], mclength, c1, c2, c3, dummy[35], codeerr;
|
||||
char codebarre[140], pattern[580];
|
||||
int debug = 0;
|
||||
int debug = symbol->debug;
|
||||
|
||||
codeerr = 0;
|
||||
|
||||
|
12
backend/qr.c
12
backend/qr.c
@ -197,8 +197,8 @@ static void qr_bscan(char *binary, int data, int h) {
|
||||
}
|
||||
|
||||
/* Convert input data to a binary stream and add padding */
|
||||
void qr_binary(int datastream[], int version, int target_binlen, char mode[], int jisdata[], int length, int gs1, int eci, int est_binlen) {
|
||||
int position = 0, debug = 0;
|
||||
void qr_binary(int datastream[], int version, int target_binlen, char mode[], int jisdata[], int length, int gs1, int eci, int est_binlen, int debug) {
|
||||
int position = 0;
|
||||
int short_data_block_length, i, scheme = 1;
|
||||
char data_block, padbits;
|
||||
int current_binlen, current_bytes;
|
||||
@ -1672,7 +1672,7 @@ int qr_code(struct zint_symbol *symbol, const unsigned char source[], int length
|
||||
fullstream = (int *) _alloca((qr_total_codewords[version - 1] + 1) * sizeof (int));
|
||||
#endif
|
||||
|
||||
qr_binary(datastream, version, target_binlen, mode, jisdata, length, gs1, symbol->eci, est_binlen);
|
||||
qr_binary(datastream, version, target_binlen, mode, jisdata, length, gs1, symbol->eci, est_binlen, symbol->debug);
|
||||
add_ecc(fullstream, datastream, version, target_binlen, blocks);
|
||||
|
||||
size = qr_sizes[version - 1];
|
||||
@ -1718,10 +1718,10 @@ int qr_code(struct zint_symbol *symbol, const unsigned char source[], int length
|
||||
|
||||
/* NOTE: From this point forward concerns Micro QR Code only */
|
||||
|
||||
int micro_qr_intermediate(char binary[], int jisdata[], char mode[], int length, int *kanji_used, int *alphanum_used, int *byte_used) {
|
||||
int micro_qr_intermediate(char binary[], int jisdata[], char mode[], int length, int *kanji_used, int *alphanum_used, int *byte_used, int debug) {
|
||||
/* Convert input data to an "intermediate stage" where data is binary encoded but
|
||||
control information is not */
|
||||
int position = 0, debug = 0;
|
||||
int position = 0;
|
||||
int short_data_block_length, i;
|
||||
char data_block;
|
||||
char buffer[2];
|
||||
@ -2707,7 +2707,7 @@ int microqr(struct zint_symbol *symbol, const unsigned char source[], int length
|
||||
}
|
||||
}
|
||||
|
||||
error_number = micro_qr_intermediate(binary_stream, jisdata, mode, length, &kanji_used, &alphanum_used, &byte_used);
|
||||
error_number = micro_qr_intermediate(binary_stream, jisdata, mode, length, &kanji_used, &alphanum_used, &byte_used, symbol->debug);
|
||||
if (error_number != 0) {
|
||||
strcpy(symbol->errtxt, "Input data too long (E64)");
|
||||
return error_number;
|
||||
|
@ -1169,7 +1169,7 @@ int general_rules(char field[], char type[]) {
|
||||
|
||||
/* Handles all data encodation from section 7.2.5 of ISO/IEC 24724 */
|
||||
int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_string[]) {
|
||||
int encoding_method, i, mask, j, read_posn, latch, debug = 0, last_mode = ISOIEC;
|
||||
int encoding_method, i, mask, j, read_posn, latch, debug = symbol->debug, last_mode = ISOIEC;
|
||||
int symbol_characters, characters_per_row;
|
||||
#ifndef _MSC_VER
|
||||
char general_field[strlen(source) + 1], general_field_type[strlen(source) + 1];
|
||||
|
@ -96,6 +96,7 @@ extern "C" {
|
||||
unsigned int bitmap_byte_length;
|
||||
float dot_size;
|
||||
struct zint_render *rendered;
|
||||
int debug;
|
||||
};
|
||||
|
||||
#define ZINT_VERSION_MAJOR 2
|
||||
|
@ -493,6 +493,7 @@ int main(int argc, char **argv) {
|
||||
{"dotsize", 1, 0, 0},
|
||||
{"eci", 1, 0, 0},
|
||||
{"filetype", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0}, // Currently undocumented, output some debug info
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
c = getopt_long(argc, argv, "htb:w:d:o:i:rcmpe", long_options, &option_index);
|
||||
@ -688,6 +689,9 @@ int main(int argc, char **argv) {
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
if (!strcmp(long_options[option_index].name, "verbose")) {
|
||||
my_symbol->debug = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
|
Loading…
Reference in New Issue
Block a user