- }
-
- *s_ = s.string;
- return 1;
-}
-
-static void
-parse_options (const char *driver_name, char *options,
- struct string_map *option_map)
-{
- struct string key = DS_EMPTY_INITIALIZER;
- struct string value = DS_EMPTY_INITIALIZER;
-
- for (;;)
- {
- options += strspn (options, CC_SPACES);
- if (*options == '\0')
- break;
-
- if (!get_option_token (&options, driver_name, &key))
- break;
-
- options += strspn (options, CC_SPACES);
- if (*options != '=')
- {
- error (0, 0, _("syntax error expecting `=' "
- "parsing options for driver \"%s\""),
- driver_name);
- break;
- }
- options++;
-
- options += strspn (options, CC_SPACES);
- if (!get_option_token (&options, driver_name, &value))
- break;
-
- if (string_map_contains (option_map, ds_cstr (&key)))
- error (0, 0, _("driver \"%s\" defines option \"%s\" multiple times"),
- driver_name, ds_cstr (&key));
- else
- string_map_insert (option_map, ds_cstr (&key), ds_cstr (&value));
- }
-
- ds_destroy (&key);
- ds_destroy (&value);
-}
-
-static char *
-trim_token (char *token)
-{
- if (token != NULL)
- {
- char *end;
-
- /* Trim leading spaces. */
- while (isspace ((unsigned char) *token))
- token++;
-
- /* Trim trailing spaces. */
- end = strchr (token, '\0');
- while (end > token && isspace ((unsigned char) end[-1]))
- *--end = '\0';
-
- /* An empty token is a null token. */
- if (*token == '\0')
- return NULL;
- }
- return token;
-}
-
-static const struct output_driver_class *
-find_output_class (const char *name)
-{
- const struct output_driver_class **classp;
-
- for (classp = driver_classes; *classp != NULL; classp++)
- if (!strcmp ((*classp)->name, name))
- break;
-
- return *classp;
-}
-
-static struct output_driver *
-create_driver (const char *driver_name, const char *class_name,
- const char *device_type, struct string_map *options)
-{
- const struct output_driver_class *class;
- enum output_device_type type;
- struct output_driver *driver;
-
- type = OUTPUT_DEVICE_UNKNOWN;
- if (device_type != NULL && device_type[0] != '\0')
- {
- if (!strcmp (device_type, "listing"))
- type = OUTPUT_DEVICE_LISTING;
- else if (!strcmp (device_type, "screen"))
- type = OUTPUT_DEVICE_SCREEN;
- else if (!strcmp (device_type, "printer"))
- type = OUTPUT_DEVICE_PRINTER;