Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / iffparse / goodtype.c
blob2a5cdad7abd352b3a6120f15e63c146329c632e3
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 0
7 #include <aros/debug.h>
8 #include "iffparse_intern.h"
10 #define DEBUG_GOODTYPE(x) ;
12 /*****************************************************************************
14 NAME */
15 #include <proto/iffparse.h>
17 AROS_LH1(LONG, GoodType,
19 /* SYNOPSIS */
20 AROS_LHA(LONG, type, D0),
22 /* LOCATION */
23 struct Library *, IFFParseBase, 44, IFFParse)
25 /* FUNCTION
26 Determines whether a IFF chunk type is valid according to the IFF specification.
28 INPUTS
29 type - An IFF chunk type to be tested.
31 RESULT
32 TRUE - type is valid.
33 FALSE - otherwise.
35 NOTES
36 Assumes the input type to be in local byte order.
38 EXAMPLE
40 BUGS
42 SEE ALSO
43 GoodID()
45 INTERNALS
47 *****************************************************************************/
49 AROS_LIBFUNC_INIT
51 UBYTE theId[4];
52 WORD i;
54 /* How can it be a valid type if its not a valid ID */
55 if(!GoodID(type))
57 DEBUG_GOODTYPE(bug("badtype 1\n"));
58 return (FALSE);
61 theId[0] = type >> 24;
62 theId[1] = type >> 16;
63 theId[2] = type >> 8;
64 theId[3] = type;
66 for(i=0; i < 4; i++)
68 /* Greater than Z, not a type */
69 if(theId[i] > 'Z')
71 DEBUG_GOODTYPE(bug("badtype 2\n"));
72 return (FALSE);
75 /* If its less than 'A', and not in '0'..'9',
76 then if its not a space its not valid. */
77 if( (theId[i] < 'A')
78 && ((theId[i] < '0') || (theId[i] > '9'))
79 && (theId[i] != ' ')
82 DEBUG_GOODTYPE(bug("badtype 3\n"));
83 return (FALSE);
86 /* Must be valid, try the next one */
89 DEBUG_GOODTYPE(bug("goodtype\n"));
90 return (TRUE);
92 AROS_LIBFUNC_EXIT
93 } /* GoodType */