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

Purpose

The longitude linter ensures that the given data represents the longitude component of a WGS84 coordinate expressed as a 10-digit number.

Functional Description

◆ gs1_lint_longitude()

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

Used to validate that an AI component represents the longitude component of a WGS84 coordinate expressed as a 10-digit number.

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_LONGITUDE_INVALID_LENGTH if the longitude does not have length 10.
GS1_LINTER_INVALID_LONGITUDE if the longitude is outside the range 0000000000 - 3600000000.
51 {
52 
53  size_t len, pos;
54 
55  assert(data);
56 
57  len = strlen(data);
58 
59  /*
60  * Data must be 10 characters.
61  *
62  */
63  if (len != 10) {
64  if (err_pos) *err_pos = 0;
65  if (err_len) *err_len = len;
67  }
68 
69  /*
70  * Data must consist of all digits.
71  *
72  */
73  if ((pos = strspn(data, "0123456789")) != len) {
74  if (err_pos) *err_pos = pos;
75  if (err_len) *err_len = 1;
77  }
78 
79  /*
80  * The longitude must be within the range 0000000000 to 3600000000.
81  *
82  */
83  if (strtoul(data, NULL, 10) > 3600000000) {
84  if (err_pos) *err_pos = 0;
85  if (err_len) *err_len = 10;
87  }
88 
89  return GS1_LINTER_OK;
90 
91 }
@ GS1_LINTER_INVALID_LONGITUDE
The longitude is outside of the range "0000000000" to "3600000000".
Definition: gs1syntaxdictionary.h:169
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition: gs1syntaxdictionary.h:66
@ GS1_LINTER_LONGITUDE_INVALID_LENGTH
The longitude value must be 10 digits.
Definition: gs1syntaxdictionary.h:172
@ GS1_LINTER_NON_DIGIT_CHARACTER
A non-digit character was found where a digit is expected.
Definition: gs1syntaxdictionary.h:67