2 Copyright © 2000, The AROS Development Team. All rights reserved.
5 Desc: DataTypesDescriptorExaminator
26 void PrintID(uint32_t ID
, uint8_t *Buffer
);
32 int main(int argc
, char **argv
)
42 fprintf(stderr
, "usage: %s datatypedescriptor\n", argv
[0]);
50 fprintf(stderr
, "Could not open %s\n", argv
[1]);
55 if(!(IH
->IFFType
==MAKE_ID('D','T','Y','P')))
57 fprintf(stderr
, "This IFF is not a valid DataType-Descriptor\n");
63 fprintf(stdout
, "# DataTypeDescription for %s\n", argv
[1]);
64 fprintf(stdout
, "# Automatically generated by %s\n\n", argv
[0]);
68 if(!ReadChunkHeader(IH
))
75 case MAKE_ID('F','V','E','R'):
77 fprintf(stdout
, "Version=");
81 Size
=ReadChunkData(IH
, Buffer
, 127);
88 fprintf(stdout
, "%s", Buffer
);
91 fprintf(stdout
, "\n");
97 case MAKE_ID('N','A','M','E'):
99 fprintf(stdout
, "Name=");
103 Size
=ReadChunkData(IH
, Buffer
, 127);
110 fprintf(stdout
, "%s", Buffer
);
113 fprintf(stdout
, "\n");
119 case MAKE_ID('D','T','H','D'):
121 struct DataTypeHeader
*DTH
;
122 unsigned char *DTHDBuffer
;
124 DTHDBuffer
=malloc(IH
->BytesLeftInChunk
);
130 Size
=IH
->BytesLeftInChunk
;
131 if(!(ReadChunkData(IH
, DTHDBuffer
, IH
->BytesLeftInChunk
)==Size
))
133 free((void *) DTHDBuffer
);
137 DTH
=(struct DataTypeHeader
*) DTHDBuffer
;
139 DTH
->dth_Name
= (uint8_t *) Swap32IfLE(((uint32_t) DTH
->dth_Name
));
140 DTH
->dth_BaseName
= (uint8_t *) Swap32IfLE(((uint32_t) DTH
->dth_BaseName
));
141 DTH
->dth_Pattern
= (uint8_t *) Swap32IfLE(((uint32_t) DTH
->dth_Pattern
));
142 DTH
->dth_Mask
= (uint16_t *) Swap32IfLE(((uint32_t) DTH
->dth_Mask
));
143 DTH
->dth_GroupID
= Swap32IfLE(DTH
->dth_GroupID
);
144 DTH
->dth_ID
= Swap32IfLE(DTH
->dth_ID
);
145 DTH
->dth_MaskLen
= Swap16IfLE(DTH
->dth_MaskLen
);
146 DTH
->dth_Pad
= Swap16IfLE(DTH
->dth_Pad
);
147 DTH
->dth_Flags
= Swap16IfLE(DTH
->dth_Flags
);
148 DTH
->dth_Priority
= Swap16IfLE(DTH
->dth_Priority
);
150 fprintf(stdout
, "BaseName=%s\n", (char *) (((long) DTHDBuffer
) + ((long) DTH
->dth_BaseName
)));
152 fprintf(stdout
, "Pattern=%s\n", (char *) (((long) DTHDBuffer
) + ((long) DTH
->dth_Pattern
)));
154 fprintf(stdout
, "Mask=");
155 for(i
=1; i
<=DTH
->dth_MaskLen
; i
++)
160 mask
= *((unsigned char *) (((long) DTHDBuffer
) + ((long) DTH
->dth_Mask
) + (2*i
-2)));
162 mask
+= *((unsigned char *) (((long) DTHDBuffer
) + ((long) DTH
->dth_Mask
) + (2*i
-1)));
166 fprintf(stdout
, "ANY ");
170 fprintf(stdout
, "0x%x ", mask
);
172 else if (isalnum(mask
))
174 fprintf(stdout
, "'%c' ", mask
);
178 fprintf(stdout
, "0x%x ", mask
);
181 fputc((int) *((char *) (((long) DTHDBuffer
) + ((long) DTH
->dth_Mask
) + (2*i
-1))), stdout
);
184 fprintf(stdout
, "\n");
186 PrintID(DTH
->dth_GroupID
, ID
);
187 fprintf(stdout
, "GroupID=%s\n", ID
);
189 PrintID(DTH
->dth_ID
, ID
);
190 fprintf(stdout
, "ID=%s\n", ID
);
192 fprintf(stdout
, "Flags=");
194 switch(DTH
->dth_Flags
&0x000F)
198 fprintf(stdout
, "DTF_BINARY");
205 fprintf(stdout
, "DTF_ASCII");
212 fprintf(stdout
, "DTF_IFF");
219 fprintf(stdout
, "DTF_MISC");
225 if(DTH
->dth_Flags
& 0x0010)
227 fprintf(stdout
, ",DTF_CASE");
230 if(DTH
->dth_Flags
& 0x1000)
232 fprintf(stdout
, ",DTF_SYSTEM1");
235 fprintf(stdout
, "\n");
237 fprintf(stdout
, "Priority=%hu\n", DTH
->dth_Priority
);
239 free((void *) DTHDBuffer
);
247 PrintID(IH
->ChunkID
, ID
);
248 fprintf(stderr
, "Unsupported chunk : %s\n", ID
);
263 void PrintID(uint32_t ID
, uint8_t *Buffer
)
270 Buffer
[0]=(ID
&0xFF000000)>>24;
271 Buffer
[1]=(ID
&0xFF0000) >>16;
272 Buffer
[2]=(ID
&0xFF00) >> 8;