Пример #1
0
static int32 get_story_file_extension(void *sf, int32 extent, char *out, int32 output_extent)
{
 int v;
 if (!extent) return INVALID_STORY_FILE_RV;
 v= ((char *) sf)[0];
 if (v>9) ASSERT_OUTPUT_SIZE(5);
 else ASSERT_OUTPUT_SIZE(4);
 sprintf(out,".z%d",v);
 return 3+(v>9);

}
Пример #2
0
static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent)
{
 char *ifid=NULL;
 int i=get_l9_version((unsigned char *)story_file, extent, &ifid);
 if (!i) return INVALID_STORY_FILE_RV;
 if (ifid)
 {
   ASSERT_OUTPUT_SIZE((signed) strlen(ifid)+1);
   strcpy(output,ifid);
   return 1;
 }
 ASSERT_OUTPUT_SIZE(10);
 sprintf(output,"LEVEL9-%d-",i);
 return INCOMPLETE_REPLY_RV;
}
Пример #3
0
static int32 get_story_file_cover(void *blorb_file, int32 extent, void *output, int32 output_extent)
{
 uint32 i,j;
 if (!blorb_get_cover(blorb_file, extent,&i,&j)) return NO_REPLY_RV;
 ASSERT_OUTPUT_SIZE((int32) j);
 memcpy(output,(char *)blorb_file+i,j);
 return j;
}
Пример #4
0
static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent)
{

 if (story_file || extent) { }
 ASSERT_OUTPUT_SIZE(6);
 strcpy(output,"ALAN-");
 return INCOMPLETE_REPLY_RV;
}
Пример #5
0
static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent)
{
 uint32 i,j;
 char ser[7];
 char buffer[32];


 if (extent<0x1D) return INVALID_STORY_FILE_RV;
 memcpy(ser, (char *) story_file+0x12, 6);
 ser[6]=0;
 /* Detect vintage story files */
 if (!(ser[0]=='8' || ser[0]=='9' ||
     (ser[0]=='0' && ser[1]>='0' && ser[1]<='5')))
 {
  for(i=0;i<(uint32) extent-7;i++) if (memcmp((char *)story_file+i,"UUID://",7)==0) break;
  if (i<(uint32) extent) /* Found explicit IFID */
  {
   for(j=i+7;j<(uint32)extent && ((char *)story_file)[j]!='/';j++);
   if (j<(uint32) extent)
   {
    i+=7;
    ASSERT_OUTPUT_SIZE((int32) (j-i));
    memcpy(output,(char *)story_file+i,j-i);
    output[j-i]=0;
    return 1;
   }
  }
 }
 /* Did not find intact IFID.  Build one */
 i=((unsigned char *)story_file)[2] << 8 |((unsigned char *)story_file)[3];
 for(j=0;j<6;j++)
  if (!isalnum(ser[j])) ser[j]='-';

 j=((unsigned char *)story_file)[0x1C] << 8 |((unsigned char *)story_file)[0x1D];

 if (strcmp(ser,"000000") && isdigit(ser[0]) && ser[0]!='8')
  sprintf(buffer,"ZCODE-%d-%s-%04X",i,ser,j);
 else
  sprintf(buffer,"ZCODE-%d-%s",i,ser);

 ASSERT_OUTPUT_SIZE((signed) strlen(buffer)+1);
 strcpy((char *)output,buffer);
 return 1;

}
Пример #6
0
static int32 get_story_file_metadata(void *blorb_file, int32 extent, char *output, int32 output_extent)
{
 uint32 i,j;
 if (!blorb_get_chunk(blorb_file, extent,"IFmd",&i,&j)) return NO_REPLY_RV;
 ASSERT_OUTPUT_SIZE((int32) j+1);
 memcpy(output,(char *)blorb_file+i,j);
 output[j]=0;
 return j+1;
}
Пример #7
0
static int32 get_story_format(void *blorb_file, int32 extent, char *output, int32 output_extent)
{
 char *o;
 o=blorb_get_story_format(blorb_file, extent);
 if (!o) return NO_REPLY_RV;
 ASSERT_OUTPUT_SIZE((signed) strlen(o)+1);
 strcpy(output,o);
 return strlen(o)+1;
}
Пример #8
0
/* IFIDs for AdvSys are formed by prepending ADVSYS- to the default
   MD5 ifid
*/
static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent)
{
 /* This line suppresses a warning from the borland compiler */
 if (story_file || extent) { }
 ASSERT_OUTPUT_SIZE(8);
 strcpy(output,"ADVSYS-");
 return INCOMPLETE_REPLY_RV;

}
Пример #9
0
static int32 get_story_file_IFID(void *sf, int32 extent, char *output, int32 output_extent)
{
 char *o;
 o=deduce_magic(sf,extent);
 if (!o) return 0;
 ASSERT_OUTPUT_SIZE((signed) strlen(o)+2);
 strcpy(output,o);
 strcat(output,"-");
 return INCOMPLETE_REPLY_RV;
}
Пример #10
0
static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent)
{
 int32 i,j, k;
 char ser[7];
 char buffer[32];


 if (extent<256) return INVALID_STORY_FILE_RV;
 for(i=0;i<extent-7;i++) if (memcmp((char *)story_file+i,"UUID://",7)==0) break;
 if (i<extent) /* Found explicit IFID */
  {
   for(j=i+7;j<extent && ((char *)story_file)[j]!='/';j++);
   if (j<extent)
   {
    i+=7;
    ASSERT_OUTPUT_SIZE(j-i);
    memcpy(output,(char *)story_file+i,j-i);
    output[j-i]=0;
    return 1;
   }
  }

 /* Did not find intact IFID.  Build one */

 j=read_int((unsigned char *)story_file+32);
 k=read_int((unsigned char *)story_file+12);
 if (memcmp((char *)story_file+36,"Info",4)==0)
 { /* Inform generated */
  char *bb=(char *)story_file+52;
  k= (int) bb[0]<<8 | (int) bb[1];
  memcpy(ser,bb+2,6);
  ser[6]=0;
  for(i=0;i<6;i++) if (!isalnum(ser[i])) ser[i]='-';
  sprintf(buffer,"GLULX-%u-%s-%04X",k,ser,j);
 }
 else
  sprintf(buffer,"GLULX-%08X-%08X",k,j);

 ASSERT_OUTPUT_SIZE((signed) strlen(buffer)+1);
 strcpy((char *)output,buffer);
 return 1;

}
Пример #11
0
static int32 get_story_file(void *blorb_file, int32 extent, void *output, int32 output_extent)
{
 uint32 i,j;
 if (blorb_get_resource(blorb_file, extent, "Exec", 0, &i, &j))
 {
  ASSERT_OUTPUT_SIZE((int32) j);
  memcpy(output,(char *)blorb_file+i,j);
  return j;
 }
 return NO_REPLY_RV;

}
Пример #12
0
static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent)
{
 int32 l, game_version, game_sig;
 unsigned char *sf=(unsigned char *)story_file;

 /* Read the position of the game desciption block */
 l=read_agt_int(sf+32);
 if (extent<l+6) return INVALID_STORY_FILE_RV;
 game_version = read_agt_short(sf+l);
 game_sig=read_agt_int(sf+l+2);
 ASSERT_OUTPUT_SIZE(19);
 sprintf(output,"AGT-%05d-%08X",game_version,game_sig);
 return 1;
}
Пример #13
0
static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent)
{
 int i;
 unsigned char *sf=(unsigned char *)story_file;
 if (extent < 42) return INVALID_STORY_FILE_RV;

 for(i=0;manifest[i].title;i++)
  if ((sf[13]<3 && manifest[i].gv==sf[13]) || memcmp(manifest[i].header,sf+12,20)==0)
   {
    ASSERT_OUTPUT_SIZE(((int32) strlen(manifest[i].ifid)+1));
    strcpy(output,manifest[i].ifid);
    return 1;
   }
 strcpy(output,"MAGNETIC-");
 return INCOMPLETE_REPLY_RV;
}
Пример #14
0
static int32 get_story_file_IFID(void *story_file, int32 extent, char *output, int32 output_extent)
{
 int adv;
 unsigned char buf[4];
 unsigned char *sf=(unsigned char *)story_file;
 vbr_state=VB_INIT;

 if (extent <12) return INVALID_STORY_FILE_RV;

 buf[3]=0;
 /* Burn the first 8 bytes of translation */
 for(adv=0;adv<8;adv++) taf_translate(0);
 /* Bytes 8-11 contain the Adrift version number in the formay N.NN */
 buf[0]=taf_translate(sf[8]);
 taf_translate(0);
 buf[1]=taf_translate(sf[10]);
 buf[2]=taf_translate(sf[11]);
 adv=atoi((char *) buf);
 ASSERT_OUTPUT_SIZE(12);
 sprintf(output,"ADRIFT-%03d-",adv);
 return INCOMPLETE_REPLY_RV;

}