]> git.sesse.net Git - ffmpeg/commitdiff
parseutils: Make av_small_strptime public
authorLuca Barbato <lu_zero@gentoo.org>
Sun, 5 Apr 2015 23:45:37 +0000 (01:45 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Tue, 7 Apr 2015 10:36:11 +0000 (12:36 +0200)
And use it in libavformat.

Based on a similar patch by Stefano Sabatini <stefasab@gmail.com>.

configure
doc/APIchanges
libavformat/utils.c
libavutil/parseutils.c
libavutil/parseutils.h
libavutil/version.h

index 6ad813b71484f4b7999c8ea6bd5a02e5af684eb0..8821cbc331e6a54d756d8c60e8a7397ed6c50eae 100755 (executable)
--- a/configure
+++ b/configure
@@ -1487,7 +1487,6 @@ SYSTEM_FUNCS="
     setrlimit
     Sleep
     strerror_r
-    strptime
     sysconf
     sysctl
     usleep
@@ -4133,7 +4132,6 @@ check_func_headers time.h nanosleep || { check_func_headers time.h nanosleep -lr
 check_func  sched_getaffinity
 check_func  setrlimit
 check_func  strerror_r
-check_func  strptime
 check_func  sysconf
 check_func  sysctl
 check_func  usleep
index 75eb66b4d1259aad9f47838cf7d7638086d7179b..35830f82789d29fb3181734ef73f3387dff5ab1d 100644 (file)
@@ -13,6 +13,9 @@ libavutil:     2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxxxxxx - lavu 54.11.0
+  Add av_small_strptime().
+
 2015-xx-xx - xxxxxxx - lavc 56.22.0
   Add FF_PROFILE_DTS_EXPRESS.
 
index 6248c1e5cbd97087327dc532840f5aeaf809a646..c275d06df4b1236a8624ad82b8849a1c81888a47 100644 (file)
@@ -2902,21 +2902,14 @@ int ff_find_stream_index(AVFormatContext *s, int id)
 
 int64_t ff_iso8601_to_unix_time(const char *datestr)
 {
-#if HAVE_STRPTIME
     struct tm time1 = { 0 }, time2 = { 0 };
     char *ret1, *ret2;
-    ret1 = strptime(datestr, "%Y - %m - %d %T", &time1);
-    ret2 = strptime(datestr, "%Y - %m - %dT%T", &time2);
+    ret1 = av_small_strptime(datestr, "%Y - %m - %d %T", &time1);
+    ret2 = av_small_strptime(datestr, "%Y - %m - %dT%T", &time2);
     if (ret2 && !ret1)
         return av_timegm(&time2);
     else
         return av_timegm(&time1);
-#else
-    av_log(NULL, AV_LOG_WARNING,
-           "strptime() unavailable on this system, cannot convert "
-           "the date string.\n");
-    return 0;
-#endif
 }
 
 int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id,
index 0e07b4a4b12b222051160f0bd4b74d3cb46886fd..be238f0dde8fc9395f8af227b2851d5123703c70 100644 (file)
@@ -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+ */
index 0844abb2f0135a866017b4df8e7f7c8b5e8487b2..8e99634773cac1895de50af55483d659e3d327f7 100644 (file)
@@ -116,6 +116,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.
  */
index b94db74d2c4effedd1f0b13e2351f1f72cc50075..14a406e7da001d452ace07426e195c7eb849913e 100644 (file)
@@ -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, \