Changeset 23984
- Timestamp:
- 09/29/13 02:19:23 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
titan/titan/global.h
r23978 r23984 671 671 { 672 672 char *tmpstr = NULL; 673 struct splitstr * tmparray = NULL;673 struct splitstr *array = NULL, *tmparray = NULL; 674 674 *count = 0; 675 675 … … 681 681 { 682 682 *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); 685 687 return NULL; 688 } 686 689 687 (& tmparray[(*count) - 1])->part = oregex(regex, tmpstr);690 (&array[(*count) - 1])->part = oregex(regex, tmpstr); 688 691 tmpstr = strtok(NULL, tok); 689 692 } 690 693 691 return tmparray;694 return array; 692 695 } 693 696 … … 5198 5201 { 5199 5202 FILE *fd = NULL; 5200 char *fileline = NULL, *buf = NULL, * buf1= NULL;5201 int buf 1size = 0, buf1oldsize = 0;5203 char *fileline = NULL, *buf = NULL, *tmpbuf = NULL; 5204 int bufsize = 0, bufoldsize = 0; 5202 5205 5203 5206 fileline = malloc(MINMALLOC); … … 5218 5221 while(fgets(fileline, MINMALLOC, fd) != NULL) 5219 5222 { 5220 buf = fileline;5221 5222 5223 if(flag == 1) 5223 if( buf[0] == '#' || buf[0] == '\n')5224 if(fileline[0] == '#' || fileline[0] == '\n') 5224 5225 continue; 5225 5226 5226 buf 1oldsize = buf1size;5227 buf 1size += strlen(buf);5228 buf1 = realloc(buf1, buf1size + 1);5229 if(buf 1== NULL)5227 bufoldsize = bufsize; 5228 bufsize += strlen(fileline); 5229 tmpbuf = buf; buf = realloc(buf, bufsize + 1); 5230 if(buf == NULL) 5230 5231 { 5231 5232 err("no memory"); 5232 5233 free(fileline); 5234 free(tmpbuf); 5233 5235 fclose(fd); 5234 5236 return NULL; 5235 5237 } 5236 5238 5237 sprintf(buf 1 + buf1oldsize, "%s", buf);5239 sprintf(buf + bufoldsize, "%s", fileline); 5238 5240 } 5239 5241 5240 5242 free(fileline); 5241 5243 fclose(fd); 5242 return buf 1;5244 return buf; 5243 5245 } 5244 5246 … … 5247 5249 unsigned char byte; 5248 5250 FILE *fil = NULL; 5249 char *zeichen = NULL, *buf = NULL, *buf1 = NULL ;5251 char *zeichen = NULL, *buf = NULL, *buf1 = NULL, *tmpbuf1 = NULL; 5250 5252 int buf1size = 0, buf1oldsize = 0; 5251 5253 int Beschreibung; … … 5276 5278 Beschreibung = 0; 5277 5279 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 { 5282 5286 fseek(fil, 4,SEEK_CUR); 5283 byte =fgetc(fil);5287 byte = fgetc(fil); 5284 5288 len = byte + 0; 5285 byte =fgetc(fil);5286 fgets(zeichen, len,fil);5287 if 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); 5289 5293 else 5290 sprintf(buf, "%s\n", zeichen);5294 sprintf(buf, "%s\n", zeichen); 5291 5295 5292 5296 buf1oldsize = buf1size; 5293 5297 buf1size += strlen(buf); 5294 buf1 = realloc(buf1, buf1size + 1);5298 tmpbuf1 = buf1; buf1 = realloc(buf1, buf1size + 1); 5295 5299 if(buf1 == NULL) 5296 5300 { … … 5298 5302 free(zeichen); 5299 5303 free(buf); 5304 free(tmpbuf1); 5300 5305 fclose(fil); 5301 5306 return NULL; … … 5304 5309 5305 5310 //printf("T %s\n", zeichen); 5306 byte =fgetc(fil);5311 byte = fgetc(fil); 5307 5312 len = byte + 0; 5308 byte =fgetc(fil);5309 fgets(zeichen, len,fil);5310 if 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); 5312 5317 else 5313 5318 sprintf(buf,"%s\n\n", zeichen); … … 5315 5320 buf1oldsize = buf1size; 5316 5321 buf1size += strlen(buf); 5317 buf1 = realloc(buf1, buf1size + 1);5322 tmpbuf1 = buf1; buf1 = realloc(buf1, buf1size + 1); 5318 5323 if(buf1 == NULL) 5319 5324 { … … 5321 5326 free(zeichen); 5322 5327 free(buf); 5328 free(tmpbuf1); 5323 5329 fclose(fil); 5324 5330 return NULL; … … 5327 5333 5328 5334 } 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); 5332 5339 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); 5338 5346 else 5339 sprintf(buf, "%s", zeichen);5347 sprintf(buf, "%s", zeichen); 5340 5348 Beschreibung = 1; 5341 5349 } 5342 5350 else 5343 5351 { 5344 if 5345 sprintf(buf, "%c%s", byte,zeichen);5352 if(byte != 0x05) 5353 sprintf(buf, "%c%s", byte, zeichen); 5346 5354 else 5347 sprintf(buf, "%s", zeichen);5355 sprintf(buf, "%s", zeichen); 5348 5356 } 5349 5357 5350 5358 buf1oldsize = buf1size; 5351 5359 buf1size += strlen(buf); 5352 buf1 = realloc(buf1, buf1size + 1);5360 tmpbuf1 = buf1; buf1 = realloc(buf1, buf1size + 1); 5353 5361 if(buf1 == NULL) 5354 5362 { … … 5356 5364 free(zeichen); 5357 5365 free(buf); 5366 free(tmpbuf1); 5358 5367 fclose(fil); 5359 5368 return NULL; … … 5362 5371 5363 5372 } 5364 else { 5365 byte=fgetc(fil); 5373 else 5374 { 5375 byte = fgetc(fil); 5366 5376 len= byte; 5367 fgets(zeichen, len+1,fil);5377 fgets(zeichen, len + 1, fil); 5368 5378 } 5369 5379 } … … 5760 5770 { 5761 5771 char *tmpstr = NULL; 5762 struct splitstr * tmparray = NULL;5772 struct splitstr *array = NULL, *tmparray = NULL; 5763 5773 *count = 0; 5764 5774 … … 5770 5780 { 5771 5781 *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); 5774 5786 return NULL; 5775 (&tmparray[(*count) - 1])->part = tmpstr; 5787 } 5788 5789 (&array[(*count) - 1])->part = tmpstr; 5776 5790 tmpstr = strtok(NULL, tok); 5777 5791 } 5778 5792 5779 return tmparray;5793 return array; 5780 5794 } 5781 5795 5782 5796 char* string_shortname(char *tmpfilename, int mode) 5783 5797 { 5784 debug(50, "in %s", tmpfilename);5798 debug(50, "in %s", tmpfilename); 5785 5799 5786 5800 // 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"; 5787 5801 char* str = NULL; 5788 5802 5789 if 5803 if(mode==1) 5790 5804 { 5791 5805 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"; 5792 5806 str = ostrcat(str, replacelist, 1, 0); 5793 5807 } 5794 else if 5808 else if(mode==2) 5795 5809 { 5796 5810 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"; … … 5826 5840 if(ostrcmp((&ret1[i])->part, (&ret2[j])->part) == 0) 5827 5841 { 5828 if 5842 if(mode==1) 5829 5843 { 5830 5844 tmpfilename = string_replace((&ret2[j])->part, replace, tmpfilename, 1); 5831 5845 continue; 5832 5846 } 5833 else if 5847 else if(mode==2) 5834 5848 { 5835 5849 tmpfilename = string_replace_remove_last_chars((&ret2[j])->part, replace, tmpfilename, 1); … … 5843 5857 } 5844 5858 } 5845 else if 5859 else if(first == 1 && mode == 2) 5846 5860 { 5847 5861 // printf("zahl: %s\n", (&ret2[j])->part);
Note: See TracChangeset
for help on using the changeset viewer.