summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-07-05 22:01:07 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-07-05 22:01:07 +0000
commit4c4a1070febe5a140cac0357267af338b9852a7e (patch)
treed7ed87a85da0733f33ea47c25797f58c25e5e9fc /gui
parentb3d59ea908ce87b3dc50bb9ba0ac81edd4765797 (diff)
downloadmpv-4c4a1070febe5a140cac0357267af338b9852a7e.tar.bz2
mpv-4c4a1070febe5a140cac0357267af338b9852a7e.tar.xz
Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
instead of plain strlcat/strlcpy git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23723 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'gui')
-rw-r--r--gui/mplayer/common.c75
-rw-r--r--gui/skin/font.c9
-rw-r--r--gui/skin/skin.c29
3 files changed, 58 insertions, 55 deletions
diff --git a/gui/mplayer/common.c b/gui/mplayer/common.c
index 789163dbc0..a3a794944d 100644
--- a/gui/mplayer/common.c
+++ b/gui/mplayer/common.c
@@ -25,6 +25,7 @@
#include "../libmpdemux/stheader.h"
#include "../codec-cfg.h"
#include "../access_mpcontext.h"
+#include "../libavutil/avstring.h"
#include "play.h"
@@ -40,23 +41,23 @@ inline void TranslateFilename( int c,char * tmp,size_t tmplen )
switch ( guiIntfStruct.StreamType )
{
case STREAMTYPE_STREAM:
- strlcpy(tmp, guiIntfStruct.Filename, tmplen);
+ av_strlcpy(tmp, guiIntfStruct.Filename, tmplen);
break;
case STREAMTYPE_FILE:
if ( ( guiIntfStruct.Filename )&&( guiIntfStruct.Filename[0] ) )
{
if ( (p = strrchr(guiIntfStruct.Filename, '/')) )
- strlcpy(tmp, p + 1, tmplen);
+ av_strlcpy(tmp, p + 1, tmplen);
else
- strlcpy(tmp, guiIntfStruct.Filename, tmplen);
+ av_strlcpy(tmp, guiIntfStruct.Filename, tmplen);
if ( tmp[strlen( tmp ) - 4] == '.' ) tmp[strlen( tmp ) - 4]=0;
if ( tmp[strlen( tmp ) - 5] == '.' ) tmp[strlen( tmp ) - 5]=0;
- } else strlcpy( tmp,MSGTR_NoFileLoaded,tmplen );
+ } else av_strlcpy( tmp,MSGTR_NoFileLoaded,tmplen );
break;
#ifdef USE_DVDREAD
case STREAMTYPE_DVD:
if ( guiIntfStruct.DVD.current_chapter ) snprintf(tmp,tmplen,MSGTR_Chapter,guiIntfStruct.DVD.current_chapter );
- else strlcat( tmp,MSGTR_NoChapter,tmplen );
+ else av_strlcat( tmp,MSGTR_NoChapter,tmplen );
break;
#endif
#ifdef HAVE_VCD
@@ -64,7 +65,7 @@ inline void TranslateFilename( int c,char * tmp,size_t tmplen )
snprintf( tmp,tmplen,MSGTR_VCDTrack,guiIntfStruct.Track );
break;
#endif
- default: strlcpy( tmp,MSGTR_NoMediaOpened,tmplen );
+ default: av_strlcpy( tmp,MSGTR_NoMediaOpened,tmplen );
}
if ( c )
{
@@ -98,75 +99,75 @@ char * Translate( char * str )
switch ( str[++i] )
{
case 't': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.Track );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case 'o': TranslateFilename( 0,tmp,sizeof( tmp ) );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case 'f': TranslateFilename( 1,tmp,sizeof( tmp ) );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case 'F': TranslateFilename( 2,tmp,sizeof( tmp ) );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case '6': t=guiIntfStruct.LengthInSec; goto calclengthhhmmss;
case '1': t=guiIntfStruct.TimeSec;
calclengthhhmmss:
snprintf( tmp,sizeof( tmp ),"%02d:%02d:%02d",t/3600,t/60%60,t%60 );
- strlcat( trbuf,tmp,sizeof( trbuf ) );
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) );
break;
case '7': t=guiIntfStruct.LengthInSec; goto calclengthmmmmss;
case '2': t=guiIntfStruct.TimeSec;
calclengthmmmmss:
snprintf( tmp,sizeof( tmp ),"%04d:%02d",t/60,t%60 );
- strlcat( trbuf,tmp,sizeof( trbuf ) );
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) );
break;
case '3': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.TimeSec / 3600 );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case '4': snprintf( tmp,sizeof( tmp ),"%02d",( ( guiIntfStruct.TimeSec / 60 ) % 60 ) );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case '5': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.TimeSec % 60 );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
- case '8': snprintf( tmp,sizeof( tmp ),"%01d:%02d:%02d",guiIntfStruct.TimeSec / 3600,( guiIntfStruct.TimeSec / 60 ) % 60,guiIntfStruct.TimeSec % 60 ); strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ case '8': snprintf( tmp,sizeof( tmp ),"%01d:%02d:%02d",guiIntfStruct.TimeSec / 3600,( guiIntfStruct.TimeSec / 60 ) % 60,guiIntfStruct.TimeSec % 60 ); av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case 'v': snprintf( tmp,sizeof( tmp ),"%3.2f%%",guiIntfStruct.Volume );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case 'V': snprintf( tmp,sizeof( tmp ),"%3.1f",guiIntfStruct.Volume );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case 'b': snprintf( tmp,sizeof( tmp ),"%3.2f%%",guiIntfStruct.Balance );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case 'B': snprintf( tmp,sizeof( tmp ),"%3.1f",guiIntfStruct.Balance );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case 'd': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.FrameDrop );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case 'x': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieWidth );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case 'y': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieHeight );
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
case 'C': snprintf( tmp,sizeof( tmp ),"%s", guiIntfStruct.sh_video? ((sh_video_t *)guiIntfStruct.sh_video)->codec->name : "");
- strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
- case 's': if ( guiIntfStruct.Playing == 0 ) strlcat( trbuf,"s",sizeof( trbuf ) ); break;
- case 'l': if ( guiIntfStruct.Playing == 1 ) strlcat( trbuf,"p",sizeof( trbuf ) ); break;
- case 'e': if ( guiIntfStruct.Playing == 2 ) strlcat( trbuf,"e",sizeof( trbuf ) ); break;
+ av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
+ case 's': if ( guiIntfStruct.Playing == 0 ) av_strlcat( trbuf,"s",sizeof( trbuf ) ); break;
+ case 'l': if ( guiIntfStruct.Playing == 1 ) av_strlcat( trbuf,"p",sizeof( trbuf ) ); break;
+ case 'e': if ( guiIntfStruct.Playing == 2 ) av_strlcat( trbuf,"e",sizeof( trbuf ) ); break;
case 'a':
- if ( mixer->muted ) { strlcat( trbuf,"n",sizeof( trbuf ) ); break; }
+ if ( mixer->muted ) { av_strlcat( trbuf,"n",sizeof( trbuf ) ); break; }
switch ( guiIntfStruct.AudioType )
{
- case 0: strlcat( trbuf,"n",sizeof( trbuf ) ); break;
- case 1: strlcat( trbuf,"m",sizeof( trbuf ) ); break;
- case 2: strlcat( trbuf,"t",sizeof( trbuf ) ); break;
+ case 0: av_strlcat( trbuf,"n",sizeof( trbuf ) ); break;
+ case 1: av_strlcat( trbuf,"m",sizeof( trbuf ) ); break;
+ case 2: av_strlcat( trbuf,"t",sizeof( trbuf ) ); break;
}
break;
case 'T':
switch ( guiIntfStruct.StreamType )
{
- case STREAMTYPE_FILE: strlcat( trbuf,"f",sizeof( trbuf ) ); break;
+ case STREAMTYPE_FILE: av_strlcat( trbuf,"f",sizeof( trbuf ) ); break;
#ifdef HAVE_VCD
- case STREAMTYPE_VCD: strlcat( trbuf,"v",sizeof( trbuf ) ); break;
+ case STREAMTYPE_VCD: av_strlcat( trbuf,"v",sizeof( trbuf ) ); break;
#endif
- case STREAMTYPE_STREAM: strlcat( trbuf,"u",sizeof( trbuf ) ); break;
+ case STREAMTYPE_STREAM: av_strlcat( trbuf,"u",sizeof( trbuf ) ); break;
#ifdef USE_DVDREAD
- case STREAMTYPE_DVD: strlcat( trbuf,"d",sizeof( trbuf ) ); break;
+ case STREAMTYPE_DVD: av_strlcat( trbuf,"d",sizeof( trbuf ) ); break;
#endif
- default: strlcat( trbuf," ",sizeof( trbuf ) ); break;
+ default: av_strlcat( trbuf," ",sizeof( trbuf ) ); break;
}
break;
- case '$': strlcat( trbuf,"$",sizeof( trbuf ) ); break;
+ case '$': av_strlcat( trbuf,"$",sizeof( trbuf ) ); break;
default: continue;
}
c=strlen( trbuf );
diff --git a/gui/skin/font.c b/gui/skin/font.c
index 3860079a98..90210ced4a 100644
--- a/gui/skin/font.c
+++ b/gui/skin/font.c
@@ -10,6 +10,7 @@
#include "font.h"
#include "cut.h"
#include "../mp_msg.h"
+#include "../libavutil/avstring.h"
int items;
@@ -27,7 +28,7 @@ int fntAddNewFont( char * name )
if ( ( Fonts[id]=calloc( 1,sizeof( bmpFont ) ) ) == NULL ) return -1;
- strlcpy( Fonts[id]->name,name,128 ); // FIXME: as defined in font.h
+ av_strlcpy( Fonts[id]->name,name,128 ); // FIXME: as defined in font.h
for ( i=0;i<256;i++ )
Fonts[id]->Fnt[i].x=Fonts[id]->Fnt[i].y=Fonts[id]->Fnt[i].sx=Fonts[id]->Fnt[i].sy=-1;
@@ -60,8 +61,8 @@ int fntRead( char * path,char * fname )
if ( id < 0 ) return id;
- strlcpy( tmp,path,sizeof( tmp ) );
- strlcat( tmp,fname,sizeof( tmp ) ); strlcat( tmp,".fnt",sizeof( tmp ) );
+ av_strlcpy( tmp,path,sizeof( tmp ) );
+ av_strlcat( tmp,fname,sizeof( tmp ) ); av_strlcat( tmp,".fnt",sizeof( tmp ) );
if ( ( f=fopen( tmp,"rt" ) ) == NULL )
{ free( Fonts[id] ); return -3; }
@@ -94,7 +95,7 @@ int fntRead( char * path,char * fname )
{
if ( !strcmp( command,"image" ) )
{
- strlcpy( tmp,path,sizeof( tmp ) ); strlcat( tmp,param,sizeof( tmp ) );
+ av_strlcpy( tmp,path,sizeof( tmp ) ); av_strlcat( tmp,param,sizeof( tmp ) );
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[font] font imagefile: %s\n",tmp );
if ( skinBPRead( tmp,&Fonts[id]->Bitmap ) ) return -4;
}
diff --git a/gui/skin/skin.c b/gui/skin/skin.c
index b83c0360e4..41dba0b26c 100644
--- a/gui/skin/skin.c
+++ b/gui/skin/skin.c
@@ -11,6 +11,7 @@
#include "../mp_msg.h"
#include "../help_mp.h"
#include "mplayer/widgets.h"
+#include "libavutil/avstring.h"
//#define MSGL_DBG2 MSGL_STATUS
@@ -116,7 +117,7 @@ int cmd_window( char * in )
{
CHECKDEFLIST( "window" );
- strlcpy( window_name,strlower( in ),sizeof( window_name ) );
+ av_strlcpy( window_name,strlower( in ),sizeof( window_name ) );
if ( !strncmp( in,"main",4 ) ) { currSection=&skinAppMPlayer->main; currSubItem=&skinAppMPlayer->NumberOfItems; currSubItems=skinAppMPlayer->Items; }
else if ( !strncmp( in,"sub",3 ) ) currSection=&skinAppMPlayer->sub;
else if ( !strncmp( in,"playbar",7 ) ) { currSection=&skinAppMPlayer->bar; currSubItem=&skinAppMPlayer->NumberOfBarItems; currSubItems=skinAppMPlayer->barItems; }
@@ -147,7 +148,7 @@ int cmd_base( char * in )
defList->main.x=x;
defList->main.y=y;
defList->main.type=itBase;
- strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp ));
+ av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, fname, sizeof( tmp ));
if ( skinBPRead( tmp,&defList->main.Bitmap ) ) return 1;
defList->main.width=defList->main.Bitmap.Width;
defList->main.height=defList->main.Bitmap.Height;
@@ -162,7 +163,7 @@ int cmd_base( char * in )
if ( !strcmp( window_name,"sub" ) )
{
defList->sub.type=itBase;
- strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp ));
+ av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, fname, sizeof( tmp ));
if ( skinBPRead( tmp,&defList->sub.Bitmap ) ) return 1;
defList->sub.x=x;
defList->sub.y=y;
@@ -179,7 +180,7 @@ int cmd_base( char * in )
{
defList->menuIsPresent=1;
defList->menuBase.type=itBase;
- strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp ));
+ av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, fname, sizeof( tmp ));
if ( skinBPRead( tmp,&defList->menuBase.Bitmap ) ) return 1;
defList->menuBase.width=defList->menuBase.Bitmap.Width;
defList->menuBase.height=defList->menuBase.Bitmap.Height;
@@ -197,7 +198,7 @@ int cmd_base( char * in )
defList->bar.x=x;
defList->bar.y=y;
defList->bar.type=itBase;
- strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp ));
+ av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, fname, sizeof( tmp ));
if ( skinBPRead( tmp,&defList->bar.Bitmap ) ) return 1;
defList->bar.width=defList->bar.Bitmap.Width;
defList->bar.height=defList->bar.Bitmap.Height;
@@ -268,7 +269,7 @@ int cmd_button( char * in )
currSubItems[ *currSubItem ].Bitmap.Image=NULL;
if ( strcmp( fname,"NULL" ) )
{
- strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp ));
+ av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, fname, sizeof( tmp ));
if ( skinBPRead( tmp,&currSubItems[ *currSubItem ].Bitmap ) ) return 1;
}
@@ -289,7 +290,7 @@ int cmd_selected( char * in )
cutItem( in,fname,',',0 );
defList->menuSelected.type=itBase;
- strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, fname, sizeof( tmp ));
+ av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, fname, sizeof( tmp ));
mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"\n[skin] selected: %s\n",fname );
if ( skinBPRead( tmp,&defList->menuSelected.Bitmap ) ) return 1;
defList->menuSelected.width=defList->menuSelected.Bitmap.Width;
@@ -381,14 +382,14 @@ int cmd_hpotmeter( char * in )
item->Bitmap.Image=NULL;
if ( strcmp( phfname,"NULL" ) )
{
- strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, phfname, sizeof( tmp ));
+ av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, phfname, sizeof( tmp ));
if ( skinBPRead( tmp,&item->Bitmap ) ) return 1;
}
item->Mask.Image=NULL;
if ( strcmp( pfname,"NULL" ) )
{
- strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, pfname, sizeof( tmp ));
+ av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, pfname, sizeof( tmp ));
if ( skinBPRead( tmp,&item->Mask ) ) return 1;
}
return 0;
@@ -445,7 +446,7 @@ int cmd_potmeter( char * in )
item->Bitmap.Image=NULL;
if ( strcmp( phfname,"NULL" ) )
{
- strlcpy(tmp, path, sizeof( tmp )); strlcat(tmp, phfname, sizeof( tmp ));
+ av_strlcpy(tmp, path, sizeof( tmp )); av_strlcat(tmp, phfname, sizeof( tmp ));
if ( skinBPRead( tmp,&item->Bitmap ) ) return 1;
}
return 0;
@@ -656,10 +657,10 @@ FILE * skinFile;
void setname( char * item1, char * item2 )
{
- strlcpy(fn, item1, sizeof( fn ));
- strlcat(fn, "/", sizeof( fn )); strlcat(fn, item2, sizeof( fn ));
- strlcpy(path, fn, sizeof( path )); strlcat(path, "/", sizeof( path ));
- strlcat(fn, "/skin", sizeof( fn ));
+ av_strlcpy(fn, item1, sizeof( fn ));
+ av_strlcat(fn, "/", sizeof( fn )); av_strlcat(fn, item2, sizeof( fn ));
+ av_strlcpy(path, fn, sizeof( path )); av_strlcat(path, "/", sizeof( path ));
+ av_strlcat(fn, "/skin", sizeof( fn ));
}
int skinRead( char * dname )