mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
GS1: update for new AI 4309 with latlong validator, plus new GS1
syntax dictionary format (pre-release) iso4217: new currency code 925
This commit is contained in:
parent
930f458979
commit
a48434c19c
@ -21,6 +21,7 @@ Changes
|
||||
in filenames
|
||||
- Add symbology BC412 (beta)
|
||||
- backend: use alloca() (z_alloca()) for both Unix and Windows
|
||||
- GS1: new AI 4309 with latlong checker, new currency code 925
|
||||
|
||||
Bugs
|
||||
----
|
||||
|
@ -1172,6 +1172,42 @@ static int couponposoffer(const unsigned char *data, int data_len, int offset, i
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Check WSG 84 latitude, longitude */
|
||||
static int latlong(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no,
|
||||
int *p_err_posn, char err_msg[50], const int length_only) {
|
||||
(void)max;
|
||||
|
||||
data_len -= offset;
|
||||
|
||||
if (data_len < min || (data_len && data_len < 20)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!length_only && data_len) {
|
||||
const unsigned char *d = data + offset;
|
||||
const unsigned char *const de = d + (data_len > max ? max : data_len);
|
||||
uint64_t lat = 0, lng = 0;
|
||||
|
||||
for (; d < de; d++) {
|
||||
if (de - d > 10) {
|
||||
lat *= 10;
|
||||
lat += *d - '0';
|
||||
} else {
|
||||
lng *= 10;
|
||||
lng += *d - '0';
|
||||
}
|
||||
}
|
||||
if (lat > 1800000000 || lng > 3600000000) {
|
||||
*p_err_no = 3;
|
||||
*p_err_posn = d - 1 - data + 1 - 10 * (lat > 1800000000);
|
||||
sprintf(err_msg, "Invalid %s", lat > 1800000000 ? "latitude" : "longitude");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Generated by "php backend/tools/gen_gs1_linter.php > backend/gs1_lint.h" */
|
||||
#include "gs1_lint.h"
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* GS1 AI checker generated by "backend/tools/gen_gs1_lint.php" from
|
||||
* https://raw.githubusercontent.com/bwipp/postscriptbarcode/master/contrib/development/gs1-format-spec.txt
|
||||
* standards/GS1/gs1-syntax-dictionary-2022-07-11.txt
|
||||
*/
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -31,9 +31,10 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#ifndef GS1_LINT_H
|
||||
#define GS1_LINT_H
|
||||
#ifndef Z_GS1_LINT_H
|
||||
#define Z_GS1_LINT_H
|
||||
|
||||
/* N18,csum,key (Used by SSCC) */
|
||||
static int n18_csum_key(const unsigned char *data, const int data_len,
|
||||
@ -57,8 +58,8 @@ static int n14_csum_key(const unsigned char *data, const int data_len,
|
||||
&& key(data, data_len, 0, 14, 14, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* X1..20 (Used by BATCH/LOT, SERIAL, CPV, PCN...) */
|
||||
static int x1__20(const unsigned char *data, const int data_len,
|
||||
/* X..20 (Used by BATCH/LOT, SERIAL, CPV, PCN...) */
|
||||
static int x__20(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 20
|
||||
&& cset82(data, data_len, 0, 1, 20, p_err_no, p_err_posn, err_msg);
|
||||
@ -80,29 +81,29 @@ static int n2(const unsigned char *data, const int data_len,
|
||||
&& numeric(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* X1..28 (Used by TPX) */
|
||||
static int x1__28(const unsigned char *data, const int data_len,
|
||||
/* X..28 (Used by TPX) */
|
||||
static int x__28(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 28
|
||||
&& cset82(data, data_len, 0, 1, 28, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* X1..30 (Used by ADDITIONAL ID, CUST. PART NO., SECONDARY SERIAL, REF. TO SOURCE...) */
|
||||
static int x1__30(const unsigned char *data, const int data_len,
|
||||
/* X..30 (Used by ADDITIONAL ID, CUST. PART NO., SECONDARY SERIAL, REF. TO SOURCE...) */
|
||||
static int x__30(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 30
|
||||
&& cset82(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* N1..6 (Used by MTO VARIANT) */
|
||||
static int n1__6(const unsigned char *data, const int data_len,
|
||||
/* N..6 (Used by MTO VARIANT) */
|
||||
static int n__6(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 6
|
||||
&& numeric(data, data_len, 0, 1, 6, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* N13,csum,key X0..17 (Used by GDTI) */
|
||||
static int n13_csum_key_x0__17(const unsigned char *data, const int data_len,
|
||||
/* N13,csum,key [X..17] (Used by GDTI) */
|
||||
static int n13_csum_key__x__17_(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 13 && data_len <= 30
|
||||
&& csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -113,8 +114,8 @@ static int n13_csum_key_x0__17(const unsigned char *data, const int data_len,
|
||||
&& cset82(data, data_len, 13, 0, 17, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* N13,csum,key N0..12 (Used by GCN) */
|
||||
static int n13_csum_key_n0__12(const unsigned char *data, const int data_len,
|
||||
/* N13,csum,key [N..12] (Used by GCN) */
|
||||
static int n13_csum_key__n__12_(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 13 && data_len <= 25
|
||||
&& csum(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -125,8 +126,8 @@ static int n13_csum_key_n0__12(const unsigned char *data, const int data_len,
|
||||
&& numeric(data, data_len, 13, 0, 12, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* N1..8 (Used by VAR. COUNT, COUNT) */
|
||||
static int n1__8(const unsigned char *data, const int data_len,
|
||||
/* N..8 (Used by VAR. COUNT, COUNT) */
|
||||
static int n__8(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 8
|
||||
&& numeric(data, data_len, 0, 1, 8, p_err_no, p_err_posn, err_msg);
|
||||
@ -139,15 +140,15 @@ static int n6(const unsigned char *data, const int data_len,
|
||||
&& numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* N1..15 (Used by AMOUNT, PRICE) */
|
||||
static int n1__15(const unsigned char *data, const int data_len,
|
||||
/* N..15 (Used by AMOUNT, PRICE) */
|
||||
static int n__15(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 15
|
||||
&& numeric(data, data_len, 0, 1, 15, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* N3,iso4217 N1..15 (Used by AMOUNT, PRICE) */
|
||||
static int n3_iso4217_n1__15(const unsigned char *data, const int data_len,
|
||||
/* N3,iso4217 N..15 (Used by AMOUNT, PRICE) */
|
||||
static int n3_iso4217_n__15(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 4 && data_len <= 18
|
||||
&& iso4217(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -163,8 +164,8 @@ static int n4(const unsigned char *data, const int data_len,
|
||||
&& numeric(data, data_len, 0, 4, 4, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* X1..30,key (Used by GINC, GIAI - ASSEMBLY, GIAI) */
|
||||
static int x1__30_key(const unsigned char *data, const int data_len,
|
||||
/* X..30,key (Used by GINC, GIAI - ASSEMBLY, GIAI) */
|
||||
static int x__30_key(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 30
|
||||
&& key(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -194,8 +195,8 @@ static int n13_csum_key(const unsigned char *data, const int data_len,
|
||||
&& key(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* N3,iso3166 X1..9 (Used by SHIP TO POST) */
|
||||
static int n3_iso3166_x1__9(const unsigned char *data, const int data_len,
|
||||
/* N3,iso3166 X..9 (Used by SHIP TO POST) */
|
||||
static int n3_iso3166_x__9(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 4 && data_len <= 12
|
||||
&& iso3166(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -213,24 +214,24 @@ static int n3_iso3166(const unsigned char *data, const int data_len,
|
||||
&& iso3166(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* N3..15,iso3166list (Used by COUNTRY - INITIAL PROCESS, COUNTRY - DISASSEMBLY) */
|
||||
static int n3__15_iso3166list(const unsigned char *data, const int data_len,
|
||||
/* N..15,iso3166list (Used by COUNTRY - INITIAL PROCESS, COUNTRY - DISASSEMBLY) */
|
||||
static int n__15_iso3166list(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 3 && data_len <= 15
|
||||
&& iso3166list(data, data_len, 0, 3, 15, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
&& numeric(data, data_len, 0, 3, 15, p_err_no, p_err_posn, err_msg)
|
||||
&& iso3166list(data, data_len, 0, 3, 15, p_err_no, p_err_posn, err_msg, 0);
|
||||
return data_len >= 1 && data_len <= 15
|
||||
&& iso3166list(data, data_len, 0, 1, 15, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
&& numeric(data, data_len, 0, 1, 15, p_err_no, p_err_posn, err_msg)
|
||||
&& iso3166list(data, data_len, 0, 1, 15, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* X1..3 (Used by ORIGIN SUBDIVISION, AQUATIC SPECIES) */
|
||||
static int x1__3(const unsigned char *data, const int data_len,
|
||||
/* X..3 (Used by ORIGIN SUBDIVISION, AQUATIC SPECIES) */
|
||||
static int x__3(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 3
|
||||
&& cset82(data, data_len, 0, 1, 3, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* X1..35,pcenc (Used by SHIP TO COMP, SHIP TO NAME, RTN TO COMP, RTN TO NAME...) */
|
||||
static int x1__35_pcenc(const unsigned char *data, const int data_len,
|
||||
/* X..35,pcenc (Used by SHIP TO COMP, SHIP TO NAME, RTN TO COMP, RTN TO NAME...) */
|
||||
static int x__35_pcenc(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 35
|
||||
&& pcenc(data, data_len, 0, 1, 35, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -238,8 +239,8 @@ static int x1__35_pcenc(const unsigned char *data, const int data_len,
|
||||
&& pcenc(data, data_len, 0, 1, 35, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* X1..70,pcenc (Used by SHIP TO ADD1, SHIP TO ADD2, SHIP TO SUB, SHIP TO LOC...) */
|
||||
static int x1__70_pcenc(const unsigned char *data, const int data_len,
|
||||
/* X..70,pcenc (Used by SHIP TO ADD1, SHIP TO ADD2, SHIP TO SUB, SHIP TO LOC...) */
|
||||
static int x__70_pcenc(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 70
|
||||
&& pcenc(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -256,7 +257,16 @@ static int x2_iso3166alpha2(const unsigned char *data, const int data_len,
|
||||
&& iso3166alpha2(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* N1,yesno (Used by DANGEROUS GOODS, AUTH LEAVE, SIG REQUIRED) */
|
||||
/* N20,latlong (Used by SHIP TO GEO) */
|
||||
static int n20_latlong(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len == 20
|
||||
&& latlong(data, data_len, 0, 20, 20, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
&& numeric(data, data_len, 0, 20, 20, p_err_no, p_err_posn, err_msg)
|
||||
&& latlong(data, data_len, 0, 20, 20, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* N1,yesno (Used by DANGEROUS GOODS, AUTH TO LEAVE, SIG REQUIRED) */
|
||||
static int n1_yesno(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len == 1
|
||||
@ -265,7 +275,7 @@ static int n1_yesno(const unsigned char *data, const int data_len,
|
||||
&& yesno(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* N6,yymmd0 N4,hhmm (Used by NBEF DEL DT., NAFT DEL DT.) */
|
||||
/* N6,yymmd0 N4,hhmm (Used by NOT BEF DEL DT, NOT AFT DEL DT) */
|
||||
static int n6_yymmd0_n4_hhmm(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len == 10
|
||||
@ -305,22 +315,22 @@ static int n6_yymmdd_n4_hhmm(const unsigned char *data, const int data_len,
|
||||
&& hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* N1..4 (Used by ACTIVE POTENCY) */
|
||||
static int n1__4(const unsigned char *data, const int data_len,
|
||||
/* N..4 (Used by ACTIVE POTENCY) */
|
||||
static int n__4(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 4
|
||||
&& numeric(data, data_len, 0, 1, 4, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* X1..12 (Used by CATCH AREA) */
|
||||
static int x1__12(const unsigned char *data, const int data_len,
|
||||
/* X..12 (Used by CATCH AREA) */
|
||||
static int x__12(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 12
|
||||
&& cset82(data, data_len, 0, 1, 12, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* N6,yymmdd N0..6,yymmdd (Used by HARVEST DATE) */
|
||||
static int n6_yymmdd_n0__6_yymmdd(const unsigned char *data, const int data_len,
|
||||
/* N6,yymmdd [N6],yymmdd (Used by HARVEST DATE) */
|
||||
static int n6_yymmdd__n6__yymmdd(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 6 && data_len <= 12
|
||||
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -331,22 +341,22 @@ static int n6_yymmdd_n0__6_yymmdd(const unsigned char *data, const int data_len,
|
||||
&& yymmdd(data, data_len, 6, 0, 6, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* X1..10 (Used by FISHING GEAR TYPE) */
|
||||
static int x1__10(const unsigned char *data, const int data_len,
|
||||
/* X..10 (Used by FISHING GEAR TYPE) */
|
||||
static int x__10(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 10
|
||||
&& cset82(data, data_len, 0, 1, 10, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* X1..2 (Used by PROD METHOD) */
|
||||
static int x1__2(const unsigned char *data, const int data_len,
|
||||
/* X..2 (Used by PROD METHOD) */
|
||||
static int x__2(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 2
|
||||
&& cset82(data, data_len, 0, 1, 2, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* N3,iso3166999 X1..27 (Used by PROCESSOR # s) */
|
||||
static int n3_iso3166999_x1__27(const unsigned char *data, const int data_len,
|
||||
/* N3,iso3166999 X..27 (Used by PROCESSOR # 0, PROCESSOR # 1, PROCESSOR # 2, PROCESSOR # 3...) */
|
||||
static int n3_iso3166999_x__27(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 4 && data_len <= 30
|
||||
&& iso3166999(data, data_len, 0, 3, 3, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -367,8 +377,8 @@ static int n1_x1_x1_x1_importeridx(const unsigned char *data, const int data_len
|
||||
&& importeridx(data, data_len, 3, 1, 1, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* X2 X1..28 (Used by CERT # s) */
|
||||
static int x2_x1__28(const unsigned char *data, const int data_len,
|
||||
/* X2 X..28 (Used by CERT # 1, CERT # 2, CERT # 3, CERT # 4...) */
|
||||
static int x2_x__28(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 3 && data_len <= 30
|
||||
&& cset82(data, data_len, 0, 2, 2, p_err_no, p_err_posn, err_msg)
|
||||
@ -394,8 +404,8 @@ static int n4_nonzero_n5_nonzero_n3_nonzero_n1_winding_n1(const unsigned char *d
|
||||
&& numeric(data, data_len, 13, 1, 1, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* N1,zero N13,csum,key X0..16 (Used by GRAI) */
|
||||
static int n1_zero_n13_csum_key_x0__16(const unsigned char *data, const int data_len,
|
||||
/* N1,zero N13,csum,key [X..16] (Used by GRAI) */
|
||||
static int n1_zero_n13_csum_key__x__16_(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 14 && data_len <= 30
|
||||
&& zero(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -421,8 +431,8 @@ static int n14_csum_n4_pieceoftotal(const unsigned char *data, const int data_le
|
||||
&& pieceoftotal(data, data_len, 14, 4, 4, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* X1..34,iban (Used by IBAN) */
|
||||
static int x1__34_iban(const unsigned char *data, const int data_len,
|
||||
/* X..34,iban (Used by IBAN) */
|
||||
static int x__34_iban(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 34
|
||||
&& iban(data, data_len, 0, 1, 34, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -430,8 +440,8 @@ static int x1__34_iban(const unsigned char *data, const int data_len,
|
||||
&& iban(data, data_len, 0, 1, 34, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* N8,yymmddhh N0..4,mmoptss (Used by PROD TIME) */
|
||||
static int n8_yymmddhh_n0__4_mmoptss(const unsigned char *data, const int data_len,
|
||||
/* N8,yymmddhh [N..4],mmoptss (Used by PROD TIME) */
|
||||
static int n8_yymmddhh__n__4__mmoptss(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 8 && data_len <= 12
|
||||
&& yymmddhh(data, data_len, 0, 8, 8, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -442,15 +452,15 @@ static int n8_yymmddhh_n0__4_mmoptss(const unsigned char *data, const int data_l
|
||||
&& mmoptss(data, data_len, 8, 0, 4, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* X1..50 (Used by OPTSEN) */
|
||||
static int x1__50(const unsigned char *data, const int data_len,
|
||||
/* X..50 (Used by OPTSEN) */
|
||||
static int x__50(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 50
|
||||
&& cset82(data, data_len, 0, 1, 50, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* C1..30,key (Used by CPID) */
|
||||
static int c1__30_key(const unsigned char *data, const int data_len,
|
||||
/* Y..30,key (Used by CPID) */
|
||||
static int y__30_key(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 30
|
||||
&& key(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -458,8 +468,8 @@ static int c1__30_key(const unsigned char *data, const int data_len,
|
||||
&& key(data, data_len, 0, 1, 30, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* N1..12,nozeroprefix (Used by CPID SERIAL) */
|
||||
static int n1__12_nozeroprefix(const unsigned char *data, const int data_len,
|
||||
/* N..12,nozeroprefix (Used by CPID SERIAL) */
|
||||
static int n__12_nozeroprefix(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 12
|
||||
&& nozeroprefix(data, data_len, 0, 1, 12, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -467,8 +477,8 @@ static int n1__12_nozeroprefix(const unsigned char *data, const int data_len,
|
||||
&& nozeroprefix(data, data_len, 0, 1, 12, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* X1..25,csumalpha,key (Used by GMN) */
|
||||
static int x1__25_csumalpha_key(const unsigned char *data, const int data_len,
|
||||
/* X..25,csumalpha,key (Used by GMN) */
|
||||
static int x__25_csumalpha_key(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 25
|
||||
&& csumalpha(data, data_len, 0, 1, 25, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -487,22 +497,22 @@ static int n18_csum(const unsigned char *data, const int data_len,
|
||||
&& csum(data, data_len, 0, 18, 18, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* N1..10 (Used by SRIN) */
|
||||
static int n1__10(const unsigned char *data, const int data_len,
|
||||
/* N..10 (Used by SRIN) */
|
||||
static int n__10(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 10
|
||||
&& numeric(data, data_len, 0, 1, 10, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* X1..25 (Used by REF NO.) */
|
||||
static int x1__25(const unsigned char *data, const int data_len,
|
||||
/* X..25 (Used by REF NO.) */
|
||||
static int x__25(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 25
|
||||
&& cset82(data, data_len, 0, 1, 25, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* X1..70,couponcode */
|
||||
static int x1__70_couponcode(const unsigned char *data, const int data_len,
|
||||
/* X..70,couponcode */
|
||||
static int x__70_couponcode(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 70
|
||||
&& couponcode(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -510,8 +520,8 @@ static int x1__70_couponcode(const unsigned char *data, const int data_len,
|
||||
&& couponcode(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* X1..70,couponposoffer */
|
||||
static int x1__70_couponposoffer(const unsigned char *data, const int data_len,
|
||||
/* X..70,couponposoffer */
|
||||
static int x__70_couponposoffer(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 70
|
||||
&& couponposoffer(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
|
||||
@ -519,15 +529,15 @@ static int x1__70_couponposoffer(const unsigned char *data, const int data_len,
|
||||
&& couponposoffer(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg, 0);
|
||||
}
|
||||
|
||||
/* X1..70 (Used by PRODUCT URL) */
|
||||
static int x1__70(const unsigned char *data, const int data_len,
|
||||
/* X..70 (Used by PRODUCT URL) */
|
||||
static int x__70(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 70
|
||||
&& cset82(data, data_len, 0, 1, 70, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
/* X1..90 (Used by INTERNAL) */
|
||||
static int x1__90(const unsigned char *data, const int data_len,
|
||||
/* X..90 (Used by INTERNAL) */
|
||||
static int x__90(const unsigned char *data, const int data_len,
|
||||
int *p_err_no, int *p_err_posn, char err_msg[50]) {
|
||||
return data_len >= 1 && data_len <= 90
|
||||
&& cset82(data, data_len, 0, 1, 90, p_err_no, p_err_posn, err_msg);
|
||||
@ -549,7 +559,7 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
|
||||
return n14_csum_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 10 || ai == 21 || ai == 22) {
|
||||
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if ((ai >= 11 && ai <= 13) || (ai >= 15 && ai <= 17)) {
|
||||
return n6_yymmd0(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
@ -558,43 +568,43 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
|
||||
return n2(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 30 || ai == 37) {
|
||||
return n1__8(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n__8(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 90) {
|
||||
return x1__30(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__30(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai >= 91) {
|
||||
return x1__90(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__90(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
} else if (ai < 300) {
|
||||
|
||||
if (ai == 235) {
|
||||
return x1__28(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__28(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 240 || ai == 241 || ai == 250 || ai == 251) {
|
||||
return x1__30(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__30(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 242) {
|
||||
return n1__6(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n__6(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 243 || ai == 254) {
|
||||
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 253) {
|
||||
return n13_csum_key_x0__17(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n13_csum_key__x__17_(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 255) {
|
||||
return n13_csum_key_n0__12(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n13_csum_key__n__12_(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
} else if (ai < 500) {
|
||||
|
||||
if (ai == 400 || ai == 403) {
|
||||
return x1__30(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__30(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 401) {
|
||||
return x1__30_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__30_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 402) {
|
||||
return n17_csum_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
@ -603,25 +613,25 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
|
||||
return n13_csum_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 420) {
|
||||
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 421) {
|
||||
return n3_iso3166_x1__9(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n3_iso3166_x__9(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 422 || ai == 424 || ai == 426) {
|
||||
return n3_iso3166(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 423 || ai == 425) {
|
||||
return n3__15_iso3166list(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n__15_iso3166list(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 427) {
|
||||
return x1__3(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__3(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
} else if (ai < 800) {
|
||||
|
||||
if (ai >= 710 && ai <= 715) {
|
||||
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
} else if (ai < 3200) {
|
||||
@ -675,10 +685,10 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
|
||||
} else if (ai < 4000) {
|
||||
|
||||
if ((ai >= 3900 && ai <= 3909) || (ai >= 3920 && ai <= 3929)) {
|
||||
return n1__15(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n__15(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if ((ai >= 3910 && ai <= 3919) || (ai >= 3930 && ai <= 3939)) {
|
||||
return n3_iso4217_n1__15(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n3_iso4217_n__15(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai >= 3940 && ai <= 3943) {
|
||||
return n4(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
@ -690,19 +700,22 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
|
||||
} else if (ai < 4400) {
|
||||
|
||||
if (ai == 4300 || ai == 4301 || ai == 4310 || ai == 4311 || ai == 4320) {
|
||||
return x1__35_pcenc(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__35_pcenc(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if ((ai >= 4302 && ai <= 4306) || (ai >= 4312 && ai <= 4316)) {
|
||||
return x1__70_pcenc(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__70_pcenc(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 4307 || ai == 4317) {
|
||||
return x2_iso3166alpha2(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 4308 || ai == 4319) {
|
||||
return x1__30(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__30(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 4309) {
|
||||
return n20_latlong(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 4318) {
|
||||
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai >= 4321 && ai <= 4323) {
|
||||
return n1_yesno(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
@ -720,40 +733,40 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
|
||||
return n13(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 7002) {
|
||||
return x1__30(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__30(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 7003) {
|
||||
return n6_yymmdd_n4_hhmm(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 7004) {
|
||||
return n1__4(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n__4(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 7005) {
|
||||
return x1__12(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__12(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 7006) {
|
||||
return n6_yymmdd(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 7007) {
|
||||
return n6_yymmdd_n0__6_yymmdd(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n6_yymmdd__n6__yymmdd(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 7008) {
|
||||
return x1__3(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__3(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 7009) {
|
||||
return x1__10(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__10(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 7010) {
|
||||
return x1__2(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__2(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai >= 7020 && ai <= 7022) {
|
||||
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 7023) {
|
||||
return x1__30_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__30_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai >= 7030 && ai <= 7039) {
|
||||
return n3_iso3166999_x1__27(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n3_iso3166999_x__27(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 7040) {
|
||||
return n1_x1_x1_x1_importeridx(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
@ -762,10 +775,10 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
|
||||
} else if (ai < 7300) {
|
||||
|
||||
if (ai >= 7230 && ai <= 7239) {
|
||||
return x2_x1__28(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x2_x__28(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 7240) {
|
||||
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
} else if (ai < 8100) {
|
||||
@ -774,13 +787,13 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
|
||||
return n4_nonzero_n5_nonzero_n3_nonzero_n1_winding_n1(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8002 || ai == 8012) {
|
||||
return x1__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__20(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8003) {
|
||||
return n1_zero_n13_csum_key_x0__16(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n1_zero_n13_csum_key__x__16_(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8004) {
|
||||
return x1__30_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__30_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8005) {
|
||||
return n6(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
@ -789,49 +802,49 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
|
||||
return n14_csum_n4_pieceoftotal(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8007) {
|
||||
return x1__34_iban(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__34_iban(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8008) {
|
||||
return n8_yymmddhh_n0__4_mmoptss(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n8_yymmddhh__n__4__mmoptss(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8009) {
|
||||
return x1__50(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__50(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8010) {
|
||||
return c1__30_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return y__30_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8011) {
|
||||
return n1__12_nozeroprefix(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n__12_nozeroprefix(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8013) {
|
||||
return x1__25_csumalpha_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__25_csumalpha_key(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8017 || ai == 8018) {
|
||||
return n18_csum(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8019) {
|
||||
return n1__10(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return n__10(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8020) {
|
||||
return x1__25(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__25(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
} else if (ai < 8200) {
|
||||
|
||||
if (ai == 8110) {
|
||||
return x1__70_couponcode(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__70_couponcode(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8111) {
|
||||
return n4(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
if (ai == 8112) {
|
||||
return x1__70_couponposoffer(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__70_couponposoffer(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
|
||||
} else if (ai < 8300) {
|
||||
|
||||
if (ai == 8200) {
|
||||
return x1__70(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
return x__70(data, data_len, p_err_no, p_err_posn, err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -840,4 +853,4 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* GS1_LINT_H */
|
||||
#endif /* Z_GS1_LINT_H */
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -30,9 +30,10 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#ifndef ISO4217_H
|
||||
#define ISO4217_H
|
||||
#ifndef Z_ISO4217_H
|
||||
#define Z_ISO4217_H
|
||||
|
||||
/* Whether ISO 4217-1 numeric */
|
||||
static int iso4217_numeric(int cc) {
|
||||
@ -51,7 +52,7 @@ static int iso4217_numeric(int cc) {
|
||||
0x45, 0x00, 0x00, 0x01, 0x00, 0x10, 0x11, 0x11,
|
||||
0x00, 0x11, 0x11, 0x00, 0x81, 0x00, 0x04, 0x04,
|
||||
0x04, 0x01, 0x00, 0x14, 0x00, 0x00, 0x44, 0x00,
|
||||
0x20, 0x00, 0x00, 0x80, 0x7F, 0xB5, 0xFD, 0xFB,
|
||||
0x20, 0x00, 0x00, 0xA0, 0x7F, 0xB5, 0xFD, 0xFB,
|
||||
0xBF, 0xBF, 0x3F, 0x47, 0xA4,
|
||||
};
|
||||
int b = cc >> 3;
|
||||
@ -62,4 +63,4 @@ static int iso4217_numeric(int cc) {
|
||||
return codes[b] & (1 << (cc & 0x7)) ? 1 : 0;
|
||||
}
|
||||
|
||||
#endif /* ISO4217_H */
|
||||
#endif /* Z_ISO4217_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -27,7 +27,7 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include "testcommon.h"
|
||||
#include "../iso4217.h"
|
||||
@ -38,7 +38,7 @@ static void test_numeric(int index) {
|
||||
int data;
|
||||
int ret;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
struct item data[] = {
|
||||
/* 0*/ { -1, 0 },
|
||||
/* 1*/ { 0, 0 },
|
||||
@ -350,82 +350,84 @@ static void test_numeric(int index) {
|
||||
/*307*/ { 900, 0 },
|
||||
/*308*/ { 901, 1 },
|
||||
/*309*/ { 902, 0 },
|
||||
/*310*/ { 926, 0 },
|
||||
/*311*/ { 927, 1 },
|
||||
/*312*/ { 928, 1 },
|
||||
/*313*/ { 929, 1 },
|
||||
/*314*/ { 930, 1 },
|
||||
/*315*/ { 931, 1 },
|
||||
/*316*/ { 932, 1 },
|
||||
/*317*/ { 933, 1 },
|
||||
/*318*/ { 934, 1 },
|
||||
/*319*/ { 935, 0 },
|
||||
/*320*/ { 936, 1 },
|
||||
/*321*/ { 937, 0 },
|
||||
/*322*/ { 938, 1 },
|
||||
/*323*/ { 939, 0 },
|
||||
/*324*/ { 940, 1 },
|
||||
/*325*/ { 941, 1 },
|
||||
/*326*/ { 942, 0 },
|
||||
/*327*/ { 943, 1 },
|
||||
/*328*/ { 944, 1 },
|
||||
/*329*/ { 945, 0 },
|
||||
/*330*/ { 946, 1 },
|
||||
/*331*/ { 947, 1 },
|
||||
/*332*/ { 948, 1 },
|
||||
/*333*/ { 949, 1 },
|
||||
/*334*/ { 950, 1 },
|
||||
/*335*/ { 951, 1 },
|
||||
/*336*/ { 952, 1 },
|
||||
/*337*/ { 953, 1 },
|
||||
/*338*/ { 954, 0 },
|
||||
/*339*/ { 955, 1 },
|
||||
/*340*/ { 956, 1 },
|
||||
/*341*/ { 957, 1 },
|
||||
/*342*/ { 958, 1 },
|
||||
/*343*/ { 959, 1 },
|
||||
/*344*/ { 960, 1 },
|
||||
/*345*/ { 961, 1 },
|
||||
/*346*/ { 962, 1 },
|
||||
/*347*/ { 963, 1 },
|
||||
/*348*/ { 964, 1 },
|
||||
/*349*/ { 965, 1 },
|
||||
/*350*/ { 966, 0 },
|
||||
/*351*/ { 967, 1 },
|
||||
/*352*/ { 968, 1 },
|
||||
/*353*/ { 969, 1 },
|
||||
/*354*/ { 970, 1 },
|
||||
/*355*/ { 971, 1 },
|
||||
/*356*/ { 972, 1 },
|
||||
/*357*/ { 973, 1 },
|
||||
/*358*/ { 974, 0 },
|
||||
/*359*/ { 975, 1 },
|
||||
/*360*/ { 976, 1 },
|
||||
/*361*/ { 977, 1 },
|
||||
/*362*/ { 978, 1 },
|
||||
/*363*/ { 979, 1 },
|
||||
/*364*/ { 980, 1 },
|
||||
/*365*/ { 981, 1 },
|
||||
/*366*/ { 982, 0 },
|
||||
/*367*/ { 983, 0 },
|
||||
/*368*/ { 984, 1 },
|
||||
/*369*/ { 985, 1 },
|
||||
/*370*/ { 986, 1 },
|
||||
/*371*/ { 987, 0 },
|
||||
/*372*/ { 988, 0 },
|
||||
/*373*/ { 989, 0 },
|
||||
/*374*/ { 990, 1 },
|
||||
/*375*/ { 991, 0 },
|
||||
/*376*/ { 992, 0 },
|
||||
/*377*/ { 993, 0 },
|
||||
/*378*/ { 994, 1 },
|
||||
/*379*/ { 995, 0 },
|
||||
/*380*/ { 996, 0 },
|
||||
/*381*/ { 997, 1 },
|
||||
/*382*/ { 998, 0 },
|
||||
/*383*/ { 999, 1 },
|
||||
/*384*/ { 1000, 0 },
|
||||
/*385*/ { 2000, 0 },
|
||||
/*310*/ { 924, 0 },
|
||||
/*311*/ { 925, 1 },
|
||||
/*312*/ { 926, 0 },
|
||||
/*313*/ { 927, 1 },
|
||||
/*314*/ { 928, 1 },
|
||||
/*315*/ { 929, 1 },
|
||||
/*316*/ { 930, 1 },
|
||||
/*317*/ { 931, 1 },
|
||||
/*318*/ { 932, 1 },
|
||||
/*319*/ { 933, 1 },
|
||||
/*320*/ { 934, 1 },
|
||||
/*321*/ { 935, 0 },
|
||||
/*322*/ { 936, 1 },
|
||||
/*323*/ { 937, 0 },
|
||||
/*324*/ { 938, 1 },
|
||||
/*325*/ { 939, 0 },
|
||||
/*326*/ { 940, 1 },
|
||||
/*327*/ { 941, 1 },
|
||||
/*328*/ { 942, 0 },
|
||||
/*329*/ { 943, 1 },
|
||||
/*330*/ { 944, 1 },
|
||||
/*331*/ { 945, 0 },
|
||||
/*332*/ { 946, 1 },
|
||||
/*333*/ { 947, 1 },
|
||||
/*334*/ { 948, 1 },
|
||||
/*335*/ { 949, 1 },
|
||||
/*336*/ { 950, 1 },
|
||||
/*337*/ { 951, 1 },
|
||||
/*338*/ { 952, 1 },
|
||||
/*339*/ { 953, 1 },
|
||||
/*340*/ { 954, 0 },
|
||||
/*341*/ { 955, 1 },
|
||||
/*342*/ { 956, 1 },
|
||||
/*343*/ { 957, 1 },
|
||||
/*344*/ { 958, 1 },
|
||||
/*345*/ { 959, 1 },
|
||||
/*346*/ { 960, 1 },
|
||||
/*347*/ { 961, 1 },
|
||||
/*348*/ { 962, 1 },
|
||||
/*349*/ { 963, 1 },
|
||||
/*350*/ { 964, 1 },
|
||||
/*351*/ { 965, 1 },
|
||||
/*352*/ { 966, 0 },
|
||||
/*353*/ { 967, 1 },
|
||||
/*354*/ { 968, 1 },
|
||||
/*355*/ { 969, 1 },
|
||||
/*356*/ { 970, 1 },
|
||||
/*357*/ { 971, 1 },
|
||||
/*358*/ { 972, 1 },
|
||||
/*359*/ { 973, 1 },
|
||||
/*360*/ { 974, 0 },
|
||||
/*361*/ { 975, 1 },
|
||||
/*362*/ { 976, 1 },
|
||||
/*363*/ { 977, 1 },
|
||||
/*364*/ { 978, 1 },
|
||||
/*365*/ { 979, 1 },
|
||||
/*366*/ { 980, 1 },
|
||||
/*367*/ { 981, 1 },
|
||||
/*368*/ { 982, 0 },
|
||||
/*369*/ { 983, 0 },
|
||||
/*370*/ { 984, 1 },
|
||||
/*371*/ { 985, 1 },
|
||||
/*372*/ { 986, 1 },
|
||||
/*373*/ { 987, 0 },
|
||||
/*374*/ { 988, 0 },
|
||||
/*375*/ { 989, 0 },
|
||||
/*376*/ { 990, 1 },
|
||||
/*377*/ { 991, 0 },
|
||||
/*378*/ { 992, 0 },
|
||||
/*379*/ { 993, 0 },
|
||||
/*380*/ { 994, 1 },
|
||||
/*381*/ { 995, 0 },
|
||||
/*382*/ { 996, 0 },
|
||||
/*383*/ { 997, 1 },
|
||||
/*384*/ { 998, 0 },
|
||||
/*385*/ { 999, 1 },
|
||||
/*386*/ { 1000, 0 },
|
||||
/*387*/ { 2000, 0 },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, ret;
|
||||
@ -445,7 +447,7 @@ static void test_numeric(int index) {
|
||||
|
||||
/* Binary chop version: Whether ISO 4217 numeric */
|
||||
static int bc_iso4217_numeric(int cc) {
|
||||
static const short codes[179] = {
|
||||
static const short codes[180] = {
|
||||
/*ALL*/ 8, /*DZD*/ 12, /*ARS*/ 32, /*AUD*/ 36, /*BSD*/ 44, /*BHD*/ 48, /*BDT*/ 50, /*AMD*/ 51, /*BBD*/ 52, /*BMD*/ 60,
|
||||
/*BTN*/ 64, /*BOB*/ 68, /*BWP*/ 72, /*BZD*/ 84, /*SBD*/ 90, /*BND*/ 96, /*MMK*/ 104, /*BIF*/ 108, /*KHR*/ 116, /*CAD*/ 124,
|
||||
/*CVE*/ 132, /*KYD*/ 136, /*LKR*/ 144, /*CLP*/ 152, /*CNY*/ 156, /*COP*/ 170, /*KMF*/ 174, /*CRC*/ 188, /*HRK*/ 191, /*CUP*/ 192,
|
||||
@ -458,12 +460,12 @@ static int bc_iso4217_numeric(int cc) {
|
||||
/*PYG*/ 600, /*PEN*/ 604, /*PHP*/ 608, /*QAR*/ 634, /*RUB*/ 643, /*RWF*/ 646, /*SHP*/ 654, /*SAR*/ 682, /*SCR*/ 690, /*SLL*/ 694,
|
||||
/*SGD*/ 702, /*VND*/ 704, /*SOS*/ 706, /*ZAR*/ 710, /*SSP*/ 728, /*SZL*/ 748, /*SEK*/ 752, /*CHF*/ 756, /*SYP*/ 760, /*THB*/ 764,
|
||||
/*TOP*/ 776, /*TTD*/ 780, /*AED*/ 784, /*TND*/ 788, /*UGX*/ 800, /*MKD*/ 807, /*EGP*/ 818, /*GBP*/ 826, /*TZS*/ 834, /*USD*/ 840,
|
||||
/*UYU*/ 858, /*UZS*/ 860, /*WST*/ 882, /*YER*/ 886, /*TWD*/ 901, /*UYW*/ 927, /*VES*/ 928, /*MRU*/ 929, /*STN*/ 930, /*CUC*/ 931,
|
||||
/*ZWL*/ 932, /*BYN*/ 933, /*TMT*/ 934, /*GHS*/ 936, /*SDG*/ 938, /*UYI*/ 940, /*RSD*/ 941, /*MZN*/ 943, /*AZN*/ 944, /*RON*/ 946,
|
||||
/*CHE*/ 947, /*CHW*/ 948, /*TRY*/ 949, /*XAF*/ 950, /*XCD*/ 951, /*XOF*/ 952, /*XPF*/ 953, /*XBA*/ 955, /*XBB*/ 956, /*XBC*/ 957,
|
||||
/*XBD*/ 958, /*XAU*/ 959, /*XDR*/ 960, /*XAG*/ 961, /*XPT*/ 962, /*XTS*/ 963, /*XPD*/ 964, /*XUA*/ 965, /*ZMW*/ 967, /*SRD*/ 968,
|
||||
/*MGA*/ 969, /*COU*/ 970, /*AFN*/ 971, /*TJS*/ 972, /*AOA*/ 973, /*BGN*/ 975, /*CDF*/ 976, /*BAM*/ 977, /*EUR*/ 978, /*MXV*/ 979,
|
||||
/*UAH*/ 980, /*GEL*/ 981, /*BOV*/ 984, /*PLN*/ 985, /*BRL*/ 986, /*CLF*/ 990, /*XSU*/ 994, /*USN*/ 997, /*XXX*/ 999,
|
||||
/*UYU*/ 858, /*UZS*/ 860, /*WST*/ 882, /*YER*/ 886, /*TWD*/ 901, /*SLE*/ 925, /*UYW*/ 927, /*VES*/ 928, /*MRU*/ 929, /*STN*/ 930,
|
||||
/*CUC*/ 931, /*ZWL*/ 932, /*BYN*/ 933, /*TMT*/ 934, /*GHS*/ 936, /*SDG*/ 938, /*UYI*/ 940, /*RSD*/ 941, /*MZN*/ 943, /*AZN*/ 944,
|
||||
/*RON*/ 946, /*CHE*/ 947, /*CHW*/ 948, /*TRY*/ 949, /*XAF*/ 950, /*XCD*/ 951, /*XOF*/ 952, /*XPF*/ 953, /*XBA*/ 955, /*XBB*/ 956,
|
||||
/*XBC*/ 957, /*XBD*/ 958, /*XAU*/ 959, /*XDR*/ 960, /*XAG*/ 961, /*XPT*/ 962, /*XTS*/ 963, /*XPD*/ 964, /*XUA*/ 965, /*ZMW*/ 967,
|
||||
/*SRD*/ 968, /*MGA*/ 969, /*COU*/ 970, /*AFN*/ 971, /*TJS*/ 972, /*AOA*/ 973, /*BGN*/ 975, /*CDF*/ 976, /*BAM*/ 977, /*EUR*/ 978,
|
||||
/*MXV*/ 979, /*UAH*/ 980, /*GEL*/ 981, /*BOV*/ 984, /*PLN*/ 985, /*BRL*/ 986, /*CLF*/ 990, /*XSU*/ 994, /*USN*/ 997, /*XXX*/ 999,
|
||||
};
|
||||
|
||||
int s = 0, e = ARRAY_SIZE(codes) - 1;
|
||||
@ -510,3 +512,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- /home/mburke/code/bwipp/postscriptbarcode/build/monolithic/barcode.ps 2022-07-08 18:34:14.221029287 +0100
|
||||
+++ backend/tests/tools/bwipp_dump.ps 2022-07-08 18:29:43.830028306 +0100
|
||||
@@ -15706,8 +15706,8 @@
|
||||
--- /home/mburke/code/bwipp/postscriptbarcode/build/monolithic/barcode.ps 2022-07-14 20:00:40.532978330 +0100
|
||||
+++ backend/tests/tools/bwipp_dump.ps 2022-07-14 20:17:25.203302237 +0100
|
||||
@@ -16606,8 +16606,8 @@
|
||||
} bind
|
||||
/fime {
|
||||
/sbs [2.25 6.75 2.25 15.75 2.25 6.75 2.25] def
|
||||
@ -11,7 +11,7 @@
|
||||
} bind
|
||||
>> def
|
||||
|
||||
@@ -27194,34 +27194,80 @@
|
||||
@@ -28094,34 +28094,80 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -111,7 +111,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -27281,7 +27327,7 @@
|
||||
@@ -28181,7 +28227,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -120,7 +120,7 @@
|
||||
|
||||
% Get the result of encoding with ean8 and gs1-cc
|
||||
options (lintype) (ean8) put
|
||||
@@ -27289,29 +27335,75 @@
|
||||
@@ -28189,29 +28235,75 @@
|
||||
options (dontdraw) true put
|
||||
|
||||
% Plot the linear part
|
||||
@ -216,7 +216,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -27371,34 +27463,80 @@
|
||||
@@ -28271,34 +28363,80 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -316,7 +316,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -27473,34 +27611,80 @@
|
||||
@@ -28373,34 +28511,80 @@
|
||||
/opt options
|
||||
>> def
|
||||
|
||||
@ -416,7 +416,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -27560,7 +27744,7 @@
|
||||
@@ -28460,7 +28644,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -425,7 +425,7 @@
|
||||
|
||||
options (lintype) (databaromni) put
|
||||
options (linkage) true put
|
||||
@@ -27571,7 +27755,7 @@
|
||||
@@ -28471,7 +28655,7 @@
|
||||
linear options //databaromni exec
|
||||
dup (sbs) get /linsbs exch def
|
||||
dup (bhs) get 0 get 72 mul /linheight exch def
|
||||
@ -434,7 +434,7 @@
|
||||
|
||||
% Plot the separator
|
||||
/sepfinder {
|
||||
@@ -27602,20 +27786,66 @@
|
||||
@@ -28502,20 +28686,66 @@
|
||||
sep 0 [0 0 0] putinterval
|
||||
sep sep length 4 sub [0 0 0 0] putinterval
|
||||
18 sepfinder 64 sepfinder
|
||||
@ -513,7 +513,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -27674,7 +27904,7 @@
|
||||
@@ -28574,7 +28804,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -522,7 +522,7 @@
|
||||
|
||||
options (lintype) (databarstacked) put
|
||||
options (linkage) true put
|
||||
@@ -27685,7 +27915,7 @@
|
||||
@@ -28585,7 +28815,7 @@
|
||||
linear options //databarstacked exec
|
||||
dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
|
||||
dup (pixy) get /linheight exch def
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
% Plot the separator
|
||||
/sepfinder {
|
||||
@@ -27713,20 +27943,52 @@
|
||||
@@ -28613,20 +28843,52 @@
|
||||
sep 0 [ 0 0 0 0 ] putinterval
|
||||
sep sep length 4 sub [ 0 0 0 0 ] putinterval
|
||||
18 sepfinder
|
||||
@ -596,7 +596,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -27785,7 +28047,7 @@
|
||||
@@ -28685,7 +28947,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -605,7 +605,7 @@
|
||||
|
||||
options (lintype) (databarstackedomni) put
|
||||
options (linkage) true put
|
||||
@@ -27796,7 +28058,7 @@
|
||||
@@ -28696,7 +28958,7 @@
|
||||
linear options //databarstackedomni exec
|
||||
dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
|
||||
dup (pixy) get /linheight exch def
|
||||
@ -614,7 +614,7 @@
|
||||
|
||||
% Plot the separator
|
||||
/sepfinder {
|
||||
@@ -27824,20 +28086,52 @@
|
||||
@@ -28724,20 +28986,52 @@
|
||||
sep 0 [ 0 0 0 0 ] putinterval
|
||||
sep sep length 4 sub [ 0 0 0 0 ] putinterval
|
||||
18 sepfinder
|
||||
@ -679,7 +679,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -28012,7 +28306,7 @@
|
||||
@@ -28912,7 +29206,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -688,7 +688,7 @@
|
||||
|
||||
options (lintype) (databarlimited) put
|
||||
options (linkage) true put
|
||||
@@ -28023,7 +28317,7 @@
|
||||
@@ -28923,7 +29217,7 @@
|
||||
linear options //databarlimited exec
|
||||
dup (sbs) get /linsbs exch def
|
||||
dup (bhs) get 0 get 72 mul /linheight exch def
|
||||
@ -697,7 +697,7 @@
|
||||
|
||||
% Plot the separator
|
||||
mark
|
||||
@@ -28031,22 +28325,68 @@
|
||||
@@ -28931,22 +29225,68 @@
|
||||
counttomark 1 sub array astore /sep exch def pop pop
|
||||
sep 0 [0 0 0] putinterval
|
||||
sep sep length 9 sub [0 0 0 0 0 0 0 0 0] putinterval % 4 + 5 right guard spaces
|
||||
@ -780,7 +780,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -28106,7 +28446,7 @@
|
||||
@@ -29006,7 +29346,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -789,7 +789,7 @@
|
||||
|
||||
options (lintype) (databarexpanded) put
|
||||
options (linkage) true put
|
||||
@@ -28117,7 +28457,7 @@
|
||||
@@ -29017,7 +29357,7 @@
|
||||
linear options //databarexpanded exec
|
||||
dup (sbs) get /linsbs exch def
|
||||
dup (bhs) get 0 get 72 mul /linheight exch def
|
||||
@ -798,7 +798,7 @@
|
||||
|
||||
% Plot the separator
|
||||
/sepfinder {
|
||||
@@ -28146,20 +28486,60 @@
|
||||
@@ -29046,20 +29386,60 @@
|
||||
18 98 bot length 13 sub {} for
|
||||
69 98 bot length 13 sub {} for
|
||||
] {sepfinder} forall
|
||||
@ -871,7 +871,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -28218,7 +28598,7 @@
|
||||
@@ -29118,7 +29498,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -880,7 +880,7 @@
|
||||
|
||||
options (lintype) (databarexpandedstacked) put
|
||||
options (linkage) true put
|
||||
@@ -28229,7 +28609,7 @@
|
||||
@@ -29129,7 +29509,7 @@
|
||||
linear options //databarexpandedstacked exec
|
||||
dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
|
||||
dup (pixy) get /linheight exch def
|
||||
@ -889,7 +889,7 @@
|
||||
|
||||
% Plot the separator
|
||||
/sepfinder {
|
||||
@@ -28255,21 +28635,49 @@
|
||||
@@ -29155,21 +29535,49 @@
|
||||
19 98 bot length 13 sub {} for
|
||||
70 98 bot length 13 sub {} for
|
||||
] {sepfinder} forall
|
||||
@ -952,7 +952,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -28329,7 +28737,7 @@
|
||||
@@ -29229,7 +29637,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -961,7 +961,7 @@
|
||||
|
||||
options (inkspread) (0) put
|
||||
options (dontdraw) true put
|
||||
@@ -28356,35 +28764,87 @@
|
||||
@@ -29256,35 +29664,87 @@
|
||||
linear << options {} forall >> //gs1-128 exec
|
||||
dup (sbs) get /linsbs exch def
|
||||
dup (bhs) get 0 get 72 mul /linheight exch def
|
||||
@ -1063,7 +1063,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -29934,3 +30394,189 @@
|
||||
@@ -30834,3 +31294,189 @@
|
||||
% --END ENCODER hibcazteccode--
|
||||
|
||||
% --END TEMPLATE--
|
||||
|
Binary file not shown.
@ -2,8 +2,10 @@
|
||||
/* Generate GS1 verify include "backend/gs1_lint.h" for "backend/gs1.c" */
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2021 <rstuart114@gmail.com>
|
||||
*/
|
||||
Copyright (C) 2021-2022 <rstuart114@gmail.com>
|
||||
*/
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
/* To create "backend/gs1_lint.h" (from project directory):
|
||||
*
|
||||
* php backend/tools/gen_gs1_lint.php > backend/gs1_lint.h
|
||||
@ -12,8 +14,12 @@
|
||||
*
|
||||
* php backend/tools/gen_gs1_lint.php -f <local-path>/gs1-format-spec.txt backend/gs1_lint.h
|
||||
*
|
||||
*************************************************************************************************
|
||||
* NOTE: for up-to-update version requires syntax dictionary that will be available from
|
||||
* https://github.com/gs1/gs1-syntax-dictionary
|
||||
* on its release. For now this generator should only be run by someone with a pre-release copy!!!
|
||||
*************************************************************************************************
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
$basename = basename(__FILE__);
|
||||
$dirname = dirname(__FILE__);
|
||||
@ -22,8 +28,11 @@ $dirdirname = basename(dirname($dirname)) . '/' . basename($dirname);
|
||||
$opts = getopt('c:f:h:l:t:');
|
||||
|
||||
$print_copyright = isset($opts['c']) ? (bool) $opts['c'] : true;
|
||||
$file = isset($opts['f']) ? $opts['f'] :
|
||||
'https://raw.githubusercontent.com/bwipp/postscriptbarcode/master/contrib/development/gs1-format-spec.txt';
|
||||
if (!isset($opts['f'])) { // TODO: temporary hack
|
||||
exit("$basename:" . __LINE__
|
||||
. " ERROR: For now this generator must only be run locally with a pre-release syntax dictionary" . PHP_EOL);
|
||||
}
|
||||
$file = $opts['f'];
|
||||
$print_h_guard = isset($opts['h']) ? (bool) $opts['h'] : true;
|
||||
$use_length_only = isset($opts['l']) ? (bool) $opts['l'] : true;
|
||||
$tab = isset($opts['t']) ? $opts['t'] : ' ';
|
||||
@ -31,6 +40,9 @@ $tab = isset($opts['t']) ? $opts['t'] : ' ';
|
||||
if (($get = file_get_contents($file)) === false) {
|
||||
exit("$basename:" . __LINE__ . " ERROR: Could not read file \"$file\"" . PHP_EOL);
|
||||
}
|
||||
// Strip to last 2 directories TODO: temporary hack
|
||||
$stripped_dir = dirname($file);
|
||||
$stripped_file = basename(dirname($stripped_dir)) . '/' . basename($stripped_dir) . '/' . basename($file);
|
||||
|
||||
$lines = explode("\n", $get);
|
||||
|
||||
@ -44,12 +56,14 @@ foreach ($lines as $line) {
|
||||
if ($line === '' || $line[0] === '#') {
|
||||
continue;
|
||||
}
|
||||
if (!preg_match('/^([0-9]+(?:-[0-9]+)?) +([ *] )([NXC][0-9.][ NXC0-9.,a-z=|]*)(?:# (.+))?$/', $line, $matches)) {
|
||||
if (!preg_match('/^([0-9]+(?:-[0-9]+)?) +([ *] )([NXYC][0-9.][ NXYC0-9.,a-z=|\[\]]*)(?:# (.+))?$/', $line, $matches)) {
|
||||
exit("$basename:" . __LINE__ . " ERROR: Could not parse line $line_no" . PHP_EOL);
|
||||
}
|
||||
$ai = $matches[1];
|
||||
$fixed = trim($matches[2]);
|
||||
$spec = preg_replace('/ +dlpkey[=0-9,|]*/', '', trim($matches[3])); // Strip Digital Link primary key info
|
||||
$spec = preg_replace('/ +req=[0-9,n]*/', '', trim($matches[3])); // Strip mandatory association info
|
||||
$spec = preg_replace('/ +ex=[0-9,n]*/', '', $spec); // Strip invalid pairings info
|
||||
$spec = preg_replace('/ +dlpkey[=0-9,|]*/', '', $spec); // Strip Digital Link primary key info
|
||||
$comment = isset($matches[4]) ? trim($matches[4]) : '';
|
||||
|
||||
if (isset($spec_ais[$spec])) {
|
||||
@ -108,9 +122,7 @@ foreach ($lines as $line) {
|
||||
foreach ($parts as $part) {
|
||||
$checkers = explode(',', $part);
|
||||
$validator = array_shift($checkers);
|
||||
if (!preg_match('/^([NXC])([0-9]+)?(\.\.[0-9|]+)?$/', $validator, $matches)) {
|
||||
exit("$basename:" . __LINE__ . " ERROR: Could not parse validator \"$validator\" line $line_no" . PHP_EOL);
|
||||
}
|
||||
if (preg_match('/^([NXYC])([0-9]+)?(\.\.[0-9|]+)?$/', $validator, $matches)) {
|
||||
if (count($matches) === 3) {
|
||||
$min = $max = (int) $matches[2];
|
||||
} else {
|
||||
@ -124,6 +136,24 @@ foreach ($lines as $line) {
|
||||
} else {
|
||||
$validator = "cset39";
|
||||
}
|
||||
} else if (preg_match('/^\[([NXYC])([1-9]+)?(\.\.[0-9|]+)?\]$/', $validator, $matches)) {
|
||||
if (count($matches) === 3) {
|
||||
$min = 0;
|
||||
$max = (int) $matches[2];
|
||||
} else {
|
||||
$min = $matches[2] === '' ? 0 : (int) $matches[2];
|
||||
$max = (int) substr($matches[3], 2);
|
||||
}
|
||||
if ($matches[1] === 'N') {
|
||||
$validator = "numeric";
|
||||
} elseif ($matches[1] === 'X') {
|
||||
$validator = "cset82";
|
||||
} else {
|
||||
$validator = "cset39";
|
||||
}
|
||||
} else {
|
||||
exit("$basename:" . __LINE__ . " ERROR: Could not parse validator \"$validator\" line $line_no" . PHP_EOL);
|
||||
}
|
||||
$spec_parts[$spec][] = array($min, $max, $validator, $checkers);
|
||||
}
|
||||
}
|
||||
@ -196,7 +226,7 @@ foreach ($spec_ais as $spec => $ais) {
|
||||
print <<<EOD
|
||||
/*
|
||||
* GS1 AI checker generated by "$dirdirname/$basename" from
|
||||
* $file
|
||||
* $stripped_file
|
||||
*/
|
||||
|
||||
EOD;
|
||||
@ -205,7 +235,7 @@ if ($print_copyright) {
|
||||
print <<<'EOD'
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -232,6 +262,7 @@ print <<<'EOD'
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
|
||||
EOD;
|
||||
@ -239,8 +270,8 @@ EOD;
|
||||
|
||||
if ($print_h_guard) {
|
||||
print <<<'EOD'
|
||||
#ifndef GS1_LINT_H
|
||||
#define GS1_LINT_H
|
||||
#ifndef Z_GS1_LINT_H
|
||||
#define Z_GS1_LINT_H
|
||||
|
||||
|
||||
EOD;
|
||||
@ -249,7 +280,7 @@ EOD;
|
||||
// Print the spec validator/checkers functions
|
||||
|
||||
foreach ($spec_parts as $spec => $spec_part) {
|
||||
$spec_funcs[$spec] = $spec_func = str_replace(array(' ', '.', ','), '_', strtolower($spec));
|
||||
$spec_funcs[$spec] = $spec_func = str_replace(array(' ', '.', ',', '[', ']'), '_', strtolower($spec));
|
||||
$comment = '';
|
||||
if (isset($spec_comments[$spec])) {
|
||||
$comment = ' (Used by';
|
||||
@ -437,7 +468,9 @@ EOD;
|
||||
if ($print_h_guard) {
|
||||
print <<<'EOD'
|
||||
|
||||
#endif /* GS1_LINT_H */
|
||||
#endif /* Z_GS1_LINT_H */
|
||||
|
||||
EOD;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -2,13 +2,14 @@
|
||||
/* Generate ISO 4217 include "backend/iso4217.h" for "backend/gs1.c" */
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2021 <rstuart114@gmail.com>
|
||||
Copyright (C) 2021-2022 <rstuart114@gmail.com>
|
||||
*/
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
/* To create "backend/iso4217.h" (from project directory):
|
||||
*
|
||||
* php backend/tools/gen_iso4217_h.php > backend/iso4217.h
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
$basename = basename(__FILE__);
|
||||
$dirname = dirname(__FILE__);
|
||||
@ -33,12 +34,12 @@ $numeric = array(
|
||||
/*PYG*/ 600, /*PEN*/ 604, /*PHP*/ 608, /*QAR*/ 634, /*RUB*/ 643, /*RWF*/ 646, /*SHP*/ 654, /*SAR*/ 682, /*SCR*/ 690, /*SLL*/ 694,
|
||||
/*SGD*/ 702, /*VND*/ 704, /*SOS*/ 706, /*ZAR*/ 710, /*SSP*/ 728, /*SZL*/ 748, /*SEK*/ 752, /*CHF*/ 756, /*SYP*/ 760, /*THB*/ 764,
|
||||
/*TOP*/ 776, /*TTD*/ 780, /*AED*/ 784, /*TND*/ 788, /*UGX*/ 800, /*MKD*/ 807, /*EGP*/ 818, /*GBP*/ 826, /*TZS*/ 834, /*USD*/ 840,
|
||||
/*UYU*/ 858, /*UZS*/ 860, /*WST*/ 882, /*YER*/ 886, /*TWD*/ 901, /*UYW*/ 927, /*VES*/ 928, /*MRU*/ 929, /*STN*/ 930, /*CUC*/ 931,
|
||||
/*ZWL*/ 932, /*BYN*/ 933, /*TMT*/ 934, /*GHS*/ 936, /*SDG*/ 938, /*UYI*/ 940, /*RSD*/ 941, /*MZN*/ 943, /*AZN*/ 944, /*RON*/ 946,
|
||||
/*CHE*/ 947, /*CHW*/ 948, /*TRY*/ 949, /*XAF*/ 950, /*XCD*/ 951, /*XOF*/ 952, /*XPF*/ 953, /*XBA*/ 955, /*XBB*/ 956, /*XBC*/ 957,
|
||||
/*XBD*/ 958, /*XAU*/ 959, /*XDR*/ 960, /*XAG*/ 961, /*XPT*/ 962, /*XTS*/ 963, /*XPD*/ 964, /*XUA*/ 965, /*ZMW*/ 967, /*SRD*/ 968,
|
||||
/*MGA*/ 969, /*COU*/ 970, /*AFN*/ 971, /*TJS*/ 972, /*AOA*/ 973, /*BGN*/ 975, /*CDF*/ 976, /*BAM*/ 977, /*EUR*/ 978, /*MXV*/ 979,
|
||||
/*UAH*/ 980, /*GEL*/ 981, /*BOV*/ 984, /*PLN*/ 985, /*BRL*/ 986, /*CLF*/ 990, /*XSU*/ 994, /*USN*/ 997, /*XXX*/ 999,
|
||||
/*UYU*/ 858, /*UZS*/ 860, /*WST*/ 882, /*YER*/ 886, /*TWD*/ 901, /*SLE*/ 925, /*UYW*/ 927, /*VES*/ 928, /*MRU*/ 929, /*STN*/ 930,
|
||||
/*CUC*/ 931, /*ZWL*/ 932, /*BYN*/ 933, /*TMT*/ 934, /*GHS*/ 936, /*SDG*/ 938, /*UYI*/ 940, /*RSD*/ 941, /*MZN*/ 943, /*AZN*/ 944,
|
||||
/*RON*/ 946, /*CHE*/ 947, /*CHW*/ 948, /*TRY*/ 949, /*XAF*/ 950, /*XCD*/ 951, /*XOF*/ 952, /*XPF*/ 953, /*XBA*/ 955, /*XBB*/ 956,
|
||||
/*XBC*/ 957, /*XBD*/ 958, /*XAU*/ 959, /*XDR*/ 960, /*XAG*/ 961, /*XPT*/ 962, /*XTS*/ 963, /*XPD*/ 964, /*XUA*/ 965, /*ZMW*/ 967,
|
||||
/*SRD*/ 968, /*MGA*/ 969, /*COU*/ 970, /*AFN*/ 971, /*TJS*/ 972, /*AOA*/ 973, /*BGN*/ 975, /*CDF*/ 976, /*BAM*/ 977, /*EUR*/ 978,
|
||||
/*MXV*/ 979, /*UAH*/ 980, /*GEL*/ 981, /*BOV*/ 984, /*PLN*/ 985, /*BRL*/ 986, /*CLF*/ 990, /*XSU*/ 994, /*USN*/ 997, /*XXX*/ 999,
|
||||
);
|
||||
|
||||
$numeric_tab = array();
|
||||
@ -68,7 +69,7 @@ if ($print_copyright) {
|
||||
print <<<'EOD'
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -95,6 +96,7 @@ print <<<'EOD'
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
|
||||
EOD;
|
||||
@ -102,8 +104,8 @@ EOD;
|
||||
|
||||
if ($print_h_guard) {
|
||||
print <<<'EOD'
|
||||
#ifndef ISO4217_H
|
||||
#define ISO4217_H
|
||||
#ifndef Z_ISO4217_H
|
||||
#define Z_ISO4217_H
|
||||
|
||||
EOD;
|
||||
}
|
||||
@ -139,7 +141,9 @@ EOD;
|
||||
if ($print_h_guard) {
|
||||
print <<<'EOD'
|
||||
|
||||
#endif /* ISO4217_H */
|
||||
#endif /* Z_ISO4217_H */
|
||||
|
||||
EOD;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
Loading…
Reference in New Issue
Block a user