aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMåns Rullgård <mans@mansr.com>2007-06-24 11:27:12 +0000
committerMåns Rullgård <mans@mansr.com>2007-06-24 11:27:12 +0000
commitf7d78f3654f8181fb889000dfc2b9a91ca85e418 (patch)
tree2dd03806da8128c531f95b35a28cfb245e405ff0
parent3565e10b44cc978b75a5179191bc4a3c946a2e4a (diff)
downloadffmpeg-f7d78f3654f8181fb889000dfc2b9a91ca85e418.tar.gz
replace the uses of old string functions that Reimar missed
Originally committed as revision 9406 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--cmdutils.c7
-rw-r--r--ffmpeg.c21
-rw-r--r--ffplay.c3
-rw-r--r--ffserver.c55
-rw-r--r--libavformat/file.c3
-rw-r--r--libavformat/http.c4
-rw-r--r--libavformat/rtp_h264.c7
-rw-r--r--libavformat/rtpproto.c7
-rw-r--r--libavformat/rtsp.c30
9 files changed, 72 insertions, 65 deletions
diff --git a/cmdutils.c b/cmdutils.c
index 171574c014..1557aaac4c 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -21,6 +21,7 @@
#include "avformat.h"
#include "cmdutils.h"
+#include "avstring.h"
#undef exit
@@ -37,10 +38,10 @@ void show_help_options(const OptionDef *options, const char *msg, int mask, int
printf("%s", msg);
first = 0;
}
- pstrcpy(buf, sizeof(buf), po->name);
+ av_strlcpy(buf, po->name, sizeof(buf));
if (po->flags & HAS_ARG) {
- pstrcat(buf, sizeof(buf), " ");
- pstrcat(buf, sizeof(buf), po->argname);
+ av_strlcat(buf, " ", sizeof(buf));
+ av_strlcat(buf, po->argname, sizeof(buf));
}
printf("-%-17s %s\n", buf, po->help);
}
diff --git a/ffmpeg.c b/ffmpeg.c
index 09acf8ad25..e1343edd68 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -26,6 +26,7 @@
#include "framehook.h"
#include "opt.h"
#include "fifo.h"
+#include "avstring.h"
#ifdef __MINGW32__
#include <conio.h>
@@ -2908,7 +2909,7 @@ static void new_audio_stream(AVFormatContext *oc)
audio_enc->sample_rate = audio_sample_rate;
audio_enc->time_base= (AVRational){1, audio_sample_rate};
if (audio_language) {
- pstrcpy(st->language, sizeof(st->language), audio_language);
+ av_strlcpy(st->language, audio_language, sizeof(st->language));
av_free(audio_language);
audio_language = NULL;
}
@@ -2954,7 +2955,7 @@ static void opt_new_subtitle_stream(void)
}
if (subtitle_language) {
- pstrcpy(st->language, sizeof(st->language), subtitle_language);
+ av_strlcpy(st->language, subtitle_language, sizeof(st->language));
av_free(subtitle_language);
subtitle_language = NULL;
}
@@ -3006,10 +3007,10 @@ static void opt_output_file(const char *filename)
}
oc->oformat = file_oformat;
- pstrcpy(oc->filename, sizeof(oc->filename), filename);
+ av_strlcpy(oc->filename, filename, sizeof(oc->filename));
if (!strcmp(file_oformat->name, "ffm") &&
- strstart(filename, "http:", NULL)) {
+ av_strstart(filename, "http:", NULL)) {
/* special case for files sent to ffserver: we get the stream
parameters from ffserver */
if (read_ffserver_streams(oc, filename) < 0) {
@@ -3049,15 +3050,15 @@ static void opt_output_file(const char *filename)
oc->timestamp = rec_timestamp;
if (str_title)
- pstrcpy(oc->title, sizeof(oc->title), str_title);
+ av_strlcpy(oc->title, str_title, sizeof(oc->title));
if (str_author)
- pstrcpy(oc->author, sizeof(oc->author), str_author);
+ av_strlcpy(oc->author, str_author, sizeof(oc->author));
if (str_copyright)
- pstrcpy(oc->copyright, sizeof(oc->copyright), str_copyright);
+ av_strlcpy(oc->copyright, str_copyright, sizeof(oc->copyright));
if (str_comment)
- pstrcpy(oc->comment, sizeof(oc->comment), str_comment);
+ av_strlcpy(oc->comment, str_comment, sizeof(oc->comment));
if (str_album)
- pstrcpy(oc->album, sizeof(oc->album), str_album);
+ av_strlcpy(oc->album, str_album, sizeof(oc->album));
}
output_files[nb_output_files++] = oc;
@@ -3074,7 +3075,7 @@ static void opt_output_file(const char *filename)
/* test if it already exists to avoid loosing precious files */
if (!file_overwrite &&
(strchr(filename, ':') == NULL ||
- strstart(filename, "file:", NULL))) {
+ av_strstart(filename, "file:", NULL))) {
if (url_exist(filename)) {
int c;
diff --git a/ffplay.c b/ffplay.c
index 574ef26d58..bc53a8c1fb 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -21,6 +21,7 @@
#include "avformat.h"
#include "swscale.h"
+#include "avstring.h"
#include "version.h"
#include "cmdutils.h"
@@ -2109,7 +2110,7 @@ static VideoState *stream_open(const char *filename, AVInputFormat *iformat)
is = av_mallocz(sizeof(VideoState));
if (!is)
return NULL;
- pstrcpy(is->filename, sizeof(is->filename), filename);
+ av_strlcpy(is->filename, filename, sizeof(is->filename));
is->iformat = iformat;
is->ytop = 0;
is->xleft = 0;
diff --git a/ffserver.c b/ffserver.c
index 98e7e78860..82cbc661dc 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -42,6 +42,7 @@
#include "version.h"
#include "ffserver.h"
#include "random.h"
+#include "avstring.h"
#undef exit
@@ -390,7 +391,7 @@ static void start_children(FFStream *feed)
close(i);
}
- pstrcpy(pathname, sizeof(pathname), my_program_name);
+ av_strlcpy(pathname, my_program_name, sizeof(pathname));
slash = strrchr(pathname, '/');
if (!slash) {
@@ -1144,17 +1145,17 @@ static void compute_real_filename(char *filename, int max_size)
FFStream *stream;
/* compute filename by matching without the file extensions */
- pstrcpy(file1, sizeof(file1), filename);
+ av_strlcpy(file1, filename, sizeof(file1));
p = strrchr(file1, '.');
if (p)
*p = '\0';
for(stream = first_stream; stream != NULL; stream = stream->next) {
- pstrcpy(file2, sizeof(file2), stream->filename);
+ av_strlcpy(file2, stream->filename, sizeof(file2));
p = strrchr(file2, '.');
if (p)
*p = '\0';
if (!strcmp(file1, file2)) {
- pstrcpy(filename, max_size, stream->filename);
+ av_strlcpy(filename, stream->filename, max_size);
break;
}
}
@@ -1187,7 +1188,7 @@ static int http_parse_request(HTTPContext *c)
p = c->buffer;
get_word(cmd, sizeof(cmd), (const char **)&p);
- pstrcpy(c->method, sizeof(c->method), cmd);
+ av_strlcpy(c->method, cmd, sizeof(c->method));
if (!strcmp(cmd, "GET"))
c->post = 0;
@@ -1197,13 +1198,13 @@ static int http_parse_request(HTTPContext *c)
return -1;
get_word(url, sizeof(url), (const char **)&p);
- pstrcpy(c->url, sizeof(c->url), url);
+ av_strlcpy(c->url, url, sizeof(c->url));
get_word(protocol, sizeof(protocol), (const char **)&p);
if (strcmp(protocol, "HTTP/1.0") && strcmp(protocol, "HTTP/1.1"))
return -1;
- pstrcpy(c->protocol, sizeof(c->protocol), protocol);
+ av_strlcpy(c->protocol, protocol, sizeof(c->protocol));
if (ffserver_debug)
http_log("New connection: %s %s\n", cmd, url);
@@ -1211,13 +1212,13 @@ static int http_parse_request(HTTPContext *c)
/* find the filename and the optional info string in the request */
p = strchr(url, '?');
if (p) {
- pstrcpy(info, sizeof(info), p);
+ av_strlcpy(info, p, sizeof(info));
*p = '\0';
} else {
info[0] = '\0';
}
- pstrcpy(filename, sizeof(filename)-1, url + ((*url == '/') ? 1 : 0));
+ av_strlcpy(filename, url + ((*url == '/') ? 1 : 0), sizeof(filename)-1);
for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) {
if (strncasecmp(p, "User-Agent:", 11) == 0) {
@@ -1254,7 +1255,7 @@ static int http_parse_request(HTTPContext *c)
// "redirect" / request to index.html
if (!strlen(filename))
- pstrcpy(filename, sizeof(filename) - 1, "index.html");
+ av_strlcpy(filename, "index.html", sizeof(filename) - 1);
stream = first_stream;
while (stream != NULL) {
@@ -1392,7 +1393,7 @@ static int http_parse_request(HTTPContext *c)
{
char hostname[256], *p;
/* extract only hostname */
- pstrcpy(hostname, sizeof(hostname), hostbuf);
+ av_strlcpy(hostname, hostbuf, sizeof(hostname));
p = strrchr(hostname, ':');
if (p)
*p = '\0';
@@ -1634,7 +1635,7 @@ static void compute_stats(HTTPContext *c)
char *eosf;
if (stream->feed != stream) {
- pstrcpy(sfilename, sizeof(sfilename) - 10, stream->filename);
+ av_strlcpy(sfilename, stream->filename, sizeof(sfilename) - 10);
eosf = sfilename + strlen(sfilename);
if (eosf - sfilename >= 4) {
if (strcmp(eosf - 4, ".asf") == 0) {
@@ -1998,14 +1999,14 @@ static int http_prepare_data(HTTPContext *c)
switch(c->state) {
case HTTPSTATE_SEND_DATA_HEADER:
memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx));
- pstrcpy(c->fmt_ctx.author, sizeof(c->fmt_ctx.author),
- c->stream->author);
- pstrcpy(c->fmt_ctx.comment, sizeof(c->fmt_ctx.comment),
- c->stream->comment);
- pstrcpy(c->fmt_ctx.copyright, sizeof(c->fmt_ctx.copyright),
- c->stream->copyright);
- pstrcpy(c->fmt_ctx.title, sizeof(c->fmt_ctx.title),
- c->stream->title);
+ av_strlcpy(c->fmt_ctx.author, c->stream->author,
+ sizeof(c->fmt_ctx.author));
+ av_strlcpy(c->fmt_ctx.comment, c->stream->comment,
+ sizeof(c->fmt_ctx.comment));
+ av_strlcpy(c->fmt_ctx.copyright, c->stream->copyright,
+ sizeof(c->fmt_ctx.copyright));
+ av_strlcpy(c->fmt_ctx.title, c->stream->title,
+ sizeof(c->fmt_ctx.title));
/* open output stream by using specified codecs */
c->fmt_ctx.oformat = c->stream->fmt;
@@ -2586,9 +2587,9 @@ static int rtsp_parse_request(HTTPContext *c)
get_word(url, sizeof(url), &p);
get_word(protocol, sizeof(protocol), &p);
- pstrcpy(c->method, sizeof(c->method), cmd);
- pstrcpy(c->url, sizeof(c->url), url);
- pstrcpy(c->protocol, sizeof(c->protocol), protocol);
+ av_strlcpy(c->method, cmd, sizeof(c->method));
+ av_strlcpy(c->url, url, sizeof(c->url));
+ av_strlcpy(c->protocol, protocol, sizeof(c->protocol));
c->pb = &pb1;
if (url_open_dyn_buf(c->pb) < 0) {
@@ -3073,7 +3074,7 @@ static void rtsp_cmd_teardown(HTTPContext *c, const char *url, RTSPHeader *h)
return;
}
- pstrcpy(session_id, sizeof(session_id), rtp_c->session_id);
+ av_strlcpy(session_id, rtp_c->session_id, sizeof(session_id));
/* abort the session */
close_connection(rtp_c);
@@ -3115,7 +3116,7 @@ static HTTPContext *rtp_new_connection(struct sockaddr_in *from_addr,
goto fail;
nb_connections++;
c->stream = stream;
- pstrcpy(c->session_id, sizeof(c->session_id), session_id);
+ av_strlcpy(c->session_id, session_id, sizeof(c->session_id));
c->state = HTTPSTATE_READY;
c->is_packetized = 1;
c->rtp_protocol = rtp_protocol;
@@ -3135,8 +3136,8 @@ static HTTPContext *rtp_new_connection(struct sockaddr_in *from_addr,
proto_str = "???";
break;
}
- pstrcpy(c->protocol, sizeof(c->protocol), "RTP/");
- pstrcat(c->protocol, sizeof(c->protocol), proto_str);
+ av_strlcpy(c->protocol, "RTP/", sizeof(c->protocol));
+ av_strlcat(c->protocol, proto_str, sizeof(c->protocol));
current_bandwidth += stream->bandwidth;
diff --git a/libavformat/file.c b/libavformat/file.c
index 3caf80a61b..7acf446133 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
+#include "avstring.h"
#include <fcntl.h>
#include <unistd.h>
#include <sys/time.h>
@@ -31,7 +32,7 @@ static int file_open(URLContext *h, const char *filename, int flags)
int access;
int fd;
- strstart(filename, "file:", &filename);
+ av_strstart(filename, "file:", &filename);
if (flags & URL_RDWR) {
access = O_CREAT | O_TRUNC | O_RDWR;
diff --git a/libavformat/http.c b/libavformat/http.c
index 6acf094443..0d9591e3a6 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -63,7 +63,7 @@ static int http_open_cnx(URLContext *h)
proxy_path = getenv("http_proxy");
use_proxy = (proxy_path != NULL) && !getenv("no_proxy") &&
- strstart(proxy_path, "http://", NULL);
+ av_strstart(proxy_path, "http://", NULL);
/* fill the dest addr */
redo:
@@ -126,7 +126,7 @@ static int http_open(URLContext *h, const char *uri, int flags)
h->priv_data = s;
s->filesize = -1;
s->off = 0;
- pstrcpy (s->location, URL_SIZE, uri);
+ av_strlcpy(s->location, uri, URL_SIZE);
ret = http_open_cnx(h);
if (ret != 0)
diff --git a/libavformat/rtp_h264.c b/libavformat/rtp_h264.c
index 564424d5d3..0b8853072f 100644
--- a/libavformat/rtp_h264.c
+++ b/libavformat/rtp_h264.c
@@ -47,6 +47,7 @@
#include "rtp_internal.h"
#include "rtp_h264.h"
#include "base64.h"
+#include "avstring.h"
/**
RTP/H264 specific private data.
@@ -357,7 +358,7 @@ static int parse_h264_sdp_line(AVStream * stream, void *data,
assert(h264_data->cookie == MAGIC_COOKIE);
- if (strstart(p, "framesize:", &p)) {
+ if (av_strstart(p, "framesize:", &p)) {
char buf1[50];
char *dst = buf1;
@@ -375,7 +376,7 @@ static int parse_h264_sdp_line(AVStream * stream, void *data,
codec->width = atoi(buf1);
codec->height = atoi(p + 1); // skip the -
codec->pix_fmt = PIX_FMT_YUV420P;
- } else if (strstart(p, "fmtp:", &p)) {
+ } else if (av_strstart(p, "fmtp:", &p)) {
char attr[256];
char value[4096];
@@ -390,7 +391,7 @@ static int parse_h264_sdp_line(AVStream * stream, void *data,
/* grab the codec extra_data from the config parameter of the fmtp line */
sdp_parse_fmtp_config_h264(stream, h264_data, attr, value);
}
- } else if (strstart(p, "cliprect:", &p)) {
+ } else if (av_strstart(p, "cliprect:", &p)) {
// could use this if we wanted.
}
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index 73f07c6ccd..f56b63f534 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
+#include "avstring.h"
#include <unistd.h>
#include <stdarg.h>
@@ -72,11 +73,11 @@ static void url_add_option(char *buf, int buf_size, const char *fmt, ...)
va_start(ap, fmt);
if (strchr(buf, '?'))
- pstrcat(buf, buf_size, "&");
+ av_strlcat(buf, "&", buf_size);
else
- pstrcat(buf, buf_size, "?");
+ av_strlcat(buf, "?", buf_size);
vsnprintf(buf1, sizeof(buf1), fmt, ap);
- pstrcat(buf, buf_size, buf1);
+ av_strlcat(buf, buf1, buf_size);
va_end(ap);
}
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 05349ab2ac..3a3ffbd13d 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -80,7 +80,7 @@ int rtsp_default_protocols = (1 << RTSP_PROTOCOL_RTP_UDP);
static int rtsp_probe(AVProbeData *p)
{
- if (strstart(p->filename, "rtsp:", NULL))
+ if (av_strstart(p->filename, "rtsp:", NULL))
return AVPROBE_SCORE_MAX;
return 0;
}
@@ -338,7 +338,7 @@ static void rtsp_parse_range_npt(const char *p, int64_t *start, int64_t *end)
char buf[256];
skip_spaces(&p);
- if (!stristart(p, "npt=", &p))
+ if (!av_stristart(p, "npt=", &p))
return;
*start = AV_NOPTS_VALUE;
@@ -460,7 +460,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
av_strlcpy(rtsp_st->control_url, s->filename, sizeof(rtsp_st->control_url));
break;
case 'a':
- if (strstart(p, "control:", &p) && s->nb_streams > 0) {
+ if (av_strstart(p, "control:", &p) && s->nb_streams > 0) {
char proto[32];
/* get the control url */
st = s->streams[s->nb_streams - 1];
@@ -475,7 +475,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
} else {
av_strlcpy(rtsp_st->control_url, p, sizeof(rtsp_st->control_url));
}
- } else if (strstart(p, "rtpmap:", &p)) {
+ } else if (av_strstart(p, "rtpmap:", &p)) {
/* NOTE: rtpmap is only supported AFTER the 'm=' tag */
get_word(buf1, sizeof(buf1), &p);
payload_type = atoi(buf1);
@@ -486,7 +486,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
sdp_parse_rtpmap(st->codec, rtsp_st, payload_type, p);
}
}
- } else if (strstart(p, "fmtp:", &p)) {
+ } else if (av_strstart(p, "fmtp:", &p)) {
/* NOTE: fmtp is only supported AFTER the 'a=rtpmap:xxx' tag */
get_word(buf1, sizeof(buf1), &p);
payload_type = atoi(buf1);
@@ -503,7 +503,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
}
}
}
- } else if(strstart(p, "framesize:", &p)) {
+ } else if(av_strstart(p, "framesize:", &p)) {
// let dynamic protocol handlers have a stab at the line.
get_word(buf1, sizeof(buf1), &p);
payload_type = atoi(buf1);
@@ -516,7 +516,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
}
}
}
- } else if(strstart(p, "range:", &p)) {
+ } else if(av_strstart(p, "range:", &p)) {
int64_t start, end;
// this is so that seeking on a streamed file can work.
@@ -683,15 +683,15 @@ void rtsp_parse_line(RTSPHeader *reply, const char *buf)
/* NOTE: we do case independent match for broken servers */
p = buf;
- if (stristart(p, "Session:", &p)) {
+ if (av_stristart(p, "Session:", &p)) {
get_word_sep(reply->session_id, sizeof(reply->session_id), ";", &p);
- } else if (stristart(p, "Content-Length:", &p)) {
+ } else if (av_stristart(p, "Content-Length:", &p)) {
reply->content_length = strtol(p, NULL, 10);
- } else if (stristart(p, "Transport:", &p)) {
+ } else if (av_stristart(p, "Transport:", &p)) {
rtsp_parse_transport(reply, p);
- } else if (stristart(p, "CSeq:", &p)) {
+ } else if (av_stristart(p, "CSeq:", &p)) {
reply->seq = strtol(p, NULL, 10);
- } else if (stristart(p, "Range:", &p)) {
+ } else if (av_stristart(p, "Range:", &p)) {
rtsp_parse_range_npt(p, &reply->range_start, &reply->range_end);
}
}
@@ -1327,7 +1327,7 @@ static int sdp_probe(AVProbeData *p1)
/* we look for a line beginning "c=IN IP4" */
while (p < p_end && *p != '\0') {
- if (p + sizeof("c=IN IP4") - 1 < p_end && strstart(p, "c=IN IP4", NULL))
+ if (p + sizeof("c=IN IP4") - 1 < p_end && av_strstart(p, "c=IN IP4", NULL))
return AVPROBE_SCORE_MAX / 2;
while(p < p_end - 1 && *p != '\n') p++;
@@ -1432,8 +1432,8 @@ static int redir_probe(AVProbeData *pd)
p = pd->buf;
while (redir_isspace(*p))
p++;
- if (strstart(p, "http://", NULL) ||
- strstart(p, "rtsp://", NULL))
+ if (av_strstart(p, "http://", NULL) ||
+ av_strstart(p, "rtsp://", NULL))
return AVPROBE_SCORE_MAX;
return 0;
}