if(!strncmp(str,"palette:",7))                 fillPalette(str,sub);
if(!strncmp(str,"palette:",7)) { fillPalette(str,sub); sub->hasPalette=1; }
uint8_t vobSubRead(char *filename,int index,VobSubInfo **info){FILE            *file=NULL;uint32_t        nb_lines;VobSubInfo      *sub=NULL;uint8_t         success=0;uint32_t        line=0,l;char            str[1024];char            *dup;int             language=0;        if(!filename)        {                printf("Null file ?\n");                return 0;        }        *info=NULL;        file=fopen(filename,"rt");        if(!file)         {                printf("Could not open %s file\n",filename);                return 0;        }        nb_lines=countLine(file,index);        if(!nb_lines)        {                printf("Empty file\n");                 goto subAbort;        }        // Try to read the file        sub=new VobSubInfo;        memset(sub,0,sizeof(VobSubInfo));        //        sub->nbLines=nb_lines;        sub->lines=new vobSubLine[nb_lines];        memset(sub->lines,0,sizeof(vobSubLine)*nb_lines);        printf("Rebuilding %d lines of subs\n",nb_lines);                while(line<nb_lines)        {                fgets(str,1023,file);                 if(!strncmp(str,"palette:",7))                 fillPalette(str,sub);                else                 {                        if(!strncmp(str,"timestamp: ",10) && language)                                {                                fillLine(str,sub,line);                                line++;                        }                        else                        {                                if(!strncmp(str,"id:",3))       // Catch language/index                                {                                  int  l;                                  char s[50];                                  sscanf(str,"id: %s index: %d",s,&l);                                  printf("Found lang : %s index %d while searching %d\n",s,l,index);                                  if(l==index) language=1;                                  else language=0;                                                                                                                                              }                                else                                {                                        if(!strncmp(str,"size:",5))       // Catch original screen dimension                                        {                                                sscanf(str,"size:%lux%lu",&(sub->width),&(sub->height));                                        }                                                                }                                                        }                }        }subSuccess:                success=1;subAbort:                if(success)        {                *info=sub;        }        else        {                destroySubInfo( sub);                }        fclose(file);        return success;}