blob: c03b1c5b923ed814580627e9059491eef1f9d3dc [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/* ANP: Assumption: host system defines 'XENV' and 'SDL_SIMULATION'. This is true in UMTS case. */
2/* To find the 'else' and 'endif' clause search for: 'SDTENV && SDL_SIMULATION' */
3
4/******************************************************************************
5*
6* (C) Danish Wireless Design
7*
8* $RCSfile: sctpred.h,v $
9*
10* $Author: pbo $
11* $Revision: 1.4 $
12* $Date: 2001/07/18 13:01:54 $
13*
14* Description:
15*
16*******************************************************************************/
17
18#ifndef X_SCTPRED_H
19#define X_SCTPRED_H
20
21
22/* This file contains implementation of the predefined data types
23 except PId. The functions defined here can be found in the file
24 sctpred.c.
25*/
26
27/*
28FILE INDEX
2900 Some utility macros
3001 Typedef, Default value, Literals
3102 Prototypes and macros for the operators of the data types
3203 Read and Write functions
3304 Generator String
3405 Generator Array (array that cannot become array in C)
3506 Generator Powerset (limited and discrete component type)
3607 Generator Powerset (general component type)
37*/
38
39/****+***************************************************************
4000 Some utility macros
41********************************************************************/
42
43/* Macros used in the generator implementations */
44
45#ifndef XENUM_TYPE
46#define XENUM_TYPE int
47#endif
48
49#ifndef XNOUSE_OPFUNCS
50#define T_SDL_OPFUNCS(P) , P
51#else
52#define T_SDL_OPFUNCS(P)
53#endif
54
55
56#ifdef XECSOP
57#define xReportStringError(S1,S2) xSDLOpError(S1,S2);
58#else
59#define xReportStringError(S1,S2)
60#endif
61
62
63/****+***************************************************************
6401 Typedef, Default value, Literals
65********************************************************************/
66/****+***************************************************************
67 NEW FOR TAU 4.2
68********************************************************************/
69/*
70FILE INDEX
7101 Assignment macros
7202 SDL predefined data types
7303 Utility functions
7404 Read and Write functions
75*/
76
77#ifndef xOffsetOf
78#define xOffsetOf(type, field) ((xptrint) &((type *) 0)->field)
79#endif
80
81/****+***************************************************************
82 Type info nodes
83********************************************************************/
84/*---+---------------------------------------------------------------
85 Boolean
86-------------------------------------------------------------------*/
87/*xlb20080717
88#if !defined(X_COMPACT_BOOL)
89typedef int SDL_boolean;
90#else
91typedef unsigned char SDL_boolean;
92#endif
93*/
94#define xDef_SDL_Boolean(V) (*(V) = (SDL_Boolean)0)
95#define yDef_SDL_Boolean(V) xDef_SDL_Boolean(V)
96#define yAssF_SDL_Boolean(V,E,A) (V = E)
97#define yEqF_SDL_Boolean(E1,E2) ((E1) == (E2))
98#define yNEqF_SDL_Boolean(E1,E2) ((E1) != (E2))
99#define ySrtN_SDL_Boolean xSrtN_SDL_Boolean
100
101#define SDL_False 0
102#define SDL_false 0
103#define SDL_True 1
104#define SDL_true 1
105
106
107/*---+---------------------------------------------------------------
108 Character
109-------------------------------------------------------------------*/
110
111typedef char SDL_Character;
112typedef char SDL_character;
113
114#define xDef_SDL_Character(V) (*(V) = '\000')
115#define yDef_SDL_Character(V) xDef_SDL_Character(V)
116#define yAssF_SDL_Character(V,E,A) (V = E)
117#define yEqF_SDL_Character(E1,E2) ((E1) == (E2))
118#define yNEqF_SDL_Character(E1,E2) ((E1) != (E2))
119#define ySrtN_SDL_Character xSrtN_SDL_Character
120
121/* predefined literals for non-printable characters,
122 other literals as in C */
123#define SDL_NUL '\000'
124#define SDL_SOH '\001'
125#define SDL_STX '\002'
126#define SDL_ETX '\003'
127#define SDL_EOT '\004'
128#define SDL_ENQ '\005'
129#define SDL_ACK '\006'
130#define SDL_BEL '\007'
131#define SDL_BS '\010'
132#define SDL_HT '\011'
133#define SDL_LF '\012'
134#define SDL_VT '\013'
135#define SDL_FF '\014'
136#define SDL_CR '\015'
137#define SDL_SO '\016'
138#define SDL_SI '\017'
139#define SDL_DLE '\020'
140#define SDL_DC1 '\021'
141#define SDL_DC2 '\022'
142#define SDL_DC3 '\023'
143#define SDL_DC4 '\024'
144#define SDL_NAK '\025'
145#define SDL_SYN '\026'
146#define SDL_ETB '\027'
147#define SDL_CAN '\030'
148#define SDL_EM '\031'
149#define SDL_SUB '\032'
150#define SDL_ESC '\033'
151#define SDL_IS4 '\034'
152#define SDL_IS3 '\035'
153#define SDL_IS2 '\036'
154#define SDL_IS1 '\037'
155#define SDL_DEL '\177'
156#define SDL_E_NUL '\200'
157#define SDL_E_SOH '\201'
158#define SDL_E_STX '\202'
159#define SDL_E_ETX '\203'
160#define SDL_E_EOT '\204'
161#define SDL_E_ENQ '\205'
162#define SDL_E_ACK '\206'
163#define SDL_E_BEL '\207'
164#define SDL_E_BS '\210'
165#define SDL_E_HT '\211'
166#define SDL_E_LF '\212'
167#define SDL_E_VT '\213'
168#define SDL_E_FF '\214'
169#define SDL_E_CR '\215'
170#define SDL_E_SO '\216'
171#define SDL_E_SI '\217'
172#define SDL_E_DLE '\220'
173#define SDL_E_DC1 '\221'
174#define SDL_E_DC2 '\222'
175#define SDL_E_DC3 '\223'
176#define SDL_E_DC4 '\224'
177#define SDL_E_NAK '\225'
178#define SDL_E_SYN '\226'
179#define SDL_E_ETB '\227'
180#define SDL_E_CAN '\230'
181#define SDL_E_EM '\231'
182#define SDL_E_SUB '\232'
183#define SDL_E_ESC '\233'
184#define SDL_E_IS4 '\234'
185#define SDL_E_IS3 '\235'
186#define SDL_E_IS2 '\236'
187#define SDL_E_IS1 '\237'
188
189
190/*---+---------------------------------------------------------------
191 Null
192-------------------------------------------------------------------*/
193
194typedef LONG SDL_Null;
195
196#define xDef_SDL_Null(V) (*(V) = (SDL_Null)0)
197#define yDef_SDL_Null(V) xDef_SDL_Null(V)
198#define yAssF_SDL_Null(V,E,A) (V = E)
199#define yEqF_SDL_Null(E1,E2) ((E1) == (E2))
200#define yNEqF_SDL_Null(E1,E2) ((E1) != (E2))
201#define ySrtN_SDL_Null xSrtN_SDL_Null
202
203#define SDL_NullValue 0
204
205#ifndef ANY_SDL_Null
206#define ANY_SDL_Null (SDL_Null)0
207#endif
208
209
210
211
212/*---+---------------------------------------------------------------
213 Charstring
214-------------------------------------------------------------------*/
215
216typedef CHAR *SDL_Charstring;
217typedef CHAR *SDL_charstring;
218
219
220#define xDef_SDL_Charstring(V) (*(V) = (SDL_Charstring)0)
221#define yDef_SDL_Charstring(V) xDef_SDL_Charstring(V)
222#define yAssF_SDL_Charstring(V,E,A) (V = E)
223#define yEqF_SDL_Charstring(E1,E2) xEq_SDL_Charstring(E1,E2)
224#define yNEqF_SDL_Charstring(E1,E2) (! xEq_SDL_Charstring(E1,E2))
225#define ySrtN_SDL_Charstring xSrtN_SDL_Charstring
226
227#define SDL_CHARSTRING_LIT(P1, P2) P1
228
229
230/*---+---------------------------------------------------------------
231 Duration
232-------------------------------------------------------------------*/
233#if 0
234#ifndef _TIMESPEC_
235#define _TIMESPEC_
236typedef long timespec;
237#endif
238#endif
239//typedef SDL_Duration SDL_duration;
240
241/*Name:KangShuJie Date:2008.01.25 Reason:windows±àÒëÖÐWaringÌ«¶à*/
242#ifdef _OS_WIN
243extern SDL_Duration SDL_Duration_Lit(SINT32 s, SINT32 ns);
244#endif
245/*End KangShuJie*/
246#define xDef_SDL_Duration(V) ( *(V) = 0)
247#define yDef_SDL_Duration(V) xDef_SDL_Duration(V)
248#define yAssF_SDL_Duration(V,E,A) (V = E)
249#define yEqF_SDL_Duration(E1,E2) xEq_SDL_Duration(E1,E2)
250#define yNEqF_SDL_Duration(E1,E2) (! xEq_SDL_Duration(E1,E2))
251#define ySrtN_SDL_Duration xSrtN_SDL_Duration
252
253#define SDL_DURATION_LIT(R,I,D) SDL_Duration_Lit(I,D)
254
255/*Date:2008-2-19 Name: Dongzhi Reason:½«GSMµÄTU¸ÄΪUMTSµÄTU*/
256//xlb20080717#define CLOCK_TICK 10000000
257//#define CLOCK_TICK 4615385 /* TDMA frame duration in ns */
258#define TDMA_CLOCK_TICK 4615385 /* TDMA frame duration in ns */
259#define SDT_TICKPERSEC 217 /* well, actually: 216,66664861111261574061535494872 */
260
261
262/*---+---------------------------------------------------------------
263 Integer
264-------------------------------------------------------------------*/
265
266#if !defined(X_LONG_INT)
267typedef LONG SDL_Integer;
268typedef LONG SDL_integer;
269#else
270typedef LONG SDL_Integer;
271typedef LONG SDL_integer;
272#endif
273
274#define xDef_SDL_Integer(V) (*(V) = (SDL_Integer)0)
275#define yDef_SDL_Integer(V) xDef_SDL_Integer(V)
276#define yAssF_SDL_Integer(V,E,A) (V = E)
277#define yEqF_SDL_Integer(E1,E2) ((E1) == (E2))
278#define yNEqF_SDL_Integer(E1,E2) ((E1) != (E2))
279#define ySrtN_SDL_Integer xSrtN_SDL_Integer
280
281#define SDL_INTEGER_LIT(I) I
282/* Literals as in C */
283
284#ifdef XVALIDATOR
285#define xMax_SDL_Integer 2147483647
286#endif
287
288
289/*---+---------------------------------------------------------------
290 Natural
291-------------------------------------------------------------------*/
292
293#if !defined(X_LONG_INT)
294typedef LONG SDL_Natural;
295typedef LONG SDL_natural;
296#else
297typedef LONG SDL_Natural;
298typedef LONG SDL_natural;
299#endif
300
301#define xDef_SDL_Natural(V) (*(V) = (SDL_Natural)0)
302#define yDef_SDL_Natural(V) xDef_SDL_Natural(V)
303#define yAssF_SDL_Natural(V,E,A) (V = E)
304#define yEqF_SDL_Natural(E1,E2) ((E1) == (E2))
305#define yNEqF_SDL_Natural(E1,E2) ((E1) != (E2))
306#define ySrtN_SDL_Natural xSrtN_SDL_Natural
307
308
309/*---+---------------------------------------------------------------
310 PId
311-------------------------------------------------------------------*/
312
313#define ySrtN_SDL_PId xSrtN_SDL_PId
314/* see sctsdl.c and scttypes.h for implementation of PId */
315
316
317#ifndef XNOUSEOFREAL
318/*---+---------------------------------------------------------------
319 Real
320-------------------------------------------------------------------*/
321
322typedef double SDL_Real;
323typedef double SDL_real;
324
325#define xDef_SDL_Real(V) (*(V) = 0.0)
326#define yDef_SDL_Real(V) xDef_SDL_Real(V)
327#define yAssF_SDL_Real(V,E,A) (V = E)
328#define yEqF_SDL_Real(E1,E2) ((E1) == (E2))
329#define yNEqF_SDL_Real(E1,E2) ((E1) != (E2))
330#define ySrtN_SDL_Real xSrtN_SDL_Real
331
332#define SDL_REAL_LIT(R,I,D) R
333/* Literals as in C */
334#endif
335
336
337/*---+---------------------------------------------------------------
338 Time
339-------------------------------------------------------------------*/
340
341
342//typedef SDL_Time SDL_time;
343
344#define xDef_SDL_Time(V) (*(V) = SDL_Time_Lit(0, 0))
345#define yDef_SDL_Time(V) xDef_SDL_Time(V)
346#define yAssF_SDL_Time(V,E,A) (V = E)
347#define yEqF_SDL_Time(E1,E2) xEq_SDL_Time(E1,E2)
348#define yNEqF_SDL_Time(E1,E2) (! xEq_SDL_Time(E1,E2))
349#define ySrtN_SDL_Time xSrtN_SDL_Time
350
351#define SDL_TIME_LIT(R,I,D) SDL_Duration_Lit(I,D)
352#define SDL_Time_Lit(I,D) SDL_Duration_Lit(I,D)
353
354#ifdef XVALIDATOR
355extern SDL_Time xMaxTime;
356#endif
357
358
359
360
361/*---+---------------------------------------------------------------
362 ASN1 coder and generic data model
363-------------------------------------------------------------------*/
364
365/* These types are used by the generic data model, but also by the SDL
366 encoders/decoders in the old data model */
367
368typedef enum
369{
370 /*SDL - standard types*/
371 type_SDL_Integer=128,
372 type_SDL_Real=129,
373 type_SDL_Natural=130,
374 type_SDL_Boolean=131,
375 type_SDL_Character=132,
376 type_SDL_Time=133,
377 type_SDL_Duration=134,
378 type_SDL_Pid=135,
379 type_SDL_Charstring=136,
380 type_SDL_Bit=137,
381 type_SDL_Bit_string=138,
382 type_SDL_Octet=139,
383 type_SDL_Octet_string=140,
384 type_SDL_IA5String=141,
385 type_SDL_NumericString=142,
386 type_SDL_PrintableString=143,
387 type_SDL_VisibleString=144,
388 type_SDL_NULL=145,
389 type_SDL_Object_identifier=146,
390
391 /* SDL - standard ctypes */
392 type_SDL_ShortInt=150,
393 type_SDL_LongInt=151,
394 type_SDL_UnsignedShortInt=152,
395 type_SDL_UnsignedInt=153,
396 type_SDL_UnsignedLongInt=154,
397 type_SDL_Float=155,
398 type_SDL_Charstar=156,
399 type_SDL_Voidstar=157,
400 type_SDL_Voidstarstar=158,
401
402 /* SDL - user defined types */
403 type_SDL_Syntype=170,
404 type_SDL_Inherits=171,
405 type_SDL_Enum=172,
406 type_SDL_Struct=173,
407 type_SDL_Union=174,
408 type_SDL_UnionC=175,
409 type_SDL_Choice=176,
410 type_SDL_ChoicePresent=177,
411 type_SDL_Powerset=178,
412 type_SDL_GPowerset=179,
413 type_SDL_Bag=180,
414 type_SDL_String=181,
415 type_SDL_LString=182,
416 type_SDL_Array=183,
417 type_SDL_Carray=184,
418 type_SDL_GArray=185,
419 type_SDL_Own=186,
420 type_SDL_Oref=187,
421 type_SDL_Ref=188,
422 type_SDL_Userdef=189,
423 type_SDL_EmptyType=190,
424 type_SDL_ComBuf=191,
425
426 /* SDL - signals */
427 type_SDL_Signal=200,
428 type_SDL_SignalId=201
429
430} tSDLTypeClass;
431
432
433
434
435#ifndef T_CONST
436#define T_CONST const
437#endif
438
439#ifndef T_SDL_EXTRA_COMP
440#define T_SDL_EXTRA_COMP
441#define T_SDL_EXTRA_VALUE
442#endif
443
444#ifndef T_SDL_USERDEF_COMP
445#define T_SDL_USERDEF_COMP
446#endif
447
448#ifdef T_SDL_NAMES
449#define T_SDL_Names(P) , P
450#else
451#define T_SDL_Names(P)
452#endif
453
454#ifdef T_SIGNAL_SDL_NAMES
455#define T_Signal_SDL_Names(P) , P
456#else
457#define T_Signal_SDL_Names(P)
458#endif
459
460#ifdef T_SDL_INFO
461#define T_SDL_Info(P) , P
462#else
463#define T_SDL_Info(P)
464#endif
465
466#define NEEDSFREE(P) (((tSDLTypeInfo *)(P))->OpNeeds & (unsigned char)1)
467#define NEEDSEQUAL(P) (((tSDLTypeInfo *)(P))->OpNeeds & (unsigned char)2)
468#define NEEDSASSIGN(P) (((tSDLTypeInfo *)(P))->OpNeeds & (unsigned char)4)
469
470
471/* Types used to represent a general String and GPowerset. */
472typedef struct xString_ystruct *xString_yptr;
473typedef struct xString_ystruct {
474 xString_yptr Suc;
475 int Data;
476} xString_yrec;
477typedef struct {
478 xString_yptr First;
479 xString_yptr Last;
480 int Length;
481 int IsAssigned;
482} xString_Type;
483
484struct tSDLFuncInfo;
485
486/* ------- General type information for SDL types ------- */
487typedef T_CONST struct tSDLTypeInfoS {
488 tSDLTypeClass TypeClass;
489 unsigned char OpNeeds;
490 xptrint SortSize;
491#ifndef XNOUSE_OPFUNCS
492 struct tSDLFuncInfo *OpFuncs;
493#endif
494 T_SDL_EXTRA_COMP
495#ifdef T_SDL_NAMES
496 char *Name;
497#endif
498#ifdef XREADANDWRITEF
499 xIdNode FatherScope;
500 xSortIdNode SortIdNode;
501#endif
502} tSDLTypeInfo;
503
504
505/* ------------------ Enumeration type ------------------ */
506
507typedef T_CONST struct {
508 int LiteralValue;
509 char *LiteralName;
510} tSDLEnumLiteralInfo;
511
512typedef T_CONST struct tSDLEnumInfoS {
513 tSDLTypeClass TypeClass;
514 unsigned char OpNeeds;
515 xptrint SortSize;
516#ifndef XNOUSE_OPFUNCS
517 struct tSDLFuncInfo *OpFuncs;
518#endif
519 T_SDL_EXTRA_COMP
520#ifdef T_SDL_NAMES
521 char *Name;
522#endif
523#ifdef XREADANDWRITEF
524 xIdNode FatherScope;
525 xSortIdNode SortIdNode;
526#endif
527 tSDLTypeInfo *CompOrFatherSort;
528#ifdef XREADANDWRITEF
529 int NoOfLiterals;
530 tSDLEnumLiteralInfo *LiteralList;
531#endif
532} tSDLEnumInfo;
533
534/* ---------- Syntype, Inherits, Own, Oref, Ref --------- */
535typedef T_CONST struct tSDLGenInfoS {
536 tSDLTypeClass TypeClass;
537 unsigned char OpNeeds;
538 xptrint SortSize;
539 struct tSDLFuncInfo *OpFuncs;
540 T_SDL_EXTRA_COMP
541#ifdef T_SDL_NAMES
542 char *Name;
543#endif
544 tSDLTypeInfo *CompOrFatherSort;
545} tSDLGenInfo;
546
547
548/* ---------------------- Powerset ---------------------- */
549typedef T_CONST struct tSDLPowersetInfoS {
550 tSDLTypeClass TypeClass;
551 unsigned char OpNeeds;
552 xptrint SortSize;
553 struct tSDLFuncInfo *OpFuncs;
554 T_SDL_EXTRA_COMP
555#ifdef T_SDL_NAMES
556 char *Name;
557#endif
558 tSDLTypeInfo *CompSort;
559 int Length;
560 int LowestValue;
561} tSDLPowersetInfo;
562
563
564/* ----------------------- Struct ----------------------- */
565typedef int (*tGetFunc) XPP((void *));
566typedef void (*tAssFunc) XPP((void *, int));
567
568typedef T_CONST struct {
569 xptrint OffsetPresent; /* 0 if not optional */
570 void *DefaultValue;
571} tSDLFieldOptInfo;
572
573typedef T_CONST struct {
574 tGetFunc GetTag;
575 tAssFunc AssTag;
576} tSDLFieldBitFInfo;
577
578
579typedef T_CONST struct {
580 tSDLTypeInfo *CompSort;
581#ifdef T_SDL_NAMES
582 char *Name;
583#endif
584 xptrint Offset; /* ~0 for bitfield */
585 tSDLFieldOptInfo *ExtraInfo;
586} tSDLFieldInfo;
587
588typedef T_CONST struct tSDLStructInfoS {
589 tSDLTypeClass TypeClass;
590 unsigned char OpNeeds;
591 xptrint SortSize;
592 struct tSDLFuncInfo *OpFuncs;
593 T_SDL_EXTRA_COMP
594#ifdef T_SDL_NAMES
595 char *Name;
596#endif
597 tSDLFieldInfo *Components;
598 int NumOfComponents;
599} tSDLStructInfo;
600
601
602/* -------------------- Choice, Union ------------------- */
603typedef T_CONST struct {
604 tSDLTypeInfo *CompSort;
605#ifdef T_SDL_NAMES
606 char *Name;
607#endif
608} tSDLChoiceFieldInfo;
609
610typedef T_CONST struct tSDLChoiceInfoS {
611 tSDLTypeClass TypeClass;
612 unsigned char OpNeeds;
613 xptrint SortSize;
614 struct tSDLFuncInfo *OpFuncs;
615 T_SDL_EXTRA_COMP
616#ifdef T_SDL_NAMES
617 char *Name;
618#endif
619 tSDLChoiceFieldInfo *Components;
620 int NumOfComponents;
621 xptrint OffsetToUnion;
622 xptrint TagSortSize;
623} tSDLChoiceInfo;
624
625
626/* ------------------- Array, CArray -------------------- */
627typedef T_CONST struct tSDLArrayInfoS {
628 tSDLTypeClass TypeClass;
629 unsigned char OpNeeds;
630 xptrint SortSize;
631 struct tSDLFuncInfo *OpFuncs;
632 T_SDL_EXTRA_COMP
633#ifdef T_SDL_NAMES
634 char *Name;
635#endif
636 tSDLTypeInfo *CompSort;
637 int Length;
638} tSDLArrayInfo;
639
640
641/* ----------------------- GArray ----------------------- */
642typedef T_CONST struct tSDLGArrayInfoS {
643 tSDLTypeClass TypeClass;
644 unsigned char OpNeeds;
645 xptrint SortSize;
646 struct tSDLFuncInfo *OpFuncs;
647 T_SDL_EXTRA_COMP
648#ifdef T_SDL_NAMES
649 char *Name;
650#endif
651 tSDLTypeInfo *IndexSort;
652 tSDLTypeInfo *CompSort;
653 xptrint yrecSize;
654 xptrint yrecIndexOffset;
655 xptrint yrecDataOffset;
656 xptrint arrayDataOffset;
657} tSDLGArrayInfo;
658
659
660/* ----- GPowerset, Bag, String, Object_Identifier ------ */
661typedef T_CONST struct tSDLGenListInfoS {
662 tSDLTypeClass TypeClass;
663 unsigned char OpNeeds;
664 xptrint SortSize;
665 struct tSDLFuncInfo *OpFuncs;
666 T_SDL_EXTRA_COMP
667#ifdef T_SDL_NAMES
668 char *Name;
669#endif
670 tSDLTypeInfo *CompSort;
671 xptrint yrecSize;
672 xptrint yrecDataOffset;
673} tSDLGenListInfo;
674
675
676/* ---------------------- LString ----------------------- */
677typedef T_CONST struct tSDLLStringInfoS {
678 tSDLTypeClass TypeClass;
679 unsigned char OpNeeds;
680 xptrint SortSize;
681 struct tSDLFuncInfo *OpFuncs;
682 T_SDL_EXTRA_COMP
683#ifdef T_SDL_NAMES
684 char *Name;
685#endif
686 tSDLTypeInfo *CompSort;
687 int MaxLength;
688 xptrint DataOffset;
689} tSDLLStringInfo;
690
691
692/* ---------------------- Userdef ----------------------- */
693/* used for user defined types #ADT(T(h)) */
694typedef T_CONST struct tSDLUserdefInfoS {
695 tSDLTypeClass TypeClass;
696 unsigned char OpNeeds;
697 xptrint SortSize;
698 struct tSDLFuncInfo *OpFuncs;
699 T_SDL_EXTRA_COMP
700#ifdef T_SDL_NAMES
701 char *Name;
702#endif
703 T_SDL_USERDEF_COMP
704} tSDLUserdefInfo;
705
706
707/* ----------------------- Signal ----------------------- */
708typedef T_CONST struct {
709 tSDLTypeInfo *ParaSort;
710 xptrint Offset;
711} tSDLSignalParaInfo;
712
713typedef T_CONST struct tSDLSignalInfoS {
714 tSDLTypeClass TypeClass;
715 unsigned char OpNeeds;
716 xptrint SortSize;
717 struct tSDLFuncInfo *OpFuncs;
718 T_SDL_EXTRA_COMP
719#ifdef T_SIGNAL_SDL_NAMES
720 char *Name;
721#endif
722 tSDLSignalParaInfo *Param;
723 int NoOfPara;
724} tSDLSignalInfo;
725
726typedef struct tSDLFuncInfo {
727 void *(*AssFunc) XPP((void *, void *, int));
728 SDL_Boolean (*EqFunc) XPP((void *, void *));
729 void (*FreeFunc) XPP((void **));
730} tSDLFuncInfo;
731
732
733/* Types used to represent a general Bag. */
734typedef struct xBag_ystruct *xBag_yptr;
735typedef struct xBag_ystruct {
736 xBag_yptr Suc;
737 int NoOfItems;
738 int Data;
739} xBag_yrec;
740typedef struct {
741 xBag_yptr First;
742 xBag_yptr Last;
743 int Length;
744 int IsAssigned;
745} xBag_Type;
746
747
748extern tSDLTypeInfo ySDL_SDL_Integer;
749extern tSDLTypeInfo ySDL_SDL_Real;
750extern tSDLTypeInfo ySDL_SDL_Natural;
751extern tSDLTypeInfo ySDL_SDL_Boolean;
752extern tSDLTypeInfo ySDL_SDL_Character;
753extern tSDLTypeInfo ySDL_SDL_Time;
754extern tSDLTypeInfo ySDL_SDL_Duration;
755extern tSDLTypeInfo ySDL_SDL_PId;
756extern tSDLTypeInfo ySDL_SDL_Charstring;
757extern tSDLTypeInfo ySDL_SDL_Bit;
758extern tSDLTypeInfo ySDL_SDL_Bit_String;
759extern tSDLTypeInfo ySDL_SDL_Octet;
760extern tSDLTypeInfo ySDL_SDL_Octet_String;
761extern tSDLTypeInfo ySDL_SDL_IA5String;
762extern tSDLTypeInfo ySDL_SDL_NumericString;
763extern tSDLTypeInfo ySDL_SDL_PrintableString;
764extern tSDLTypeInfo ySDL_SDL_VisibleString;
765extern tSDLTypeInfo ySDL_SDL_Null;
766extern tSDLGenListInfo ySDL_SDL_Object_Identifier;
767
768/* End section with type info nodes */
769
770extern LONG GenericGetValue XPP((DWORD, VOID *));
771extern VOID GenericSetValue XPP((DWORD, VOID *, LONG));
772
773
774/****+***************************************************************
77501
776********************************************************************/
777
778/* Macros used in assign functions */
779
780/* XASS_1_2_3 should be read:
7811 = AC : always copy
7821 = MR : may reuse (take pointer if temporary object)
7831 = AR : always reuse (take pointer)
7842 = ASS : new object assigned to "variable"
7852 = TMP : new object temporary
7863 = FR : call free for old value refered to by variable
7873 = NF : do not call free for old value
788*/
789#define XASS_AC_ASS_FR (int)25 /* 1+8+16 */
790#define XASS_MR_ASS_FR (int)26 /* 2+8+16 */ /* = XASS */
791#define XASS_AR_ASS_FR (int)28 /* 4+8+16 */
792
793#define XASS_AC_TMP_FR (int)17 /* 1+0+16 */
794#define XASS_MR_TMP_FR (int)18 /* 2+0+16 */ /* = XASSMAKE */
795#define XASS_AR_TMP_FR (int)20 /* 4+0+16 */
796
797#define XASS_AC_ASS_NF (int)9 /* 1+8+0 */
798#define XASS_MR_ASS_NF (int)10 /* 2+8+0 */
799#define XASS_AR_ASS_NF (int)12 /* 4+8+0 */
800
801#define XASS_AC_TMP_NF (int)1 /* 1+0+0 */ /* = XASS2MAKE */
802#define XASS_MR_TMP_NF (int)2 /* 2+0+0 */ /* = XASSMAKE */
803#define XASS_AR_TMP_NF (int)4 /* 4+0+0 */
804
805#define SHOULD_COPY(P) (P & (int)1)
806#define MAY_REUSE(P) (P & (int)2)
807#define SHOULD_REUSE(P) (P & (int)4)
808#define SHOULD_RESULT_BE_ASS(P) (P & (int)8)
809#define SHOULD_FREE_OLD(P) (P & (int)16)
810
811#define SET_ASS_NF(P) ((P & (int)15) | (int)8)
812#define SET_NF(P) (P & (int)15)
813
814
815
816/*---+---------------------------------------------------------------
817 Bit
818-------------------------------------------------------------------*/
819
820typedef BYTE SDL_Bit;
821
822#define yAssF_SDL_Bit(V,E,A) (V = E)
823#define yEqF_SDL_Bit(E1,E2) ((E1) == (E2))
824#define yNEqF_SDL_Bit(E1,E2) ((E1) != (E2))
825#define ySrtN_SDL_Bit xSrtN_SDL_Bit
826
827#define SDL_BIT_LIT(I) I
828
829#define xNot_SDL_Bit(B) (!(B))
830#define xAnd_SDL_Bit(B1,B2) ((B1)&(B2))
831#define xOr_SDL_Bit(B1,B2) ((B1)|(B2))
832#define xXor_SDL_Bit(B1,B2) ((B1)^(B2))
833#define xImpl_SDL_Bit(B1,B2) ((B1)<=(B2))
834
835#ifndef ANY_SDL_Bit
836#define ANY_SDL_Bit (SDL_Bit)(GETINTRAND % 2)
837#endif
838
839
840/*---+---------------------------------------------------------------
841 Octet
842-------------------------------------------------------------------*/
843
844typedef BYTE SDL_Octet;
845
846#define xDef_SDL_Octet(V) (*(V) = (SDL_Octet)0)
847#define yAssF_SDL_Octet(V,E,A) (V = E)
848#define yEqF_SDL_Octet(E1,E2) ((E1) == (E2))
849#define yNEqF_SDL_Octet(E1,E2) ((E1) != (E2))
850#define ySrtN_SDL_Octet xSrtN_SDL_Octet
851
852extern SDL_Bit *yAddr_SDL_Octet XPP((SDL_Octet *, SDL_Integer));
853extern SDL_Bit xExtr_SDL_Octet XPP((SDL_Octet, SDL_Integer));
854
855#define xLT_SDL_Octet(B1,B2) ((B1)<(B2))
856#define xLE_SDL_Octet(B1,B2) ((B1)<=(B2))
857#define xGT_SDL_Octet(B1,B2) ((B1)>(B2))
858#define xGE_SDL_Octet(B1,B2) ((B1)>=(B2))
859
860#define xNot_SDL_Octet(B) (SDL_Octet)(~(B))
861#define xAnd_SDL_Octet(B1,B2) ((B1)&(B2))
862#define xOr_SDL_Octet(B1,B2) ((B1)|(B2))
863#define xXor_SDL_Octet(B1,B2) ((B1)^(B2))
864#define xImpl_SDL_Octet(B1,B2) xNot_SDL_Octet(xAnd_SDL_Octet((B1),xNot_SDL_Octet(B2)))
865#define xShiftL_SDL_Octet(B,I) (SDL_Octet)(((B)<<(I)) & 0xFF)
866#define xShiftR_SDL_Octet(B,I) ((B)>>(I))
867#define xPlus_SDL_Octet(B1,B2) (SDL_Octet)(((B1)+(B2)) & 0xFF)
868#define xMinus_SDL_Octet(B1,B2) (SDL_Octet)((B1)-(B2))
869#define xMult_SDL_Octet(B1,B2) (SDL_Octet)(((B1)*(B2)) & 0xFF)
870#define xI2O_SDL_Octet(I) (SDL_Octet)(I)
871#define xO2I_SDL_Octet(B) (SDL_Integer)(B)
872
873#ifndef XEINTDIV
874#define xDiv_SDL_Octet(B1,B2) ((B1)/(B2))
875#define xMod_SDL_Octet(B1,B2) ((B1)%(B2))
876#define xRem_SDL_Octet(B1,B2) ((B1)%(B2))
877#else
878extern SDL_Octet xDiv_SDL_Octet XPP((SDL_Octet, SDL_Octet));
879extern SDL_Octet xMod_SDL_Octet XPP((SDL_Octet, SDL_Octet));
880extern SDL_Octet xRem_SDL_Octet XPP((SDL_Octet, SDL_Octet));
881#endif
882
883extern SDL_Octet xBitStr_SDL_Octet XPP((SDL_Charstring));
884extern SDL_Octet xHexStr_SDL_Octet XPP((SDL_Charstring));
885
886#ifndef ANY_SDL_Octet
887#define ANY_SDL_Octet (SDL_Octet)(GETINTRAND % 256)
888#endif
889
890
891
892#ifndef XNOUSEOFOCTETBITSTRING
893/*---+---------------------------------------------------------------
894 Bit_String
895-------------------------------------------------------------------*/
896
897typedef struct {
898 int Length;
899 xbool IsAssigned;
900 unsigned char * Bits;
901} SDL_Bit_String;
902
903#define xDef_SDL_Bit_String(V) \
904 {(*V).Length = 0; (*V).IsAssigned = (xbool)1; (*V).Bits = 0;}
905#define yDef_SDL_Bit_String(V) xDef_SDL_Bit_String(V)
906#define yAssF_SDL_Bit_String(V,E,A) xAss_SDL_Bit_String(&(V),E,A)
907#define yEqF_SDL_Bit_String(E1,E2) xEq_SDL_Bit_String(E1,E2)
908#define yNEqF_SDL_Bit_String(E1,E2) (! xEq_SDL_Bit_String(E1,E2))
909#define ySrtN_SDL_Bit_String xSrtN_SDL_Bit_String
910
911#define yFree_SDL_Bit_String(P) xFree_SDL_Bit_String(P)
912extern void xAss_SDL_Bit_String XPP((SDL_Bit_String *, SDL_Bit_String, int));
913extern SDL_Boolean xEq_SDL_Bit_String XPP((SDL_Bit_String, SDL_Bit_String));
914extern void xFree_SDL_Bit_String XPP((void **));
915extern SDL_Bit * yAddr_SDL_Bit_String XPP((SDL_Bit_String *, SDL_Integer));
916extern SDL_Bit xExtr_SDL_Bit_String XPP((SDL_Bit_String, SDL_Integer));
917extern SDL_Bit_String xNot_SDL_Bit_String XPP((SDL_Bit_String));
918extern SDL_Bit_String xAnd_SDL_Bit_String XPP((SDL_Bit_String, SDL_Bit_String));
919extern SDL_Bit_String xOr_SDL_Bit_String XPP((SDL_Bit_String, SDL_Bit_String));
920extern SDL_Bit_String xXor_SDL_Bit_String XPP((SDL_Bit_String, SDL_Bit_String));
921extern SDL_Bit_String xImpl_SDL_Bit_String XPP((SDL_Bit_String, SDL_Bit_String));
922extern SDL_Bit_String xMkString_SDL_Bit_String XPP((SDL_Bit));
923extern SDL_Integer xLength_SDL_Bit_String XPP((SDL_Bit_String));
924extern SDL_Bit xFirst_SDL_Bit_String XPP((SDL_Bit_String));
925extern SDL_Bit xLast_SDL_Bit_String XPP((SDL_Bit_String));
926extern SDL_Bit_String xConcat_SDL_Bit_String XPP((SDL_Bit_String, SDL_Bit_String));
927extern SDL_Bit_String xSubString_SDL_Bit_String XPP((SDL_Bit_String, SDL_Integer, SDL_Integer));
928extern SDL_Bit_String xBitStr_SDL_Bit_String XPP((SDL_Charstring));
929
930SDL_Bit_String xHexStr_SDL_Bit_String XPP((SDL_Charstring));
931
932
933
934#ifndef ANY_SDL_Bit_String
935#define ANY_SDL_Bit_String \
936 xConcat_SDL_Bit_String \
937 (xMkString_SDL_Bit_String(((unsigned char)(GETINTRAND%2))), \
938 xMkString_SDL_Bit_String(((unsigned char)(GETINTRAND%2))) \
939 )
940#endif
941
942#endif /* XNOUSEOFOCTETBITSTRING */
943
944
945#ifndef XNOUSEOFOCTETBITSTRING
946/*---+---------------------------------------------------------------
947 Octet_String
948-------------------------------------------------------------------*/
949
950/* An error in the implementation of Octet_String was introduced
951 in SDT 3.2, when Octet_String was first supported.
952 Octet_Strings should be indexed from 1, not from 0 as the
953 SDL Suite implementation assumes. Note that Bit_Strings are indexed
954 from 0. The inconsistancy between Octet_Strings and Bit_Strings
955 in SDL is inherited from ASN.1.
956 In SDT 3.6 this indexing error for Octet_Strings is corrected.
957 To obtain the Octet_String behaviour from SDT3.2 - SDT3.5,
958 OCTET_STRING_START_INDEX_0 should be defined, for example by
959 uncommenting the #define below. It is not necessary to recompile
960 the kernel for this to take effect.
961 This change will effect the behaviour of indexing of
962 Octet_Strings and the start parameter in operator SubString.
963*/
964/* #define OCTET_STRING_START_INDEX_0 */
965
966typedef SDL_Bit_String SDL_Octet_String;
967
968#define xDef_SDL_Octet_String(V) \
969 {(*V).Length = 0; (*V).IsAssigned = (xbool)1; (*V).Bits = 0;}
970#define yDef_SDL_Octet_String(V) xDef_SDL_Octet_String(V)
971#define yAssF_SDL_Octet_String(V,E,A) xAss_SDL_Bit_String(&(V),E,A)
972#define yEqF_SDL_Octet_String(E1,E2) xEq_SDL_Bit_String(E1,E2)
973#define yNEqF_SDL_Octet_String(E1,E2) (! xEq_SDL_Bit_String(E1,E2))
974#define ySrtN_SDL_Octet_String xSrtN_SDL_Octet_String
975
976#define yFree_SDL_Octet_String(P) xFree_SDL_Bit_String(P)
977#define xFree_SDL_Octet_String(P) xFree_SDL_Bit_String(P)
978#define xAss_SDL_Octet_String(V,E,A) xAss_SDL_Bit_String(V,E,A)
979#define xEq_SDL_Octet_String(V,E,A) xEq_SDL_Bit_String(V,E,A)
980#ifdef OCTET_STRING_START_INDEX_0
981#define yAddr_SDL_Octet_String(B1,B2) yAddr_SDL_Bit_String(B1,B2)
982#define xExtr_SDL_Octet_String(B1,B2) xExtr_SDL_Bit_String(B1,B2)
983#else
984#define yAddr_SDL_Octet_String(B1,B2) yAddr_SDL_Bit_String(B1,B2-1)
985#define xExtr_SDL_Octet_String(B1,B2) xExtr_SDL_Bit_String(B1,B2-1)
986#endif
987#define xMkString_SDL_Octet_String(B) xMkString_SDL_Bit_String(B)
988#define xLength_SDL_Octet_String(B) xLength_SDL_Bit_String(B)
989#define xFirst_SDL_Octet_String(B) xFirst_SDL_Bit_String(B)
990#define xLast_SDL_Octet_String(B) xLast_SDL_Bit_String(B)
991#define xConcat_SDL_Octet_String(B1,B2) xConcat_SDL_Bit_String(B1,B2)
992#ifdef OCTET_STRING_START_INDEX_0
993#define xSubString_SDL_Octet_String(B1,B2,B3) xSubString_SDL_Bit_String(B1,B2,B3)
994#else
995#define xSubString_SDL_Octet_String(B1,B2,B3) xSubString_SDL_Bit_String(B1,B2-1,B3)
996#endif
997extern SDL_Octet_String xBitStr_SDL_Octet_String XPP((SDL_Charstring));
998extern SDL_Octet_String xHexStr_SDL_Octet_String XPP((SDL_Charstring));
999extern SDL_Bit_String xBit_String_SDL_Octet_String XPP((SDL_Octet_String));
1000extern SDL_Octet_String xOctet_String_SDL_Octet_String XPP((SDL_Bit_String));
1001
1002#ifndef ANY_SDL_Octet_String
1003#define ANY_SDL_Octet_String \
1004 xConcat_SDL_Octet_String \
1005 (xMkString_SDL_Octet_String(((unsigned char)(GETINTRAND%256))), \
1006 xMkString_SDL_Octet_String(((unsigned char)(GETINTRAND%256))) \
1007 )
1008#endif
1009
1010#endif /* XNOUSEOFOCTETBITSTRING */
1011
1012
1013
1014/*---+---------------------------------------------------------------
1015 Object_Identifier
1016-------------------------------------------------------------------*/
1017
1018typedef struct SDL_Object_Identifier_ystruct *SDL_Object_Identifier_yptr;
1019typedef struct SDL_Object_Identifier_ystruct {
1020 SDL_Object_Identifier_yptr Suc;
1021 SDL_Natural Data;
1022} SDL_Object_Identifier_yrec;
1023typedef struct {
1024 SDL_Object_Identifier_yptr First;
1025 SDL_Object_Identifier_yptr Last;
1026 int Length;
1027 int IsAssigned;
1028} SDL_Object_Identifier;
1029
1030#define xDef_SDL_Object_Identifier(V) \
1031 {(*V).First = 0; (*V).Last = 0; (*V).Length = 0; (*V).IsAssigned = (xbool)1;}
1032#define yDef_SDL_Object_Identifier(V) xDef_SDL_Object_Identifier(V)
1033#define yAssF_SDL_Object_Identifier(V,E,A) yAss_SDL_Object_Identifier(&(V),E,A)
1034#define yEqF_SDL_Object_Identifier(E1,E2) yEq_SDL_Object_Identifier(E1,E2)
1035#define yNEqF_SDL_Object_Identifier(E1,E2) (! yEq_SDL_Object_Identifier(E1,E2))
1036#define ySrtN_SDL_Object_Identifier xSrtN_SDL_Object_Identifier
1037
1038extern SDL_Object_Identifier yEmptystring_SDL_Object_Identifier XPP((void));
1039extern SDL_Object_Identifier yMkString_SDL_Object_Identifier XPP((SDL_Natural));
1040extern SDL_Integer yLength_SDL_Object_Identifier XPP((SDL_Object_Identifier));
1041extern SDL_Natural yFirst_SDL_Object_Identifier XPP((SDL_Object_Identifier));
1042extern SDL_Natural yLast_SDL_Object_Identifier XPP((SDL_Object_Identifier));
1043extern SDL_Object_Identifier yConcat_SDL_Object_Identifier
1044 XPP((SDL_Object_Identifier, SDL_Object_Identifier));
1045extern SDL_Object_Identifier ySubString_SDL_Object_Identifier
1046 XPP((SDL_Object_Identifier, SDL_Integer, SDL_Integer));
1047extern SDL_Natural yExtr_SDL_Object_Identifier
1048 XPP((SDL_Object_Identifier, SDL_Integer));
1049extern SDL_Natural *yAddr_SDL_Object_Identifier
1050 XPP((SDL_Object_Identifier *, SDL_Integer));
1051
1052extern void yAss_SDL_Object_Identifier
1053 XPP((SDL_Object_Identifier *, SDL_Object_Identifier, int));
1054extern SDL_Boolean yEq_SDL_Object_Identifier
1055 XPP((SDL_Object_Identifier, SDL_Object_Identifier));
1056extern void yFree_SDL_Object_Identifier XPP((void **));
1057
1058#ifndef ANY_SDL_Object_Identifier
1059#define ANY_SDL_Object_Identifier \
1060 yConcat_SDL_Object_Identifier(yMkString_SDL_Object_Identifier(ANY_SDL_Natural), \
1061 yMkString_SDL_Object_Identifier(ANY_SDL_Natural))
1062#endif
1063
1064
1065/*---+---------------------------------------------------------------
1066 GenericAssignSort
1067-------------------------------------------------------------------*/
1068
1069extern void GenericFreeSort XPP((void **, tSDLTypeInfo *));
1070extern SDL_Boolean GenericEqualSort XPP((void *, void *, tSDLTypeInfo *));
1071extern VOID * GenericAssignSort XPP((VOID *, VOID *, LONG, tSDLTypeInfo *));
1072// #define GenericAssignSort(Addr,Expr,AssName,dummy) *(Addr) = *(Expr)
1073
1074
1075
1076
1077
1078
1079
1080
1081/****+***************************************************************
108202 Prototypes and macros for the operators of the data types
1083********************************************************************/
1084
1085/*---+---------------------------------------------------------------
1086 yInit_Predefined
1087-------------------------------------------------------------------*/
1088
1089#ifndef XOPTSORT
1090extern void yInit_Predefined XPP((void));
1091#endif
1092
1093
1094/*---+---------------------------------------------------------------
1095 Boolean
1096-------------------------------------------------------------------*/
1097
1098#define xNot_SDL_Boolean(B) (!(B))
1099#define xAnd_SDL_Boolean(B1,B2) ((B1)&&(B2))
1100#define xOr_SDL_Boolean(B1,B2) ((B1)||(B2))
1101#define xXor_SDL_Boolean(B1,B2) ((B1)!=(B2))
1102#define xImpl_SDL_Boolean(B1,B2) ((B1)<=(B2))
1103#define ANY_SDL_Boolean (SDL_Boolean)(GETINTRAND % 2)
1104
1105/*---+---------------------------------------------------------------
1106 Character
1107-------------------------------------------------------------------*/
1108
1109#define xLT_SDL_Character(C1,C2) ((C1)<(C2))
1110#define xLE_SDL_Character(C1,C2) ((C1)<=(C2))
1111#define xGT_SDL_Character(C1,C2) ((C1)>(C2))
1112#define xGE_SDL_Character(C1,C2) ((C1)>=(C2))
1113#define xChr_SDL_Character(I) ((SDL_Character)xMod_SDL_Integer(I,128))
1114#define xNum_SDL_Character(C) ((SDL_Integer)C)
1115#define ANY_SDL_Character xChr_SDL_Character(GETINTRAND)
1116
1117
1118/*---+---------------------------------------------------------------
1119 Charstring
1120-------------------------------------------------------------------*/
1121
1122/*-- yFree_SDL_Charstring -----------------------------------------*/
1123#define yFree_SDL_Charstring(P) xFree_SDL_Charstring(P)
1124extern void xFree_SDL_Charstring XPP((void **));
1125/* function in sctos.c */
1126
1127/*-- xAss_SDL_Charstring ------------------------------------------*/
1128extern void xAss_SDL_Charstring XPP((
1129 SDL_Charstring *CVar,
1130 SDL_Charstring CExpr,
1131 int AssType ));
1132
1133/*-- xEq_SDL_Charstring -------------------------------------------*/
1134extern SDL_Boolean xEq_SDL_Charstring XPP((
1135 SDL_Charstring C1,
1136 SDL_Charstring C2 ));
1137
1138/*-- xMod_SDL_Charstring ------------------------------------------*/
1139/* No longer used by generated code */
1140extern SDL_Charstring xMod_SDL_Charstring XPP((
1141 SDL_Charstring C,
1142 SDL_Integer Index,
1143 SDL_Character Value ));
1144
1145/*-- yAddr_SDL_Charstring ------------------------------------------*/
1146extern SDL_Character * yAddr_SDL_Charstring XPP((
1147 SDL_Charstring *C,
1148 SDL_Integer Index ));
1149
1150/*-- xExtr_SDL_Charstring -----------------------------------------*/
1151extern SDL_Character xExtr_SDL_Charstring XPP((
1152 SDL_Charstring C,
1153 SDL_Integer Index ));
1154
1155/*-- xMkString_SDL_Charstring -------------------------------------*/
1156extern SDL_Charstring xMkString_SDL_Charstring XPP((
1157 SDL_Character C ));
1158
1159/*-- xLength_SDL_Charstring ---------------------------------------*/
1160extern SDL_Integer xLength_SDL_Charstring XPP((
1161 SDL_Charstring C ));
1162
1163/*-- xFirst_SDL_Charstring ----------------------------------------*/
1164extern SDL_Character xFirst_SDL_Charstring XPP((
1165 SDL_Charstring C ));
1166
1167/*-- xLast_SDL_Charstring -----------------------------------------*/
1168extern SDL_Character xLast_SDL_Charstring XPP((
1169 SDL_Charstring C ));
1170
1171/*-- xConcat_SDL_Charstring ---------------------------------------*/
1172extern SDL_Charstring xConcat_SDL_Charstring XPP((
1173 SDL_Charstring C1,
1174 SDL_Charstring C2 ));
1175
1176/*-- xSubString_SDL_Charstring ------------------------------------*/
1177extern SDL_Charstring xSubString_SDL_Charstring XPP((
1178 SDL_Charstring C,
1179 SDL_Integer Start,
1180 SDL_Integer SubLength ));
1181
1182#define ANY_SDL_Charstring \
1183 xConcat_SDL_Charstring \
1184 (xMkString_SDL_Charstring( ((SDL_Character)(1+GETINTRAND%127)) ), \
1185 xMkString_SDL_Charstring( ((SDL_Character)(1+GETINTRAND%127)) ) \
1186 )
1187
1188
1189/*---+---------------------------------------------------------------
1190 Duration
1191-------------------------------------------------------------------*/
1192
1193/*-- xPlus_SDL_Duration -------------------------------------------*/
1194
1195#define xPlus_SDL_Duration(D1,D2) ((D1) + (D2))
1196
1197/*-- xMinus_SDL_Duration ------------------------------------------*/
1198
1199#define xMinus_SDL_Duration(D1,D2) ((D1) - (D2))
1200
1201/*-- xMonMinus_SDL_Duration ---------------------------------------*/
1202
1203#define xMonMinus_SDL_Duration(D) (-(D))
1204
1205/*-- xMult_SDL_Duration -------------------------------------------*/
1206#ifndef XNOUSEOFREAL
1207extern SDL_Duration xMult_SDL_Duration XPP((
1208 SDL_Duration D,
1209 SDL_Real R ));
1210#endif
1211
1212/*-- xMultRD_SDL_Duration -----------------------------------------*/
1213#define xMultRD_SDL_Duration(R,D) xMult_SDL_Duration(D, R)
1214
1215/*-- xDiv_SDL_Duration --------------------------------------------*/
1216#ifndef XNOUSEOFREAL
1217extern SDL_Duration xDiv_SDL_Duration XPP((
1218 SDL_Duration D,
1219 SDL_Real R ));
1220#endif
1221
1222#define xGT_SDL_Duration(P1, P2) xLT_SDL_Time(P2, P1)
1223#define xGE_SDL_Duration(P1, P2) xLE_SDL_Time(P2, P1)
1224#define xLT_SDL_Duration(P1, P2) xLT_SDL_Time(P1, P2)
1225#define xLE_SDL_Duration(P1, P2) xLE_SDL_Time(P1, P2)
1226
1227/*-- xEq_SDL_Duration ---------------------------------------------*/
1228
1229#define xEq_SDL_Duration(D1,D2) ((D1) == (D2))
1230
1231#define ANY_SDL_Duration \
1232 SDL_Duration_Lit(GETINTRAND, GETINTRAND % 1000000000)
1233
1234
1235/*---+---------------------------------------------------------------
1236 Integer
1237-------------------------------------------------------------------*/
1238
1239#define xMonMinus_SDL_Integer(I) (-(I))
1240#define xPlus_SDL_Integer(I1,I2) ((I1)+(I2))
1241#define xMinus_SDL_Integer(I1,I2) ((I1)-(I2))
1242#define xMult_SDL_Integer(I1,I2) ((I1)*(I2))
1243
1244/*-- xDiv_SDL_Integer ---------------------------------------------*/
1245#ifdef XEINTDIV
1246extern SDL_Integer xDiv_SDL_Integer XPP((
1247 SDL_Integer i,
1248 SDL_Integer k ));
1249#else
1250#define xDiv_SDL_Integer(i,k) ((i)/(k))
1251#endif
1252
1253/*-- xMod_SDL_Integer ---------------------------------------------*/
1254#define xMod_SDL_Integer(i_, k_) ((i_) % (k_))
1255
1256
1257/*-- xRem_SDL_Integer ---------------------------------------------*/
1258#ifdef XEINTDIV
1259extern SDL_Integer xRem_SDL_Integer XPP((
1260 SDL_Integer i,
1261 SDL_Integer k ));
1262#else
1263#define xRem_SDL_Integer(i,k) ((i)%(k))
1264#endif
1265
1266#define xLT_SDL_Integer(I1,I2) ((I1)<(I2))
1267#define xLE_SDL_Integer(I1,I2) ((I1)<=(I2))
1268#define xGT_SDL_Integer(I1,I2) ((I1)>(I2))
1269#define xGE_SDL_Integer(I1,I2) ((I1)>=(I2))
1270
1271/*-- xFix_SDL_Integer ---------------------------------------------*/
1272#ifdef XEFIXOF
1273extern SDL_Integer xFix_SDL_Integer XPP((
1274 SDL_Real Re ));
1275#else
1276#define xFix_SDL_Integer(Re) ((SDL_Integer)Re)
1277#endif
1278
1279/* -- xFloat_SDL_Integer ------------------------------------------*/
1280#ifndef XNOUSEOFREAL
1281#define xFloat_SDL_Integer(I) ((SDL_Real)I)
1282#endif
1283
1284#define ANY_SDL_Integer (SDL_Integer)(GETINTRAND - GETINTRAND_MAX/2)
1285
1286
1287/*---+---------------------------------------------------------------
1288 Natural
1289-------------------------------------------------------------------*/
1290
1291/*-- xTest_SDL_Natural --------------------------------------------*/
1292#ifdef XTESTF
1293extern xbool xTest_SDL_Natural XPP((
1294 void * N ));
1295#endif
1296
1297/*-- xTstA_SDL_Natural --------------------------------------------*/
1298#ifdef XERANGE
1299extern SDL_Natural xTstA_SDL_Natural XPP(( SDL_Natural N ));
1300#define yTstA_SDL_Natural(N) xTstA_SDL_Natural(N)
1301#else
1302#define xTstA_SDL_Natural(N) N
1303#define yTstA_SDL_Natural(N) N
1304#endif
1305
1306/*-- xTstI_SDL_Natural --------------------------------------------*/
1307#ifdef XEINDEX
1308extern SDL_Natural xTstI_SDL_Natural XPP(( SDL_Natural N ));
1309#define yTstI_SDL_Natural(N) xTstI_SDL_Natural(N)
1310#else
1311#define xTstI_SDL_Natural(N) N
1312#define yTstI_SDL_Natural(N) N
1313#endif
1314
1315#define ANY_SDL_Natural (SDL_Natural)(GETINTRAND)
1316
1317
1318/*---+---------------------------------------------------------------
1319 PId
1320-------------------------------------------------------------------*/
1321
1322#define ANY_SDL_PId SDL_NULL
1323
1324
1325/*---+---------------------------------------------------------------
1326 Real
1327-------------------------------------------------------------------*/
1328
1329#define xMonMinus_SDL_Real(R) (-(R))
1330#define xPlus_SDL_Real(R1,R2) ((R1)+(R2))
1331#define xMinus_SDL_Real(R1,R2) ((R1)-(R2))
1332#define xMult_SDL_Real(R1,R2) ((R1)*(R2))
1333
1334/*-- xDiv_SDL_Real ------------------------------------------------*/
1335#ifndef XNOUSEOFREAL
1336#ifdef XEREALDIV
1337extern SDL_Real xDiv_SDL_Real XPP((
1338 SDL_Real i,
1339 SDL_Real k ));
1340#else
1341#define xDiv_SDL_Real(i,k) ((i)/(k))
1342#endif
1343#endif
1344
1345#define xLT_SDL_Real(R1,R2) ((R1)<(R2))
1346#define xLE_SDL_Real(R1,R2) ((R1)<=(R2))
1347#define xGT_SDL_Real(R1,R2) ((R1)>(R2))
1348#define xGE_SDL_Real(R1,R2) ((R1)>=(R2))
1349
1350#define ANY_SDL_Real (SDL_Real)(GETINTRAND - GETINTRAND_MAX/2)
1351
1352
1353/*---+---------------------------------------------------------------
1354 Time
1355-------------------------------------------------------------------*/
1356
1357/*-- xPlus_SDL_Time -----------------------------------------------*/
1358#define xPlus_SDL_Time(P1, P2) ((P1) + (P2))
1359
1360/*-- xPlusDT_SDL_Time ---------------------------------------------*/
1361#define xPlusDT_SDL_Time(P1, P2) ((P1) + (P2))
1362
1363/*-- xMinusD_SDL_Time ---------------------------------------------*/
1364#define xMinusD_SDL_Time(P1, P2) ((P1) - (P2))
1365
1366/*-- xMinusT_SDL_Time ---------------------------------------------*/
1367#define xMinusT_SDL_Time(P1, P2) ((P1) - (P2))
1368
1369/*-- xEq_SDL_Time -------------------------------------------------*/
1370#define xEq_SDL_Time(P1, P2) ((P1) == (P2))
1371
1372/*-- xLT_SDL_Time -------------------------------------------------*/
1373#define xLT_SDL_Time(T1, T2) ((T1) < (T2))
1374
1375/*-- xLE_SDL_Time -------------------------------------------------*/
1376#define xLE_SDL_Time(T1, T2) ((T1) <= (T2))
1377
1378/*-- xGT_SDL_Time -------------------------------------------------*/
1379#define xGT_SDL_Time(P1, P2) ((P1) > (P2))
1380
1381/*-- xGE_SDL_Time -------------------------------------------------*/
1382#define xGE_SDL_Time(P1, P2) ((P1) >= (P2))
1383
1384#define ANY_SDL_Time \
1385 SDL_Time_Lit(GETINTRAND, GETINTRAND % 1000000000)
1386
1387
1388/****+***************************************************************
138903 Read and Write functions
1390********************************************************************/
1391#ifdef XREADANDWRITEF
1392
1393/*-- xRead_SDL_Boolean --------------------------------------------*/
1394#define xRead_SDL_Boolean(Addr) xReadSort(Addr, xSrtN_SDL_Boolean)
1395
1396/*-- xWri_SDL_Boolean ---------------------------------------------*/
1397#define xWri_SDL_Boolean(Value) xWriteSort(Value, xSrtN_SDL_Boolean)
1398
1399/*-- xRead_SDL_Character ------------------------------------------*/
1400extern int xRead_SDL_Character XPP((void *));
1401
1402/*-- xWri_SDL_Character -------------------------------------------*/
1403extern char * xWri_SDL_Character XPP((void *));
1404
1405/*-- xRead_SDL_Charstring -----------------------------------------*/
1406extern int xRead_SDL_Charstring XPP((void *));
1407
1408/*-- xWri_SDL_Charstring ------------------------------------------*/
1409extern char * xWri_SDL_Charstring XPP((void *));
1410
1411/*-- xRead_SDL_Duration -------------------------------------------*/
1412extern int xRead_SDL_Duration XPP((void *));
1413
1414/*-- xWri_SDL_Duration --------------------------------------------*/
1415extern char * xWri_SDL_Duration XPP((void *));
1416
1417/*-- xRead_SDL_Integer --------------------------------------------*/
1418extern int xRead_SDL_Integer XPP((void *));
1419
1420/*-- xWri_SDL_Integer ---------------------------------------------*/
1421extern char * xWri_SDL_Integer XPP((void *));
1422
1423/*-- xRead_SDL_Real -----------------------------------------------*/
1424extern int xRead_SDL_Real XPP((void *));
1425
1426/*-- xWri_SDL_Real ------------------------------------------------*/
1427extern char * xWri_SDL_Real XPP((void *));
1428
1429/*-- xRead_SDL_Time -----------------------------------------------*/
1430extern int xRead_SDL_Time XPP((void *));
1431
1432/*-- xWri_SDL_Time ------------------------------------------------*/
1433extern char * xWri_SDL_Time XPP((void *));
1434
1435
1436
1437/* Help functions, also used by sctutil.c and sctmon.c */
1438/*-- xReadSDL_Time ------------------------------------------------*/
1439extern int xReadSDL_Time XPP((SDL_Time *));
1440
1441/*-- xWriteSDL_Time -----------------------------------------------*/
1442extern char * xWriteSDL_Time XPP((SDL_Time, int));
1443
1444
1445#endif
1446 /* XREADANDWRITEF */
1447
1448
1449
1450#ifndef XNO_LONG_MACROS
1451
1452/****+***************************************************************
145304 Generator String
1454********************************************************************/
1455
1456/* typedef for String type ----------------------------------------*/
1457
1458#define String_Type(SORT, COMPONENTSORT) \
1459 typedef struct XCAT(SORT,_ystruct) * XCAT(SORT,_yptr); \
1460 typedef struct XCAT(SORT,_ystruct) { \
1461 XCAT(SORT,_yptr) Suc; \
1462 COMPONENTSORT Data; \
1463 } XCAT(SORT,_yrec); \
1464 typedef struct { \
1465 XCAT(SORT,_yptr) First; \
1466 XCAT(SORT,_yptr) Last; \
1467 int Length; \
1468 xbool IsAssigned; \
1469 } SORT;
1470
1471
1472/* String operator prototypes -------------------------------------*/
1473
1474#define String_prototypes(SORT, COMPONENTSORT) \
1475 extern SORT XCAT(yEmptystring_,SORT) XPP((void)); \
1476 extern SORT XCAT(yMkString_,SORT) XPP((COMPONENTSORT)); \
1477 extern SDL_Integer XCAT(yLength_,SORT) XPP((SORT)); \
1478 extern COMPONENTSORT XCAT(yFirst_,SORT) XPP((SORT)); \
1479 extern COMPONENTSORT XCAT(yLast_,SORT) XPP((SORT)); \
1480 extern SORT XCAT(yConcat_,SORT) XPP((SORT, SORT)); \
1481 extern SORT XCAT(ySubString_,SORT) \
1482 XPP((SORT, SDL_Integer, SDL_Integer)); \
1483 extern COMPONENTSORT XCAT(yExtr_,SORT) XPP((SORT, SDL_Integer)); \
1484 extern COMPONENTSORT *XCAT(yAddr_,SORT) XPP((SORT *, SDL_Integer)); \
1485 \
1486 extern XCAT(SORT,_yptr) XCAT(yGetAvail_,SORT) XPP((void)); \
1487 extern void XCAT(yAppend_,SORT) XPP((SORT *result, SORT S)); \
1488 \
1489 extern char * XCAT(yWri_,SORT) XPP((void * S)); \
1490 extern int XCAT(yRead_,SORT) XPP((void * Result));
1491
1492
1493
1494/* String operator implementations --------------------------------*/
1495
1496/*-- yEmptystring_SORT (String)------------------------------------*/
1497#define String_Emptystring(SORT, COMPONENTSORT) \
1498 extern SORT XCAT(yEmptystring_,SORT) XPP((void)) \
1499 { \
1500 SORT Result; \
1501 Result.First = (XCAT(SORT,_yptr))0; \
1502 Result.Last = (XCAT(SORT,_yptr))0; \
1503 Result.Length = 0; \
1504 Result.IsAssigned = (xbool)0; \
1505 return Result; \
1506 }
1507
1508
1509/*-- yMkString_SORT (String)---------------------------------------*/
1510#define String_MkString(SORT, COMPONENTSORT) \
1511 extern XCAT(SORT,_yptr) XCAT(yGetAvail_,SORT) XPP((void)) \
1512 { \
1513 XCAT(SORT,_yptr) Item; \
1514 if (XCAT(yAvail_,SORT) != (XCAT(SORT,_yptr))0) { \
1515 Item = XCAT(yAvail_,SORT); \
1516 XCAT(yAvail_,SORT) = XCAT(yAvail_,SORT)->Suc; \
1517 } else { \
1518 Item = (XCAT(SORT,_yptr))xAlloc((unsigned)sizeof(XCAT(SORT,_yrec))); \
1519 } \
1520 Item->Suc = (XCAT(SORT,_yptr))0; \
1521 XCAT(yDef_,COMPONENTSORT)(&Item->Data); \
1522 return Item; \
1523 } \
1524 \
1525 extern SORT XCAT(yMkString_,SORT) \
1526 XPP_PROTO( (COMPONENTSORT Component) ) \
1527 XPP_NOPROTO( (Component) COMPONENTSORT Component; ) \
1528 { \
1529 SORT Result; \
1530 Result.First = XCAT(yGetAvail_,SORT)(); \
1531 Result.Last = Result.First; \
1532 Result.Length = 1; \
1533 Result.IsAssigned = (xbool)0; \
1534 XCAT(yAssF_,COMPONENTSORT)(Result.First->Data, Component, XASS); \
1535 return Result; \
1536 }
1537
1538
1539/*-- yLength_SORT (String)-----------------------------------------*/
1540#define String_Length(SORT, COMPONENTSORT) \
1541 extern SDL_Integer XCAT(yLength_,SORT) \
1542 XPP_PROTO( (SORT S) ) \
1543 XPP_NOPROTO( (S) SORT S; ) \
1544 { \
1545 if (! S.IsAssigned && S.First != (XCAT(SORT,_yptr))0) { \
1546 XCAT(yFree_,SORT)((void **)&S); \
1547 } \
1548 return S.Length; \
1549 }
1550
1551/*-- yFirst_SORT (String)------------------------------------------*/
1552#define String_First(SORT, COMPONENTSORT) \
1553 extern COMPONENTSORT XCAT(yFirst_,SORT) \
1554 XPP_PROTO( (SORT S) ) \
1555 XPP_NOPROTO( (S) SORT S; ) \
1556 { \
1557 COMPONENTSORT Result; \
1558 if (S.Length > 0) { \
1559 Result = S.First->Data; \
1560 if (! S.IsAssigned) { \
1561 XCAT(yFree_,SORT)((void **)&S); \
1562 } \
1563 } else { \
1564 xReportStringError("First in String sort", "Length is zero") \
1565 (void)memset((void *)(&Result), 0, sizeof(COMPONENTSORT)); \
1566 XCAT(yDef_,COMPONENTSORT)(&Result); \
1567 } \
1568 return Result; \
1569 }
1570
1571
1572/*-- yLast_SORT (String)-------------------------------------------*/
1573#define String_Last(SORT, COMPONENTSORT) \
1574 extern COMPONENTSORT XCAT(yLast_,SORT) \
1575 XPP_PROTO( (SORT S) ) \
1576 XPP_NOPROTO( (S) SORT S; ) \
1577 { \
1578 COMPONENTSORT Result; \
1579 if (S.Length > 0) { \
1580 Result = S.Last->Data; \
1581 if (! S.IsAssigned) { \
1582 XCAT(yFree_,SORT)((void **)&S); \
1583 } \
1584 } else { \
1585 xReportStringError("Last in String sort", "Length is zero") \
1586 (void)memset((void *)(&Result), 0, sizeof(COMPONENTSORT)); \
1587 XCAT(yDef_,COMPONENTSORT)(&Result); \
1588 } \
1589 return Result; \
1590 }
1591
1592
1593/*-- yConcat_SORT (String)-----------------------------------------*/
1594#define String_Concat(SORT, COMPONENTSORT) \
1595 extern void XCAT(yAppend_,SORT) \
1596 XPP_PROTO( (SORT *result, SORT S) ) \
1597 XPP_NOPROTO( (result, S) SORT *result; SORT S; ) \
1598 { \
1599 XCAT(SORT,_yptr) TempSVar, TempExpr; \
1600 \
1601 (*result).Length = (*result).Length + S.Length; \
1602 if (S.IsAssigned) { \
1603 TempExpr = S.First; \
1604 TempSVar = XCAT(yGetAvail_,SORT)(); \
1605 if ((*result).First == (XCAT(SORT,_yptr))0) \
1606 (*result).First = TempSVar; \
1607 else \
1608 (*result).Last->Suc = TempSVar; \
1609 XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
1610 \
1611 while (TempExpr->Suc != (XCAT(SORT,_yptr))0) { \
1612 TempExpr = TempExpr->Suc; \
1613 TempSVar->Suc = XCAT(yGetAvail_,SORT)(); \
1614 TempSVar = TempSVar->Suc; \
1615 XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
1616 } \
1617 (*result).Last = TempSVar; \
1618 } else { \
1619 if ((*result).First == (XCAT(SORT,_yptr))0) \
1620 (*result).First = S.First; \
1621 else \
1622 (*result).Last->Suc = S.First; \
1623 (*result).Last = S.Last; \
1624 } \
1625 } \
1626 \
1627 \
1628 extern SORT XCAT(yConcat_,SORT) \
1629 XPP_PROTO( (SORT S1, SORT S2) ) \
1630 XPP_NOPROTO( (S1, S2) SORT S1; SORT S2; ) \
1631 { \
1632 SORT result; \
1633 \
1634 result.First = (XCAT(SORT,_yptr))0; \
1635 result.Last = (XCAT(SORT,_yptr))0; \
1636 result.Length = 0; \
1637 result.IsAssigned = (xbool)0; \
1638 if (S1.Length == 0) { \
1639 if (S2.Length == 0) \
1640 return result; \
1641 else if (! S2.IsAssigned) \
1642 return S2; \
1643 else { \
1644 XCAT(yAppend_,SORT)(&result, S2); \
1645 } \
1646 } else if (S2.Length == 0) { \
1647 if (! S1.IsAssigned) \
1648 return S1; \
1649 else { \
1650 XCAT(yAppend_,SORT)(&result, S1); \
1651 } \
1652 } else { \
1653 XCAT(yAppend_,SORT)(&result, S1); \
1654 XCAT(yAppend_,SORT)(&result, S2); \
1655 } \
1656 \
1657 return result; \
1658 }
1659
1660
1661/*-- ySubstring_SORT (String)--------------------------------------*/
1662#define String_Substring(SORT, COMPONENTSORT) \
1663 extern SORT XCAT(ySubString_,SORT) \
1664 XPP_PROTO( (SORT S, SDL_Integer Start, SDL_Integer SubLength) ) \
1665 XPP_NOPROTO( (S, Start, SubLength) SORT S; SDL_Integer Start; SDL_Integer SubLength; ) \
1666 { \
1667 SORT result; \
1668 XCAT(SORT,_yptr) TempSVar, TempExpr; \
1669 int I; \
1670 \
1671 result.First = (XCAT(SORT,_yptr))0; \
1672 result.Last = (XCAT(SORT,_yptr))0; \
1673 result.Length = 0; \
1674 result.IsAssigned = (xbool)0; \
1675 if ( S.Length <= 0 ) { \
1676 xReportStringError("SubString in string sort", "Length is zero" ) \
1677 } else if ( Start <= 0 ) { \
1678 xReportStringError("SubString in string sort", \
1679 "Start is less than or equal to zero" ) \
1680 } else if ( SubLength <= 0 ) { \
1681 xReportStringError("SubString in string sort", \
1682 "SubLength is less than or equal to zero" ) \
1683 } else if ( Start+SubLength-1 > S.Length ) { \
1684 xReportStringError("SubString in string sort", \
1685 "Start+Substring-1 length is greater than string length" ) \
1686 } else { \
1687 TempExpr = S.First; \
1688 for (I=1; I<Start; I++) TempExpr = TempExpr->Suc; \
1689 TempSVar = XCAT(yGetAvail_,SORT)(); \
1690 result.First = TempSVar; \
1691 XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
1692 \
1693 for (I=2; I<=SubLength; I++) { \
1694 TempExpr = TempExpr->Suc; \
1695 TempSVar->Suc = XCAT(yGetAvail_,SORT)(); \
1696 TempSVar = TempSVar->Suc; \
1697 XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
1698 } \
1699 result.Last = TempSVar; \
1700 result.Length = SubLength; \
1701 } \
1702 if (! S.IsAssigned && S.First != (XCAT(SORT,_yptr))0) { \
1703 XCAT(yFree_,SORT)((void **)&S); \
1704 } \
1705 return result; \
1706 }
1707
1708
1709
1710/*-- yModify_SORT (String)-----------------------------------------*/
1711#define String_Modify(SORT, COMPONENTSORT) \
1712 extern COMPONENTSORT *XCAT(yAddr_,SORT) \
1713 XPP_PROTO( (SORT *S, SDL_Integer Index) ) \
1714 XPP_NOPROTO( (S, Index) SORT *S; SDL_Integer Index; ) \
1715 { \
1716 COMPONENTSORT *result; \
1717 XCAT(SORT,_yptr) Temp; \
1718 if ((*S).Length == 0) { \
1719 xReportStringError("Modify of component of string sort", \
1720 "String is empty. Returns default value" ) \
1721 result = (COMPONENTSORT *)xAlloc((xptrint)sizeof(COMPONENTSORT)); \
1722 XCAT(yDef_,COMPONENTSORT)(result); \
1723 return result; \
1724 } else { \
1725 if (Index > (*S).Length) { \
1726 xReportStringError("Modify of component of string sort", \
1727 "Index > string length. Index set to 1" ) \
1728 Index = 1; \
1729 } \
1730 if (Index <= (SDL_Integer)0) { \
1731 xReportStringError("Modify of component of string sort", \
1732 "Index <= 0. Index set to 1" ) \
1733 Index = 1; \
1734 } \
1735 Temp = (*S).First; \
1736 for (; Index>1; Index--) Temp = Temp->Suc; \
1737 if (! (*S).IsAssigned && (*S).First != (XCAT(SORT,_yptr))0) { \
1738 XCAT(yFree_,SORT)((void **)S); \
1739 } \
1740 return &Temp->Data; \
1741 } \
1742 }
1743
1744
1745/*-- yExtr_SORT (String)--------------------------------------------*/
1746#define String_Extract(SORT, COMPONENTSORT) \
1747 extern COMPONENTSORT XCAT(yExtr_,SORT) \
1748 XPP_PROTO( (SORT S, SDL_Integer Index) ) \
1749 XPP_NOPROTO( (S, Index) SORT S; SDL_Integer Index; ) \
1750 { \
1751 COMPONENTSORT result; \
1752 XCAT(SORT,_yptr) Temp; \
1753 if (S.Length == 0) { \
1754 xReportStringError("Extract in string sort", \
1755 "String is empty. Returns default value" ) \
1756 (void)memset((void *)(&result), 0, sizeof(COMPONENTSORT)); \
1757 XCAT(yDef_,COMPONENTSORT)(&result); \
1758 return result; \
1759 } else { \
1760 if (Index > S.Length) { \
1761 xReportStringError("Extract in string sort", \
1762 "Index > string length. Index set to 1" ) \
1763 Index = 1; \
1764 } \
1765 if (Index <= (SDL_Integer)0) { \
1766 xReportStringError("Extract in string sort", \
1767 "Index <= 0. Index set to 1" ) \
1768 Index = 1; \
1769 } \
1770 Temp = S.First; \
1771 for (; Index>1; Index--) Temp = Temp->Suc; \
1772 if (! S.IsAssigned && S.First != (XCAT(SORT,_yptr))0) { \
1773 XCAT(yFree_,SORT)((void **)&S); \
1774 } \
1775 return Temp->Data; \
1776 } \
1777 }
1778
1779
1780/*-- yAss_SORT (String)--------------------------------------------*/
1781#define String_Assign(SORT, COMPONENTSORT) \
1782 static XCAT(SORT,_yptr) XCAT(yAvail_,SORT) = (XCAT(SORT,_yptr))0; \
1783 extern void XCAT(yAss_,SORT) \
1784 XPP_PROTO( (SORT * SVar, SORT SExpr, int AssType) ) \
1785 XPP_NOPROTO( (SVar, SExpr, AssType) SORT * SVar; SORT SExpr; int AssType; ) \
1786 { \
1787 XCAT(SORT,_yptr) TempSVar, TempExpr; \
1788 \
1789 if ((*SVar).First == SExpr.First) \
1790 return; \
1791 if (AssType == XASS && (*SVar).First != (XCAT(SORT,_yptr))0) { \
1792 XCAT(yFree_,SORT)((void **)SVar); \
1793 } \
1794 if ( (SExpr.IsAssigned || AssType == XASS2MAKE) && \
1795 SExpr.First != (XCAT(SORT,_yptr))0) { \
1796 TempExpr = SExpr.First; \
1797 TempSVar = XCAT(yGetAvail_,SORT)(); \
1798 (*SVar).First = TempSVar; \
1799 XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
1800 \
1801 TempExpr = TempExpr->Suc; \
1802 while (TempExpr != (XCAT(SORT,_yptr))0) { \
1803 TempSVar->Suc = XCAT(yGetAvail_,SORT)(); \
1804 TempSVar = TempSVar->Suc; \
1805 XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
1806 TempExpr = TempExpr->Suc; \
1807 } \
1808 (*SVar).Last = TempSVar; \
1809 } else { \
1810 (*SVar).First = SExpr.First; \
1811 (*SVar).Last = SExpr.Last; \
1812 } \
1813 (*SVar).Length = SExpr.Length; \
1814 (*SVar).IsAssigned = (xbool)1; \
1815 }
1816
1817
1818/*-- yEq_SORT (String)---------------------------------------------*/
1819#define String_Equal(SORT, COMPONENTSORT) \
1820 extern SDL_Boolean XCAT(yEq_,SORT) \
1821 XPP_PROTO( (SORT Expr1, SORT Expr2) ) \
1822 XPP_NOPROTO( (Expr1, Expr2) SORT Expr1; SORT Expr2; ) \
1823 { \
1824 XCAT(SORT,_yptr) Temp1, Temp2; \
1825 SDL_Boolean Result; \
1826 \
1827 Result = SDL_True; \
1828 if (Expr1.Length != Expr2.Length) \
1829 Result = SDL_False; \
1830 Temp1 = Expr1.First; \
1831 Temp2 = Expr2.First; \
1832 while (Result && Temp1 != (XCAT(SORT,_yptr))0) { \
1833 if (XCAT(yNEqF_,COMPONENTSORT)(Temp1->Data, Temp2->Data) ) \
1834 Result = SDL_False; \
1835 Temp1 = Temp1->Suc; \
1836 Temp2 = Temp2->Suc; \
1837 } \
1838 if (! Expr1.IsAssigned && Expr1.First != (XCAT(SORT,_yptr))0) { \
1839 XCAT(yFree_,SORT)((void **)&Expr1); \
1840 } \
1841 if (! Expr2.IsAssigned && Expr2.First != (XCAT(SORT,_yptr))0) { \
1842 XCAT(yFree_,SORT)((void **)&Expr2); \
1843 } \
1844 return Result; \
1845 }
1846
1847/*-- yDef_SORT (String)--------------------------------------------*/
1848#define String_Default(SORT, COMPONENTSORT) \
1849 extern void XCAT(yDef_,SORT) \
1850 XPP_PROTO( (SORT *S) ) \
1851 XPP_NOPROTO( (S) SORT *S; ) \
1852 { \
1853 (*S).First = (XCAT(SORT,_yptr))0; \
1854 (*S).Last = (XCAT(SORT,_yptr))0; \
1855 (*S).Length = 0; \
1856 (*S).IsAssigned = (xbool)1; \
1857 }
1858
1859
1860/*-- yFree_SORT (String)-------------------------------------------*/
1861#ifdef XFREEFUNCS
1862#define String_Free(SORT, COMPONENTSORT, HASCOMPFREE) \
1863 extern void XCAT(yFree_,SORT) \
1864 XPP_PROTO( (void ** C) ) \
1865 XPP_NOPROTO( (C) void ** C; ) \
1866 { \
1867 XCAT(SORT,_yptr) Temp; \
1868 if (HASCOMPFREE) { \
1869 for (Temp = (*(SORT *)C).First; \
1870 Temp != (XCAT(SORT,_yptr))0; \
1871 Temp = Temp->Suc) { \
1872 XCAT(yFree_,COMPONENTSORT)((void **)&Temp->Data); \
1873 } \
1874 } \
1875 if ((*(SORT *)C).First != (XCAT(SORT,_yptr))0) { \
1876 (*(SORT *)C).Last->Suc = XCAT(yAvail_,SORT); \
1877 XCAT(yAvail_,SORT) = (*(SORT *)C).First; \
1878 } \
1879 }
1880#else
1881#define String_Free(SORT, COMPONENTSORT, HASCOMPFREE) \
1882 extern void XCAT(yFree_,SORT) \
1883 XPP_PROTO( (void ** C) ) \
1884 XPP_NOPROTO( (C) void ** C; ) \
1885 { \
1886 if ((*(SORT *)C).First != (XCAT(SORT,_yptr))0) { \
1887 (*(SORT *)C).Last->Suc = XCAT(yAvail_,SORT); \
1888 XCAT(yAvail_,SORT) = (*(SORT *)C).First; \
1889 } \
1890 }
1891#endif
1892
1893
1894/*-- yWri_SORT (String)-------------------------------------------*/
1895#define String_Write(SORT, COMPONENTSORT) \
1896 extern char * XCAT(yWri_,SORT) \
1897 XPP_PROTO( (void * S) ) \
1898 XPP_NOPROTO( (S) void * S; ) \
1899 { \
1900 XCAT(SORT,_yptr) Temp, TempLast; \
1901 static char CTemp[MAX_WRI_LENGTH]; \
1902 \
1903 strcpy(CTemp, "(. "); \
1904 TempLast = (*(SORT *)S).Last; \
1905 for (Temp = (*(SORT *)S).First; \
1906 Temp != (XCAT(SORT,_yptr))0; \
1907 Temp = Temp->Suc) { \
1908 xSafeStrcat(CTemp, \
1909 xWriteSort((void *)(&Temp->Data), XCAT(ySrtN_,COMPONENTSORT))); \
1910 if (strlen(CTemp) == MAX_WRI_LENGTH - 1) \
1911 return CTemp; \
1912 if (Temp != TempLast) \
1913 xSafeStrcat(CTemp, ", "); \
1914 } \
1915 xSafeStrcat(CTemp, " .)"); \
1916 return CTemp; \
1917 }
1918
1919
1920/*-- yRead_SORT (String)------------------------------------------*/
1921#define String_Read(SORT, COMPONENTSORT) \
1922 extern int XCAT(yRead_,SORT) \
1923 XPP_PROTO( (void * Result) ) \
1924 XPP_NOPROTO( (Result) void * Result; ) \
1925 { \
1926 COMPONENTSORT Item; \
1927 xxToken Token; \
1928 char strVar[256]; \
1929 int Res; \
1930 \
1931 (*(SORT *)Result).First = (XCAT(SORT,_yptr))0; \
1932 (*(SORT *)Result).Last = (XCAT(SORT,_yptr))0; \
1933 (*(SORT *)Result).Length = 0; \
1934 (*(SORT *)Result).IsAssigned = (int)0; \
1935 Token = xScanToken(strVar); \
1936 if (Token != xxLParDot && Token != xxQuestionMark && Token != xxEoln) { \
1937 xPrintString("String value should start with (.\n"); \
1938 return 0; \
1939 } \
1940 if (Token != xxLParDot) xUngetToken(Token, strVar); \
1941 \
1942 while (Token != xxRParDot) { \
1943 sprintf(strVar, " (%s) : ", XCAT(ySrtN_,COMPONENTSORT)->Name); \
1944 (void)memset((void *)(&Item), 0, sizeof(COMPONENTSORT)); \
1945 Res = xReadOneParameter(XCAT(ySrtN_,COMPONENTSORT), strVar, (void *)&Item); \
1946 if (Res == 0) return 0; \
1947 if (Res == 2) { \
1948 Token = xScanToken(strVar); \
1949 if (Token == xxRParDot) break; \
1950 return 0; \
1951 } \
1952 XCAT(yAppend_,SORT)((SORT *)Result, XCAT(yMkString_,SORT)(Item)); \
1953 Token = xScanToken(strVar); \
1954 if (Token != xxRParDot) xUngetToken(Token, strVar); \
1955 } \
1956 (*(SORT *)Result).IsAssigned = (int)1; \
1957 return 1; \
1958 }
1959
1960/****+***************************************************************
196105 Generator Array (array that cannot become array in C)
1962********************************************************************/
1963
1964/* typedef for Array type -----------------------------------------*/
1965
1966#define Array_Type(SORT, INDEXSORT, COMPONENTSORT) \
1967 typedef struct XCAT(SORT,_ystruct) * XCAT(SORT,_yptr); \
1968 typedef struct XCAT(SORT,_ystruct) { \
1969 XCAT(SORT,_yptr) Suc; \
1970 INDEXSORT Index; \
1971 COMPONENTSORT Data; \
1972 } XCAT(SORT,_yrec); \
1973 typedef struct { \
1974 XCAT(SORT,_yptr) First; \
1975 XCAT(SORT,_yptr) Last; \
1976 xbool IsAssigned; \
1977 COMPONENTSORT Data; \
1978 } SORT;
1979
1980
1981/* Array operator prototypes --------------------------------------*/
1982
1983#define Array_prototypes(SORT, INDEXSORT, COMPONENTSORT) \
1984 extern SORT XCAT(yMake_,SORT) XPP((COMPONENTSORT)); \
1985 extern COMPONENTSORT XCAT(yExtr_,SORT) XPP((SORT, INDEXSORT)); \
1986 extern COMPONENTSORT *XCAT(yAddr_,SORT) XPP((SORT *, INDEXSORT)); \
1987 \
1988 extern XCAT(SORT,_yptr) XCAT(yGetAvail_,SORT) XPP((void)); \
1989 extern COMPONENTSORT XCAT(yExtrInner_,SORT) \
1990 XPP((SORT S, INDEXSORT Index)); \
1991 \
1992 extern char * XCAT(yWri_,SORT) XPP((void * S)); \
1993 extern int XCAT(yRead_,SORT) XPP((void * Result));
1994
1995
1996/* Array operator implementations ---------------------------------*/
1997
1998/*-- yMake_SORT (Array)--------------------------------------------*/
1999#define Array_Make(SORT, INDEXSORT, COMPONENTSORT) \
2000 extern SORT XCAT(yMake_,SORT) \
2001 XPP_PROTO( (COMPONENTSORT Component) ) \
2002 XPP_NOPROTO( (Component) COMPONENTSORT Component; ) \
2003 { \
2004 SORT Result; \
2005 Result.First = (XCAT(SORT,_yptr))0; \
2006 Result.Last = (XCAT(SORT,_yptr))0; \
2007 Result.IsAssigned = (xbool)0; \
2008 XCAT(yAssF_,COMPONENTSORT)(Result.Data, Component, XASSMAKE); \
2009 return Result; \
2010 }
2011
2012
2013/*-- yModify_SORT (Array)------------------------------------------*/
2014#define Array_Modify(SORT, INDEXSORT, COMPONENTSORT) \
2015 extern XCAT(SORT,_yptr) XCAT(yGetAvail_,SORT) XPP((void)) \
2016 { \
2017 XCAT(SORT,_yptr) Item; \
2018 if (XCAT(yAvail_,SORT) != (XCAT(SORT,_yptr))0) { \
2019 Item = XCAT(yAvail_,SORT); \
2020 XCAT(yAvail_,SORT) = XCAT(yAvail_,SORT)->Suc; \
2021 } else { \
2022 Item = (XCAT(SORT,_yptr))xAlloc((unsigned)sizeof(XCAT(SORT,_yrec))); \
2023 } \
2024 Item->Suc = (XCAT(SORT,_yptr))0; \
2025 return Item; \
2026 } \
2027 \
2028 extern COMPONENTSORT *XCAT(yAddr_,SORT) \
2029 XPP_PROTO( (SORT *S, INDEXSORT Index) ) \
2030 XPP_NOPROTO( (S, Index) SORT *S; INDEXSORT Index; ) \
2031 { \
2032 XCAT(SORT,_yptr) Temp; \
2033 Temp = (*S).First; \
2034 while ( Temp != (XCAT(SORT,_yptr))0 && \
2035 XCAT(yNEqF_,INDEXSORT)(Temp->Index, Index) ) \
2036 Temp = Temp->Suc; \
2037 if (Temp != (XCAT(SORT,_yptr))0) \
2038 return &Temp->Data; \
2039 if ((*S).First == (XCAT(SORT,_yptr))0) { \
2040 (*S).First = XCAT(yGetAvail_,SORT)(); \
2041 (*S).Last = (*S).First; \
2042 } else { \
2043 (*S).Last->Suc = XCAT(yGetAvail_,SORT)(); \
2044 (*S).Last = (*S).Last->Suc; \
2045 } \
2046 XCAT(yAssF_,INDEXSORT)((*S).Last->Index, Index, XASS); \
2047 XCAT(yAssF_,COMPONENTSORT)((*S).Last->Data, (*S).Data, XASS); \
2048 return &(*S).Last->Data; \
2049 }
2050
2051
2052/*-- yExtr_SORT (Array)---------------------------------------------*/
2053#define Array_Extract(SORT, INDEXSORT, COMPONENTSORT) \
2054 \
2055 extern COMPONENTSORT XCAT(yExtrInner_,SORT) \
2056 XPP_PROTO( (SORT S, INDEXSORT Index) ) \
2057 XPP_NOPROTO( (S, Index) SORT S; INDEXSORT Index; ) \
2058 { \
2059 XCAT(SORT,_yptr) Temp; \
2060 Temp = S.First; \
2061 while ( Temp != (XCAT(SORT,_yptr))0 && \
2062 XCAT(yNEqF_,INDEXSORT)(Temp->Index, Index) ) \
2063 Temp = Temp->Suc; \
2064 if (Temp != (XCAT(SORT,_yptr))0) \
2065 return Temp->Data; \
2066 else \
2067 return S.Data; \
2068 } \
2069 \
2070 extern COMPONENTSORT XCAT(yExtr_,SORT) \
2071 XPP_PROTO( (SORT S, INDEXSORT Index) ) \
2072 XPP_NOPROTO( (S, Index) SORT S; INDEXSORT Index; ) \
2073 { \
2074 COMPONENTSORT result; \
2075 result = XCAT(yExtrInner_,SORT)(S, Index); \
2076 if (! S.IsAssigned && S.First != (XCAT(SORT,_yptr))0) \
2077 XCAT(yFree_,SORT)((void **)&S); \
2078 return result; \
2079 }
2080
2081
2082/*-- yAss_SORT (Array)---------------------------------------------*/
2083#define Array_Assign(SORT, INDEXSORT, COMPONENTSORT) \
2084 static XCAT(SORT,_yptr) XCAT(yAvail_,SORT) = (XCAT(SORT,_yptr))0; \
2085 extern void XCAT(yAss_,SORT) \
2086 XPP_PROTO( (SORT * SVar, SORT SExpr, int AssType) ) \
2087 XPP_NOPROTO( (SVar, SExpr, AssType) SORT * SVar; SORT SExpr; int AssType; ) \
2088 { \
2089 XCAT(SORT,_yptr) TempSVar, TempExpr, PrevExpr; \
2090 \
2091 if ((*SVar).First != SExpr.First) {\
2092 if (AssType == XASS && (*SVar).First != (XCAT(SORT,_yptr))0) \
2093 XCAT(yFree_,SORT)((void **)SVar); \
2094 if ( (SExpr.IsAssigned || AssType == XASS2MAKE) && \
2095 SExpr.First != (XCAT(SORT,_yptr))0) { \
2096 TempExpr = SExpr.First; \
2097 TempSVar = XCAT(yGetAvail_,SORT)(); \
2098 (*SVar).First = TempSVar; \
2099 XCAT(yAssF_,INDEXSORT)(TempSVar->Index, TempExpr->Index, XASS); \
2100 XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
2101 \
2102 TempExpr = TempExpr->Suc; \
2103 while (TempExpr != (XCAT(SORT,_yptr))0) { \
2104 TempSVar->Suc = XCAT(yGetAvail_,SORT)(); \
2105 TempSVar = TempSVar->Suc; \
2106 XCAT(yAssF_,INDEXSORT)(TempSVar->Index, TempExpr->Index, XASS); \
2107 XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
2108 TempExpr = TempExpr->Suc; \
2109 } \
2110 (*SVar).Last = TempSVar; \
2111 } else { \
2112 (*SVar).First = SExpr.First; \
2113 (*SVar).Last = SExpr.Last; \
2114 } \
2115 } \
2116 XCAT(yAssF_,COMPONENTSORT)((*SVar).Data, SExpr.Data, XASS); \
2117 (*SVar).IsAssigned = (xbool)1; \
2118 \
2119 PrevExpr = (*SVar).First; \
2120 while ( PrevExpr != (XCAT(SORT,_yptr))0 && \
2121 XCAT(yEqF_,COMPONENTSORT)(PrevExpr->Data, (*SVar).Data) ) { \
2122 (*SVar).First = PrevExpr->Suc; \
2123 PrevExpr->Suc = XCAT(yAvail_,SORT); \
2124 XCAT(yAvail_,SORT) = PrevExpr; \
2125 PrevExpr = (*SVar).First; \
2126 } \
2127 if ( PrevExpr != (XCAT(SORT,_yptr))0 ) { \
2128 while ( PrevExpr->Suc != (XCAT(SORT,_yptr))0 ) { \
2129 TempExpr = PrevExpr->Suc; \
2130 if ( XCAT(yEqF_,COMPONENTSORT)(TempExpr->Data, (*SVar).Data) ) { \
2131 PrevExpr->Suc = TempExpr->Suc; \
2132 TempExpr->Suc = XCAT(yAvail_,SORT); \
2133 XCAT(yAvail_,SORT) = TempExpr; \
2134 } else { \
2135 PrevExpr = TempExpr; \
2136 } \
2137 } \
2138 } \
2139 (*SVar).Last = PrevExpr; \
2140 }
2141
2142
2143/*-- yEq_SORT (Array)----------------------------------------------*/
2144#define Array_Equal(SORT, INDEXSORT, COMPONENTSORT) \
2145 extern SDL_Boolean XCAT(yEq_,SORT) \
2146 XPP_PROTO( (SORT Expr1, SORT Expr2) ) \
2147 XPP_NOPROTO( (Expr1, Expr2) SORT Expr1; SORT Expr2; ) \
2148 { \
2149 XCAT(SORT,_yptr) Temp; \
2150 SDL_Boolean Result; \
2151 \
2152 Result = XCAT(yEqF_,COMPONENTSORT)(Expr1.Data, Expr2.Data); \
2153 if (Result) { \
2154 Temp = Expr1.First; \
2155 while (Result && Temp != (XCAT(SORT,_yptr))0) { \
2156 if (XCAT(yNEqF_,COMPONENTSORT) \
2157 (Temp->Data, XCAT(yExtrInner_,SORT)(Expr2, Temp->Index)) ) \
2158 Result = SDL_False; \
2159 Temp = Temp->Suc; \
2160 } \
2161 Temp = Expr2.First; \
2162 while (Result && Temp != (XCAT(SORT,_yptr))0) { \
2163 if (XCAT(yNEqF_,COMPONENTSORT) \
2164 (Temp->Data, XCAT(yExtrInner_,SORT)(Expr1, Temp->Index)) ) \
2165 Result = SDL_False; \
2166 Temp = Temp->Suc; \
2167 } \
2168 } \
2169 \
2170 if (! Expr1.IsAssigned) \
2171 XCAT(yFree_,SORT)((void **)&Expr1); \
2172 if (! Expr2.IsAssigned) \
2173 XCAT(yFree_,SORT)((void **)&Expr2); \
2174 return Result; \
2175 }
2176
2177/*-- yDef_SORT (Array)---------------------------------------------*/
2178#define Array_Default(SORT, INDEXSORT, COMPONENTSORT) \
2179 extern void XCAT(yDef_,SORT) \
2180 XPP_PROTO( (SORT *S) ) \
2181 XPP_NOPROTO( (S) SORT *S; ) \
2182 { \
2183 (*S).First = (XCAT(SORT,_yptr))0; \
2184 (*S).Last = (XCAT(SORT,_yptr))0; \
2185 XCAT(yDef_,COMPONENTSORT)(&(*S).Data); \
2186 (*S).IsAssigned = (xbool)1; \
2187 }
2188
2189
2190/*-- yFree_SORT (Array)--------------------------------------------*/
2191#ifdef XFREEFUNCS
2192#define Array_Free(SORT, INDEXSORT, HASINDEXFREE, COMPONENTSORT, HASCOMPFREE) \
2193 extern void XCAT(yFree_,SORT) \
2194 XPP_PROTO( (void ** C) ) \
2195 XPP_NOPROTO( (C) void ** C; ) \
2196 { \
2197 XCAT(SORT,_yptr) Temp; \
2198 if (HASCOMPFREE || HASINDEXFREE) { \
2199 for (Temp = (*(SORT *)C).First; \
2200 Temp != (XCAT(SORT,_yptr))0; \
2201 Temp = Temp->Suc) { \
2202 if (HASCOMPFREE) \
2203 XCAT(yFree_,COMPONENTSORT)((void **)&Temp->Data); \
2204 if (HASINDEXFREE) \
2205 XCAT(yFree_,INDEXSORT)((void **)&Temp->Index); \
2206 } \
2207 if (HASCOMPFREE) \
2208 XCAT(yFree_,COMPONENTSORT)((void **)&(*(SORT *)C).Data); \
2209 } \
2210 if ((*(SORT *)C).First != (XCAT(SORT,_yptr))0) { \
2211 (*(SORT *)C).Last->Suc = XCAT(yAvail_,SORT); \
2212 XCAT(yAvail_,SORT) = (*(SORT *)C).First; \
2213 } \
2214 }
2215#else
2216#define Array_Free(SORT, INDEXSORT, HASINDEXFREE, COMPONENTSORT, HASCOMPFREE) \
2217 extern void XCAT(yFree_,SORT) \
2218 XPP_PROTO( (void ** C) ) \
2219 XPP_NOPROTO( (C) void ** C; ) \
2220 { \
2221 if ((*(SORT *)C).First != (XCAT(SORT,_yptr))0) { \
2222 (*(SORT *)C).Last->Suc = XCAT(yAvail_,SORT); \
2223 XCAT(yAvail_,SORT) = (*(SORT *)C).First; \
2224 } \
2225 }
2226#endif
2227
2228
2229/*-- yWri_SORT (Array)---------------------------------------------*/
2230#define Array_Write(SORT, INDEXSORT, COMPONENTSORT) \
2231 extern char * XCAT(yWri_,SORT) \
2232 XPP_PROTO( (void * S) ) \
2233 XPP_NOPROTO( (S) void * S; ) \
2234 { \
2235 XCAT(SORT,_yptr) ArrPtr; \
2236 static char CTemp[MAX_WRI_LENGTH]; \
2237 \
2238 strcpy(CTemp, "(: (others:"); \
2239 xSafeStrcat(CTemp, \
2240 xWriteSort((void *)(&(*(SORT *)S).Data), XCAT(ySrtN_,COMPONENTSORT))); \
2241 xSafeStrcat(CTemp, ")"); \
2242 for (ArrPtr = (*(SORT *)S).First; \
2243 ArrPtr != (XCAT(SORT,_yptr))0; \
2244 ArrPtr = ArrPtr->Suc) { \
2245 xSafeStrcat(CTemp, ", ("); \
2246 xSafeStrcat(CTemp, \
2247 xWriteSort((void *)(&ArrPtr->Index), XCAT(ySrtN_,INDEXSORT))); \
2248 xSafeStrcat(CTemp, ":"); \
2249 xSafeStrcat(CTemp, \
2250 xWriteSort((void *)(&ArrPtr->Data), XCAT(ySrtN_,COMPONENTSORT))); \
2251 xSafeStrcat(CTemp, ")"); \
2252 } \
2253 xSafeStrcat(CTemp, " :)"); \
2254 return CTemp; \
2255 }
2256
2257
2258/*-- yRead_SORT (Array)--------------------------------------------*/
2259#define Array_Read(SORT, INDEXSORT, COMPONENTSORT) \
2260 extern int XCAT(yRead_,SORT) \
2261 XPP_PROTO( (void * Result) ) \
2262 XPP_NOPROTO( (Result) void * Result; ) \
2263 { \
2264 INDEXSORT Index; \
2265 COMPONENTSORT Item; \
2266 xxToken Token; \
2267 char strVar[256]; \
2268 xbool IsOthers; \
2269 int Res; \
2270 \
2271 XCAT(yDef_,SORT)((SORT *)Result); \
2272 Token = xScanToken(strVar); \
2273 if (Token != xxLParColon && Token != xxQuestionMark && Token != xxEoln) { \
2274 xPrintString("Array value should start with (:\n"); \
2275 return 0; \
2276 } \
2277 if (Token != xxLParColon) xUngetToken(Token, strVar); \
2278 \
2279 IsOthers = (xbool)1; \
2280 while (Token != xxRParColon) { \
2281 Token = xScanToken(strVar); \
2282 if (Token == xxLPar) Token = xScanToken(strVar); \
2283 if (! IsOthers) { \
2284 if (Token == xxEoln || Token == xxQuestionMark) { \
2285 sprintf(strVar, " Index (%s) : ", XCAT(ySrtN_,INDEXSORT)->Name); \
2286 xPrintString(strVar); \
2287 Token = xScanToken(strVar); \
2288 } \
2289 if (Token == xxRParColon) break; \
2290 xUngetToken(Token, strVar); \
2291 (void)memset((void *)(&Index), 0, sizeof(INDEXSORT)); \
2292 if ( ! xReadSort((void *)&Index, XCAT(ySrtN_,INDEXSORT))) { \
2293 xPrintString("Illegal index value\n"); \
2294 return 0; \
2295 } \
2296 Token = xScanToken(strVar); \
2297 } else { \
2298 if (Token == xxEoln || Token == xxQuestionMark) { \
2299 xPrintString(" others"); \
2300 } else if (Token == xxId) { \
2301 if (xfEqualIdString(strVar, "others") != 2) { \
2302 xPrintString("others expected\n"); \
2303 return 0; \
2304 } \
2305 Token = xScanToken(strVar); \
2306 } else { \
2307 xPrintString("others expected\n"); \
2308 return 0; \
2309 } \
2310 } \
2311 if (Token != xxColon) xUngetToken(Token, strVar); \
2312 if (IsOthers) \
2313 sprintf(strVar, " Others component (%s) : ", XCAT(ySrtN_,COMPONENTSORT)->Name); \
2314 else \
2315 sprintf(strVar, " Component (%s) : ", XCAT(ySrtN_,COMPONENTSORT)->Name); \
2316 (void)memset((void *)(&Item), 0, sizeof(COMPONENTSORT)); \
2317 Res = xReadOneParameter(XCAT(ySrtN_,COMPONENTSORT), strVar, (void *)&Item); \
2318 if (Res == 0) { \
2319 xPrintString("Illegal component value\n"); \
2320 return 0; \
2321 } \
2322 if (IsOthers) \
2323 XCAT(yAss_,SORT)((SORT *)Result, XCAT(yMake_,SORT)(Item), XASS); \
2324 else \
2325 XCAT(yAssF_,COMPONENTSORT)( \
2326 (* XCAT(yAddr_,SORT)((SORT *)Result, Index)) , Item, XASS); \
2327 \
2328 Token = xScanToken(strVar); \
2329 if (Token == xxRPar) Token = xScanToken(strVar); \
2330 if (Token == xxComma) Token = xScanToken(strVar); \
2331 if (Token != xxRParColon) xUngetToken(Token, strVar); \
2332 IsOthers = (xbool)0; \
2333 } \
2334 (*(SORT *)Result).IsAssigned = (int)1; \
2335 return 1; \
2336 }
2337
2338
2339/****+***************************************************************
234006 Generator Powerset (limited and discrete component type)
2341********************************************************************/
2342
2343/* typedef for Powerset type --------------------------------------*/
2344
2345#define Powerset_Type(SORT, COMPONENTSORT, LOW, HIGH) \
2346 typedef struct { \
2347 unsigned long A[(HIGH-LOW)/32+1]; \
2348 } SORT;
2349
2350 /* unsigned long is assumed to be 32 bits */
2351
2352
2353#define Powerset_prototypes(SORT, COMPONENTSORT, LOW, HIGH) \
2354 extern SORT XCAT(yEmpty_,SORT) XPP((void)); \
2355 extern SDL_Boolean XCAT(yIn_,SORT) XPP((COMPONENTSORT, SORT)); \
2356 extern SORT XCAT(yIncl_,SORT) XPP((COMPONENTSORT, SORT)); \
2357 extern SORT XCAT(yDel_,SORT) XPP((COMPONENTSORT, SORT)); \
2358 extern SDL_Boolean XCAT(yLT_,SORT) XPP((SORT, SORT)); \
2359 extern SDL_Boolean XCAT(yGT_,SORT) XPP((SORT, SORT)); \
2360 extern SDL_Boolean XCAT(yLE_,SORT) XPP((SORT, SORT)); \
2361 extern SDL_Boolean XCAT(yGE_,SORT) XPP((SORT, SORT)); \
2362 extern SORT XCAT(yAnd_,SORT) XPP((SORT, SORT)); \
2363 extern SORT XCAT(yOr_,SORT) XPP((SORT, SORT)); \
2364 \
2365 extern SDL_Integer XCAT(yCard_,SORT) XPP((SORT)); \
2366 extern COMPONENTSORT XCAT(yElement_,SORT) XPP((SORT, SDL_Integer));
2367
2368
2369/*-- yEmpty_SORT (Powerset)----------------------------------------*/
2370#define Powerset_Empty(SORT, COMPONENTSORT, LOW, HIGH) \
2371 extern SORT XCAT(yEmpty_,SORT) XPP((void)) \
2372 { \
2373 SORT PS; \
2374 int Item; \
2375 for (Item=0; Item<=(HIGH-LOW)/32; Item++) \
2376 PS.A[Item] = 0; \
2377 return PS; \
2378 }
2379
2380
2381/*-- yIn_SORT (Powerset)-------------------------------------------*/
2382#define Powerset_In(SORT, COMPONENTSORT, LOW, HIGH) \
2383 extern SDL_Boolean XCAT(yIn_,SORT) \
2384 XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
2385 XPP_NOPROTO( (Item, PS) COMPONENTSORT Item; SORT PS; ) \
2386 { \
2387 if (Item < LOW || Item > HIGH) return SDL_False; \
2388 Item = Item - LOW; \
2389 if ( ((unsigned long)1 << Item%32) & PS.A[Item/32] ) \
2390 return SDL_True; \
2391 return SDL_False; \
2392 }
2393
2394
2395/*-- yIncl_SORT (Powerset)-----------------------------------------*/
2396#define Powerset_Incl(SORT, COMPONENTSORT, LOW, HIGH) \
2397 extern SORT XCAT(yIncl_,SORT) \
2398 XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
2399 XPP_NOPROTO( (Item, PS) COMPONENTSORT Item; SORT PS; ) \
2400 { \
2401 if (Item < LOW || Item > HIGH) return PS; \
2402 Item = Item - LOW; \
2403 PS.A[Item/32] = ((unsigned long)1 << Item%32) | PS.A[Item/32]; \
2404 return PS; \
2405 }
2406
2407
2408/*-- yDel_SORT (Powerset)------------------------------------------*/
2409#define Powerset_Del(SORT, COMPONENTSORT, LOW, HIGH) \
2410 extern SORT XCAT(yDel_,SORT) \
2411 XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
2412 XPP_NOPROTO( (Item, PS) COMPONENTSORT Item; SORT PS; ) \
2413 { \
2414 if (Item < LOW || Item > HIGH) return PS; \
2415 Item = Item - LOW; \
2416 PS.A[Item/32] = ~((unsigned long)1 << Item%32) & PS.A[Item/32]; \
2417 return PS; \
2418 }
2419
2420
2421/*-- yAnd_SORT (Powerset)------------------------------------------*/
2422#define Powerset_And(SORT, COMPONENTSORT, LOW, HIGH) \
2423 extern SORT XCAT(yAnd_,SORT) \
2424 XPP_PROTO( (SORT PS1, SORT PS2) ) \
2425 XPP_NOPROTO( (PS1, PS2) SORT PS1; SORT PS2; ) \
2426 { \
2427 SORT PS; \
2428 int Item; \
2429 \
2430 for (Item=0; Item<=(HIGH-LOW)/32; Item++) \
2431 PS.A[Item] = PS1.A[Item] & PS2.A[Item]; \
2432 return PS; \
2433 }
2434
2435
2436/*-- yOr_SORT (Powerset)-------------------------------------------*/
2437#define Powerset_Or(SORT, COMPONENTSORT, LOW, HIGH) \
2438 extern SORT XCAT(yOr_,SORT) \
2439 XPP_PROTO( (SORT PS1, SORT PS2) ) \
2440 XPP_NOPROTO( (PS1, PS2) SORT PS1; SORT PS2; ) \
2441 { \
2442 SORT PS; \
2443 int Item; \
2444 \
2445 for (Item=0; Item<=(HIGH-LOW)/32; Item++) \
2446 PS.A[Item] = PS1.A[Item] | PS2.A[Item]; \
2447 return PS; \
2448 }
2449
2450
2451/*-- yLE_SORT (Powerset)-------------------------------------------*/
2452#define Powerset_LE(SORT, COMPONENTSORT, LOW, HIGH) \
2453 extern SDL_Boolean XCAT(yLE_,SORT) \
2454 XPP_PROTO( (SORT PS1, SORT PS2) ) \
2455 XPP_NOPROTO( (PS1, PS2) SORT PS1; SORT PS2; ) \
2456 { \
2457 int Item; \
2458 \
2459 for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
2460 if ( (PS2.A[Item] | PS1.A[Item]) ^ PS2.A[Item] ) \
2461 return SDL_False; \
2462 } \
2463 return SDL_True; \
2464 }
2465
2466
2467/*-- yLT_SORT (Powerset)-------------------------------------------*/
2468#define Powerset_LT(SORT, COMPONENTSORT, LOW, HIGH) \
2469 extern SDL_Boolean XCAT(yLT_,SORT) \
2470 XPP_PROTO( (SORT PS1, SORT PS2) ) \
2471 XPP_NOPROTO( (PS1, PS2) SORT PS1; SORT PS2; ) \
2472 { \
2473 int Item; \
2474 for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
2475 if ( (PS2.A[Item] | PS1.A[Item]) ^ PS2.A[Item] ) \
2476 return SDL_False; \
2477 } \
2478 for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
2479 if ( PS2.A[Item] ^ PS1.A[Item] ) \
2480 return SDL_True; \
2481 } \
2482 return SDL_False; \
2483 }
2484
2485
2486/*-- yGE_SORT (Powerset)-------------------------------------------*/
2487#define Powerset_GE(SORT, COMPONENTSORT, LOW, HIGH) \
2488 extern SDL_Boolean XCAT(yGE_,SORT) \
2489 XPP_PROTO( (SORT PS1, SORT PS2) ) \
2490 XPP_NOPROTO( (PS1, PS2) SORT PS1; SORT PS2; ) \
2491 { \
2492 int Item; \
2493 for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
2494 if ( (PS1.A[Item] | PS2.A[Item]) ^ PS1.A[Item] ) \
2495 return SDL_False; \
2496 } \
2497 return SDL_True; \
2498 }
2499
2500
2501/*-- yGT_SORT (Powerset)-------------------------------------------*/
2502#define Powerset_GT(SORT, COMPONENTSORT, LOW, HIGH) \
2503 extern SDL_Boolean XCAT(yGT_,SORT) \
2504 XPP_PROTO( (SORT PS1, SORT PS2) ) \
2505 XPP_NOPROTO( (PS1, PS2) SORT PS1; SORT PS2; ) \
2506 { \
2507 int Item; \
2508 for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
2509 if ( (PS1.A[Item] | PS2.A[Item]) ^ PS1.A[Item] ) \
2510 return SDL_False; \
2511 } \
2512 for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
2513 if ( PS1.A[Item] ^ PS2.A[Item] ) \
2514 return SDL_True; \
2515 } \
2516 return SDL_False; \
2517 }
2518
2519
2520/*-- yEq_SORT (Powerset)-------------------------------------------*/
2521#define Powerset_Equal(SORT, COMPONENTSORT, LOW, HIGH) \
2522 extern SDL_Boolean XCAT(yEq_,SORT) \
2523 XPP_PROTO( (SORT Expr1, SORT Expr2) ) \
2524 XPP_NOPROTO( (Expr1, Expr2) SORT Expr1; SORT Expr2; ) \
2525 { \
2526 int Item; \
2527 for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
2528 if ( Expr1.A[Item] ^ Expr2.A[Item] ) \
2529 return SDL_False; \
2530 } \
2531 return SDL_True; \
2532 }
2533
2534
2535/*-- yDef_SORT (Powerset)------------------------------------------*/
2536#define Powerset_Default(SORT, COMPONENTSORT, LOW, HIGH) \
2537 extern void XCAT(yDef_,SORT) \
2538 XPP_PROTO( (SORT *S) ) \
2539 XPP_NOPROTO( (S) SORT *S; ) \
2540 { \
2541 int Item; \
2542 for (Item=0; Item<=(HIGH-LOW)/32; Item++) \
2543 (*S).A[Item] = (unsigned long)0; \
2544 }
2545
2546
2547
2548/****+***************************************************************
254907 Generator Powerset (general component type)
2550********************************************************************/
2551
2552/* typedef for GPowerset type -------------------------------------*/
2553
2554#define GPowerset_Type(SORT, COMPONENTSORT) \
2555 typedef struct XCAT(SORT,_ystruct) * XCAT(SORT,_yptr); \
2556 typedef struct XCAT(SORT,_ystruct) { \
2557 XCAT(SORT,_yptr) Suc; \
2558 COMPONENTSORT Data; \
2559 } XCAT(SORT,_yrec); \
2560 typedef struct { \
2561 XCAT(SORT,_yptr) First; \
2562 XCAT(SORT,_yptr) Last; \
2563 int Length; \
2564 xbool IsAssigned; \
2565 } SORT;
2566
2567
2568#define GPowerset_prototypes(SORT, COMPONENTSORT) \
2569 extern SORT XCAT(yEmpty_,SORT) XPP((void)); \
2570 extern SDL_Boolean XCAT(yIn_,SORT) XPP((COMPONENTSORT, SORT)); \
2571 extern SORT XCAT(yIncl_,SORT) XPP((COMPONENTSORT, SORT)); \
2572 extern SORT XCAT(yDel_,SORT) XPP((COMPONENTSORT, SORT)); \
2573 extern SDL_Boolean XCAT(yLT_,SORT) XPP((SORT, SORT)); \
2574 extern SDL_Boolean XCAT(yGT_,SORT) XPP((SORT, SORT)); \
2575 extern SDL_Boolean XCAT(yLE_,SORT) XPP((SORT, SORT)); \
2576 extern SDL_Boolean XCAT(yGE_,SORT) XPP((SORT, SORT)); \
2577 extern SORT XCAT(yAnd_,SORT) XPP((SORT, SORT)); \
2578 extern SORT XCAT(yOr_,SORT) XPP((SORT, SORT)); \
2579 extern SDL_Integer XCAT(yCard_,SORT) XPP((SORT)); \
2580 extern COMPONENTSORT XCAT(yElement_,SORT) XPP((SORT, SDL_Integer)); \
2581 \
2582 extern SORT XCAT(yCopyList_,SORT) XPP((SORT PS)); \
2583 extern SDL_Boolean XCAT(yInInner_,SORT) \
2584 XPP((COMPONENTSORT Item, SORT PS)); \
2585 extern XCAT(SORT,_yptr) XCAT(yGetAvail_,SORT) XPP((void)); \
2586 \
2587 extern char * XCAT(yWri_,SORT) XPP((void * PS)); \
2588 extern int XCAT(yRead_,SORT) XPP((void * Result));
2589
2590
2591/*-- yEmpty_SORT (GPowerset)---------------------------------------*/
2592#define GPowerset_Empty(SORT, COMPONENTSORT) \
2593 extern XCAT(SORT,_yptr) XCAT(yGetAvail_,SORT) XPP((void)) \
2594 { \
2595 XCAT(SORT,_yptr) Item; \
2596 if (XCAT(yAvail_,SORT) != (XCAT(SORT,_yptr))0) { \
2597 Item = XCAT(yAvail_,SORT); \
2598 XCAT(yAvail_,SORT) = XCAT(yAvail_,SORT)->Suc; \
2599 } else { \
2600 Item = (XCAT(SORT,_yptr))xAlloc((unsigned)sizeof(XCAT(SORT,_yrec))); \
2601 } \
2602 Item->Suc = (XCAT(SORT,_yptr))0; \
2603 return Item; \
2604 } \
2605 \
2606 extern SORT XCAT(yEmpty_,SORT) XPP((void)) \
2607 { \
2608 SORT Result; \
2609 Result.First = (XCAT(SORT,_yptr))0; \
2610 Result.Last = (XCAT(SORT,_yptr))0; \
2611 Result.Length = 0; \
2612 Result.IsAssigned = (xbool)0; \
2613 return Result; \
2614 }
2615
2616
2617/*-- yIn_SORT (GPowerset)------------------------------------------*/
2618#define GPowerset_In(SORT, COMPONENTSORT) \
2619 extern SDL_Boolean XCAT(yInInner_,SORT) \
2620 XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
2621 XPP_NOPROTO( (Item, PS) COMPONENTSORT Item; SORT PS; ) \
2622 { \
2623 XCAT(SORT,_yptr) Temp; \
2624 SDL_Boolean Result; \
2625 Result = SDL_False; \
2626 for (Temp=PS.First; \
2627 Temp!=(XCAT(SORT,_yptr))0 && !Result; \
2628 Temp=Temp->Suc) \
2629 if ( XCAT(yEqF_,COMPONENTSORT)(Temp->Data, Item) ) \
2630 Result = SDL_True; \
2631 return Result; \
2632 } \
2633 \
2634 extern SDL_Boolean XCAT(yIn_,SORT) \
2635 XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
2636 XPP_NOPROTO( (Item, PS) COMPONENTSORT Item; SORT PS; ) \
2637 { \
2638 SDL_Boolean Result; \
2639 Result = XCAT(yInInner_,SORT)(Item, PS); \
2640 if (! PS.IsAssigned) \
2641 XCAT(yFree_,SORT)((void **)&PS); \
2642 return Result; \
2643 }
2644
2645
2646/*-- yIncl_SORT (GPowerset)----------------------------------------*/
2647#define GPowerset_Incl(SORT, COMPONENTSORT) \
2648 extern SORT XCAT(yCopyList_,SORT) \
2649 XPP_PROTO( (SORT PS) ) \
2650 XPP_NOPROTO( (PS) SORT PS; ) \
2651 { \
2652 XCAT(SORT,_yptr) TempPS, TempRes; \
2653 SORT Result; \
2654 Result = PS; \
2655 Result.IsAssigned = (xbool)0; \
2656 if (PS.First != (XCAT(SORT,_yptr))0 ) { \
2657 TempPS = PS.First; \
2658 TempRes = XCAT(yGetAvail_,SORT)(); \
2659 XCAT(yAssF_,COMPONENTSORT)(TempRes->Data, TempPS->Data, XASS); \
2660 Result.First = TempRes; \
2661 while (TempPS->Suc != (XCAT(SORT,_yptr))0) { \
2662 TempPS = TempPS->Suc; \
2663 TempRes->Suc = XCAT(yGetAvail_,SORT)(); \
2664 TempRes = TempRes->Suc; \
2665 XCAT(yAssF_,COMPONENTSORT)(TempRes->Data, TempPS->Data, XASS); \
2666 } \
2667 Result.Last = TempRes; \
2668 } \
2669 return Result; \
2670 } \
2671 \
2672 extern SORT XCAT(yIncl_,SORT) \
2673 XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
2674 XPP_NOPROTO( (Item, PS) COMPONENTSORT Item; SORT PS; ) \
2675 { \
2676 SORT Result; \
2677 if (PS.IsAssigned) \
2678 Result = XCAT(yCopyList_,SORT)(PS); \
2679 else \
2680 Result = PS; \
2681 if (! XCAT(yInInner_,SORT)(Item, Result) ) { \
2682 if (Result.Last == (XCAT(SORT,_yptr))0) { \
2683 Result.Last = XCAT(yGetAvail_,SORT)(); \
2684 Result.First = Result.Last; \
2685 } else { \
2686 Result.Last->Suc = XCAT(yGetAvail_,SORT)(); \
2687 Result.Last = Result.Last->Suc; \
2688 } \
2689 XCAT(yAssF_,COMPONENTSORT)(Result.Last->Data, Item, XASS); \
2690 Result.Length++; \
2691 } \
2692 return Result; \
2693 }
2694
2695
2696/*-- yDel_SORT (GPowerset)-----------------------------------------*/
2697#define GPowerset_Del(SORT, COMPONENTSORT) \
2698 extern SORT XCAT(yDel_,SORT) \
2699 XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
2700 XPP_NOPROTO( (Item, PS) COMPONENTSORT Item; SORT PS; ) \
2701 { \
2702 SORT Result; \
2703 XCAT(SORT,_yptr) Temp, Prev; \
2704 if (PS.IsAssigned) \
2705 Result = XCAT(yCopyList_,SORT)(PS); \
2706 else \
2707 Result = PS; \
2708 if ( Result.First != (XCAT(SORT,_yptr))0 ) { \
2709 Prev = Result.First; \
2710 if ( XCAT(yEqF_,COMPONENTSORT)(Prev->Data, Item) ) { \
2711 Result.First = Prev->Suc; \
2712 if (Result.Last == Prev) Result.Last = (XCAT(SORT,_yptr))0; \
2713 Prev->Suc = XCAT(yAvail_,SORT); \
2714 XCAT(yAvail_,SORT) = Prev; \
2715 Result.Length--; \
2716 return Result; \
2717 } \
2718 for (Temp=Prev->Suc; \
2719 Temp!=(XCAT(SORT,_yptr))0; \
2720 Temp=Temp->Suc) { \
2721 if ( XCAT(yEqF_,COMPONENTSORT)(Temp->Data, Item) ) {\
2722 Prev->Suc = Temp->Suc; \
2723 if (Result.Last == Temp) Result.Last = Prev; \
2724 Temp->Suc = XCAT(yAvail_,SORT); \
2725 XCAT(yAvail_,SORT) = Temp; \
2726 Result.Length--; \
2727 return Result; \
2728 } \
2729 Prev = Temp; \
2730 } \
2731 } \
2732 return Result; \
2733 }
2734
2735
2736/*-- yAnd_SORT (GPowerset)-----------------------------------------*/
2737#define GPowerset_And(SORT, COMPONENTSORT) \
2738 extern SORT XCAT(yAnd_,SORT) \
2739 XPP_PROTO( (SORT PS1, SORT PS2) ) \
2740 XPP_NOPROTO( (PS1, PS2) SORT PS1; SORT PS2; ) \
2741 { \
2742 SORT Result; \
2743 XCAT(SORT,_yptr) Temp; \
2744 Result = XCAT(yEmpty_,SORT)(); \
2745 for (Temp=PS1.First; Temp!=(XCAT(SORT,_yptr))0; Temp=Temp->Suc) \
2746 if ( XCAT(yInInner_,SORT)(Temp->Data, PS2) ) { \
2747 if (Result.First == (XCAT(SORT,_yptr))0) { \
2748 Result.First = XCAT(yGetAvail_,SORT)(); \
2749 Result.Last = Result.First; \
2750 } else { \
2751 Result.Last->Suc = XCAT(yGetAvail_,SORT)(); \
2752 Result.Last = Result.Last->Suc; \
2753 } \
2754 XCAT(yAssF_,COMPONENTSORT)(Result.Last->Data, Temp->Data, XASS); \
2755 Result.Length++; \
2756 } \
2757 if (! PS1.IsAssigned) \
2758 XCAT(yFree_,SORT)((void **)&PS1); \
2759 if (! PS2.IsAssigned) \
2760 XCAT(yFree_,SORT)((void **)&PS2); \
2761 return Result; \
2762 }
2763
2764
2765/*-- yOr_SORT (GPowerset)------------------------------------------*/
2766#define GPowerset_Or(SORT, COMPONENTSORT) \
2767 extern SORT XCAT(yOr_,SORT) \
2768 XPP_PROTO( (SORT PS1, SORT PS2) ) \
2769 XPP_NOPROTO( (PS1, PS2) SORT PS1; SORT PS2; ) \
2770 { \
2771 SORT Result; \
2772 XCAT(SORT,_yptr) Temp; \
2773 if (PS2.IsAssigned) \
2774 Result = XCAT(yCopyList_,SORT)(PS2); \
2775 else \
2776 Result = PS2; \
2777 for (Temp=PS1.First; Temp!=(XCAT(SORT,_yptr))0; Temp=Temp->Suc) \
2778 if ( ! XCAT(yInInner_,SORT)(Temp->Data, Result) ) { \
2779 if (Result.First == (XCAT(SORT,_yptr))0) { \
2780 Result.First = XCAT(yGetAvail_,SORT)(); \
2781 Result.Last = Result.First; \
2782 } else { \
2783 Result.Last->Suc = XCAT(yGetAvail_,SORT)(); \
2784 Result.Last = Result.Last->Suc; \
2785 } \
2786 XCAT(yAssF_,COMPONENTSORT)(Result.Last->Data, Temp->Data, XASS); \
2787 Result.Length++; \
2788 } \
2789 if (! PS1.IsAssigned) \
2790 XCAT(yFree_,SORT)((void **)&PS1); \
2791 return Result; \
2792 }
2793
2794
2795/*-- yLE_SORT (GPowerset)------------------------------------------*/
2796#define GPowerset_LE(SORT, COMPONENTSORT) \
2797 extern SDL_Boolean XCAT(yLE_,SORT) \
2798 XPP_PROTO( (SORT PS1, SORT PS2) ) \
2799 XPP_NOPROTO( (PS1, PS2) SORT PS1; SORT PS2; ) \
2800 { \
2801 XCAT(SORT,_yptr) Temp; \
2802 SDL_Boolean Result; \
2803 Result = PS1.Length <= PS2.Length; \
2804 for (Temp=PS1.First; \
2805 Temp!=(XCAT(SORT,_yptr))0 && Result; \
2806 Temp=Temp->Suc) \
2807 if ( ! XCAT(yInInner_,SORT)(Temp->Data, PS2) ) \
2808 Result = SDL_False; \
2809 if (! PS1.IsAssigned) \
2810 XCAT(yFree_,SORT)((void **)&PS1); \
2811 if (! PS2.IsAssigned) \
2812 XCAT(yFree_,SORT)((void **)&PS2); \
2813 return Result; \
2814 }
2815
2816
2817/*-- yLT_SORT (GPowerset)------------------------------------------*/
2818#define GPowerset_LT(SORT, COMPONENTSORT) \
2819 extern SDL_Boolean XCAT(yLT_,SORT) \
2820 XPP_PROTO( (SORT PS1, SORT PS2) ) \
2821 XPP_NOPROTO( (PS1, PS2) SORT PS1; SORT PS2; ) \
2822 { \
2823 XCAT(SORT,_yptr) Temp; \
2824 SDL_Boolean Result; \
2825 Result = PS1.Length < PS2.Length; \
2826 for (Temp=PS1.First; \
2827 Temp!=(XCAT(SORT,_yptr))0 && Result; \
2828 Temp=Temp->Suc) \
2829 if ( ! XCAT(yInInner_,SORT)(Temp->Data, PS2) ) \
2830 Result = SDL_False; \
2831 if (! PS1.IsAssigned) \
2832 XCAT(yFree_,SORT)((void **)&PS1); \
2833 if (! PS2.IsAssigned) \
2834 XCAT(yFree_,SORT)((void **)&PS2); \
2835 return Result; \
2836 }
2837
2838
2839/*-- yGE_SORT (GPowerset)------------------------------------------*/
2840#define GPowerset_GE(SORT, COMPONENTSORT) \
2841 extern SDL_Boolean XCAT(yGE_,SORT) \
2842 XPP_PROTO( (SORT PS1, SORT PS2) ) \
2843 XPP_NOPROTO( (PS1, PS2) SORT PS1; SORT PS2; ) \
2844 { \
2845 return XCAT(yLE_,SORT)(PS2, PS1); \
2846 }
2847
2848
2849/*-- yGT_SORT (GPowerset)------------------------------------------*/
2850#define GPowerset_GT(SORT, COMPONENTSORT) \
2851 extern SDL_Boolean XCAT(yGT_,SORT) \
2852 XPP_PROTO( (SORT PS1, SORT PS2) ) \
2853 XPP_NOPROTO( (PS1, PS2) SORT PS1; SORT PS2; ) \
2854 { \
2855 return XCAT(yLT_,SORT)(PS2, PS1); \
2856 }
2857
2858
2859/*-- yAss_SORT (GPowerset)-----------------------------------------*/
2860#define GPowerset_Assign(SORT, COMPONENTSORT) \
2861 static XCAT(SORT,_yptr) XCAT(yAvail_,SORT) = (XCAT(SORT,_yptr))0; \
2862 extern void XCAT(yAss_,SORT) \
2863 XPP_PROTO( (SORT * SVar, SORT SExpr, int AssType) ) \
2864 XPP_NOPROTO( (SVar, SExpr, AssType) SORT * SVar; SORT SExpr; int AssType; ) \
2865 { \
2866 if ((*SVar).First == SExpr.First) { \
2867 (*SVar).IsAssigned = (xbool)1; \
2868 return; \
2869 } \
2870 if (AssType == XASS && (*SVar).First != (XCAT(SORT,_yptr))0) { \
2871 XCAT(yFree_,SORT)((void **)SVar); \
2872 } \
2873 if ( (SExpr.IsAssigned || AssType == XASS2MAKE) && \
2874 SExpr.First != (XCAT(SORT,_yptr))0) { \
2875 *SVar = XCAT(yCopyList_,SORT)(SExpr); \
2876 } else { \
2877 (*SVar).First = SExpr.First; \
2878 (*SVar).Last = SExpr.Last; \
2879 (*SVar).Length = SExpr.Length; \
2880 } \
2881 (*SVar).IsAssigned = (xbool)1; \
2882 }
2883
2884
2885/*-- yEq_SORT (GPowerset)------------------------------------------*/
2886#define GPowerset_Equal(SORT, COMPONENTSORT) \
2887 extern SDL_Boolean XCAT(yEq_,SORT) \
2888 XPP_PROTO( (SORT Expr1, SORT Expr2) ) \
2889 XPP_NOPROTO( (Expr1, Expr2) SORT Expr1; SORT Expr2; ) \
2890 { \
2891 XCAT(SORT,_yptr) Temp; \
2892 SDL_Boolean Result; \
2893 Result = Expr1.Length == Expr2.Length; \
2894 for (Temp=Expr1.First; \
2895 Temp!=(XCAT(SORT,_yptr))0 && Result; \
2896 Temp=Temp->Suc) \
2897 if ( ! XCAT(yInInner_,SORT)(Temp->Data, Expr2) ) \
2898 Result = SDL_False; \
2899 if (! Expr1.IsAssigned) \
2900 XCAT(yFree_,SORT)((void **)&Expr1); \
2901 if (! Expr2.IsAssigned) \
2902 XCAT(yFree_,SORT)((void **)&Expr2); \
2903 return Result; \
2904 }
2905
2906
2907/*-- yDef_SORT (GPowerset)-----------------------------------------*/
2908#define GPowerset_Default(SORT, COMPONENTSORT) \
2909 extern void XCAT(yDef_,SORT) \
2910 XPP_PROTO( (SORT *S) ) \
2911 XPP_NOPROTO( (S) SORT *S; ) \
2912 { \
2913 (*S).First = (XCAT(SORT,_yptr))0; \
2914 (*S).Last = (XCAT(SORT,_yptr))0; \
2915 (*S).Length = 0; \
2916 (*S).IsAssigned = (xbool)1; \
2917 }
2918
2919
2920/*-- yFree_SORT (GPowerset)---------------------------------------*/
2921#ifdef XFREEFUNCS
2922#define GPowerset_Free(SORT, COMPONENTSORT, HASCOMPFREE) \
2923 extern void XCAT(yFree_,SORT) \
2924 XPP_PROTO( (void ** C) ) \
2925 XPP_NOPROTO( (C) void ** C; ) \
2926 { \
2927 XCAT(SORT,_yptr) Temp; \
2928 if (HASCOMPFREE) { \
2929 for (Temp = (*(SORT *)C).First; \
2930 Temp != (XCAT(SORT,_yptr))0; \
2931 Temp = Temp->Suc) { \
2932 XCAT(yFree_,COMPONENTSORT)((void **)&Temp->Data); \
2933 } \
2934 } \
2935 if ((*(SORT *)C).First != (XCAT(SORT,_yptr))0) { \
2936 (*(SORT *)C).Last->Suc = XCAT(yAvail_,SORT); \
2937 XCAT(yAvail_,SORT) = (*(SORT *)C).First; \
2938 } \
2939 }
2940#else
2941#define GPowerset_Free(SORT, COMPONENTSORT, HASCOMPFREE) \
2942 extern void XCAT(yFree_,SORT) \
2943 XPP_PROTO( (void ** C) ) \
2944 XPP_NOPROTO( (C) void ** C; ) \
2945 { \
2946 if ((*(SORT *)C).First != (XCAT(SORT,_yptr))0) { \
2947 (*(SORT *)C).Last->Suc = XCAT(yAvail_,SORT); \
2948 XCAT(yAvail_,SORT) = (*(SORT *)C).First; \
2949 } \
2950 }
2951#endif
2952
2953
2954/*-- yCard_SORT (GPowerset)---------------------------------------*/
2955#define GPowerset_Card(SORT, COMPONENTSORT) \
2956 extern SDL_Integer XCAT(yCard_,SORT) \
2957 XPP_PROTO( (SORT PS) ) \
2958 XPP_NOPROTO( (PS) SORT PS; ) \
2959 { \
2960 return PS.Length; \
2961 }
2962
2963
2964/*-- yElement_SORT (GPowerset)------------------------------------*/
2965#define GPowerset_Element(SORT, COMPONENTSORT) \
2966 extern COMPONENTSORT XCAT(yElement_,SORT) \
2967 XPP_PROTO( (SORT PS, SDL_Integer Index) ) \
2968 XPP_NOPROTO( (PS, Index) SORT PS; SDL_Integer Index; ) \
2969 { \
2970 XCAT(SORT,_yptr) Temp; \
2971 int Number = 0; \
2972 COMPONENTSORT Result; \
2973 for (Temp=PS.First; \
2974 Temp!=(XCAT(SORT,_yptr))0 && ++Number<Index; \
2975 Temp=Temp->Suc) ; \
2976 if (Number == Index && Temp != (XCAT(SORT,_yptr))0) \
2977 return Temp->Data; \
2978 xReportStringError("Element in Powerset sort", "Index out of range") \
2979 (void)memset((void *)(&Result), 0, sizeof(COMPONENTSORT)); \
2980 XCAT(yDef_,COMPONENTSORT)(&Result); \
2981 return Result; \
2982 }
2983
2984
2985/*-- yWri_SORT (GPowerset)----------------------------------------*/
2986#define GPowerset_Write(SORT, COMPONENTSORT) \
2987 extern char * XCAT(yWri_,SORT) \
2988 XPP_PROTO( (void * PS) ) \
2989 XPP_NOPROTO( (PS) void * PS; ) \
2990 { \
2991 XCAT(SORT,_yptr) Temp, TempLast; \
2992 static char CTemp[MAX_WRI_LENGTH]; \
2993 \
2994 strcpy(CTemp, "[ "); \
2995 TempLast = (*(SORT *)PS).Last; \
2996 for (Temp = (*(SORT *)PS).First; \
2997 Temp != (XCAT(SORT,_yptr))0; \
2998 Temp = Temp->Suc) { \
2999 xSafeStrcat(CTemp, \
3000 xWriteSort((void *)(&Temp->Data), XCAT(ySrtN_,COMPONENTSORT))); \
3001 if (strlen(CTemp) == MAX_WRI_LENGTH - 1) \
3002 return CTemp; \
3003 if (Temp != TempLast) \
3004 xSafeStrcat(CTemp, ", "); \
3005 } \
3006 xSafeStrcat(CTemp, " ]"); \
3007 return CTemp; \
3008 }
3009
3010
3011/*-- yRead_SORT (GPowerset)---------------------------------------*/
3012#define GPowerset_Read(SORT, COMPONENTSORT) \
3013 extern int XCAT(yRead_,SORT) \
3014 XPP_PROTO( (void * Result) ) \
3015 XPP_NOPROTO( (Result) void * Result; ) \
3016 { \
3017 COMPONENTSORT Item; \
3018 xxToken Token; \
3019 char strVar[256]; \
3020 int Res; \
3021 \
3022 (*(SORT *)Result).First = (XCAT(SORT,_yptr))0; \
3023 (*(SORT *)Result).Last = (XCAT(SORT,_yptr))0; \
3024 (*(SORT *)Result).Length = 0; \
3025 (*(SORT *)Result).IsAssigned = (int)0; \
3026 Token = xScanToken(strVar); \
3027 if (Token != xxLBracket && Token != xxQuestionMark && Token != xxEoln) { \
3028 xPrintString("Powerset value should start with [\n"); \
3029 return 0; \
3030 } \
3031 if (Token != xxLBracket) xUngetToken(Token, strVar); \
3032 \
3033 while (Token != xxRBracket) { \
3034 sprintf(strVar, " (%s) : ", XCAT(ySrtN_,COMPONENTSORT)->Name); \
3035 (void)memset((void *)(&Item), 0, sizeof(COMPONENTSORT)); \
3036 Res = xReadOneParameter(XCAT(ySrtN_,COMPONENTSORT), strVar, (void *)&Item); \
3037 if (Res == 0) return 0; \
3038 if (Res == 2) { \
3039 Token = xScanToken(strVar); \
3040 if (Token == xxRBracket) break; \
3041 return 0; \
3042 } \
3043 *(SORT *)Result = XCAT(yIncl_,SORT)(Item, *(SORT *)Result); \
3044 Token = xScanToken(strVar); \
3045 if (Token != xxRBracket) xUngetToken(Token, strVar); \
3046 } \
3047 (*(SORT *)Result).IsAssigned = (int)1; \
3048 return 1; \
3049 }
3050#endif
3051 /* XNO_LONG_MACROS */
3052
3053
3054
3055
3056#endif
3057 /* X_SCTPRED_H */
3058
3059/*******************************************************************************
3060* History log:
3061*===============================================================================
3062* $Log: sctpred.h,v $
3063* Revision 1.4 2001/07/18 13:01:54 pbo
3064* New Release UGLOBE_2
3065*
3066* Revision 3.0 2001/07/18 11:29:36 pbo
3067* DUM_2
3068*
3069* Revision 2.0 2001/06/12 11:52:25 pbo
3070* DUM_1
3071*
3072* Revision 1.1.1.1 2001/03/28 13:37:25 pbo
3073* Initial version
3074*
3075*******************************************************************************/
3076