GS1 Syntax Dictionary: Linter reference
A reference to the AI component linter routines referred to by the GS1 Syntax Dictionary.
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.
47 {
48 
49  size_t len;
50 
51  assert(data);
52 
53  len = strlen(data);
54 
55  if (*data == '\0') {
56  if (err_pos) *err_pos = 0;
57  if (err_len) *err_len = 0;
58  return GS1_LINTER_NOT_ZERO;
59  }
60 
61  /*
62  * Data must not contain a non-zero character
63  *
64  */
65  if (strspn(data, "0") != len) {
66  if (err_pos) *err_pos = 0;
67  if (err_len) *err_len = len;
68  return GS1_LINTER_NOT_ZERO;
69  }
70 
71  return GS1_LINTER_OK;
72 
73 }
@ GS1_LINTER_NOT_ZERO
A zero value is required.
Definition: gs1syntaxdictionary.h:82
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition: gs1syntaxdictionary.h:66