#include "output/output-item.h"
#include "output/text-item.h"
+#include "gl/error.h"
#include "gl/xalloc.h"
#include "gl/xmemdup0.h"
return driver;
}
+
+void
+output_driver_parse_option (const char *option, struct string_map *options)
+{
+ const char *equals = strchr (option, '=');
+ if (equals == NULL)
+ {
+ error (0, 0, _("%s: output option missing `='"), option);
+ return;
+ }
+
+ char *key = xmemdup0 (option, equals - option);
+ if (string_map_contains (options, key))
+ {
+ error (0, 0, _("%s: output option specified more than once"), key);
+ free (key);
+ return;
+ }
+
+ char *value = xmemdup0 (equals + 1, strlen (equals + 1));
+ string_map_insert_nocopy (options, key, value);
+}
void output_submit (struct output_item *);
void output_flush (void);
+void output_driver_parse_option (const char *option,
+ struct string_map *options);
struct output_driver *output_driver_create (struct string_map *options);
bool output_driver_is_registered (const struct output_driver *);
}
}
-static void
-parse_output_option (struct terminal_opts *to, const char *option)
-{
- const char *equals;
- char *key, *value;
-
- equals = strchr (option, '=');
- if (equals == NULL)
- {
- error (0, 0, _("%s: output option missing `='"), option);
- return;
- }
-
- key = xmemdup0 (option, equals - option);
- if (string_map_contains (&to->options, key))
- {
- error (0, 0, _("%s: output option specified more than once"), key);
- free (key);
- return;
- }
-
- value = xmemdup0 (equals + 1, strlen (equals + 1));
- string_map_insert_nocopy (&to->options, key, value);
-}
-
static char *
get_supported_formats (void)
{
break;
case OPT_OUTPUT_OPTION:
- parse_output_option (to, optarg);
+ output_driver_parse_option (optarg, &to->options);
break;
case OPT_NO_OUTPUT: