mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
UPU_S10/GS1: properly expose iso3166_alpha2()
; add UPU_S10 to tcl
This commit is contained in:
parent
53769c6ed1
commit
ab7da62a3a
@ -1180,8 +1180,6 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||
return error_number;
|
||||
}
|
||||
|
||||
INTERNAL int iso3166_alpha2(const char *cc); /* In "iso3166.h" which is included by "gs1.c" */
|
||||
|
||||
/* Universal Postal Union S10 */
|
||||
/* https://www.upu.int/UPU/media/upu/files/postalSolutions/programmesAndServices/standards/S10-12.pdf */
|
||||
INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
@ -1247,7 +1245,7 @@ INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
} else if (strchr("FHIOXY", local_source[0]) != NULL) { /* These aren't allocated as of spec Oct 2017 */
|
||||
strcpy(symbol->errtxt, "840: Non-standard Service Indicator (first 2 characters)");
|
||||
error_number = ZINT_WARN_NONCOMPLIANT;
|
||||
} else if (!iso3166_alpha2((const char *) (local_source + 11))) {
|
||||
} else if (!gs1_iso3166_alpha2(local_source + 11)) {
|
||||
strcpy(symbol->errtxt, "841: Country code (last two characters) is not ISO 3166-1");
|
||||
error_number = ZINT_WARN_NONCOMPLIANT;
|
||||
}
|
||||
|
@ -1428,4 +1428,9 @@ INTERNAL char gs1_check_digit(const unsigned char source[], const int length) {
|
||||
return itoc((10 - (count % 10)) % 10);
|
||||
}
|
||||
|
||||
/* Helper to expose `iso3166_alpha2()` */
|
||||
INTERNAL int gs1_iso3166_alpha2(const unsigned char *cc) {
|
||||
return iso3166_alpha2((const char *) cc);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -40,6 +40,7 @@ extern "C" {
|
||||
INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const int src_len,
|
||||
unsigned char reduced[]);
|
||||
INTERNAL char gs1_check_digit(const unsigned char source[], const int src_len);
|
||||
INTERNAL int gs1_iso3166_alpha2(const unsigned char *cc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ static int iso3166_numeric(int cc) {
|
||||
}
|
||||
|
||||
/* Whether ISO 3166-1 alpha2 */
|
||||
INTERNAL int iso3166_alpha2(const char *cc) {
|
||||
static int iso3166_alpha2(const char *cc) {
|
||||
static const unsigned char codes[85] = {
|
||||
0x78, 0x59, 0xDF, 0xEE, 0xEF, 0xBD, 0xDD, 0xDE,
|
||||
0x27, 0x3F, 0x84, 0x15, 0x80, 0xD4, 0x00, 0x0E,
|
||||
|
@ -162,6 +162,8 @@
|
||||
- Added MAILMARK_2D
|
||||
- Renamed MAILMARK to MAILMARK_4S
|
||||
*** Potential incompatibility ***
|
||||
2022-12-09 GL
|
||||
- Added UPU_S10
|
||||
*/
|
||||
|
||||
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
|
||||
@ -308,6 +310,7 @@ static const char *s_code_list[] = {
|
||||
"DotCode",
|
||||
"HanXin",
|
||||
"MailMark-2D",
|
||||
"UPU-S10",
|
||||
"MailMark-4S",
|
||||
"AztecRunes",
|
||||
"Code32",
|
||||
@ -409,6 +412,7 @@ static const int s_code_number[] = {
|
||||
BARCODE_DOTCODE,
|
||||
BARCODE_HANXIN,
|
||||
BARCODE_MAILMARK_2D,
|
||||
BARCODE_UPU_S10,
|
||||
BARCODE_MAILMARK_4S,
|
||||
BARCODE_AZRUNE,
|
||||
BARCODE_CODE32,
|
||||
|
Loading…
Reference in New Issue
Block a user