[Mplayer-cvslog] CVS: main/Gui interface.c,1.35,1.36 interface.h,1.18,1.19
Zoltan Ponekker
pontscho at mplayerhq.hu
Wed Aug 14 14:17:06 CEST 2002
Update of /cvsroot/mplayer/main/Gui
In directory mail:/var/tmp.root/cvs-serv29461/Gui
Modified Files:
interface.c interface.h
Log Message:
add uri2filename converter
Index: interface.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/interface.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- interface.c 11 Aug 2002 18:07:42 -0000 1.35
+++ interface.c 14 Aug 2002 12:16:50 -0000 1.36
@@ -29,6 +29,14 @@
#include <inttypes.h>
#include <sys/types.h>
+#ifdef USE_ICONV
+ #ifdef __FreeBSD__
+ #include <giconv.h>
+ #else
+ #include <iconv.h>
+ #endif
+#endif
+
#include "../libmpdemux/stream.h"
#include "../libmpdemux/demuxer.h"
@@ -76,6 +84,49 @@
else gstrcat( str,what );
}
+#ifdef USE_ICONV
+char * gconvert_uri_to_filename( char * str )
+{
+ iconv_t d;
+ char * out = strdup( str );
+ char * tmp = NULL;
+ char * ize;
+ size_t inb,outb;
+ char * charset = "ISO8859-1";
+ char * cs;
+
+ if ( !strchr( str,'%' ) ) return str;
+
+ {
+ char * t = calloc( 1,strlen( out ) );
+ int i,c = 0;
+ for ( i=0;i < (int)strlen( out );i++ )
+ if ( out[i] != '%' ) t[c++]=out[i];
+ else
+ {
+ char tmp[4] = "0xXX";
+// if ( out[++i] == '%' ) { t[c++]='%'; continue; };
+ tmp[2]=out[++i]; tmp[3]=out[++i];
+ t[c++]=(char)strtol( tmp,(char **)NULL,0 );
+ }
+ free( out );
+ out=t;
+ }
+
+ if ( (cs=getenv( "CHARSET" )) && *cs ) charset=cs;
+
+ inb=outb=strlen( out );
+ tmp=calloc( 1,outb + 1 );
+ ize=tmp;
+ d=iconv_open( charset,"UTF-8" );
+ if ( (iconv_t)(-1) == d ) return str;
+ iconv( d,&out,&inb,&tmp,&outb );
+ iconv_close( d );
+ free( out );
+ return ize;
+}
+#endif
+
void guiInit( void )
{
memset( &guiIntfStruct,0,sizeof( guiIntfStruct ) );
Index: interface.h
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/interface.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- interface.h 4 Aug 2002 19:23:56 -0000 1.18
+++ interface.h 14 Aug 2002 12:16:50 -0000 1.19
@@ -171,6 +171,7 @@
extern void * gtkSet( int cmd,float param, void * vparam );
+extern char * gconvert_uri_to_filename( char * str );
extern char * gstrdup( char * str );
extern int gstrcmp( char * a,char * b );
extern void gfree( void ** p );
More information about the MPlayer-cvslog
mailing list