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

Purpose

The iso5218 linter ensures that the given data represents a ISO/IEC 5218 biological sex code, either "0" (not known), "1" (male), "2" (female) or "9" (not applicable).

Remarks
The biological sex codes are defined by ISO/IEC 5218: Information technology - Codes for the representation of human sexes.

Functional Description

◆ gs1_lint_iso5218()

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

Used to validate that an AI component is the string "0", "1", "2" or "9".

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_INVALID_BIOLOGICAL_SEX_CODE if the data is not "0", "1", "2" or "9".
53{
54
55 assert(data);
56
57 /*
58 * The data must be either "0", "1", "2" or "9".
59 *
60 */
61 if (GS1_LINTER_UNLIKELY(data[0] == '\0' || data[1] != '\0'))
64 0,
65 strlen(data)
66 );
67
69 data[0] != '0' && data[0] != '1' && data[0] != '2' && data[0] != '9'
70 )
71 )
74 0,
75 1
76 );
77
79
80}
#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_INVALID_BIOLOGICAL_SEX_CODE
A valid ISO/IEC 5218 biological sex code required.
Definition gs1syntaxdictionary.h:188