1 /* executable.c Treaty of Babel module for Z-code files
\r
2 * 2006 By L. Ross Raszewski
\r
4 * This file depends on treaty_builder.h
\r
6 * This file is public domain, but note that any changes to this file
\r
7 * may render it noncompliant with the Treaty of Babel
\r
10 #define FORMAT executable
\r
11 #define HOME_PAGE "http://http://en.wikipedia.org/wiki/Executable"
\r
12 #define FORMAT_EXT ".exe"
\r
16 #include "treaty_builder.h"
\r
20 static char elfmagic[] = { 0x7f, 0x45, 0x4c, 0x46, 0 };
\r
21 static char javamagic[] = { 0xCA, 0xFE, 0xBA, 0xBE, 0 };
\r
22 static char amigamagic[] = { 0, 0, 3, 0xe7, 0 };
\r
23 static char machomagic[] = { 0xFE, 0xED, 0xFA, 0xCE, 0};
\r
30 static struct exetype magic[]= { { "MZ", "MZ", 2 },
\r
31 { elfmagic, "ELF", 4 },
\r
32 { javamagic, "JAVA", 4 },
\r
33 { amigamagic, "AMIGA", 4 },
\r
34 { "#! ", "SCRIPT", 3 },
\r
35 { machomagic, "MACHO",4 },
\r
36 { "APPL", "MAC",4 },
\r
37 { NULL, NULL, 0 } };
\r
39 static char *deduce_magic(void *sf, int32 extent)
\r
42 for(i=0;magic[i].magic;i++)
\r
43 if (extent >= magic[i].len && memcmp(magic[i].magic,sf,magic[i].len)==0)
\r
44 return magic[i].name;
\r
48 static int32 claim_story_file(void *sf, int32 extent)
\r
50 if (deduce_magic(sf,extent)) return VALID_STORY_FILE_RV;
\r
53 static int32 get_story_file_IFID(void *sf, int32 extent, char *output, int32 output_extent)
\r
56 o=deduce_magic(sf,extent);
\r
58 ASSERT_OUTPUT_SIZE((signed) strlen(o)+2);
\r
61 return INCOMPLETE_REPLY_RV;
\r