Browse code

ffprobe: make writer_print_integer support long long int values

This makes possible to use writer_print_integer for printing int64_t
values.

Stefano Sabatini authored on 2011/11/07 23:58:41
Showing 1 changed files
... ...
@@ -141,7 +141,7 @@ typedef struct Writer {
141 141
     void (*print_chapter_footer)(WriterContext *wctx, const char *);
142 142
     void (*print_section_header)(WriterContext *wctx, const char *);
143 143
     void (*print_section_footer)(WriterContext *wctx, const char *);
144
-    void (*print_integer)       (WriterContext *wctx, const char *, int);
144
+    void (*print_integer)       (WriterContext *wctx, const char *, long long int);
145 145
     void (*print_string)        (WriterContext *wctx, const char *, const char *);
146 146
     void (*show_tags)           (WriterContext *wctx, AVDictionary *dict);
147 147
     int flags;                  ///< a combination or WRITER_FLAG_*
... ...
@@ -254,7 +254,7 @@ static inline void writer_print_section_footer(WriterContext *wctx,
254 254
 }
255 255
 
256 256
 static inline void writer_print_integer(WriterContext *wctx,
257
-                                        const char *key, int val)
257
+                                        const char *key, long long int val)
258 258
 {
259 259
     wctx->writer->print_integer(wctx, key, val);
260 260
     wctx->nb_item++;
... ...
@@ -285,13 +285,10 @@ static void writer_print_time(WriterContext *wctx, const char *key,
285 285
 
286 286
 static void writer_print_ts(WriterContext *wctx, const char *key, int64_t ts)
287 287
 {
288
-    char buf[128];
289
-
290 288
     if (ts == AV_NOPTS_VALUE) {
291 289
         writer_print_string(wctx, key, "N/A", 1);
292 290
     } else {
293
-        snprintf(buf, sizeof(buf), "%"PRId64, ts);
294
-        writer_print_string(wctx, key, buf, 0);
291
+        writer_print_integer(wctx, key, ts);
295 292
     }
296 293
 }
297 294
 
... ...
@@ -436,9 +433,9 @@ static void default_print_str(WriterContext *wctx, const char *key, const char *
436 436
     printf("%s=%s\n", key, value);
437 437
 }
438 438
 
439
-static void default_print_int(WriterContext *wctx, const char *key, int value)
439
+static void default_print_int(WriterContext *wctx, const char *key, long long int value)
440 440
 {
441
-    printf("%s=%d\n", key, value);
441
+    printf("%s=%lld\n", key, value);
442 442
 }
443 443
 
444 444
 static void default_show_tags(WriterContext *wctx, AVDictionary *dict)
... ...
@@ -649,14 +646,14 @@ static void compact_print_str(WriterContext *wctx, const char *key, const char *
649 649
                                      value, compact->item_sep, wctx));
650 650
 }
651 651
 
652
-static void compact_print_int(WriterContext *wctx, const char *key, int value)
652
+static void compact_print_int(WriterContext *wctx, const char *key, long long int value)
653 653
 {
654 654
     CompactContext *compact = wctx->priv;
655 655
 
656 656
     if (wctx->nb_item) printf("%c", compact->item_sep);
657 657
     if (!compact->nokey)
658 658
         printf("%s=", key);
659
-    printf("%d", value);
659
+    printf("%lld", value);
660 660
 }
661 661
 
662 662
 static void compact_show_tags(WriterContext *wctx, AVDictionary *dict)
... ...
@@ -825,12 +822,12 @@ static void json_print_str(WriterContext *wctx, const char *key, const char *val
825 825
     json_print_item_str(wctx, key, value, INDENT);
826 826
 }
827 827
 
828
-static void json_print_int(WriterContext *wctx, const char *key, int value)
828
+static void json_print_int(WriterContext *wctx, const char *key, long long int value)
829 829
 {
830 830
     JSONContext *json = wctx->priv;
831 831
 
832 832
     if (wctx->nb_item) printf(",\n");
833
-    printf(INDENT "\"%s\": %d",
833
+    printf(INDENT "\"%s\": %lld",
834 834
            json_escape_str(&json->buf, &json->buf_size, key, wctx), value);
835 835
 }
836 836