Used to ensure that an AI component conforms to the North American Coupon Code (NACC) specification, as carried in AI (8110).
190 char expiry_date[7] = {0};
200 if ((pos = strspn(data,
"0123456789")) != strlen(data)) {
201 if (err_pos) *err_pos = pos;
202 if (err_len) *err_len = 1;
207 q = data + strlen(data);
218 if (err_pos) *err_pos = 0;
219 if (err_len) *err_len = (size_t)(q - data);
223 if (err_pos) *err_pos = (size_t)(p - data);
224 if (err_len) *err_len = 1;
232 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
233 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
241 strncpy(gcp, p, (
size_t)vli);
249 if (err_pos) *err_pos = (size_t)(p - data);
250 if (err_len) *err_len = (size_t)vli;
262 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
263 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
278 if (err_pos) *err_pos = 0;
279 if (err_len) *err_len = (size_t)(q - data);
282 if (*p < '1' || *p >
'5') {
283 if (err_pos) *err_pos = (size_t)(p - data);
284 if (err_len) *err_len = 1;
292 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
293 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
308 if (err_pos) *err_pos = 0;
309 if (err_len) *err_len = (size_t)(q - data);
312 if (*p < '1' || *p >
'5') {
313 if (err_pos) *err_pos = (size_t)(p - data);
314 if (err_len) *err_len = 1;
322 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
323 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
338 if (err_pos) *err_pos = 0;
339 if (err_len) *err_len = (size_t)(q - data);
343 if (*p >
'4' && *p !=
'9') {
344 if (err_pos) *err_pos = (size_t)(p - data);
345 if (err_len) *err_len = 1;
357 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
358 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
372 if (p < q && *p ==
'1') {
384 if (err_pos) *err_pos = 0;
385 if (err_len) *err_len = (size_t)(q - data);
390 if (err_pos) *err_pos = (size_t)(p - data);
391 if (err_len) *err_len = 1;
407 if (err_pos) *err_pos = 0;
408 if (err_len) *err_len = (size_t)(q - data);
411 if (*p < '1' || *p >
'5') {
412 if (err_pos) *err_pos = (size_t)(p - data);
413 if (err_len) *err_len = 1;
421 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
422 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
437 if (err_pos) *err_pos = 0;
438 if (err_len) *err_len = (size_t)(q - data);
442 if (*p >
'4' && *p !=
'9') {
443 if (err_pos) *err_pos = (size_t)(p - data);
444 if (err_len) *err_len = 1;
457 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
458 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
474 if (err_pos) *err_pos = 0;
475 if (err_len) *err_len = (size_t)(q - data);
478 if (*p >
'6' && *p !=
'9') {
479 if (err_pos) *err_pos = (size_t)(p - data);
480 if (err_len) *err_len = 1;
483 vli = (*p !=
'9') ? *p -
'0' + 6 : 0;
488 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
489 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
497 strncpy(gcp, p, (
size_t)vli);
505 if (err_pos) *err_pos = (size_t)(p - data);
506 if (err_len) *err_len = (size_t)vli;
522 if (p < q && *p ==
'2') {
535 if (err_pos) *err_pos = 0;
536 if (err_len) *err_len = (size_t)(q - data);
539 if (*p < '1' || *p >
'5') {
540 if (err_pos) *err_pos = (size_t)(p - data);
541 if (err_len) *err_len = 1;
549 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
550 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
565 if (err_pos) *err_pos = 0;
566 if (err_len) *err_len = (size_t)(q - data);
570 if (*p >
'4' && *p !=
'9') {
571 if (err_pos) *err_pos = (size_t)(p - data);
572 if (err_len) *err_len = 1;
585 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
586 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
602 if (err_pos) *err_pos = 0;
603 if (err_len) *err_len = (size_t)(q - data);
606 if (*p >
'6' && *p !=
'9') {
607 if (err_pos) *err_pos = (size_t)(p - data);
608 if (err_len) *err_len = 1;
611 vli = (*p !=
'9') ? *p -
'0' + 6 : 0;
616 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
617 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
625 strncpy(gcp, p, (
size_t)vli);
633 if (err_pos) *err_pos = (size_t)(p - data);
634 if (err_len) *err_len = (size_t)vli;
650 if (p < q && *p ==
'3') {
659 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
660 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
664 memcpy(expiry_date, p, 6);
675 if (err_pos) *err_pos = (size_t)(p - data);
676 if (err_len) *err_len = 6;
694 if (p < q && *p ==
'4') {
696 char start_date[7] = {0};
705 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
706 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
710 memcpy(start_date, p, 6);
721 if (err_pos) *err_pos = (size_t)(p - data);
722 if (err_len) *err_len = 6;
731 if (expiry_set && strcmp(start_date, expiry_date) > 0) {
732 if (err_pos) *err_pos = (size_t)(p - data - 8);
733 if (err_len) *err_len = 14;
749 if (p < q && *p ==
'5') {
759 if (err_pos) *err_pos = 0;
760 if (err_len) *err_len = (size_t)(q - data);
768 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
769 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
785 if (p < q && *p ==
'6') {
797 if (err_pos) *err_pos = 0;
798 if (err_len) *err_len = (size_t)(q - data);
801 if (*p < '1' || *p >
'7') {
802 if (err_pos) *err_pos = (size_t)(p - data);
803 if (err_len) *err_len = 1;
811 if (err_pos) *err_pos = (p == q) ? 0 : (
size_t)(p - data);
812 if (err_len) *err_len = (p == q) ? (
size_t)(q - data) : (
size_t)(q - p);
820 strncpy(gcp, p, (
size_t)vli);
828 if (err_pos) *err_pos = (size_t)(p - data);
829 if (err_len) *err_len = (size_t)vli;
845 if (p < q && *p ==
'9') {
857 if (err_pos) *err_pos = 0;
858 if (err_len) *err_len = (size_t)(q - data);
861 if (*p !=
'0' && *p !=
'1' && *p !=
'2' && *p !=
'5' && *p !=
'6') {
862 if (err_pos) *err_pos = (size_t)(p - data);
863 if (err_len) *err_len = 1;
877 if (err_pos) *err_pos = 0;
878 if (err_len) *err_len = (size_t)(q - data);
882 if (err_pos) *err_pos = (size_t)(p - data);
883 if (err_len) *err_len = 1;
896 if (err_pos) *err_pos = 0;
897 if (err_len) *err_len = (size_t)(q - data);
911 if (err_pos) *err_pos = 0;
912 if (err_len) *err_len = (size_t)(q - data);
915 if (*p !=
'0' && *p !=
'1') {
916 if (err_pos) *err_pos = (size_t)(p - data);
917 if (err_len) *err_len = 1;
930 if (err_pos) *err_pos = (size_t)(p - data);
931 if (err_len) *err_len = (size_t)(q - p);
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yymmdd(const char *data, size_t *err_pos, size_t *err_len)
Definition: lint_yymmdd.c:52
gs1_lint_err_t
Linter return codes other than GS1_LINTER_OK indicate an error condition.
Definition: gs1syntaxdictionary.h:65
@ GS1_LINTER_ILLEGAL_DAY
The date contains an illegal day of the month.
Definition: gs1syntaxdictionary.h:102
@ GS1_LINTER_COUPON_TRUNCATED_2ND_PURCHASE_FAMILY_CODE
The coupon's second purchase Family Code is shorter than the required three digits.
Definition: gs1syntaxdictionary.h:138
@ GS1_LINTER_COUPON_TRUNCATED_RETAILER_GCP_OR_GLN
The coupon's Retailer GCP/GLN is shorter than what is indicated by its VLI.
Definition: gs1syntaxdictionary.h:158
@ GS1_LINTER_COUPON_INVALID_2ND_PURCHASE_REQUIREMENT_LENGTH
The coupon's second purchase Requirement VLI must be "1" to "5".
Definition: gs1syntaxdictionary.h:134
@ GS1_LINTER_COUPON_MISSING_3RD_PURCHASE_REQUIREMENT_VLI
The coupon's third purchase Requirement VLI is missing.
Definition: gs1syntaxdictionary.h:142
@ GS1_LINTER_COUPON_MISSING_RETAILER_GCP_OR_GLN_VLI
The coupon's Retailer GCP/GLN VLI is missing.
Definition: gs1syntaxdictionary.h:156
@ GS1_LINTER_COUPON_INVALID_3RD_PURCHASE_REQUIREMENT_LENGTH
The coupon's third purchase Requirement VLI must be "1" to "5".
Definition: gs1syntaxdictionary.h:143
@ GS1_LINTER_COUPON_MISSING_1ST_PURCHASE_REQUIREMENT_VLI
The coupon's primary purchase Requirement VLI is missing.
Definition: gs1syntaxdictionary.h:125
@ GS1_LINTER_COUPON_INVALID_SAVE_VALUE_CODE
The coupon's Save Value Code must be "0", "1", "2", "5" or "6".
Definition: gs1syntaxdictionary.h:160
@ GS1_LINTER_COUPON_INVALID_2ND_PURCHASE_GCP_LENGTH
The coupon's second purchase GS1 Company Prefix VLI must be "0" to "6" or "9".
Definition: gs1syntaxdictionary.h:140
@ GS1_LINTER_COUPON_TRUNCATED_1ST_PURCHASE_FAMILY_CODE
The coupon's primary purchase Family Code is shorter than the required three digits.
Definition: gs1syntaxdictionary.h:130
@ GS1_LINTER_COUPON_INVALID_SAVE_VALUE_APPLIES_TO_ITEM
The coupon's Save Value Applies to Item must be "0" to "2".
Definition: gs1syntaxdictionary.h:162
@ GS1_LINTER_COUPON_MISSING_SAVE_VALUE_APPLIES_TO_ITEM
The coupon's Save Value Applies to Item is missing.
Definition: gs1syntaxdictionary.h:161
@ GS1_LINTER_COUPON_TRUNCATED_GCP
The coupon's primary GS1 Company Prefix is shorter than what is indicated by its VLI.
Definition: gs1syntaxdictionary.h:121
@ GS1_LINTER_COUPON_MISSING_3RD_PURCHASE_REQUIREMENT_CODE
The coupon's third purchase Requirement Code is missing.
Definition: gs1syntaxdictionary.h:145
@ GS1_LINTER_COUPON_TRUNCATED_3RD_PURCHASE_REQUIREMENT
The coupon's third purchase Requirement is shorter than what is indicated by its VLI.
Definition: gs1syntaxdictionary.h:144
@ GS1_LINTER_DATE_TOO_LONG
The date is too long for YYMMDD format.
Definition: gs1syntaxdictionary.h:95
@ GS1_LINTER_COUPON_TRUNCATED_SAVE_VALUE
The coupon's Save Value is shorter than what is indicated by its VLI.
Definition: gs1syntaxdictionary.h:124
@ GS1_LINTER_COUPON_INVALID_2ND_PURCHASE_REQUIREMENT_CODE
The coupon's second purchase Requirement Code must be "0" to "4" or "9".
Definition: gs1syntaxdictionary.h:137
@ GS1_LINTER_GCP_DATASOURCE_OFFLINE
The data source for GCP lookups is offline.
Definition: gs1syntaxdictionary.h:76
@ GS1_LINTER_COUPON_MISSING_SERIAL_NUMBER_VLI
The coupon's Serial Number VLI is missing.
Definition: gs1syntaxdictionary.h:117
@ GS1_LINTER_COUPON_TRUNCATED_1ST_PURCHASE_REQUIREMENT
The coupon's primary purchase Requirement is shorter than what is indicated by its VLI.
Definition: gs1syntaxdictionary.h:127
@ GS1_LINTER_COUPON_MISSING_1ST_PURCHASE_REQUIREMENT_CODE
The coupon's primary purchase Requirement Code is missing.
Definition: gs1syntaxdictionary.h:128
@ GS1_LINTER_ILLEGAL_MONTH
The date contains an illegal month of the year.
Definition: gs1syntaxdictionary.h:101
@ GS1_LINTER_COUPON_MISSING_GCP_VLI
The coupon's primary GS1 Company Prefix VLI is missing.
Definition: gs1syntaxdictionary.h:119
@ GS1_LINTER_COUPON_MISSING_2ND_PURCHASE_REQUIREMENT_CODE
The coupon's second purchase Requirement Code is missing.
Definition: gs1syntaxdictionary.h:136
@ GS1_LINTER_COUPON_MISSING_2ND_PURCHASE_REQUIREMENT_VLI
The coupon's second purchase Requirement VLI is missing.
Definition: gs1syntaxdictionary.h:133
@ GS1_LINTER_COUPON_TRUNCATED_3RD_PURCHASE_FAMILY_CODE
The coupon's third purchase Family Code is shorter than the required three digits.
Definition: gs1syntaxdictionary.h:147
@ GS1_LINTER_COUPON_TRUNCATED_SERIAL_NUMBER
The coupon's Serial Number is shorter than what is indicated by its VLI.
Definition: gs1syntaxdictionary.h:118
@ GS1_LINTER_COUPON_TOO_SHORT_FOR_START_DATE
The coupon's start date is too short to YYMMDD format.
Definition: gs1syntaxdictionary.h:153
@ GS1_LINTER_COUPON_INVALID_START_DATE
The coupon's start date is invalid.
Definition: gs1syntaxdictionary.h:154
@ GS1_LINTER_COUPON_INVALID_SAVE_VALUE_LENGTH
The coupon's Save Value VLI must be "1" to "5".
Definition: gs1syntaxdictionary.h:123
@ GS1_LINTER_COUPON_TRUNCATED_OFFER_CODE
The coupon's Offer Code is shorter than the required six digits.
Definition: gs1syntaxdictionary.h:116
@ GS1_LINTER_COUPON_MISSING_ADDITIONAL_PURCHASE_RULES_CODE
The coupon's Additional Purchase Rules Code is missing.
Definition: gs1syntaxdictionary.h:131
@ GS1_LINTER_COUPON_INVALID_DONT_MULTIPLY_FLAG
The coupon's Don't Multiply Flag must be "0" or "1".
Definition: gs1syntaxdictionary.h:165
@ GS1_LINTER_COUPON_TRUNCATED_2ND_PURCHASE_GCP
The coupon's second purchase GS1 Company Prefix is shorter than what is indicated by its VLI.
Definition: gs1syntaxdictionary.h:141
@ GS1_LINTER_COUPON_MISSING_STORE_COUPON_FLAG
The coupon's Store Coupon Flag is missing.
Definition: gs1syntaxdictionary.h:163
@ GS1_LINTER_COUPON_EXCESS_DATA
The coupon contains excess data after the recognised optional fields.
Definition: gs1syntaxdictionary.h:166
@ GS1_LINTER_COUPON_MISSING_3RD_PURCHASE_GCP_VLI
The coupon's third purchase GS1 Company Prefix VLI is missing.
Definition: gs1syntaxdictionary.h:148
@ GS1_LINTER_COUPON_MISSING_2ND_PURCHASE_GCP_VLI
The coupon's second purchase GS1 Company Prefix VLI is missing.
Definition: gs1syntaxdictionary.h:139
@ GS1_LINTER_COUPON_TOO_SHORT_FOR_EXPIRATION_DATE
The coupon's expiration date is too short for YYMMDD format.
Definition: gs1syntaxdictionary.h:151
@ GS1_LINTER_COUPON_INVALID_GCP_LENGTH
The coupon's primary GS1 Company Prefix VLI must be "0" to "6".
Definition: gs1syntaxdictionary.h:120
@ GS1_LINTER_DATE_TOO_SHORT
The date is too short for YYMMDD format.
Definition: gs1syntaxdictionary.h:94
@ GS1_LINTER_COUPON_INVALID_EXIPIRATION_DATE
The coupon's expiration date is invalid.
Definition: gs1syntaxdictionary.h:152
@ GS1_LINTER_COUPON_MISSING_SAVE_VALUE_VLI
The coupon's Save Value VLI is missing.
Definition: gs1syntaxdictionary.h:122
@ GS1_LINTER_COUPON_INVALID_1ST_PURCHASE_REQUIREMENT_CODE
The coupon's primary purchase Requirement Code must be "0" to "4" or "9".
Definition: gs1syntaxdictionary.h:129
@ GS1_LINTER_COUPON_TRUNCATED_2ND_PURCHASE_REQUIREMENT
The coupon's second purchase Requirement is shorter than what is indicated by its VLI.
Definition: gs1syntaxdictionary.h:135
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition: gs1syntaxdictionary.h:66
@ GS1_LINTER_COUPON_INVALID_3RD_PURCHASE_REQUIREMENT_CODE
The coupon's third purchase Requirement Code must be "0" to "4" or "9".
Definition: gs1syntaxdictionary.h:146
@ GS1_LINTER_COUPON_EXPIRATION_BEFORE_START
The coupon's expiration date preceed the start date.
Definition: gs1syntaxdictionary.h:155
@ GS1_LINTER_COUPON_INVALID_ADDITIONAL_PURCHASE_RULES_CODE
The coupon's Additional Purchase Rules Code must be "0" to "3".
Definition: gs1syntaxdictionary.h:132
@ GS1_LINTER_COUPON_INVALID_1ST_PURCHASE_REQUIREMENT_LENGTH
The coupon's primary purchase Requirement VLI must be "1" to "5".
Definition: gs1syntaxdictionary.h:126
@ GS1_LINTER_INVALID_GCP_PREFIX
The GS1 Company Prefix is invalid.
Definition: gs1syntaxdictionary.h:78
@ GS1_LINTER_COUPON_TRUNCATED_3RD_PURCHASE_GCP
The coupon's third purchase GS1 Company Prefix is shorter than what is indicated by its VLI.
Definition: gs1syntaxdictionary.h:150
@ GS1_LINTER_NON_DIGIT_CHARACTER
A non-digit character was found where a digit is expected.
Definition: gs1syntaxdictionary.h:67
@ GS1_LINTER_COUPON_MISSING_DONT_MULTIPLY_FLAG
The coupon's Don't Multiply Flag is missing.
Definition: gs1syntaxdictionary.h:164
@ GS1_LINTER_COUPON_MISSING_SAVE_VALUE_CODE
The coupon's Save Value Code is missing.
Definition: gs1syntaxdictionary.h:159
@ GS1_LINTER_COUPON_INVALID_RETAILER_GCP_OR_GLN_LENGTH
The coupon's Retailer GCP/GLN VLI must be "1" to "7".
Definition: gs1syntaxdictionary.h:157
@ GS1_LINTER_COUPON_INVALID_3RD_PURCHASE_GCP_LENGTH
The coupon's third purchase GS1 Company Prefix VLI must be "0" to "6" or "9".
Definition: gs1syntaxdictionary.h:149
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_key(const char *data, size_t *err_pos, size_t *err_len)
Definition: lint_key.c:95