Rename C++ header files to .hpp
[lttng-tools.git] / src / bin / lttng / commands / list_triggers.cpp
index 9a57714b6f9cfa1ba9a5a073da37732278e82489..e7075844520eaeb7da3a90f086545e047969ac5c 100644 (file)
@@ -7,20 +7,21 @@
 
 #include <stdio.h>
 
-#include "../command.h"
+#include "../command.hpp"
 
 #include "common/argpar/argpar.h"
-#include "common/dynamic-array.h"
-#include "common/mi-lttng.h"
+#include "common/argpar-utils/argpar-utils.hpp"
+#include "common/dynamic-array.hpp"
+#include "common/mi-lttng.hpp"
 /* For lttng_condition_type_str(). */
-#include "lttng/condition/condition-internal.h"
+#include "lttng/condition/condition-internal.hpp"
 #include "lttng/condition/event-rule-matches.h"
-#include "lttng/condition/event-rule-matches-internal.h"
+#include "lttng/condition/event-rule-matches-internal.hpp"
 /* For lttng_domain_type_str(). */
-#include "lttng/domain-internal.h"
+#include "lttng/domain-internal.hpp"
 /* For lttng_event_rule_kernel_syscall_emission_site_str() */
-#include "lttng/event-rule/kernel-syscall-internal.h"
-#include "../loglevel.h"
+#include "lttng/event-rule/kernel-syscall-internal.hpp"
+#include "../loglevel.hpp"
 #include <lttng/lttng.h>
 
 #ifdef LTTNG_EMBED_HELP
@@ -747,7 +748,6 @@ static void print_condition_event_rule_matches(
 }
 
 static void print_action_errors(const struct lttng_trigger *trigger,
-               const struct lttng_action *action,
                const uint64_t *action_path_indexes,
                size_t action_path_length)
 {
@@ -962,7 +962,7 @@ void print_one_action(const struct lttng_trigger *trigger,
        }
 
        MSG("");
-       print_action_errors(trigger, action, action_path_indexes,
+       print_action_errors(trigger, action_path_indexes,
                        action_path_length);
 
 end:
@@ -1317,27 +1317,39 @@ static enum lttng_error_code mi_error_query_condition_callback(
 int cmd_list_triggers(int argc, const char **argv)
 {
        int ret;
-       struct argpar_parse_ret argpar_parse_ret = {};
+       struct argpar_iter *argpar_iter = NULL;
+       const struct argpar_item *argpar_item = NULL;
        struct lttng_triggers *triggers = NULL;
-       int i;
        struct mi_writer *mi_writer = NULL;
 
-       argpar_parse_ret = argpar_parse(
-                       argc - 1, argv + 1, list_trigger_options, true);
-       if (!argpar_parse_ret.items) {
-               ERR("%s", argpar_parse_ret.error);
+       argc--;
+       argv++;
+
+       argpar_iter = argpar_iter_create(argc, argv, list_trigger_options);
+       if (!argpar_iter) {
+               ERR("Failed to allocate an argpar iter.");
                goto error;
        }
 
-       for (i = 0; i < argpar_parse_ret.items->n_items; i++) {
-               const struct argpar_item *item =
-                               argpar_parse_ret.items->items[i];
+       while (true) {
+               enum parse_next_item_status status;
 
-               if (item->type == ARGPAR_ITEM_TYPE_OPT) {
-                       const struct argpar_item_opt *item_opt =
-                                       (const struct argpar_item_opt *) item;
+               status = parse_next_item(argpar_iter, &argpar_item, 1, argv,
+                       true, NULL, NULL);
+               if (status == PARSE_NEXT_ITEM_STATUS_ERROR ||
+                               status == PARSE_NEXT_ITEM_STATUS_ERROR_MEMORY) {
+                       goto error;
+               } else if (status == PARSE_NEXT_ITEM_STATUS_END) {
+                       break;
+               }
+
+               assert(status == PARSE_NEXT_ITEM_STATUS_OK);
 
-                       switch (item_opt->descr->id) {
+               if (argpar_item_type(argpar_item) == ARGPAR_ITEM_TYPE_OPT) {
+                       const struct argpar_opt_descr *descr =
+                               argpar_item_opt_descr(argpar_item);
+
+                       switch (descr->id) {
                        case OPT_HELP:
                                SHOW_HELP();
                                ret = 0;
@@ -1354,10 +1366,8 @@ int cmd_list_triggers(int argc, const char **argv)
                        }
 
                } else {
-                       const struct argpar_item_non_opt *item_non_opt =
-                               (const struct argpar_item_non_opt *) item;
-
-                       ERR("Unexpected argument: %s", item_non_opt->arg);
+                       ERR("Unexpected argument: %s",
+                               argpar_item_non_opt_arg(argpar_item));
                }
        }
 
@@ -1438,7 +1448,8 @@ error:
        ret = 1;
 
 end:
-       argpar_parse_ret_fini(&argpar_parse_ret);
+       argpar_item_destroy(argpar_item);
+       argpar_iter_destroy(argpar_iter);
        lttng_triggers_destroy(triggers);
        /* Mi clean-up. */
        if (mi_writer && mi_lttng_writer_destroy(mi_writer)) {
This page took 0.032236 seconds and 4 git commands to generate.