GS1 Syntax Dictionary: Linter reference
A reference to the AI component linter routines referred to by the GS1 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".
52{
53
55
56 assert(data);
57
58 /*
59 * The data may contain the string "999".
60 *
61 */
62 if (strcmp(data, "999") == 0)
63 return GS1_LINTER_OK;
64
65 /*
66 * Validate the data with the iso3166 linter.
67 *
68 */
69 ret = gs1_lint_iso3166(data, err_pos, err_len);
70
71 assert(ret == GS1_LINTER_OK || ret == GS1_LINTER_NOT_ISO3166);
72
74
75}
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:65
@ GS1_LINTER_NOT_ISO3166_OR_999
A valid ISO 3166 three-digit country code or "999" is required.
Definition gs1syntaxdictionary.h:87
@ GS1_LINTER_NOT_ISO3166
A valid ISO 3166 three-digit country code is required.
Definition gs1syntaxdictionary.h:86
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition gs1syntaxdictionary.h:66