Used to validate that an AI component conforms to the format required for an IBAN.
65{
66
67 char cc[3] = {0};
69 size_t len, pos;
70 const char *p;
71 unsigned int csum;
72
73 static const char* const csetiban = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
74
75 assert(data);
76
77 len = strlen(data);
78
82 0,
83 len
84 );
85
86
87
88
89
90 if ((pos = strspn(data, csetiban)) != len)
93 pos,
94 1
95 );
96
97
98
99
100
101 strncpy(cc, data, 2);
104
108 0,
109 2
110 );
111
112
113
114
115
116
117
118 csum = 0;
119 p = data + 4;
120 do {
121
122 if (*p < 'A')
123 csum = csum * 10 + (unsigned int)(*p - '0');
124 else
125 csum = csum * 100 + (unsigned int)(*p - 'A' + 10);
126 csum %= 97;
127
128
129
130
131
132 if (++p == data + len)
133 p = data;
134
135 } while (p != data + 4);
136
137
138
139
140
141 if (csum != 1)
144 2,
145 2
146 );
147
149
150}
#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_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso3166alpha2(const char *data, size_t *err_pos, size_t *err_len)
Definition lint_iso3166alpha2.c:75
gs1_lint_err_t
Linter return codes other than GS1_LINTER_OK indicate an error condition.
Definition gs1syntaxdictionary.h:76
@ GS1_LINTER_INCORRECT_IBAN_CHECKSUM
The IBAN is invalid since the check characters are incorrect.
Definition gs1syntaxdictionary.h:104
@ GS1_LINTER_INVALID_IBAN_CHARACTER
The IBAN contains an invalid character.
Definition gs1syntaxdictionary.h:102
@ GS1_LINTER_ILLEGAL_IBAN_COUNTRY_CODE
The IBAN must start with a valid ISO 3166 two-character country code.
Definition gs1syntaxdictionary.h:103
@ GS1_LINTER_IBAN_TOO_SHORT
The IBAN is too short.
Definition gs1syntaxdictionary.h:101
@ GS1_LINTER_OK
No issues were detected by the linter.
Definition gs1syntaxdictionary.h:77
@ GS1_LINTER_NOT_ISO3166_ALPHA2
A valid ISO 3166 two-character country code is required.
Definition gs1syntaxdictionary.h:99
#define IBAN_MIN_LENGTH
No clear minimum length; sufficient for check characters.
Definition lint_iban.c:39