/* to compile do: gcc -o wbzd wbzd.c */ /* This is a program to get a photo's description from a wbz file and output */ /* a suitable filename; blanks to underscores and all lower case */ #include #define ADOBE "Adobe" #define ALGO1 "WWBB0000" #define ALGO2 "WWBB1111" #define HDR1 0xFF #define HDR2 0xD8 int main (int argc,char *argv[]) { FILE *fp1, *fp2; char *infile, *outfile; char *filenames[100]; char isalgo1[9]; char isadobe[6]; int letter,flag=0,flag1=0,ishdr1=0,ishdr2=0; int verwb=0,cnt=0,cnt1=0,A[100],B[100],counter=0; int magicvalue=0,C[100]; int getfilenames(char *[],FILE *); if(argc >= 1) { infile = argv[1]; } else { printf("Usage: wbz2 inputfile.wbz\n"); exit (1); } if((fp1 =fopen(infile,"r")) == NULL) { printf("Can't open infile %s\n",infile); exit (0); } getfilenames(filenames,fp1); /* printf("offset %x\n",ftell(fp1)); */ } int getfilenames(char *filenames[],FILE *fp1) { int countlines=0,count=0,it_cnt=0,pig=0,letter; char imagetitle[16],nme[50]; while((letter = fgetc(fp1)) != EOF) { if(letter==0x53) { imagetitle[it_cnt++]=letter; while(it_cnt<15 && (letter = fgetc(fp1)) != EOF) { imagetitle[it_cnt++]=letter; } imagetitle[it_cnt]='\0'; it_cnt=0; if(strcmp("STR_ImageTitle=",imagetitle)==0) { count=0; while((letter = fgetc(fp1)) != EOF && letter > 0x13) /* 0D 0A end of title, 0x13 CR in there */ { if(letter == 0x20)letter=0x5f; if(letter != 0x2c){ if(letter>64 && letter<91)letter+=32; nme[count++]=letter; } } nme[count]='\0'; printf("%s.jpg\n",nme); countlines++; } else{fseek(fp1,-14L,SEEK_CUR);} } } return countlines; }