Thread

Reading Cache IDX / DAT's (Sdk)

Reading Cache IDX / DAT's // Sdk

1  |  

strike rapier

Jun 14, 2002, 3:38pm
Hello Everyone :)

Im in the process of designing a tool that can convert between Propdump,
Xelagot Dump, FireStorm OB and AW Cache.

Ive managed to convert everything to everything else except I cannot work
out how to read from the cache, which would be a great thing as I could use
it for cache changing and manipulating using my own FireStorm DB system.

If possable, could someone help me understand how to extract information
from cache IDX / DAT files in Visual Basic terms. I know Andras has
acomplished it in C or something allong those lines but id like to be able
to do it in VB.

- Mark

ananas

Jun 14, 2002, 6:15pm
As far as I know, Andras uses the original C-Tree libraries,
but http://www.faircom.com/sales/pricing2.shtml ...

This code accesses the telegram.dat through telegram.idx,
maybe this helps. It is my telegram to text converter.


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>

#pragma pack (1)

typedef struct
{
unsigned long Follow;
long Dummy;
short Anz;
char Dummy1[7];
} BlockHead;

typedef struct
{
unsigned char IsRead;
unsigned long Offset;
time_t Timestamp;
unsigned long Receiver;
char Sender[17];
} IdxEntry;

typedef struct
{
unsigned short fafa;
unsigned long Len;
unsigned long Len1;
unsigned char Dummy;
} DatEntry;


main ()
{
FILE *idx, *dat, *txt;
IdxEntry sIdx;
DatEntry sDat;
BlockHead sBlock;
char Buffer[512];
unsigned long Count=0L, BlockStart=0x0200;
struct tm sGMT;
short i;

if (!(idx = fopen ("telegram.idx", "rb")))
{
fputs ("Hey, where's telegram.idx ???", stderr);
exit(-1);
}
if (!(dat = fopen ("telegram.dat", "rb")))
{
fputs ("Hey, where's telegram.dat ???", stderr);
exit(-1);
}
if (!(txt = fopen ("telegram.txt", "wt")))
{
fputs ("ARGH, couldn't create telegram.txt !", stderr);
exit(-1);
}

while ((BlockStart>0) && ! fseek (idx, BlockStart, SEEK_SET) )
{
if (!fread (&sBlock, 1, sizeof (sBlock), idx))
break;
for (i=0; i<sBlock.Anz; i++)
{
memset (&sIdx, 0, sizeof (sIdx));
memset (&sDat, 0, sizeof (sDat));
memset (Buffer, 0, sizeof (Buffer));

fread (&sIdx, 1, sizeof (sIdx)-1, idx);

Count ++;
sIdx.Sender[16]='\0';

_gmtime (&sIdx.Timestamp, &sGMT);

fprintf (txt, "%04d-%02d-%02d\t%2d:%02d:%02d\t"
, sGMT.tm_year+1900, sGMT.tm_mon+1, sGMT.tm_mday
, sGMT.tm_hour, sGMT.tm_min, sGMT.tm_sec);
fprintf (txt, "%-16s\t%ld\n", sIdx.Sender, sIdx.Receiver);

fseek (dat, sIdx.Offset, SEEK_SET);
fread (&sDat, 1, sizeof (sDat), dat);
fread (Buffer, min (sizeof (Buffer), sDat.Len1-1), 1, dat);
fprintf (txt, "%s\n\n", Buffer);
}
BlockStart = sBlock.Follow;
}
fclose (txt);
fclose (dat);
fclose (idx);

printf ("%d telegrams converted\n", Count);
}




[View Quote]

jerme

Jun 15, 2002, 3:35am
That looks a little messy. What's up with all the structs? I guess it just
looks weird because it's the old C syntax...

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jeremy Booker - Owner
JTech Web Systems
www.JTechWebSystems.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[View Quote]

ananas

Jun 15, 2002, 4:10am
The structs directly represent the internal file structure
of the IDX/DAT headers and entries. That's why you can
just use one "read" command to fetch the informations at
once instead of reading each variable separate.

btw.: in C++ structs still are useful

[View Quote]

1  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn