GS1 Syntax Dictionary: Linter reference
A reference to the AI component linter routines referred to by the GS1 Syntax Dictionary.
lint_yesno.c File Reference

Purpose

The yesno linter ensures that the given data represents a meaningful boolean state, either "0" (no) or "1" (yes).

Functional Description

◆ gs1_lint_yesno()

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

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

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_OR_ONE if the data is not "0" or "1".
48 {
49 
50  assert(data);
51 
52  /*
53  * The data must be either "0" or "1".
54  *
55  */
56  if (strcmp(data, "0") != 0 && strcmp(data, "1") != 0) {
57  if (err_pos) *err_pos = 0;
58  if (err_len) *err_len = strlen(data);
60  }
61 
62  return GS1_LINTER_OK;
63 
64 }
@ GS1_LINTER_NOT_ZERO_OR_ONE
A "0" or "1" is required.
Definition: gs1syntaxdictionary.h:84
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition: gs1syntaxdictionary.h:66