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

Purpose

The winding linter ensures that the given data represents a meaningful Winding Direction on a roll, either "0" (face out), "1" (face in) or "9" (undefined).

Remarks
The Winding Direction is defined in the GS1 General Specifications section "Roll products - width, length, core diameter, direction, splices: AI (8001)".

Functional Description

◆ gs1_lint_winding()

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

Used to validate that an AI component is the string "0", "1" or "9".

Parameters
[in]dataPointer to the data to be linted. Must not be NULL.
[in]data_lenLength of the data to be linted.
[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_WINDING_DIRECTION if the data is not "0", "1" or "9".
54{
55
56 assert(data);
57
58
59 /*
60 * The data must be either "0", "1" or "9".
61 *
62 */
63 if (GS1_LINTER_UNLIKELY(data_len != 1))
66 0,
67 data_len
68 );
69
70 if (GS1_LINTER_UNLIKELY(data[0] != '0' && data[0] != '1' && data[0] != '9'))
73 0,
74 1
75 );
76
78
79}
#define GS1_LINTER_UNLIKELY(x)
Implementation may provide hint to the compiler that the expression is likely to be false.
Definition gs1syntaxdictionary-utils.h:76
#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:103
#define GS1_LINTER_RETURN_OK
Return from a linter indicating that no problem was detected with the given data.
Definition gs1syntaxdictionary-utils.h:88
@ GS1_LINTER_INVALID_WINDING_DIRECTION
The winding direction must be either "0", "1" or "9".
Definition gs1syntaxdictionary.h:96