Merge branch 'master' into browser
[projects/chimara/chimara.git] / babel / tads2.c
diff --git a/babel/tads2.c b/babel/tads2.c
new file mode 100644 (file)
index 0000000..87c1fcc
--- /dev/null
@@ -0,0 +1,100 @@
+/* \r
+ *   tads2.c - Treaty of Babel module for Tads 2 files\r
+ *   \r
+ *   This file depends on treaty_builder.h\r
+ *   \r
+ *   This file is public domain, but note that any changes to this file may\r
+ *   render it noncompliant with the Treaty of Babel\r
+ *   \r
+ *   Modified\r
+ *.   04/15/2006 LRRaszewski - Separated tads2.c and tads3.c \r
+ *.   04/08/2006 LRRaszewski - changed babel API calls to threadsafe versions\r
+ *.   04/08/2006 MJRoberts  - initial implementation\r
+ */\r
+\r
+#define FORMAT tads2\r
+#define HOME_PAGE "http://www.tads.org"\r
+#define FORMAT_EXT ".gam"\r
+\r
+\r
+#include "treaty_builder.h"\r
+#include "tads.h"\r
+\r
+#define T2_SIGNATURE "TADS2 bin\012\015\032"\r
+\r
+#ifndef FALSE\r
+#define FALSE 0\r
+#endif\r
+#ifndef TRUE\r
+#define TRUE 1\r
+#endif\r
+\r
+/*\r
+ *   get a story file's IFID\r
+ */\r
+static int32 get_story_file_IFID(void *story_file, int32 extent,\r
+                                 char *output, int32 output_extent)\r
+{\r
+    /* use the common tads IFID extractor/generator */\r
+    return tads_get_story_file_IFID(story_file, extent,\r
+                                    output, output_extent);\r
+}\r
+\r
+/*\r
+ *   determine if a given story file is one of ours \r
+ */\r
+static int32 claim_story_file(void *story_file, int32 extent)\r
+{\r
+    /* check our signature */\r
+    if (tads_match_sig(story_file, extent, T2_SIGNATURE))\r
+        return VALID_STORY_FILE_RV;\r
+\r
+    /* not one of ours */\r
+    return INVALID_STORY_FILE_RV;\r
+}\r
+\r
+/*\r
+ *   Get the size of the iFiction metadata for the game \r
+ */\r
+static int32 get_story_file_metadata_extent(void *story_file, int32 extent)\r
+{\r
+    /* use the common tads iFiction synthesizer */\r
+    return tads_get_story_file_metadata_extent(story_file, extent);\r
+}\r
+\r
+/*\r
+ *   Get the iFiction metadata for the game\r
+ */\r
+static int32 get_story_file_metadata(void *story_file, int32 extent,\r
+                                     char *buf, int32 bufsize)\r
+{\r
+    /* use the common tads iFiction synthesizer */\r
+    return tads_get_story_file_metadata(story_file, extent, buf,  bufsize);\r
+}\r
+\r
+static int32 get_story_file_cover_extent(void *story_file, int32 story_len)\r
+{\r
+    /* use the common tads cover file extractor */\r
+    return tads_get_story_file_cover_extent(story_file, story_len);\r
+}\r
+\r
+/*\r
+ *   Get the format of the cover art \r
+ */\r
+static int32 get_story_file_cover_format(void *story_file, int32 story_len)\r
+{\r
+    /* use the common tads cover file extractor */\r
+    return tads_get_story_file_cover_format(story_file, story_len);\r
+}\r
+\r
+/*\r
+ *   Get the cover art data \r
+ */\r
+static int32 get_story_file_cover(void *story_file, int32 story_len,\r
+                                  void *outbuf, int32 output_extent)\r
+{\r
+    /* use the common tads cover file extractor */\r
+    return tads_get_story_file_cover(story_file, story_len,\r
+                                     outbuf, output_extent);\r
+}\r
+\r