changeset 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 5159b5f8784e
children ce80673fbf0d
files configure gui/mplayer/common.c gui/skin/font.c gui/skin/skin.c libmpdemux/demux_mkv.c libmpdemux/demux_ty.c libvo/vo_dxr3.c m_option.c osdep/Makefile osdep/strlcat.c osdep/strlcpy.c stream/stream_cue.c stream/stream_dvb.c stream/stream_pvr.c stream/stream_radio.c stream/tv.c
diffstat 16 files changed, 97 insertions(+), 170 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Thu Jul 05 10:18:58 2007 +0000
+++ b/configure	Thu Jul 05 22:01:07 2007 +0000
@@ -3394,38 +3394,6 @@
 fi
 echores "$_strsep"
 
-echocheck "strlcpy()"
-cat > $TMPC << EOF
-#include <string.h>
-int main (void) { char *s = "Hello, world!", t[20]; (void) strlcpy(t, s, sizeof( t )); return 0; }
-EOF
-_strlcpy=no
-cc_check && _strlcpy=yes
-if test "$_strlcpy" = yes ; then
- _def_strlcpy='#define HAVE_STRLCPY 1'
- _need_strlcpy=no
-else
- _def_strlcpy='#undef HAVE_STRLCPY'
- _need_strlcpy=yes
-fi
-echores "$_strlcpy"
-
-echocheck "strlcat()"
-cat > $TMPC << EOF
-#include <string.h>
-int main (void) { char *s = "Hello, world!", t[20]; (void) strlcat(t, s, sizeof( t )); return 0; }
-EOF
-_strlcat=no
-cc_check && _strlcat=yes
-if test "$_strlcat" = yes ; then
- _def_strlcat='#define HAVE_STRLCAT 1'
- _need_strlcat=no
-else
- _def_strlcat='#undef HAVE_STRLCAT'
- _need_strlcat=yes
-fi
-echores "$_strlcat"
-
 echocheck "fseeko()"
 cat > $TMPC << EOF
 #include <stdio.h>
@@ -7499,8 +7467,6 @@
 NEED_SCANDIR = $_need_scandir
 NEED_SETENV  = $_need_setenv
 NEED_SHMEM   = $_need_shmem
-NEED_STRLCAT = $_need_strlcat
-NEED_STRLCPY = $_need_strlcpy
 NEED_STRSEP  = $_need_strsep
 NEED_SWAB    = $_need_swab
 NEED_VSSCANF = $_need_vsscanf
@@ -7868,18 +7834,6 @@
 /* Define this if your system has strsep */
 $_def_strsep
 
-/* Define this if your system has strlcpy */
-$_def_strlcpy
-#ifndef HAVE_STRLCPY
-unsigned int strlcpy (char *dest, const char *src, unsigned int size);
-#endif
-
-/* Define this if your system has strlcat */
-$_def_strlcat
-#ifndef HAVE_STRLCAT
-unsigned int strlcat (char *dest, const char *src, unsigned int size);
-#endif
-
 /* Define this if your system has fseeko */
 $_def_fseeko
 #ifndef HAVE_FSEEKO
--- a/gui/mplayer/common.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/gui/mplayer/common.c	Thu Jul 05 22:01:07 2007 +0000
@@ -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 @@
  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 @@
         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 @@
      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 );
--- a/gui/skin/font.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/gui/skin/font.c	Thu Jul 05 22:01:07 2007 +0000
@@ -10,6 +10,7 @@
 #include "font.h"
 #include "cut.h"
 #include "../mp_msg.h"
+#include "../libavutil/avstring.h"
 
 int items;
 
@@ -27,7 +28,7 @@
 
  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 @@
  
  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 @@
      {
       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;
        }
--- 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 )
--- a/libmpdemux/demux_mkv.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/libmpdemux/demux_mkv.c	Thu Jul 05 22:01:07 2007 +0000
@@ -45,6 +45,7 @@
 #include "libavutil/lzo.h"
 #include "libavutil/intreadwrite.h"
 #endif
+#include "libavutil/avstring.h"
 
 static unsigned char sipr_swaps[38][2]={
     {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68},
@@ -3607,7 +3608,7 @@
   mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
   mkv_track_t *track = demux_mkv_find_track_by_num (mkv_d, track_num, MATROSKA_TRACK_SUBTITLE);
   if (track && track->language && strcmp(track->language, "und"))
-    strlcpy(lang, track->language, maxlen);
+    av_strlcpy(lang, track->language, maxlen);
 }
 
 /** \brief Get the language code for an audio track.
@@ -3627,7 +3628,7 @@
   mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
   mkv_track_t *track = demux_mkv_find_track_by_num (mkv_d, track_num, MATROSKA_TRACK_AUDIO);
   if (track && track->language && strcmp(track->language, "und"))
-    strlcpy(lang, track->language, maxlen);
+    av_strlcpy(lang, track->language, maxlen);
 }
 
 
--- a/libmpdemux/demux_ty.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/libmpdemux/demux_ty.c	Thu Jul 05 22:01:07 2007 +0000
@@ -44,6 +44,7 @@
 #include "parse_es.h"
 #include "stheader.h"
 #include "sub_cc.h"
+#include "libavutil/avstring.h"
 
 extern void skip_audio_frame( sh_audio_t *sh_audio );
 extern int sub_justify;
@@ -201,8 +202,8 @@
          error = 1;
          break;
       }
-      strlcpy( name, &header[ 0 ], 100 );
-      strlcpy( sizestr, &header[ 124 ], 12 );
+      av_strlcpy( name, &header[ 0 ], 100 );
+      av_strlcpy( sizestr, &header[ 124 ], 12 );
       size = ty_octaltodecimal( sizestr );
 
       blocks = size / 512;
--- a/libvo/vo_dxr3.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/libvo/vo_dxr3.c	Thu Jul 05 22:01:07 2007 +0000
@@ -148,6 +148,7 @@
 #ifdef HAVE_X11
 #include "x11_common.h"
 #endif
+#include "libavutil/avstring.h"
 
 #define SPU_SUPPORT
 
@@ -1125,13 +1126,13 @@
     int j;
 	
     if(!p) {
-	strlcpy(fname, getenv("HOME"), sizeof( fname ));
-	strlcat(fname,"/.overlay", sizeof( fname ));	    
+	av_strlcpy(fname, getenv("HOME"), sizeof( fname ));
+	av_strlcat(fname,"/.overlay", sizeof( fname ));	    
     } else
-	strlcpy(fname, p, sizeof( fname ));
+	av_strlcpy(fname, p, sizeof( fname ));
     
     sprintf(tmp,"/res_%dx%dx%d",o->xres,o->yres,o->depth);
-    strlcat(fname, tmp, sizeof( fname ));
+    av_strlcat(fname, tmp, sizeof( fname ));
 
     if(!(fp=fopen(fname,"r")))
 	return -1;
@@ -1188,10 +1189,10 @@
     int i,j;
 	
     if(!p) {
-	strlcpy(fname, getenv("HOME"), sizeof( fname ));
-	strlcat(fname,"/.overlay", sizeof( fname ));	    
+	av_strlcpy(fname, getenv("HOME"), sizeof( fname ));
+	av_strlcat(fname,"/.overlay", sizeof( fname ));	    
     } else
-	strlcpy(fname, p, sizeof( fname ));
+	av_strlcpy(fname, p, sizeof( fname ));
 
     if(access(fname, W_OK|X_OK|R_OK)) {
 	if(mkdir(fname,0766))
@@ -1199,7 +1200,7 @@
     }	
     
     sprintf(tmp,"/res_%dx%dx%d",o->xres,o->yres,o->depth);
-    strlcat(fname, tmp, sizeof( fname ));
+    av_strlcat(fname, tmp, sizeof( fname ));
     
     if(!(fp=fopen(fname,"w")))
 	return -1;
--- a/m_option.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/m_option.c	Thu Jul 05 22:01:07 2007 +0000
@@ -16,6 +16,7 @@
 //#include "m_config.h"
 #include "mp_msg.h"
 #include "stream/url.h"
+#include "libavutil/avstring.h"
 
 // Don't free for 'production' atm
 #ifndef MP_DEBUG
@@ -920,7 +921,7 @@
       int optlen = strcspn(p, ":=");
       /* clear out */
       subopt[0] = subparam[0] = 0;
-      strlcpy(subopt, p, optlen + 1);
+      av_strlcpy(subopt, p, optlen + 1);
       p = &p[optlen];
       if (p[0] == '=') {
         sscanf_ret = 2;
@@ -928,7 +929,7 @@
         if (p[0] == '"') {
           p = &p[1];
           optlen = strcspn(p, "\"");
-          strlcpy(subparam, p, optlen + 1);
+          av_strlcpy(subparam, p, optlen + 1);
           p = &p[optlen];
           if (p[0] != '"') {
             mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Terminating '\"' missing for '%s'\n", subopt);
@@ -943,11 +944,11 @@
             return M_OPT_INVALID;
           }
           p = &p[1];
-          strlcpy(subparam, p, optlen + 1);
+          av_strlcpy(subparam, p, optlen + 1);
           p = &p[optlen];
         } else {
           optlen = strcspn(p, ":");
-          strlcpy(subparam, p, optlen + 1);
+          av_strlcpy(subparam, p, optlen + 1);
           p = &p[optlen];
         }
       }
--- a/osdep/Makefile	Thu Jul 05 10:18:58 2007 +0000
+++ b/osdep/Makefile	Thu Jul 05 22:01:07 2007 +0000
@@ -12,8 +12,6 @@
 SRCS_COMMON-$(NEED_SCANDIR)          += scandir.c
 SRCS_COMMON-$(NEED_SETENV)           += setenv.c
 SRCS_COMMON-$(NEED_SHMEM)            += shmem.c
-SRCS_COMMON-$(NEED_STRLCAT)          += strlcat.c
-SRCS_COMMON-$(NEED_STRLCPY)          += strlcpy.c
 SRCS_COMMON-$(NEED_STRSEP)           += strsep.c
 SRCS_COMMON-$(NEED_SWAB)             += swab.c
 SRCS_COMMON-$(NEED_VSSCANF)          += vsscanf.c
--- a/osdep/strlcat.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/osdep/strlcat.c	Thu Jul 05 22:01:07 2007 +0000
@@ -1,15 +0,0 @@
-/* strlcat implementation for systems that do not have it in libc
- * Time-stamp: <2004-03-14 njk>
- * (C) 2003-2004 Nicholas J. Kain <njk@aerifal.cx>
- */
-
-#include "config.h"
-
-unsigned int strlcat (char *dest, const char *src, unsigned int size)
-{
-	register char *d = dest;
-
-	for (; size > 0 && *d != '\0'; size--, d++);
-	return (d - dest) + strlcpy(d, src, size);
-}
-
--- a/osdep/strlcpy.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/osdep/strlcpy.c	Thu Jul 05 22:01:07 2007 +0000
@@ -1,22 +0,0 @@
-/* strlcpy implementation for systems that do not have it in libc
- * Time-stamp: <2004-03-14 njk>
- * (C) 2003-2004 Nicholas J. Kain <njk@aerifal.cx>
- */
-
-#include "config.h"
-
-unsigned int strlcpy (char *dest, const char *src, unsigned int size)
-{
-	register unsigned int i = 0;
-
-	if (size > 0) {
-	size--;
-	for (i=0; size > 0 && src[i] != '\0'; ++i, size--)
-		dest[i] = src[i];
-
-	dest[i] = '\0';
-	}
-	while (src[i++]);
-
-	return i;
-}
--- a/stream/stream_cue.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/stream/stream_cue.c	Thu Jul 05 22:01:07 2007 +0000
@@ -18,6 +18,7 @@
 #include "help_mp.h"
 #include "m_option.h"
 #include "m_struct.h"
+#include "libavutil/avstring.h"
 
 #define byte    unsigned char
 #define SIZERAW 2352
@@ -325,15 +326,15 @@
        strcpy(t, "/");
   }
   
-  strlcpy(bincue_path,t,sizeof( bincue_path ));
+  av_strlcpy(bincue_path,t,sizeof( bincue_path ));
   mp_msg(MSGT_OPEN,MSGL_V,"dirname: %s, cuepath: %s\n", t, bincue_path);
 
   /* no path at all? */
   if (strcmp(bincue_path, ".") == 0) {
     mp_msg(MSGT_OPEN,MSGL_V,"bincue_path: %s\n", bincue_path);
-    strlcpy(cue_filename,in_cue_filename,sizeof( cue_filename ));
+    av_strlcpy(cue_filename,in_cue_filename,sizeof( cue_filename ));
   } else {
-    strlcpy(cue_filename,in_cue_filename + strlen(bincue_path) + 1,
+    av_strlcpy(cue_filename,in_cue_filename + strlen(bincue_path) + 1,
             sizeof( cue_filename ));
   }
 
--- a/stream/stream_dvb.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/stream/stream_dvb.c	Thu Jul 05 22:01:07 2007 +0000
@@ -44,6 +44,7 @@
 #include "help_mp.h"
 #include "m_option.h"
 #include "m_struct.h"
+#include "libavutil/avstring.h"
 
 #include "dvbin.h"
 
@@ -176,7 +177,7 @@
 			ptr->name = malloc(k+1);
 			if(! ptr->name)
 				continue;
-			strlcpy(ptr->name, line, k+1);
+			av_strlcpy(ptr->name, line, k+1);
 		}
 		else
 			continue;
--- a/stream/stream_pvr.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/stream/stream_pvr.c	Thu Jul 05 22:01:07 2007 +0000
@@ -45,6 +45,7 @@
 
 #include "frequencies.h"
 #include "libavutil/common.h"
+#include "libavutil/avstring.h"
 
 #define PVR_DEFAULT_DEVICE "/dev/video0"
 #define PVR_MAX_CONTROLS 10
@@ -232,12 +233,12 @@
   
   /* transport the channel list data to our extented struct */
   stationlist->total = num;
-  strlcpy (stationlist->name, chanlists[chantab].name, PVR_STATION_NAME_SIZE);
+  av_strlcpy (stationlist->name, chanlists[chantab].name, PVR_STATION_NAME_SIZE);
 
   for (i = 0; i < chanlists[chantab].count; i++)
   {
     stationlist->list[i].station[0]= '\0'; /* no station name yet */
-    strlcpy (stationlist->list[i].name,
+    av_strlcpy (stationlist->list[i].name,
              chanlists[chantab].list[i].name, PVR_STATION_NAME_SIZE);
     stationlist->list[i].freq = chanlists[chantab].list[i].freq;
     stationlist->list[i].enabled = 1; /* default enabled */
@@ -324,10 +325,10 @@
     }
     
     if (station)
-      strlcpy (pvr->stationlist.list[i].station,
+      av_strlcpy (pvr->stationlist.list[i].station,
                station, PVR_STATION_NAME_SIZE);
     else if (channel)
-      strlcpy (pvr->stationlist.list[i].station,
+      av_strlcpy (pvr->stationlist.list[i].station,
                channel, PVR_STATION_NAME_SIZE);
     else
       snprintf (pvr->stationlist.list[i].station,
@@ -381,10 +382,10 @@
   pvr->stationlist.enabled++;
 
   if (station)
-    strlcpy (pvr->stationlist.list[i].station,
+    av_strlcpy (pvr->stationlist.list[i].station,
              station, PVR_STATION_NAME_SIZE);
   if (channel)
-    strlcpy (pvr->stationlist.list[i].name, channel, PVR_STATION_NAME_SIZE);
+    av_strlcpy (pvr->stationlist.list[i].name, channel, PVR_STATION_NAME_SIZE);
   else
     snprintf (pvr->stationlist.list[i].name,
               PVR_STATION_NAME_SIZE, "F %d", freq);
@@ -476,10 +477,10 @@
       if (!sep)
         continue; /* Wrong syntax, but mplayer should not crash */
 
-      strlcpy (station, sep + 1, PVR_STATION_NAME_SIZE);
+      av_strlcpy (station, sep + 1, PVR_STATION_NAME_SIZE);
 
       sep[0] = '\0';
-      strlcpy (channel, tmp, PVR_STATION_NAME_SIZE);
+      av_strlcpy (channel, tmp, PVR_STATION_NAME_SIZE);
 
       while ((sep = strchr (station, '_')))
         sep[0] = ' ';
--- a/stream/stream_radio.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/stream/stream_radio.c	Thu Jul 05 22:01:07 2007 +0000
@@ -63,6 +63,7 @@
 #include "mp_msg.h"
 #include "help_mp.h"
 #include "stream_radio.h"
+#include "libavutil/avstring.h"
 
 #ifdef USE_RADIO_CAPTURE
 #include "audio_in.h"
@@ -207,7 +208,7 @@
             char* tmp = *(channels++);
             char* sep = strchr(tmp,'-');
             if (!sep) continue; // Wrong syntax, but mplayer should not crash
-            strlcpy(priv->radio_channel_current->name, sep + 1,sizeof(priv->radio_channel_current->name)-1);
+            av_strlcpy(priv->radio_channel_current->name, sep + 1,sizeof(priv->radio_channel_current->name)-1);
 
             sep[0] = '\0';
 
--- a/stream/tv.c	Thu Jul 05 10:18:58 2007 +0000
+++ b/stream/tv.c	Thu Jul 05 22:01:07 2007 +0000
@@ -29,6 +29,7 @@
 
 #include "libaf/af_format.h"
 #include "libmpcodecs/img_format.h"
+#include "libavutil/avstring.h"
 
 #include "tv.h"
 
@@ -354,7 +355,7 @@
 
 		if (!sep) continue; // Wrong syntax, but mplayer should not crash
 
-		strlcpy(tv_channel_current->name, sep + 1,
+		av_strlcpy(tv_channel_current->name, sep + 1,
 		        sizeof(tv_channel_current->name));
 		sep[0] = '\0';
 		strncpy(tv_channel_current->number, tmp, 5);