Correction :
After some deletions/uploads, I see some inconsistencies in the algorithm, as Greg also noticed. It seems that every 0xFF is a record seperator. It makes sense, as the db_index now starts at 0...
See the new code :

#include <fcntl.h>
#include <stdio.h>

#define DBFILE "/empeg/var/database"
#define TAGFILE "/empeg/var/tags"

int main(int argc, char *argv[])
{
unsigned char c;
char s[2048];
char *tags[50];
int i,end_entry,db_index;
FILE *fp,*fp2;

fp=fopen(TAGFILE, "rb");
i=0;
while (fgets(s,sizeof(s), fp) != NULL) {
s[strlen(s)-1]='\0';
tags[i++]=(char *)strdup(s);
}
fclose(fp);
i=0;
db_index=0;
fp=fopen(DBFILE, "rb");
while ( fread(&c,1,1,fp) > 0 ) {
if ( c == 0xFF ) {
end_entry=1;
db_index++;
} else {
if (end_entry) {
printf("--------------------------------\n\n");
i=db_index << 4 | 1;
printf("****************************\n");
printf("opening /drive0/fids/%x\n",i);
printf("index: %d\n",db_index);
sprintf(s,"/drive0/fids/%x",i);
fp2=fopen(s, "rb");
if ( fp2 != NULL ) {
while (fgets(s,sizeof(s), fp2) != NULL) {
printf("%s",s);
}
fclose(fp2);
}
printf("****************************\n");
end_entry=0;
}
i=c;
fread(&c,1,1,fp);
fread(s,1,c,fp);
s[c]='\0';
printf("%s : %s\n",tags[ i ],s);
}
}
fclose(fp);
}
_________________________
Frank van Gestel