#include #include #include #include #include void convertSegment(int segNum); void getStats(); FILE *fpin,*fpout,*fptest,*fpinclude; int totalSegments=0; int totalFrames=0; char infile[255]; int getNextNum(char *s, char *n,int l) { int j=0; while(!isdigit(s[l])&&s[l]!='.'&&s[l]!='-')l++; while (isdigit(s[l])||s[l]=='.'||s[l]=='-'){ n[j]=s[l]; j++;l++; } n[j]=NULL; return(l); } void getStats() { static int first=1; char seg[255]="Segment", astring[255],tmp[255],tmp1[255]; if ((fpin = fopen(infile, "r"))==NULL) { printf("ERROR: can't open %s\n",infile); exit(0);} while(!feof(fpin)){ fgets(tmp,255,fpin); //read first line sscanf(tmp,"%s",astring); if((strncmp(seg,tmp,5))==0){ // found start of segement totalSegments++; if(first){ first=0; fgets(tmp,255,fpin); //read second line // get totalFrames form 2nd line getNextNum(tmp,tmp1,9); printf("tmp1 %s\n",tmp1); totalFrames=atoi(tmp1); printf("totalFrames %d\n",totalFrames); } } } fprintf(fpout,"#define TOTAL_SEGMENTS %d\n#define TOTAL_FRAMES %d\n\n",totalSegments,totalFrames); fclose(fpin); } void main(int argc,char *argv[]) { int i; char string[10]; strcpy(infile,*++argv); if ((fpout = fopen("motion.h", "w+"))==NULL) { printf("ERROR: can't open %s\n","motion.h");exit(0);} if ((fptest = fopen("mydat.c", "w+"))==NULL) { printf("ERROR: can't open %s\n","mydat.c");exit(0);} if ((fpinclude = fopen("frame.h", "w+"))==NULL) { printf("ERROR: can't open %s\n","frame.h");exit(0);} getStats(); if ((fpin = fopen(infile, "r"))==NULL) { printf("ERROR: can't open input .bva file %s\n",infile); exit(0);} for(i=0;i