mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-12 22:25:59 -04: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
10 changed files with 962 additions and 864 deletions
|
@ -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"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue