[Mplayer-cvslog] CVS: main subreader.c,1.3,1.4
Zoltan Ponekker
pontscho at users.sourceforge.net
Wed Apr 18 22:25:06 CEST 2001
Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv25132
Modified Files:
subreader.c
Log Message:
add sub autodetect
Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** subreader.c 2001/04/01 19:35:18 1.3
--- subreader.c 2001/04/18 20:25:04 1.4
***************
*** 200,203 ****
--- 200,251 ----
}
+ char * strreplace( char * in,char * what,char * whereof )
+ {
+ int i;
+ char * tmp;
+
+ if ( ( in == NULL )||( what == NULL )||( whereof == NULL )||( ( tmp=strstr( in,what ) ) == NULL ) ) return NULL;
+ for( i=0;i<strlen( whereof );i++ ) tmp[i]=whereof[i];
+ if ( strlen( what ) > strlen( whereof ) ) tmp[i]=0;
+ return in;
+ }
+
+ char * sub_filename( char * fname )
+ {
+ char * sub_name = NULL;
+ char * sub_tmp = NULL;
+ int i;
+ #define SUB_EXTS 4
+ char * sub_exts[SUB_EXTS] =
+ { ".sub",
+ ".SUB",
+ ".srt",
+ ".SRT" };
+
+ if ( fname == NULL ) return NULL;
+ for( i=strlen( fname );i>0;i-- )
+ if( fname[i] == '.' )
+ {
+ sub_tmp=(char *)&fname[i];
+ break;
+ }
+ if ( i == 0 ) return NULL;
+ sub_name=strdup( fname );
+ for ( i=0;i<SUB_EXTS;i++ )
+ {
+ FILE * f;
+
+ strcpy( sub_name,fname );
+ f=fopen( strreplace( sub_name,sub_tmp,sub_exts[i] ),"rt" );
+ if ( f != NULL )
+ {
+ fclose( f );
+ printf( "SUB: Detected sub file: %s\n",sub_name );
+ return sub_name;
+ }
+ }
+ return NULL;
+ }
+
#if 0
int main(int argc, char **argv) { // for testing
_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog
More information about the MPlayer-cvslog
mailing list