typedef struct {
ProbeElement *prefix;
int level;
+ void (*print_header)(void);
+ void (*print_footer)(void);
+
+ void (*print_array_header) (const char *name);
+ void (*print_array_footer) (const char *name);
+ void (*print_object_header)(const char *name);
+ void (*print_object_footer)(const char *name);
+
+ void (*print_integer) (const char *key, int64_t value);
+ void (*print_string) (const char *key, const char *value);
} OutputContext;
static AVIOContext *probe_out = NULL;
}
}
-
-void (*print_header)(void) = ini_print_header;
-void (*print_footer)(void) = ini_print_footer;
-
-void (*print_array_header) (const char *name) = ini_print_array_header;
-void (*print_array_footer) (const char *name);
-void (*print_object_header)(const char *name) = ini_print_object_header;
-void (*print_object_footer)(const char *name);
-
-void (*print_integer) (const char *key, int64_t value) = ini_print_integer;
-void (*print_string) (const char *key, const char *value) = ini_print_string;
-
-
static void probe_group_enter(const char *name, int type)
{
int64_t count = -1;
static void probe_header(void)
{
- if (print_header)
- print_header();
+ if (octx.print_header)
+ octx.print_header();
probe_group_enter("root", OBJECT);
}
static void probe_footer(void)
{
- if (print_footer)
- print_footer();
+ if (octx.print_footer)
+ octx.print_footer();
probe_group_leave();
}
static void probe_array_header(const char *name)
{
- if (print_array_header)
- print_array_header(name);
+ if (octx.print_array_header)
+ octx.print_array_header(name);
probe_group_enter(name, ARRAY);
}
static void probe_array_footer(const char *name)
{
probe_group_leave();
- if (print_array_footer)
- print_array_footer(name);
+ if (octx.print_array_footer)
+ octx.print_array_footer(name);
}
static void probe_object_header(const char *name)
{
- if (print_object_header)
- print_object_header(name);
+ if (octx.print_object_header)
+ octx.print_object_header(name);
probe_group_enter(name, OBJECT);
}
static void probe_object_footer(const char *name)
{
probe_group_leave();
- if (print_object_footer)
- print_object_footer(name);
+ if (octx.print_object_footer)
+ octx.print_object_footer(name);
}
static void probe_int(const char *key, int64_t value)
{
- print_integer(key, value);
+ octx.print_integer(key, value);
octx.prefix[octx.level -1].nb_elems++;
}
static void probe_str(const char *key, const char *value)
{
- print_string(key, value);
+ octx.print_string(key, value);
octx.prefix[octx.level -1].nb_elems++;
}
{
if (!strcmp(arg, "json")) {
- print_header = json_print_header;
- print_footer = json_print_footer;
- print_array_header = json_print_array_header;
- print_array_footer = json_print_array_footer;
- print_object_header = json_print_object_header;
- print_object_footer = json_print_object_footer;
-
- print_integer = json_print_integer;
- print_string = json_print_string;
+ octx.print_header = json_print_header;
+ octx.print_footer = json_print_footer;
+ octx.print_array_header = json_print_array_header;
+ octx.print_array_footer = json_print_array_footer;
+ octx.print_object_header = json_print_object_header;
+ octx.print_object_footer = json_print_object_footer;
+
+ octx.print_integer = json_print_integer;
+ octx.print_string = json_print_string;
} else if (!strcmp(arg, "ini")) {
- print_header = ini_print_header;
- print_footer = ini_print_footer;
- print_array_header = ini_print_array_header;
- print_object_header = ini_print_object_header;
+ octx.print_header = ini_print_header;
+ octx.print_footer = ini_print_footer;
+ octx.print_array_header = ini_print_array_header;
+ octx.print_object_header = ini_print_object_header;
- print_integer = ini_print_integer;
- print_string = ini_print_string;
+ octx.print_integer = ini_print_integer;
+ octx.print_string = ini_print_string;
} else if (!strcmp(arg, "old")) {
- print_header = NULL;
- print_object_header = old_print_object_header;
- print_object_footer = old_print_object_footer;
+ octx.print_header = NULL;
+ octx.print_object_header = old_print_object_header;
+ octx.print_object_footer = old_print_object_footer;
- print_string = old_print_string;
+ octx.print_string = old_print_string;
} else {
av_log(NULL, AV_LOG_ERROR, "Unsupported formatter %s\n", arg);
return AVERROR(EINVAL);
{
do_show_format = 1;
nb_fmt_entries_to_show++;
- print_header = NULL;
- print_footer = NULL;
- print_array_header = NULL;
- print_array_footer = NULL;
- print_object_header = NULL;
- print_object_footer = NULL;
-
- print_integer = show_format_entry_integer;
- print_string = show_format_entry_string;
+ octx.print_header = NULL;
+ octx.print_footer = NULL;
+ octx.print_array_header = NULL;
+ octx.print_array_footer = NULL;
+ octx.print_object_header = NULL;
+ octx.print_object_footer = NULL;
+
+ octx.print_integer = show_format_entry_integer;
+ octx.print_string = show_format_entry_string;
av_dict_set(&fmt_entries_to_show, arg, "", 0);
return 0;
}
if (!probe_out)
exit(1);
+ octx.print_header = ini_print_header;
+ octx.print_footer = ini_print_footer;
+
+ octx.print_array_header = ini_print_array_header;
+ octx.print_object_header = ini_print_object_header;
+
+ octx.print_integer = ini_print_integer;
+ octx.print_string = ini_print_string;
+
probe_header();
ret = probe_file(input_filename);
probe_footer();