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

Purpose

The zero linter ensures that the given data has a zero value.

Functional Description

◆ gs1_lint_zero()

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

Used to validate that an AI component has a zero value.

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_NOT_ZERO if the data does not contain a zero value.
48{
49
50 const char *p;
51
52 assert(data);
53
54 if (GS1_LINTER_UNLIKELY(*data == '\0'))
57 0,
58 0
59 );
60
61 /*
62 * Data must not contain a non-zero character
63 *
64 */
65 for (p = data; *p; p++) {
66 if (GS1_LINTER_UNLIKELY(*p != '0')) {
67 while (*p) p++;
70 0,
71 (size_t)(p - data)
72 );
73 }
74 }
75
77
78}
#define GS1_LINTER_UNLIKELY(x)
Implemention 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_NOT_ZERO
A zero value is required.
Definition gs1syntaxdictionary.h:93