summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2011-11-02 20:17:25 +0100
committerMartin Storsjö <martin@martin.st>2011-11-06 11:52:57 +0200
commitbb3244dee26e3c500b14830e9500cb2d3658f809 (patch)
tree197235a2c136636ffbeab1464e51a87963ea6e36 /libavformat
parentba04ecfdacec4cf86e74b43fe8bcc09e06bb7a72 (diff)
Replace all usage of strcasecmp/strncasecmp
All current usages of it are incompatible with localization. For example strcasecmp("i", "I") != 0 is possible, but would break many of the places where it is used. Instead use our own implementations that always treat the data as ASCII. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avidec.c4
-rw-r--r--libavformat/http.c17
-rw-r--r--libavformat/img2.c3
-rw-r--r--libavformat/matroskaenc.c4
-rw-r--r--libavformat/metadata.c6
-rw-r--r--libavformat/mp3enc.c3
-rw-r--r--libavformat/nutdec.c5
-rw-r--r--libavformat/rtpdec.c4
-rw-r--r--libavformat/rtpdec_mpeg4.c3
-rw-r--r--libavformat/rtsp.c11
-rw-r--r--libavformat/utils.c7
11 files changed, 30 insertions, 37 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 68d652a120..0cd84c0d6b 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -19,11 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <strings.h>
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/bswap.h"
#include "libavutil/dict.h"
+#include "libavutil/avstring.h"
#include "avformat.h"
#include "avi.h"
#include "dv.h"
@@ -281,7 +281,7 @@ static void avi_metadata_creation_time(AVDictionary **metadata, char *date)
if (sscanf(date, "%*3s%*[ ]%3s%*[ ]%2d%*[ ]%8s%*[ ]%4d",
month, &day, time, &year) == 4) {
for (i=0; i<12; i++)
- if (!strcasecmp(month, months[i])) {
+ if (!av_strcasecmp(month, months[i])) {
snprintf(buffer, sizeof(buffer), "%.4d-%.2d-%.2d %s",
year, i+1, day, time);
av_dict_set(metadata, "creation_time", buffer, 0);
diff --git a/libavformat/http.c b/libavformat/http.c
index 243a4d78e3..52e1886bef 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -22,7 +22,6 @@
#include "libavutil/avstring.h"
#include "avformat.h"
#include <unistd.h>
-#include <strings.h>
#include "internal.h"
#include "network.h"
#include "http.h"
@@ -251,12 +250,12 @@ static int process_line(URLContext *h, char *line, int line_count,
p++;
while (isspace(*p))
p++;
- if (!strcasecmp(tag, "Location")) {
+ if (!av_strcasecmp(tag, "Location")) {
strcpy(s->location, p);
*new_location = 1;
- } else if (!strcasecmp (tag, "Content-Length") && s->filesize == -1) {
+ } else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) {
s->filesize = atoll(p);
- } else if (!strcasecmp (tag, "Content-Range")) {
+ } else if (!av_strcasecmp (tag, "Content-Range")) {
/* "bytes $from-$to/$document_size" */
const char *slash;
if (!strncmp (p, "bytes ", 6)) {
@@ -266,16 +265,16 @@ static int process_line(URLContext *h, char *line, int line_count,
s->filesize = atoll(slash+1);
}
h->is_streamed = 0; /* we _can_ in fact seek */
- } else if (!strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 5)) {
+ } else if (!av_strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 5)) {
h->is_streamed = 0;
- } else if (!strcasecmp (tag, "Transfer-Encoding") && !strncasecmp(p, "chunked", 7)) {
+ } else if (!av_strcasecmp (tag, "Transfer-Encoding") && !av_strncasecmp(p, "chunked", 7)) {
s->filesize = -1;
s->chunksize = 0;
- } else if (!strcasecmp (tag, "WWW-Authenticate")) {
+ } else if (!av_strcasecmp (tag, "WWW-Authenticate")) {
ff_http_auth_handle_header(&s->auth_state, tag, p);
- } else if (!strcasecmp (tag, "Authentication-Info")) {
+ } else if (!av_strcasecmp (tag, "Authentication-Info")) {
ff_http_auth_handle_header(&s->auth_state, tag, p);
- } else if (!strcasecmp (tag, "Connection")) {
+ } else if (!av_strcasecmp (tag, "Connection")) {
if (!strcmp(p, "close"))
s->willclose = 1;
}
diff --git a/libavformat/img2.c b/libavformat/img2.c
index 34ab79f6cc..25c3f7656a 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -29,7 +29,6 @@
#include "avformat.h"
#include "avio_internal.h"
#include "internal.h"
-#include <strings.h>
typedef struct {
const AVClass *class; /**< Class for private options. */
@@ -121,7 +120,7 @@ static enum CodecID av_str2id(const IdStrMap *tags, const char *str)
str++;
while (tags->id) {
- if (!strcasecmp(str, tags->str))
+ if (!av_strcasecmp(str, tags->str))
return tags->id;
tags++;
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 1adb479dd8..5edd2be91c 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -33,9 +33,9 @@
#include "libavutil/random_seed.h"
#include "libavutil/lfg.h"
#include "libavutil/dict.h"
+#include "libavutil/avstring.h"
#include "libavcodec/xiph.h"
#include "libavcodec/mpeg4audio.h"
-#include <strings.h>
typedef struct ebml_master {
int64_t pos; ///< absolute offset in the file where the master's elements start
@@ -760,7 +760,7 @@ static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int eleme
end_ebml_master(s->pb, targets);
while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX)))
- if (strcasecmp(t->key, "title"))
+ if (av_strcasecmp(t->key, "title"))
mkv_write_simpletag(s->pb, t);
end_ebml_master(s->pb, tag);
diff --git a/libavformat/metadata.c b/libavformat/metadata.c
index d8957dfa95..7d85363cfe 100644
--- a/libavformat/metadata.c
+++ b/libavformat/metadata.c
@@ -18,10 +18,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <strings.h>
#include "avformat.h"
#include "metadata.h"
#include "libavutil/dict.h"
+#include "libavutil/avstring.h"
#if FF_API_OLD_METADATA2
AVDictionaryEntry *
@@ -69,13 +69,13 @@ void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv,
key = mtag->key;
if (s_conv)
for (sc=s_conv; sc->native; sc++)
- if (!strcasecmp(key, sc->native)) {
+ if (!av_strcasecmp(key, sc->native)) {
key = sc->generic;
break;
}
if (d_conv)
for (dc=d_conv; dc->native; dc++)
- if (!strcasecmp(key, dc->generic)) {
+ if (!av_strcasecmp(key, dc->generic)) {
key = dc->native;
break;
}
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index e3c0987b6e..ce547ead38 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <strings.h>
#include "avformat.h"
#include "avio_internal.h"
#include "id3v1.h"
@@ -64,7 +63,7 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t *buf)
buf[127] = 0xFF; /* default to unknown genre */
if ((tag = av_dict_get(s->metadata, "TCON", NULL, 0))) { //genre
for(i = 0; i <= ID3v1_GENRE_MAX; i++) {
- if (!strcasecmp(tag->value, ff_id3v1_genre_str[i])) {
+ if (!av_strcasecmp(tag->value, ff_id3v1_genre_str[i])) {
buf[127] = i;
count++;
break;
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 8903424b09..c41b4ce466 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -20,7 +20,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <strings.h>
#include "libavutil/avstring.h"
#include "libavutil/bswap.h"
#include "libavutil/dict.h"
@@ -459,8 +458,8 @@ static int decode_info_header(NUTContext *nut){
set_disposition_bits(s, str_value, stream_id_plus1 - 1);
continue;
}
- if(metadata && strcasecmp(name,"Uses")
- && strcasecmp(name,"Depends") && strcasecmp(name,"Replaces"))
+ if(metadata && av_strcasecmp(name,"Uses")
+ && av_strcasecmp(name,"Depends") && av_strcasecmp(name,"Replaces"))
av_dict_set(metadata, name, str_value, 0);
}
}
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 92535ec181..1e6bd6eee7 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -20,13 +20,13 @@
*/
#include "libavutil/mathematics.h"
+#include "libavutil/avstring.h"
#include "libavcodec/get_bits.h"
#include "avformat.h"
#include "mpegts.h"
#include "url.h"
#include <unistd.h>
-#include <strings.h>
#include "network.h"
#include "rtpdec.h"
@@ -91,7 +91,7 @@ RTPDynamicProtocolHandler *ff_rtp_handler_find_by_name(const char *name,
RTPDynamicProtocolHandler *handler;
for (handler = RTPFirstDynamicPayloadHandler;
handler; handler = handler->next)
- if (!strcasecmp(name, handler->enc_name) &&
+ if (!av_strcasecmp(name, handler->enc_name) &&
codec_type == handler->codec_type)
return handler;
return NULL;
diff --git a/libavformat/rtpdec_mpeg4.c b/libavformat/rtpdec_mpeg4.c
index 7a63cc315b..65071bd4d3 100644
--- a/libavformat/rtpdec_mpeg4.c
+++ b/libavformat/rtpdec_mpeg4.c
@@ -31,7 +31,6 @@
#include "internal.h"
#include "libavutil/avstring.h"
#include "libavcodec/get_bits.h"
-#include <strings.h>
/** Structure listing useful vars to parse RTP packet payload*/
struct PayloadContext
@@ -206,7 +205,7 @@ static int parse_fmtp(AVStream *stream, PayloadContext *data,
if (codec->codec_id == CODEC_ID_AAC) {
/* Looking for a known attribute */
for (i = 0; attr_names[i].str; ++i) {
- if (!strcasecmp(attr, attr_names[i].str)) {
+ if (!av_strcasecmp(attr, attr_names[i].str)) {
if (attr_names[i].type == ATTR_NAME_TYPE_INT) {
*(int *)((char *)data+
attr_names[i].offset) = atoi(value);
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index b9f340d7b1..c673c35572 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -34,7 +34,6 @@
#if HAVE_POLL_H
#include <poll.h>
#endif
-#include <strings.h>
#include "internal.h"
#include "network.h"
#include "os_support.h"
@@ -661,7 +660,7 @@ static void rtsp_parse_transport(RTSPMessageHeader *reply, const char *p)
get_word_sep(transport_protocol, sizeof(transport_protocol),
"/", &p);
- if (!strcasecmp (transport_protocol, "rtp")) {
+ if (!av_strcasecmp (transport_protocol, "rtp")) {
get_word_sep(profile, sizeof(profile), "/;,", &p);
lower_transport[0] = '\0';
/* rtp/avp/<protocol> */
@@ -670,14 +669,14 @@ static void rtsp_parse_transport(RTSPMessageHeader *reply, const char *p)
";,", &p);
}
th->transport = RTSP_TRANSPORT_RTP;
- } else if (!strcasecmp (transport_protocol, "x-pn-tng") ||
- !strcasecmp (transport_protocol, "x-real-rdt")) {
+ } else if (!av_strcasecmp (transport_protocol, "x-pn-tng") ||
+ !av_strcasecmp (transport_protocol, "x-real-rdt")) {
/* x-pn-tng/<protocol> */
get_word_sep(lower_transport, sizeof(lower_transport), "/;,", &p);
profile[0] = '\0';
th->transport = RTSP_TRANSPORT_RDT;
}
- if (!strcasecmp(lower_transport, "TCP"))
+ if (!av_strcasecmp(lower_transport, "TCP"))
th->lower_transport = RTSP_LOWER_TRANSPORT_TCP;
else
th->lower_transport = RTSP_LOWER_TRANSPORT_UDP;
@@ -1556,7 +1555,7 @@ redirect:
if (rt->server_type != RTSP_SERVER_REAL && reply->real_challenge[0]) {
rt->server_type = RTSP_SERVER_REAL;
continue;
- } else if (!strncasecmp(reply->server, "WMServer/", 9)) {
+ } else if (!av_strncasecmp(reply->server, "WMServer/", 9)) {
rt->server_type = RTSP_SERVER_WMS;
} else if (rt->server_type == RTSP_SERVER_REAL)
strcpy(real_challenge, reply->real_challenge);
diff --git a/libavformat/utils.c b/libavformat/utils.c
index c13ce3da0c..78139764c0 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -37,7 +37,6 @@
#include "url.h"
#include <sys/time.h>
#include <time.h>
-#include <strings.h>
#include <stdarg.h>
#if CONFIG_NETWORK
#include "network.h"
@@ -169,7 +168,7 @@ int av_match_ext(const char *filename, const char *extensions)
while (*p != '\0' && *p != ',' && q-ext1<sizeof(ext1)-1)
*q++ = *p++;
*q = '\0';
- if (!strcasecmp(ext1, ext))
+ if (!av_strcasecmp(ext1, ext))
return 1;
if (*p == '\0')
break;
@@ -190,11 +189,11 @@ static int match_format(const char *name, const char *names)
namelen = strlen(name);
while ((p = strchr(names, ','))) {
len = FFMAX(p - names, namelen);
- if (!strncasecmp(name, names, len))
+ if (!av_strncasecmp(name, names, len))
return 1;
names = p+1;
}
- return !strcasecmp(name, names);
+ return !av_strcasecmp(name, names);
}
AVOutputFormat *av_guess_format(const char *short_name, const char *filename,