3
3
4
4
#include <Types.h>
5
5
6
- int parse_extension (const char * cp , Word * ftype , LongWord * atype )
6
+ // cp should be a filename w/ .ext
7
+ int parse_extension (const char * cp , Word size , Word * ftype , LongWord * atype );
8
+ int parse_extension_c (const char * cp , Word * ftype , LongWord * atype )
7
9
{
8
- Word size ;
9
- Word * wp = (Word * )cp ;
10
- Word h ;
11
10
int i ;
12
11
int pd ;
13
12
14
- * ftype = 0 ;
15
- * atype = 0 ;
16
-
17
-
18
13
if (!cp || !* cp ) return 0 ;
19
14
20
15
pd = -1 ;
@@ -34,23 +29,24 @@ int parse_extension(const char *cp, Word *ftype, LongWord *atype)
34
29
if (pd + 1 >= i ) return 0 ;
35
30
pd ++ ; // skip past it...
36
31
37
- cp += pd ;
38
- size = i - pd ;
32
+ return parse_extension (cp + pd , i - pd , ftype , atype );
33
+ }
34
+
35
+ // cp is just the extension
36
+ int parse_extension (const char * cp , Word size , Word * ftype , LongWord * atype )
37
+ {
38
+ Word * wp = (Word * )cp ;
39
+ Word h ;
40
+
41
+
42
+ if (!cp || !size ) return 0 ;
43
+
39
44
40
45
h = ((* cp | 0x20 ) ^ size ) & 0x0f ;
41
46
42
47
switch (h )
43
48
{
44
49
case 0x00 :
45
- // text
46
- if (size == 4
47
- && (wp [0 ] | 0x2020 ) == 0x6574 // 'te'
48
- && (wp [1 ] | 0x2020 ) == 0x7478 // 'xt'
49
- ) {
50
- * ftype = 0x04 ;
51
- * atype = 0x0000 ;
52
- return 1 ;
53
- }
54
50
// shk
55
51
if (size == 3
56
52
&& (wp [0 ] | 0x2020 ) == 0x6873 // 'sh'
@@ -60,6 +56,15 @@ int parse_extension(const char *cp, Word *ftype, LongWord *atype)
60
56
* atype = 0x8002 ;
61
57
return 1 ;
62
58
}
59
+ // text
60
+ if (size == 4
61
+ && (wp [0 ] | 0x2020 ) == 0x6574 // 'te'
62
+ && (wp [1 ] | 0x2020 ) == 0x7478 // 'xt'
63
+ ) {
64
+ * ftype = 0x04 ;
65
+ * atype = 0x0000 ;
66
+ return 1 ;
67
+ }
63
68
break ;
64
69
65
70
case 0x01 :
0 commit comments