| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#define FORMAT agt |
| 11 |
#define HOME_PAGE "http://www.ifarchive.org/indexes/if-archiveXprogrammingXagt" |
| 12 |
#define FORMAT_EXT ".agx" |
| 13 |
#define NO_METADATA |
| 14 |
#define NO_COVER |
| 15 |
|
| 16 |
#include "treaty_builder.h" |
| 17 |
#include <ctype.h> |
| 18 |
#include <stdio.h> |
| 19 |
|
| 20 |
|
| 21 |
static char AGX_MAGIC[4] = { 0x58, 0xC7, 0xC1, 0x51 }; |
| 22 |
|
| 23 |
|
| 24 |
static int32 read_agt_short(unsigned char *sf) |
| 25 |
{ |
| 26 |
return sf[0] | (int32) sf[1]<<8; |
| 27 |
} |
| 28 |
static int32 read_agt_int(unsigned char *sf) |
| 29 |
{ |
| 30 |
return (read_agt_short(sf+2) << 16) | read_agt_short(sf); |
| 31 |
|
| 32 |
} |
| 33 |
|
| 34 |
static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent) |
| 35 |
{ |
| 36 |
int32 l, game_version, game_sig; |
| 37 |
unsigned char *sf=(unsigned char *)story_file; |
| 38 |
|
| 39 |
|
| 40 |
l=read_agt_int(sf+32); |
| 41 |
if (extent<l+6) return INVALID_STORY_FILE_RV; |
| 42 |
game_version = read_agt_short(sf+l); |
| 43 |
game_sig=read_agt_int(sf+l+2); |
| 44 |
ASSERT_OUTPUT_SIZE(19); |
| 45 |
sprintf(output,"AGT-%05d-%08X",game_version,game_sig); |
| 46 |
return 1; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
static int32 claim_story_file(void *story_file, int32 extent) |
| 53 |
{ |
| 54 |
|
| 55 |
|
| 56 |
if (extent<36 || memcmp(story_file,AGX_MAGIC,4)) return INVALID_STORY_FILE_RV; |
| 57 |
return VALID_STORY_FILE_RV; |
| 58 |
|
| 59 |
} |