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

Purpose

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

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

Functional Description

◆ gs1_lint_cset39()

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

Used to validate that an AI component conforms to C..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_CSET39_CHARACTER if the data contains a non-CSET 39 character.
57{
58
59 /*
60 * All characters in "CSET 39", the 39 character alphabet.
61 *
62 */
63 static const char* const cset39 =
64 "#-/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
65
66 size_t pos;
67
68 assert(data);
69
70 /*
71 * Any character outside of CSET 39 is illegal.
72 *
73 */
74 if ((pos = strspn(data, cset39)) != strlen(data))
77 pos,
78 1
79 );
80
82
83}
#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_CSET39_CHARACTER
A non-CSET 39 character was found where a CSET 39 character is expected.
Definition gs1syntaxdictionary.h:80