Debian Codegraph @

support/babel/advsys.c

raw symbols SCIP
1 /* advsys.c Treaty of Babel module for AdvSys 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 advsys
11 #define HOME_PAGE "http://www.ifarchive.org/if-archive/programming/advsys/"
12 #define FORMAT_EXT ".dat"
13 #define NO_METADATA
14 #define NO_COVER
15
16 #include "treaty_builder.h"
17 #include <ctype.h>
18 #include <stdio.h>
19
20 /* IFIDs for AdvSys are formed by prepending ADVSYS- to the default
21 MD5 ifid
22 */
23 static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent)
24 {
25 /* This line suppresses a warning from the borland compiler */
26 if (story_file || extent) { }
27 ASSERT_OUTPUT_SIZE(8);
28 strcpy(output,"ADVSYS-");
29 return INCOMPLETE_REPLY_RV;
30
31 }
32
33 /* The Advsys claim algorithm: bytes 2-8 of the file contain the
34 text "ADVSYS", unobfuscated in the following way:
35 30 is added to each byte, then the bits are reversed
36 */
37 static int32 claim_story_file(void *story_file, int32 extent)
38 {
39 char buf[7];
40 int i;
41 if (extent >=8)
42 {
43 for(i=0;i<6;i++)
44 buf[i]=~(((char *)story_file)[i+2]+30);
45 buf[6]=0;
46 if (strcmp(buf,"ADVSYS")==0) return VALID_STORY_FILE_RV;
47 }
48 return INVALID_STORY_FILE_RV;
49 }