1 /******************************************************************************
2 * Copyright (c) 2000-2016 Ericsson Telecom AB
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
16 * Szabo, Janos Zoltan – initial implementation
17 * Zalanyi, Balazs Andor
19 ******************************************************************************/
28 class BITSTRING_ELEMENT;
30 class HEXSTRING_ELEMENT;
32 class OCTETSTRING_ELEMENT;
34 class CHARSTRING_ELEMENT;
35 class UNIVERSAL_CHARSTRING;
36 class UNIVERSAL_CHARSTRING_ELEMENT;
37 class BITSTRING_template;
38 class HEXSTRING_template;
39 class OCTETSTRING_template;
40 class CHARSTRING_template;
41 class UNIVERSAL_CHARSTRING_template;
43 extern char hexdigit_to_char(unsigned char hexdigit);
45 // Additional predefined functions defined in Annex C of ES 101 873-1
48 extern CHARSTRING int2char(int value);
49 extern CHARSTRING int2char(const INTEGER& value);
52 extern UNIVERSAL_CHARSTRING int2unichar(int value);
53 extern UNIVERSAL_CHARSTRING int2unichar(const INTEGER& value);
56 extern BITSTRING int2bit(int value, int length);
57 extern BITSTRING int2bit(int value, const INTEGER& length);
58 extern BITSTRING int2bit(const INTEGER& value, int length);
59 extern BITSTRING int2bit(const INTEGER& value, const INTEGER& length);
62 extern HEXSTRING int2hex(int value, int length);
63 extern HEXSTRING int2hex(int value, const INTEGER& length);
64 extern HEXSTRING int2hex(const INTEGER& value, int length);
65 extern HEXSTRING int2hex(const INTEGER& value, const INTEGER& length);
68 extern OCTETSTRING int2oct(int value, int length);
69 extern OCTETSTRING int2oct(int value, const INTEGER& length);
70 extern OCTETSTRING int2oct(const INTEGER& value, int length);
71 extern OCTETSTRING int2oct(const INTEGER& value, const INTEGER& length);
74 extern CHARSTRING int2str(int value);
75 extern CHARSTRING int2str(const INTEGER& value);
78 extern double int2float(int value);
79 extern double int2float(const INTEGER& value);
82 extern INTEGER float2int(double value);
83 extern INTEGER float2int(const FLOAT& value);
86 extern int char2int(char value);
87 extern int char2int(const char *value);
88 extern int char2int(const CHARSTRING& value);
89 extern int char2int(const CHARSTRING_ELEMENT& value);
92 extern OCTETSTRING char2oct(const char *value);
93 extern OCTETSTRING char2oct(const CHARSTRING& value);
94 extern OCTETSTRING char2oct(const CHARSTRING_ELEMENT& value);
97 extern int unichar2int(const universal_char& value);
98 extern int unichar2int(const UNIVERSAL_CHARSTRING& value);
99 extern int unichar2int(const UNIVERSAL_CHARSTRING_ELEMENT& value);
102 extern INTEGER bit2int(const BITSTRING& value);
103 extern INTEGER bit2int(const BITSTRING_ELEMENT& value);
106 extern HEXSTRING bit2hex(const BITSTRING& value);
107 extern HEXSTRING bit2hex(const BITSTRING_ELEMENT& value);
110 extern OCTETSTRING bit2oct(const BITSTRING& value);
111 extern OCTETSTRING bit2oct(const BITSTRING_ELEMENT& value);
114 extern CHARSTRING bit2str(const BITSTRING& value);
115 extern CHARSTRING bit2str(const BITSTRING_ELEMENT& value);
118 extern INTEGER hex2int(const HEXSTRING& value);
119 extern INTEGER hex2int(const HEXSTRING_ELEMENT& value);
122 extern BITSTRING hex2bit(const HEXSTRING& value);
123 extern BITSTRING hex2bit(const HEXSTRING_ELEMENT& value);
126 extern OCTETSTRING hex2oct(const HEXSTRING& value);
127 extern OCTETSTRING hex2oct(const HEXSTRING_ELEMENT& value);
130 extern CHARSTRING hex2str(const HEXSTRING& value);
131 extern CHARSTRING hex2str(const HEXSTRING_ELEMENT& value);
134 extern INTEGER oct2int(const OCTETSTRING& value);
135 extern INTEGER oct2int(const OCTETSTRING_ELEMENT& value);
138 extern BITSTRING oct2bit(const OCTETSTRING& value);
139 extern BITSTRING oct2bit(const OCTETSTRING_ELEMENT& value);
142 extern HEXSTRING oct2hex(const OCTETSTRING& value);
143 extern HEXSTRING oct2hex(const OCTETSTRING_ELEMENT& value);
146 extern CHARSTRING oct2str(const OCTETSTRING& value);
147 extern CHARSTRING oct2str(const OCTETSTRING_ELEMENT& value);
150 extern CHARSTRING oct2char(const OCTETSTRING& value);
151 extern CHARSTRING oct2char(const OCTETSTRING_ELEMENT& value);
154 extern INTEGER str2int(const char *value);
155 extern INTEGER str2int(const CHARSTRING& value);
156 extern INTEGER str2int(const CHARSTRING_ELEMENT& value);
159 extern OCTETSTRING str2oct(const char *value);
160 extern OCTETSTRING str2oct(const CHARSTRING& value);
163 extern double str2float(const char *value);
164 extern double str2float(const CHARSTRING& value);
166 // C.28 - lengthof: built-in
168 // C.29 - sizeof: built-in
170 // C.31 - ispresent: built-in
172 // C.32 - ischosen: built-in
175 extern CHARSTRING regexp(const CHARSTRING& instr, const CHARSTRING& expression,
177 extern CHARSTRING regexp(const CHARSTRING& instr, const CHARSTRING& expression,
178 const INTEGER& groupno);
179 extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
180 const UNIVERSAL_CHARSTRING* expression_val,
181 const UNIVERSAL_CHARSTRING_template* expression_tmpl,
183 extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
184 const UNIVERSAL_CHARSTRING& expression, int groupno);
185 extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
186 const UNIVERSAL_CHARSTRING& expression, const INTEGER& groupno);
187 // regexp on templates
188 extern CHARSTRING regexp(const CHARSTRING_template& instr,
189 const CHARSTRING_template& expression, int groupno);
190 extern CHARSTRING regexp(const CHARSTRING_template& instr,
191 const CHARSTRING_template& expression, const INTEGER& groupno);
192 extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING_template& instr,
193 const UNIVERSAL_CHARSTRING_template& expression, int groupno);
194 extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING_template& instr,
195 const UNIVERSAL_CHARSTRING_template& expression, const INTEGER& groupno);
198 extern void check_substr_arguments(int value_length, int index,
199 int returncount, const char *string_type, const char *element_name);
200 extern BITSTRING substr(const BITSTRING& value, int index, int returncount);
201 extern BITSTRING substr(const BITSTRING& value, int index,
202 const INTEGER& returncount);
203 extern BITSTRING substr(const BITSTRING& value, const INTEGER& index,
205 extern BITSTRING substr(const BITSTRING& value, const INTEGER& index,
206 const INTEGER& returncount);
207 extern BITSTRING substr(const BITSTRING_ELEMENT& value, int index,
209 extern BITSTRING substr(const BITSTRING_ELEMENT& value, int index,
210 const INTEGER& returncount);
211 extern BITSTRING substr(const BITSTRING_ELEMENT& value, const INTEGER& index,
213 extern BITSTRING substr(const BITSTRING_ELEMENT& value, const INTEGER& index,
214 const INTEGER& returncount);
216 extern HEXSTRING substr(const HEXSTRING& value, int index, int returncount);
217 extern HEXSTRING substr(const HEXSTRING& value, int index,
218 const INTEGER& returncount);
219 extern HEXSTRING substr(const HEXSTRING& value, const INTEGER& index,
221 extern HEXSTRING substr(const HEXSTRING& value, const INTEGER& index,
222 const INTEGER& returncount);
223 extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, int index,
225 extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, int index,
226 const INTEGER& returncount);
227 extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, const INTEGER& index,
229 extern HEXSTRING substr(const HEXSTRING_ELEMENT& value, const INTEGER& index,
230 const INTEGER& returncount);
232 extern OCTETSTRING substr(const OCTETSTRING& value, int index,
234 extern OCTETSTRING substr(const OCTETSTRING& value, int index,
235 const INTEGER& returncount);
236 extern OCTETSTRING substr(const OCTETSTRING& value, const INTEGER& index,
238 extern OCTETSTRING substr(const OCTETSTRING& value, const INTEGER& index,
239 const INTEGER& returncount);
240 extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value, int index,
242 extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value, int index,
243 const INTEGER& returncount);
244 extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value,
245 const INTEGER& index, int returncount);
246 extern OCTETSTRING substr(const OCTETSTRING_ELEMENT& value,
247 const INTEGER& index, const INTEGER& returncount);
249 extern CHARSTRING substr(const CHARSTRING& value, int index,
251 extern CHARSTRING substr(const CHARSTRING& value, int index,
252 const INTEGER& returncount);
253 extern CHARSTRING substr(const CHARSTRING& value, const INTEGER& index,
255 extern CHARSTRING substr(const CHARSTRING& value, const INTEGER& index,
256 const INTEGER& returncount);
257 extern CHARSTRING substr(const CHARSTRING_ELEMENT& value, int index,
259 extern CHARSTRING substr(const CHARSTRING_ELEMENT& value, int index,
260 const INTEGER& returncount);
261 extern CHARSTRING substr(const CHARSTRING_ELEMENT& value,
262 const INTEGER& index, int returncount);
263 extern CHARSTRING substr(const CHARSTRING_ELEMENT& value,
264 const INTEGER& index, const INTEGER& returncount);
266 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING& value,
267 int index, int returncount);
268 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING& value,
269 int index, const INTEGER& returncount);
270 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING& value,
271 const INTEGER& index, int returncount);
272 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING& value,
273 const INTEGER& index, const INTEGER& returncount);
274 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_ELEMENT& value,
275 int index, int returncount);
276 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_ELEMENT& value,
277 int index, const INTEGER& returncount);
278 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_ELEMENT& value,
279 const INTEGER& index, int returncount);
280 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_ELEMENT& value,
281 const INTEGER& index, const INTEGER& returncount);
283 // substr for templates
284 extern BITSTRING substr(const BITSTRING_template& value, int index,
286 extern BITSTRING substr(const BITSTRING_template& value, int index,
287 const INTEGER& returncount);
288 extern BITSTRING substr(const BITSTRING_template& value, const INTEGER& index,
290 extern BITSTRING substr(const BITSTRING_template& value, const INTEGER& index,
291 const INTEGER& returncount);
293 extern HEXSTRING substr(const HEXSTRING_template& value, int index,
295 extern HEXSTRING substr(const HEXSTRING_template& value, int index,
296 const INTEGER& returncount);
297 extern HEXSTRING substr(const HEXSTRING_template& value, const INTEGER& index,
299 extern HEXSTRING substr(const HEXSTRING_template& value, const INTEGER& index,
300 const INTEGER& returncount);
302 extern OCTETSTRING substr(const OCTETSTRING_template& value, int index,
304 extern OCTETSTRING substr(const OCTETSTRING_template& value, int index,
305 const INTEGER& returncount);
306 extern OCTETSTRING substr(const OCTETSTRING_template& value, const INTEGER& index,
308 extern OCTETSTRING substr(const OCTETSTRING_template& value, const INTEGER& index,
309 const INTEGER& returncount);
311 extern CHARSTRING substr(const CHARSTRING_template& value, int index,
313 extern CHARSTRING substr(const CHARSTRING_template& value, int index,
314 const INTEGER& returncount);
315 extern CHARSTRING substr(const CHARSTRING_template& value, const INTEGER& index,
317 extern CHARSTRING substr(const CHARSTRING_template& value, const INTEGER& index,
318 const INTEGER& returncount);
320 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_template& value,
321 int index, int returncount);
322 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_template& value,
323 int index, const INTEGER& returncount);
324 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_template& value,
325 const INTEGER& index, int returncount);
326 extern UNIVERSAL_CHARSTRING substr(const UNIVERSAL_CHARSTRING_template& value,
327 const INTEGER& index, const INTEGER& returncount);
330 extern void check_replace_arguments(int value_length, int index, int len,
331 const char *string_type, const char *element_name);
332 extern BITSTRING replace(const BITSTRING& value, int index, int len,
333 const BITSTRING& repl);
334 extern BITSTRING replace(const BITSTRING& value, int index,
335 const INTEGER& len, const BITSTRING& repl);
336 extern BITSTRING replace(const BITSTRING& value, const INTEGER& index,
337 int len, const BITSTRING& repl);
338 extern BITSTRING replace(const BITSTRING& value, const INTEGER& index,
339 const INTEGER& len, const BITSTRING& repl);
341 extern HEXSTRING replace(const HEXSTRING& value, int index, int len,
342 const HEXSTRING& repl);
343 extern HEXSTRING replace(const HEXSTRING& value, int index,
344 const INTEGER& len, const HEXSTRING& repl);
345 extern HEXSTRING replace(const HEXSTRING& value, const INTEGER& index,
346 int len, const HEXSTRING& repl);
347 extern HEXSTRING replace(const HEXSTRING& value, const INTEGER& index,
348 const INTEGER& len, const HEXSTRING& repl);
350 extern OCTETSTRING replace(const OCTETSTRING& value, int index, int len,
351 const OCTETSTRING& repl);
352 extern OCTETSTRING replace(const OCTETSTRING& value, int index,
353 const INTEGER& len, const OCTETSTRING& repl);
354 extern OCTETSTRING replace(const OCTETSTRING& value, const INTEGER& index,
355 int len, const OCTETSTRING& repl);
356 extern OCTETSTRING replace(const OCTETSTRING& value, const INTEGER& index,
357 const INTEGER& len, const OCTETSTRING& repl);
359 extern CHARSTRING replace(const CHARSTRING& value, int index, int len,
360 const CHARSTRING& repl);
361 extern CHARSTRING replace(const CHARSTRING& value, int index,
362 const INTEGER& len, const CHARSTRING& repl);
363 extern CHARSTRING replace(const CHARSTRING& value, const INTEGER& index,
364 int len, const CHARSTRING& repl);
365 extern CHARSTRING replace(const CHARSTRING& value, const INTEGER& index,
366 const INTEGER& len, const CHARSTRING& repl);
368 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING& value,
369 int index, int len, const UNIVERSAL_CHARSTRING& repl);
370 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING& value,
371 int index, const INTEGER& len, const UNIVERSAL_CHARSTRING& repl);
372 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING& value,
373 const INTEGER& index, int len, const UNIVERSAL_CHARSTRING& repl);
374 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING& value,
375 const INTEGER& index, const INTEGER& len,
376 const UNIVERSAL_CHARSTRING& repl);
377 // replace - template parameters
378 extern BITSTRING replace(const BITSTRING_template& value, int index, int len,
379 const BITSTRING_template& repl);
380 extern BITSTRING replace(const BITSTRING_template& value, int index,
381 const INTEGER& len, const BITSTRING_template& repl);
382 extern BITSTRING replace(const BITSTRING_template& value, const INTEGER& index,
383 int len, const BITSTRING_template& repl);
384 extern BITSTRING replace(const BITSTRING_template& value, const INTEGER& index,
385 const INTEGER& len, const BITSTRING_template& repl);
387 extern HEXSTRING replace(const HEXSTRING_template& value, int index, int len,
388 const HEXSTRING_template& repl);
389 extern HEXSTRING replace(const HEXSTRING_template& value, int index,
390 const INTEGER& len, const HEXSTRING_template& repl);
391 extern HEXSTRING replace(const HEXSTRING_template& value, const INTEGER& index,
392 int len, const HEXSTRING_template& repl);
393 extern HEXSTRING replace(const HEXSTRING_template& value, const INTEGER& index,
394 const INTEGER& len, const HEXSTRING_template& repl);
396 extern OCTETSTRING replace(const OCTETSTRING_template& value, int index, int len,
397 const OCTETSTRING& repl);
398 extern OCTETSTRING replace(const OCTETSTRING_template& value, int index,
399 const INTEGER& len, const OCTETSTRING& repl);
400 extern OCTETSTRING replace(const OCTETSTRING_template& value, const INTEGER& index,
401 int len, const OCTETSTRING_template& repl);
402 extern OCTETSTRING replace(const OCTETSTRING_template& value, const INTEGER& index,
403 const INTEGER& len, const OCTETSTRING_template& repl);
405 extern CHARSTRING replace(const CHARSTRING_template& value, int index, int len,
406 const CHARSTRING_template& repl);
407 extern CHARSTRING replace(const CHARSTRING_template& value, int index,
408 const INTEGER& len, const CHARSTRING_template& repl);
409 extern CHARSTRING replace(const CHARSTRING_template& value, const INTEGER& index,
410 int len, const CHARSTRING_template& repl);
411 extern CHARSTRING replace(const CHARSTRING_template& value, const INTEGER& index,
412 const INTEGER& len, const CHARSTRING_template& repl);
414 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING_template& value,
415 int index, int len, const UNIVERSAL_CHARSTRING_template& repl);
416 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING_template& value,
417 int index, const INTEGER& len, const UNIVERSAL_CHARSTRING_template& repl);
418 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING_template& value,
419 const INTEGER& index, int len, const UNIVERSAL_CHARSTRING_template& repl);
420 extern UNIVERSAL_CHARSTRING replace(const UNIVERSAL_CHARSTRING_template& value,
421 const INTEGER& index, const INTEGER& len,
422 const UNIVERSAL_CHARSTRING_template& repl);
427 extern double rnd(double seed);
428 extern double rnd(const FLOAT& seed);
431 // Additional predefined functions defined in Annex B of ES 101 873-7
433 // B.1 decomp - not implemented yet
436 // Non-standard functions
439 extern BITSTRING str2bit(const char *value);
440 extern BITSTRING str2bit(const CHARSTRING& value);
441 extern BITSTRING str2bit(const CHARSTRING_ELEMENT& value);
444 extern HEXSTRING str2hex(const char *value);
445 extern HEXSTRING str2hex(const CHARSTRING& value);
446 extern HEXSTRING str2hex(const CHARSTRING_ELEMENT& value);
449 extern CHARSTRING float2str(double value);
450 extern CHARSTRING float2str(const FLOAT& value);
453 extern CHARSTRING unichar2char(const UNIVERSAL_CHARSTRING& value);
454 extern CHARSTRING unichar2char(const UNIVERSAL_CHARSTRING_ELEMENT& value);
456 // only for internal purposes
457 extern CHARSTRING get_port_name(const char *port_name, int array_index);
458 extern CHARSTRING get_port_name(const char *port_name,
459 const INTEGER& array_index);
460 extern CHARSTRING get_port_name(const CHARSTRING& port_name, int array_index);
461 extern CHARSTRING get_port_name(const CHARSTRING& port_name,
462 const INTEGER& array_index);
464 unsigned char char_to_hexdigit(char c);
467 extern OCTETSTRING unichar2oct(const UNIVERSAL_CHARSTRING& invalue); // default string_encoding UTF-8
468 extern OCTETSTRING unichar2oct(const UNIVERSAL_CHARSTRING& invalue,
469 const CHARSTRING& string_encoding);
471 extern UNIVERSAL_CHARSTRING oct2unichar(const OCTETSTRING& invalue ); // default string_encoding UTF-8
472 extern UNIVERSAL_CHARSTRING oct2unichar(const OCTETSTRING& invalue,
473 const CHARSTRING& string_encoding);
475 extern CHARSTRING get_stringencoding(const OCTETSTRING& encoded__value);
476 extern OCTETSTRING remove_bom(const OCTETSTRING& encoded__value);
477 extern CHARSTRING encode_base64(const OCTETSTRING& msg, bool use_linebreaks);
478 extern CHARSTRING encode_base64(const OCTETSTRING& msg);
479 extern OCTETSTRING decode_base64(const CHARSTRING& b64);