Used to ensure that the AI component has a valid alphanumeric check character pair.
79 static const unsigned int primes[] = {
80 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37,
81 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89,
82 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151,
83 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223,
84 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
85 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359,
86 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433,
87 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503,
95 static const char*
const cset82 =
96 "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_"
97 "abcdefghijklmnopqrstuvwxyz";
103 static const char*
const cset32 =
"23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
106 unsigned int sum = 0;
107 const unsigned int *p;
118 if (err_pos) *err_pos = 0;
119 if (err_len) *err_len = len;
128 if (len >
sizeof(primes) /
sizeof(primes[0])) {
129 if (err_pos) *err_pos = 0;
130 if (err_len) *err_len = len;
138 if ((pos = strspn(data, cset82)) < len - 2) {
139 if (err_pos) *err_pos = pos;
140 if (err_len) *err_len = 1;
148 if ((pos = strspn(&data[len - 2], cset32)) != 2) {
149 if (err_pos) *err_pos = len - 2 + pos;
150 if (err_len) *err_len = 1;
169 p = primes + len - 3;
170 for (i = 0; i < len - 2; i++)
171 sum += (
unsigned int)(strchr(cset82, data[i]) - cset82) * *p--;
174 if (data[i] != cset32[sum >> 5] || data[i+1] != cset32[sum & 31]) {
175 if (err_pos) *err_pos = len - 2;
176 if (err_len) *err_len = 2;
@ GS1_LINTER_TOO_LONG_FOR_CHECK_PAIR_IMPLEMENTATION
The component is too long to perform an alphanumeric check character pair calculation.
Definition: gs1syntaxdictionary.h:75
@ GS1_LINTER_INCORRECT_CHECK_PAIR
The alphanumeric check-character pair are incorrect.
Definition: gs1syntaxdictionary.h:73
@ GS1_LINTER_INVALID_CSET82_CHARACTER
A non-CSET 82 character was found where a CSET 82 character is expected.
Definition: gs1syntaxdictionary.h:68
@ GS1_LINTER_TOO_SHORT_FOR_CHECK_PAIR
The component is too short to perform an alphanumeric check character pair calculation.
Definition: gs1syntaxdictionary.h:74
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition: gs1syntaxdictionary.h:66
@ GS1_LINTER_INVALID_CSET32_CHARACTER
A non-CSET 32 character was found where a CSET 32 character is expected.
Definition: gs1syntaxdictionary.h:70