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_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.
58{
59
60 size_t len;
61
62 /*
63 * All valid Importer Index characters.
64 *
65 */
66 static const char* const importeridx =
67 "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
68
69 assert(data);
70
71 len = strlen(data);
72
73 /*
74 * Data must be a single character.
75 *
76 */
77 if (len != 1)
80 0,
81 len
82 );
83
84 /*
85 * Any character outside of the valid Importer Index character list is
86 * illegal.
87 *
88 */
89 if (strspn(data, importeridx) != len)
92 0,
93 1
94 );
95
97
98}
#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_LINTER_INVALID_IMPORT_IDX_CHARACTER
The Importer Index is an invalid character.
Definition gs1syntaxdictionary.h:91
@ GS1_LINTER_IMPORTER_IDX_MUST_BE_ONE_CHARACTER
The Importer Index must be a single character.
Definition gs1syntaxdictionary.h:90