From 4c4a1070febe5a140cac0357267af338b9852a7e Mon Sep 17 00:00:00 2001 From: reimar Date: Thu, 5 Jul 2007 22:01:07 +0000 Subject: 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 --- stream/stream_cue.c | 7 ++++--- stream/stream_dvb.c | 3 ++- stream/stream_pvr.c | 17 +++++++++-------- stream/stream_radio.c | 3 ++- stream/tv.c | 3 ++- 5 files changed, 19 insertions(+), 14 deletions(-) (limited to 'stream') diff --git a/stream/stream_cue.c b/stream/stream_cue.c index ef2c8f71a2..0790de7b23 100644 --- a/stream/stream_cue.c +++ b/stream/stream_cue.c @@ -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 @@ static int cue_read_cue (char *in_cue_filename) 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 )); } diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index 7be16e11ef..41352822d4 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -44,6 +44,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "help_mp.h" #include "m_option.h" #include "m_struct.h" +#include "libavutil/avstring.h" #include "dvbin.h" @@ -176,7 +177,7 @@ static dvb_channels_list *dvb_get_channels(char *filename, int type) ptr->name = malloc(k+1); if(! ptr->name) continue; - strlcpy(ptr->name, line, k+1); + av_strlcpy(ptr->name, line, k+1); } else continue; diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c index c6aa4a2b0a..6bde5df1a5 100644 --- a/stream/stream_pvr.c +++ b/stream/stream_pvr.c @@ -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 @@ copycreate_stationlist (stationlist_t *stationlist, int num) /* 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 @@ set_station (struct pvr_t *pvr, const char *station, } 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 @@ set_station (struct pvr_t *pvr, const char *station, 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 @@ parse_setup_stationlist (struct pvr_t *pvr) 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] = ' '; diff --git a/stream/stream_radio.c b/stream/stream_radio.c index 441dff367c..12b19deeb3 100644 --- a/stream/stream_radio.c +++ b/stream/stream_radio.c @@ -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 @@ static int parse_channels(radio_priv_t* priv,float freq_channel,float* pfreq){ 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'; diff --git a/stream/tv.c b/stream/tv.c index dcb96f1126..fd686e38a7 100644 --- a/stream/tv.c +++ b/stream/tv.c @@ -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 @@ static int open_tv(tvi_handle_t *tvh) 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); -- cgit v1.2.3