+static struct driver_option *
+opt (struct output_driver *d, struct string_map *options, const char *key,
+ const char *default_value)
+{
+ return driver_option_get (d, options, key, default_value);
+}
+
+static struct output_driver *
+ascii_create (const char *file_name, enum settings_output_devices device_type,
+ struct string_map *o)
+{
+ struct output_driver *d;
+ struct ascii_driver *a;
+ int paper_length;
+ int right, bottom, left, top;
+
+ a = xzalloc (sizeof *a);
+ d = &a->driver;
+ output_driver_init (&a->driver, &ascii_driver_class, file_name, device_type);
+ a->append = parse_boolean (opt (d, o, "append", "false"));
+ a->headers = parse_boolean (opt (d, o, "headers", "false"));
+ a->paginate = parse_boolean (opt (d, o, "paginate", "false"));
+ a->squeeze_blank_lines = parse_boolean (opt (d, o, "squeeze", "true"));
+ a->emphasis = parse_enum (opt (d, o, "emphasis", "none"),
+ "bold", EMPH_BOLD,
+ "underline", EMPH_UNDERLINE,
+ "none", EMPH_NONE,
+ NULL_SENTINEL);
+
+ a->chart_file_name = parse_chart_file_name (opt (d, o, "charts", file_name));
+
+ a->top_margin = parse_int (opt (d, o, "top-margin", "0"), 0, INT_MAX);
+ a->bottom_margin = parse_int (opt (d, o, "bottom-margin", "0"), 0, INT_MAX);
+
+ a->width = parse_page_size (opt (d, o, "width", "79"));
+ paper_length = parse_page_size (opt (d, o, "length", "66"));
+ a->auto_width = a->width < 0;
+ a->auto_length = paper_length < 0;
+ a->length = paper_length - vertical_margins (a);
+
+ for (right = 0; right < 4; right++)
+ for (bottom = 0; bottom < 4; bottom++)
+ for (left = 0; left < 4; left++)
+ for (top = 0; top < 4; top++)
+ {
+ int indx = make_box_index (left, right, top, bottom);
+ const char *default_value;
+ char name[16];
+
+ sprintf (name, "box[%d%d%d%d]", right, bottom, left, top);
+ default_value = get_default_box (right, bottom, left, top);
+ a->box[indx] = parse_string (opt (d, o, name, default_value));
+ }
+ a->init = parse_string (opt (d, o, "init", ""));
+
+ a->command_name = NULL;
+ a->title = xstrdup ("");
+ a->subtitle = xstrdup ("");
+ a->file_name = xstrdup (file_name);
+ a->file = NULL;
+ a->error = false;
+ a->page_number = 0;
+ a->lines = NULL;
+ a->allocated_lines = 0;
+ a->chart_cnt = 1;
+
+ if (!update_page_size (a, true))
+ goto error;