2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: UnpackStructureTags - unpack structure to values in TagList.
10 /*****************************************************************************
13 #include <utility/tagitem.h>
14 #include <utility/pack.h>
15 #include <proto/utility.h>
17 AROS_LH3(ULONG
, UnpackStructureTags
,
20 AROS_LHA(APTR
, pack
, A0
),
21 AROS_LHA(ULONG
*, packTable
, A1
),
22 AROS_LHA(struct TagItem
*, tagList
, A2
),
25 struct Library
*, UtilityBase
, 36, Utility
)
28 For each table entry, if the matching tag is found in the tagList,
29 then the data in the structure will be placed in the memory pointed
30 to by the tags ti_Data.
32 Note: The value contained in ti_Data must be a *POINTER* to a
36 pack - Pointer to the memory area to be unpacked.
37 packTable - Table describing the unpacking operation.
38 See the include file <utility/pack.h> for
39 more information on this table.
40 tagList - List of TagItems to unpack into.
43 The number of Tags unpacked.
46 PSTF_EXISTS has no effect on this function.
53 PackStructureTags(), FindTagItem()
58 29-10-95 digulla automatically created from
59 utility_lib.fd and clib/utility_protos.h
61 *****************************************************************************/
71 union memaccess
* memptr
;
73 tagBase
= *packTable
++;
74 for( ; *packTable
!= 0; packTable
++)
79 tagBase
= *++packTable
;
83 /* This entry is not defined for unpacking */
84 if((*packTable
& PSTF_UNPACK
)) continue;
86 tagOff
= (*packTable
>> 16) & 0x3FF;
88 /* Does the tag we are interested in exist in that list. */
89 ti
= FindTagItem(tagBase
+ tagOff
, tagList
);
93 memOff
= *packTable
& 0x1FFF;
94 bitOff
= (*packTable
& 0xE000) >> 13;
95 memptr
= (union memaccess
*)((UBYTE
*)pack
+ memOff
);
98 The assigning is different for signed and unsigned since
99 ti_Data is not necessarily the same size as the structure field,
100 so we have to let the compiler do sign extension.
102 switch(*packTable
& 0x98000000)
106 /* EXPERIMENTAL: use bitOff as "full IPTR flag" on 64 bits */
108 *(IPTR
*)ti
->ti_Data
= (IPTR
)memptr
->up
;
111 *(IPTR
*)ti
->ti_Data
= (IPTR
)memptr
->ul
;
115 *(IPTR
*)ti
->ti_Data
= (IPTR
)memptr
->uw
;
119 *(IPTR
*)ti
->ti_Data
= (IPTR
)memptr
->ub
;
125 *(IPTR
*)ti
->ti_Data
= (IPTR
)memptr
->sp
;
128 *(IPTR
*)ti
->ti_Data
= (IPTR
)memptr
->sl
;
132 *(IPTR
*)ti
->ti_Data
= (IPTR
)memptr
->sw
;
136 *(IPTR
*)ti
->ti_Data
= (IPTR
)memptr
->sb
;
140 if( memptr
->ub
& (1 << bitOff
) )
141 *(IPTR
*)ti
->ti_Data
= TRUE
;
143 *(IPTR
*)ti
->ti_Data
= FALSE
;
147 if( memptr
->ub
& (1 << bitOff
) )
148 *(IPTR
*)ti
->ti_Data
= FALSE
;
150 *(IPTR
*)ti
->ti_Data
= TRUE
;
153 /* We didn't actually pack anything */
166 } /* UnpackStructureTags */