+static void
+configure_drivers (int width, int length, int min_break)
+{
+ struct string_map options, tmp;
+ struct output_driver *driver;
+
+ string_map_init (&options);
+ string_map_insert (&options, "format", "txt");
+ string_map_insert (&options, "output-file", "-");
+ string_map_insert_nocopy (&options, xstrdup ("width"),
+ xasprintf ("%d", width));
+ string_map_insert_nocopy (&options, xstrdup ("length"),
+ xasprintf ("%d", length));
+ if (min_break >= 0)
+ {
+ string_map_insert_nocopy (&options, xstrdup ("min-hbreak"),
+ xasprintf ("%d", min_break));
+ string_map_insert_nocopy (&options, xstrdup ("min-vbreak"),
+ xasprintf ("%d", min_break));
+ }
+ if (emphasis != NULL)
+ string_map_insert (&options, "emphasis", emphasis);
+ if (box != NULL)
+ string_map_insert (&options, "box", box);
+
+ /* Render to stdout. */
+ if (render_stdout)
+ {
+ string_map_clone (&tmp, &options);
+ ascii_driver = driver = output_driver_create (&tmp);
+ if (driver == NULL)
+ exit (EXIT_FAILURE);
+ output_driver_register (driver);
+ string_map_destroy (&tmp);
+ }
+
+ if (draw_mode)
+ {
+ string_map_destroy (&options);
+ return;
+ }
+
+ /* Render to <base>.txt. */
+ if (render_txt)
+ {
+ string_map_clear (&options);
+ string_map_insert_nocopy (&options, xstrdup ("output-file"),
+ xasprintf ("%s.txt", output_base));
+ driver = output_driver_create (&options);
+ if (driver == NULL)
+ exit (EXIT_FAILURE);
+ output_driver_register (driver);
+ }
+
+#ifdef HAVE_CAIRO
+ /* Render to <base>.pdf. */
+ if (render_pdf)
+ {
+ string_map_clear (&options);
+ string_map_insert_nocopy (&options, xstrdup ("output-file"),
+ xasprintf ("%s.pdf", output_base));
+ string_map_insert (&options, "top-margin", "0");
+ string_map_insert (&options, "bottom-margin", "0");
+ string_map_insert (&options, "left-margin", "0");
+ string_map_insert (&options, "right-margin", "0");
+ string_map_insert_nocopy (&options, xstrdup ("paper-size"),
+ xasprintf ("%dx%dpt", width * 5, length * 8));
+ if (min_break >= 0)
+ {
+ string_map_insert_nocopy (&options, xstrdup ("min-hbreak"),
+ xasprintf ("%d", min_break * 5));
+ string_map_insert_nocopy (&options, xstrdup ("min-vbreak"),
+ xasprintf ("%d", min_break * 8));
+ }
+ driver = output_driver_create (&options);
+ if (driver == NULL)
+ exit (EXIT_FAILURE);
+ output_driver_register (driver);
+ }
+#endif
+
+ /* Render to <base>.csv. */
+ if (render_csv)
+ {
+ string_map_clear (&options);
+ string_map_insert_nocopy (&options, xstrdup ("output-file"),
+ xasprintf ("%s.csv", output_base));
+ driver = output_driver_create (&options);
+ if (driver == NULL)
+ exit (EXIT_FAILURE);
+ output_driver_register (driver);
+ }
+
+ /* Render to <base>.odt. */
+ string_map_replace_nocopy (&options, xstrdup ("output-file"),
+ xasprintf ("%s.odt", output_base));
+ driver = output_driver_create (&options);
+ if (driver == NULL)
+ exit (EXIT_FAILURE);
+ output_driver_register (driver);
+
+ string_map_destroy (&options);
+}
+