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_importeridx.c File Reference

Purpose

The importeridx linter ensures that the given data is a valid Importer Index, as included in a Facility ID or Machine ID used in the EU 2018/574 system.

Remarks
The Facility ID and Machine ID data elements used in the EU 2018/574 system are described in the GS1 General Specification section "European Regulation 2018/574, traceability of tobacco products".

Functional Description

◆ gs1_lint_importeridx()

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

Used to validate that an AI component is a valid Importer Index.

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_INVALID_IMPORT_IDX_CHARACTER if the data is not a valid Importer Index character.
GS1_LINTER_IMPORTER_IDX_MUST_BE_ONE_CHARACTER if the data isn't a single character.
57{
58
59 size_t len;
60
61 /*
62 * All valid Importer Index characters.
63 *
64 */
65 static const char* const importeridx =
66 "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
67
68 assert(data);
69
70 len = strlen(data);
71
72 /*
73 * Data must be a single character.
74 *
75 */
76 if (len != 1) {
77 if (err_pos) *err_pos = 0;
78 if (err_len) *err_len = len;
80 }
81
82 /*
83 * Any character outside of the valid Importer Index character list is
84 * illegal.
85 *
86 */
87 if (strspn(data, importeridx) != len) {
88 if (err_pos) *err_pos = 0;
89 if (err_len) *err_len = 1;
91 }
92
93 return GS1_LINTER_OK;
94
95}
@ GS1_LINTER_INVALID_IMPORT_IDX_CHARACTER
The Importer Index is an invalid character.
Definition gs1syntaxdictionary.h:80
@ GS1_LINTER_IMPORTER_IDX_MUST_BE_ONE_CHARACTER
The Importer Index must be a single character.
Definition gs1syntaxdictionary.h:79
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition gs1syntaxdictionary.h:66