-__malloc static void *aow_parse_config_or_die(int argc, char **argv)
-{
- struct ao_write_args_info *conf = para_calloc(sizeof(*conf));
-
- /* exits on errors */
- ao_write_cmdline_parser(argc, argv, conf);
- return conf;
-}
-
-static void aow_free_config(void *conf)
-{
- ao_write_cmdline_parser_free(conf);
-}
-
-/**
- * The init function of the ao writer.
- *
- * \param w Pointer to the writer to initialize.
- *
- * \sa struct writer.
- */
-void ao_write_init(struct writer *w)
-{
- struct ao_write_args_info dummy;
- int i, j, num_drivers, num_lines;
- ao_info **driver_list;
- char **dh; /* detailed help */
-
- ao_write_cmdline_parser_init(&dummy);
- w->close = aow_close;
- w->pre_select = aow_pre_select;
- w->post_select = aow_post_select;
- w->parse_config_or_die = aow_parse_config_or_die;
- w->free_config = aow_free_config;
- w->help = (struct ggo_help)DEFINE_GGO_HELP(ao_write);
- /* create detailed help containing all supported drivers/options */
- for (i = 0; ao_write_args_info_detailed_help[i]; i++)
- ; /* nothing */
- num_lines = i;
- dh = para_malloc((num_lines + 3) * sizeof(char *));
- for (i = 0; i < num_lines; i++)
- dh[i] = para_strdup(ao_write_args_info_detailed_help[i]);
- dh[num_lines++] = para_strdup("libao drivers available on this host:");
- dh[num_lines++] = para_strdup("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
-
- ao_initialize();
- driver_list = ao_driver_info_list(&num_drivers);
-
- for (i = 0; i < num_drivers; i++) {
- ao_info *info = driver_list[i];
- char *keys = NULL, *tmp = NULL;
-
- if (info->type == AO_TYPE_FILE)
- continue;
- for (j = 0; j < info->option_count; j++) {
- tmp = make_message("%s%s%s", keys? keys : "",
- keys? ", " : "",
- info->options[j]);
- free(keys);
- keys = tmp;
- }
- dh = para_realloc(dh, (num_lines + 6) * sizeof(char *));
- dh[num_lines++] = make_message("%s: %s", info->short_name, info->name);
- dh[num_lines++] = make_message("priority: %d", info->priority);
- dh[num_lines++] = make_message("keys: %s", keys? keys : "[none]");
- dh[num_lines++] = make_message("comment: %s", info->comment?
- info->comment : "[none]");
- dh[num_lines++] = para_strdup(NULL);
- free(keys);
- }
- dh[num_lines] = NULL;
- w->help.detailed_help = (const char **)dh;
- ao_write_cmdline_parser_free(&dummy);
- ao_shutdown();
-}