From 063ac4ce4f25ba6aadb4375a3bd4a65a8d4472bb Mon Sep 17 00:00:00 2001 From: hooper114 Date: Thu, 9 Jul 2009 08:28:00 +0000 Subject: [PATCH] Add GS1 support to Code 49 --- backend/code49.c | 15 ++++++++++++--- backend/library.c | 6 ++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/backend/code49.c b/backend/code49.c index 865efa5a..d83c9955 100644 --- a/backend/code49.c +++ b/backend/code49.c @@ -25,8 +25,8 @@ #include "common.h" #include "code49.h" -#define INSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%!&" -/* "!" represents Shift 1 and "&" represents Shift 2 */ +#define INSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%!&*" +/* "!" represents Shift 1 and "&" represents Shift 2, "*" represents FNC1 */ int code_49(struct zint_symbol *symbol, unsigned char source[]) { @@ -37,11 +37,13 @@ int code_49(struct zint_symbol *symbol, unsigned char source[]) int w_grid[8][4]; /* Refets to table 2 */ int pad_count = 0; char pattern[40]; + int gs1; if(ustrlen(source) > 81) { strcpy(symbol->errtxt, "Input too long"); return ERROR_TOO_LONG; } + if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; } strcpy(intermediate, ""); for(i = 0; i < ustrlen(source); i++) { @@ -49,10 +51,17 @@ int code_49(struct zint_symbol *symbol, unsigned char source[]) strcpy(symbol->errtxt, "Invalid characters in input data"); return ERROR_INVALID_DATA; } + if(gs1 && (i = 0)) { + concat(intermediate, "*"); /* FNC1 */ + } if(source[i] == symbol->nullchar) { concat(intermediate, c49_table7[0]); } else { - concat(intermediate, c49_table7[source[i]]); + if(gs1 && (source[i] == '[')) { + concat(intermediate, "*"); /* FNC1 */ + } else { + concat(intermediate, c49_table7[source[i]]); + } } } diff --git a/backend/library.c b/backend/library.c index 326a3af8..4a6d61d5 100644 --- a/backend/library.c +++ b/backend/library.c @@ -376,6 +376,8 @@ int gs1_compliant(int symbology) case BARCODE_AZTEC: case BARCODE_DATAMATRIX: case BARCODE_CODABLOCKF: + case BARCODE_CODEONE: + case BARCODE_CODE49: result = 1; break; } @@ -595,14 +597,14 @@ int ZBarcode_Print(struct zint_symbol *symbol) int error_number; char output[4]; - /* int i, j; + /*int i, j; for(i = 0; i < symbol->rows; i++) { for(j = 0; j <= symbol->width / 7; j++) { printf("%2.2X ", symbol->encoded_data[i][j]); } printf("\n"); - } */ + }*/ if(strlen(symbol->outfile) > 3) { output[0] = symbol->outfile[strlen(symbol->outfile) - 3];