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

Purpose

The cset82 linter ensures that the given data contains only characters within the GS1 AI encodable character set 82 ("CSET 82").

Remarks
CSET 82 is defined in the GS1 General Specifications table "GS1 AI encodable character set 82".

Functional Description

◆ gs1_lint_cset82()

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

Used to validate that an AI component conforms to X..99 syntax.

Note: The length of the component is validated by the framework that calls this function.

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_CSET82_CHARACTER if the data contains a non-CSET 82 character.
56{
57
58 /*
59 * All characters in "CSET 82", the 82 character alphabet.
60 *
61 */
62 static const char* const cset82 =
63 "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRS"
64 "TUVWXYZ_abcdefghijklmnopqrstuvwxyz";
65
66 size_t pos;
67
68 assert(data);
69
70 /*
71 * Any character outside of CSET 82 is illegal.
72 *
73 */
74 if ((pos = strspn(data, cset82)) != strlen(data)) {
75 if (err_pos) *err_pos = pos;
76 if (err_len) *err_len = 1;
78 }
79
80 return GS1_LINTER_OK;
81
82}
@ GS1_LINTER_INVALID_CSET82_CHARACTER
A non-CSET 82 character was found where a CSET 82 character is expected.
Definition gs1syntaxdictionary.h:68
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition gs1syntaxdictionary.h:66