1 /*
2    Copyright (C) 2002-2012, 2014-2020 Free Software Foundation, Inc.
3    Written by Keisuke Nishida, Roger While, Simon Sobisch, Ron Norman,
4    Edward Hart
5 
6    This file is part of GnuCOBOL.
7 
8    The GnuCOBOL runtime library is free software: you can redistribute it
9    and/or modify it under the terms of the GNU Lesser General Public License
10    as published by the Free Software Foundation, either version 3 of the
11    License, or (at your option) any later version.
12 
13    GnuCOBOL is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU Lesser General Public License for more details.
17 
18    You should have received a copy of the GNU Lesser General Public License
19    along with GnuCOBOL.  If not, see <https://www.gnu.org/licenses/>.
20 */
21 
22 #ifndef COB_COMMON_H
23 #define COB_COMMON_H
24 
25 /* Only define cob_decimal if we have the necessary mpz_t from gmp.h/mpir.h
26    (or can self-define it from mp.h) */
27 #if !defined (__GMP_H__)
28 #ifndef __GNU_MP__
29 #define COB_WITHOUT_DECIMAL
30 #else
31 typedef __mpz_struct mpz_t[1];
32 #endif
33 #endif
34 
35 
36 /* General type defines */
37 #define	cob_c8_t		char
38 #define	cob_s8_t		signed char
39 #define	cob_u8_t		unsigned char
40 #define	cob_s16_t		short
41 #define	cob_u16_t		unsigned short
42 #define	cob_s32_t		int
43 #define	cob_u32_t		unsigned int
44 #define	cob_sli_t		long int
45 #define	cob_uli_t		unsigned long int
46 
47 #if	defined(_WIN32) && !defined(__MINGW32__)
48 
49 #define	cob_s64_t		__int64
50 #define	cob_u64_t		unsigned __int64
51 
52 #define	COB_S64_C(x)		x ## I64
53 #define	COB_U64_C(x)		x ## UI64
54 
55 #else
56 
57 #define	cob_s64_t		long long
58 #define	cob_u64_t		unsigned long long
59 
60 #define	COB_S64_C(x)		x ## LL
61 #define	COB_U64_C(x)		x ## ULL
62 
63 #endif
64 
65 #if	defined(_WIN32)
66 
67 #define	CB_FMT_LLD		"%I64d"
68 #define	CB_FMT_LLU		"%I64u"
69 #define	CB_FMT_LLX		"%I64x"
70 #define	CB_FMT_PLLD		"%+*.*I64d"
71 #define	CB_FMT_PLLU		"%*.*I64u"
72 
73 #if defined (__MINGW32__)
74 #define	CB_FMT_LLD_F		"%I64dLL"
75 #define	CB_FMT_LLU_F		"%I64uULL"
76 #else
77 #define	CB_FMT_LLD_F		"%I64dI64"
78 #define	CB_FMT_LLU_F		"%I64uUI64"
79 #endif
80 
81 #else
82 
83 #define	CB_FMT_LLD		"%lld"
84 #define	CB_FMT_LLU		"%llu"
85 #define	CB_FMT_LLX		"%llx"
86 #define	CB_FMT_PLLD		"%+*.*lld"
87 #define	CB_FMT_PLLU		"%*.*llu"
88 #define	CB_FMT_LLD_F		"%lldLL"
89 #define	CB_FMT_LLU_F		"%lluULL"
90 
91 #endif
92 
93 #define	cob_c8_ptr		cob_c8_t *
94 #define	cob_u8_ptr		cob_u8_t *
95 #define	cob_s8_ptr		cob_s8_t *
96 #define	cob_u16_ptr		cob_u16_t *
97 #define	cob_s16_ptr		cob_s16_t *
98 #define	cob_u32_ptr		cob_u32_t *
99 #define	cob_s32_ptr		cob_s32_t *
100 #define	cob_u64_ptr		cob_u64_t *
101 #define	cob_s64_ptr		cob_s64_t *
102 
103 #define	cob_void_ptr		void *
104 #define	cob_field_ptr		cob_field *
105 #define	cob_file_ptr		cob_file *
106 #define	cob_module_ptr		cob_module *
107 #define	cob_screen_ptr		cob_screen *
108 #define	cob_file_key_ptr	cob_file_key *
109 
110 /* Readable compiler version defines */
111 
112 #if defined(_MSC_VER)
113 
114 /*
115 _MSC_VER == 1400 (Visual Studio 2005, VS8 , MSVC 8) since OS-Version 2000
116 _MSC_VER == 1500 (Visual Studio 2008, VS9 , MSVC 9) since OS-Version XP / 2003
117 _MSC_VER == 1600 (Visual Studio 2010, VS10, MSVC10) since OS-Version XP / 2003
118 _MSC_VER == 1700 (Visual Studio 2012, VS11, MSVC11) since OS-Version 7(XP) / 2008 R2(2003)
119 _MSC_VER == 1800 (Visual Studio 2013, VS12, MSVC12) since OS-Version 7(XP) / 2008 R2(2003)
120 _MSC_VER == 1900 (Visual Studio 2015, VS14, MSVC14) since OS-Version 7(XP) / 2008 R2(2003)
121 _MSC_VER == 1910 (Visual Studio 2017, VS15, MSVC14.1) since OS-Version 7 / 2012 R2
122 _MSC_VER == 1920 (Visual Studio 2019, VS16, MSVC14.2) since OS-Version 7 / 2012 R2
123 
124 Note: also defined together with __clang__ in both frontends:
125    __llvm__ Clang LLVM frontend for Visual Studio by LLVM Project (via clang-cl.exe [cl build options])
126    __c2__   Clang C2 frontend with MS CodeGen (via clang.exe [original clang build options])
127 */
128 
129 #if _MSC_VER >= 1500
130 #define COB_USE_VC2008_OR_GREATER 1
131 #else
132 #define COB_USE_VC2008_OR_GREATER 0
133 #if _MSC_VER < 1400
134 #error Support for Visual Studio 2003 and older Visual C++ compilers dropped with GnuCOBOL 2.0
135 #endif
136 #endif
137 
138 #if _MSC_VER >= 1700
139 #define COB_USE_VC2012_OR_GREATER 1
140 #else
141 #define COB_USE_VC2012_OR_GREATER 0
142 #endif
143 
144 #if _MSC_VER >= 1800
145 #define COB_USE_VC2013_OR_GREATER 1
146 #else
147 #define COB_USE_VC2013_OR_GREATER 0
148 #endif
149 
150 #if _MSC_VER >= 1900
151 #define COB_USE_VC2015_OR_GREATER 1
152 #else
153 #define COB_USE_VC2015_OR_GREATER 0
154 #endif
155 
156 #endif /* _MSC_VER */
157 
158 /* Byte swap functions */
159 
160 /*
161    The original idea for the byteswap routines was taken from GLib.
162    (Specifically glib/gtypes.h)
163    GLib is licensed under the GNU Lesser General Public License.
164 */
165 
166 /* Generic swapping functions */
167 
168 #undef	COB_BSWAP_16_CONSTANT
169 #undef	COB_BSWAP_32_CONSTANT
170 #undef	COB_BSWAP_64_CONSTANT
171 #undef	COB_BSWAP_16
172 #undef	COB_BSWAP_32
173 #undef	COB_BSWAP_64
174 
175 #define COB_BSWAP_16_CONSTANT(val)	((cob_u16_t) (		\
176     (((cob_u16_t)(val) & (cob_u16_t) 0x00FFU) << 8) |		\
177     (((cob_u16_t)(val) & (cob_u16_t) 0xFF00U) >> 8)))
178 
179 #define COB_BSWAP_32_CONSTANT(val)	((cob_u32_t) (		\
180     (((cob_u32_t) (val) & (cob_u32_t) 0x000000FFU) << 24) |	\
181     (((cob_u32_t) (val) & (cob_u32_t) 0x0000FF00U) <<  8) |	\
182     (((cob_u32_t) (val) & (cob_u32_t) 0x00FF0000U) >>  8) |	\
183     (((cob_u32_t) (val) & (cob_u32_t) 0xFF000000U) >> 24)))
184 
185 #define COB_BSWAP_64_CONSTANT(val)	((cob_u64_t) (		\
186     (((cob_u64_t) (val) &					\
187       (cob_u64_t) COB_U64_C(0x00000000000000FF)) << 56) |	\
188     (((cob_u64_t) (val) &					\
189       (cob_u64_t) COB_U64_C(0x000000000000FF00)) << 40) |	\
190     (((cob_u64_t) (val) &					\
191       (cob_u64_t) COB_U64_C(0x0000000000FF0000)) << 24) |	\
192     (((cob_u64_t) (val) &					\
193       (cob_u64_t) COB_U64_C(0x00000000FF000000)) <<  8) |	\
194     (((cob_u64_t) (val) &					\
195       (cob_u64_t) COB_U64_C(0x000000FF00000000)) >>  8) |	\
196     (((cob_u64_t) (val) &					\
197       (cob_u64_t) COB_U64_C(0x0000FF0000000000)) >> 24) |	\
198     (((cob_u64_t) (val) &					\
199       (cob_u64_t) COB_U64_C(0x00FF000000000000)) >> 40) |	\
200     (((cob_u64_t) (val) &					\
201       (cob_u64_t) COB_U64_C(0xFF00000000000000)) >> 56)))
202 
203 /* Machine/OS specific overrides */
204 
205 #ifdef	__GNUC__
206 
207 #if	__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
208 
209 #define COB_BSWAP_16(val) (COB_BSWAP_16_CONSTANT (val))
210 #define COB_BSWAP_32(val) (__builtin_bswap32 (val))
211 #define COB_BSWAP_64(val) (__builtin_bswap64 (val))
212 
213 #elif	defined(__i386__)
214 
215 #define COB_BSWAP_16(val) (COB_BSWAP_16_CONSTANT (val))
216 #define COB_BSWAP_32(val)					\
217        (__extension__						\
218 	({ register cob_u32_t __v,				\
219 	     __x = ((cob_u32_t) (val));				\
220 	   if (__builtin_constant_p (__x))			\
221 	     __v = COB_BSWAP_32_CONSTANT (__x);			\
222 	   else							\
223 	     __asm__ ("bswap %0"				\
224 		      : "=r" (__v)				\
225 		      : "0" (__x));				\
226 	    __v; }))
227 #define COB_BSWAP_64(val)					\
228        (__extension__						\
229 	({ union { cob_u64_t __ll;				\
230 		   cob_u32_t __l[2]; } __w, __r;		\
231 	   __w.__ll = ((cob_u64_t) (val));			\
232 	   if (__builtin_constant_p (__w.__ll))			\
233 	     __r.__ll = COB_BSWAP_64_CONSTANT (__w.__ll);	\
234 	   else							\
235 	     {							\
236 	       __r.__l[0] = COB_BSWAP_32 (__w.__l[1]);		\
237 	       __r.__l[1] = COB_BSWAP_32 (__w.__l[0]);		\
238 	     }							\
239 	   __r.__ll; }))
240 
241 #elif defined (__ia64__)
242 
243 #define COB_BSWAP_16(val) (COB_BSWAP_16_CONSTANT (val))
244 #define COB_BSWAP_32(val)					\
245        (__extension__						\
246 	 ({ register cob_u32_t __v,				\
247 	      __x = ((cob_u32_t) (val));			\
248 	    if (__builtin_constant_p (__x))			\
249 	      __v = COB_BSWAP_32_CONSTANT (__x);		\
250 	    else						\
251 	     __asm__ __volatile__ ("shl %0 = %1, 32 ;;"		\
252 				   "mux1 %0 = %0, @rev ;;"	\
253 				    : "=r" (__v)		\
254 				    : "r" (__x));		\
255 	    __v; }))
256 #define COB_BSWAP_64(val)					\
257        (__extension__						\
258 	({ register cob_u64_t __v,				\
259 	     __x = ((cob_u64_t) (val));				\
260 	   if (__builtin_constant_p (__x))			\
261 	     __v = COB_BSWAP_64_CONSTANT (__x);			\
262 	   else							\
263 	     __asm__ __volatile__ ("mux1 %0 = %1, @rev ;;"	\
264 				   : "=r" (__v)			\
265 				   : "r" (__x));		\
266 	   __v; }))
267 
268 #elif defined (__x86_64__)
269 
270 #define COB_BSWAP_16(val) (COB_BSWAP_16_CONSTANT (val))
271 #define COB_BSWAP_32(val)					\
272       (__extension__						\
273 	({ register cob_u32_t __v,				\
274 	     __x = ((cob_u32_t) (val));				\
275 	   if (__builtin_constant_p (__x))			\
276 	     __v = COB_BSWAP_32_CONSTANT (__x);			\
277 	   else							\
278 	    __asm__ ("bswapl %0"				\
279 		     : "=r" (__v)				\
280 		     : "0" (__x));				\
281 	   __v; }))
282 #define COB_BSWAP_64(val)					\
283        (__extension__						\
284 	({ register cob_u64_t __v,				\
285 	     __x = ((cob_u64_t) (val));				\
286 	   if (__builtin_constant_p (__x))			\
287 	     __v = COB_BSWAP_64_CONSTANT (__x);			\
288 	   else							\
289 	     __asm__ ("bswapq %0"				\
290 		      : "=r" (__v)				\
291 		      : "0" (__x));				\
292 	   __v; }))
293 
294 #else /* Generic gcc */
295 
296 #define COB_BSWAP_16(val) (COB_BSWAP_16_CONSTANT (val))
297 #define COB_BSWAP_32(val) (COB_BSWAP_32_CONSTANT (val))
298 #define COB_BSWAP_64(val) (COB_BSWAP_64_CONSTANT (val))
299 
300 #endif
301 
302 #elif defined(_MSC_VER)
303 
304 #define COB_BSWAP_16(val) (_byteswap_ushort (val))
305 #define COB_BSWAP_32(val) (_byteswap_ulong (val))
306 #define COB_BSWAP_64(val) (_byteswap_uint64 (val))
307 
308 #elif defined(__ORANGEC__)
309 
310 #define COB_BSWAP_16(val) (COB_BSWAP_16_CONSTANT (val))
311 #define COB_BSWAP_32(val) (__builtin_bswap32 (val))
312 #define COB_BSWAP_64(val) (__builtin_bswap64 (val))
313 
314 #else /* Generic */
315 
316 #define COB_BSWAP_16(val) (COB_BSWAP_16_CONSTANT (val))
317 #define COB_BSWAP_32(val) (COB_BSWAP_32_CONSTANT (val))
318 #define COB_BSWAP_64(val) (COB_BSWAP_64_CONSTANT (val))
319 
320 #endif
321 
322 /* End byte swap functions */
323 
324 /* Compiler characteristics */
325 
326 #ifdef	_MSC_VER
327 
328 #ifndef	_CRT_SECURE_NO_DEPRECATE
329 #define _CRT_SECURE_NO_DEPRECATE	1
330 #endif
331 
332 /* Disable certain warnings */
333 /* Deprecated functions */
334 #pragma warning(disable: 4996)
335 /* Function declarations without parameter list */
336 #pragma warning(disable: 4255)
337 
338 #define strncasecmp		_strnicmp
339 #define strcasecmp		_stricmp
340 #define snprintf		_snprintf
341 #define getpid			_getpid
342 #define access			_access
343 #define popen			_popen
344 #define pclose			_pclose
345 /* MSDN says these are available since VC2005 #if COB_USE_VC2013_OR_GREATER
346 only usable with COB_USE_VC2013_OR_GREATER */
347 #define timezone		_timezone
348 #define tzname			_tzname
349 #define daylight		_daylight
350 /* only usable with COB_USE_VC2013_OR_GREATER - End
351 #endif */
352 
353 #if !COB_USE_VC2013_OR_GREATER
354 #define atoll			_atoi64
355 #endif
356 
357 #define __attribute__(x)
358 
359 #ifndef	_M_IA64
360 #ifdef	_WIN64
361 #define	__x86_64__
362 #else
363 #define	__i386__
364 #endif
365 #else
366 #define __ia64__
367 #endif
368 
369 #endif /* _MSC_VER */
370 
371 #ifdef	__MINGW32__	/* needed by older versions */
372 #define strncasecmp		_strnicmp
373 #define strcasecmp		_stricmp
374 #endif /* __MINGW32__ */
375 
376 #ifdef __BORLANDC__
377 #define strncasecmp	strnicmp
378 #define strcasecmp	stricmp
379 #define _setmode	setmode
380 #define _chdir		chdir
381 #define timezone	_timezone
382 #define tzname		_tzname
383 #define daylight	_daylight
384 #endif /* __BORLANDC__ */
385 
386 #ifdef __ORANGEC__
387 #define timezone		_timezone
388 #define tzname			_tzname
389 #define daylight		_daylight
390 #endif /* _ORANGEC__ */
391 
392 #if	__SUNPRO_C
393 /* Disable certain warnings */
394 #pragma error_messages (off, E_STATEMENT_NOT_REACHED)
395 #endif
396 
397 #ifndef COB_WITHOUT_JMP
398 #include <setjmp.h>
399 #endif
400 
401 #ifndef	COB_EXT_EXPORT
402 #if	((defined(_WIN32) || defined(__CYGWIN__)) && !defined(__clang__))
403 #define COB_EXT_EXPORT	__declspec(dllexport) extern
404 #else
405 #define COB_EXT_EXPORT	extern
406 #endif
407 #endif
408 #ifndef COB_EXT_IMPORT
409 #if	((defined(_WIN32) || defined(__CYGWIN__)) && !defined(__clang__))
410 #define COB_EXT_IMPORT	__declspec(dllimport) extern
411 #else
412 #define COB_EXT_IMPORT	extern
413 #endif
414 #endif
415 
416 #ifndef COB_EXPIMP
417 #ifdef	COB_LIB_EXPIMP
418 	#define COB_EXPIMP	COB_EXT_EXPORT
419 #else
420 	#define COB_EXPIMP	COB_EXT_IMPORT
421 #endif
422 #endif
423 
424 #if	defined(COB_KEYWORD_INLINE)
425 	#define COB_INLINE	COB_KEYWORD_INLINE
426 #else
427 	#define COB_INLINE
428 #endif
429 
430 /* Also OK for icc which defines __GNUC__ */
431 
432 #if	 defined(__GNUC__) || \
433 	(defined(__xlc__) && __IBMC__ >= 700  ) || \
434 	(defined(__HP_cc) && __HP_cc  >= 61000)
435 #define	COB_A_NORETURN	__attribute__((noreturn))
436 #define	COB_A_FORMAT12	__attribute__((format(printf, 1, 2)))
437 #define	COB_A_FORMAT23	__attribute__((format(printf, 2, 3)))
438 #define	COB_A_FORMAT34	__attribute__((format(printf, 3, 4)))
439 #define	COB_A_FORMAT45	__attribute__((format(printf, 4, 5)))
440 #define	DECLNORET
441 #else
442 #define	COB_A_NORETURN
443 #define	COB_A_FORMAT12
444 #define	COB_A_FORMAT23
445 #define	COB_A_FORMAT34
446 #define	COB_A_FORMAT45
447 
448 #if defined	(_MSC_VER) || defined (__ORANGEC__) || \
449    (defined (__BORLANDC__) && defined (_WIN32))
450 #define	DECLNORET	__declspec(noreturn)
451 #else
452 #define	DECLNORET
453 #endif
454 #endif
455 
456 #if	defined(__GNUC__)
457 #define	optim_memcpy(x,y,z)	__builtin_memcpy (x, y, z)
458 #else
459 #define	optim_memcpy(x,y,z)	memcpy (x, y, z)
460 #endif
461 
462 #if	defined(__GNUC__) && (__GNUC__ >= 3)
463 #define likely(x)	__builtin_expect((long int)!!(x), 1L)
464 #define unlikely(x)	__builtin_expect((long int)!!(x), 0L)
465 #define	COB_A_MALLOC	__attribute__((malloc))
466 #define	COB_HAVE_STEXPR	1
467 
468 #if	__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
469 #define	COB_NOINLINE	__attribute__((noinline))
470 #define	COB_A_INLINE	__attribute__((always_inline))
471 #else
472 #define	COB_NOINLINE
473 #define	COB_A_INLINE
474 #endif
475 
476 #if	__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
477 #define	COB_A_COLD	__attribute__((cold))
478 #else
479 #define	COB_A_COLD
480 #endif
481 
482 #elif	defined(__xlc__) && __IBMC__ >= 700
483 
484 #if	__IBMC__ >= 900
485 #define likely(x)	__builtin_expect((long int)!!(x), 1L)
486 #define unlikely(x)	__builtin_expect((long int)!!(x), 0L)
487 #else
488 #define likely(x)	(x)
489 #define unlikely(x)	(x)
490 #endif
491 #define	COB_NOINLINE	__attribute__((noinline))
492 #define	COB_A_INLINE	__attribute__((always_inline))
493 #define	COB_A_MALLOC
494 #define	COB_A_COLD
495 #if	__IBMC__ >= 800
496 #define	COB_HAVE_STEXPR	1
497 #else
498 #undef	COB_HAVE_STEXPR
499 #endif
500 
501 #elif	defined(__SUNPRO_C) && __SUNPRO_C >= 0x590
502 
503 #define likely(x)	(x)
504 #define unlikely(x)	(x)
505 #define	COB_A_MALLOC	__attribute__((malloc))
506 #define	COB_NOINLINE	__attribute__((noinline))
507 #define	COB_A_INLINE	__attribute__((always_inline))
508 #define	COB_A_COLD
509 #define	COB_HAVE_STEXPR	1
510 
511 #elif	defined(_MSC_VER)
512 
513 #define likely(x)	(x)
514 #define unlikely(x)	(x)
515 #define	COB_A_MALLOC
516 #define	COB_NOINLINE	__declspec(noinline)
517 #define	COB_A_INLINE	__forceinline
518 #define	COB_A_COLD
519 /* #undef	COB_HAVE_STEXPR */
520 
521 #else
522 
523 #define likely(x)	(x)
524 #define unlikely(x)	(x)
525 #define	COB_A_MALLOC
526 #define	COB_NOINLINE
527 #define	COB_A_INLINE
528 #define	COB_A_COLD
529 #undef	COB_HAVE_STEXPR
530 
531 #endif
532 
533 /* Posix macros, in case they are not defined */
534 #ifndef	S_ISDIR
535 #define S_ISDIR(x)		(((x) & _S_IFMT) == _S_IFDIR)
536 #endif
537 
538 #ifndef	S_ISREG
539 #define S_ISREG(x)		(((x) & _S_IFMT) == _S_IFREG)
540 #endif
541 
542 /* Prevent unwanted verbosity when using icc */
543 #ifdef	__INTEL_COMPILER
544 
545 /* Unreachable code */
546 #pragma warning ( disable : 111 )
547 /* Declared but never referenced */
548 #pragma warning ( disable : 177 )
549 /* Format conversion */
550 #pragma warning ( disable : 181 )
551 /* Enumerated type mixed with other type */
552 #pragma warning ( disable : 188 )
553 /* #undefine tested for zero */
554 #pragma warning ( disable : 193 )
555 /* Set but not used */
556 #pragma warning ( disable : 593 )
557 /* Parameter not referenced */
558 #pragma warning ( disable : 869 )
559 /* Operands are evaluated in unspecified order */
560 #pragma warning ( disable : 981 )
561 /* Missing return at end of non-void function */
562 /* Note - occurs because we have a non-returning abort call in cobc */
563 #pragma warning ( disable : 1011 )
564 /* Declaration in same source as definition */
565 #pragma warning ( disable : 1419 )
566 /* Shadowed variable - 1599 and 1944 are essentially the same */
567 #pragma warning ( disable : 1599 )
568 #pragma warning ( disable : 1944 )
569 /* Possible loss of precision */
570 #pragma warning ( disable : 2259 )
571 
572 #endif
573 
574 #if defined(_MSC_VER) || defined(__ORANGEC__) || defined(__WATCOMC__) || \
575     defined(__BORLANDC__) || defined(__MINGW32__) || defined (__DJGPP__)
576 #define PATHSEP_CHAR (char) ';'
577 #define PATHSEP_STR (char *) ";"
578 #else
579 #define PATHSEP_CHAR (char) ':'
580 #define PATHSEP_STR (char *) ":"
581 #endif
582 #ifndef	_WIN32 /* note: needs to be \ for MinGW, needed for cobc -j */
583 #define SLASH_CHAR	(char) '/'
584 #define SLASH_STR	(char *) "/"
585 #else
586 #define SLASH_CHAR	(char) '\\'
587 #define SLASH_STR	(char *) "\\"
588 #endif
589 
590 #ifdef __DJGPP__
591 #define HAVE_8DOT3_FILENAMES
592 #endif
593 
594 /* End compiler stuff */
595 
596 /* EBCDIC determination */
597 
598 #if ' ' == 0x40
599 #define	COB_EBCDIC_MACHINE
600 #else
601 #undef	COB_EBCDIC_MACHINE
602 #endif
603 
604 /* Macro to prevent compiler warning "conditional expression is constant" */
605 #if defined (_MSC_VER) && COB_USE_VC2008_OR_GREATER
606 #define ONCE_COB \
607 	__pragma( warning(push) )		\
608 	__pragma( warning(disable:4127) )	\
609 	while (0) \
610 	__pragma( warning(pop) )
611 #else
612 #define ONCE_COB while (0)
613 #endif
614 
615 /* Macro to prevent unused parameter warning */
616 
617 #define	COB_UNUSED(z)	do { (void)(z); } ONCE_COB
618 
619 /* Buffer size definitions */
620 
621 #define	COB_MINI_BUFF		256
622 #define	COB_SMALL_BUFF		1024
623 #define	COB_NORMAL_BUFF		2048
624 #define	COB_FILE_BUFF		4096
625 #define	COB_MEDIUM_BUFF		8192
626 #define	COB_LARGE_BUFF		16384
627 #define	COB_MINI_MAX		(COB_MINI_BUFF - 1)
628 #define	COB_SMALL_MAX		(COB_SMALL_BUFF - 1)
629 #define	COB_NORMAL_MAX		(COB_NORMAL_BUFF - 1)
630 #define	COB_FILE_MAX		(COB_FILE_BUFF - 1)
631 #define	COB_MEDIUM_MAX		(COB_MEDIUM_BUFF - 1)
632 #define	COB_LARGE_MAX		(COB_LARGE_BUFF - 1)
633 
634 /* Perform stack size */
635 #define	COB_STACK_SIZE		255
636 
637 /* Maximum size of file records */
638 /* TODO: add compiler configuration for limiting this */
639 #define	MAX_FD_RECORD		64 * 1024 * 1024
640 
641 /* Maximum size of file records (IDX) */
642 /* TODO: define depending on used ISAM */
643 /* TODO: add compiler configuration for limiting this */
644 #define	MAX_FD_RECORD_IDX	65535
645 
646 /* Maximum amount of keys per file */
647 /* TODO: define depending on used ISAM */
648 /* TODO: add compiler configuration for limiting this */
649 #define	MAX_FILE_KEYS	255
650 
651 /* Maximum number of field digits */
652 #define	COB_MAX_DIGITS		38
653 
654 /* Maximum digits in binary field */
655 #define	COB_MAX_BINARY		39
656 
657 /* Maximum exponent digits (both in literals and floating-point numeric-edited item */
658 #define COB_FLOAT_DIGITS_MAX         36
659 
660 /* Maximum bytes in a single/group field,
661    which doesn't contain UNBOUNDED items */
662 /* TODO: add compiler configuration for limiting this */
663 #define	COB_MAX_FIELD_SIZE	268435456
664 
665 /* Maximum bytes in an unbounded table entry
666    (IBM: 999999998) */
667 #define	COB_MAX_UNBOUNDED_SIZE	999999998
668 
669 /* Maximum number of cob_decimal structures */
670 #define	COB_MAX_DEC_STRUCT	32
671 
672 /* Maximum length of COBOL words */
673 #define	COB_MAX_WORDLEN		63
674 
675 /* Maximum length of literals */
676 #define	COB_MAX_LITERAL_LEN		256 * 1024
677 
678 /* Maximum length of COBOL program names */
679 #define	COB_MAX_NAMELEN		31
680 
681 /* Maximum number of subscripts */
682 #define COB_MAX_SUBSCRIPTS	16
683 
684 /* Memory size for sorting */
685 #define	COB_SORT_MEMORY		128 * 1024 * 1024
686 #define	COB_SORT_CHUNK		256 * 1024
687 
688 /* Program return types */
689 #define	COB_RET_TYPE_INT	0
690 #define	COB_RET_TYPE_PTR	1
691 #define	COB_RET_TYPE_VOID	2
692 
693 /* Fold case types */
694 #define	COB_FOLD_NONE		0
695 #define	COB_FOLD_UPPER		1
696 #define	COB_FOLD_LOWER		2
697 
698 /* Locale types */
699 #define	COB_LC_COLLATE		0
700 #define	COB_LC_CTYPE		1
701 #define	COB_LC_MESSAGES		2
702 #define	COB_LC_MONETARY		3
703 #define	COB_LC_NUMERIC		4
704 #define	COB_LC_TIME		5
705 #define	COB_LC_ALL		6
706 #define	COB_LC_USER		7
707 #define	COB_LC_CLASS		8
708 
709 /* Field types */
710 
711 #define COB_TYPE_UNKNOWN		0x00
712 #define COB_TYPE_GROUP			0x01U
713 #define COB_TYPE_BOOLEAN		0x02U
714 
715 #define COB_TYPE_NUMERIC		0x10U
716 #define COB_TYPE_NUMERIC_DISPLAY	0x10U
717 #define COB_TYPE_NUMERIC_BINARY		0x11U
718 #define COB_TYPE_NUMERIC_PACKED		0x12U
719 #define COB_TYPE_NUMERIC_FLOAT		0x13U
720 #define COB_TYPE_NUMERIC_DOUBLE		0x14U
721 #define COB_TYPE_NUMERIC_L_DOUBLE	0x15U
722 #define COB_TYPE_NUMERIC_FP_DEC64	0x16U
723 #define COB_TYPE_NUMERIC_FP_DEC128	0x17U
724 #define COB_TYPE_NUMERIC_FP_BIN32	0x18U
725 #define COB_TYPE_NUMERIC_FP_BIN64	0x19U
726 #define COB_TYPE_NUMERIC_FP_BIN128	0x1AU
727 #define COB_TYPE_NUMERIC_COMP5		0x1BU
728 
729 #define COB_TYPE_NUMERIC_EDITED		0x24U
730 
731 #define COB_TYPE_ALNUM			0x20U
732 #define COB_TYPE_ALPHANUMERIC		0x21U
733 #define COB_TYPE_ALPHANUMERIC_ALL	0x22U
734 #define COB_TYPE_ALPHANUMERIC_EDITED	0x23U
735 
736 #define COB_TYPE_NATIONAL		0x40U
737 #define COB_TYPE_NATIONAL_EDITED	0x41U
738 
739 /* Field flags */
740 
741 #define COB_FLAG_HAVE_SIGN		(1U << 0)	/* 0x0001 */
742 #define COB_FLAG_SIGN_SEPARATE		(1U << 1)	/* 0x0002 */
743 #define COB_FLAG_SIGN_LEADING		(1U << 2)	/* 0x0004 */
744 #define COB_FLAG_BLANK_ZERO		(1U << 3)	/* 0x0008 */
745 #define COB_FLAG_JUSTIFIED		(1U << 4)	/* 0x0010 */
746 #define COB_FLAG_BINARY_SWAP		(1U << 5)	/* 0x0020 */
747 #define COB_FLAG_REAL_BINARY		(1U << 6)	/* 0x0040 */
748 #define COB_FLAG_IS_POINTER		(1U << 7)	/* 0x0080 */
749 #define COB_FLAG_NO_SIGN_NIBBLE		(1U << 8)	/* 0x0100 */
750 #define COB_FLAG_IS_FP			(1U << 9)	/* 0x0200 */
751 #define COB_FLAG_REAL_SIGN		(1U << 10)	/* 0x0400 */
752 #define COB_FLAG_BINARY_TRUNC		(1U << 11)	/* 0x0800 */
753 #define COB_FLAG_CONSTANT		(1U << 12)	/* 0x1000 */
754 
755 #define COB_FIELD_HAVE_SIGN(f)		((f)->attr->flags & COB_FLAG_HAVE_SIGN)
756 #define COB_FIELD_SIGN_SEPARATE(f)	((f)->attr->flags & COB_FLAG_SIGN_SEPARATE)
757 #define COB_FIELD_SIGN_LEADING(f)	((f)->attr->flags & COB_FLAG_SIGN_LEADING)
758 #define COB_FIELD_BLANK_ZERO(f)		((f)->attr->flags & COB_FLAG_BLANK_ZERO)
759 #define COB_FIELD_JUSTIFIED(f)		((f)->attr->flags & COB_FLAG_JUSTIFIED)
760 #define COB_FIELD_BINARY_SWAP(f)	((f)->attr->flags & COB_FLAG_BINARY_SWAP)
761 #define COB_FIELD_REAL_BINARY(f)	((f)->attr->flags & COB_FLAG_REAL_BINARY)
762 #define COB_FIELD_IS_POINTER(f)		((f)->attr->flags & COB_FLAG_IS_POINTER)
763 #define COB_FIELD_NO_SIGN_NIBBLE(f)	((f)->attr->flags & COB_FLAG_NO_SIGN_NIBBLE)
764 #define COB_FIELD_IS_FP(f)		((f)->attr->flags & COB_FLAG_IS_FP)
765 #define COB_FIELD_REAL_SIGN(f)		((f)->attr->flags & COB_FLAG_REAL_SIGN)
766 #define COB_FIELD_BINARY_TRUNC(f)	((f)->attr->flags & COB_FLAG_BINARY_TRUNC)
767 #define COB_FIELD_CONSTANT(f)		((f)->attr->flags & COB_FLAG_CONSTANT)
768 
769 #define	COB_FLAG_LEADSEP		\
770 	(COB_FLAG_SIGN_SEPARATE | COB_FLAG_SIGN_LEADING)
771 
772 #define COB_FIELD_SIGN_LEADSEP(f)	\
773 	(((f)->attr->flags & COB_FLAG_LEADSEP) == COB_FLAG_LEADSEP)
774 
775 #define COB_FIELD_TYPE(f)	((f)->attr->type)
776 #define COB_FIELD_DIGITS(f)	((f)->attr->digits)
777 #define COB_FIELD_SCALE(f)	((f)->attr->scale)
778 #define COB_FIELD_FLAGS(f)	((f)->attr->flags)
779 #define COB_FIELD_PIC(f)	((f)->attr->pic)
780 
781 #define COB_FIELD_DATA(f)	\
782 	((f)->data + (COB_FIELD_SIGN_LEADSEP (f) ? 1 : 0))
783 
784 #define COB_FIELD_SIZE(f)	\
785 	(COB_FIELD_SIGN_SEPARATE (f) ? f->size - 1 : f->size)
786 
787 #define COB_FIELD_IS_NUMERIC(f)	(COB_FIELD_TYPE (f) & COB_TYPE_NUMERIC)
788 #define COB_FIELD_IS_NUMDISP(f)	(COB_FIELD_TYPE (f) == COB_TYPE_NUMERIC_DISPLAY)
789 #define COB_FIELD_IS_ALNUM(f)	(COB_FIELD_TYPE (f) == COB_TYPE_ALPHANUMERIC)
790 #define COB_FIELD_IS_ANY_ALNUM(f)	(COB_FIELD_TYPE (f) & COB_TYPE_ALNUM)
791 #define COB_FIELD_IS_NATIONAL(f)	(COB_FIELD_TYPE (f) & COB_TYPE_NATIONAL)
792 
793 
794 #define	COB_DISPLAY_SIGN_ASCII	0
795 #define	COB_DISPLAY_SIGN_EBCDIC	1
796 
797 #define	COB_NATIONAL_SIZE	2
798 
799 #define	COB_SET_FLD(v,x,y,z)	(v.size = x, v.data = y, v.attr = z, &v)
800 #define	COB_SET_DATA(x,z)	(x.data = z, &x)
801 
802 /* Fatal error definitions */
803 
804 enum cob_fatal_error {
805 	COB_FERROR_NONE = 0,
806 	COB_FERROR_CANCEL,
807 	COB_FERROR_INITIALIZED,
808 	COB_FERROR_CODEGEN,
809 	COB_FERROR_CHAINING,
810 	COB_FERROR_STACK,
811 	COB_FERROR_GLOBAL,
812 	COB_FERROR_MEMORY,
813 	COB_FERROR_MODULE,
814 	COB_FERROR_RECURSIVE,
815 	COB_FERROR_SCR_INP,
816 	COB_FERROR_FILE,
817 	COB_FERROR_FUNCTION,
818 	COB_FERROR_FREE,
819 	COB_FERROR_XML,
820 	COB_FERROR_JSON
821 };
822 
823 /* Exception identifier enumeration */
824 
825 #undef	COB_EXCEPTION
826 #ifndef COB_WITHOUT_EXCEPTIONS
827 #define	COB_EXCEPTION(code,tag,name,critical)	tag,
828 
829 enum cob_exception_id {
830 	COB_EC_ZERO = 0,
831 #include <libcob/exception.def>
832 	COB_EC_MAX
833 };
834 
835 #undef	COB_EXCEPTION
836 #endif
837 
838 /* File attributes */
839 
840 /* Start conditions */
841 /* Note that COB_NE is disallowed */
842 #define COB_EQ			1	/* x == y */
843 #define COB_LT			2	/* x <  y */
844 #define COB_LE			3	/* x <= y */
845 #define COB_GT			4	/* x >  y */
846 #define COB_GE			5	/* x >= y */
847 #define COB_NE			6	/* x != y */
848 #define COB_FI			7	/* First */
849 #define COB_LA			8	/* Last */
850 
851 #define COB_ASCENDING		0
852 #define COB_DESCENDING		1
853 
854 #define COB_FILE_MODE		0666
855 
856 /* Organization, FIXME: change to enum */
857 
858 #define COB_ORG_SEQUENTIAL	0
859 #define COB_ORG_LINE_SEQUENTIAL	1
860 #define COB_ORG_RELATIVE	2
861 #define COB_ORG_INDEXED		3
862 #define COB_ORG_SORT		4
863 #define COB_ORG_MAX		5
864 #define COB_ORG_MESSAGE	6 /* only for syntax checks */
865 
866 /* Access mode, FIXME: change to enum */
867 
868 #define COB_ACCESS_SEQUENTIAL	1
869 #define COB_ACCESS_DYNAMIC	2
870 #define COB_ACCESS_RANDOM	3
871 
872 /* SELECT features */
873 
874 #define	COB_SELECT_FILE_STATUS	(1U << 0)
875 #define	COB_SELECT_EXTERNAL	(1U << 1)
876 #define	COB_SELECT_LINAGE	(1U << 2)
877 #define	COB_SELECT_SPLITKEY	(1U << 3)
878 #define	COB_SELECT_STDIN	(1U << 4)
879 #define	COB_SELECT_STDOUT	(1U << 5)
880 #define	COB_SELECT_TEMPORARY	(1U << 6)
881 
882 #define COB_FILE_SPECIAL(x)	\
883 	((x)->flag_select_features & (COB_SELECT_STDIN | COB_SELECT_STDOUT))
884 #define COB_FILE_STDIN(x)	((x)->flag_select_features & COB_SELECT_STDIN)
885 #define COB_FILE_STDOUT(x)	((x)->flag_select_features & COB_SELECT_STDOUT)
886 #define COB_FILE_TEMPORARY(x)	((x)->flag_select_features & COB_SELECT_TEMPORARY)
887 
888 /* Lock mode */
889 
890 #define COB_LOCK_EXCLUSIVE	(1U << 0)
891 #define COB_LOCK_MANUAL		(1U << 1)
892 #define COB_LOCK_AUTOMATIC	(1U << 2)
893 #define COB_LOCK_MULTIPLE	(1U << 3)
894 #define COB_LOCK_OPEN_EXCLUSIVE	(1U << 4)
895 
896 #define COB_FILE_EXCLUSIVE	(COB_LOCK_EXCLUSIVE | COB_LOCK_OPEN_EXCLUSIVE)
897 
898 /* Open mode */
899 
900 #define COB_OPEN_CLOSED		0
901 #define COB_OPEN_INPUT		1
902 #define COB_OPEN_OUTPUT		2
903 #define COB_OPEN_I_O		3
904 #define COB_OPEN_EXTEND		4
905 #define COB_OPEN_LOCKED		5
906 
907 /* Close options */
908 
909 #define COB_CLOSE_NORMAL	0
910 #define COB_CLOSE_LOCK		1
911 #define COB_CLOSE_NO_REWIND	2
912 #define COB_CLOSE_UNIT		3
913 #define COB_CLOSE_UNIT_REMOVAL	4
914 
915 /* Write options */
916 
917 #define COB_WRITE_MASK		0x0000FFFF
918 
919 #define COB_WRITE_LINES		0x00010000
920 #define COB_WRITE_PAGE		0x00020000
921 #define COB_WRITE_CHANNEL	0x00040000
922 #define COB_WRITE_AFTER		0x00100000
923 #define COB_WRITE_BEFORE	0x00200000
924 #define COB_WRITE_EOP		0x00400000
925 #define COB_WRITE_LOCK		0x00800000
926 #define COB_WRITE_NO_LOCK	0x01000000
927 
928 /* Read options */
929 
930 #define COB_READ_NEXT		(1 << 0)
931 #define COB_READ_PREVIOUS	(1 << 1)
932 #define COB_READ_FIRST		(1 << 2)
933 #define COB_READ_LAST		(1 << 3)
934 #define COB_READ_LOCK		(1 << 4)
935 #define COB_READ_NO_LOCK	(1 << 5)
936 #define COB_READ_KEPT_LOCK	(1 << 6)
937 #define COB_READ_WAIT_LOCK	(1 << 7)
938 #define COB_READ_IGNORE_LOCK	(1 << 8)
939 
940 #define COB_READ_MASK		\
941 	(COB_READ_NEXT | COB_READ_PREVIOUS | COB_READ_FIRST | COB_READ_LAST)
942 
943 /* I-O status */
944 
945 #define COB_STATUS_00_SUCCESS			00
946 #define COB_STATUS_02_SUCCESS_DUPLICATE		02
947 #define COB_STATUS_04_SUCCESS_INCOMPLETE	04
948 #define COB_STATUS_05_SUCCESS_OPTIONAL		05
949 #define COB_STATUS_07_SUCCESS_NO_UNIT		07
950 #define COB_STATUS_10_END_OF_FILE		10
951 #define COB_STATUS_14_OUT_OF_KEY_RANGE		14
952 #define COB_STATUS_21_KEY_INVALID		21
953 #define COB_STATUS_22_KEY_EXISTS		22
954 #define COB_STATUS_23_KEY_NOT_EXISTS		23
955 #define COB_STATUS_24_KEY_BOUNDARY		24
956 #define COB_STATUS_30_PERMANENT_ERROR		30
957 #define COB_STATUS_31_INCONSISTENT_FILENAME	31
958 #define COB_STATUS_34_BOUNDARY_VIOLATION	34
959 #define COB_STATUS_35_NOT_EXISTS		35
960 #define COB_STATUS_37_PERMISSION_DENIED		37
961 #define COB_STATUS_38_CLOSED_WITH_LOCK		38
962 #define COB_STATUS_39_CONFLICT_ATTRIBUTE	39
963 #define COB_STATUS_41_ALREADY_OPEN		41
964 #define COB_STATUS_42_NOT_OPEN			42
965 #define COB_STATUS_43_READ_NOT_DONE		43
966 #define COB_STATUS_44_RECORD_OVERFLOW		44
967 #define COB_STATUS_45_IDENTIFICATION_FAILURE	45	/* currently not implemented */
968 #define COB_STATUS_46_READ_ERROR		46
969 #define COB_STATUS_47_INPUT_DENIED		47
970 #define COB_STATUS_48_OUTPUT_DENIED		48
971 #define COB_STATUS_49_I_O_DENIED		49
972 #define COB_STATUS_51_RECORD_LOCKED		51
973 #define COB_STATUS_52_DEAD_LOCK			52	/* currently not implemented (patch available) */
974 #define COB_STATUS_53_MAX_LOCKS			53	/* currently not implemented */
975 #define COB_STATUS_54_MAX_LOCKS_FD		54	/* currently not implemented */
976 #define COB_STATUS_57_I_O_LINAGE		57
977 #define COB_STATUS_61_FILE_SHARING		61
978 #define COB_STATUS_91_NOT_AVAILABLE		91
979 
980 /* Special status */
981 /* Used by extfh handler */
982 #define	COB_NOT_CONFIGURED			32768
983 
984 /* End File attributes */
985 
986 /* Number store defines */
987 
988 #define COB_STORE_ROUND			(1 << 0)
989 #define COB_STORE_KEEP_ON_OVERFLOW	(1 << 1)
990 #define COB_STORE_TRUNC_ON_OVERFLOW	(1 << 2)
991 
992 #define COB_STORE_AWAY_FROM_ZERO	(1 << 4)
993 #define COB_STORE_NEAR_AWAY_FROM_ZERO	(1 << 5)
994 #define COB_STORE_NEAR_EVEN		(1 << 6)
995 #define COB_STORE_NEAR_TOWARD_ZERO	(1 << 7)
996 #define COB_STORE_PROHIBITED		(1 << 8)
997 #define COB_STORE_TOWARD_GREATER	(1 << 9)
998 #define COB_STORE_TOWARD_LESSER		(1 << 10)
999 #define COB_STORE_TRUNCATION		(1 << 11)
1000 
1001 #define COB_STORE_MASK					\
1002 	(COB_STORE_ROUND | COB_STORE_KEEP_ON_OVERFLOW |	\
1003 	 COB_STORE_TRUNC_ON_OVERFLOW)
1004 
1005 /* Screen attribute defines */
1006 
1007 #define COB_SCREEN_BLACK		0
1008 #define COB_SCREEN_BLUE			1
1009 #define COB_SCREEN_GREEN		2
1010 #define COB_SCREEN_CYAN			3
1011 #define COB_SCREEN_RED			4
1012 #define COB_SCREEN_MAGENTA		5
1013 #define COB_SCREEN_YELLOW		6
1014 #define COB_SCREEN_WHITE		7
1015 
1016 typedef cob_s64_t cob_flags_t;
1017 
1018 #define COB_SCREEN_LINE_PLUS		((cob_flags_t)1 << 0)
1019 #define COB_SCREEN_LINE_MINUS		((cob_flags_t)1 << 1)
1020 #define COB_SCREEN_COLUMN_PLUS		((cob_flags_t)1 << 2)
1021 #define COB_SCREEN_COLUMN_MINUS		((cob_flags_t)1 << 3)
1022 #define COB_SCREEN_AUTO			((cob_flags_t)1 << 4)
1023 #define COB_SCREEN_BELL			((cob_flags_t)1 << 5)
1024 #define COB_SCREEN_BLANK_LINE		((cob_flags_t)1 << 6)
1025 #define COB_SCREEN_BLANK_SCREEN		((cob_flags_t)1 << 7)
1026 #define COB_SCREEN_BLINK		((cob_flags_t)1 << 8)
1027 #define COB_SCREEN_ERASE_EOL		((cob_flags_t)1 << 9)
1028 #define COB_SCREEN_ERASE_EOS		((cob_flags_t)1 << 10)
1029 #define COB_SCREEN_FULL			((cob_flags_t)1 << 11)
1030 #define COB_SCREEN_HIGHLIGHT		((cob_flags_t)1 << 12)
1031 #define COB_SCREEN_LOWLIGHT		((cob_flags_t)1 << 13)
1032 #define COB_SCREEN_REQUIRED		((cob_flags_t)1 << 14)
1033 #define COB_SCREEN_REVERSE		((cob_flags_t)1 << 15)
1034 #define COB_SCREEN_SECURE		((cob_flags_t)1 << 16)
1035 #define COB_SCREEN_UNDERLINE		((cob_flags_t)1 << 17)
1036 #define COB_SCREEN_OVERLINE		((cob_flags_t)1 << 18)
1037 #define COB_SCREEN_PROMPT		((cob_flags_t)1 << 19)
1038 #define COB_SCREEN_UPDATE		((cob_flags_t)1 << 20)
1039 #define COB_SCREEN_INPUT		((cob_flags_t)1 << 21)
1040 #define COB_SCREEN_SCROLL_DOWN		((cob_flags_t)1 << 22)
1041 #define COB_SCREEN_INITIAL		((cob_flags_t)1 << 23)
1042 #define COB_SCREEN_NO_ECHO		((cob_flags_t)1 << 24)
1043 #define COB_SCREEN_LEFTLINE		((cob_flags_t)1 << 25)
1044 #define COB_SCREEN_NO_DISP		((cob_flags_t)1 << 26)
1045 #define COB_SCREEN_EMULATE_NL		((cob_flags_t)1 << 27)
1046 #define COB_SCREEN_UPPER		((cob_flags_t)1 << 28)
1047 #define COB_SCREEN_LOWER		((cob_flags_t)1 << 29)
1048 #define COB_SCREEN_GRID			((cob_flags_t)1 << 30)
1049 /*#define COB_SCREEN_reserved		((cob_flags_t)1 << 31) /+ reserved for next flag used in screenio */
1050 #define COB_SCREEN_TAB			((cob_flags_t)1 << 32) /* used for syntax checking */
1051 #define COB_SCREEN_NO_UPDATE		((cob_flags_t)1 << 33) /* used for syntax checking */
1052 #define COB_SCREEN_SCROLL_UP		((cob_flags_t)1 << 34) /* used for syntax checking */
1053 
1054 #define COB_SCREEN_TYPE_GROUP		0
1055 #define COB_SCREEN_TYPE_FIELD		1
1056 #define COB_SCREEN_TYPE_VALUE		2
1057 #define COB_SCREEN_TYPE_ATTRIBUTE	3
1058 
1059 /* End Screen attribute defines */
1060 
1061 /* Report attribute defines */
1062 
1063 #define COB_REPORT_LINE			(1U << 0)
1064 #define COB_REPORT_LINE_PLUS		(1U << 1)
1065 #define COB_REPORT_COLUMN_PLUS		(1U << 2)
1066 #define COB_REPORT_RESET_FINAL		(1U << 3)
1067 #define COB_REPORT_HEADING		(1U << 4)
1068 #define COB_REPORT_FOOTING		(1U << 5)
1069 #define COB_REPORT_PAGE_HEADING		(1U << 6)
1070 #define COB_REPORT_PAGE_FOOTING		(1U << 7)
1071 #define COB_REPORT_CONTROL_HEADING	(1U << 8)
1072 #define COB_REPORT_CONTROL_HEADING_FINAL (1U << 9)
1073 #define COB_REPORT_CONTROL_FOOTING	(1U << 10)
1074 #define COB_REPORT_CONTROL_FOOTING_FINAL (1U << 11)
1075 #define COB_REPORT_DETAIL		(1U << 12)
1076 #define COB_REPORT_NEXT_GROUP_LINE	(1U << 13)
1077 #define COB_REPORT_NEXT_GROUP_PLUS	(1U << 14)
1078 #define COB_REPORT_NEXT_GROUP_PAGE	(1U << 15)
1079 #define COB_REPORT_LINE_NEXT_PAGE	(1U << 16)
1080 #define COB_REPORT_NEXT_PAGE		(1U << 17)
1081 #define COB_REPORT_GROUP_INDICATE	(1U << 18)
1082 #define COB_REPORT_GROUP_ITEM		(1U << 19)
1083 #define COB_REPORT_HAD_WHEN		(1U << 20)
1084 #define COB_REPORT_COLUMN_LEFT		(1U << 21)
1085 #define COB_REPORT_COLUMN_CENTER	(1U << 22)
1086 #define COB_REPORT_COLUMN_RIGHT		(1U << 23)
1087 #define COB_REPORT_PRESENT		(1U << 24)
1088 #define COB_REPORT_BEFORE		(1U << 25)
1089 #define COB_REPORT_PAGE			(1U << 26)
1090 #define COB_REPORT_ALL			(1U << 27)
1091 
1092 #define COB_REPORT_NEGATE		(1U << 28)	/* Negative: so ABSENT == PRESENT & NEGATE */
1093 
1094 #define COB_REPORT_SUM_EMITTED		(1U << 29)
1095 #define COB_REPORT_LINE_EMITTED		(1U << 30)
1096 #define COB_REPORT_REF_EMITTED		(1U << 31)
1097 #define COB_REPORT_EMITTED		(COB_REPORT_REF_EMITTED | COB_REPORT_LINE_EMITTED | COB_REPORT_SUM_EMITTED)
1098 
1099 /* End Report attribute defines */
1100 
1101 #define COB_JSON_CJSON			1
1102 #define COB_JSON_JSON_C			2
1103 
1104 /* Structure/union declarations */
1105 
1106 
1107 /* Picture symbol structure */
1108 
1109 typedef struct __cob_pic_symbol {
1110 	char	symbol;
1111 	int 	times_repeated;
1112 } cob_pic_symbol;
1113 
1114 /* Field attribute structure */
1115 
1116 typedef struct __cob_field_attr {
1117 	unsigned short		type;		/* Field type */
1118 	unsigned short		digits;		/* Digit count */
1119 	signed short		scale;		/* Field scale */
1120 	unsigned short		flags;		/* Field flags */
1121 	const cob_pic_symbol	*pic;		/* Pointer to picture string */
1122 } cob_field_attr;
1123 
1124 /* Field structure */
1125 
1126 typedef struct __cob_field {
1127 	size_t			size;		/* Field size */
1128 	unsigned char		*data;		/* Pointer to field data */
1129 	const cob_field_attr	*attr;		/* Pointer to attribute */
1130 } cob_field;
1131 
1132 #if	0	/* RXWRXW - Constant field */
1133 /* Field structure for constants */
1134 
1135 typedef struct __cob_const_field {
1136 	const size_t		size;		/* Field size */
1137 	const unsigned char	*data;		/* Pointer to field data */
1138 	const cob_field_attr	*attr;		/* Pointer to attribute */
1139 } cob_const_field;
1140 
1141 
1142 /* Union for field constants */
1143 
1144 typedef union __cob_fld_union {
1145 	const cob_const_field	cf;
1146 	cob_field		vf;
1147 } cob_fld_union;
1148 #endif
1149 
1150 /* Representation of 128 bit FP */
1151 
1152 typedef struct __cob_fp_128 {
1153 	cob_u64_t	fpval[2];
1154 } cob_fp_128;
1155 
1156 #ifndef COB_WITHOUT_DECIMAL
1157 /* Internal representation of decimal numbers */
1158 /* n = value / 10 ^ scale */
1159 /* Decimal structure */
1160 
1161 typedef struct __cob_decimal {
1162 	mpz_t		value;			/* GMP value definition */
1163 	int 		scale;			/* Decimal scale */
1164 } cob_decimal;
1165 #endif
1166 
1167 /* Perform stack structure */
1168 struct cob_frame {
1169 	void		*return_address_ptr;	/* Return address pointer */
1170 	unsigned int	perform_through;	/* Perform number */
1171 	unsigned int	return_address_num;	/* Return address number */
1172 };
1173 
1174 /* Call union structures */
1175 
1176 typedef union __cob_content {
1177 	unsigned char data[8];
1178 	cob_s64_t     datall;
1179 	cob_u64_t     dataull;
1180 	int           dataint;
1181 } cob_content;
1182 
1183 typedef union __cob_call_union {
1184 	void		*(*funcptr)();	/* Function returning "void *" */
1185 	void		(*funcnull)();	/* Function returning nothing */
1186 	cob_field	*(*funcfld)();	/* Function returning "cob_field *" */
1187 	int		(*funcint)();	/* Function returning "int" */
1188 	void		*funcvoid;	/* Redefine to "void *" */
1189 #ifdef	_WIN32
1190 							/* stdcall variants */
1191 	void		*(__stdcall *funcptr_std)();
1192 	void		(__stdcall *funcnull_std)();
1193 	cob_field	*(__stdcall *funcfld_std)();
1194 	int		(__stdcall *funcint_std)();
1195 #endif
1196 } cob_call_union;
1197 
1198 struct cob_call_struct {
1199 	const char		*cob_cstr_name;		/* Call name */
1200 	cob_call_union		cob_cstr_call;		/* Call entry */
1201 	cob_call_union		cob_cstr_cancel;	/* Cancel entry */
1202 };
1203 
1204 /* Screen structure */
1205 typedef struct __cob_screen {
1206 	struct __cob_screen	*next;		/* Pointer to next */
1207 	struct __cob_screen	*prev;		/* Pointer to previous */
1208 	struct __cob_screen	*child;		/* For COB_SCREEN_TYPE_GROUP */
1209 	struct __cob_screen	*parent;	/* Pointer to parent */
1210 	cob_field		*field;		/* For COB_SCREEN_TYPE_FIELD */
1211 	cob_field		*value;		/* For COB_SCREEN_TYPE_VALUE */
1212 	cob_field		*line;		/* LINE */
1213 	cob_field		*column;	/* COLUMN */
1214 	cob_field		*foreg;		/* FOREGROUND */
1215 	cob_field		*backg;		/* BACKGROUND */
1216 	cob_field		*prompt;	/* PROMPT */
1217 	int			type;		/* Structure type */
1218 	int			occurs;		/* OCCURS */
1219 	int			attr;		/* COB_SCREEN_TYPE_ATTRIBUTE */
1220 } cob_screen;
1221 
1222 /* Module structure */
1223 #define COB_MODULE_TYPE_PROGRAM		0
1224 #define COB_MODULE_TYPE_FUNCTION	1
1225 
1226 /*
1227   For backwards compatibility of the libcob ABI, the size of existing members
1228   and their positions must not change! Add new members at the end.
1229  */
1230 typedef struct __cob_module {
1231 	struct __cob_module	*next;			/* Next pointer */
1232 	cob_field		**cob_procedure_params;	/* Arguments */
1233 	const char		*module_name;		/* Module name */
1234 	const char		*module_formatted_date;	/* Module full date */
1235 	const char		*module_source;		/* Module source */
1236 	cob_call_union		module_entry;		/* Module entry */
1237 	cob_call_union		module_cancel;		/* Module cancel */
1238 	const unsigned char	*collating_sequence;	/* COLLATING */
1239 	cob_field		*crt_status;		/* CRT STATUS */
1240 	cob_field		*cursor_pos;		/* CURSOR */
1241 	unsigned int		*module_ref_count;	/* Module ref count */
1242 	const char		**module_path;		/* Module path */
1243 
1244 	unsigned int		module_active;		/* Module is active */
1245 	unsigned int		module_date;		/* Module num date */
1246 	unsigned int		module_time;		/* Module num time */
1247 	unsigned int		module_type;		/* Module type (program = 0, function = 1) */
1248 	unsigned int		module_param_cnt;	/* Module param count */
1249 	unsigned int		module_returning;	/* Module return type, currently unset+unused */
1250 	int			module_num_params;	/* Module arg count */
1251 
1252 	unsigned char		ebcdic_sign;		/* DISPLAY SIGN */
1253 	unsigned char		decimal_point;		/* DECIMAL POINT */
1254 	unsigned char		currency_symbol;	/* CURRENCY */
1255 	unsigned char		numeric_separator;	/* Separator */
1256 
1257 	unsigned char		flag_filename_mapping;	/* Mapping */
1258 	unsigned char		flag_binary_truncate;	/* Truncation */
1259 	unsigned char		flag_pretty_display;	/* Pretty display */
1260 	unsigned char		flag_host_sign;		/* Host sign */
1261 
1262 	unsigned char		flag_no_phys_canc;	/* No physical cancel */
1263 	unsigned char		flag_main;		/* Main module */
1264 	unsigned char		flag_fold_call;		/* Fold case */
1265 	unsigned char		flag_exit_program;	/* Exit after CALL */
1266 
1267 	unsigned char		flag_did_cancel;	/* Module has been canceled */
1268 	unsigned char		flag_dump_ready;	/* Module was compiled with -fdump */
1269 	unsigned char		flag_debug_trace;	/* Module debug/trace compile option */
1270 #if 0 /* currently unused */
1271 #define COB_MODULE_DEBUG	1
1272 #endif
1273 #define COB_MODULE_TRACE	2
1274 #define COB_MODULE_TRACEALL	4
1275 	unsigned char		unused[1];		/* Use these flags up later, added for alignment */
1276 
1277 	unsigned int		module_stmt;		/* Last statement executed */
1278 	const char		**module_sources;	/* Source module names compiled */
1279 
1280 	cob_field		*xml_code;		/* XML-CODE */
1281 	cob_field		*xml_event;		/* XML-EVENT */
1282 	cob_field		*xml_information;	/* XML-INFORMATION */
1283 	cob_field		*xml_namespace;		/* XML-NAMESPACE */
1284 	cob_field		*xml_nnamespace;	/* XML-NNAMESPACE */
1285 	cob_field		*xml_namespace_prefix;	/* XML-NAMESPACE-PREFIX */
1286 	cob_field		*xml_nnamespace_prefix;	/* XML-NNAMESPACE-PREFIX */
1287 	cob_field		*xml_ntext;		/* XML-NTEXT */
1288 	cob_field		*xml_text;		/* XML-TEXT */
1289 
1290 	cob_field		*json_code;		/* JSON-CODE */
1291 	cob_field		*json_status;		/* JSON-STATUS */
1292 } cob_module;
1293 
1294 
1295 /* User function structure */
1296 
1297 struct cob_func_loc {
1298 	cob_field		*ret_fld;
1299 	cob_field		**save_proc_parms;
1300 	cob_field		**func_params;
1301 	unsigned char		**data;
1302 	cob_module		*save_module;
1303 	int			save_call_params;
1304 	int			save_num_params;
1305 };
1306 
1307 /* File connector */
1308 
1309 /* Key structure */
1310 
1311 #define COB_MAX_KEYCOMP 8	/* max number of parts in a compound key (disam.h :: NPARTS ) */
1312 
1313 typedef struct __cob_file_key {
1314 	cob_field	*field;	/* Key field */
1315 	int		flag;				/* ASCENDING/DESCENDING (for SORT) */
1316 	int		tf_duplicates;			/* WITH DUPLICATES (for RELATIVE/INDEXED) */
1317 	int		tf_ascending;			/* ASCENDING/DESCENDING (for SORT)*/
1318 	int		tf_suppress;			/* supress keys where all chars = char_suppress */
1319 	int		char_suppress;			/* key supression character  */
1320 	unsigned int	offset;			/* Offset of field */
1321 	int		count_components;		/* 0..1::simple-key  2..n::split-key   */
1322 	cob_field	*component[COB_MAX_KEYCOMP];	/* key-components iff split-key   */
1323 } cob_file_key;
1324 
1325 
1326 /* File version (likely can be removed from cob_file in the future) */
1327 #define	COB_FILE_VERSION	1
1328 
1329 /* File structure */
1330 
1331 /*NOTE: *** Add new fields to end  ***
1332  *       cob_file is now allocated by cob_file_malloc in common.c
1333  *       so as long as you add new fields to the end there should be no
1334  *       need to change COB_FILE_VERSION
1335  */
1336 typedef struct __cob_file {
1337 	const char		*select_name;		/* Name in SELECT */
1338 	unsigned char		*file_status;		/* FILE STATUS */
1339 	cob_field		*assign;		/* ASSIGN TO */
1340 	cob_field		*record;		/* Record area */
1341 	cob_field		*variable_record;	/* Record size variable */
1342 	cob_file_key		*keys;			/* ISAM/RANDOM/SORT keys */
1343 	void			*file;			/* File specific pointer */
1344 	void			*linorkeyptr;		/* LINAGE or SPLIT KEY */
1345 	const unsigned char	*sort_collating;	/* SORT collating */
1346 	void			*extfh_ptr;		/* For EXTFH usage */
1347 	size_t			record_min;		/* Record min size */
1348 	size_t			record_max;		/* Record max size */
1349 	size_t			nkeys;			/* Number of keys */
1350 	int			fd;			/* File descriptor */
1351 
1352 	unsigned char		organization;		/* ORGANIZATION */
1353 	unsigned char		access_mode;		/* ACCESS MODE */
1354 	unsigned char		lock_mode;		/* LOCK MODE */
1355 	unsigned char		open_mode;		/* OPEN MODE */
1356 	unsigned char		flag_optional;		/* OPTIONAL */
1357 	unsigned char		last_open_mode;		/* Mode given by OPEN */
1358 	unsigned char		flag_operation;		/* File type specific */
1359 	unsigned char		flag_nonexistent;	/* Nonexistent file */
1360 
1361 	unsigned char		flag_end_of_file;	/* Reached end of file */
1362 	unsigned char		flag_begin_of_file;	/* Reached start of file */
1363 	unsigned char		flag_first_read;	/* OPEN/START read flag */
1364 	unsigned char		flag_read_done;		/* READ successful */
1365 	unsigned char		flag_select_features;	/* SELECT features */
1366 	unsigned char		flag_needs_nl;		/* Needs NL at close */
1367 	unsigned char		flag_needs_top;		/* Linage needs top */
1368 	unsigned char		file_version;		/* File I/O version */
1369 
1370 	unsigned char		flag_line_adv;		/* LINE ADVANCING */
1371 	short				curkey;			/* Current file index read sequentially */
1372 	short 				mapkey;			/* Remapped index number, when FD does not match file */
1373 
1374 } cob_file;
1375 
1376 
1377 /* Linage structure */
1378 
1379 typedef struct __cob_linage {
1380 	cob_field		*linage;		/* LINAGE */
1381 	cob_field		*linage_ctr;		/* LINAGE-COUNTER */
1382 	cob_field		*latfoot;		/* LINAGE FOOTING */
1383 	cob_field		*lattop;		/* LINAGE AT TOP */
1384 	cob_field		*latbot;		/* LINAGE AT BOTTOM */
1385 	int			lin_lines;		/* Current Linage */
1386 	int			lin_foot;		/* Current Footage */
1387 	int			lin_top;		/* Current Top */
1388 	int			lin_bot;		/* Current Bottom */
1389 } cob_linage;
1390 
1391 
1392 /********************/
1393 /* Report structure */
1394 /********************/
1395 
1396 /* for each SUM field of each line in the report */
1397 typedef struct __cob_report_sum {
1398 	struct __cob_report_sum	*next;			/* Next field */
1399 	cob_field		*f;			/* Field to be summed */
1400 } cob_report_sum;
1401 
1402 /* for each field of each line in the report */
1403 typedef struct __cob_report_field {
1404 	struct __cob_report_field *next;			/* Next field */
1405 	cob_field		*f;			/* Field definition */
1406 	cob_field		*source;		/* Field SOURCE */
1407 	cob_field		*control;		/* CONTROL Field */
1408 	char			*litval;		/* Literal value */
1409 	int			litlen;			/* Length of literal string */
1410 	unsigned int		flags;
1411 	int			line;
1412 	int			column;
1413 	int			step_count;
1414 	int			next_group_line;	/* NEXT GROUP line or PLUS line; see flags */
1415 	unsigned int		level:8;		/* Data item level number */
1416 	unsigned int		group_indicate:1;	/* field had GROUP INDICATE */
1417 	unsigned int		suppress:1;		/* SUPPRESS display of this field */
1418 	unsigned int		present_now:1;		/* PRESENT BEFORE|AFTER to be processed */
1419 } cob_report_field;
1420 
1421 /* for each line of a report */
1422 typedef struct __cob_report_line {
1423 	struct __cob_report_line	*sister;		/* Next line */
1424 	struct __cob_report_line	*child;			/* Child line */
1425 	cob_report_field	*fields;		/* List of fields on this line */
1426 	cob_field		*control;		/* CONTROL Field */
1427 	int			use_decl;		/* Label# of Declaratives code */
1428 	unsigned int		flags;			/* flags defined with line */
1429 	int			line;			/* 'LINE' value */
1430 	int			step_count;
1431 	int			next_group_line;
1432 	unsigned int		report_flags;		/* flags ORed with upper level flags */
1433 	unsigned int		suppress:1;		/* SUPPRESS printing this line */
1434 } cob_report_line;
1435 
1436 /* for each 'line referencing a control field' of the report */
1437 typedef struct __cob_report_control_ref {
1438 	struct __cob_report_control_ref *next;		/* Next control_ref */
1439 	cob_report_line		*ref_line;		/* Report Line with this control field */
1440 } cob_report_control_ref;
1441 
1442 /* for each 'control field' of the report */
1443 typedef struct __cob_report_control {
1444 	struct __cob_report_control *next;		/* Next control */
1445 	const char		*name;			/* Control field name */
1446 	cob_field		*f;			/* Field definition */
1447 	cob_field		*val;			/* previous field value */
1448 	cob_field		*sf;			/* save field value */
1449 	cob_report_control_ref	*control_ref;		/* References to this control field */
1450 	int			sequence;		/* Order of Control Break */
1451 	unsigned int		data_change:1;		/* Control field data did change */
1452 	unsigned int		has_heading:1;		/* CONTROL HEADING */
1453 	unsigned int		has_footing:1;		/* CONTROL FOOTING */
1454 	unsigned int		suppress:1;		/* SUPPRESS printing this break */
1455 } cob_report_control;
1456 
1457 /* for each SUM counter in the report */
1458 typedef struct __cob_report_sumctr {
1459 	struct __cob_report_sumctr *next;		/* Next sum counter */
1460 	const char		*name;			/* Name of this SUM counter */
1461 	cob_report_sum		*sum;			/* list of fields to be summed */
1462 	cob_field		*counter;		/* Field to hold the SUM counter */
1463 	cob_field		*f;			/* Data Field for SUM counter */
1464 	cob_report_control	*control;		/* RESET when this control field changes */
1465 	unsigned int		reset_final:1;		/* RESET on FINAL */
1466 	unsigned int		control_final:1;	/* CONTROL FOOTING FINAL */
1467 	unsigned int		subtotal:1;		/* This is a 'subtotal' counter */
1468 	unsigned int		crossfoot:1;		/* This is a 'crossfoot' counter */
1469 } cob_report_sum_ctr;
1470 
1471 /* main report table for each RD */
1472 typedef struct __cob_report {
1473 	const char		*report_name;		/* Report name */
1474 	struct __cob_report	*next;			/* Next report */
1475 	cob_file		*report_file;		/* Report file */
1476 	cob_field		*page_counter;		/* PAGE-COUNTER */
1477 	cob_field		*line_counter;		/* LINE-COUNTER */
1478 	cob_report_line		*first_line;		/* First defined LINE of report */
1479 	cob_report_control	*controls;		/* control fields of report */
1480 	cob_report_sum_ctr	*sum_counters;		/* List of SUM counters in report */
1481 	int			def_lines;		/* Default lines */
1482 	int			def_cols;		/* Default columns */
1483 	int			def_heading;		/* Default heading */
1484 	int			def_first_detail;	/* Default first detail */
1485 	int			def_last_control;	/* Default last control */
1486 	int			def_last_detail;	/* Default last detail */
1487 	int			def_footing;		/* Default footing */
1488 	int			curr_page;		/* Current page */
1489 	int			curr_line;		/* Current line on page */
1490 	int			curr_cols;		/* Current column on line */
1491 	int			curr_status;		/* Current status */
1492 	int			next_value;		/* NEXT GROUP Line/Page/Plus value */
1493 	unsigned int		control_final:1;	/* CONTROL FINAL declared */
1494 	unsigned int		global:1;		/* IS GLOBAL declared */
1495 	unsigned int		first_detail:1;		/* First Detail on page */
1496 	unsigned int		in_page_footing:1;	/* doing page footing now */
1497 	unsigned int		in_page_heading:1;	/* doing page heading now */
1498 	unsigned int		first_generate:1;	/* Ready for first GENERATE */
1499 	unsigned int		initiate_done:1;	/* INITIATE has been done */
1500 	unsigned int		next_line:1;		/* Advance to line on next DETAIL */
1501 
1502 	unsigned int		next_line_plus:1;	/* Advance to plus line on next DETAIL */
1503 	unsigned int		next_page:1;		/* Advance to next page on next DETAIL */
1504 	unsigned int		next_just_set:1;	/* NEXT xxx was just set so ignore */
1505 	unsigned int		in_report_footing:1;	/* doing report footing now */
1506 	unsigned int		incr_line:1;		/* 'curr_lines' should be incremented */
1507 	unsigned int		foot_next_page:1;	/* Advance to next page after all CONTROL footings */
1508 	unsigned int		code_is_present:1;	/* CODE IS present */
1509 	unsigned int		unused:17;		/* Use these bits up next */
1510 
1511 	int			code_len;		/* Length to use for holding 'CODE IS' value */
1512 	char			*code_is;		/* Value of CODE IS for this report */
1513 } cob_report;
1514 
1515 /* ML tree structure */
1516 
1517 typedef struct __cob_ml_attr {
1518 	cob_field		*name;
1519 	cob_field		*value;
1520 	unsigned int		is_suppressed;
1521 	struct __cob_ml_attr	*sibling;
1522 } cob_ml_attr;
1523 
1524 typedef struct __cob_ml_tree {
1525         cob_field		*name;
1526 	cob_ml_attr		*attrs;
1527 	cob_field		*content;
1528 	unsigned int		is_suppressed;
1529 	struct __cob_ml_tree	*children;
1530 	struct __cob_ml_tree	*sibling;
1531 } cob_ml_tree;
1532 
1533 /* Global variable structure */
1534 
1535 typedef struct __cob_global {
1536 	cob_file		*cob_error_file;	/* Last error file */
1537 	cob_module		*cob_current_module;	/* Current module */
1538 	const char		*last_exception_statement;	/* SLast exception: tatement */
1539 	const char		*last_exception_id;	/* Last exception: PROGRAMM-ID / FUNCTION-ID*/
1540 	const char		*last_exception_section;	/* Last exception: Section */
1541 	const char		*last_exception_paragraph;	/* Last exception: Paragraph */
1542 	const char		*cob_main_argv0;	/* Main program */
1543 	char			*cob_locale;		/* Program locale */
1544 	char			*cob_locale_orig;	/* Initial locale */
1545 	char			*cob_locale_ctype;	/* Initial locale */
1546 	char			*cob_locale_collate;	/* Initial locale */
1547 	char			*cob_locale_messages;	/* Initial locale */
1548 	char			*cob_locale_monetary;	/* Initial locale */
1549 	char			*cob_locale_numeric;	/* Initial locale */
1550 	char			*cob_locale_time;	/* Initial locale */
1551 
1552 	int			cob_exception_code;	/* current exception code, in contrast to last_exception_code heavily changed */
1553 	int			cob_call_params;	/* Number of current arguments
1554 									   This is set to the actual number before a CALL
1555 									   and is stored directly on module entry to its
1556 									   cob_module structure within cob_module_enter().
1557 									*/
1558 	int			cob_initial_external;	/* First external ref */
1559 	unsigned int		last_exception_line;		/* Last exception: Program source line */
1560 	unsigned int		cob_got_exception;	/* Exception active (see last_exception) */
1561 	unsigned int		cob_screen_initialized;	/* Screen initialized */
1562 	unsigned int		cob_physical_cancel;	/* Unloading of modules */
1563 												/* screenio / termio */
1564 	unsigned char		*cob_term_buff;		/* Screen I/O buffer */
1565 	int			cob_accept_status;	/* ACCEPT STATUS */
1566 
1567 	int			cob_max_y;		/* Screen max y */
1568 	int			cob_max_x;		/* Screen max x */
1569 
1570 	unsigned int		cob_stmt_exception;	/* Statement has 'On Exception' */
1571 
1572 	unsigned int		cob_debugging_mode;	/* activation of USE ON DEBUGGING code */
1573 
1574 } cob_global;
1575 
1576 /* File I/O function pointer structure */
1577 struct cob_fileio_funcs {
1578 	int	(*open)		(cob_file *, char *, const int, const int);
1579 	int	(*close)	(cob_file *, const int);
1580 	int	(*start)	(cob_file *, const int, cob_field *);
1581 	int	(*read)		(cob_file *, cob_field *, const int);
1582 	int	(*read_next)	(cob_file *, const int);
1583 	int	(*write)	(cob_file *, const int);
1584 	int	(*rewrite)	(cob_file *, const int);
1585 	int	(*fdelete)	(cob_file *);
1586 };
1587 
1588 #ifndef COB_WITHOUT_JMP
1589 /* Low level jump structure */
1590 struct cobjmp_buf {
1591 	int	cbj_int[4];
1592 	void	*cbj_ptr[4];
1593 	jmp_buf	cbj_jmp_buf;
1594 	void	*cbj_ptr_rest[2];
1595 };
1596 #endif
1597 
1598 #define __LIBCOB_VERSION	3
1599 #define __LIBCOB_VERSION_MINOR		1
1600 #define __LIBCOB_VERSION_PATCHLEVEL	2	/* Note: possibly differs from patchelvel shown with cobc --version! */
1601 
1602 #define __LIBCOB_RELEASE (__LIBCOB_VERSION * 10000 + __LIBCOB_VERSION_MINOR * 100 + __LIBCOB_VERSION_PATCHLEVEL)
1603 
1604 
1605 /*******************************/
1606 
1607 /* Function declarations */
1608 
1609 /*******************************/
1610 /* Functions in common.c */
1611 COB_EXPIMP const char*	libcob_version (void);
1612 COB_EXPIMP int		set_libcob_version (int *, int *, int *);
1613 COB_EXPIMP void		print_info	(void);
1614 COB_EXPIMP void		print_info_detailed	(const int);
1615 COB_EXPIMP void		print_version	(void);
1616 COB_EXPIMP void		print_version_summary (void);
1617 COB_EXPIMP int		cob_load_config	(void);
1618 COB_EXPIMP void		print_runtime_conf	(void);
1619 
1620 COB_EXPIMP void		cob_set_exception	(const int);
1621 COB_EXPIMP int		cob_last_exception_is	(const int);
1622 
1623 COB_EXPIMP void		cob_runtime_hint	(const char *, ...) COB_A_FORMAT12;
1624 COB_EXPIMP void		cob_runtime_error	(const char *, ...) COB_A_FORMAT12;
1625 COB_EXPIMP void		cob_runtime_warning	(const char *, ...) COB_A_FORMAT12;
1626 
1627 /* General functions */
1628 
1629 COB_EXPIMP int		cob_is_initialized	(void);
1630 COB_EXPIMP cob_global		*cob_get_global_ptr	(void);
1631 
1632 COB_EXPIMP void	cob_init			(const int, char **);
1633 COB_EXPIMP void	cob_init_nomain		(const int, char **);
1634 COB_EXPIMP void	cob_common_init		(void *);
1635 
1636 COB_EXPIMP int	cob_module_global_enter	(cob_module **, cob_global **,
1637 						 const int, const int, const unsigned int *);
1638 COB_EXPIMP void	cob_module_enter		(cob_module **, cob_global **,
1639 						 const int);
1640 COB_EXPIMP void	cob_module_leave		(cob_module *);
1641 
1642 COB_EXPIMP void	cob_module_free	(cob_module **);
1643 
1644 DECLNORET COB_EXPIMP void	cob_stop_run	(const int) COB_A_NORETURN;
1645 DECLNORET COB_EXPIMP void	cob_fatal_error	(const enum cob_fatal_error) COB_A_NORETURN;
1646 
1647 COB_EXPIMP void	*cob_malloc			(const size_t) COB_A_MALLOC;
1648 COB_EXPIMP void	*cob_realloc			(void *, const size_t, const size_t) COB_A_MALLOC;
1649 COB_EXPIMP char	*cob_strdup				(const char *);
1650 COB_EXPIMP void	cob_free			(void *);
1651 COB_EXPIMP void	*cob_fast_malloc		(const size_t) COB_A_MALLOC;
1652 COB_EXPIMP void	*cob_cache_malloc		(const size_t) COB_A_MALLOC;
1653 COB_EXPIMP void	*cob_cache_realloc		(void *, const size_t);
1654 COB_EXPIMP void	cob_cache_free			(void *);
1655 
1656 COB_EXPIMP void	cob_set_locale			(cob_field *, const int);
1657 
1658 COB_EXPIMP int 	cob_setenv		(const char *, const char *, int);
1659 COB_EXPIMP int 	cob_unsetenv		(const char *);
1660 COB_EXPIMP char	*cob_getenv_direct		(const char *);
1661 COB_EXPIMP char* cob_expand_env_string	(char*);
1662 COB_EXPIMP char	*cob_getenv			(const char *);
1663 COB_EXPIMP int	cob_putenv			(char *);
1664 
1665 COB_EXPIMP void	cob_check_version		(const char *, const char *,
1666 						 const int);
1667 
1668 COB_EXPIMP struct cob_func_loc *cob_save_func	(cob_field **,
1669 									const int, const int, ...);
1670 COB_EXPIMP void	cob_restore_func		(struct cob_func_loc *);
1671 
1672 COB_EXPIMP void	cob_accept_arg_number		(cob_field *);
1673 COB_EXPIMP void	cob_accept_arg_value		(cob_field *);
1674 COB_EXPIMP void	cob_accept_command_line		(cob_field *);
1675 COB_EXPIMP void	cob_accept_date			(cob_field *);
1676 COB_EXPIMP void	cob_accept_date_yyyymmdd	(cob_field *);
1677 COB_EXPIMP void	cob_accept_day			(cob_field *);
1678 COB_EXPIMP void	cob_accept_day_yyyyddd		(cob_field *);
1679 COB_EXPIMP void	cob_accept_day_of_week		(cob_field *);
1680 COB_EXPIMP void	cob_accept_environment		(cob_field *);
1681 COB_EXPIMP void	cob_accept_exception_status	(cob_field *);
1682 COB_EXPIMP void	cob_accept_time			(cob_field *);
1683 COB_EXPIMP void	cob_accept_user_name		(cob_field *);
1684 COB_EXPIMP void	cob_display_command_line	(cob_field *);
1685 COB_EXPIMP void	cob_display_environment		(const cob_field *);
1686 COB_EXPIMP void	cob_display_env_value		(const cob_field *);
1687 COB_EXPIMP void	cob_display_arg_number		(cob_field *);
1688 COB_EXPIMP void	cob_get_environment		(const cob_field *, cob_field *);
1689 COB_EXPIMP void	cob_set_environment		(const cob_field *,
1690 						 const cob_field *);
1691 COB_EXPIMP void	cob_chain_setup			(void *, const size_t,
1692 						 const size_t);
1693 COB_EXPIMP void	cob_allocate			(unsigned char **, cob_field *,
1694 						 cob_field *, cob_field *);
1695 COB_EXPIMP void	cob_free_alloc			(unsigned char **, unsigned char *);
1696 COB_EXPIMP void	cob_continue_after		(cob_field *);
1697 COB_EXPIMP int	cob_extern_init			(void);
1698 COB_EXPIMP int	cob_tidy			(void);
1699 COB_EXPIMP char	*cob_command_line		(int, int *, char ***,
1700 						 char ***, char **);
1701 
1702 COB_EXPIMP void	cob_incr_temp_iteration 	(void);
1703 COB_EXPIMP void	cob_temp_name			(char *, const char *);
1704 
1705 /* System routines */
1706 COB_EXPIMP int	cob_sys_exit_proc	(const void *, const void *);
1707 COB_EXPIMP int	cob_sys_error_proc	(const void *, const void *);
1708 COB_EXPIMP int	cob_sys_system		(const void *);
1709 COB_EXPIMP int	cob_sys_hosted		(void *, const void *);
1710 COB_EXPIMP int	cob_sys_and		(const void *, void *, const int);
1711 COB_EXPIMP int	cob_sys_or		(const void *, void *, const int);
1712 COB_EXPIMP int	cob_sys_nor		(const void *, void *, const int);
1713 COB_EXPIMP int	cob_sys_xor		(const void *, void *, const int);
1714 COB_EXPIMP int	cob_sys_imp		(const void *, void *, const int);
1715 COB_EXPIMP int	cob_sys_nimp		(const void *, void *, const int);
1716 COB_EXPIMP int	cob_sys_eq		(const void *, void *, const int);
1717 COB_EXPIMP int	cob_sys_not		(void *, const int);
1718 COB_EXPIMP int	cob_sys_xf4		(void *, const void *);
1719 COB_EXPIMP int	cob_sys_xf5		(const void *, void *);
1720 COB_EXPIMP int	cob_sys_x91		(void *, const void *, void *);
1721 COB_EXPIMP int	cob_sys_toupper		(void *, const int);
1722 COB_EXPIMP int	cob_sys_tolower		(void *, const int);
1723 COB_EXPIMP int	cob_sys_oc_nanosleep	(const void *);
1724 COB_EXPIMP int	cob_sys_getpid		(void);
1725 COB_EXPIMP int	cob_sys_return_args	(void *);
1726 COB_EXPIMP int	cob_sys_parameter_size	(void *);
1727 COB_EXPIMP int	cob_sys_fork	(void);
1728 COB_EXPIMP int	cob_sys_waitpid	(const void *);
1729 
1730 /*
1731  * cob_sys_getopt_long_long
1732  */
1733 COB_EXPIMP int	cob_sys_getopt_long_long	(void*, void*, void*, const int, void*, void*);
1734 typedef struct __longoption_def {
1735 	char name[25];
1736 	char has_option;
1737 	char return_value_pointer[sizeof(char*)];
1738 	char return_value[4];
1739 } longoption_def;
1740 
1741 
1742 COB_EXPIMP int	cob_sys_sleep		(const void *);
1743 COB_EXPIMP int	cob_sys_calledby	(void *);
1744 COB_EXPIMP int	cob_sys_justify		(void *, ...);
1745 COB_EXPIMP int	cob_sys_printable	(void *, ...);
1746 
1747 COB_EXPIMP int	cob_sys_extfh		(const void *, void *);
1748 
1749 /* Utilities */
1750 
1751 /* compatibility functions up to GnuCOBOL 2.2 */
1752 COB_EXPIMP void	cob_set_location	(const char *, const unsigned int,
1753 					 const char *, const char *,
1754 					 const char *);
1755 COB_EXPIMP void	cob_trace_section	(const char *, const char *, const int);
1756 /* new functions from 3.0-dev on: */
1757 COB_EXPIMP void	cob_trace_sect		(const char *name);
1758 COB_EXPIMP void	cob_trace_para		(const char *name);
1759 COB_EXPIMP void	cob_trace_entry		(const char *name);
1760 COB_EXPIMP void	cob_trace_exit		(const char *name);
1761 COB_EXPIMP void	cob_trace_stmt		(const char *stmt);
1762 
1763 COB_EXPIMP void			*cob_external_addr	(const char *, const int);
1764 COB_EXPIMP unsigned char	*cob_get_pointer	(const void *);
1765 COB_EXPIMP void			cob_ready_trace		(void);
1766 COB_EXPIMP void			cob_reset_trace		(void);
1767 COB_EXPIMP void			cob_nop (void);
1768 
1769 /* Call from outside to set/read/re-evaluate libcob options */
1770 enum cob_runtime_option_switch {
1771 	COB_SET_RUNTIME_TRACE_FILE = 0,				/* 'p' is  FILE *  */
1772 	COB_SET_RUNTIME_DISPLAY_PRINTER_FILE = 1,	/* 'p' is  FILE *  */
1773 	COB_SET_RUNTIME_RESCAN_ENV = 2,		/* rescan environment variables */
1774 	COB_SET_RUNTIME_DISPLAY_PUNCH_FILE = 3,	/* 'p' is  FILE *  */
1775 	COB_SET_RUNTIME_DUMP_FILE = 4	/* 'p' is  FILE *  */
1776 };
1777 COB_EXPIMP void			cob_set_runtime_option		(enum cob_runtime_option_switch opt, void *p);
1778 COB_EXPIMP void			*cob_get_runtime_option		(enum cob_runtime_option_switch opt);
1779 
1780 COB_EXPIMP void			cob_stack_trace (void *target);		/* 'target' is FILE *  */
1781 
1782 #define COB_GET_LINE_NUM(n) ( n & 0xFFFFF )
1783 #define COB_GET_FILE_NUM(n) ( (n >> 20) & 0xFFF)
1784 #define COB_SET_LINE_FILE(l,f) ( (unsigned int)((unsigned int)f<<20) | l)
1785 
1786 /* Datetime structure */
1787 struct cob_time
1788 {
1789 	int	year;			/* Year         [1900-9999] */
1790 	int	month;			/* Month        [1-12] 1 = Jan ... 12 = Dec */
1791 	int	day_of_month;	/* Day          [1-31] */
1792 	int	day_of_week;	/* Day of week  [1-7] 1 = Monday ... 7 = Sunday */
1793 	int day_of_year;	/* Days in year [1-366] -1 on _WIN32! */
1794 	int	hour;			/* Hours        [0-23] */
1795 	int	minute;			/* Minutes      [0-59] */
1796 	int	second;			/* Seconds      [0-60] (1 leap second) */
1797 	int	nanosecond;		/* Nanoseconds */
1798 	int	offset_known;
1799 	int	utc_offset;		/* Minutes east of UTC */
1800 	int is_daylight_saving_time;	/* DST [-1/0/1] */
1801 };
1802 
1803 COB_EXPIMP struct cob_time cob_get_current_date_and_time	(void);
1804 
1805 /* Registration of external handlers */
1806 COB_EXPIMP void	cob_reg_sighnd	(void (*sighnd) (int));
1807 
1808 /* Raise signal (run both internal and external handlers) */
1809 COB_EXPIMP void	cob_raise		(int);
1810 
1811 /* Switch */
1812 
1813 COB_EXPIMP int	cob_get_switch		(const int);
1814 COB_EXPIMP void	cob_set_switch		(const int, const int);
1815 
1816 /* Comparison */
1817 
1818 COB_EXPIMP int	cob_cmp			(cob_field *, cob_field *);
1819 
1820 /* Class check */
1821 
1822 COB_EXPIMP int	cob_is_omitted		(const cob_field *);
1823 COB_EXPIMP int	cob_is_numeric		(const cob_field *);
1824 COB_EXPIMP int	cob_is_alpha		(const cob_field *);
1825 COB_EXPIMP int	cob_is_upper		(const cob_field *);
1826 COB_EXPIMP int	cob_is_lower		(const cob_field *);
1827 
1828 /* Table sort */
1829 
1830 COB_EXPIMP void	cob_table_sort_init	(const size_t, const unsigned char *);
1831 COB_EXPIMP void	cob_table_sort_init_key	(cob_field *, const int,
1832 					 const unsigned int);
1833 COB_EXPIMP void	cob_table_sort		(cob_field *, const int);
1834 
1835 /* Run-time error checking */
1836 
1837 COB_EXPIMP void	cob_check_numeric	(const cob_field *, const char *);
1838 COB_EXPIMP void	cob_correct_numeric	(cob_field *);
1839 COB_EXPIMP void	cob_check_based		(const unsigned char *,
1840 					 const char *);
1841 COB_EXPIMP void	cob_check_linkage	(const unsigned char *,
1842 					 const char *, const int);
1843 COB_EXPIMP void	cob_check_odo		(const int, const int, const int,
1844 					 const char *, const char *);
1845 COB_EXPIMP void	cob_check_subscript	(const int, const int,
1846 					 const char *, const int);
1847 COB_EXPIMP void	cob_check_ref_mod_detailed	(const char *, const int, const int,
1848 					 const int, const int, const int);
1849 COB_EXPIMP void	cob_check_ref_mod_minimal	(const char *,
1850 					 const int, const int);
1851 COB_EXPIMP void	cob_check_ref_mod	(const int, const int,
1852 					 const int, const char *);
1853 
1854 /* Comparison functions */
1855 COB_EXPIMP int	cob_numeric_cmp		(cob_field *, cob_field *);
1856 
1857 /*******************************/
1858 /* Functions in strings.c */
1859 
1860 COB_EXPIMP void cob_inspect_init	(cob_field *, const cob_u32_t);
1861 COB_EXPIMP void cob_inspect_start	(void);
1862 COB_EXPIMP void cob_inspect_before	(const cob_field *);
1863 COB_EXPIMP void cob_inspect_after	(const cob_field *);
1864 COB_EXPIMP void cob_inspect_characters	(cob_field *);
1865 COB_EXPIMP void cob_inspect_all		(cob_field *, cob_field *);
1866 COB_EXPIMP void cob_inspect_leading	(cob_field *, cob_field *);
1867 COB_EXPIMP void cob_inspect_first	(cob_field *, cob_field *);
1868 COB_EXPIMP void cob_inspect_trailing	(cob_field *, cob_field *);
1869 COB_EXPIMP void cob_inspect_converting	(const cob_field *, const cob_field *);
1870 COB_EXPIMP void cob_inspect_finish	(void);
1871 
1872 COB_EXPIMP void cob_string_init		(cob_field *, cob_field *);
1873 COB_EXPIMP void cob_string_delimited	(cob_field *);
1874 COB_EXPIMP void cob_string_append	(cob_field *);
1875 COB_EXPIMP void cob_string_finish	(void);
1876 
1877 COB_EXPIMP void cob_unstring_init	(cob_field *, cob_field *, const size_t);
1878 COB_EXPIMP void cob_unstring_delimited	(cob_field *, const cob_u32_t);
1879 COB_EXPIMP void cob_unstring_into	(cob_field *, cob_field *, cob_field *);
1880 COB_EXPIMP void cob_unstring_tallying	(cob_field *);
1881 COB_EXPIMP void cob_unstring_finish	(void);
1882 
1883 /*******************************/
1884 /*   Functions in move.c       */
1885 /*******************************/
1886 
1887 COB_EXPIMP void		cob_move	(cob_field *, cob_field *);
1888 COB_EXPIMP void		cob_move_ibm	(void *, void *, const int);
1889 COB_EXPIMP void		cob_init_table	(void *, const size_t, const size_t);
1890 COB_EXPIMP void		cob_set_int	(cob_field *, const int);
1891 COB_EXPIMP int		cob_get_int	(cob_field *);
1892 COB_EXPIMP cob_s64_t	cob_get_llint	(cob_field *);
1893 /**************************************************/
1894 /* Functions in move.c for C access to COBOL data */
1895 /**************************************************/
1896 COB_EXPIMP char *	cob_get_picx( void *cbldata, size_t len, void *charfld, size_t charlen);
1897 COB_EXPIMP cob_s64_t	cob_get_s64_comp3(void *cbldata, int len);
1898 COB_EXPIMP cob_s64_t	cob_get_s64_comp5(void *cbldata, int len);
1899 COB_EXPIMP cob_s64_t	cob_get_s64_compx(void *cbldata, int len);
1900 COB_EXPIMP cob_s64_t	cob_get_s64_pic9 (void *cbldata, int len);
1901 COB_EXPIMP cob_u64_t	cob_get_u64_comp3(void *cbldata, int len);
1902 COB_EXPIMP cob_u64_t	cob_get_u64_comp5(void *cbldata, int len);
1903 COB_EXPIMP cob_u64_t	cob_get_u64_comp6(void *cbldata, int len);
1904 COB_EXPIMP cob_u64_t	cob_get_u64_compx(void *cbldata, int len);
1905 COB_EXPIMP cob_u64_t	cob_get_u64_pic9 (void *cbldata, int len);
1906 COB_EXPIMP float 	cob_get_comp1(void *cbldata);
1907 COB_EXPIMP double	cob_get_comp2(void *cbldata);
1908 COB_EXPIMP void		cob_put_comp1(float val, void *cbldata);
1909 COB_EXPIMP void		cob_put_comp2(double val, void *cbldata);
1910 COB_EXPIMP void 	cob_put_picx( void *cbldata, size_t len, void *string);
1911 COB_EXPIMP void		cob_put_s64_comp3(cob_s64_t val, void *cbldata, int len);
1912 COB_EXPIMP void		cob_put_s64_comp5(cob_s64_t val, void *cbldata, int len);
1913 COB_EXPIMP void		cob_put_s64_compx(cob_s64_t val, void *cbldata, int len);
1914 COB_EXPIMP void		cob_put_s64_pic9 (cob_s64_t val, void *cbldata, int len);
1915 COB_EXPIMP void		cob_put_u64_comp3(cob_u64_t val, void *cbldata, int len);
1916 COB_EXPIMP void		cob_put_u64_comp5(cob_u64_t val, void *cbldata, int len);
1917 COB_EXPIMP void		cob_put_u64_comp6(cob_u64_t val, void *cbldata, int len);
1918 COB_EXPIMP void		cob_put_u64_compx(cob_u64_t val, void *cbldata, int len);
1919 COB_EXPIMP void		cob_put_u64_pic9 (cob_u64_t val, void *cbldata, int len);
1920 COB_EXPIMP void		cob_put_pointer(void *val, void *cbldata);
1921 
1922 
1923 /**************************/
1924 /* Functions in numeric.c */
1925 
1926 #ifndef COB_WITHOUT_DECIMAL
1927 COB_EXPIMP void	cob_decimal_init	(cob_decimal *);
1928 COB_EXPIMP void	cob_decimal_clear	(cob_decimal *);
1929 COB_EXPIMP void cob_decimal_set_llint	(cob_decimal *, const cob_s64_t);
1930 COB_EXPIMP void cob_decimal_set_ullint	(cob_decimal *, const cob_u64_t);
1931 COB_EXPIMP void	cob_decimal_set_field	(cob_decimal *, cob_field *);
1932 COB_EXPIMP int	cob_decimal_get_field	(cob_decimal *, cob_field *, const int);
1933 COB_EXPIMP void	cob_decimal_add		(cob_decimal *, cob_decimal *);
1934 COB_EXPIMP void	cob_decimal_sub		(cob_decimal *, cob_decimal *);
1935 COB_EXPIMP void	cob_decimal_mul		(cob_decimal *, cob_decimal *);
1936 COB_EXPIMP void	cob_decimal_div		(cob_decimal *, cob_decimal *);
1937 COB_EXPIMP void	cob_decimal_pow		(cob_decimal *, cob_decimal *);
1938 COB_EXPIMP int	cob_decimal_cmp		(cob_decimal *, cob_decimal *);
1939 COB_EXPIMP void	cob_decimal_align(cob_decimal *, const int);
1940 #endif
1941 
1942 COB_EXPIMP void	cob_add			(cob_field *, cob_field *, const int);
1943 COB_EXPIMP void	cob_sub			(cob_field *, cob_field *, const int);
1944 COB_EXPIMP void	cob_mul			(cob_field *, cob_field *, const int);
1945 COB_EXPIMP void	cob_div			(cob_field *, cob_field *, const int);
1946 COB_EXPIMP int	cob_add_int		(cob_field *, const int, const int);
1947 COB_EXPIMP int	cob_sub_int		(cob_field *, const int, const int);
1948 COB_EXPIMP void	cob_div_quotient	(cob_field *, cob_field *,
1949 					 cob_field *, const int);
1950 COB_EXPIMP void	cob_div_remainder	(cob_field *, const int);
1951 
1952 COB_EXPIMP int	cob_cmp_int		(cob_field *, const int);
1953 COB_EXPIMP int	cob_cmp_uint		(cob_field *, const unsigned int);
1954 COB_EXPIMP int	cob_cmp_llint		(cob_field *, const cob_s64_t);
1955 COB_EXPIMP int	cob_cmp_packed		(cob_field *, const cob_s64_t);
1956 COB_EXPIMP int	cob_cmp_numdisp		(const unsigned char *,
1957 					 const size_t, const cob_s64_t,
1958 					 const cob_u32_t);
1959 COB_EXPIMP int	cob_cmp_float		(cob_field *, cob_field *);
1960 COB_EXPIMP void	cob_set_packed_zero	(cob_field *);
1961 COB_EXPIMP void	cob_set_packed_int	(cob_field *, const int);
1962 
1963 COB_EXPIMP void	cob_decimal_alloc	(const cob_u32_t, ...);
1964 COB_EXPIMP void	cob_decimal_push	(const cob_u32_t, ...);
1965 COB_EXPIMP void	cob_decimal_pop		(const cob_u32_t, ...);
1966 
1967 COB_EXPIMP void	cob_gmp_free		(void *);
1968 
1969 
1970 /*******************************/
1971 /* Functions in call.c */
1972 
1973 DECLNORET COB_EXPIMP void	cob_call_error		(void) COB_A_NORETURN;
1974 COB_EXPIMP void		cob_field_constant (cob_field *f, cob_field *t, cob_field_attr *a, void *d);
1975 
1976 COB_EXPIMP void		cob_set_cancel		(cob_module *);
1977 COB_EXPIMP int		cob_encode_program_id (const unsigned char * const, unsigned char * const,
1978 						 const int, const int);
1979 COB_EXPIMP void		*cob_resolve		(const char *);
1980 COB_EXPIMP void		*cob_resolve_cobol	(const char *, const int,
1981 						 const int);
1982 COB_EXPIMP void		*cob_resolve_func	(const char *);
1983 COB_EXPIMP const char	*cob_resolve_error	(void);
1984 COB_EXPIMP void		*cob_call_field		(const cob_field *,
1985 						 const struct cob_call_struct *,
1986 						 const unsigned int,
1987 						 const int);
1988 COB_EXPIMP void		cob_cancel_field	(const cob_field *,
1989 						 const struct cob_call_struct *);
1990 COB_EXPIMP void		cob_cancel		(const char *);
1991 COB_EXPIMP int		cob_call		(const char *, const int, void **);
1992 COB_EXPIMP int		cob_func		(const char *, const int, void **);
1993 
1994 #ifndef COB_WITHOUT_JMP
1995 COB_EXPIMP void		*cob_savenv		(struct cobjmp_buf *);
1996 COB_EXPIMP void		*cob_savenv2		(struct cobjmp_buf *, const int);
1997 COB_EXPIMP void		cob_longjmp		(struct cobjmp_buf *);
1998 #endif
1999 
2000 COB_EXPIMP int		cob_get_num_params ( void );
2001 COB_EXPIMP int		cob_get_param_constant ( int num_param );
2002 COB_EXPIMP int		cob_get_param_digits( int num_param );
2003 COB_EXPIMP int		cob_get_param_scale( int num_param );
2004 COB_EXPIMP int		cob_get_param_sign ( int num_param );
2005 COB_EXPIMP int		cob_get_param_size ( int num_param );
2006 COB_EXPIMP int		cob_get_param_type ( int num_param );
2007 COB_EXPIMP void *	cob_get_param_data ( int num_param );
2008 COB_EXPIMP cob_s64_t	cob_get_s64_param  ( int num_param );
2009 COB_EXPIMP cob_u64_t	cob_get_u64_param  ( int num_param );
2010 COB_EXPIMP double	cob_get_dbl_param  ( int num_param );
2011 COB_EXPIMP char *	cob_get_picx_param ( int num_param, void *charfld, size_t charlen );
2012 COB_EXPIMP void *	cob_get_grp_param  ( int num_param, void *charfld, size_t charlen );
2013 COB_EXPIMP void		cob_put_dbl_param  ( int num_param, double value );
2014 COB_EXPIMP void		cob_put_s64_param  ( int num_param, cob_s64_t value );
2015 COB_EXPIMP void		cob_put_u64_param  ( int num_param, cob_u64_t value );
2016 COB_EXPIMP void 	cob_put_picx_param ( int num_param, void *charfld );
2017 COB_EXPIMP void  	cob_put_grp_param  ( int num_param, void *charfld, size_t charlen );
2018 
2019 COB_EXPIMP const char	*cob_get_param_str ( int num_param, char *buff, size_t size);
2020 COB_EXPIMP const char	*cob_get_param_str_buffered ( int num_param );
2021 COB_EXPIMP int		cob_put_param_str ( int num_param, const char *src );
2022 
2023 
2024 COB_EXPIMP void		cob_runtime_warning_external	(const char *, const int,
2025 						const char *, ...) COB_A_FORMAT34;
2026 
2027 /* get access to one of the fields (to only operate with libcob functions on it!) */
2028 COB_EXPIMP cob_field	*cob_get_param_field (int n, const char *caller_name);
2029 COB_EXPIMP int		cob_get_field_size (const cob_field *);
2030 COB_EXPIMP int		cob_get_field_type (const cob_field *);
2031 COB_EXPIMP int		cob_get_field_digits	(const cob_field *);
2032 COB_EXPIMP int		cob_get_field_scale	(const cob_field *);
2033 COB_EXPIMP int		cob_get_field_sign	(const cob_field *);
2034 COB_EXPIMP int		cob_get_field_constant (const cob_field *);
2035 COB_EXPIMP const char	*explain_field_type (const cob_field *);
2036 
2037 /* get the field's pretty-display value */
2038 COB_EXPIMP const char	*cob_get_field_str (const cob_field *, char *buff, size_t size);
2039 /* get the field's pretty-display value with an internal buffer for one-time access */
2040 COB_EXPIMP const char	*cob_get_field_str_buffered (const cob_field *);
2041 /* set the field's data using the appropriate internal type, returns EINVAL if data is invalid */
2042 COB_EXPIMP int		cob_put_field_str (const cob_field *, const char *);
2043 
2044 /*******************************/
2045 /* Functions in screenio.c */
2046 
2047 COB_EXPIMP void		cob_screen_line_col	(cob_field *, const int);
2048 COB_EXPIMP void		cob_screen_display	(cob_screen *, cob_field *,
2049 					 cob_field *, const int);
2050 COB_EXPIMP void		cob_screen_accept	(cob_screen *, cob_field *,
2051 					 cob_field *, cob_field *,
2052 					 const int);
2053 COB_EXPIMP void		cob_field_display	(cob_field *, cob_field *, cob_field *,
2054 					 cob_field *, cob_field *, cob_field *,
2055 					 cob_field *, const cob_flags_t);
2056 COB_EXPIMP void		cob_field_accept	(cob_field *, cob_field *, cob_field *,
2057 					 cob_field *, cob_field *, cob_field *,
2058 					 cob_field *, cob_field *, cob_field *,
2059 					 const cob_flags_t);
2060 COB_EXPIMP int		cob_display_text (const char *);
2061 COB_EXPIMP int		cob_display_formatted_text (const char *, ...);
2062 COB_EXPIMP int		cob_get_char	(void);
2063 COB_EXPIMP void		cob_set_cursor_pos	(int, int);
2064 COB_EXPIMP void		cob_accept_escape_key	(cob_field *);
2065 COB_EXPIMP int		cob_sys_clear_screen	(void);
2066 COB_EXPIMP int		cob_sys_sound_bell	(void);
2067 COB_EXPIMP int		cob_sys_get_scr_size	(unsigned char *, unsigned char *);
2068 COB_EXPIMP int		cob_sys_get_char	(unsigned char *);
2069 COB_EXPIMP int		cob_get_text 		(char *, int);
2070 COB_EXPIMP int		cob_get_scr_cols	(void);
2071 COB_EXPIMP int		cob_get_scr_lines	(void);
2072 COB_EXPIMP int		cob_sys_get_csr_pos	(unsigned char *);
2073 COB_EXPIMP int		cob_sys_set_csr_pos	(unsigned char *);
2074 
2075 /******************************************************************************
2076 *                                                                             *
2077 *  Data structure definitions and function prototypes for the External File   *
2078 *  Handler (ExtFH) as defined by Micro Focus COBOL for use with GnuCOBOL      *
2079 *                                                                             *
2080 ******************************************************************************/
2081 /*
2082  *  COBOL status code values
2083 */
2084 #define S1_SUCCESS		'0'
2085 #define S1_AT_END		'1'
2086 #define S1_INVALID_KEY		'2'
2087 #define S1_PERMANENT_ERROR	'3'
2088 #define S1_LOGIC_ERROR		'4'
2089 #define S1_RUN_TIME_ERROR	'9'
2090 
2091 #define S2_NO_INFO		'0'			/* S1_SUCCESS */
2092 #define S2_DUPLICATE		'2'
2093 #define S2_REC_LENGTH		'4'
2094 #define S2_FILE_MISSING		'5'
2095 #define S2_REEL_UNIT		'7'
2096 #define S2_AT_END		'0'			/* S1_AT_END */
2097 #define S2_KEY_LENGTH		'4'
2098 #define S2_SEQ_ERROR		'1'			/* S1_INVALID_KEY */
2099 #define S2_DUPLICATE_ERROR	'2'
2100 #define S2_NO_FIND		'3'
2101 #define S2_BOUNDARY_ERROR	'4'
2102 #define S2_OPEN_ERROR		'7'			/* S1_PERMANENT_ERROR */
2103 #define S2_OPEN_LOCK		'8'
2104 #define S2_ATTR_CONFLICT	'9'
2105 #define S2_ALREADY_OPEN		'1'			/* S1_LOGIC_ERROR */
2106 #define S2_ALREADY_CLOSED	'2'
2107 #define S2_NO_READ		'3'
2108 #define S2_NO_NEXT		'6'
2109 #define S2_NOT_INPUT		'7'
2110 #define S2_NOT_OUTPUT		'8'
2111 #define S2_NOT_OUTPUT2		'9'
2112 
2113 /********************************************
2114 	INDEXED FILE Key definition block
2115 ********************************************/
2116 #define MF_MAXKEYS	64
2117 typedef struct {
2118 	unsigned char	count[2];		/* Component count */
2119 	unsigned char	offset[2];		/* Offset to components */
2120 	unsigned char	keyFlags;
2121 #define	KEY_SPARSE		0x02
2122 #define	KEY_PRIMARY		0x10
2123 #define	KEY_DUPS		0x40
2124 	unsigned char	compFlags;
2125 #define KEY_COMP_DUPS		0x01
2126 #define KEY_COMP_LEADING	0x02
2127 #define KEY_COMP_TRAILING	0x04
2128 	unsigned char	sparse;			/* Character which defines SPARSE key */
2129 	unsigned char	reserved[9];
2130 } KDB_KEY;
2131 
2132 typedef struct {
2133 	unsigned char	kdbLen[2];
2134 	char		filler[4];
2135 	unsigned char	nkeys[2];
2136 	char		filler2[6];
2137 	KDB_KEY	 key[MF_MAXKEYS];
2138 } KDB;
2139 
2140 typedef struct {
2141 	unsigned char	desc;
2142 	unsigned char	type;
2143 	unsigned char	pos[4];				/* Position in record */
2144 	unsigned char	len[4];				/* length of key component */
2145 } EXTKEY;
2146 
2147 #define MF_MAXKEYAREA (sizeof(KDB)+(sizeof(EXTKEY)*MF_MAXKEYS))
2148 /****************************
2149  *  File Control Description (FCD).  The format of this structure is
2150  *  defined by the MicroFocus COBOL compiler.  Do not change this
2151  *  structure unless required by changes to MF COBOL.
2152 ****************************/
2153 
2154 #define pointer_8byte(type, name)	\
2155 	union {					\
2156 		type	*ptr_name;			\
2157 		char	filler[8];			\
2158 	} name
2159 
2160 /**********************************************************/
2161 /* Following is the 64-bit FCD (or also known as FCD3) */
2162 /* This format is used at least for:                      */
2163 /* - MF Visual COBOL         (both 32 and 64 bit)         */
2164 /* - MF Developer Enterprise (both 32 and 64 bit)         */
2165 /* - MF Server Express       (64 bit)                     */
2166 /* - MF Studio Enterprise    (64 bit)                     */
2167 /*                                                        */
2168 /* The FCD2 format is currently not supported, it was     */
2169 /* used at least for                                      */
2170 /* - MF Server Express, Net Express  (32 bit)             */
2171 /* - MF Studio Enterprise            (32 bit)             */
2172 /*                                                        */
2173 /* MF says: FCD 1 is obsolete and should never be used    */
2174 /**********************************************************/
2175 typedef struct {
2176 	unsigned char	fileStatus[2];			/* I/O completion status */
2177 	unsigned char	fcdLen[2];			/* contains length of FCD */
2178 	char		fcdVer;				/* FCD format version */
2179 #define FCD_VER_64Bit	1
2180 	unsigned char	fileOrg;			/* file organization */
2181 #define ORG_LINE_SEQ		0
2182 #define ORG_SEQ			1
2183 #define ORG_INDEXED		2
2184 #define ORG_RELATIVE		3
2185 #define ORG_DETERMINE		255		/* not really implemented yet */
2186 	unsigned char	accessFlags;			/* status byte (bit 7) & file access flags (bits 0-6)*/
2187 #define ACCESS_SEQ			0
2188 #define ACCESS_DUP_PRIME		1	/* not implemented yet */
2189 #define ACCESS_RANDOM		4
2190 #define ACCESS_DYNAMIC		8
2191 #define ACCESS_USER_STAT	0x80
2192 	unsigned char	openMode;			/* open mode INPUT, I-O, etc. */
2193 #define OPEN_INPUT		0
2194 #define OPEN_OUTPUT		1
2195 #define OPEN_IO			2
2196 #define OPEN_EXTEND		3
2197 #define OPEN_NOT_OPEN	128
2198 	unsigned char	recordMode;			/* recording mode */
2199 #define REC_MODE_FIXED		0
2200 #define REC_MODE_VARIABLE	1
2201 	unsigned char	fileFormat;			/* File format */
2202 #define MF_FF_DEFAULT		0		/* Default format */
2203 #define MF_FF_CISAM		1		/* C-ISAM format */
2204 #define MF_FF_LEVELII		2	/* LEVEL II COBOL format */
2205 #define MF_FF_COBOL		3		/* IDXFORMAT"3" format (COBOL2) */
2206 #define MF_FF_IDX4		4		/* IDXFORMAT"4" format */
2207 #define MF_FF_IDX8		8		/* IDXFORMAT"8" format (BIG) */
2208 	unsigned char	deviceFlag;
2209 	unsigned char	lockAction;
2210 	unsigned char	compType;			/* data compression type */
2211 	unsigned char	blocking;
2212 	unsigned char	idxCacheSz;			/* index cache size */
2213 	unsigned char	percent;
2214 	unsigned char	blockSize;
2215 	unsigned char	flags1;
2216 	unsigned char	flags2;
2217 	unsigned char	mvsFlags;
2218 	unsigned char	fstatusType;
2219 #define MF_FST_COBOL85		0x80
2220 #define MF_FST_NoSpaceFill	0x40
2221 #define MF_FST_NoStripSpaces	0x20
2222 #define MF_FST_NoExpandtabs	0x10
2223 #define MF_FST_LsRecLF		0x08
2224 #define MF_FST_InsertTabs	0x04
2225 #define MF_FST_InsertNulls	0x02
2226 #define MF_FST_CRdelim		0x01
2227 	unsigned char	otherFlags;			/* miscellaneous flags */
2228 #define OTH_OPTIONAL		0x80
2229 #define OTH_NOT_OPTIONAL	0x20
2230 #define OTH_EXTERNAL		0x10
2231 #define OTH_DOLSREAD		0x08
2232 #define OTH_NODETECTLOCK	0x04
2233 #define OTH_MULTI_REEL		0x02
2234 #define OTH_LINE_ADVANCE	0x01
2235 	unsigned char	transLog;
2236 	unsigned char	lockTypes;
2237 	unsigned char	fsFlags;
2238 	unsigned char	confFlags;			/* configuration flags */
2239 #define MF_CF_WRTHRU		0x80			/* Write through to disk */
2240 #define MF_CF_RELADRS		0x40			/* Use relative byte address */
2241 #define MF_CF_UPPTR		0x20			/* Update current record pointer */
2242 #define MF_CF_REC64		0x10			/* Use 64-bit record address */
2243 	unsigned char	miscFlags;			/* misc flags */
2244 	unsigned char	confFlags2;			/* configuration flags */
2245 	unsigned char	lockMode;			/* locking flags */
2246 #define FCD_LOCK_MULTI		0x80
2247 #define FCD_LOCK_WRITE		0x40
2248 #define FCD_LOCK_RETRY_OPEN	0x20
2249 #define FCD_LOCK_SKIP		0x10
2250 #define FCD_LOCK_RETRY_LOCK	0x08
2251 #define FCD_LOCK_MANU_LOCK	0x04
2252 #define FCD_LOCK_AUTO_LOCK	0x02
2253 #define FCD_LOCK_EXCL_LOCK	0x01
2254 	unsigned char	fsv2Flags;			/* Fileshare V2 flags */
2255 	unsigned char	idxCacheArea;			/* index cache buffers */
2256 	unsigned char	fcdInternal1;
2257 	unsigned char	fcdInternal2;
2258 	char		res3[14];
2259 	unsigned char	gcFlags; 			/* was "res3"; Local GnuCOBOL feature only */
2260 #define MF_CALLFH_GNUCOBOL	0x80			/* GnuCOBOL is being used */
2261 #define MF_CALLFH_BYPASS	0x40			/* Stop passing this file to 'callfh' */
2262 #define MF_CALLFH_TRACE		0x20			/* Trace I/O for this file */
2263 #define MF_CALLFH_STATS		0x10			/* Record Stats for this file */
2264 	unsigned char	nlsId[2];
2265 	char		fsv2FileId[2];			/* Fileshare V2 file id */
2266 	char		retryOpenCount[2];
2267 	unsigned char	fnameLen[2];			/* file name length */
2268 	unsigned char	idxNameLen[2];			/* index name length */
2269 	char		retryCount[2];
2270 	unsigned char	refKey[2];			/* key of reference */
2271 	unsigned char	lineCount[2];
2272 	unsigned char	useFiles;
2273 	unsigned char	giveFiles;
2274 	unsigned char	effKeyLen[2];			/* effective key length */
2275 	char		res5[14];
2276 	unsigned char	eop[2];				/* was "res5"; Use for cob_write eop value */
2277 	char		opt[4];				/* was "res5"; Use for cob_write opts value */
2278 	unsigned char	curRecLen[4];			/* current record length in bytes */
2279 	unsigned char	minRecLen[4];			/* min. record length in bytes */
2280 	unsigned char	maxRecLen[4];			/* max. record length in bytes */
2281 	char		fsv2SessionId[4];		/* Fileshare V2 session id */
2282 	char		res6[24];
2283 	unsigned char	relByteAdrs[8];			/* 64-bit, relative byte address */
2284 	unsigned char	maxRelKey[8];			/* 64-bit, max relative key/Record num */
2285 	unsigned char	relKey[8];			/* 64-bit, (cur) relative key/Record num */
2286 	pointer_8byte(void,	_fileHandle);			/* file handle */
2287 	pointer_8byte(unsigned char,	_recPtr);			/* pointer to record area */
2288 	pointer_8byte(char,	_fnamePtr);			/* pointer to file name area */
2289 	pointer_8byte(char,	_idxNamePtr);			/* pointer to index name area */
2290 	pointer_8byte(KDB,	_kdbPtr);			/* pointer to key definition block */
2291 	pointer_8byte(void,	_colPtr);			/* pointer to collating sequence block */
2292 	pointer_8byte(void,	_fileDef);			/* pointer to filedef */
2293 	pointer_8byte(void,	_dfSortPtr);			/* pointer to DFSORT */
2294 } FCD3;
2295 
2296 #define fileHandle	_fileHandle.ptr_name	/* EXTFH: file handle */
2297 #define recPtr		_recPtr.ptr_name	/* EXTFH: pointer to record area */
2298 #define fnamePtr	_fnamePtr.ptr_name		/* EXTFH: pointer to file name area */
2299 #define idxNamePtr	_idxNamePtr.ptr_name	/* EXTFH: pointer to index name area */
2300 #define kdbPtr		_kdbPtr.ptr_name 		/* EXTFH: pointer to key definition block */
2301 #define colPtr		_colPtr.ptr_name		/* EXTFH: pointer to collating sequence block */
2302 #define fileDef		_fileDef.ptr_name		/* EXTFH: pointer to filedef */
2303 #define dfSortPtr	_dfSortPtr.ptr_name		/* EXTFH: pointer to DFSORT */
2304 
2305 #define LSUCHAR(f)	((unsigned char*)(f))
2306 /* xxCOMPXn : Big Endian Binary data */
2307 #define LDCOMPX2(f)	(((f[0] << 8 ) & 0xFF00) | (f[1] & 0xFF))
2308 #define LDCOMPX4(f)	(((f[0] << 24 ) & 0xFF000000) | ((f[1] << 16 ) & 0xFF0000) | ((f[2] << 8 ) & 0xFF00) | (f[3] & 0xFF))
2309 #define STCOMPX2(v,f)	(f[1] = (v) & 0xFF, f[0] = ((v) >> 8) & 0xFF)
2310 #define STCOMPX4(v,f)	(f[3] = (v) & 0xFF, f[2] = ((v) >> 8) & 0xFF, f[1] = ((v) >> 16) & 0xFF, f[0] = ((v) >> 24) & 0xFF)
2311 
2312 /* xxBINLEn : Little Endian Binary data */
2313 #define LDBINLE2(f)	(((f[1] << 8 ) & 0xFF00) | (f[0] & 0xFF))
2314 #define LDBINLE4(f)	(((f[3] << 24 ) & 0xFF000000) | ((f[2] << 16 ) & 0xFF0000) | ((f[1] << 8 ) & 0xFF00) | (f[0] & 0xFF))
2315 #define STBINLE2(v,f)	(f[0] = (v) & 0xFF, f[1] = ((v) >> 8) & 0xFF)
2316 #define STBINLE4(v,f)	(f[0] = (v) & 0xFF, f[1] = ((v) >> 8) & 0xFF, f[2] = ((v) >> 16) & 0xFF, f[3] = ((v) >> 24) & 0xFF)
2317 
2318 /*************************/
2319 /* EXTFH operation codes */
2320 /*************************/
2321 #define OP_GETINFO			0x0006
2322 #define OP_CRE8_INDEX			0x0007
2323 #define OP_FLUSH			0x000C
2324 #define OP_UNLOCK_REC			0x000F
2325 
2326 #define OP_CLOSE			0xFA80		/* OP CODES */
2327 #define OP_CLOSE_LOCK			0xFA81
2328 #define OP_CLOSE_NO_REWIND		0xFA82
2329 #define OP_CLOSE_REEL			0xFA84
2330 #define OP_CLOSE_REMOVE			0xFA85
2331 #define OP_CLOSE_NOREWIND		0xFA86
2332 
2333 #define OP_OPEN_INPUT			0xFA00
2334 #define OP_OPEN_OUTPUT			0xFA01
2335 #define OP_OPEN_IO			0xFA02
2336 #define OP_OPEN_EXTEND			0xFA03
2337 #define OP_OPEN_INPUT_NOREWIND		0xFA04
2338 #define OP_OPEN_OUTPUT_NOREWIND		0xFA05
2339 #define OP_OPEN_INPUT_REVERSED		0xFA08
2340 
2341 #define OP_READ_SEQ_NO_LOCK		0xFA8D
2342 #define OP_READ_SEQ_LOCK		0xFAD8
2343 #define OP_READ_SEQ_KEPT_LOCK		0xFAD9
2344 #define OP_READ_SEQ			0xFAF5
2345 #define OP_READ_PREV_NO_LOCK		0xFA8C
2346 #define OP_READ_PREV_LOCK		0xFADE
2347 #define OP_READ_PREV_KEPT_LOCK		0xFADF
2348 #define OP_READ_PREV			0xFAF9
2349 #define OP_READ_RAN_NO_LOCK		0xFA8E
2350 #define OP_READ_RAN_LOCK		0xFADA
2351 #define OP_READ_RAN_KEPT_LOCK		0xFADB
2352 #define OP_READ_RAN			0xFAF6
2353 #define OP_READ_DIR_NO_LOCK		0xFA8F
2354 #define OP_READ_DIR_LOCK		0xFAD6
2355 #define OP_READ_DIR_KEPT_LOCK		0xFAD7
2356 #define OP_READ_DIR			0xFAC9
2357 #define OP_READ_POSITION		0xFAF1
2358 
2359 #define OP_WRITE_BEFORE			0xFAE1
2360 #define OP_WRITE_BEFORE_TAB		0xFAE3
2361 #define OP_WRITE_BEFORE_PAGE		0xFAE5
2362 #define OP_WRITE_AFTER			0xFAE2
2363 #define OP_WRITE_AFTER_TAB		0xFAE4
2364 #define OP_WRITE_AFTER_PAGE		0xFAE6
2365 
2366 #define OP_WRITE			0xFAF3
2367 #define OP_REWRITE			0xFAF4
2368 
2369 #define OP_START_EQ			0xFAE8
2370 #define OP_START_EQ_ANY			0xFAE9
2371 #define OP_START_GT			0xFAEA
2372 #define OP_START_GE			0xFAEB
2373 #define OP_START_LT			0xFAFE
2374 #define OP_START_LE			0xFAFF
2375 #define OP_START_LA			0xFAEC	/* LAST: Not in MF standard */
2376 #define OP_START_FI			0xFAED	/* FIRST: Not in MF standard */
2377 
2378 #define OP_STEP_NEXT_NO_LOCK		0xFA90
2379 #define OP_STEP_NEXT_LOCK		0xFAD4
2380 #define OP_STEP_NEXT_KEPT_LOCK		0xFAD5
2381 #define OP_STEP_NEXT			0xFACA
2382 #define OP_STEP_FIRST_NO_LOCK		0xFA92
2383 #define OP_STEP_FIRST_LOCK		0xFAD0
2384 #define OP_STEP_FIRST_KEPT_LOCK		0xFAD1
2385 #define OP_STEP_FIRST			0xFACC
2386 
2387 #define OP_DELETE			0xFAF7
2388 #define OP_DELETE_FILE			0xFAF8
2389 #define OP_UNLOCK			0xFA0E
2390 #define OP_COMMIT			0xFADC
2391 #define OP_ROLLBACK			0xFADD
2392 
2393 /*******************************/
2394 /* Functions in termio.c */
2395 
2396 COB_EXPIMP void cob_display	(const int, const int, const int, ...);
2397 COB_EXPIMP void cob_dump_output (const char *);
2398 COB_EXPIMP void cob_dump_file (const char *, cob_file *);
2399 COB_EXPIMP void cob_dump_field	(const int, const char *, cob_field *, const int, const int, ...);
2400 COB_EXPIMP void cob_dump_field_ext	(const int, const char *, cob_field *, const cob_uli_t, const cob_u32_t, ...);
2401 COB_EXPIMP void cob_accept	(cob_field *);
2402 
2403 /*******************************/
2404 /* Functions in fileio.c */
2405 
2406 COB_EXPIMP void	cob_file_external_addr (const char *,
2407 				 cob_file **, cob_file_key **,
2408 				 const int nkeys, const int linage);
2409 COB_EXPIMP void	cob_file_malloc (cob_file **, cob_file_key **,
2410 				 const int nkeys, const int linage);
2411 COB_EXPIMP void	cob_file_free   (cob_file **, cob_file_key **);
2412 
2413 COB_EXPIMP int	cob_findkey (cob_file *, cob_field *, int *, int *);
2414 
2415 COB_EXPIMP void cob_open	(cob_file *, const int, const int, cob_field *);
2416 COB_EXPIMP void cob_close	(cob_file *, cob_field *, const int, const int);
2417 COB_EXPIMP void cob_read	(cob_file *, cob_field *, cob_field *, const int);
2418 COB_EXPIMP void cob_read_next	(cob_file *, cob_field *, const int);
2419 COB_EXPIMP void cob_rewrite	(cob_file *, cob_field *, const int, cob_field *);
2420 COB_EXPIMP void cob_delete	(cob_file *, cob_field *);
2421 COB_EXPIMP void cob_start	(cob_file *, const int, cob_field *,
2422 				 cob_field *, cob_field *);
2423 COB_EXPIMP void cob_write	(cob_file *, cob_field *, const int,
2424 				 cob_field *, const unsigned int);
2425 
2426 COB_EXPIMP void cob_delete_file	(cob_file *, cob_field *);
2427 COB_EXPIMP void cob_unlock_file	(cob_file *, cob_field *);
2428 COB_EXPIMP void cob_commit	(void);
2429 COB_EXPIMP void cob_rollback	(void);
2430 
2431 
2432 /* functions in fileio.c for the MF style EXTFH interface */
2433 COB_EXPIMP int	EXTFH		(unsigned char *opcode, FCD3 *fcd);
2434 
2435 COB_EXPIMP void	cob_extfh_open		(int (*callfh)(unsigned char *opcode, FCD3 *fcd),
2436 					cob_file *, const int, const int, cob_field *);
2437 COB_EXPIMP void cob_extfh_close		(int (*callfh)(unsigned char *opcode, FCD3 *fcd),
2438 					cob_file *, cob_field *, const int, const int);
2439 COB_EXPIMP void cob_extfh_read		(int (*callfh)(unsigned char *opcode, FCD3 *fcd),
2440 					cob_file *, cob_field *, cob_field *, const int);
2441 COB_EXPIMP void cob_extfh_read_next	(int (*callfh)(unsigned char *opcode, FCD3 *fcd),
2442 					cob_file *, cob_field *, const int);
2443 COB_EXPIMP void cob_extfh_rewrite	(int (*callfh)(unsigned char *opcode, FCD3 *fcd),
2444 					cob_file *, cob_field *, const int, cob_field *);
2445 COB_EXPIMP void cob_extfh_delete	(int (*callfh)(unsigned char *opcode, FCD3 *fcd),
2446 					cob_file *, cob_field *);
2447 COB_EXPIMP void cob_extfh_start		(int (*callfh)(unsigned char *opcode, FCD3 *fcd),
2448 					cob_file *, const int, cob_field *,
2449 					cob_field *, cob_field *);
2450 COB_EXPIMP void cob_extfh_write		(int (*callfh)(unsigned char *opcode, FCD3 *fcd),
2451 					cob_file *, cob_field *, const int,
2452 				 	cob_field *, const unsigned int);
2453 
2454 /* File system routines */
2455 COB_EXPIMP int cob_sys_open_file	(unsigned char *, unsigned char *,
2456 					 unsigned char *, unsigned char *,
2457 					 unsigned char *);
2458 COB_EXPIMP int cob_sys_create_file	(unsigned char *, unsigned char *,
2459 					 unsigned char *, unsigned char *,
2460 					 unsigned char *);
2461 COB_EXPIMP int cob_sys_read_file	(unsigned char *, unsigned char *,
2462 					 unsigned char *, unsigned char *,
2463 					 unsigned char *);
2464 COB_EXPIMP int cob_sys_write_file	(unsigned char *, unsigned char *,
2465 					 unsigned char *, unsigned char *,
2466 					 unsigned char *);
2467 COB_EXPIMP int cob_sys_close_file	(unsigned char *);
2468 COB_EXPIMP int cob_sys_flush_file	(unsigned char *);
2469 COB_EXPIMP int cob_sys_delete_file	(unsigned char *);
2470 COB_EXPIMP int cob_sys_copy_file	(unsigned char *, unsigned char *);
2471 COB_EXPIMP int cob_sys_check_file_exist	(unsigned char *, unsigned char *);
2472 COB_EXPIMP int cob_sys_rename_file	(unsigned char *, unsigned char *);
2473 COB_EXPIMP int cob_sys_get_current_dir	(const int, const int, unsigned char *);
2474 COB_EXPIMP int cob_sys_change_dir	(unsigned char *);
2475 COB_EXPIMP int cob_sys_create_dir	(unsigned char *);
2476 COB_EXPIMP int cob_sys_delete_dir	(unsigned char *);
2477 COB_EXPIMP int cob_sys_chdir		(unsigned char *, unsigned char *);
2478 COB_EXPIMP int cob_sys_mkdir		(unsigned char *);
2479 COB_EXPIMP int cob_sys_copyfile		(unsigned char *, unsigned char *,
2480 					 unsigned char *);
2481 COB_EXPIMP int cob_sys_file_info	(unsigned char *, unsigned char *);
2482 COB_EXPIMP int cob_sys_file_delete	(unsigned char *, unsigned char *);
2483 
2484 /* SORT routines */
2485 COB_EXPIMP void	cob_file_sort_init	(cob_file *, const unsigned int,
2486 					 const unsigned char *,
2487 					 void *, cob_field *);
2488 COB_EXPIMP void	cob_file_sort_init_key	(cob_file *, cob_field *,
2489 					 const int, const unsigned int);
2490 COB_EXPIMP void	cob_file_sort_close	(cob_file *);
2491 COB_EXPIMP void	cob_file_sort_using	(cob_file *, cob_file *);
2492 COB_EXPIMP void	cob_file_sort_giving	(cob_file *, const size_t, ...);
2493 COB_EXPIMP void	cob_file_release	(cob_file *);
2494 COB_EXPIMP void	cob_file_return		(cob_file *);
2495 
2496 /***************************/
2497 /* Functions in reportio.c */
2498 /***************************/
2499 COB_EXPIMP void cob_report_initiate	(cob_report *);
2500 COB_EXPIMP int  cob_report_terminate	(cob_report *, int);
2501 COB_EXPIMP int  cob_report_generate	(cob_report *, cob_report_line *, int);
2502 COB_EXPIMP void cob_report_suppress	(cob_report *r, cob_report_line *l);
2503 
2504 /**********************/
2505 /* Functions in mlio.c */
2506 /**********************/
2507 
2508 COB_EXPIMP int	cob_is_valid_uri	(const char *);
2509 COB_EXPIMP int	cob_is_xml_namestartchar	(const int);
2510 COB_EXPIMP int	cob_is_xml_namechar	(const int);
2511 COB_EXPIMP void	cob_xml_generate	(cob_field *, cob_ml_tree *,
2512 					 cob_field *, const int, cob_field *,
2513 					 cob_field *);
2514 COB_EXPIMP void cob_json_generate	(cob_field *, cob_ml_tree *,
2515 					 cob_field *);
2516 COB_EXPIMP void	cob_xml_generate_new	(cob_field *, cob_ml_tree *,
2517 					 cob_field *, const int, cob_field *,
2518 					 cob_field *, const char);
2519 COB_EXPIMP void cob_json_generate_new	(cob_field *, cob_ml_tree *,
2520 					 cob_field *, const char);
2521 
2522 
2523 /****************************/
2524 /* Functions in intrinsic.c */
2525 /****************************/
2526 COB_EXPIMP void		cob_put_indirect_field		(cob_field *);
2527 COB_EXPIMP void		cob_get_indirect_field		(cob_field *);
2528 COB_EXPIMP cob_field *cob_switch_value			(const int);
2529 COB_EXPIMP cob_field *cob_intr_binop			(cob_field *, const int,
2530 							 cob_field *);
2531 
2532 COB_EXPIMP int cob_check_numval				(const cob_field *,
2533 							 const cob_field *,
2534 							 const int, const int);
2535 
2536 COB_EXPIMP int cob_valid_date_format			(const char *);
2537 COB_EXPIMP int cob_valid_datetime_format		(const char *, const char);
2538 COB_EXPIMP int cob_valid_time_format			(const char *, const char);
2539 
2540 COB_EXPIMP cob_field *cob_intr_current_date		(const int, const int);
2541 COB_EXPIMP cob_field *cob_intr_when_compiled		(const int, const int,
2542 							 cob_field *);
2543 COB_EXPIMP cob_field *cob_intr_module_date		(void);
2544 COB_EXPIMP cob_field *cob_intr_module_time		(void);
2545 COB_EXPIMP cob_field *cob_intr_module_id		(void);
2546 COB_EXPIMP cob_field *cob_intr_module_caller_id		(void);
2547 COB_EXPIMP cob_field *cob_intr_module_source		(void);
2548 COB_EXPIMP cob_field *cob_intr_module_formatted_date	(void);
2549 COB_EXPIMP cob_field *cob_intr_module_path		(void);
2550 COB_EXPIMP cob_field *cob_intr_exception_file		(void);
2551 COB_EXPIMP cob_field *cob_intr_exception_location	(void);
2552 COB_EXPIMP cob_field *cob_intr_exception_status		(void);
2553 COB_EXPIMP cob_field *cob_intr_exception_statement	(void);
2554 COB_EXPIMP cob_field *cob_intr_mon_decimal_point	(void);
2555 COB_EXPIMP cob_field *cob_intr_num_decimal_point	(void);
2556 COB_EXPIMP cob_field *cob_intr_mon_thousands_sep	(void);
2557 COB_EXPIMP cob_field *cob_intr_num_thousands_sep	(void);
2558 COB_EXPIMP cob_field *cob_intr_currency_symbol		(void);
2559 COB_EXPIMP cob_field *cob_intr_char			(cob_field *);
2560 COB_EXPIMP cob_field *cob_intr_ord			(cob_field *);
2561 COB_EXPIMP cob_field *cob_intr_stored_char_length	(cob_field *);
2562 COB_EXPIMP cob_field *cob_intr_combined_datetime	(cob_field *, cob_field *);
2563 COB_EXPIMP cob_field *cob_intr_date_of_integer		(cob_field *);
2564 COB_EXPIMP cob_field *cob_intr_day_of_integer		(cob_field *);
2565 COB_EXPIMP cob_field *cob_intr_integer_of_date		(cob_field *);
2566 COB_EXPIMP cob_field *cob_intr_integer_of_day		(cob_field *);
2567 COB_EXPIMP cob_field *cob_intr_test_date_yyyymmdd	(cob_field *);
2568 COB_EXPIMP cob_field *cob_intr_test_day_yyyyddd		(cob_field *);
2569 COB_EXPIMP cob_field *cob_intr_test_numval		(cob_field *);
2570 COB_EXPIMP cob_field *cob_intr_test_numval_c		(cob_field *, cob_field *);
2571 COB_EXPIMP cob_field *cob_intr_test_numval_f		(cob_field *);
2572 COB_EXPIMP cob_field *cob_intr_factorial		(cob_field *);
2573 
2574 COB_EXPIMP cob_field *cob_intr_pi			(void);
2575 COB_EXPIMP cob_field *cob_intr_e			(void);
2576 COB_EXPIMP cob_field *cob_intr_exp			(cob_field *);
2577 COB_EXPIMP cob_field *cob_intr_exp10			(cob_field *);
2578 COB_EXPIMP cob_field *cob_intr_abs			(cob_field *);
2579 COB_EXPIMP cob_field *cob_intr_acos			(cob_field *);
2580 COB_EXPIMP cob_field *cob_intr_asin			(cob_field *);
2581 COB_EXPIMP cob_field *cob_intr_atan			(cob_field *);
2582 COB_EXPIMP cob_field *cob_intr_cos			(cob_field *);
2583 COB_EXPIMP cob_field *cob_intr_log			(cob_field *);
2584 COB_EXPIMP cob_field *cob_intr_log10			(cob_field *);
2585 COB_EXPIMP cob_field *cob_intr_sin			(cob_field *);
2586 COB_EXPIMP cob_field *cob_intr_sqrt			(cob_field *);
2587 COB_EXPIMP cob_field *cob_intr_tan			(cob_field *);
2588 
2589 COB_EXPIMP cob_field *cob_intr_upper_case		(const int, const int,
2590 							 cob_field *);
2591 COB_EXPIMP cob_field *cob_intr_lower_case		(const int, const int,
2592 							 cob_field *);
2593 COB_EXPIMP cob_field *cob_intr_reverse			(const int, const int,
2594 							 cob_field *);
2595 COB_EXPIMP cob_field *cob_intr_concatenate		(const int, const int,
2596 							 const int, ...);
2597 COB_EXPIMP cob_field *cob_intr_substitute		(const int, const int,
2598 							 const int, ...);
2599 COB_EXPIMP cob_field *cob_intr_substitute_case		(const int, const int,
2600 							 const int, ...);
2601 COB_EXPIMP cob_field *cob_intr_trim			(const int, const int,
2602 							 cob_field *, const int);
2603 COB_EXPIMP cob_field *cob_intr_length			(cob_field *);
2604 COB_EXPIMP cob_field *cob_intr_byte_length		(cob_field *);
2605 COB_EXPIMP cob_field *cob_intr_integer			(cob_field *);
2606 COB_EXPIMP cob_field *cob_intr_integer_part		(cob_field *);
2607 COB_EXPIMP cob_field *cob_intr_fraction_part		(cob_field *);
2608 COB_EXPIMP cob_field *cob_intr_sign			(cob_field *);
2609 COB_EXPIMP cob_field *cob_intr_lowest_algebraic		(cob_field *);
2610 COB_EXPIMP cob_field *cob_intr_highest_algebraic	(cob_field *);
2611 COB_EXPIMP cob_field *cob_intr_numval			(cob_field *);
2612 COB_EXPIMP cob_field *cob_intr_numval_c			(cob_field *, cob_field *);
2613 COB_EXPIMP cob_field *cob_intr_numval_f			(cob_field *);
2614 COB_EXPIMP cob_field *cob_intr_annuity			(cob_field *, cob_field *);
2615 COB_EXPIMP cob_field *cob_intr_mod			(cob_field *, cob_field *);
2616 COB_EXPIMP cob_field *cob_intr_rem			(cob_field *, cob_field *);
2617 COB_EXPIMP cob_field *cob_intr_sum			(const int, ...);
2618 COB_EXPIMP cob_field *cob_intr_ord_min			(const int, ...);
2619 COB_EXPIMP cob_field *cob_intr_ord_max			(const int, ...);
2620 COB_EXPIMP cob_field *cob_intr_min			(const int, ...);
2621 COB_EXPIMP cob_field *cob_intr_max			(const int, ...);
2622 COB_EXPIMP cob_field *cob_intr_midrange			(const int, ...);
2623 COB_EXPIMP cob_field *cob_intr_median			(const int, ...);
2624 COB_EXPIMP cob_field *cob_intr_mean			(const int, ...);
2625 COB_EXPIMP cob_field *cob_intr_range			(const int, ...);
2626 COB_EXPIMP cob_field *cob_intr_random			(const int, ...);
2627 COB_EXPIMP cob_field *cob_intr_variance			(const int, ...);
2628 COB_EXPIMP cob_field *cob_intr_standard_deviation	(const int, ...);
2629 COB_EXPIMP cob_field *cob_intr_present_value		(const int, ...);
2630 COB_EXPIMP cob_field *cob_intr_year_to_yyyy		(const int, ...);
2631 COB_EXPIMP cob_field *cob_intr_date_to_yyyymmdd		(const int, ...);
2632 COB_EXPIMP cob_field *cob_intr_day_to_yyyyddd		(const int, ...);
2633 COB_EXPIMP cob_field *cob_intr_locale_compare		(const int, ...);
2634 COB_EXPIMP cob_field *cob_intr_locale_date		(const int, const int,
2635 							 cob_field *, cob_field *);
2636 COB_EXPIMP cob_field *cob_intr_locale_time		(const int, const int,
2637 							 cob_field *, cob_field *);
2638 
2639 COB_EXPIMP cob_field *cob_intr_seconds_past_midnight	(void);
2640 COB_EXPIMP cob_field *cob_intr_lcl_time_from_secs	(const int, const int,
2641 							 cob_field *, cob_field *);
2642 
2643 COB_EXPIMP cob_field *cob_intr_seconds_from_formatted_time	(cob_field *,
2644 								 cob_field *);
2645 
2646 COB_EXPIMP cob_field *cob_intr_boolean_of_integer	(cob_field *, cob_field *);
2647 COB_EXPIMP cob_field *cob_intr_char_national		(cob_field *);
2648 COB_EXPIMP cob_field *cob_intr_display_of		(const int, const int,
2649 							 const int, ...);
2650 COB_EXPIMP cob_field *cob_intr_exception_file_n		(void);
2651 COB_EXPIMP cob_field *cob_intr_exception_location_n	(void);
2652 COB_EXPIMP cob_field *cob_intr_formatted_current_date	(const int, const int,
2653 							 cob_field *);
2654 COB_EXPIMP cob_field *cob_intr_formatted_date		(const int, const int,
2655 							 cob_field *, cob_field *);
2656 COB_EXPIMP cob_field *cob_intr_formatted_datetime	(const int, const int,
2657 							 const int, ...);
2658 COB_EXPIMP cob_field *cob_intr_formatted_time		(const int, const int,
2659 							 const int, ...);
2660 COB_EXPIMP cob_field *cob_intr_integer_of_boolean	(cob_field *);
2661 COB_EXPIMP cob_field *cob_intr_national_of		(const int, const int,
2662 							 const int, ...);
2663 COB_EXPIMP cob_field *cob_intr_standard_compare		(const int, ...);
2664 COB_EXPIMP cob_field *cob_intr_test_formatted_datetime	(cob_field *, cob_field *);
2665 
2666 COB_EXPIMP cob_field *cob_intr_integer_of_formatted_date	(cob_field *,
2667 								 cob_field *);
2668 COB_EXPIMP cob_field *cob_intr_content_length		(cob_field *);
2669 COB_EXPIMP cob_field *cob_intr_content_of		(const int, const int,
2670 							 const int, ...);
2671 
2672 /*******************************/
2673 
2674 /*******************************/
2675 /* defines for MicroFocus C -> COBOL API */
2676 typedef	char *		cobchar_t;
2677 #define	cobs8_t		cob_s8_t
2678 #define	cobuns8_t	cob_u8_t
2679 #define	cobs16_t	cob_s16_t
2680 #define	cobuns16_t	cob_u16_t
2681 #define	cobs32_t	cob_s32_t
2682 #define	cobuns32_t	cob_u32_t
2683 #define	cobs64_t	cob_s64_t
2684 #define	cobuns64_t	cob_u64_t
2685 
2686 #ifndef COB_WITHOUT_JMP
2687 #define	cobsetjmp(x)	setjmp (cob_savenv (x))
2688 #define	coblongjmp(x)	cob_longjmp (x)
2689 #define	cobsavenv(x)	cob_savenv (x)
2690 #define	cobsavenv2(x,z)	cob_savenv2 (x, z)
2691 #endif
2692 
2693 #define	cobfunc(x,y,z)	cob_func (x, y, z)
2694 #define	cobcall(x,y,z)	cob_call (x, y, z)
2695 #define	cobcancel(x)	cob_cancel (x)
2696 
2697 #define	cobgetenv(x)	cob_getenv (x)
2698 #define	cobputenv(x)	cob_putenv (x)
2699 #define cobrescanenv()	0 	/* not necessary as GnuCOBOL always reads the process environment */
2700 #define	cobtidy()	cob_tidy ()
2701 #define	cobinit()	cob_extern_init ()
2702 #define	cobexit(x)	cob_stop_run (x)
2703 #define	cobcommandline(v,w,x,y,z)	cob_command_line (v,w,x,y,z)
2704 
2705 #define cobclear()	(void) cob_sys_clear_screen ()
2706 #define cobmove(y,x)	cob_set_cursor_pos (y, x)
2707 #define	cobcols()	cob_get_scr_cols ()
2708 #define	coblines()	cob_get_scr_lines ()
2709 #define cobaddstrc(x)	cob_display_text (x) 		/* no limit [MF=255] */
2710 #define cobprintf	cob_display_formatted_text	/* limit of 2047 [MF=255] */
2711 #define cobgetch()	cob_get_char ()
2712 
2713 #define cobget_x1_compx(d)	(cobuns8_t) 	cob_get_u64_compx(d, 1)
2714 #define cobget_x2_compx(d)	(cobuns16_t)	cob_get_u64_compx(d, 2)
2715 #define cobget_x4_compx(d)	(cobuns32_t)	cob_get_u64_compx(d, 4)
2716 #define cobget_x8_compx(d)	(cobuns64_t)	cob_get_u64_compx(d, 8)
2717 #define cobget_sx1_compx(d)	(cobs8_t) 	cob_get_s64_compx(d, 1)
2718 #define cobget_sx2_compx(d)	(cobs16_t)	cob_get_s64_compx(d, 2)
2719 #define cobget_sx4_compx(d)	(cobs32_t)	cob_get_s64_compx(d, 4)
2720 #define cobget_sx8_compx(d)	(cobs64_t)	cob_get_s64_compx(d, 8)
2721 #define cobget_x1_comp5(d)	(cobuns8_t) 	cob_get_u64_comp5(d, 1)
2722 #define cobget_x2_comp5(d)	(cobuns16_t)	cob_get_u64_comp5(d, 2)
2723 #define cobget_x4_comp5(d)	(cobuns32_t)	cob_get_u64_comp5(d, 4)
2724 #define cobget_x8_comp5(d)	(cobuns64_t)	cob_get_u64_comp5(d, 8)
2725 #define cobget_sx1_comp5(d)	(cobs8_t) 	cob_get_s64_comp5(d, 1)
2726 #define cobget_sx2_comp5(d)	(cobs16_t)	cob_get_s64_comp5(d, 2)
2727 #define cobget_sx4_comp5(d)	(cobs32_t)	cob_get_s64_comp5(d, 4)
2728 #define cobget_sx8_comp5(d)	(cobs64_t)	cob_get_s64_comp5(d, 8)
2729 #define cobget_xn_comp5(d,n)	(cobuns64_t)	cob_get_u64_comp5(d, n)
2730 #define cobget_xn_compx(d,n)	(cobuns64_t)	cob_get_u64_compx(d, n)
2731 #define cobget_sxn_comp5(d,n)	(cobs64_t)	cob_get_s64_comp5(d, n)
2732 #define cobget_sxn_compx(d,n)	(cobs64_t)	cob_get_s64_compx(d, n)
2733 
2734 #define cobput_x1_compx(d,v)	(void)	cob_put_u64_compx((cob_u64_t)v,d,1)
2735 #define cobput_x2_compx(d,v)	(void)	cob_put_u64_compx((cob_u64_t)v,d,2)
2736 #define cobput_x4_compx(d,v)	(void)	cob_put_u64_compx((cob_u64_t)v,d,4)
2737 #define cobput_x8_compx(d,v)	(void)	cob_put_u64_compx((cob_u64_t)v,d,8)
2738 #define cobput_x1_comp5(d,v)	(void)	cob_put_u64_comp5((cob_u64_t)v,d,1)
2739 #define cobput_x2_comp5(d,v)	(void)	cob_put_u64_comp5((cob_u64_t)v,d,2)
2740 #define cobput_x4_comp5(d,v)	(void)	cob_put_u64_comp5((cob_u64_t)v,d,4)
2741 #define cobput_x8_comp5(d,v)	(void)	cob_put_u64_comp5((cob_u64_t)v,d,8)
2742 #define cobput_sx1_comp5(d,v)	(void)	cob_put_s64_comp5((cob_s64_t)v,d,1)
2743 #define cobput_sx2_comp5(d,v)	(void)	cob_put_s64_comp5((cob_s64_t)v,d,2)
2744 #define cobput_sx4_comp5(d,v)	(void)	cob_put_s64_comp5((cob_s64_t)v,d,4)
2745 #define cobput_sx8_comp5(d,v)	(void)	cob_put_s64_comp5((cob_s64_t)v,d,8)
2746 #define cobput_xn_comp5(d,n,v)	(void)	cob_put_u64_comp5(v, d, n)
2747 #define cobput_xn_compx(d,n,v)	(void)	cob_put_u64_compx(v, d, n)
2748 #define cobput_sxn_comp5(d,n,v)	(void)	cob_put_s64_comp5(v, d, n)
2749 #define cobput_sxn_compx(d,n,v)	(void)	cob_put_s64_compx(v, d, n)
2750 
2751 /*******************************/
2752 
2753 #endif	/* COB_COMMON_H */
2754