summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2015-04-06 01:45:37 +0200
committerLuca Barbato <lu_zero@gentoo.org>2015-04-07 12:36:11 +0200
commit27f274628234c1f934b9a6a6380ed567c1b4ceae (patch)
tree647efad34e75a371f43d71470c08eac773b4aa19 /libavutil
parent108f2f381acb93827fb4add0517eeae859afa3bf (diff)
parseutils: Make av_small_strptime public
And use it in libavformat. Based on a similar patch by Stefano Sabatini <stefasab@gmail.com>.
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/parseutils.c10
-rw-r--r--libavutil/parseutils.h31
-rw-r--r--libavutil/version.h2
3 files changed, 37 insertions, 6 deletions
diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index 0e07b4a4b1..be238f0dde 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -400,7 +400,7 @@ static int date_get_num(const char **pp,
return val;
}
-static const char *small_strptime(const char *p, const char *fmt, struct tm *dt)
+const char *av_small_strptime(const char *p, const char *fmt, struct tm *dt)
{
int c, val;
@@ -453,7 +453,7 @@ static const char *small_strptime(const char *p, const char *fmt, struct tm *dt)
dt->tm_mday = val;
break;
case 'T':
- p = small_strptime(p, "%H:%M:%S", dt);
+ p = av_small_strptime(p, "%H:%M:%S", dt);
if (!p)
return NULL;
break;
@@ -526,7 +526,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
/* parse the year-month-day part */
for (i = 0; i < FF_ARRAY_ELEMS(date_fmt); i++) {
- q = small_strptime(p, date_fmt[i], &dt);
+ q = av_small_strptime(p, date_fmt[i], &dt);
if (q) {
break;
}
@@ -550,7 +550,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
/* parse the hour-minute-second part */
for (i = 0; i < FF_ARRAY_ELEMS(time_fmt); i++) {
- q = small_strptime(p, time_fmt[i], &dt);
+ q = av_small_strptime(p, time_fmt[i], &dt);
if (q) {
break;
}
@@ -562,7 +562,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
++p;
}
/* parse timestr as HH:MM:SS */
- q = small_strptime(p, time_fmt[0], &dt);
+ q = av_small_strptime(p, time_fmt[0], &dt);
if (!q) {
char *o;
/* parse timestr as S+ */
diff --git a/libavutil/parseutils.h b/libavutil/parseutils.h
index 0844abb2f0..8e99634773 100644
--- a/libavutil/parseutils.h
+++ b/libavutil/parseutils.h
@@ -117,6 +117,37 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration);
int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
/**
+ * Simplified version of strptime
+ *
+ * Parse the input string p according to the format string fmt and
+ * store its results in the structure dt.
+ *
+ * Neither text and locale's alternative representation are supported.
+ *
+ * The supported input field descriptors are listed below.
+ * - %H: the hour as a decimal number, using a 24-hour clock, in the
+ * range '00' through '23'
+ * - %M: the minute as a decimal number, using a 24-hour clock, in the
+ * range '00' through '59'
+ * - %S: the second as a decimal number, using a 24-hour clock, in the
+ * range '00' through '59'
+ * - %Y: the year as a decimal number, using the Gregorian calendar
+ * - %m: the month as a decimal number, in the range '1' through '12'
+ * - %d: the day of the month as a decimal number, in the range '1'
+ * through '31'
+ * - %T: alias for '%H:%M:%S'
+ * - %%: a literal '%'
+ *
+ * @return a pointer to the first character not processed in this function
+ * call. In case the input string contains more characters than
+ * required by the format string the return value points right after
+ * the last consumed input character. In case the whole input string
+ * is consumed the return value points to the null byte at the end of
+ * the string. On failure NULL is returned.
+ */
+const char *av_small_strptime(const char *p, const char *fmt, struct tm *dt);
+
+/**
* Convert the decomposed UTC time in tm to a time_t value.
*/
time_t av_timegm(struct tm *tm);
diff --git a/libavutil/version.h b/libavutil/version.h
index b94db74d2c..14a406e7da 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 54
-#define LIBAVUTIL_VERSION_MINOR 10
+#define LIBAVUTIL_VERSION_MINOR 11
#define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \