gopher/ftype.txt

104 lines
1.3 KiB
Plaintext

%%
#pragma optimize 79
#pragma noroot
#include <Types.h>
// cp should be a filename w/ .ext
int parse_extension(const char *cp, Word size, Word *ftype, LongWord *atype);
int parse_extension_c(const char *cp, Word *ftype, LongWord *atype)
{
int i;
int pd;
if (!cp || !*cp) return 0;
pd = -1;
for (i = 0; ; ++i)
{
char c;
c = cp[i];
if (c == 0) break;
if (c == '.') pd = i;
}
// pd == position of final .
// i == strlen
if (pd == -1) return 0;
if (pd + 1 >= i) return 0;
pd++; // skip past it...
return parse_extension(cp + pd, i - pd, ftype, atype);
}
// cp is just the extension
int parse_extension(const char *cp, Word size, Word *ftype, LongWord *atype)
{
Word *wp = (Word *)cp;
Word h;
if (!cp || !size) return 0;
h = ((*cp | 0x20) ^ size) & 0x0f;
switch (h)
{
%%
}
return 0;
}
%%
'h' ->
*ftype = 0xb0;
*atype = 0x0008;
return 1;
.
'c' ->
*ftype = 0xb0;
*atype = 0x0008;
return 1;
.
'asm' ->
*ftype = 0xb0;
*atype = 0x0003;
return 1;
.
'pas' ->
*ftype = 0xb0;
*atype = 0x0005;
return 1;
.
'txt' ->
*ftype = 0x04;
*atype = 0x0000;
return 1;
.
'text' ->
*ftype = 0x04;
*atype = 0x0000;
return 1;
.
'shk' ->
*ftype = 0xe0;
*atype = 0x8002;
return 1;
.
'bxy' ->
*ftype = 0xe0;
*atype = 0x8000;
return 1;
.