Mercurial > mplayer.hg
diff gui/skin/skin.c @ 23703:9fb716ab06a3
Avoid code duplication and ugly config.h hack by using av_strlcat/av_strlcpy
instead of plain strlcat/strlcpy
author | reimar |
---|---|
date | Thu, 05 Jul 2007 22:01:07 +0000 |
parents | 17bf4f4b0715 |
children | 10dfbc523184 |
line wrap: on
line diff
--- a/gui/skin/skin.c Thu Jul 05 10:18:58 2007 +0000 +++ b/gui/skin/skin.c Thu Jul 05 22:01:07 2007 +0000 @@ -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 @@ { 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 )