Merge branch 'master' into gtk3
[projects/chimara/chimara.git] / babel / tads3.c
1 /* \r
2  *   tads3.c - Treaty of Babel module for Tads 3 files\r
3  *   \r
4  *   This file depends on treaty_builder.h\r
5  *   \r
6  *   This file is public domain, but note that any changes to this file may\r
7  *   render it noncompliant with the Treaty of Babel\r
8  *   \r
9  *   Modified\r
10  *.   04/15/2006 LRRaszewski - Separated tads2.c and tads3.c \r
11  *.   04/08/2006 LRRaszewski - changed babel API calls to threadsafe versions\r
12  *.   04/08/2006 MJRoberts  - initial implementation\r
13  */\r
14 \r
15 #define FORMAT tads3\r
16 #define HOME_PAGE "http://www.tads.org"\r
17 #define FORMAT_EXT ".t3"\r
18 \r
19 \r
20 #include "treaty_builder.h"\r
21 #include "tads.h"\r
22 \r
23 #define T3_SIGNATURE "T3-image\015\012\032"\r
24 \r
25 #ifndef FALSE\r
26 #define FALSE 0\r
27 #endif\r
28 #ifndef TRUE\r
29 #define TRUE 1\r
30 #endif\r
31 \r
32 /*\r
33  *   get a story file's IFID \r
34  */\r
35 static int32 get_story_file_IFID(void *story_file, int32 extent,\r
36                                  char *output, int32 output_extent)\r
37 {\r
38     /* use the common tads IFID extractor/generator */\r
39     return tads_get_story_file_IFID(story_file, extent,\r
40                                     output, output_extent);\r
41 }\r
42 \r
43 /*\r
44  *   determine if a given story file is one of ours \r
45  */\r
46 static int32 claim_story_file(void *story_file, int32 extent)\r
47 {\r
48     /* check our signature */\r
49     if (tads_match_sig(story_file, extent, T3_SIGNATURE))\r
50         return VALID_STORY_FILE_RV;\r
51 \r
52     /* not one of ours */\r
53     return INVALID_STORY_FILE_RV;\r
54 }\r
55 \r
56 /*\r
57  *   Get the size of the iFiction metadata for the game \r
58  */\r
59 static int32 get_story_file_metadata_extent(void *story_file, int32 extent)\r
60 {\r
61     /* use the common tads iFiction synthesizer */\r
62     return tads_get_story_file_metadata_extent(story_file, extent);\r
63 }\r
64 \r
65 /*\r
66  *   Get the iFiction metadata for the game\r
67  */\r
68 static int32 get_story_file_metadata(void *story_file, int32 extent,\r
69                                      char *buf, int32 bufsize)\r
70 {\r
71     /* use the common tads iFiction synthesizer */\r
72     return tads_get_story_file_metadata(story_file, extent, buf,  bufsize);\r
73 }\r
74 \r
75 static int32 get_story_file_cover_extent(void *story_file, int32 story_len)\r
76 {\r
77     /* use the common tads cover file extractor */\r
78     return tads_get_story_file_cover_extent(story_file, story_len);\r
79 }\r
80 \r
81 /*\r
82  *   Get the format of the cover art \r
83  */\r
84 static int32 get_story_file_cover_format(void *story_file, int32 story_len)\r
85 {\r
86     /* use the common tads cover file extractor */\r
87     return tads_get_story_file_cover_format(story_file, story_len);\r
88 }\r
89 \r
90 /*\r
91  *   Get the cover art data \r
92  */\r
93 static int32 get_story_file_cover(void *story_file, int32 story_len,\r
94                                   void *outbuf, int32 output_extent)\r
95 {\r
96     /* use the common tads cover file extractor */\r
97     return tads_get_story_file_cover(story_file, story_len,\r
98                                      outbuf, output_extent);\r
99 }\r
100 \r