GS1 Syntax Dictionary: Linter reference
A reference to the AI component linter routines referred to by the GS1 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".
52{
53
54 assert(data);
55
56 /*
57 * The data must be either "0", "1", "2" or "9".
58 *
59 */
60 if (strcmp(data, "0") != 0 && strcmp(data, "1") != 0 &&
61 strcmp(data, "2") != 0 && strcmp(data, "9") != 0) {
62 if (err_pos) *err_pos = 0;
63 if (err_len) *err_len = strlen(data);
65 }
66
67 return GS1_LINTER_OK;
68
69}
@ GS1_LINTER_INVALID_BIOLOGICAL_SEX_CODE
A valid ISO/IEC 5218 biological sex code required.
Definition gs1syntaxdictionary.h:176
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition gs1syntaxdictionary.h:66