GS1 Barcode Syntax Tests reference
A reference to the AI component "linter" routines referred to by the GS1 Barcode Syntax Dictionary. Copyright (c) 2022-2024 GS1 AISBL.
lint_iso3166999.c File Reference

Purpose

The iso3166999 linter ensures that the data represents an ISO 3166 "num-3" country code, or the value "999".

Remarks
The three-digit country codes are defined by ISO 3166-1:2020: Codes for the representation of names of countries and their subdivisions - Part 1: Country code as the "num-3" codes.

Functional Description

◆ gs1_lint_iso3166999()

GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso3166999 ( const char *const  data,
size_t *const  err_pos,
size_t *const  err_len 
)

Used to validate that an AI component is an ISO 3166 "num-3" country code or the string "999".

Parameters
[in]dataPointer to the null-terminated data to be linted. Must not be NULL.
[out]err_posTo facilitate error highlighting, the start position of the bad data is written to this pointer, if not NULL.
[out]err_lenThe length of the bad data is written to this pointer, if not NULL.
Returns
GS1_LINTER_OK if okay.
GS1_LINTER_NOT_ISO3166_OR_999 if the data is not a num-3 country code or the string "999".
53{
54
56
57 assert(data);
58
59 /*
60 * The data may contain the string "999".
61 *
62 */
63 if (strcmp(data, "999") == 0)
65
66 /*
67 * Validate the data with the iso3166 linter.
68 *
69 */
70 ret = gs1_lint_iso3166(data, err_pos, err_len);
71
72 assert(ret == GS1_LINTER_OK || ret == GS1_LINTER_NOT_ISO3166);
73
76 *err_pos,
77 *err_len
78 );
79
80}
#define GS1_LINTER_RETURN_ERROR(error, position, length)
Return from a linter indicating that a problem was detected with the given data.
Definition gs1syntaxdictionary-utils.h:77
#define GS1_LINTER_RETURN_OK
Return from a linter indicating that no problem was detected with the given data.
Definition gs1syntaxdictionary-utils.h:62
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso3166(const char *data, size_t *err_pos, size_t *err_len)
Definition lint_iso3166.c:76
gs1_lint_err_t
Linter return codes other than GS1_LINTER_OK indicate an error condition.
Definition gs1syntaxdictionary.h:76
@ GS1_LINTER_NOT_ISO3166_OR_999
A valid ISO 3166 three-digit country code or "999" is required.
Definition gs1syntaxdictionary.h:98
@ GS1_LINTER_NOT_ISO3166
A valid ISO 3166 three-digit country code is required.
Definition gs1syntaxdictionary.h:97
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition gs1syntaxdictionary.h:77