Used to validate that an AI component is an ISO 4217 three-digit currency code.
78{
79
80
81
82
83
84#ifdef GS1_LINTER_CUSTOM_ISO4217_LOOKUP
85#define GS1_LINTER_ISO4217_LOOKUP(cc) GS1_LINTER_CUSTOM_ISO4217_LOOKUP(cc)
86#else
87
88
89
90
91
92
93
94
95
96
97
98
99 static const uint64_t iso4217[] = {
100#if __STDC_VERSION__ >= 202311L
101 0b0000000010001000000000000000000010001000000010001011100000001000,
102 0b1000100010000000000010000010000010000000100010000000100000001000,
103 0b0000100010000000100000001000100000000000001000100000000000001001,
104 0b1000000000010000100000100000001000000010100000100010000000000000,
105 0b0000001000000010000000000000000000001000000000000000000000000000,
106 0b1000100010001000000010001000100010001000100010001000000010000000,
107 0b0000100010000010100010001010001001100010001000100010000000000010,
108 0b0000001000100010000000000000000010001000000000001010000010000000,
109 0b1000100000001000000011000000000000001000001000100000001000000000,
110 0b0010000000100010000000101000100010000000000000000000000000100000,
111 0b0001001000000010000000000000000000000000001000000010001000000010,
112 0b1010001000000000000000001000000000000000000010001000100010001000,
113 0b0000000010001000100010000000000010000001000000000010000000100000,
114 0b0010000010000000000000000010100000000000000000000010001000000000,
115 0b0000010000000000000000000000110111111110101011011011111111011111,
116 0b1111110111111101111111001110001000100101000000000000000000000000,
117#else
118
119
120
121
122
123
124
125
126 0x008800008808b808, 0x8880082080880808, 0x0880808800220009, 0x8010820202822000,
127 0x0202000008000000, 0x8888088888888080, 0x088288a262222002, 0x022200008800a080,
128 0x88080c0008220200, 0x2022028880000020, 0x1202000000202202, 0xa200008000088888,
129 0x0088880081002020, 0x2080002800002200, 0x0400000dfeadbfdf, 0xfdfdfce225000000,
130#endif
131 };
132
133
134#define GS1_LINTER_ISO4217_LOOKUP(cc) do { \
135 if (strlen(cc) == 3 && isdigit(cc[0]) && isdigit(cc[1]) && isdigit(cc[2])) { \
136 int v = (cc[0] - '0') * 100 + (cc[1] - '0') * 10 + cc[2] - '0'; \
137 GS1_LINTER_BITFIELD_LOOKUP(v, iso4217); \
138 } \
139} while (0)
140
141
142#endif
143
144 int valid = 0;
145
146 assert(data);
147
148
149
150
151
152 GS1_LINTER_ISO4217_LOOKUP(data);
153 if (valid)
155
156
157
158
159
162 0,
163 strlen(data)
164 );
165
166}
#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_NOT_ISO4217
A valid ISO 4217 three-digit currency code is required.
Definition gs1syntaxdictionary.h:100