}
static
-void destroy_item(struct bt_argpar_item * const item)
+void destroy_item(struct argpar_item * const item)
{
if (!item) {
goto end;
}
- if (item->type == BT_ARGPAR_ITEM_TYPE_OPT) {
- struct bt_argpar_item_opt * const opt_item = (void *) item;
+ if (item->type == ARGPAR_ITEM_TYPE_OPT) {
+ struct argpar_item_opt * const opt_item = (void *) item;
free((void *) opt_item->arg);
}
}
static
-bool push_item(struct bt_argpar_item_array * const array,
- struct bt_argpar_item * const item)
+bool push_item(struct argpar_item_array * const array,
+ struct argpar_item * const item)
{
bool success;
if (array->n_items == array->n_alloc) {
unsigned int new_n_alloc = array->n_alloc * 2;
- struct bt_argpar_item **new_items;
+ struct argpar_item **new_items;
new_items = argpar_realloc(array->items,
- struct bt_argpar_item *, new_n_alloc);
+ struct argpar_item *, new_n_alloc);
if (!new_items) {
success = false;
goto end;
}
static
-void destroy_item_array(struct bt_argpar_item_array * const array)
+void destroy_item_array(struct argpar_item_array * const array)
{
if (array) {
unsigned int i;
}
static
-struct bt_argpar_item_array *new_item_array(void)
+struct argpar_item_array *new_item_array(void)
{
- struct bt_argpar_item_array *ret;
+ struct argpar_item_array *ret;
const int initial_size = 10;
- ret = argpar_zalloc(struct bt_argpar_item_array);
+ ret = argpar_zalloc(struct argpar_item_array);
if (!ret) {
goto end;
}
- ret->items = argpar_calloc(struct bt_argpar_item *, initial_size);
+ ret->items = argpar_calloc(struct argpar_item *, initial_size);
if (!ret->items) {
goto error;
}
}
static
-struct bt_argpar_item_opt *create_opt_item(
- const struct bt_argpar_opt_descr * const descr,
+struct argpar_item_opt *create_opt_item(
+ const struct argpar_opt_descr * const descr,
const char * const arg)
{
- struct bt_argpar_item_opt *opt_item =
- argpar_zalloc(struct bt_argpar_item_opt);
+ struct argpar_item_opt *opt_item =
+ argpar_zalloc(struct argpar_item_opt);
if (!opt_item) {
goto end;
}
- opt_item->base.type = BT_ARGPAR_ITEM_TYPE_OPT;
+ opt_item->base.type = ARGPAR_ITEM_TYPE_OPT;
opt_item->descr = descr;
if (arg) {
}
static
-struct bt_argpar_item_non_opt *create_non_opt_item(const char * const arg,
+struct argpar_item_non_opt *create_non_opt_item(const char * const arg,
const unsigned int orig_index,
const unsigned int non_opt_index)
{
- struct bt_argpar_item_non_opt * const non_opt_item =
- argpar_zalloc(struct bt_argpar_item_non_opt);
+ struct argpar_item_non_opt * const non_opt_item =
+ argpar_zalloc(struct argpar_item_non_opt);
if (!non_opt_item) {
goto end;
}
- non_opt_item->base.type = BT_ARGPAR_ITEM_TYPE_NON_OPT;
+ non_opt_item->base.type = ARGPAR_ITEM_TYPE_NON_OPT;
non_opt_item->arg = arg;
non_opt_item->orig_index = orig_index;
non_opt_item->non_opt_index = non_opt_index;
}
static
-const struct bt_argpar_opt_descr *find_descr(
- const struct bt_argpar_opt_descr * const descrs,
+const struct argpar_opt_descr *find_descr(
+ const struct argpar_opt_descr * const descrs,
const char short_name, const char * const long_name)
{
- const struct bt_argpar_opt_descr *descr;
+ const struct argpar_opt_descr *descr;
for (descr = descrs; descr->short_name || descr->long_name; descr++) {
if (short_name && descr->short_name &&
static
enum parse_orig_arg_opt_ret parse_short_opts(const char * const short_opts,
const char * const next_orig_arg,
- const struct bt_argpar_opt_descr * const descrs,
- struct bt_argpar_parse_ret * const parse_ret,
+ const struct argpar_opt_descr * const descrs,
+ struct argpar_parse_ret * const parse_ret,
bool * const used_next_orig_arg)
{
enum parse_orig_arg_opt_ret ret = PARSE_ORIG_ARG_OPT_RET_OK;
while (*short_opt_ch) {
const char *opt_arg = NULL;
- const struct bt_argpar_opt_descr *descr;
- struct bt_argpar_item_opt *opt_item;
+ const struct argpar_opt_descr *descr;
+ struct argpar_item_opt *opt_item;
/* Find corresponding option descriptor */
descr = find_descr(descrs, *short_opt_ch, NULL);
static
enum parse_orig_arg_opt_ret parse_long_opt(const char * const long_opt_arg,
const char * const next_orig_arg,
- const struct bt_argpar_opt_descr * const descrs,
- struct bt_argpar_parse_ret * const parse_ret,
+ const struct argpar_opt_descr * const descrs,
+ struct argpar_parse_ret * const parse_ret,
bool * const used_next_orig_arg)
{
const size_t max_len = 127;
enum parse_orig_arg_opt_ret ret = PARSE_ORIG_ARG_OPT_RET_OK;
- const struct bt_argpar_opt_descr *descr;
- struct bt_argpar_item_opt *opt_item;
+ const struct argpar_opt_descr *descr;
+ struct argpar_item_opt *opt_item;
/* Option's argument, if any */
const char *opt_arg = NULL;
static
enum parse_orig_arg_opt_ret parse_orig_arg_opt(const char * const orig_arg,
const char * const next_orig_arg,
- const struct bt_argpar_opt_descr * const descrs,
- struct bt_argpar_parse_ret * const parse_ret,
+ const struct argpar_opt_descr * const descrs,
+ struct argpar_parse_ret * const parse_ret,
bool * const used_next_orig_arg)
{
enum parse_orig_arg_opt_ret ret = PARSE_ORIG_ARG_OPT_RET_OK;
}
ARGPAR_HIDDEN
-struct bt_argpar_parse_ret bt_argpar_parse(unsigned int argc,
+struct argpar_parse_ret argpar_parse(unsigned int argc,
const char * const *argv,
- const struct bt_argpar_opt_descr * const descrs,
+ const struct argpar_opt_descr * const descrs,
bool fail_on_unknown_opt)
{
- struct bt_argpar_parse_ret parse_ret = { 0 };
+ struct argpar_parse_ret parse_ret = { 0 };
unsigned int i;
unsigned int non_opt_index = 0;
if (orig_arg[0] != '-') {
/* Non-option argument */
- struct bt_argpar_item_non_opt *non_opt_item =
+ struct argpar_item_non_opt *non_opt_item =
create_non_opt_item(orig_arg, i, non_opt_index);
if (!non_opt_item) {
}
ARGPAR_HIDDEN
-void bt_argpar_parse_ret_fini(struct bt_argpar_parse_ret *ret)
+void argpar_parse_ret_fini(struct argpar_parse_ret *ret)
{
ARGPAR_ASSERT(ret);
#include <stdbool.h>
/* Sentinel for an option descriptor array */
-#define BT_ARGPAR_OPT_DESCR_SENTINEL { -1, '\0', NULL, false }
+#define ARGPAR_OPT_DESCR_SENTINEL { -1, '\0', NULL, false }
/*
* ARGPAR_HIDDEN: if argpar is used in some shared library, we don't want them
#endif
/* Option descriptor */
-struct bt_argpar_opt_descr {
+struct argpar_opt_descr {
/* Numeric ID for this option */
const int id;
};
/* Item type */
-enum bt_argpar_item_type {
+enum argpar_item_type {
/* Option */
- BT_ARGPAR_ITEM_TYPE_OPT,
+ ARGPAR_ITEM_TYPE_OPT,
/* Non-option */
- BT_ARGPAR_ITEM_TYPE_NON_OPT,
+ ARGPAR_ITEM_TYPE_NON_OPT,
};
/* Base item */
-struct bt_argpar_item {
- enum bt_argpar_item_type type;
+struct argpar_item {
+ enum argpar_item_type type;
};
/* Option item */
-struct bt_argpar_item_opt {
- struct bt_argpar_item base;
+struct argpar_item_opt {
+ struct argpar_item base;
/* Corresponding descriptor */
- const struct bt_argpar_opt_descr *descr;
+ const struct argpar_opt_descr *descr;
/* Argument, or `NULL` if none */
const char *arg;
};
/* Non-option item */
-struct bt_argpar_item_non_opt {
- struct bt_argpar_item base;
+struct argpar_item_non_opt {
+ struct argpar_item base;
/*
* Complete argument, pointing to one of the entries of the
unsigned int non_opt_index;
};
-struct bt_argpar_item_array {
- /* Array of `struct bt_argpar_item *`, or `NULL` on error */
- struct bt_argpar_item **items;
+struct argpar_item_array {
+ /* Array of `struct argpar_item *`, or `NULL` on error */
+ struct argpar_item **items;
/* Number of used slots in `items`. */
unsigned int n_items;
unsigned int n_alloc;
};
-/* What is returned by bt_argpar_parse() */
-struct bt_argpar_parse_ret {
- /* Array of `struct bt_argpar_item *`, or `NULL` on error */
- struct bt_argpar_item_array *items;
+/* What is returned by argpar_parse() */
+struct argpar_parse_ret {
+ /* Array of `struct argpar_item *`, or `NULL` on error */
+ struct argpar_item_array *items;
/* Error string, or `NULL` if none */
char *error;
/*
* Parses the arguments `argv` of which the count is `argc` using the
- * sentinel-terminated (use `BT_ARGPAR_OPT_DESCR_SENTINEL`) option
+ * sentinel-terminated (use `ARGPAR_OPT_DESCR_SENTINEL`) option
* descriptor array `descrs`.
*
* This function considers ALL the elements of `argv`, including the
* contains one entry for each instance).
*
* On success, this function returns an array of items
- * (`struct bt_argpar_item *`). Each item is to be casted to the
- * appropriate type (`struct bt_argpar_item_opt *` or
- * `struct bt_argpar_item_non_opt *`) depending on its type.
+ * (`struct argpar_item *`). Each item is to be casted to the
+ * appropriate type (`struct argpar_item_opt *` or
+ * `struct argpar_item_non_opt *`) depending on its type.
*
* The returned array contains the items in the same order that the
* arguments were parsed, including non-option arguments. This means,
* the `error` string member contains details about the error.
*
* You can finalize the returned structure with
- * bt_argpar_parse_ret_fini().
+ * argpar_parse_ret_fini().
*/
ARGPAR_HIDDEN
-struct bt_argpar_parse_ret bt_argpar_parse(unsigned int argc,
+struct argpar_parse_ret argpar_parse(unsigned int argc,
const char * const *argv,
- const struct bt_argpar_opt_descr *descrs,
+ const struct argpar_opt_descr *descrs,
bool fail_on_unknown_opt);
/*
- * Finalizes what is returned by bt_argpar_parse().
+ * Finalizes what is returned by argpar_parse().
*
- * It is safe to call bt_argpar_parse() multiple times with the same
+ * It is safe to call argpar_parse() multiple times with the same
* structure.
*/
ARGPAR_HIDDEN
-void bt_argpar_parse_ret_fini(struct bt_argpar_parse_ret *ret);
+void argpar_parse_ret_fini(struct argpar_parse_ret *ret);
#endif /* BABELTRACE_ARGPAR_H */
static
void test_succeed(const char *cmdline,
const char *expected_cmd_line,
- const struct bt_argpar_opt_descr *descrs,
+ const struct argpar_opt_descr *descrs,
unsigned int expected_ingested_orig_args)
{
- struct bt_argpar_parse_ret parse_ret;
+ struct argpar_parse_ret parse_ret;
GString *res_str = g_string_new(NULL);
gchar **argv = g_strsplit(cmdline, " ", 0);
unsigned int i;
assert(argv);
assert(res_str);
- parse_ret = bt_argpar_parse(g_strv_length(argv),
+ parse_ret = argpar_parse(g_strv_length(argv),
(const char * const *) argv, descrs, false);
ok(parse_ret.items,
- "bt_argpar_parse() succeeds for command line `%s`", cmdline);
+ "argpar_parse() succeeds for command line `%s`", cmdline);
ok(!parse_ret.error,
- "bt_argpar_parse() does not write an error for command line `%s`", cmdline);
+ "argpar_parse() does not write an error for command line `%s`", cmdline);
ok(parse_ret.ingested_orig_args == expected_ingested_orig_args,
- "bt_argpar_parse() returns the correct number of ingested "
+ "argpar_parse() returns the correct number of ingested "
"original arguments for command line `%s`", cmdline);
if (parse_ret.ingested_orig_args != expected_ingested_orig_args) {
diag("Expected: %u Got: %u", expected_ingested_orig_args,
}
if (!parse_ret.items) {
- fail("bt_argpar_parse() returns the expected parsed arguments "
+ fail("argpar_parse() returns the expected parsed arguments "
"for command line `%s`", cmdline);
goto end;
}
for (i = 0; i < parse_ret.items->n_items; i++) {
- const struct bt_argpar_item *arg = parse_ret.items->items[i];
+ const struct argpar_item *arg = parse_ret.items->items[i];
switch (arg->type) {
- case BT_ARGPAR_ITEM_TYPE_OPT:
+ case ARGPAR_ITEM_TYPE_OPT:
{
- const struct bt_argpar_item_opt *arg_opt =
+ const struct argpar_item_opt *arg_opt =
(const void *) arg;
if (arg_opt->descr->long_name) {
break;
}
- case BT_ARGPAR_ITEM_TYPE_NON_OPT:
+ case ARGPAR_ITEM_TYPE_NON_OPT:
{
- const struct bt_argpar_item_non_opt *arg_non_opt =
+ const struct argpar_item_non_opt *arg_non_opt =
(const void *) arg;
g_string_append_printf(res_str, "%s<%u,%u> ",
}
ok(strcmp(expected_cmd_line, res_str->str) == 0,
- "bt_argpar_parse() returns the expected parsed arguments "
+ "argpar_parse() returns the expected parsed arguments "
"for command line `%s`", cmdline);
if (strcmp(expected_cmd_line, res_str->str) != 0) {
diag("Expected: `%s`", expected_cmd_line);
}
end:
- bt_argpar_parse_ret_fini(&parse_ret);
+ argpar_parse_ret_fini(&parse_ret);
g_string_free(res_str, TRUE);
g_strfreev(argv);
}
{
/* No arguments */
{
- const struct bt_argpar_opt_descr descrs[] = {
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ const struct argpar_opt_descr descrs[] = {
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Single long option */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "salut", false },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Single short option */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'f', NULL, false },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Short and long option (aliases) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'f', "flaw", false },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Long option with argument (space form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "tooth", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Long option with argument (equal form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "polish", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Short option with argument (space form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'c', NULL, true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Short option with argument (glued form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'c', NULL, true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Short and long option (aliases) with argument (all forms) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'd', "dry", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Many short options, last one with argument (glued form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'd', NULL, false },
{ 0, 'e', NULL, false },
{ 0, 'f', NULL, true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Many options */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'd', NULL, false },
{ 0, 'e', "east", true },
{ 0, '\0', "mind", false },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Single non-option argument */
{
- const struct bt_argpar_opt_descr descrs[] = {
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ const struct argpar_opt_descr descrs[] = {
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Two non-option arguments */
{
- const struct bt_argpar_opt_descr descrs[] = {
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ const struct argpar_opt_descr descrs[] = {
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Single non-option argument mixed with options */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'd', NULL, false },
{ 0, '\0', "squeeze", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Unknown short option (space form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'd', NULL, true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Unknown short option (glued form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'd', NULL, true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Unknown long option (space form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "sink", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Unknown long option (equal form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "sink", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Unknown option before non-option argument */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "thumb", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Unknown option after non-option argument */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "thumb", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Valid `---opt` */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "-fuel", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Long option containing `=` in argument (equal form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "zebra", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Short option's argument starting with `-` (glued form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'z', NULL, true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Short option's argument starting with `-` (space form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'z', NULL, true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Long option's argument starting with `-` (space form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "janine", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Long option's argument starting with `-` (equal form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "janine", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
/* Long option's empty argument (equal form) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'f', NULL, false },
{ 0, '\0', "yeah", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_succeed(
*/
static
void test_fail(const char *cmdline, const char *expected_error,
- const struct bt_argpar_opt_descr *descrs)
+ const struct argpar_opt_descr *descrs)
{
- struct bt_argpar_parse_ret parse_ret;
+ struct argpar_parse_ret parse_ret;
gchar **argv = g_strsplit(cmdline, " ", 0);
- parse_ret = bt_argpar_parse(g_strv_length(argv),
+ parse_ret = argpar_parse(g_strv_length(argv),
(const char * const *) argv, descrs, true);
ok(!parse_ret.items,
- "bt_argpar_parse() fails for command line `%s`", cmdline);
+ "argpar_parse() fails for command line `%s`", cmdline);
ok(parse_ret.error,
- "bt_argpar_parse() writes an error string for command line `%s`",
+ "argpar_parse() writes an error string for command line `%s`",
cmdline);
if (parse_ret.items) {
- fail("bt_argpar_parse() writes the expected error string");
+ fail("argpar_parse() writes the expected error string");
goto end;
}
ok(strcmp(expected_error, parse_ret.error) == 0,
- "bt_argpar_parse() writes the expected error string "
+ "argpar_parse() writes the expected error string "
"for command line `%s`", cmdline);
if (strcmp(expected_error, parse_ret.error) != 0) {
diag("Expected: `%s`", expected_error);
}
end:
- bt_argpar_parse_ret_fini(&parse_ret);
+ argpar_parse_ret_fini(&parse_ret);
g_strfreev(argv);
}
{
/* Unknown long option */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "thumb", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_fail(
/* Unknown short option */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "thumb", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_fail(
/* Missing long option argument */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, '\0', "thumb", true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_fail(
/* Missing short option argument */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'k', NULL, true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_fail(
/* Missing short option argument (multiple glued) */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'a', NULL, false },
{ 0, 'b', NULL, false },
{ 0, 'c', NULL, true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_fail(
/* Invalid `-` */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'a', NULL, false },
{ 0, 'b', NULL, false },
{ 0, 'c', NULL, true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_fail(
/* Invalid `--` */
{
- const struct bt_argpar_opt_descr descrs[] = {
+ const struct argpar_opt_descr descrs[] = {
{ 0, 'a', NULL, false },
{ 0, 'b', NULL, false },
{ 0, 'c', NULL, true },
- BT_ARGPAR_OPT_DESCR_SENTINEL
+ ARGPAR_OPT_DESCR_SENTINEL
};
test_fail(