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

Purpose

The yymmdd linter ensures that the data represents a meaningful date, in YYMMDD format.

Functional Description

◆ gs1_lint_yymmdd()

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

Used to ensure that an AI component conforms to the YYMMDD format.

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_DATE_TOO_SHORT if the data is too short for YYMMDD format.
GS1_LINTER_DATE_TOO_LONG if the data is too long for YYMMDD format.
GS1_LINTER_NON_DIGIT_CHARACTER if the data contains a non-digit character.
GS1_LINTER_ILLEGAL_MONTH if the data contains an invalid month.
GS1_LINTER_ILLEGAL_DAY if the data contains an invalid day of the month.
53 {
54 
55  const gs1_lint_err_t ret = gs1_lint_yymmd0(data, err_pos, err_len);
56 
57  assert(ret == GS1_LINTER_OK ||
59  ret == GS1_LINTER_DATE_TOO_LONG ||
61  ret == GS1_LINTER_ILLEGAL_MONTH ||
62  ret == GS1_LINTER_ILLEGAL_DAY);
63 
64  if (ret != GS1_LINTER_OK)
65  return ret;
66 
67  if (data[4] == '0' && data[5] == '0') {
68  if (err_pos) *err_pos = 4;
69  if (err_len) *err_len = 2;
71  }
72 
73  return GS1_LINTER_OK;
74 
75 }
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yymmd0(const char *data, size_t *err_pos, size_t *err_len)
Definition: lint_yymmd0.c:60
gs1_lint_err_t
Linter return codes other than GS1_LINTER_OK indicate an error condition.
Definition: gs1syntaxdictionary.h:65
@ GS1_LINTER_ILLEGAL_DAY
The date contains an illegal day of the month.
Definition: gs1syntaxdictionary.h:102
@ GS1_LINTER_DATE_TOO_LONG
The date is too long for YYMMDD format.
Definition: gs1syntaxdictionary.h:95
@ GS1_LINTER_ILLEGAL_MONTH
The date contains an illegal month of the year.
Definition: gs1syntaxdictionary.h:101
@ GS1_LINTER_DATE_TOO_SHORT
The date is too short for YYMMDD format.
Definition: gs1syntaxdictionary.h:94
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition: gs1syntaxdictionary.h:66
@ GS1_LINTER_NON_DIGIT_CHARACTER
A non-digit character was found where a digit is expected.
Definition: gs1syntaxdictionary.h:67