Debian Codegraph @

support/babel/magscrolls.c

raw symbols SCIP
1 /* magscrolls.c Treaty of Babel module for Z-code files
2 * 2006 By L. Ross Raszewski
3 *
4 * This file depends on treaty_builder.h
5 *
6 * This file is public domain, but note that any changes to this file
7 * may render it noncompliant with the Treaty of Babel
8 */
9
10 #define FORMAT magscrolls
11 #define HOME_PAGE "http://www.if-legends.org/~msmemorial/memorial.htm"
12 #define FORMAT_EXT ".mag"
13 #define NO_COVER
14 #define NO_METADATA
15
16 #include "treaty_builder.h"
17 #include <ctype.h>
18 #include <stdio.h>
19
20 struct maginfo
21 {
22 int gv;
23 char header[21];
24 char *title;
25 int bafn;
26 int year;
27 char *ifid;
28 char *author;
29 char *meta;
30 };
31
32
33 static struct maginfo manifest[] = {
34 { 0, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000",
35 "The Pawn",
36 0,
37 1985,
38 "MAGNETIC-1",
39 "Rob Steggles",
40 },
41 { 1, "\000\004\000\001\007\370\000\000\340\000\000\000\041\064\000\000\040\160\000\000",
42 "Guild of Thieves",
43 0,
44 1987,
45 "MAGNETIC-2",
46 "Rob Steggles",
47 },
48 { 2, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000",
49 "Jinxter",
50 0,
51 1987,
52 "MAGNETIC-3",
53 "Georgina Sinclair and Michael Bywater",
54 },
55 { 4, "\000\004\000\001\045\140\000\001\000\000\000\000\161\017\000\000\035\210\000\001",
56 "Corruption",
57 0,
58 1988,
59 "MAGNETIC-4",
60 "Rob Steggles and Hugh Steers",
61 },
62 { 4, "\000\004\000\001\044\304\000\001\000\000\000\000\134\137\000\000\040\230\000\001",
63 "Fish!",
64 0,
65 1988,
66 "MAGNETIC-5",
67 "John Molloy, Pete Kemp, Phil South, Rob Steggles",
68 },
69 { 4, "\000\003\000\000\377\000\000\000\340\000\000\000\221\000\000\000\036\000\000\001",
70 "Corruption",
71 0,
72 1988,
73 "MAGNETIC-4",
74 "Rob Steggles and Hugh Steers",
75 },
76 { 4, "\000\003\000\001\000\000\000\000\340\000\000\000\175\000\000\000\037\000\000\001",
77 "Fish!",
78 0,
79 1988,
80 "MAGNETIC-5",
81 "John Molloy, Pete Kemp, Phil South, Rob Steggles",
82 },
83 { 4, "\000\003\000\000\335\000\000\000\140\000\000\000\064\000\000\000\023\000\000\000",
84 "Myth",
85 0,
86 1989,
87 "MAGNETIC-6",
88 "Paul Findley",
89 },
90 { 4, "\000\004\000\001\122\074\000\001\000\000\000\000\114\146\000\000\057\240\000\001",
91 "Wonderland",
92 0,
93 1990,
94 "MAGNETIC-7",
95 "David Bishop",
96 },
97 { 0, "0", NULL, 0, 0, NULL, NULL }
98 };
99
100 static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent)
101 {
102 int i;
103 unsigned char *sf=(unsigned char *)story_file;
104 if (extent < 42) return INVALID_STORY_FILE_RV;
105
106 for(i=0;manifest[i].title;i++)
107 if ((sf[13]<3 && manifest[i].gv==sf[13]) || memcmp(manifest[i].header,sf+12,20)==0)
108 {
109 ASSERT_OUTPUT_SIZE(((int32) strlen(manifest[i].ifid)+1));
110 strcpy(output,manifest[i].ifid);
111 return 1;
112 }
113 strcpy(output,"MAGNETIC-");
114 return INCOMPLETE_REPLY_RV;
115 }
116
117 static int32 claim_story_file(void *story_file, int32 extent)
118 {
119 if (extent<42 ||
120 memcmp(story_file,"MaSc",4)
121 ) return INVALID_STORY_FILE_RV;
122 return VALID_STORY_FILE_RV;
123 }
124