Changeset 23984


Ignore:
Timestamp:
09/29/13 02:19:23 (9 years ago)
Author:
nit
Message:

[titan] cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • titan/titan/global.h

    r23978 r23984  
    671671{
    672672        char *tmpstr = NULL;
    673         struct splitstr *tmparray = NULL;
     673        struct splitstr *array = NULL, *tmparray = NULL;
    674674        *count = 0;
    675675
     
    681681        {
    682682                *count = *count + 1;
    683                 tmparray = (struct splitstr*)realloc(tmparray, sizeof(struct splitstr*) * (*count));
    684                 if(tmparray == NULL)
     683                tmparray = array; array = (struct splitstr*)realloc(array, sizeof(struct splitstr*) * (*count));
     684                if(array == NULL)
     685                {
     686                        free(tmparray);
    685687                        return NULL;
     688                }
    686689     
    687                 (&tmparray[(*count) - 1])->part = oregex(regex, tmpstr);
     690                (&array[(*count) - 1])->part = oregex(regex, tmpstr);
    688691                tmpstr = strtok(NULL, tok);
    689692        }
    690693
    691         return tmparray;
     694        return array;
    692695}
    693696
     
    51985201{
    51995202        FILE *fd = NULL;
    5200         char *fileline = NULL, *buf = NULL, *buf1 = NULL;
    5201         int buf1size = 0, buf1oldsize = 0;
     5203        char *fileline = NULL, *buf = NULL, *tmpbuf = NULL;
     5204        int bufsize = 0, bufoldsize = 0;
    52025205
    52035206        fileline = malloc(MINMALLOC);
     
    52185221        while(fgets(fileline, MINMALLOC, fd) != NULL)
    52195222        {
    5220                 buf = fileline;
    5221 
    52225223                if(flag == 1)
    5223                         if(buf[0] == '#' || buf[0] == '\n')
     5224                        if(fileline[0] == '#' || fileline[0] == '\n')
    52245225                                continue;
    52255226
    5226                 buf1oldsize = buf1size;
    5227                 buf1size += strlen(buf);
    5228                 buf1 = realloc(buf1, buf1size + 1);
    5229                 if(buf1 == NULL)
     5227                bufoldsize = bufsize;
     5228                bufsize += strlen(fileline);
     5229                tmpbuf = buf;   buf = realloc(buf, bufsize + 1);
     5230                if(buf == NULL)
    52305231                {
    52315232                        err("no memory");
    52325233                        free(fileline);
     5234                        free(tmpbuf);
    52335235                        fclose(fd);
    52345236                        return NULL;
    52355237                }
    52365238
    5237                 sprintf(buf1 + buf1oldsize, "%s", buf);
     5239                sprintf(buf + bufoldsize, "%s", fileline);
    52385240        }
    52395241
    52405242        free(fileline);
    52415243        fclose(fd);
    5242         return buf1;
     5244        return buf;
    52435245}
    52445246
     
    52475249        unsigned char byte;
    52485250        FILE *fil = NULL;
    5249         char *zeichen = NULL, *buf = NULL, *buf1 = NULL;
     5251        char *zeichen = NULL, *buf = NULL, *buf1 = NULL, *tmpbuf1 = NULL;
    52505252        int buf1size = 0, buf1oldsize = 0;
    52515253        int Beschreibung;
     
    52765278        Beschreibung = 0;
    52775279        fseek(fil, 12, SEEK_SET); //ersten 12 Byte nicht relevant
    5278         while(!feof(fil)) {
    5279                 byte=fgetc(fil);
    5280 
    5281                 if (byte == 0x4D) {
     5280        while(!feof(fil))
     5281        {
     5282                byte = fgetc(fil);
     5283
     5284                if(byte == 0x4D)
     5285                {
    52825286                        fseek(fil, 4,SEEK_CUR);
    5283                         byte=fgetc(fil);
     5287                        byte = fgetc(fil);
    52845288                        len = byte + 0;
    5285                         byte=fgetc(fil);
    5286                         fgets(zeichen,len,fil);
    5287                         if (byte != 0x05)
    5288                                 sprintf(buf,"%c%s\n", byte,zeichen);
     5289                        byte = fgetc(fil);
     5290                        fgets(zeichen, len, fil);
     5291                        if(byte != 0x05)
     5292                                sprintf(buf, "%c%s\n", byte, zeichen);
    52895293                        else
    5290                                 sprintf(buf,"%s\n", zeichen);
     5294                                sprintf(buf, "%s\n", zeichen);
    52915295
    52925296                        buf1oldsize = buf1size;
    52935297                        buf1size += strlen(buf);
    5294                         buf1 = realloc(buf1, buf1size + 1);
     5298                        tmpbuf1 = buf1; buf1 = realloc(buf1, buf1size + 1);
    52955299                        if(buf1 == NULL)
    52965300                        {
     
    52985302                                free(zeichen);
    52995303                                free(buf);
     5304                                free(tmpbuf1);
    53005305                                fclose(fil);
    53015306                                return NULL;
     
    53045309
    53055310                        //printf("T %s\n", zeichen);
    5306                         byte=fgetc(fil);
     5311                        byte = fgetc(fil);
    53075312                        len = byte + 0;
    5308                         byte=fgetc(fil);
    5309                         fgets(zeichen,len,fil);
    5310                         if (byte != 0x05)
    5311                                 sprintf(buf,"%c%s\n\n", byte,zeichen);
     5313                        byte = fgetc(fil);
     5314                        fgets(zeichen, len, fil);
     5315                        if(byte != 0x05)
     5316                                sprintf(buf,"%c%s\n\n", byte, zeichen);
    53125317                        else
    53135318                                sprintf(buf,"%s\n\n", zeichen);
     
    53155320                        buf1oldsize = buf1size;
    53165321                        buf1size += strlen(buf);
    5317                         buf1 = realloc(buf1, buf1size + 1);
     5322                        tmpbuf1 = buf1; buf1 = realloc(buf1, buf1size + 1);
    53185323                        if(buf1 == NULL)
    53195324                        {
     
    53215326                                free(zeichen);
    53225327                                free(buf);
     5328                                free(tmpbuf1);
    53235329                                fclose(fil);
    53245330                                return NULL;
     
    53275333
    53285334                }
    5329                 else if (byte == 0x4E) {
    5330                         fseek(fil, 6,SEEK_CUR);
    5331                         byte=fgetc(fil);
     5335                else if(byte == 0x4E)
     5336                {
     5337                        fseek(fil, 6, SEEK_CUR);
     5338                        byte = fgetc(fil);
    53325339                        len = byte;
    5333                         byte=fgetc(fil);
    5334                         fgets(zeichen,len,fil);
    5335                         if (Beschreibung == 0) {
    5336                                 if (byte != 0x05)
    5337                                         sprintf(buf,"%c%s", byte,zeichen);
     5340                        byte = fgetc(fil);
     5341                        fgets(zeichen, len, fil);
     5342                        if(Beschreibung == 0)
     5343                        {
     5344                                if(byte != 0x05)
     5345                                        sprintf(buf, "%c%s", byte, zeichen);
    53385346                                else
    5339                                         sprintf(buf,"%s", zeichen);
     5347                                        sprintf(buf, "%s", zeichen);
    53405348                                Beschreibung = 1;
    53415349                        }
    53425350                        else
    53435351                        {
    5344                                 if (byte != 0x05)
    5345                                         sprintf(buf,"%c%s", byte,zeichen);
     5352                                if(byte != 0x05)
     5353                                        sprintf(buf, "%c%s", byte, zeichen);
    53465354                                else
    5347                                         sprintf(buf,"%s", zeichen);
     5355                                        sprintf(buf, "%s", zeichen);
    53485356                        }       
    53495357
    53505358                        buf1oldsize = buf1size;
    53515359                        buf1size += strlen(buf);
    5352                         buf1 = realloc(buf1, buf1size + 1);
     5360                        tmpbuf1 = buf1; buf1 = realloc(buf1, buf1size + 1);
    53535361                        if(buf1 == NULL)
    53545362                        {
     
    53565364                                free(zeichen);
    53575365                                free(buf);
     5366                                free(tmpbuf1);
    53585367                                fclose(fil);
    53595368                                return NULL;
     
    53625371
    53635372                }
    5364                 else {
    5365                         byte=fgetc(fil);
     5373                else
     5374                {
     5375                        byte = fgetc(fil);
    53665376                        len= byte;
    5367                         fgets(zeichen,len+1,fil);
     5377                        fgets(zeichen, len + 1, fil);
    53685378                } 
    53695379        }
     
    57605770{
    57615771        char *tmpstr = NULL;
    5762         struct splitstr *tmparray = NULL;
     5772        struct splitstr *array = NULL, *tmparray = NULL;
    57635773        *count = 0;
    57645774
     
    57705780        {
    57715781                *count = *count + 1;
    5772                 tmparray = (struct splitstr*)realloc(tmparray, sizeof(struct splitstr*) * (*count));
    5773                 if(tmparray == NULL)
     5782                tmparray = array; array = (struct splitstr*)realloc(array, sizeof(struct splitstr*) * (*count));
     5783                if(array == NULL)
     5784                {
     5785                        free(tmparray);
    57745786                        return NULL;
    5775                 (&tmparray[(*count) - 1])->part = tmpstr;
     5787                }
     5788               
     5789                (&array[(*count) - 1])->part = tmpstr;
    57765790                tmpstr = strtok(NULL, tok);
    57775791        }
    57785792
    5779         return tmparray;
     5793        return array;
    57805794}
    57815795
    57825796char* string_shortname(char *tmpfilename, int mode)
    57835797{
    5784         debug(50, "in %s",tmpfilename);
     5798        debug(50, "in %s", tmpfilename);
    57855799
    57865800//      char replacelist[] = "avi mkv x264 se disc0 disc1 disc2 disc3 disc4 0disc 1disc 2disc 3disc 4disc season0 season1 season2 season3 season4 season5 season6 season7 season8 season9 hdtv 720p 1080i 1080p uncut cd0 cd1 cd2 cd3 cd4 cd5 cd6 cd7 cd8 cd9 dvd0 dvd1 dvd2 dvd3 dvd4 ac3d ac3 bdrip bluray cam camrip complete custom cut dc directors dl doku dts dvdr dvdrip dvdscr dvdscreener extended french finnish german hd hddvd hddvdrip hdtv int internal int ld limited multi multisubs nordic ntsc pal pl r1 r5 recut remastered repack rip screener se see special.edition sse stv subbed swedish staffel tc telecine telesync ts unrated ws xxx italian";
    57875801        char* str = NULL;
    57885802
    5789         if (mode==1)
     5803        if(mode==1)
    57905804        {
    57915805                char* replacelist = "avi mkv x264 xvid se uncut ac3d ac3hd ac3 bdrip bluray cam camrip complete custom cut dc directors dl doku dts dvdr dvdrip dvdscr dvdscreener ecc extended french finnish german hd hddvd hddvdrip hdtv int internal int ld limited multi multisubs nordic ntsc pal pl r1 r5 recut remastered repack rip screener se see sse stv subbed swedish staffel tc telecine telesync ts unrated ws xxx italian";
    57925806                str = ostrcat(str, replacelist, 1, 0);
    57935807        }
    5794         else if (mode==2)
     5808        else if(mode==2)
    57955809        {
    57965810                char* replacelist = "1080i 1080p 720p ac3 ac3d ac3hd avi bdrip bluray cam camrip complete custom cut dat dc directors divx dl doku dts dvdr dvdrip dvdscr dvdscreener ecc ed extended finnish flv french german hd hddvd hddvdrip hdtv int internal ld limited linedubbed m2ts m4v md mkv mov mp4 mpeg mpg mts multi multisubs nordic ntsc pal pl proper r1 r3 r5 recut remastered repack rip rm screener se sse staffel stv subbed svcd swedish tc telecine telesync trp ts uc uncut unrated ur vcd vdr vob wmv ws x264 xvid xxx";
     
    58265840                                if(ostrcmp((&ret1[i])->part, (&ret2[j])->part) == 0)
    58275841                                {
    5828                                         if (mode==1)
     5842                                        if(mode==1)
    58295843                                        {
    58305844                                                tmpfilename = string_replace((&ret2[j])->part, replace, tmpfilename, 1);
    58315845                                                continue;
    58325846                                        }
    5833                                         else if (mode==2)
     5847                                        else if(mode==2)
    58345848                                        {
    58355849                                                tmpfilename = string_replace_remove_last_chars((&ret2[j])->part, replace, tmpfilename, 1);
     
    58435857                                        }
    58445858                                }
    5845                                 else if (first == 1 && mode == 2)
     5859                                else if(first == 1 && mode == 2)
    58465860                                {
    58475861//                                      printf("zahl: %s\n", (&ret2[j])->part);
Note: See TracChangeset for help on using the changeset viewer.