*/
static
void append_to_res_str(GString * const res_str,
- const struct argpar_item * const item)
+ const argpar_item_t * const item)
{
if (res_str->len > 0) {
g_string_append_c(res_str, ' ');
switch (argpar_item_type(item)) {
case ARGPAR_ITEM_TYPE_OPT:
{
- const struct argpar_opt_descr * const descr =
+ const argpar_opt_descr_t * const descr =
argpar_item_opt_descr(item);
const char * const arg = argpar_item_opt_arg(item);
static
void test_succeed(const char * const cmdline,
const char * const expected_cmd_line,
- const struct argpar_opt_descr * const descrs,
+ const argpar_opt_descr_t * const descrs,
const unsigned int expected_ingested_orig_args)
{
- struct argpar_iter *iter = NULL;
- const struct argpar_item *item = NULL;
- const struct argpar_error *error = NULL;
+ argpar_iter_t *iter = NULL;
+ const argpar_item_t *item = NULL;
+ const argpar_error_t *error = NULL;
GString * const res_str = g_string_new(NULL);
gchar ** const argv = g_strsplit(cmdline, " ", 0);
unsigned int i, actual_ingested_orig_args;
assert(iter);
for (i = 0; ; i++) {
- enum argpar_iter_next_status status;
+ argpar_iter_next_status_t status;
ARGPAR_ITEM_DESTROY_AND_RESET(item);
status = argpar_iter_next(iter, &item, &error);
{
/* No arguments */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
ARGPAR_OPT_DESCR_SENTINEL
};
/* Single long option */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', "salut", false },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Single short option */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'f', NULL, false },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Short and long option (aliases) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'f', "flaw", false },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Long option with argument (space form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', "tooth", true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Long option with argument (equal form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', "polish", true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Short option with argument (space form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'c', NULL, true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Short option with argument (glued form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'c', NULL, true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Short and long option (aliases) with argument (all forms) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'd', "dry", true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Many short options, last one with argument (glued form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'd', NULL, false },
{ 0, 'e', NULL, false },
{ 0, 'f', NULL, true },
/* Many options */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'd', NULL, false },
{ 0, 'e', "east", true },
{ 0, '\0', "mind", false },
/* Single non-option argument */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
ARGPAR_OPT_DESCR_SENTINEL
};
/* Two non-option arguments */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
ARGPAR_OPT_DESCR_SENTINEL
};
/* Single non-option argument mixed with options */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'd', NULL, false },
{ 0, '\0', "squeeze", true },
ARGPAR_OPT_DESCR_SENTINEL
/* Valid `---opt` */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', "-fuel", true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Long option containing `=` in argument (equal form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', "zebra", true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Short option's argument starting with `-` (glued form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'z', NULL, true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Short option's argument starting with `-` (space form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'z', NULL, true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Long option's argument starting with `-` (space form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', "janine", true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Long option's argument starting with `-` (equal form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', "janine", true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Long option's empty argument (equal form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'f', NULL, false },
{ 0, '\0', "yeah", true },
ARGPAR_OPT_DESCR_SENTINEL
/* `-` non-option argument */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'f', NULL, false },
ARGPAR_OPT_DESCR_SENTINEL
};
/* `--` non-option argument */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'f', NULL, false },
ARGPAR_OPT_DESCR_SENTINEL
};
"cornhole-cliche-tattooed-green-juice-adaptogen-"
"kitsch-lo-fi-vexillologist-migas-gentrify-"
"viral-raw-denim";
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', opt_name, true },
ARGPAR_OPT_DESCR_SENTINEL
};
*/
static
void test_fail(const char * const cmdline,
- const enum argpar_error_type expected_error_type,
+ const argpar_error_type_t expected_error_type,
const unsigned int expected_orig_index,
const char * const expected_unknown_opt_name,
const unsigned int expected_opt_descr_index,
const bool expected_is_short,
- const struct argpar_opt_descr * const descrs)
+ const argpar_opt_descr_t * const descrs)
{
- struct argpar_iter *iter = NULL;
- const struct argpar_item *item = NULL;
+ argpar_iter_t *iter = NULL;
+ const argpar_item_t *item = NULL;
gchar ** const argv = g_strsplit(cmdline, " ", 0);
unsigned int i;
- const struct argpar_error *error = NULL;
+ const argpar_error_t *error = NULL;
iter = argpar_iter_create(g_strv_length(argv),
(const char * const *) argv, descrs);
assert(iter);
for (i = 0; ; i++) {
- enum argpar_iter_next_status status;
+ argpar_iter_next_status_t status;
ARGPAR_ITEM_DESTROY_AND_RESET(item);
status = argpar_iter_next(iter, &item, &error);
/* Unknown short option (space form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'd', NULL, true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Unknown short option (glued form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'd', 0, true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Unknown long option (space form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', "sink", true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Unknown long option (equal form) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', "sink", true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Unknown option before non-option argument */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', "thumb", true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Unknown option after non-option argument */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', "thumb", true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Missing long option argument */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, '\0', "thumb", true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Missing short option argument */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'k', NULL, true },
ARGPAR_OPT_DESCR_SENTINEL
};
/* Missing short option argument (multiple glued) */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'a', NULL, false },
{ 0, 'b', NULL, false },
{ 0, 'c', NULL, true },
/* Unexpected long option argument */
{
- const struct argpar_opt_descr descrs[] = {
+ const argpar_opt_descr_t descrs[] = {
{ 0, 'c', "chevre", false },
ARGPAR_OPT_DESCR_SENTINEL
};