From d13a3aaf1a9a31ae86426fb61194bc809dfedee0 Mon Sep 17 00:00:00 2001 From: Antoine Merino Date: Thu, 19 Dec 2024 18:57:18 +0100 Subject: [PATCH 1/7] Add symbology: DX Film Edge barcode DX Film Edge barcodes are used 35 mm and APS films --- backend/CMakeLists.txt | 2 +- backend/dxfilmedge.c | 330 ++++++++++++++++++++ backend/library.c | 10 +- backend/output.c | 6 + backend/tests/CMakeLists.txt | 1 + backend/tests/test_dxfilmedge.c | 310 ++++++++++++++++++ backend/tests/test_library.c | 6 +- backend/zint.h | 3 +- backend_qt/backend_qt.pro | 1 + backend_qt/backend_vc8.pro | 1 + backend_tcl/configure | 1 + backend_tcl/configure.ac | 1 + frontend/main.c | 3 +- frontend_qt/mainwindow.cpp | 2 +- win32/libzint.vcxproj | 1 + win32/vs2008/libzint.vcproj | 4 + win32/vs2015/libzint.vcxproj | 1 + win32/vs2017/libzint.vcxproj | 1 + win32/vs2019/libzint.vcxproj | 1 + win32/zint_cmdline_vc6/zint_cmdline_vc6.dsp | 4 + 20 files changed, 680 insertions(+), 9 deletions(-) create mode 100644 backend/dxfilmedge.c create mode 100644 backend/tests/test_dxfilmedge.c diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index d1cf5f68..0af1802b 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -10,7 +10,7 @@ if(ZINT_USE_PNG) endif() set(zint_COMMON_SRCS common.c library.c large.c reedsol.c gs1.c eci.c filemem.c general_field.c) -set(zint_ONEDIM_SRCS bc412.c code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c) +set(zint_ONEDIM_SRCS bc412.c code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c dxfilmedge.c) set(zint_POSTAL_SRCS postal.c auspost.c imail.c mailmark.c) set(zint_TWODIM_SRCS code16k.c codablock.c dmatrix.c pdf417.c qr.c maxicode.c composite.c aztec.c code49.c code1.c gridmtx.c hanxin.c dotcode.c ultra.c) if(ZINT_USE_PNG AND PNG_FOUND) diff --git a/backend/dxfilmedge.c b/backend/dxfilmedge.c new file mode 100644 index 00000000..1a5c25c0 --- /dev/null +++ b/backend/dxfilmedge.c @@ -0,0 +1,330 @@ +/* dxfilmedge.c - Handles DX Film Edge symbology */ +/* + libzint - the open source barcode library + Copyright (C) 2024-2025 Antoine Merino + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ +/* SPDX-License-Identifier: BSD-3-Clause */ + +/* DX Film Edge Barcode is used on 35mm and APS films: + * https://en.wikipedia.org/wiki/DX_encoding + * + * A little information about decoding this symbology can be found at + * https://www.merinorus.com/blog/identifying-manufacturer-35-mm-films/ + * + * Partial specification and history can be found on this Kodak patent: + * https://patents.google.com/patent/US4965628A/en + */ + +#include +#include +#include +#include +#include "common.h" + +#define DEBUG_STR_LEN 20 +/* Max length of the DX info part. Include the \0. Eg: "018500\0", "150-10\0" */ +#define MAX_DX_INFO_LENGTH 7 +/* Max length of the frame info part. Eg: "00A\0", "23A\0" */ +#define MAX_FRAME_INFO_LENGTH 4 + +void int_to_binary(int value, int width, char *output) { + int i; + for (i = 0; i < width; i++) { + output[width - 1 - i] = (value & (1 << i)) ? '1' : '0'; + } + output[width] = '\0'; +} + +void str_to_uppercase(char *str) { + int i; + for (i = 0; str[i] != '\0'; i++) { + str[i] = toupper(str[i]); + } +} + +int count_char_occurrences(const char *str, char target) { + int i, count = 0; + for (i = 0; str[i] != '\0'; i++) { + if (str[i] == target) { + count++; + if (count > 1) { + return count; + } + } + } + return count; +} + + +int parse_dx_code(struct zint_symbol *symbol, const char *source, char *binary_output, int *output_length, bool *has_frame_info) { + + int i; + int parity_bit = 0; + int dx_extract = -1, dx_code_1 = -1, dx_code_2 = -1, frame_number = -1; + char binary_dx_code_1[8], binary_dx_code_2[5], binary_frame_number[7]; + char half_frame_flag = '\0'; + char dx_info[MAX_DX_INFO_LENGTH] = "\0"; + char frame_info[MAX_FRAME_INFO_LENGTH] = "\0"; + char *detected_char = strchr((const char *)(source), ' '); + const char *frame_start; + + *has_frame_info = false; + + /* All codes should start with a digit*/ + if (not_sane(IS_NUM_F, (unsigned char *)source, 1)){ + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1018, "Invalid character \"%c\", DX code should start with a number", source[0]); + } + + /* Check if there is the '/' separator, which indicates the frame number is present. */ + detected_char = strchr((const char *)(source), '/'); + if (detected_char){ + /* Split the DX information from the frame number */ + size_t dx_length = detected_char - (char *)source; + if (dx_length >= MAX_DX_INFO_LENGTH){ + return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 1014, "DX information is too long"); + } + strncat(dx_info, source, dx_length); + dx_info[dx_length] = '\0'; + frame_start = detected_char + 1; + if (strlen(frame_start) >= MAX_FRAME_INFO_LENGTH) { + return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 1002, "Frame number part is too long"); + } + strncat(frame_info, frame_start, sizeof(frame_info) - 1); + *has_frame_info = true; + str_to_uppercase(frame_info); + if ((i = not_sane(IS_UPR_F | IS_NUM_F | IS_MNS_F, (unsigned char *)(frame_info), strlen(frame_info)))){ + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1012, "Frame number \"%s\" is invalid (expected digits, eventually followed by \'A\')", frame_info); + } + } + else{ + /* No "/" found, store the entire input in dx_info */ + if (strlen(source) >= MAX_DX_INFO_LENGTH) { + return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 1003, "DX information is too long"); + } + strncat(dx_info, source, sizeof(dx_info) - 1); + } + + if ((i = not_sane(IS_NUM_F | IS_MNS_F, (unsigned char *)dx_info, strlen(dx_info)))){ + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1016, "Invalid character at position %d in DX info (digits and \'-\' character only)", i); + } + + if (ZINT_DEBUG_PRINT) printf("\nDX info part: \"%s\", Frame info part: \"%s\"\n", dx_info, frame_info); + /* Parse the DX information */ + if (strchr(dx_info, '-')){ + /* DX code parts 1 and 2 are given directly, separated by a '-'. Eg: "79-7" */ + if (ZINT_DEBUG_PRINT) printf("DX code 1 and 2 are separated by a dash \'-\'\n"); + if (count_char_occurrences(dx_info, '-') > 1){ + return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 1009, "The \'-\' is used to separate DX parts 1 and 2, and should be used no more than once"); + } + if (sscanf(dx_info, "%d-%d", &dx_code_1, &dx_code_2) < 2){ + return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 1004, "Wrong format for DX parts 1 and 2 (expected format: XXX-XX, digits)"); + } + if (dx_code_1 <= 0 || dx_code_1 > 127){ + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1006, "DX part 1 \"%d\" must be between 1 and 127", dx_code_1); + } + if (dx_code_2 < 0 || dx_code_2 > 15){ + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1007, "DX part 2 \"%d\" must be between 0 and 15", dx_code_2); + } + } + else{ + /* DX format is either 4 digits (DX Extract, eg: 1271) or 6 digits (DX Full, eg: 012710) */ + if (ZINT_DEBUG_PRINT) printf("No \'-\' separator, computing from DX Extract (4 digits) or DX Full (6 digits)\n"); + if (strlen(dx_info) == 5 || strlen(dx_info) > 6){ + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1005, "DX number \"%s\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)", dx_info); + } + if (strlen(dx_info) == 6){ + if (ZINT_DEBUG_PRINT) printf("DX full format detected: %s. Removing the first and the last characters.\n", dx_info); + /* Convert DX Full to DX Extract (remove first and last character) */ + for (i=0; i <= 3; ++i){ + dx_info[i] = dx_info[i+1]; + } + dx_info[4] = '\0'; + } + /* Compute the DX parts 1 and 2 from the DX extract */ + if (sscanf(dx_info, "%d", &dx_extract) < 1){ + /* Should not happen (DX info format has been checked above), but better safe than sorry */ + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1005, "DX number \"%s\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)", dx_info); + } + if (dx_extract < 16 || dx_extract > 2047){ + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1015, "DX extract \"%d\" must be between 16 and 2047", dx_extract); + } + if (ZINT_DEBUG_PRINT) printf("Computed DX extract: %04d\n", dx_extract); + dx_code_1 = dx_extract / 16; + dx_code_2 = dx_extract % 16; + } + + /* Convert components to binary strings */ + int_to_binary(dx_code_1, 7, binary_dx_code_1); + int_to_binary(dx_code_2, 4, binary_dx_code_2); + + if (ZINT_DEBUG_PRINT) printf("%-*s%d\t-> %s\n", DEBUG_STR_LEN, "DX code 1:", dx_code_1, binary_dx_code_1); + if (ZINT_DEBUG_PRINT) printf("%-*s%d\t-> %s\n", DEBUG_STR_LEN, "DX code 2:", dx_code_2, binary_dx_code_2); + + if (*has_frame_info) { + if (strlen(frame_info) < 1){ + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1017, "Frame number indicator \"/\" at position %d, but frame number is empty", (int)(detected_char - (char *)source + 1)); + } + /* Some frame numbers are special values, convert them their equivalent number */ + if (strcmp(frame_info, "S") == 0 || strcmp(frame_info, "X") == 0) { + strcpy(frame_info, "62"); + } else if (strcmp(frame_info, "SA") == 0 || strcmp(frame_info, "XA") == 0) { + strcpy(frame_info, "62A"); + } else if (strcmp(frame_info, "K") == 0 || strcmp(frame_info, "00") == 0) { + strcpy(frame_info, "63"); + } else if (strcmp(frame_info, "KA") == 0 || strcmp(frame_info, "00A") == 0) { + strcpy(frame_info, "63A"); + } else if (strcmp(frame_info, "F") == 0) { + strcpy(frame_info, "0"); + } else if (strcmp(frame_info, "FA") == 0) { + strcpy(frame_info, "0A"); + } + + if (sscanf(frame_info, "%d%c", &frame_number, &half_frame_flag) < 1){ + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1012, "Frame number \"%s\" is invalid (expected digits, eventually followed by \'A\')", frame_info); + } + if (frame_number < 0 || frame_number > 63){ + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1008, "Frame number \"%d\"should be between 0 and 63", frame_number); + } + int_to_binary(frame_number, 6, binary_frame_number); + if (ZINT_DEBUG_PRINT) printf("%-*s%d\t-> %s\n", DEBUG_STR_LEN, "Frame number:", frame_number, binary_frame_number); + } + + /* Build the binary output */ + strcpy(binary_output, "101010"); /* Start pattern */ + strcat(binary_output, binary_dx_code_1); + strcat(binary_output, "0"); /* Separator between DX part 1 and DX part 2 */ + strcat(binary_output, binary_dx_code_2); + if (*has_frame_info) { + strcat(binary_output, binary_frame_number); + if (toupper(half_frame_flag) == 'A') { + if (ZINT_DEBUG_PRINT) printf("%-*s\'%c\'\t-> 1\n", DEBUG_STR_LEN, "Half frame flag:", half_frame_flag); + strcat(binary_output, "1"); /* Half-frame is set */ + } else { + if (half_frame_flag){ + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1012, "Frame number \"%s\" is invalid (expected digits, eventually followed by \'A\')", frame_info); + } + if (ZINT_DEBUG_PRINT) printf("%-*s\'%c\'\t-> 0\n", DEBUG_STR_LEN, "Half frame flag:", half_frame_flag); + strcat(binary_output, "0"); /* Half-frame is NOT set */ + } + strcat(binary_output, "0"); /* Separator between half frame flag and parity bit*/ + } + + /* Parity bit */ + for (i = 6; binary_output[i] != '\0'; i++) { + if (binary_output[i] == '1') { + parity_bit++; + } + } + parity_bit %= 2; + if (ZINT_DEBUG_PRINT) printf("%-*s%s\t-> %d\n", DEBUG_STR_LEN, "Parity bit:", parity_bit?"yes":"no", parity_bit); + if (parity_bit){ + strcat(binary_output, "1"); + } + else{ + strcat(binary_output, "0"); + } + + strcat(binary_output, "0101"); /* Stop pattern */ + + *output_length = strlen(binary_output); + return 0; +} + + +INTERNAL int dxfilmedge(struct zint_symbol *symbol, char source[], int length) { + int i; + int writer = 0; + int error_number = 0; + + char char_data[32]; + int data_length; + bool has_frame_info; + + const char long_clock_pattern[] = "1111101010101010101010101010111"; + const char short_clock_pattern[] = "11111010101010101010111"; + const char *clock_pattern; + int clock_length; + int parse_result = -1; + + if (length > 10) { + return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 1013, "Input length %d too long (maximum 10)", length); + } + + parse_result = parse_dx_code(symbol, source, char_data, &data_length, &has_frame_info); + if (parse_result != 0){ + if (ZINT_DEBUG_PRINT) printf("Error %s\n\n", symbol->errtxt); + return parse_result; + } + + /* Clock signal is longer if the frame number is provided */ + if (has_frame_info){ + clock_pattern = long_clock_pattern; + clock_length = sizeof(long_clock_pattern) -1; + } + else{ + clock_pattern = short_clock_pattern; + clock_length = sizeof(short_clock_pattern) -1; + } + + /* First row: clock pattern */ + for (i = 0; i < clock_length; i++) { + if (clock_pattern[i] == '1') { + set_module(symbol, 0, writer); + } else if (clock_pattern[i] == '0') { + unset_module(symbol, 0, writer); + } + writer++; + } + + /* Reset writer X position for the second row */ + writer = 0; + + /* Second row: data signal */ + for (i = 0; i < clock_length; i++) { + if (char_data[i] == '1') { + set_module(symbol, 1, writer); + } else if (char_data[i] == '0') { + unset_module(symbol, 1, writer); + } + writer++; + } + symbol->rows = 2; + symbol->width = clock_length; + + if (symbol->output_options & COMPLIANT_HEIGHT) { + /* Measured ratio on 35mm films. Depending on the brands, one symbol height is about 3 * the X-dim.*/ + const float default_height = 6.0f; + + /* AFAIK There is no standard on minimum and maximum height, so we stay close to the measurements */ + const float min_row_height = 2.2f; + const float max_height = 7.5f; + error_number = set_height(symbol, min_row_height, default_height, max_height, 0 /*no_errtxt*/); + } + + return error_number; +} diff --git a/backend/library.c b/backend/library.c index de0bc1ff..6f8350d6 100644 --- a/backend/library.c +++ b/backend/library.c @@ -235,6 +235,7 @@ INTERNAL int ultra(struct zint_symbol *symbol, struct zint_seg segs[], const int INTERNAL int rmqr(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count); /* rMQR */ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length); /* DPD Code */ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int length); /* BC412 */ +INTERNAL int dxfilmedge(struct zint_symbol *symbol, unsigned char source[], int length); /* DX Film Edge Barcode */ /* Output handlers */ /* Plot to BMP/GIF/PCX/PNG/TIF */ @@ -512,6 +513,7 @@ static int has_hrt(const int symbology) { case BARCODE_FIM: case BARCODE_PHARMA: case BARCODE_PHARMA_TWO: + case BARCODE_DXFILMEDGE: case BARCODE_CEPNET: case BARCODE_PDF417: case BARCODE_PDF417COMP: @@ -580,7 +582,7 @@ static const barcode_src_func_t barcode_src_funcs[BARCODE_LAST + 1] = { composite, composite, composite, composite, composite, /*130-134*/ composite, composite, composite, composite, composite, /*135-139*/ channel, NULL, NULL, upnqr, NULL, /*140-144*/ - NULL, bc412, /*145-146*/ + NULL, bc412, dxfilmedge, /*145-147*/ }; #define LIB_SEG_FUNCS_START 55 @@ -1640,7 +1642,7 @@ int ZBarcode_BarcodeName(int symbol_id, char name[32]) { "EANX_CC", "GS1_128_CC", "DBAR_OMN_CC", "DBAR_LTD_CC", "DBAR_EXP_CC", /*130-134*/ "UPCA_CC", "UPCE_CC", "DBAR_STK_CC", "DBAR_OMNSTK_CC", "DBAR_EXPSTK_CC", /*135-139*/ "CHANNEL", "CODEONE", "GRIDMATRIX", "UPNQR", "ULTRA", /*140-144*/ - "RMQR", "BC412", /*145-146*/ + "RMQR", "BC412", "DXFILMEDGE", /*145-147*/ }; name[0] = '\0'; @@ -1867,7 +1869,9 @@ float ZBarcode_Default_Xdim(int symbol_id) { case BARCODE_DBAR_EXPSTK_CC: x_dim_mm = 0.33f; /* GS1 General Standards 22.0 Section 5.12.3 Table 1 except DBAR_LTD Table 4 */ break; - + case BARCODE_DXFILMEDGE: + x_dim_mm = 0.403548f; /* Measured on Kodak 35mm film, a DX Film Edge with frame number with 31 symbols is 12,51 mm long*/ + break; /* Specific */ case BARCODE_BC412: x_dim_mm = 0.12f; /* SEMI T1-95 Table 1 */ diff --git a/backend/output.c b/backend/output.c index e6f5ed9a..44d49aaf 100644 --- a/backend/output.c +++ b/backend/output.c @@ -360,6 +360,12 @@ static int out_quiet_zones(const struct zint_symbol *symbol, const int hide_text *left = *right = 10.0f; done = 1; break; + + case BARCODE_DXFILMEDGE: + /* No known standard. Add a little horizontal space to make the detection easier. Tested with Zxing-CPP. */ + *left = *right = 1.8f; + done = 1; + break; case BARCODE_C25INTER: /* ISO/IEC 16390:2007 Section 4.4 10X */ diff --git a/backend/tests/CMakeLists.txt b/backend/tests/CMakeLists.txt index 7a165f72..e07341b8 100644 --- a/backend/tests/CMakeLists.txt +++ b/backend/tests/CMakeLists.txt @@ -56,6 +56,7 @@ zint_add_test(common test_common) zint_add_test(composite test_composite) zint_add_test(dmatrix test_dmatrix) zint_add_test(dotcode test_dotcode) +zint_add_test(dxfilmedge test_dxfilmedge) zint_add_test(eci test_eci) zint_add_test(emf test_emf) zint_add_test(filemem test_filemem) diff --git a/backend/tests/test_dxfilmedge.c b/backend/tests/test_dxfilmedge.c new file mode 100644 index 00000000..1fb8b1b1 --- /dev/null +++ b/backend/tests/test_dxfilmedge.c @@ -0,0 +1,310 @@ +/* + libzint - the open source barcode library + Copyright (C) 2024-2025 Antoine Merino + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#include "testcommon.h" + + +static void test_encode(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int option_2; + char *data; + int ret; + + int expected_rows; + int expected_width; + char *comment; + char *expected; + }; + static const struct item data[] = { + /* DX code 1: 79, DX code 2: 7. DX Extract = 1271. DX Full: X1271X (X is any digit)*/ + /* 0*/ { BARCODE_DXFILMEDGE, -1, "79-7", 0, 2, 23, "", + "1111101010101010101011110101010011110011100101" + }, + /* 1*/ { BARCODE_DXFILMEDGE, -1, "1271", 0, 2, 23, "", + "1111101010101010101011110101010011110011100101" + }, + /* 2*/ { BARCODE_DXFILMEDGE, -1, "012710", 0, 2, 23, "", + "1111101010101010101011110101010011110011100101" + }, + /* 3*/ { BARCODE_DXFILMEDGE, -1, "112712", 0, 2, 23, "", + "1111101010101010101011110101010011110011100101" + }, + /* Lower limit: DX part 1 = 1, DX part 2 = 0*/ + /* 4*/ { BARCODE_DXFILMEDGE, -1, "1-0", 0, 2, 23, "", + "1111101010101010101011110101000000010000010101" + }, + /* 5*/ { BARCODE_DXFILMEDGE, -1, "000160", 0, 2, 23, "", + "1111101010101010101011110101000000010000010101" + }, + /* 6*/ { BARCODE_DXFILMEDGE, -1, "16", 0, 2, 23, "", + "1111101010101010101011110101000000010000010101" + }, + /* Upper limit: DX part 1 = 127, DX part 2 = 15 */ + /* 7*/ { BARCODE_DXFILMEDGE, -1, "920479/63A", 0, 2, 31, "", + "11111010101010101010101010101111010101111111011111111111000101" + }, + /* 8*/ { BARCODE_DXFILMEDGE, -1, "127-15/00A", 0, 2, 31, "", + "11111010101010101010101010101111010101111111011111111111000101" + }, + + /* 9*/ { BARCODE_DXFILMEDGE, -1, "79-7/1", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001110000010010101" + }, + /* Optional behaviour: leading zeros are accepted*/ + /* 10*/ { BARCODE_DXFILMEDGE, -1, "0079-7/001", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001110000010010101" + }, + /* Frame number */ + /* 11*/ { BARCODE_DXFILMEDGE, -1, "79-7/1", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001110000010010101" + }, + /* 12*/ { BARCODE_DXFILMEDGE, -1, "1271/1", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001110000010010101" + }, + /* 13*/ { BARCODE_DXFILMEDGE, -1, "912718/1", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001110000010010101" + }, + /* 14*/ { BARCODE_DXFILMEDGE, -1, "79-7/1A", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001110000011000101" + }, + /* 15*/ { BARCODE_DXFILMEDGE, -1, "1271/1a", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001110000011000101" + }, + /* 16*/ { BARCODE_DXFILMEDGE, -1, "212715/1A", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001110000011000101" + }, + /* Special frame numbers */ + /* 17*/ { BARCODE_DXFILMEDGE, -1, "79-7/62", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001111111100010101" + }, + /* 18*/ { BARCODE_DXFILMEDGE, -1, "79-7/S", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001111111100010101" + }, + /* 19*/ { BARCODE_DXFILMEDGE, -1, "79-7/x", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001111111100010101" + }, + /* 20*/ { BARCODE_DXFILMEDGE, -1, "79-7/62a", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001111111101000101" + }, + /* 21*/ { BARCODE_DXFILMEDGE, -1, "79-7/sA", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001111111101000101" + }, + /* 22*/ { BARCODE_DXFILMEDGE, -1, "79-7/Xa", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001111111101000101" + }, + /* 23*/ { BARCODE_DXFILMEDGE, -1, "79-7/63", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001111111110000101" + }, + /* 24*/ { BARCODE_DXFILMEDGE, -1, "79-7/k", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001111111110000101" + }, + /* 25*/ { BARCODE_DXFILMEDGE, -1, "79-7/00", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001111111110000101" + }, + /* 26*/ { BARCODE_DXFILMEDGE, -1, "79-7/63a", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001111111111010101" + }, + /* 27*/ { BARCODE_DXFILMEDGE, -1, "79-7/kA", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001111111111010101" + }, + /* 28*/ { BARCODE_DXFILMEDGE, -1, "79-7/00a", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001111111111010101" + }, + /* 29*/ { BARCODE_DXFILMEDGE, -1, "79-7/0", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001110000000000101" + }, + /* 30*/ { BARCODE_DXFILMEDGE, -1, "79-7/F", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001110000000000101" + }, + /* 31*/ { BARCODE_DXFILMEDGE, -1, "79-7/0a", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001110000001010101" + }, + /* 32*/ { BARCODE_DXFILMEDGE, -1, "79-7/fA", 0, 2, 31, "", + "11111010101010101010101010101111010101001111001110000001010101" + }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + char escaped[1024]; + char cmp_buf[4096]; + char cmp_msg[1024]; + + int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ + int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ + + testStartSymbol("test_encode", &symbol); + + for (i = 0; i < data_size; i++) { + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); + + ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + + if (p_ctx->generate) { + printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n", + i, testUtilBarcodeName(data[i].symbology), data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), + testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); + testUtilModulesPrint(symbol, " ", "\n"); + printf(" },\n"); + } else { + if (ret < ZINT_ERROR) { + int width, row; + + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); + + ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); + assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); + + if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) { + ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + + ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected); + assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected); + } + if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { + int cmp_len, ret_len; + char modules_dump[8192 + 1]; + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); + assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + + ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); + assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); + } + } + } + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + +static void test_input(const testCtx *const p_ctx) { + int debug = p_ctx->debug; + + struct item { + int symbology; + int input_mode; + char *data; + int ret; + int expected_rows; + int expected_width; + char *expected_errtxt; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { BARCODE_DXFILMEDGE, -1, "79-1/123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1002: Frame number part is too long" }, + /* 1*/ { BARCODE_DXFILMEDGE, -1, "012312365", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1003: DX information is too long" }, + /* 2*/ { BARCODE_DXFILMEDGE, -1, "12-", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1004: Wrong format for DX parts 1 and 2 (expected format: XXX-XX, digits)" }, + /* 3*/ { BARCODE_DXFILMEDGE, -1, "01234/00A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1005: DX number \"01234\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)" }, + /* 4*/ { BARCODE_DXFILMEDGE, -1, "01234/00A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1005: DX number \"01234\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)" }, + /* 5*/ { BARCODE_DXFILMEDGE, -1, "128-0/24", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1006: DX part 1 \"128\" must be between 1 and 127" }, + /* 6*/ { BARCODE_DXFILMEDGE, -1, "127-16", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1007: DX part 2 \"16\" must be between 0 and 15" }, + /* 7*/ { BARCODE_DXFILMEDGE, -1, "79-2/-1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1008: Frame number \"-1\"should be between 0 and 63" }, + /* 8*/ { BARCODE_DXFILMEDGE, -1, "79-2/64", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1008: Frame number \"64\"should be between 0 and 63" }, + /* 9*/ { BARCODE_DXFILMEDGE, -1, "79-2-1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1009: The \'-\' is used to separate DX parts 1 and 2, and should be used no more than once" }, + /* 10*/ { BARCODE_DXFILMEDGE, -1, "110-2/2B", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1012: Frame number \"2B\" is invalid (expected digits, eventually followed by \'A\')" }, + /* 11*/ { BARCODE_DXFILMEDGE, -1, "099990/123A", ZINT_ERROR_TOO_LONG, -1, -1, "Error 1013: Input length 11 too long (maximum 10)" }, + /* 12*/ { BARCODE_DXFILMEDGE, -1, "0123123/1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1014: DX information is too long" }, + /* 13*/ { BARCODE_DXFILMEDGE, -1, "120481", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1015: DX extract \"2048\" must be between 16 and 2047" }, + /* 14*/ { BARCODE_DXFILMEDGE, -1, "100151", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1015: DX extract \"15\" must be between 16 and 2047" }, + /* 15*/ { BARCODE_DXFILMEDGE, -1, "15", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1015: DX extract \"15\" must be between 16 and 2047" }, + /* 16*/ { BARCODE_DXFILMEDGE, -1, "12-12A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1016: Invalid character at position 6 in DX info (digits and \'-\' character only)" }, + /* 17*/ { BARCODE_DXFILMEDGE, -1, "012X", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1016: Invalid character at position 4 in DX info (digits and \'-\' character only)" }, + /* 18*/ { BARCODE_DXFILMEDGE, -1, "110-2/", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1017: Frame number indicator \"/\" at position 6, but frame number is empty" }, + /* 19*/ { BARCODE_DXFILMEDGE, -1, "/", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1018: Invalid character \"/\", DX code should start with a number" }, + /* 20*/ { BARCODE_DXFILMEDGE, -1, "-12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1018: Invalid character \"-\", DX code should start with a number" }, + /* 21*/ { BARCODE_DXFILMEDGE, -1, "X1234X", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1018: Invalid character \"X\", DX code should start with a number" }, + }; + + + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + struct zint_symbol *symbol = NULL; + + testStartSymbol("test_input", &symbol); + + for (i = 0; i < data_size; i++) { + + if (testContinue(p_ctx, i)) continue; + + symbol = ZBarcode_Create(); + assert_nonnull(symbol, "Symbol not created\n"); + + length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, -1 /*output_options*/, data[i].data, -1, debug); + + ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt); + assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt); + + if (ret < ZINT_ERROR) { + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); + } + + ZBarcode_Delete(symbol); + } + + testFinish(); +} + + +int main(int argc, char *argv[]) { + + testFunction funcs[] = { /* name, func */ + { "test_input", test_input }, + { "test_encode", test_encode }, + }; + + testRun(argc, argv, funcs, ARRAY_SIZE(funcs)); + + testReport(); + + return 0; +} + diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index 276fa2a9..762b70c8 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -191,8 +191,8 @@ static void test_checks(const testCtx *const p_ctx) { /*127*/ { 126, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, /*128*/ { 127, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, /*129*/ { 127, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*130*/ { 147, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*131*/ { 147, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*130*/ { 148, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*131*/ { 148, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, /*132*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, /*133*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, /*134*/ { BARCODE_CODE128, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 }, @@ -964,6 +964,7 @@ static void test_cap_compliant_height(const testCtx *const p_ctx) { case BARCODE_DBAR_EXPSTK_CC: case BARCODE_CHANNEL: case BARCODE_BC412: + case BARCODE_DXFILMEDGE: /* TODO: what's this? */ assert_equal(uret, ZINT_CAP_COMPLIANT_HEIGHT, "symbol_id %d (%s) uret 0x%X != ZINT_CAP_COMPLIANT_HEIGHT\n", symbol_id, testUtilBarcodeName(symbol_id), uret); break; default: @@ -1549,6 +1550,7 @@ static int test_prev_ZBarcode_BarcodeName(int symbol_id, char name[32]) { { "BARCODE_ULTRA", BARCODE_ULTRA, 144 }, { "BARCODE_RMQR", BARCODE_RMQR, 145 }, { "BARCODE_BC412", BARCODE_BC412, 146 }, + { "BARCODE_DXFILMEDGE", BARCODE_DXFILMEDGE, 147 }, }; name[0] = '\0'; diff --git a/backend/zint.h b/backend/zint.h index c507a0e5..77779c49 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -274,7 +274,8 @@ extern "C" { #define BARCODE_ULTRA 144 /* Ultracode */ #define BARCODE_RMQR 145 /* Rectangular Micro QR Code (rMQR) */ #define BARCODE_BC412 146 /* IBM BC412 (SEMI T1-95) */ -#define BARCODE_LAST 146 /* Max barcode number marker, not barcode */ +#define BARCODE_DXFILMEDGE 147 /* DX Film Edge Barcode on 35mm and APS films*/ +#define BARCODE_LAST 147 /* Max barcode number marker, not barcode */ /* Output options (`symbol->output_options`) */ #define BARCODE_BIND_TOP 0x00001 /* Boundary bar above the symbol only (not below), does not affect stacking */ diff --git a/backend_qt/backend_qt.pro b/backend_qt/backend_qt.pro index c6578491..6777a32f 100644 --- a/backend_qt/backend_qt.pro +++ b/backend_qt/backend_qt.pro @@ -85,6 +85,7 @@ SOURCES += ../backend/2of5.c \ ../backend/composite.c \ ../backend/dmatrix.c \ ../backend/dotcode.c \ + ../backend/dxfilmedge.c \ ../backend/eci.c \ ../backend/emf.c \ ../backend/filemem.c \ diff --git a/backend_qt/backend_vc8.pro b/backend_qt/backend_vc8.pro index 36180d04..becfbbf6 100644 --- a/backend_qt/backend_vc8.pro +++ b/backend_qt/backend_vc8.pro @@ -68,6 +68,7 @@ SOURCES += ../backend/2of5.c \ ../backend/composite.c \ ../backend/dmatrix.c \ ../backend/dotcode.c \ + ../backend/dxfilmedge.c \ ../backend/eci.c \ ../backend/emf.c \ ../backend/gridmtx.c \ diff --git a/backend_tcl/configure b/backend_tcl/configure index 8c3c2891..cb021f0d 100755 --- a/backend_tcl/configure +++ b/backend_tcl/configure @@ -5450,6 +5450,7 @@ printf "%s\n" "$ac_cv_c_bigendian" >&6; } ../backend/dllversion.c ../backend/dmatrix.c ../backend/dotcode.c + ../backend/dxfilmedge.c ../backend/eci.c ../backend/emf.c ../backend/filemem.c diff --git a/backend_tcl/configure.ac b/backend_tcl/configure.ac index cb973b94..bb4b933d 100644 --- a/backend_tcl/configure.ac +++ b/backend_tcl/configure.ac @@ -88,6 +88,7 @@ TEA_ADD_SOURCES([ ../backend/dllversion.c ../backend/dmatrix.c ../backend/dotcode.c + ../backend/dxfilmedge.c ../backend/eci.c ../backend/emf.c ../backend/filemem.c diff --git a/frontend/main.c b/frontend/main.c index 5949a52e..ead5685c 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -116,7 +116,7 @@ static void types(void) { "71 DATAMATRIX Data Matrix 144 ULTRA Ultracode\n" "72 EAN14 EAN-14 145 RMQR Rectangular Micro QR\n" "73 VIN Vehicle Information No. 146 BC412 BC412\n", stdout); - fputs("74 CODABLOCKF Codablock-F\n", stdout); + fputs("74 CODABLOCKF Codablock-F 147 DXFILMEDGE DX Film Edge\n", stdout); } /* Output version information */ @@ -480,6 +480,7 @@ static int get_barcode_name(const char *barcode_name) { { BARCODE_DPD, "dpd" }, { BARCODE_DPIDENT, "dpident" }, { BARCODE_DPLEIT, "dpleit" }, + { BARCODE_DXFILMEDGE, "dxfilmedge" }, { BARCODE_EANX, "ean" }, /* Synonym */ { BARCODE_GS1_128, "ean128" }, /* Synonym */ { BARCODE_GS1_128_CC, "ean128cc" }, /* Synonym */ diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index 5eb351af..38af14c2 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -145,6 +145,7 @@ static const struct bstyle_item bstyle_items[] = { { QSL("DotCode"), BARCODE_DOTCODE }, { QSL("DPD Code"), BARCODE_DPD }, { QSL("Dutch Post KIX"), BARCODE_KIX }, + { QSL("DX Film Edge"), BARCODE_DXFILMEDGE }, { QSL("EAN (EAN-2, EAN-5, EAN-8 and EAN-13) (ISO 15420)"), BARCODE_EANX }, { QSL("EAN-14"), BARCODE_EAN14 }, { QSL("FIM (Facing Identification Mark)"), BARCODE_FIM }, @@ -295,7 +296,6 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags fl) /* Prior to Qt 5.10 comboboxes have display issues when filtered (scrollers not accounted for), so disable */ filter_bstyle->hide(); #endif - bstyle->setCurrentIndex(settings.value(QSL("studio/symbology"), 12).toInt()); load_settings(settings); diff --git a/win32/libzint.vcxproj b/win32/libzint.vcxproj index 93e4e1d0..57fc894a 100644 --- a/win32/libzint.vcxproj +++ b/win32/libzint.vcxproj @@ -137,6 +137,7 @@ + diff --git a/win32/vs2008/libzint.vcproj b/win32/vs2008/libzint.vcproj index e7e7c908..7a6ff52a 100644 --- a/win32/vs2008/libzint.vcproj +++ b/win32/vs2008/libzint.vcproj @@ -256,6 +256,10 @@ + + + diff --git a/win32/vs2017/libzint.vcxproj b/win32/vs2017/libzint.vcxproj index 04100810..7388b398 100644 --- a/win32/vs2017/libzint.vcxproj +++ b/win32/vs2017/libzint.vcxproj @@ -137,6 +137,7 @@ + diff --git a/win32/vs2019/libzint.vcxproj b/win32/vs2019/libzint.vcxproj index 84717cdb..7f17a2be 100644 --- a/win32/vs2019/libzint.vcxproj +++ b/win32/vs2019/libzint.vcxproj @@ -137,6 +137,7 @@ + diff --git a/win32/zint_cmdline_vc6/zint_cmdline_vc6.dsp b/win32/zint_cmdline_vc6/zint_cmdline_vc6.dsp index d4b13c9b..08aae636 100644 --- a/win32/zint_cmdline_vc6/zint_cmdline_vc6.dsp +++ b/win32/zint_cmdline_vc6/zint_cmdline_vc6.dsp @@ -148,6 +148,10 @@ SOURCE=..\..\backend\dotcode.c # End Source File # Begin Source File +SOURCE=..\..\backend\dxfilmedge.c +# End Source File +# Begin Source File + SOURCE=..\..\backend\eci.c # End Source File # Begin Source File From fe3907c2cb2fb765f0c778df8c953a738df555af Mon Sep 17 00:00:00 2001 From: gitlost Date: Mon, 23 Dec 2024 20:52:08 +0000 Subject: [PATCH 2/7] DXFILMEDGE: various tweaks: change # 147 -> 127 to use up barcode # holes; use "common.h" funcs `str_to_uppercase()` -> `to_upper()`, `count_char_occurrences()` -> `chr_cnt()`; prefix defines with `DX_` and funcs with `dx_`; `ZINT_DEBUG_PRINT` -> `symbol->debug & ZINT_DEBUG_PRINT`; bools to ints; use `posn()` to check for slash (returns length); restrict line lengths to 118; suppress some clang-tidy warnings; normalize some error messages; check for single "A" if any (`sscanf()`); use compliant height default; some whitespace formatting; Tcl: add DXFILMEDGE support docs: document DXFILMEDGE; update to latest pandoc test suite: ZXingCPP: DXFILMEDGE support --- ChangeLog | 3 +- README | 13 +- backend/dxfilmedge.c | 256 +++++++++++++++++--------------- backend/library.c | 11 +- backend/output.c | 2 +- backend/tests/test_dxfilmedge.c | 81 ++++------ backend/tests/test_library.c | 57 ++++--- backend/tests/testcommon.c | 83 ++++++++++- backend/zint.h | 4 +- backend_tcl/configure | 2 +- backend_tcl/win/makefile.vc | 1 + backend_tcl/zint.c | 6 +- docs/README | 12 +- docs/images/dxfilmedge.svg | 9 ++ docs/manual.html | 46 +++++- docs/manual.pmd | 35 ++++- docs/manual.txt | 36 ++++- docs/zint.1 | 4 +- docs/zint.1.pmd | 2 +- docs/zint_images.sh | 3 +- frontend/main.c | 40 ++--- 21 files changed, 451 insertions(+), 255 deletions(-) create mode 100644 docs/images/dxfilmedge.svg diff --git a/ChangeLog b/ChangeLog index f64680b8..9991dedd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -Version 2.13.0.9 (dev) not released yet (2024-11-23) +Version 2.13.0.9 (dev) not released yet (2024-12-23) ==================================================== **Incompatible changes** @@ -51,6 +51,7 @@ Changes touch add-on TODO: revisit when standard clarified - manual: make explicit that AI "(00)" and "(01)" prefixes added by Zint are HRT-only; clarify Codablock-F length maximum & add examples +- add DXFILMEDGE (MR #159, props Antoine Mérino) Bugs ---- diff --git a/README b/README index f5e30e7c..033782e1 100644 --- a/README +++ b/README @@ -38,12 +38,13 @@ Deutsche Post Leitcode Telepen DotCode Telepen Numeric DPD Code UK Plessey Dutch Post KIX Ultracode -EAN (EAN-2, EAN-5, EAN-8 and EAN-13) UPC-A -EAN-14 UPC-E -FIM (Facing Identification Mark) UPNQR -Flattermarken UPU S10 -Grid Matrix USPS Intelligent Mail (OneCode) -GS1 Composite (EAN/UPC/DataBar/GS-128) VIN (Vehicle Identification Number) +DX Film Edge Barcode UPC-A +EAN (EAN-2, EAN-5, EAN-8 and EAN-13) UPC-E +EAN-14 UPNQR +FIM (Facing Identification Mark) UPU S10 +Flattermarken USPS Intelligent Mail (OneCode) +Grid Matrix VIN (Vehicle Identification Number) +GS1 Composite (EAN/UPC/DataBar/GS-128) Output can be saved as BMP, EMF, EPS, GIF, PCX, PNG, SVG or TIF. diff --git a/backend/dxfilmedge.c b/backend/dxfilmedge.c index 1a5c25c0..dd76f9ec 100644 --- a/backend/dxfilmedge.c +++ b/backend/dxfilmedge.c @@ -1,7 +1,7 @@ /* dxfilmedge.c - Handles DX Film Edge symbology */ /* libzint - the open source barcode library - Copyright (C) 2024-2025 Antoine Merino + Copyright (C) 2024 Antoine Merino Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -40,19 +40,19 @@ * https://patents.google.com/patent/US4965628A/en */ -#include -#include +#include #include -#include #include "common.h" -#define DEBUG_STR_LEN 20 +#define DX_DEBUG_STR_LEN 20 /* Max length of the DX info part. Include the \0. Eg: "018500\0", "150-10\0" */ -#define MAX_DX_INFO_LENGTH 7 +#define DX_MAX_DX_INFO_LENGTH 6 +#define DX_MAX_DX_INFO_MAX_STR "6" /* String version of above */ /* Max length of the frame info part. Eg: "00A\0", "23A\0" */ -#define MAX_FRAME_INFO_LENGTH 4 +#define DX_MAX_FRAME_INFO_LENGTH 3 +#define DX_MAX_FRAME_INFO_MAX_STR "3" /* String version of above */ -void int_to_binary(int value, int width, char *output) { +static void dx_int_to_binary(const int value, const int width, char *output) { int i; for (i = 0; i < width; i++) { output[width - 1 - i] = (value & (1 << i)) ? '1' : '0'; @@ -60,134 +60,133 @@ void int_to_binary(int value, int width, char *output) { output[width] = '\0'; } -void str_to_uppercase(char *str) { - int i; - for (i = 0; str[i] != '\0'; i++) { - str[i] = toupper(str[i]); - } -} - -int count_char_occurrences(const char *str, char target) { - int i, count = 0; - for (i = 0; str[i] != '\0'; i++) { - if (str[i] == target) { - count++; - if (count > 1) { - return count; - } - } - } - return count; -} - - -int parse_dx_code(struct zint_symbol *symbol, const char *source, char *binary_output, int *output_length, bool *has_frame_info) { - +static int dx_parse_code(struct zint_symbol *symbol, const unsigned char *source, const int length, + char *binary_output, int *output_length, int *has_frame_info) { int i; int parity_bit = 0; int dx_extract = -1, dx_code_1 = -1, dx_code_2 = -1, frame_number = -1; char binary_dx_code_1[8], binary_dx_code_2[5], binary_frame_number[7]; char half_frame_flag = '\0'; - char dx_info[MAX_DX_INFO_LENGTH] = "\0"; - char frame_info[MAX_FRAME_INFO_LENGTH] = "\0"; - char *detected_char = strchr((const char *)(source), ' '); + char dx_info[DX_MAX_DX_INFO_LENGTH + 1] = "\0"; + char frame_info[DX_MAX_FRAME_INFO_LENGTH + 1] = "\0"; + int dx_length; const char *frame_start; + const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; - *has_frame_info = false; + *has_frame_info = 0; /* All codes should start with a digit*/ - if (not_sane(IS_NUM_F, (unsigned char *)source, 1)){ - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1018, "Invalid character \"%c\", DX code should start with a number", source[0]); + if (!z_isdigit(source[0])) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 970, + "Invalid first character \"%c\", DX code should start with a number", source[0]); } /* Check if there is the '/' separator, which indicates the frame number is present. */ - detected_char = strchr((const char *)(source), '/'); - if (detected_char){ + dx_length = posn((const char *) source, '/'); + if (dx_length != -1) { /* Split the DX information from the frame number */ - size_t dx_length = detected_char - (char *)source; - if (dx_length >= MAX_DX_INFO_LENGTH){ - return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 1014, "DX information is too long"); + int frame_info_len; + if (dx_length > DX_MAX_DX_INFO_LENGTH) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 971, + "DX information length %d too long (maximum " DX_MAX_DX_INFO_MAX_STR ")", dx_length); } - strncat(dx_info, source, dx_length); + ustrncat(dx_info, source, dx_length); dx_info[dx_length] = '\0'; - frame_start = detected_char + 1; - if (strlen(frame_start) >= MAX_FRAME_INFO_LENGTH) { - return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 1002, "Frame number part is too long"); + frame_start = (const char *) source + dx_length + 1; + frame_info_len = (int) strlen(frame_start); + if (frame_info_len > DX_MAX_FRAME_INFO_LENGTH) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 972, + "Frame number part length %d too long (maximum " DX_MAX_FRAME_INFO_MAX_STR ")", frame_info_len); } - strncat(frame_info, frame_start, sizeof(frame_info) - 1); - *has_frame_info = true; - str_to_uppercase(frame_info); - if ((i = not_sane(IS_UPR_F | IS_NUM_F | IS_MNS_F, (unsigned char *)(frame_info), strlen(frame_info)))){ - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1012, "Frame number \"%s\" is invalid (expected digits, eventually followed by \'A\')", frame_info); + ustrcpy(frame_info, frame_start); + *has_frame_info = 1; + to_upper((unsigned char *) frame_info, frame_info_len); + if (not_sane(IS_UPR_F | IS_NUM_F | IS_MNS_F, (const unsigned char *) frame_info, frame_info_len)) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 973, + "Frame number \"%s\" is invalid (expected digits, optionally followed by a single \"A\")", + frame_info); } - } - else{ + } else { /* No "/" found, store the entire input in dx_info */ - if (strlen(source) >= MAX_DX_INFO_LENGTH) { - return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 1003, "DX information is too long"); + dx_length = length; + if (dx_length > DX_MAX_DX_INFO_LENGTH) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 974, + "DX information length %d too long (maximum " DX_MAX_DX_INFO_MAX_STR ")", dx_length); } - strncat(dx_info, source, sizeof(dx_info) - 1); + ustrcpy(dx_info, source); } - if ((i = not_sane(IS_NUM_F | IS_MNS_F, (unsigned char *)dx_info, strlen(dx_info)))){ - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1016, "Invalid character at position %d in DX info (digits and \'-\' character only)", i); + if ((i = not_sane(IS_NUM_F | IS_MNS_F, (const unsigned char *) dx_info, dx_length))) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 975, + "Invalid character at position %d in DX info (digits and \"-\" character only)", i); } - if (ZINT_DEBUG_PRINT) printf("\nDX info part: \"%s\", Frame info part: \"%s\"\n", dx_info, frame_info); + if (debug_print) printf("\nDX info part: \"%s\", Frame info part: \"%s\"\n", dx_info, frame_info); /* Parse the DX information */ - if (strchr(dx_info, '-')){ + if (strchr(dx_info, '-')) { /* DX code parts 1 and 2 are given directly, separated by a '-'. Eg: "79-7" */ - if (ZINT_DEBUG_PRINT) printf("DX code 1 and 2 are separated by a dash \'-\'\n"); - if (count_char_occurrences(dx_info, '-') > 1){ - return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 1009, "The \'-\' is used to separate DX parts 1 and 2, and should be used no more than once"); + if (debug_print) printf("DX code 1 and 2 are separated by a dash \"-\"\n"); + if (chr_cnt((const unsigned char *) dx_info, dx_length, '-') > 1) { + return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 976, + "The \"-\" is used to separate DX parts 1 and 2, and should be used no more than once"); } - if (sscanf(dx_info, "%d-%d", &dx_code_1, &dx_code_2) < 2){ - return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 1004, "Wrong format for DX parts 1 and 2 (expected format: XXX-XX, digits)"); + if (sscanf(dx_info, "%d-%d", &dx_code_1, &dx_code_2) < 2) { + return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 977, + "Wrong format for DX parts 1 and 2 (expected format: XXX-XX, digits)"); } - if (dx_code_1 <= 0 || dx_code_1 > 127){ - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1006, "DX part 1 \"%d\" must be between 1 and 127", dx_code_1); + if (dx_code_1 <= 0 || dx_code_1 > 127) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 978, "DX part 1 \"%d\" out of range (1 to 127)", + dx_code_1); } - if (dx_code_2 < 0 || dx_code_2 > 15){ - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1007, "DX part 2 \"%d\" must be between 0 and 15", dx_code_2); + if (dx_code_2 < 0 || dx_code_2 > 15) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 979, "DX part 2 \"%d\" out of range (0 to 15)", + dx_code_2); } - } - else{ + } else { /* DX format is either 4 digits (DX Extract, eg: 1271) or 6 digits (DX Full, eg: 012710) */ - if (ZINT_DEBUG_PRINT) printf("No \'-\' separator, computing from DX Extract (4 digits) or DX Full (6 digits)\n"); - if (strlen(dx_info) == 5 || strlen(dx_info) > 6){ - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1005, "DX number \"%s\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)", dx_info); + if (debug_print) printf("No \"-\" separator, computing from DX Extract (4 digits) or DX Full (6 digits)\n"); + if (dx_length == 5 || dx_length > 6) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 980, + "DX number \"%s\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)", dx_info); } - if (strlen(dx_info) == 6){ - if (ZINT_DEBUG_PRINT) printf("DX full format detected: %s. Removing the first and the last characters.\n", dx_info); + if (dx_length == 6) { + if (debug_print) { + printf("DX full format detected: %s. Removing the first and the last characters.\n", dx_info); + } /* Convert DX Full to DX Extract (remove first and last character) */ - for (i=0; i <= 3; ++i){ - dx_info[i] = dx_info[i+1]; + for (i = 0; i <= 3; ++i) { + dx_info[i] = dx_info[i + 1]; } dx_info[4] = '\0'; + dx_length = 4; } /* Compute the DX parts 1 and 2 from the DX extract */ - if (sscanf(dx_info, "%d", &dx_extract) < 1){ - /* Should not happen (DX info format has been checked above), but better safe than sorry */ - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1005, "DX number \"%s\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)", dx_info); + dx_extract = to_int((const unsigned char *) dx_info, dx_length); + assert(dx_extract != -1); + if (dx_extract < 16 || dx_extract > 2047) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 981, "DX extract \"%d\" out of range (16 to 2047)", + dx_extract); } - if (dx_extract < 16 || dx_extract > 2047){ - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1015, "DX extract \"%d\" must be between 16 and 2047", dx_extract); - } - if (ZINT_DEBUG_PRINT) printf("Computed DX extract: %04d\n", dx_extract); + if (debug_print) printf("Computed DX extract: %04d\n", dx_extract); dx_code_1 = dx_extract / 16; dx_code_2 = dx_extract % 16; } /* Convert components to binary strings */ - int_to_binary(dx_code_1, 7, binary_dx_code_1); - int_to_binary(dx_code_2, 4, binary_dx_code_2); + dx_int_to_binary(dx_code_1, 7, binary_dx_code_1); + dx_int_to_binary(dx_code_2, 4, binary_dx_code_2); - if (ZINT_DEBUG_PRINT) printf("%-*s%d\t-> %s\n", DEBUG_STR_LEN, "DX code 1:", dx_code_1, binary_dx_code_1); - if (ZINT_DEBUG_PRINT) printf("%-*s%d\t-> %s\n", DEBUG_STR_LEN, "DX code 2:", dx_code_2, binary_dx_code_2); + if (debug_print) { + printf("%-*s%d\t-> %s\n", DX_DEBUG_STR_LEN, "DX code 1:", dx_code_1, binary_dx_code_1); + printf("%-*s%d\t-> %s\n", DX_DEBUG_STR_LEN, "DX code 2:", dx_code_2, binary_dx_code_2); + } if (*has_frame_info) { - if (strlen(frame_info) < 1){ - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1017, "Frame number indicator \"/\" at position %d, but frame number is empty", (int)(detected_char - (char *)source + 1)); + int ret_sscanf, n; + if (strlen(frame_info) < 1) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 982, + "Frame number indicator \"/\" at position %d, but frame number is empty", + dx_length + 1); } /* Some frame numbers are special values, convert them their equivalent number */ if (strcmp(frame_info, "S") == 0 || strcmp(frame_info, "X") == 0) { @@ -204,14 +203,20 @@ int parse_dx_code(struct zint_symbol *symbol, const char *source, char *binary_o strcpy(frame_info, "0A"); } - if (sscanf(frame_info, "%d%c", &frame_number, &half_frame_flag) < 1){ - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1012, "Frame number \"%s\" is invalid (expected digits, eventually followed by \'A\')", frame_info); + ret_sscanf = sscanf(frame_info, "%d%c%n", &frame_number, &half_frame_flag, &n); + if (ret_sscanf < 1 || (ret_sscanf == 2 && frame_info[n] != '\0')) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 983, + "Frame number \"%s\" is invalid (expected digits, optionally followed by a single \"A\")", + frame_info); } - if (frame_number < 0 || frame_number > 63){ - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1008, "Frame number \"%d\"should be between 0 and 63", frame_number); + if (frame_number < 0 || frame_number > 63) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 984, "Frame number \"%d\" out of range (0 to 63)", + frame_number); + } + dx_int_to_binary(frame_number, 6, binary_frame_number); + if (debug_print) { + printf("%-*s%d\t-> %s\n", DX_DEBUG_STR_LEN, "Frame number:", frame_number, binary_frame_number); } - int_to_binary(frame_number, 6, binary_frame_number); - if (ZINT_DEBUG_PRINT) printf("%-*s%d\t-> %s\n", DEBUG_STR_LEN, "Frame number:", frame_number, binary_frame_number); } /* Build the binary output */ @@ -221,19 +226,22 @@ int parse_dx_code(struct zint_symbol *symbol, const char *source, char *binary_o strcat(binary_output, binary_dx_code_2); if (*has_frame_info) { strcat(binary_output, binary_frame_number); - if (toupper(half_frame_flag) == 'A') { - if (ZINT_DEBUG_PRINT) printf("%-*s\'%c\'\t-> 1\n", DEBUG_STR_LEN, "Half frame flag:", half_frame_flag); + to_upper((unsigned char *) &half_frame_flag, 1); + if (half_frame_flag == 'A') { + if (debug_print) printf("%-*s'%c'\t-> 1\n", DX_DEBUG_STR_LEN, "Half frame flag:", half_frame_flag); strcat(binary_output, "1"); /* Half-frame is set */ } else { - if (half_frame_flag){ - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 1012, "Frame number \"%s\" is invalid (expected digits, eventually followed by \'A\')", frame_info); + if (half_frame_flag) { + return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 985, + "Frame number \"%s\" is invalid (expected digits, optionally followed by a single \"A\")", + frame_info); } - if (ZINT_DEBUG_PRINT) printf("%-*s\'%c\'\t-> 0\n", DEBUG_STR_LEN, "Half frame flag:", half_frame_flag); + if (debug_print) printf("%-*s'%c'\t-> 0\n", DX_DEBUG_STR_LEN, "Half frame flag:", half_frame_flag); strcat(binary_output, "0"); /* Half-frame is NOT set */ } strcat(binary_output, "0"); /* Separator between half frame flag and parity bit*/ } - + /* Parity bit */ for (i = 6; binary_output[i] != '\0'; i++) { if (binary_output[i] == '1') { @@ -241,56 +249,56 @@ int parse_dx_code(struct zint_symbol *symbol, const char *source, char *binary_o } } parity_bit %= 2; - if (ZINT_DEBUG_PRINT) printf("%-*s%s\t-> %d\n", DEBUG_STR_LEN, "Parity bit:", parity_bit?"yes":"no", parity_bit); - if (parity_bit){ - strcat(binary_output, "1"); + if (debug_print) { + printf("%-*s%s\t-> %d\n", DX_DEBUG_STR_LEN, "Parity bit:", parity_bit ? "yes" : "no", parity_bit); } - else{ + if (parity_bit) { + strcat(binary_output, "1"); + } else { strcat(binary_output, "0"); } - + strcat(binary_output, "0101"); /* Stop pattern */ - *output_length = strlen(binary_output); + *output_length = (int) strlen(binary_output); return 0; } - -INTERNAL int dxfilmedge(struct zint_symbol *symbol, char source[], int length) { +INTERNAL int dxfilmedge(struct zint_symbol *symbol, unsigned char source[], int length) { int i; int writer = 0; int error_number = 0; char char_data[32]; int data_length; - bool has_frame_info; + int has_frame_info; const char long_clock_pattern[] = "1111101010101010101010101010111"; const char short_clock_pattern[] = "11111010101010101010111"; const char *clock_pattern; int clock_length; int parse_result = -1; + const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; if (length > 10) { - return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 1013, "Input length %d too long (maximum 10)", length); + return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 986, "Input length %d too long (maximum 10)", length); } - parse_result = parse_dx_code(symbol, source, char_data, &data_length, &has_frame_info); - if (parse_result != 0){ - if (ZINT_DEBUG_PRINT) printf("Error %s\n\n", symbol->errtxt); + parse_result = dx_parse_code(symbol, source, length, char_data, &data_length, &has_frame_info); + if (parse_result != 0) { + if (debug_print) printf("Error %s\n\n", symbol->errtxt); return parse_result; } /* Clock signal is longer if the frame number is provided */ - if (has_frame_info){ + if (has_frame_info) { clock_pattern = long_clock_pattern; clock_length = sizeof(long_clock_pattern) -1; - } - else{ + } else { clock_pattern = short_clock_pattern; clock_length = sizeof(short_clock_pattern) -1; } - + /* First row: clock pattern */ for (i = 0; i < clock_length; i++) { if (clock_pattern[i] == '1') { @@ -313,7 +321,7 @@ INTERNAL int dxfilmedge(struct zint_symbol *symbol, char source[], int length) { } writer++; } - symbol->rows = 2; + symbol->rows = 2; symbol->width = clock_length; if (symbol->output_options & COMPLIANT_HEIGHT) { @@ -324,7 +332,13 @@ INTERNAL int dxfilmedge(struct zint_symbol *symbol, char source[], int length) { const float min_row_height = 2.2f; const float max_height = 7.5f; error_number = set_height(symbol, min_row_height, default_height, max_height, 0 /*no_errtxt*/); + } else { + /* Using compliant height as default as no backwards compatibility to consider */ + const float default_height = 6.0f; + (void) set_height(symbol, 0.0f, default_height, 0.0f, 1 /*no_errtxt*/); } return error_number; } + +/* vim: set ts=4 sw=4 et : */ diff --git a/backend/library.c b/backend/library.c index 6f8350d6..78f24e01 100644 --- a/backend/library.c +++ b/backend/library.c @@ -578,11 +578,11 @@ static const barcode_src_func_t barcode_src_funcs[BARCODE_LAST + 1] = { NULL, NULL, NULL, NULL, NULL, /*110-114*/ NULL, NULL, NULL, NULL, mailmark_2d, /*115-119*/ upu_s10, mailmark_4s, NULL, NULL, NULL, /*120-124*/ - NULL, NULL, NULL, azrune, code32, /*125-129*/ + NULL, NULL, dxfilmedge, azrune, code32, /*125-129*/ composite, composite, composite, composite, composite, /*130-134*/ composite, composite, composite, composite, composite, /*135-139*/ channel, NULL, NULL, upnqr, NULL, /*140-144*/ - NULL, bc412, dxfilmedge, /*145-147*/ + NULL, bc412, /*145-146*/ }; #define LIB_SEG_FUNCS_START 55 @@ -1638,11 +1638,11 @@ int ZBarcode_BarcodeName(int symbol_id, char name[32]) { "HIBC_BLOCKF", "", "HIBC_AZTEC", "", "", /*110-114*/ "DOTCODE", "HANXIN", "", "", "MAILMARK_2D", /*115-119*/ "UPU_S10", "MAILMARK_4S", "", "", "", /*120-124*/ - "", "", "", "AZRUNE", "CODE32", /*125-129*/ + "", "", "DXFILMEDGE", "AZRUNE", "CODE32", /*125-129*/ "EANX_CC", "GS1_128_CC", "DBAR_OMN_CC", "DBAR_LTD_CC", "DBAR_EXP_CC", /*130-134*/ "UPCA_CC", "UPCE_CC", "DBAR_STK_CC", "DBAR_OMNSTK_CC", "DBAR_EXPSTK_CC", /*135-139*/ "CHANNEL", "CODEONE", "GRIDMATRIX", "UPNQR", "ULTRA", /*140-144*/ - "RMQR", "BC412", "DXFILMEDGE", /*145-147*/ + "RMQR", "BC412", /*145-146*/ }; name[0] = '\0'; @@ -1870,7 +1870,8 @@ float ZBarcode_Default_Xdim(int symbol_id) { x_dim_mm = 0.33f; /* GS1 General Standards 22.0 Section 5.12.3 Table 1 except DBAR_LTD Table 4 */ break; case BARCODE_DXFILMEDGE: - x_dim_mm = 0.403548f; /* Measured on Kodak 35mm film, a DX Film Edge with frame number with 31 symbols is 12,51 mm long*/ + /* Measured on Kodak 35mm film, a DX Film Edge with frame number with 31 symbols is 12,51 mm long */ + x_dim_mm = 0.403548f; break; /* Specific */ case BARCODE_BC412: diff --git a/backend/output.c b/backend/output.c index 44d49aaf..03ec7eda 100644 --- a/backend/output.c +++ b/backend/output.c @@ -362,7 +362,7 @@ static int out_quiet_zones(const struct zint_symbol *symbol, const int hide_text break; case BARCODE_DXFILMEDGE: - /* No known standard. Add a little horizontal space to make the detection easier. Tested with Zxing-CPP. */ + /* No known standard. Add a little horizontal space to make the detection easier. Tested with Zxing-CPP */ *left = *right = 1.8f; done = 1; break; diff --git a/backend/tests/test_dxfilmedge.c b/backend/tests/test_dxfilmedge.c index 1fb8b1b1..8100e7f4 100644 --- a/backend/tests/test_dxfilmedge.c +++ b/backend/tests/test_dxfilmedge.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2024-2025 Antoine Merino + Copyright (C) 2024 Antoine Merino Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -31,7 +31,6 @@ #include "testcommon.h" - static void test_encode(const testCtx *const p_ctx) { int debug = p_ctx->debug; @@ -47,8 +46,7 @@ static void test_encode(const testCtx *const p_ctx) { char *expected; }; static const struct item data[] = { - /* DX code 1: 79, DX code 2: 7. DX Extract = 1271. DX Full: X1271X (X is any digit)*/ - /* 0*/ { BARCODE_DXFILMEDGE, -1, "79-7", 0, 2, 23, "", + /* 0*/ { BARCODE_DXFILMEDGE, -1, "79-7", 0, 2, 23, "DX code 1: 79, DX code 2: 7. DX Extract = 1271. DX Full: X1271X (X is any digit)", "1111101010101010101011110101010011110011100101" }, /* 1*/ { BARCODE_DXFILMEDGE, -1, "1271", 0, 2, 23, "", @@ -60,8 +58,7 @@ static void test_encode(const testCtx *const p_ctx) { /* 3*/ { BARCODE_DXFILMEDGE, -1, "112712", 0, 2, 23, "", "1111101010101010101011110101010011110011100101" }, - /* Lower limit: DX part 1 = 1, DX part 2 = 0*/ - /* 4*/ { BARCODE_DXFILMEDGE, -1, "1-0", 0, 2, 23, "", + /* 4*/ { BARCODE_DXFILMEDGE, -1, "1-0", 0, 2, 23, "Lower limit: DX part 1 = 1, DX part 2 = 0", "1111101010101010101011110101000000010000010101" }, /* 5*/ { BARCODE_DXFILMEDGE, -1, "000160", 0, 2, 23, "", @@ -70,23 +67,19 @@ static void test_encode(const testCtx *const p_ctx) { /* 6*/ { BARCODE_DXFILMEDGE, -1, "16", 0, 2, 23, "", "1111101010101010101011110101000000010000010101" }, - /* Upper limit: DX part 1 = 127, DX part 2 = 15 */ - /* 7*/ { BARCODE_DXFILMEDGE, -1, "920479/63A", 0, 2, 31, "", + /* 7*/ { BARCODE_DXFILMEDGE, -1, "920479/63A", 0, 2, 31, "Upper limit: DX part 1 = 127, DX part 2 = 15", "11111010101010101010101010101111010101111111011111111111000101" }, /* 8*/ { BARCODE_DXFILMEDGE, -1, "127-15/00A", 0, 2, 31, "", "11111010101010101010101010101111010101111111011111111111000101" }, - /* 9*/ { BARCODE_DXFILMEDGE, -1, "79-7/1", 0, 2, 31, "", "11111010101010101010101010101111010101001111001110000010010101" }, - /* Optional behaviour: leading zeros are accepted*/ - /* 10*/ { BARCODE_DXFILMEDGE, -1, "0079-7/001", 0, 2, 31, "", + /* 10*/ { BARCODE_DXFILMEDGE, -1, "0079-7/001", 0, 2, 31, "Optional behaviour: leading zeros are accepted", "11111010101010101010101010101111010101001111001110000010010101" }, - /* Frame number */ - /* 11*/ { BARCODE_DXFILMEDGE, -1, "79-7/1", 0, 2, 31, "", + /* 11*/ { BARCODE_DXFILMEDGE, -1, "79-7/1", 0, 2, 31, "Frame number", "11111010101010101010101010101111010101001111001110000010010101" }, /* 12*/ { BARCODE_DXFILMEDGE, -1, "1271/1", 0, 2, 31, "", @@ -104,8 +97,7 @@ static void test_encode(const testCtx *const p_ctx) { /* 16*/ { BARCODE_DXFILMEDGE, -1, "212715/1A", 0, 2, 31, "", "11111010101010101010101010101111010101001111001110000011000101" }, - /* Special frame numbers */ - /* 17*/ { BARCODE_DXFILMEDGE, -1, "79-7/62", 0, 2, 31, "", + /* 17*/ { BARCODE_DXFILMEDGE, -1, "79-7/62", 0, 2, 31, "Special frame numbers", "11111010101010101010101010101111010101001111001111111100010101" }, /* 18*/ { BARCODE_DXFILMEDGE, -1, "79-7/S", 0, 2, 31, "", @@ -162,7 +154,6 @@ static void test_encode(const testCtx *const p_ctx) { char cmp_buf[4096]; char cmp_msg[1024]; - int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ testStartSymbol("test_encode", &symbol); @@ -195,14 +186,6 @@ static void test_encode(const testCtx *const p_ctx) { ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); - if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) { - ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); - assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); - - ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected); - assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", - i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected); - } if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { int cmp_len, ret_len; char modules_dump[8192 + 1]; @@ -237,31 +220,31 @@ static void test_input(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_DXFILMEDGE, -1, "79-1/123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1002: Frame number part is too long" }, - /* 1*/ { BARCODE_DXFILMEDGE, -1, "012312365", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1003: DX information is too long" }, - /* 2*/ { BARCODE_DXFILMEDGE, -1, "12-", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1004: Wrong format for DX parts 1 and 2 (expected format: XXX-XX, digits)" }, - /* 3*/ { BARCODE_DXFILMEDGE, -1, "01234/00A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1005: DX number \"01234\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)" }, - /* 4*/ { BARCODE_DXFILMEDGE, -1, "01234/00A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1005: DX number \"01234\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)" }, - /* 5*/ { BARCODE_DXFILMEDGE, -1, "128-0/24", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1006: DX part 1 \"128\" must be between 1 and 127" }, - /* 6*/ { BARCODE_DXFILMEDGE, -1, "127-16", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1007: DX part 2 \"16\" must be between 0 and 15" }, - /* 7*/ { BARCODE_DXFILMEDGE, -1, "79-2/-1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1008: Frame number \"-1\"should be between 0 and 63" }, - /* 8*/ { BARCODE_DXFILMEDGE, -1, "79-2/64", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1008: Frame number \"64\"should be between 0 and 63" }, - /* 9*/ { BARCODE_DXFILMEDGE, -1, "79-2-1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1009: The \'-\' is used to separate DX parts 1 and 2, and should be used no more than once" }, - /* 10*/ { BARCODE_DXFILMEDGE, -1, "110-2/2B", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1012: Frame number \"2B\" is invalid (expected digits, eventually followed by \'A\')" }, - /* 11*/ { BARCODE_DXFILMEDGE, -1, "099990/123A", ZINT_ERROR_TOO_LONG, -1, -1, "Error 1013: Input length 11 too long (maximum 10)" }, - /* 12*/ { BARCODE_DXFILMEDGE, -1, "0123123/1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1014: DX information is too long" }, - /* 13*/ { BARCODE_DXFILMEDGE, -1, "120481", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1015: DX extract \"2048\" must be between 16 and 2047" }, - /* 14*/ { BARCODE_DXFILMEDGE, -1, "100151", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1015: DX extract \"15\" must be between 16 and 2047" }, - /* 15*/ { BARCODE_DXFILMEDGE, -1, "15", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1015: DX extract \"15\" must be between 16 and 2047" }, - /* 16*/ { BARCODE_DXFILMEDGE, -1, "12-12A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1016: Invalid character at position 6 in DX info (digits and \'-\' character only)" }, - /* 17*/ { BARCODE_DXFILMEDGE, -1, "012X", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1016: Invalid character at position 4 in DX info (digits and \'-\' character only)" }, - /* 18*/ { BARCODE_DXFILMEDGE, -1, "110-2/", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1017: Frame number indicator \"/\" at position 6, but frame number is empty" }, - /* 19*/ { BARCODE_DXFILMEDGE, -1, "/", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1018: Invalid character \"/\", DX code should start with a number" }, - /* 20*/ { BARCODE_DXFILMEDGE, -1, "-12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1018: Invalid character \"-\", DX code should start with a number" }, - /* 21*/ { BARCODE_DXFILMEDGE, -1, "X1234X", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 1018: Invalid character \"X\", DX code should start with a number" }, + /* 0*/ { BARCODE_DXFILMEDGE, -1, "79-1/123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 972: Frame number part length 4 too long (maximum 3)" }, + /* 1*/ { BARCODE_DXFILMEDGE, -1, "79-1/1@A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 973: Frame number \"1@A\" is invalid (expected digits, optionally followed by a single \"A\")" }, + /* 2*/ { BARCODE_DXFILMEDGE, -1, "012312365", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 974: DX information length 9 too long (maximum 6)" }, + /* 3*/ { BARCODE_DXFILMEDGE, -1, "12-", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 977: Wrong format for DX parts 1 and 2 (expected format: XXX-XX, digits)" }, + /* 4*/ { BARCODE_DXFILMEDGE, -1, "01234/00A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 980: DX number \"01234\" is incorrect; expected 4 digits (DX extract) or 6 digits (DX full)" }, + /* 5*/ { BARCODE_DXFILMEDGE, -1, "0123/0AA", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 983: Frame number \"0AA\" is invalid (expected digits, optionally followed by a single \"A\")" }, + /* 6*/ { BARCODE_DXFILMEDGE, -1, "128-0/24", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 978: DX part 1 \"128\" out of range (1 to 127)" }, + /* 7*/ { BARCODE_DXFILMEDGE, -1, "127-16", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 979: DX part 2 \"16\" out of range (0 to 15)" }, + /* 8*/ { BARCODE_DXFILMEDGE, -1, "79-2/A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 983: Frame number \"A\" is invalid (expected digits, optionally followed by a single \"A\")" }, + /* 9*/ { BARCODE_DXFILMEDGE, -1, "79-2/-1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 984: Frame number \"-1\" out of range (0 to 63)" }, + /* 10*/ { BARCODE_DXFILMEDGE, -1, "79-2/64", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 984: Frame number \"64\" out of range (0 to 63)" }, + /* 11*/ { BARCODE_DXFILMEDGE, -1, "79-2-1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 976: The \"-\" is used to separate DX parts 1 and 2, and should be used no more than once" }, + /* 12*/ { BARCODE_DXFILMEDGE, -1, "110-2/2B", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 985: Frame number \"2B\" is invalid (expected digits, optionally followed by a single \"A\")" }, + /* 13*/ { BARCODE_DXFILMEDGE, -1, "099990/123A", ZINT_ERROR_TOO_LONG, -1, -1, "Error 986: Input length 11 too long (maximum 10)" }, + /* 14*/ { BARCODE_DXFILMEDGE, -1, "0123123/1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 971: DX information length 7 too long (maximum 6)" }, + /* 15*/ { BARCODE_DXFILMEDGE, -1, "120481", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 981: DX extract \"2048\" out of range (16 to 2047)" }, + /* 16*/ { BARCODE_DXFILMEDGE, -1, "100151", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 981: DX extract \"15\" out of range (16 to 2047)" }, + /* 17*/ { BARCODE_DXFILMEDGE, -1, "15", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 981: DX extract \"15\" out of range (16 to 2047)" }, + /* 18*/ { BARCODE_DXFILMEDGE, -1, "12-12A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 975: Invalid character at position 6 in DX info (digits and \"-\" character only)" }, + /* 19*/ { BARCODE_DXFILMEDGE, -1, "012X", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 975: Invalid character at position 4 in DX info (digits and \"-\" character only)" }, + /* 20*/ { BARCODE_DXFILMEDGE, -1, "110-2/", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 982: Frame number indicator \"/\" at position 6, but frame number is empty" }, + /* 21*/ { BARCODE_DXFILMEDGE, -1, "/", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 970: Invalid first character \"/\", DX code should start with a number" }, + /* 22*/ { BARCODE_DXFILMEDGE, -1, "-12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 970: Invalid first character \"-\", DX code should start with a number" }, + /* 23*/ { BARCODE_DXFILMEDGE, -1, "X1234X", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 970: Invalid first character \"X\", DX code should start with a number" }, }; - - const int data_size = ARRAY_SIZE(data); int i, length, ret; struct zint_symbol *symbol = NULL; @@ -293,7 +276,6 @@ static void test_input(const testCtx *const p_ctx) { testFinish(); } - int main(int argc, char *argv[]) { testFunction funcs[] = { /* name, func */ @@ -308,3 +290,4 @@ int main(int argc, char *argv[]) { return 0; } +/* vim: set ts=4 sw=4 et : */ diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index 762b70c8..9bf65927 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -189,32 +189,30 @@ static void test_checks(const testCtx *const p_ctx) { /*125*/ { 125, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, /*126*/ { 126, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, /*127*/ { 126, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*128*/ { 127, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*129*/ { 127, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*130*/ { 148, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*131*/ { 148, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*132*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, - /*133*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, - /*134*/ { BARCODE_CODE128, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 }, - /*135*/ { BARCODE_CODE128, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 }, - /*136*/ { BARCODE_MAXICODE, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 }, - /*137*/ { BARCODE_MAXICODE, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 }, - /*138*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'", -1 }, - /*139*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) position 14: Bad checksum '4', expected '1'", -1 }, - /*140*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 }, - /*141*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, - /*142*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_USES_ECI, "Error 222: Encoded data includes ECI 13", -1 }, - /*143*/ { BARCODE_CODEONE, -1, "[01]12345678901231", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 512: ECI ignored for GS1 mode", -1 }, - /*144*/ { BARCODE_CODEONE, -1, "[01]12345678901231", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 512: ECI ignored for GS1 mode", -1 }, - /*145*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 512: ECI ignored for GS1 mode", -1 }, /* Warning in encoder overrides library warnings */ - /*146*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) position 14: Bad checksum '4', expected '1'", -1 }, /* But not errors */ - /*147*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 }, - /*148*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, - /*149*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_USES_ECI, "Error 222: Encoded data includes ECI 13", -1 }, - /*150*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 503: Error correction level '6' out of range (1 to 4), ignoring", -1 }, - /*151*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Error correction level '6' out of range (1 to 4)", -1 }, - /*152*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, /* ECI warning trumps all other warnings */ - /*153*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Error correction level '6' out of range (1 to 4)", -1 }, /* But not errors */ + /*128*/ { 147, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*129*/ { 147, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*130*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 }, + /*131*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 }, + /*132*/ { BARCODE_CODE128, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 }, + /*133*/ { BARCODE_CODE128, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 }, + /*134*/ { BARCODE_MAXICODE, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 }, + /*135*/ { BARCODE_MAXICODE, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 }, + /*136*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'", -1 }, + /*137*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) position 14: Bad checksum '4', expected '1'", -1 }, + /*138*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 }, + /*139*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, + /*140*/ { BARCODE_QRCODE, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_USES_ECI, "Error 222: Encoded data includes ECI 13", -1 }, + /*141*/ { BARCODE_CODEONE, -1, "[01]12345678901231", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 512: ECI ignored for GS1 mode", -1 }, + /*142*/ { BARCODE_CODEONE, -1, "[01]12345678901231", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 512: ECI ignored for GS1 mode", -1 }, + /*143*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 512: ECI ignored for GS1 mode", -1 }, /* Warning in encoder overrides library warnings */ + /*144*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) position 14: Bad checksum '4', expected '1'", -1 }, /* But not errors */ + /*145*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 }, + /*146*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, + /*147*/ { BARCODE_AZTEC, -1, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_USES_ECI, "Error 222: Encoded data includes ECI 13", -1 }, + /*148*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 503: Error correction level '6' out of range (1 to 4), ignoring", -1 }, + /*149*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Error correction level '6' out of range (1 to 4)", -1 }, + /*150*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, /* ECI warning trumps all other warnings */ + /*151*/ { BARCODE_AZTEC, 6, "ก", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Error correction level '6' out of range (1 to 4)", -1 }, /* But not errors */ }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -964,10 +962,12 @@ static void test_cap_compliant_height(const testCtx *const p_ctx) { case BARCODE_DBAR_EXPSTK_CC: case BARCODE_CHANNEL: case BARCODE_BC412: - case BARCODE_DXFILMEDGE: /* TODO: what's this? */ + case BARCODE_DXFILMEDGE: + /* Make sure ZINT_CAP_COMPLIANT_HEIGHT set for those that have it */ assert_equal(uret, ZINT_CAP_COMPLIANT_HEIGHT, "symbol_id %d (%s) uret 0x%X != ZINT_CAP_COMPLIANT_HEIGHT\n", symbol_id, testUtilBarcodeName(symbol_id), uret); break; default: + /* And not set for those that don't */ assert_zero(uret, "symbol_id %d (%s) uret 0x%X non-zero\n", symbol_id, testUtilBarcodeName(symbol_id), uret); break; } @@ -1530,7 +1530,7 @@ static int test_prev_ZBarcode_BarcodeName(int symbol_id, char name[32]) { { "", -1, 124 }, { "", -1, 125 }, { "", -1, 126 }, - { "", -1, 127 }, + { "BARCODE_DXFILMEDGE", BARCODE_DXFILMEDGE, 127 }, { "BARCODE_AZRUNE", BARCODE_AZRUNE, 128 }, { "BARCODE_CODE32", BARCODE_CODE32, 129 }, { "BARCODE_EANX_CC", BARCODE_EANX_CC, 130 }, @@ -1550,7 +1550,6 @@ static int test_prev_ZBarcode_BarcodeName(int symbol_id, char name[32]) { { "BARCODE_ULTRA", BARCODE_ULTRA, 144 }, { "BARCODE_RMQR", BARCODE_RMQR, 145 }, { "BARCODE_BC412", BARCODE_BC412, 146 }, - { "BARCODE_DXFILMEDGE", BARCODE_DXFILMEDGE, 147 }, }; name[0] = '\0'; diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index 2e57f099..3f453ca7 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -2357,7 +2357,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol { "", -1, 124, 0, 0, 0, 0, 0, }, { "", -1, 125, 0, 0, 0, 0, 0, }, { "", -1, 126, 0, 0, 0, 0, 0, }, - { "", -1, 127, 0, 0, 0, 0, 0, }, + { "", BARCODE_DXFILMEDGE, 127, 0, 0, 0, 0, 0, }, { "aztecrune", BARCODE_AZRUNE, 128, 0, 0, 0, 0, 0, }, { "code32", BARCODE_CODE32, 129, 0, 0, 0, 0, 0, }, { "ean13composite", BARCODE_EANX_CC, 130, 1, 1, 0, 72 /*linear_row_height*/, 1 /*gs1_cvt*/, }, @@ -3513,6 +3513,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int return 0; } +/* Append multiple segments together and then call `testUtilBwipp()` */ int testUtilBwippSegs(int index, struct zint_symbol *symbol, int option_1, int option_2, int option_3, const struct zint_seg segs[], const int seg_count, const char *primary, char *buffer, int buffer_size) { const int symbology = symbol->symbology; @@ -3679,6 +3680,7 @@ int testUtilHaveZXingCPPDecoder(void) { return system("zxingcppdecoder " DEV_NULL_STDERR) == 0; } +/* Helper to test whether have non-ASCII */ static int testUtilHasNonASCII(const char *source, const int length) { int i; for (i = 0; i < length; i++) { @@ -3825,7 +3827,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym { "", -1, 124, }, { "", -1, 125, }, { "", -1, 126, }, - { "", -1, 127, }, + { "DXFilmEdge", BARCODE_DXFILMEDGE, 127, }, { "", BARCODE_AZRUNE, 128, }, { "", BARCODE_CODE32, 129, }, /* Code39 based */ { "", BARCODE_EANX_CC, 130, }, @@ -3844,6 +3846,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym { "QRCode", BARCODE_UPNQR, 143, }, { "", BARCODE_ULTRA, 144, }, { "RMQRCode", BARCODE_RMQR, 145, }, + { "", BARCODE_BC412, 146, }, }; const int data_size = ARRAY_SIZE(data); @@ -3906,6 +3909,7 @@ int testUtilCanZXingCPP(int index, const struct zint_symbol *symbol, const char return testUtilZXingCPPName(index, symbol, source, length, debug) != NULL; } +/* Run "zxingcppdecoder", returning result in `buffer` */ int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source, const int length, char *bits, char *buffer, const int buffer_size, int *p_cmp_len) { static const char cmd_fmt[] = "zxingcppdecoder -textonly -format %s -width %d -bits '%s'"; @@ -4038,6 +4042,37 @@ INTERNAL int escape_char_process_test(struct zint_symbol *symbol, const unsigned static const char TECHNETIUM[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"; /* Same as SILVER (CODE39) */ +/* Helper to strip leading zeroes (as long as have at least one non-zero digit) */ +static const char *testUtilZXingCPPLeadingZeroes(const char *expected) { + const char *stripped = expected; + while (*stripped == '0') stripped++; + return z_isdigit(*stripped) ? stripped : expected; +} + +/* Helper to convert DX number from "NNNN"/"NNNNNN" format to "NNN-NN" format */ +static int textUtilZXingCPPDX(const char *expected, const int expected_len, const char *cmp_buf, char *out) { + if (strchr(cmp_buf, '-')) { + const char *stripped; + if (strchr(expected, '-') == NULL) { + if (expected_len == 6) { + const int dx = to_int((const unsigned char *) expected + 1, expected_len - 2); + sprintf(out, "%d-%d", dx / 16, dx % 16); + } else { + const int dx = to_int((const unsigned char *) expected, expected_len); + sprintf(out, "%d-%d", dx / 16, dx % 16); + } + return 1; + } + if ((stripped = testUtilZXingCPPLeadingZeroes(expected)) != expected) { + memcpy(out, stripped, expected_len - (stripped - expected)); + out[expected_len - (stripped - expected)] = '\0'; + return 1; + } + } + return 0; +} + +/* Massage result from "zxingcppdecoder" so as can compare to Zint input */ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, int cmp_len, const char *expected, int expected_len, const char *primary, char *ret_buf, int *p_ret_len) { const int symbology = symbol->symbology; @@ -4068,6 +4103,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in ? (char *) z_alloca(expected_len + 3 + 19 + 1) : NULL; char *dpd = need_dpd_prefix ? (char *) z_alloca(28 + 1) : NULL; char *pzn = symbology == BARCODE_PZN ? (char *) z_alloca(expected_len + 1 + 1) : NULL; + char *dxfe = symbology == BARCODE_DXFILMEDGE ? (char *) z_alloca(expected_len * 2 + 1) : NULL; int ret; int ret_memcmp; @@ -4226,7 +4262,6 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in expected_len++; } c25inter[expected_len] = '\0'; - printf("c25inter %s\n", c25inter); expected = c25inter; } } else if (symbology == BARCODE_DPLEIT || symbology == BARCODE_DPIDENT) { @@ -4397,6 +4432,48 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in } expected = pzn; expected_len++; + + } else if (symbology == BARCODE_DXFILMEDGE) { + const int dx_info_len = posn(expected, '/'); + if (dx_info_len != -1) { + char frame_info[20]; + assert(strlen(expected + dx_info_len + 1) < sizeof(frame_info)); + strcpy(frame_info, expected + dx_info_len + 1); + to_upper((unsigned char *) frame_info, (int) strlen(frame_info)); + if (!textUtilZXingCPPDX(expected, dx_info_len, cmp_buf, dxfe)) { + memcpy(dxfe, expected, dx_info_len); + dxfe[dx_info_len] = '\0'; + } + if (strcmp(frame_info, "S") == 0 || strcmp(frame_info, "X") == 0) { + strcat(dxfe, "/62"); + } else if (strcmp(frame_info, "SA") == 0 || strcmp(frame_info, "XA") == 0) { + strcat(dxfe, "/62A"); + } else if (strcmp(frame_info, "K") == 0 || strcmp(frame_info, "00") == 0) { + strcat(dxfe, "/63"); + } else if (strcmp(frame_info, "KA") == 0 || strcmp(frame_info, "00A") == 0) { + strcat(dxfe, "/63A"); + } else if (strcmp(frame_info, "F") == 0) { + strcat(dxfe, "/0"); + } else if (strcmp(frame_info, "FA") == 0) { + strcat(dxfe, "/0A"); + } else { + const char *stripped; + if ((stripped = testUtilZXingCPPLeadingZeroes(frame_info)) != frame_info) { + strcat(dxfe, "/"); + strcat(dxfe, stripped); + } else { + strcat(dxfe, expected + dx_info_len); + } + } + expected = dxfe; + expected_len = (int) strlen(expected); + to_upper((unsigned char *) expected, expected_len); + } else { + if (textUtilZXingCPPDX(expected, expected_len, cmp_buf, dxfe)) { + expected = dxfe; + expected_len = (int) strlen(expected); + } + } } if (ret_buf) { diff --git a/backend/zint.h b/backend/zint.h index 77779c49..c6d809b5 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -248,6 +248,7 @@ extern "C" { #define BARCODE_MAILMARK 121 /* Legacy */ /* Zint specific */ +#define BARCODE_DXFILMEDGE 127 /* DX Film Edge Barcode on 35mm and APS films */ #define BARCODE_AZRUNE 128 /* Aztec Runes */ #define BARCODE_CODE32 129 /* Code 32 */ #define BARCODE_EANX_CC 130 /* EAN Composite */ @@ -274,8 +275,7 @@ extern "C" { #define BARCODE_ULTRA 144 /* Ultracode */ #define BARCODE_RMQR 145 /* Rectangular Micro QR Code (rMQR) */ #define BARCODE_BC412 146 /* IBM BC412 (SEMI T1-95) */ -#define BARCODE_DXFILMEDGE 147 /* DX Film Edge Barcode on 35mm and APS films*/ -#define BARCODE_LAST 147 /* Max barcode number marker, not barcode */ +#define BARCODE_LAST 146 /* Max barcode number marker, not barcode */ /* Output options (`symbol->output_options`) */ #define BARCODE_BIND_TOP 0x00001 /* Boundary bar above the symbol only (not below), does not affect stacking */ diff --git a/backend_tcl/configure b/backend_tcl/configure index cb021f0d..1d33f2b8 100755 --- a/backend_tcl/configure +++ b/backend_tcl/configure @@ -5450,7 +5450,7 @@ printf "%s\n" "$ac_cv_c_bigendian" >&6; } ../backend/dllversion.c ../backend/dmatrix.c ../backend/dotcode.c - ../backend/dxfilmedge.c + ../backend/dxfilmedge.c ../backend/eci.c ../backend/emf.c ../backend/filemem.c diff --git a/backend_tcl/win/makefile.vc b/backend_tcl/win/makefile.vc index be2db55f..8b2c7442 100644 --- a/backend_tcl/win/makefile.vc +++ b/backend_tcl/win/makefile.vc @@ -51,6 +51,7 @@ PRJ_OBJS = \ $(TMP_DIR)\dllversion.obj \ $(TMP_DIR)\dmatrix.obj \ $(TMP_DIR)\dotcode.obj \ + $(TMP_DIR)\dxfilmedge.obj \ $(TMP_DIR)\eci.obj \ $(TMP_DIR)\emf.obj \ $(TMP_DIR)\filemem.obj \ diff --git a/backend_tcl/zint.c b/backend_tcl/zint.c index a1e888f3..52e8a3fb 100644 --- a/backend_tcl/zint.c +++ b/backend_tcl/zint.c @@ -1,7 +1,7 @@ /* zint_tcl.c TCL binding for zint */ /* zint - the open source tcl binding to the zint barcode library - Copyright (C) 2014-2023 Harald Oehlmann + Copyright (C) 2014-2024 Harald Oehlmann Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -176,6 +176,8 @@ - TCL 9 compatibility - support TCL buildinfo - remove the zint command on dll unload +2024-12-23 GL +- Added DXFILMEDGE */ #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) @@ -330,6 +332,7 @@ static const char *s_code_list[] = { "MailMark-2D", "UPU-S10", "MailMark-4S", + "DXFilmEdge", "AztecRunes", "Code32", "EAN-CC", @@ -432,6 +435,7 @@ static const int s_code_number[] = { BARCODE_MAILMARK_2D, BARCODE_UPU_S10, BARCODE_MAILMARK_4S, + BARCODE_DXFILMEDGE, BARCODE_AZRUNE, BARCODE_CODE32, BARCODE_EANX_CC, diff --git a/docs/README b/docs/README index aafad60b..0c3a7992 100644 --- a/docs/README +++ b/docs/README @@ -1,11 +1,11 @@ -% docs/README 2024-10-27 +% docs/README 2024-12-23 For generation of "docs/manual.pdf" and "docs/manual.txt" from "manual.pmd" using a recent version of pandoc On Ubuntu/Debian (tested on Ubuntu 22.04 and Ubuntu 24.04) - wget https://github.com/jgm/pandoc/releases/download/3.5/pandoc-3.5-1-amd64.deb - sudo dpkg -i pandoc-3.5-1-amd64.deb + wget https://github.com/jgm/pandoc/releases/download/3.6.1/pandoc-3.6.1-1-amd64.deb + sudo dpkg -i pandoc-3.6.1-1-amd64.deb For Ubuntu 22.04 (python < 3.12) sudo apt install python3-pip pip install pandoc-tablenos --user @@ -27,9 +27,9 @@ Then On Fedora (tested on Fedora Linux 38 (Workstation Edition) and Fedora Linux 40 (Workstation Edition)) - wget https://github.com/jgm/pandoc/releases/download/3.5/pandoc-3.5-linux-amd64.tar.gz - tar xf pandoc-3.5-linux-amd64.tar.gz - sudo mv -i pandoc-3.5/bin/pandoc /usr/local/bin + wget https://github.com/jgm/pandoc/releases/download/3.6.1/pandoc-3.6.1-linux-amd64.tar.gz + tar xf pandoc-3.6.1-linux-amd64.tar.gz + sudo mv -i pandoc-3.6.1/bin/pandoc /usr/local/bin sudo dnf install python3-pip pip install pandoc-tablenos --user export PATH=~/.local/bin:"$PATH" diff --git a/docs/images/dxfilmedge.svg b/docs/images/dxfilmedge.svg new file mode 100644 index 00000000..da2b3fe3 --- /dev/null +++ b/docs/images/dxfilmedge.svg @@ -0,0 +1,9 @@ + + + + Zint Generated Symbol + + + + + diff --git a/docs/manual.html b/docs/manual.html index b4a3a853..9456830b 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -260,8 +260,9 @@ } .display.math{display: block; text-align: center; margin: 0.5rem auto;} /* CSS for syntax highlighting */ + html { -webkit-text-size-adjust: 100%; } pre > code.sourceCode { white-space: pre; position: relative; } - pre > code.sourceCode > span { line-height: 1.25; } + pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } pre > code.sourceCode > span:empty { height: 1.2em; } .sourceCode { overflow: visible; } code.sourceCode > span { color: inherit; text-decoration: inherit; } @@ -272,7 +273,7 @@ } @media print { pre > code.sourceCode { white-space: pre-wrap; } - pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; } + pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } } pre.numberSource code { counter-reset: source-line 0; } @@ -332,7 +333,7 @@

Zint Barcode Generator and Zint Barcode Studio User Manual

Version 2.13.0.9

-

November 2024

+

December 2024