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 (strcmp(data, "0") != 0 && strcmp(data, "1") != 0 &&
62 strcmp(data, "2") != 0 && strcmp(data, "9") != 0)
65 0,
66 strlen(data)
67 );
68
70
71}
#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:77
#define GS1_LINTER_RETURN_OK
Return from a linter indicating that no problem was detected with the given data.
Definition gs1syntaxdictionary-utils.h:62
@ GS1_LINTER_INVALID_BIOLOGICAL_SEX_CODE
A valid ISO/IEC 5218 biological sex code required.
Definition gs1syntaxdictionary.h:188