use the correct targets to build the drivers so they can be disabled as appropriate.
[AROS.git] / tools / dtdesc / examinedtdesc.c
blob47e5e88419009de76671c076cdf3b46dc0698aae
1 /*
2 Copyright © 2000, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: DataTypesDescriptorExaminator
6 Lang: English.
7 */
9 /*
10 * includes
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <string.h>
16 #include <ctype.h>
18 #include <c_iff.h>
20 #include "dtdesc.h"
23 * prototypes
26 void PrintID(uint32_t ID, uint8_t *Buffer);
29 * functions
32 int main(int argc, char **argv)
34 struct IFFHandle *IH;
35 char Buffer[128];
36 long Size;
37 uint8_t ID[5];
38 int i;
40 if(!(argc==2))
42 fprintf(stderr, "usage: %s datatypedescriptor\n", argv[0]);
44 return(0);
47 IH=OpenIFF(argv[1]);
48 if(!IH)
50 fprintf(stderr, "Could not open %s\n", argv[1]);
52 return(0);
55 if(!(IH->IFFType==MAKE_ID('D','T','Y','P')))
57 fprintf(stderr, "This IFF is not a valid DataType-Descriptor\n");
59 CloseIFF(IH);
60 return(0);
63 fprintf(stdout, "# DataTypeDescription for %s\n", argv[1]);
64 fprintf(stdout, "# Automatically generated by %s\n\n", argv[0]);
66 while(TRUE)
68 if(!ReadChunkHeader(IH))
70 break;
73 switch(IH->ChunkID)
75 case MAKE_ID('F','V','E','R'):
77 fprintf(stdout, "Version=");
79 while(TRUE)
81 Size=ReadChunkData(IH, Buffer, 127);
82 if(Size<=0)
84 break;
87 Buffer[Size]='\0';
88 fprintf(stdout, "%s", Buffer);
91 fprintf(stdout, "\n");
93 SkipChunkData(IH);
94 break;
97 case MAKE_ID('N','A','M','E'):
99 fprintf(stdout, "Name=");
101 while(TRUE)
103 Size=ReadChunkData(IH, Buffer, 127);
104 if(Size<=0)
106 break;
109 Buffer[Size]='\0';
110 fprintf(stdout, "%s", Buffer);
113 fprintf(stdout, "\n");
115 SkipChunkData(IH);
116 break;
119 case MAKE_ID('D','T','H','D'):
121 struct FileDataTypeHeader *DTH;
122 unsigned char *DTHDBuffer;
124 DTHDBuffer=malloc(IH->BytesLeftInChunk);
125 if(!DTHDBuffer)
127 goto TheEnd;
130 Size=IH->BytesLeftInChunk;
131 if(!(ReadChunkData(IH, DTHDBuffer, IH->BytesLeftInChunk)==Size))
133 free((void *) DTHDBuffer);
134 goto TheEnd;
137 DTH=(struct FileDataTypeHeader *) DTHDBuffer;
139 DTH->dth_Name = Swap32IfLE(DTH->dth_Name);
140 DTH->dth_BaseName = Swap32IfLE(DTH->dth_BaseName);
141 DTH->dth_Pattern = Swap32IfLE(DTH->dth_Pattern);
142 DTH->dth_Mask = Swap32IfLE(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", DTHDBuffer + DTH->dth_BaseName);
152 fprintf(stdout, "Pattern=%s\n", DTHDBuffer + DTH->dth_Pattern);
154 fprintf(stdout, "Mask=");
155 for(i=1; i<=DTH->dth_MaskLen; i++)
157 #if 1
158 unsigned short mask;
160 mask = *((unsigned char *) ((DTHDBuffer + DTH->dth_Mask) + (2*i-2)));
161 mask *= 256;
162 mask += *((unsigned char *) ((DTHDBuffer + DTH->dth_Mask) + (2*i-1)));
164 if ((short)mask < 0)
166 fprintf(stdout, "ANY ");
168 else if (mask > 255)
170 fprintf(stdout, "0x%x ", mask);
172 else if (isalnum(mask))
174 fprintf(stdout, "'%c' ", mask);
176 else
178 fprintf(stdout, "0x%x ", mask);
180 #else
181 fputc((int) *((char *) (((long) DTHDBuffer) + ((long) DTH->dth_Mask) + (2*i-1))), stdout);
182 #endif
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)
196 case 0:
198 fprintf(stdout, "DTF_BINARY");
200 break;
203 case 1:
205 fprintf(stdout, "DTF_ASCII");
207 break;
210 case 2:
212 fprintf(stdout, "DTF_IFF");
214 break;
217 case 3:
219 fprintf(stdout, "DTF_MISC");
221 break;
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);
240 SkipChunkData(IH);
241 break;
244 default:
246 #if 0
247 PrintID(IH->ChunkID, ID);
248 fprintf(stderr, "Unsupported chunk : %s\n", ID);
249 #endif /* 0 */
250 SkipChunkData(IH);
251 break;
256 TheEnd:
258 CloseIFF(IH);
260 return(0);
263 void PrintID(uint32_t ID, uint8_t *Buffer)
265 if(!Buffer)
267 return;
270 Buffer[0]=(ID&0xFF000000)>>24;
271 Buffer[1]=(ID&0xFF0000) >>16;
272 Buffer[2]=(ID&0xFF00) >> 8;
273 Buffer[3]=(ID&0xFF);
274 Buffer[4]='\0';