3 * Copyright (C) 2001-2003 A.J. van Os; Released under GPL
6 * Build, read and destroy a list (array) of Word property modifiers
14 #define ELEMENTS_TO_ADD 3
16 #define ELEMENTS_TO_ADD 30
19 /* Variables needed to write the property modifier list */
20 static UCHAR
**ppAnchor
= NULL
;
21 static size_t tNextFree
= 0;
22 static size_t tMaxElements
= 0;
26 * vDestroyPropModList - destroy the property modifier list
29 vDestroyPropModList(void)
33 DBG_MSG("vDestroyPropModList");
35 /* Free all the elements of the list */
36 for (tIndex
= 0; tIndex
< tNextFree
; tIndex
++) {
37 ppAnchor
[tIndex
] = xfree(ppAnchor
[tIndex
]);
39 /* Free the list itself */
40 ppAnchor
= xfree(ppAnchor
);
41 /* Reset all control variables */
44 } /* end of vDestroyPropModList */
47 * vAdd2PropModList - add an element to the property modifier list
50 vAdd2PropModList(const UCHAR
*aucPropMod
)
54 fail(aucPropMod
== NULL
);
56 NO_DBG_MSG("vAdd2PropModList");
58 if (tNextFree
>= tMaxElements
) {
59 tMaxElements
+= ELEMENTS_TO_ADD
;
60 tSize
= tMaxElements
* sizeof(UCHAR
**);
61 ppAnchor
= xrealloc(ppAnchor
, tSize
);
63 NO_DBG_DEC(tNextFree
);
65 tLen
= 2 + (size_t)usGetWord(0, aucPropMod
);
67 NO_DBG_PRINT_BLOCK(pucPropMod
, tLen
);
68 ppAnchor
[tNextFree
] = xmalloc(tLen
);
69 memcpy(ppAnchor
[tNextFree
], aucPropMod
, tLen
);
71 } /* end of vAdd2PropModList */
74 * aucReadPropModListItem - get an item of the property modifier list
77 aucReadPropModListItem(USHORT usPropMod
)
79 static UCHAR aucBuffer
[4];
82 if (usPropMod
== IGNORE_PROPMOD
) {
83 /* This Properties Modifier must be ignored */
87 if (!odd(usPropMod
)) {
88 /* Variant 1: The information is in the input ifself */
91 aucBuffer
[2] = (UCHAR
)((usPropMod
& 0x00fe) >> 1);
92 aucBuffer
[3] = (UCHAR
)((usPropMod
& 0xff00) >> 8);
96 if (ppAnchor
== NULL
) {
97 /* No information available */
101 /* Variant 2: The input contains an index */
102 tIndex
= (size_t)(usPropMod
>> 1);
103 if (tIndex
>= tNextFree
) {
109 return ppAnchor
[tIndex
];
110 } /* end of aucGetPropModListItem */