- int i, ret = 1;
-
- PARA_NOTICE_LOG("opening wng %p with %d writer(s)\n", g, g->num_writers);
- register_task(&g->task);
- FOR_EACH_WRITER_NODE(i, g) {
- struct writer_node *wn = &g->writer_nodes[i];
- wn->wng = g;
- ret = wn->writer->open(wn);
- if (ret < 0)
- goto err_out;
- wn->chunk_bytes = ret;
- g->max_chunk_bytes = PARA_MAX(g->max_chunk_bytes, ret);
+ if (wid <= 0)
+ wid = default_writer_id();
+ return lls_command_name(WRITE_CMD(wid));
+}
+
+/**
+ * Check if the given string is a valid command line for any writer.
+ *
+ * \param wa String of the form writer_name options.
+ * \param lprp Contains the parsed command line on success.
+ *
+ * If wa is \p NULL, the (configuration-dependent) default writer is assumed.
+ * Otherwise, the function checks whether \a wa starts with the name of a
+ * supported writer. If a valid writer name was found, the rest of the command
+ * line is passed to the config parser of this writer.
+ *
+ * \return On success, the positive writer ID is returned. Otherwise the
+ * function prints an error message and calls exit().
+ */
+int check_writer_arg_or_die(const char *wa, struct lls_parse_result **lprp)
+{
+ int ret, writer_num, argc;
+ char **argv = NULL, *errctx = NULL;
+ const struct lls_command *cmd;
+
+ if (!wa || !*wa) {
+ writer_num = default_writer_id();
+ cmd = WRITE_CMD(writer_num);
+ argv = para_malloc(2 * sizeof(char *));
+ argc = 1;
+ argv[0] = para_strdup(lls_command_name(cmd));
+ argv[1] = NULL;
+ goto parse;