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

Purpose

The gcppos2 linter checks whether an input starts with a GS1 Company Prefix ("GCP") from its second character position.

Remarks
The GCP is defined in the GS1 General Specifications section "GS1 Company Prefix".

Functional Description

◆ gs1_lint_gcppos2()

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

Used to ensure that an AI component starts with a GCP from its second position.

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_GCP_PREFIX if the data does not start with a GCP.
GS1_LINTER_TOO_SHORT_FOR_GCP if the data is too short to start with a GCP.
GS1_LINTER_GCP_DATASOURCE_OFFLINE if the user-provided GCP lookup source is unavailable and this should result in the linting failing. [IMPLEMENTATION SPECIFIC]
58{
59
61
62 assert(data);
63
64 if (GS1_LINTER_UNLIKELY(!data[0] || !data[1]))
67 0,
68 !data[0] ? 0 : 1
69 );
70
71 ret = gs1_lint_gcppos1(data + 1, err_pos, err_len);
72
73 assert(ret == GS1_LINTER_OK ||
77
80 ret,
81 *err_pos + 1,
82 *err_len
83 );
84
86
87}
#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_lint_err_t
Linter return codes other than GS1_LINTER_OK indicate an error condition.
Definition gs1syntaxdictionary.h:76
@ GS1_LINTER_TOO_SHORT_FOR_GCP
The component is shorter than the minimum length GS1 Company Prefix.
Definition gs1syntaxdictionary.h:199
@ GS1_LINTER_GCP_DATASOURCE_OFFLINE
The data source for GCP lookups is offline.
Definition gs1syntaxdictionary.h:87
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition gs1syntaxdictionary.h:77
@ GS1_LINTER_INVALID_GCP_PREFIX
The GS1 Company Prefix is invalid.
Definition gs1syntaxdictionary.h:89
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_gcppos1(const char *data, size_t *err_pos, size_t *err_len)
Definition lint_gcppos1.c:101