23 #include "./arguments_impl.h"
24 #include "./remap_impl.h"
26 #include "rcl/error_handling.h"
30 #include "rcl/visibility_control.h"
31 #include "rcl_yaml_param_parser/parser.h"
32 #include "rcl_yaml_param_parser/types.h"
33 #include "rcutils/allocator.h"
34 #include "rcutils/error_handling.h"
35 #include "rcutils/logging.h"
36 #include "rcutils/logging_macros.h"
37 #include "rcutils/strdup.h"
38 #include "rcutils/types/rcutils_ret.h"
52 _rcl_parse_remap_rule(
69 _rcl_parse_param_rule(
71 rcl_params_t * params);
77 char *** parameter_files)
83 *(parameter_files) = allocator.allocate(
85 if (NULL == *parameter_files) {
90 if (NULL == (*parameter_files)[i]) {
92 for (
int r = i; r >= 0; --r) {
93 allocator.deallocate((*parameter_files)[r], allocator.state);
95 allocator.deallocate((*parameter_files), allocator.state);
96 (*parameter_files) = NULL;
107 if (NULL == args || NULL == args->
impl) {
116 rcl_params_t ** parameter_overrides)
122 if (NULL != *parameter_overrides) {
123 RCL_SET_ERROR_MSG(
"Output parameter override pointer is not null. May leak memory.");
126 *parameter_overrides = NULL;
129 if (NULL == *parameter_overrides) {
161 _rcl_parse_log_level(
176 _rcl_parse_external_log_file_name(
179 char ** log_file_name_prefix);
192 _rcl_parse_external_log_config_file(
195 char ** log_config_file);
210 _rcl_parse_param_file(
213 rcl_params_t * params,
232 #define RCL_ENABLE_FLAG_PREFIX "--enable-"
233 #define RCL_DISABLE_FLAG_PREFIX "--disable-"
245 _rcl_parse_disabling_flag(
263 const char *
const * argv,
269 RCL_SET_ERROR_MSG(
"Argument count cannot be negative");
271 }
else if (argc > 0) {
276 if (args_output->
impl != NULL) {
277 RCL_SET_ERROR_MSG(
"Parse output is not zero-initialized");
284 ret = _rcl_allocate_initialized_arguments_impl(args_output, &allocator);
308 args_impl->
parameter_files = allocator.allocate(
sizeof(
char *) * argc, allocator.state);
313 args_impl->
unparsed_ros_args = allocator.allocate(
sizeof(
int) * argc, allocator.state);
318 args_impl->
unparsed_args = allocator.allocate(
sizeof(
int) * argc, allocator.state);
330 bool parsing_ros_args =
false;
331 for (
int i = 0; i < argc; ++i) {
332 if (parsing_ros_args) {
340 parsing_ros_args =
false;
349 RCUTILS_LOG_DEBUG_NAMED(
350 ROS_PACKAGE_NAME,
"Got param override rule : %s\n", argv[i + 1]);
354 rcl_error_string_t prev_error_string = rcl_get_error_string();
356 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
357 "Couldn't parse parameter override rule: '%s %s'. Error: %s", argv[i], argv[i + 1],
358 prev_error_string.str);
360 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
361 "Couldn't parse trailing %s flag. No parameter override rule found.", argv[i]);
366 RCUTILS_LOG_DEBUG_NAMED(
367 ROS_PACKAGE_NAME,
"Arg %d (%s) is not a %s nor a %s flag.",
376 if (
RCL_RET_OK == _rcl_parse_remap_rule(argv[i + 1], allocator, rule)) {
378 RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Got remap rule : %s\n", argv[i + 1]);
382 rcl_error_string_t prev_error_string = rcl_get_error_string();
384 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
385 "Couldn't parse remap rule: '%s %s'. Error: %s", argv[i], argv[i + 1],
386 prev_error_string.str);
388 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
389 "Couldn't parse trailing %s flag. No remap rule found.", argv[i]);
394 RCUTILS_LOG_DEBUG_NAMED(
395 ROS_PACKAGE_NAME,
"Arg %d (%s) is not a %s nor a %s flag.",
409 RCUTILS_LOG_DEBUG_NAMED(
411 "Got params file : %s\ntotal num param files %d",
417 rcl_error_string_t prev_error_string = rcl_get_error_string();
419 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
420 "Couldn't parse params file: '%s %s'. Error: %s", argv[i], argv[i + 1],
421 prev_error_string.str);
423 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
424 "Couldn't parse trailing %s flag. No file path provided.", argv[i]);
429 RCUTILS_LOG_DEBUG_NAMED(
430 ROS_PACKAGE_NAME,
"Arg %d (%s) is not a %s flag.",
437 _rcl_parse_log_level(argv[i + 1], &args_impl->
log_levels))
439 RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Got log level: %s\n", argv[i + 1]);
443 rcl_error_string_t prev_error_string = rcl_get_error_string();
445 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
446 "Couldn't parse log level: '%s %s'. Error: %s", argv[i], argv[i + 1],
447 prev_error_string.str);
449 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
450 "Couldn't parse trailing log level flag: '%s'. No log level provided.", argv[i]);
455 RCUTILS_LOG_DEBUG_NAMED(
456 ROS_PACKAGE_NAME,
"Arg %d (%s) is not a %s flag.",
463 RCUTILS_LOG_DEBUG_NAMED(
464 ROS_PACKAGE_NAME,
"Overriding log file name : %s\n",
469 if (
RCL_RET_OK == _rcl_parse_external_log_file_name(
472 RCUTILS_LOG_DEBUG_NAMED(
473 ROS_PACKAGE_NAME,
"Got log file name prefix : %s\n",
478 rcl_error_string_t prev_error_string = rcl_get_error_string();
480 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
481 "Couldn't parse log file name prefix: '%s %s'. Error: %s", argv[i], argv[i + 1],
482 prev_error_string.str);
484 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
485 "Couldn't parse trailing %s flag. No string prefix provided.", argv[i]);
490 RCUTILS_LOG_DEBUG_NAMED(
491 ROS_PACKAGE_NAME,
"Arg %d (%s) is not a %s flag.",
498 RCUTILS_LOG_DEBUG_NAMED(
499 ROS_PACKAGE_NAME,
"Overriding log configuration file : %s\n",
504 if (
RCL_RET_OK == _rcl_parse_external_log_config_file(
507 RCUTILS_LOG_DEBUG_NAMED(
508 ROS_PACKAGE_NAME,
"Got log configuration file : %s\n",
513 rcl_error_string_t prev_error_string = rcl_get_error_string();
515 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
516 "Couldn't parse log configuration file: '%s %s'. Error: %s", argv[i], argv[i + 1],
517 prev_error_string.str);
519 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
520 "Couldn't parse trailing %s flag. No file path provided.", argv[i]);
525 RCUTILS_LOG_DEBUG_NAMED(
526 ROS_PACKAGE_NAME,
"Arg %d (%s) is not a %s flag.",
532 if (NULL != args_impl->
enclave) {
533 RCUTILS_LOG_DEBUG_NAMED(
534 ROS_PACKAGE_NAME,
"Overriding security enclave : %s\n",
536 allocator.deallocate(args_impl->
enclave, allocator.state);
540 argv[i + 1], allocator, &args_impl->
enclave))
542 RCUTILS_LOG_DEBUG_NAMED(
543 ROS_PACKAGE_NAME,
"Got enclave: %s\n",
548 rcl_error_string_t prev_error_string = rcl_get_error_string();
550 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
551 "Couldn't parse enclave name: '%s %s'. Error: %s", argv[i], argv[i + 1],
552 prev_error_string.str);
554 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
555 "Couldn't parse trailing %s flag. No enclave path provided.", argv[i]);
560 RCUTILS_LOG_DEBUG_NAMED(
561 ROS_PACKAGE_NAME,
"Arg %d (%s) is not a %s flag.",
565 ret = _rcl_parse_disabling_flag(
568 RCUTILS_LOG_DEBUG_NAMED(
569 ROS_PACKAGE_NAME,
"Disable log stdout ? %s\n",
573 RCUTILS_LOG_DEBUG_NAMED(
575 "Couldn't parse arg %d (%s) as %s%s or %s%s flag. Error: %s",
581 ret = _rcl_parse_disabling_flag(
584 RCUTILS_LOG_DEBUG_NAMED(
585 ROS_PACKAGE_NAME,
"Disable log rosout ? %s\n",
589 RCUTILS_LOG_DEBUG_NAMED(
591 "Couldn't parse arg %d (%s) as %s%s or %s%s flag. Error: %s",
597 ret = _rcl_parse_disabling_flag(
600 RCUTILS_LOG_DEBUG_NAMED(
601 ROS_PACKAGE_NAME,
"Disable log external lib ? %s\n",
605 RCUTILS_LOG_DEBUG_NAMED(
607 "Couldn't parse arg %d (%s) as %s%s or %s%s flag. Error: %s",
618 parsing_ros_args =
true;
625 if (
RCL_RET_OK == _rcl_parse_remap_rule(argv[i], allocator, rule)) {
626 RCUTILS_LOG_WARN_NAMED(
628 "Found remap rule '%s'. This syntax is deprecated. Use '%s %s %s' instead.",
630 RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME,
"Got remap rule : %s\n", argv[i + 1]);
634 RCUTILS_LOG_DEBUG_NAMED(
636 "Couldn't parse arg %d (%s) as a remap rule in its deprecated form. Error: %s",
637 i, argv[i], rcl_get_error_string().str);
649 allocator.deallocate(args_impl->
remap_rules, allocator.state);
652 rcl_remap_t * new_remap_rules = allocator.reallocate(
656 if (NULL == new_remap_rules) {
668 char ** new_parameter_files = allocator.reallocate(
672 if (NULL == new_parameter_files) {
702 allocator.deallocate(args_impl->
unparsed_args, allocator.state);
722 if (NULL != args_impl) {
725 RCUTILS_LOG_ERROR_NAMED(ROS_PACKAGE_NAME,
"Failed to fini arguments after earlier failure");
735 if (NULL == args || NULL == args->
impl) {
745 int ** output_unparsed_indices)
752 *output_unparsed_indices = NULL;
754 *output_unparsed_indices = allocator.allocate(
756 if (NULL == *output_unparsed_indices) {
770 if (NULL == args || NULL == args->
impl) {
780 int ** output_unparsed_ros_indices)
787 *output_unparsed_ros_indices = NULL;
789 *output_unparsed_ros_indices = allocator.allocate(
791 if (NULL == *output_unparsed_ros_indices) {
806 return zero_arguments;
811 const char *
const * argv,
815 const char *** nonros_argv)
821 if (NULL != *nonros_argv) {
822 RCL_SET_ERROR_MSG(
"Output nonros_argv pointer is not null. May leak memory.");
827 if (*nonros_argc < 0) {
828 RCL_SET_ERROR_MSG(
"Failed to get unparsed non ROS specific arguments count.");
830 }
else if (*nonros_argc > 0) {
835 if (0 == *nonros_argc) {
839 int * unparsed_indices = NULL;
846 size_t alloc_size =
sizeof(
char *) * *nonros_argc;
847 *nonros_argv = allocator.allocate(alloc_size, allocator.state);
848 if (NULL == *nonros_argv) {
849 allocator.deallocate(unparsed_indices, allocator.state);
852 for (
int i = 0; i < *nonros_argc; ++i) {
853 (*nonros_argv)[i] = argv[unparsed_indices[i]];
856 allocator.deallocate(unparsed_indices, allocator.state);
871 if (NULL != args_out->
impl) {
872 RCL_SET_ERROR_MSG(
"args_out must be zero initialized");
878 rcl_ret_t ret = _rcl_allocate_initialized_arguments_impl(args_out, &allocator);
889 RCL_SET_ERROR_MSG(
"Error while finalizing arguments due to another error");
905 RCL_SET_ERROR_MSG(
"Error while finalizing arguments due to another error");
921 RCL_SET_ERROR_MSG(
"Error while finalizing arguments due to another error");
931 RCL_SET_ERROR_MSG(
"Error while finalizing arguments due to another error");
951 RCL_SET_ERROR_MSG(
"Error while finalizing arguments due to another error");
960 RCL_SET_ERROR_MSG(
"Error while finalizing arguments due to another error");
967 char * enclave_copy = rcutils_strdup(args->
impl->
enclave, allocator);
970 RCL_SET_ERROR_MSG(
"Error while finalizing arguments due to another error");
972 RCL_SET_ERROR_MSG(
"Error while copying enclave argument");
992 RCUTILS_LOG_ERROR_NAMED(
994 "Failed to finalize remap rule while finalizing arguments. Continuing...");
1004 ret = log_levels_ret;
1005 RCUTILS_LOG_ERROR_NAMED(
1007 "Failed to finalize log levels while finalizing arguments. Continuing...");
1050 RCL_SET_ERROR_MSG(
"rcl_arguments_t finalized twice");
1060 _rcl_parse_remap_fully_qualified_namespace(
1066 assert(NULL != lex_lookahead);
1102 assert(NULL != lex_lookahead);
1114 RCL_SET_ERROR_MSG(
"Backreferences are not implemented");
1131 _rcl_parse_remap_replacement_name(
1139 assert(NULL != lex_lookahead);
1140 assert(NULL != rule);
1143 if (NULL == replacement_start) {
1144 RCL_SET_ERROR_MSG(
"failed to get start of replacement");
1161 ret = _rcl_parse_remap_replacement_token(lex_lookahead);
1174 ret = _rcl_parse_remap_replacement_token(lex_lookahead);
1186 size_t length = (size_t)(replacement_end - replacement_start);
1190 RCL_SET_ERROR_MSG(
"failed to copy replacement");
1209 assert(NULL != lex_lookahead);
1219 RCL_SET_ERROR_MSG(
"Wildcard '*' is not implemented");
1222 RCL_SET_ERROR_MSG(
"Wildcard '**' is not implemented");
1225 RCL_SET_ERROR_MSG(
"Expecting token or wildcard");
1238 _rcl_parse_resource_match(
1241 char ** resource_match)
1247 assert(NULL != lex_lookahead);
1248 assert(rcutils_allocator_is_valid(&allocator));
1249 assert(NULL != resource_match);
1250 assert(NULL == *resource_match);
1253 if (NULL == match_start) {
1254 RCL_SET_ERROR_MSG(
"failed to get start of match");
1271 ret = _rcl_parse_resource_match_token(lex_lookahead);
1287 ret = _rcl_parse_resource_match_token(lex_lookahead);
1299 const size_t length = (size_t)(match_end - match_start);
1300 *resource_match = rcutils_strndup(match_start, length, allocator);
1301 if (NULL == *resource_match) {
1302 RCL_SET_ERROR_MSG(
"failed to copy match");
1317 assert(NULL != lex_lookahead);
1325 RCL_SET_ERROR_MSG(
"Wildcard '*' is not implemented");
1328 RCL_SET_ERROR_MSG(
"Wildcard '**' is not implemented");
1331 RCL_SET_ERROR_MSG(
"Expecting token or wildcard");
1356 _rcl_parse_param_name(
1365 assert(NULL != lex_lookahead);
1366 assert(rcutils_allocator_is_valid(&allocator));
1367 assert(NULL != param_name);
1368 assert(NULL == *param_name);
1371 if (NULL == name_start) {
1372 RCL_SET_ERROR_MSG(
"failed to get start of param name");
1377 ret = _rcl_parse_param_name_token(lex_lookahead);
1390 ret = _rcl_parse_param_name_token(lex_lookahead);
1402 const size_t length = (size_t)(name_end - name_start);
1403 *param_name = rcutils_strndup(name_start, length, allocator);
1404 if (NULL == *param_name) {
1405 RCL_SET_ERROR_MSG(
"failed to copy param name");
1419 _rcl_parse_remap_match_name(
1427 assert(NULL != lex_lookahead);
1428 assert(NULL != rule);
1436 rule->
impl->
type = RCL_SERVICE_REMAP;
1439 rule->
impl->
type = RCL_TOPIC_REMAP;
1442 rule->
impl->
type = (RCL_TOPIC_REMAP | RCL_SERVICE_REMAP);
1448 ret = _rcl_parse_resource_match(
1462 _rcl_parse_remap_name_remap(
1469 assert(NULL != lex_lookahead);
1470 assert(NULL != rule);
1473 ret = _rcl_parse_remap_match_name(lex_lookahead, rule);
1483 ret = _rcl_parse_remap_replacement_name(lex_lookahead, rule);
1497 _rcl_parse_remap_namespace_replacement(
1504 assert(NULL != lex_lookahead);
1505 assert(NULL != rule);
1519 if (NULL == ns_start) {
1520 RCL_SET_ERROR_MSG(
"failed to get start of namespace");
1523 ret = _rcl_parse_remap_fully_qualified_namespace(lex_lookahead);
1527 RCUTILS_LOG_WARN_NAMED(
1528 ROS_PACKAGE_NAME,
"Namespace not remapped to a fully qualified name (found: %s)", ns_start);
1536 RCUTILS_LOG_WARN_NAMED(
1537 ROS_PACKAGE_NAME,
"Namespace not remapped to a fully qualified name (found: %s)", ns_start);
1543 size_t length = (size_t)(ns_end - ns_start);
1546 RCL_SET_ERROR_MSG(
"failed to copy namespace");
1550 rule->
impl->
type = RCL_NAMESPACE_REMAP;
1560 _rcl_parse_remap_nodename_replacement(
1565 const char * node_name;
1569 assert(NULL != lex_lookahead);
1570 assert(NULL != rule);
1586 RCUTILS_LOG_WARN_NAMED(
1587 ROS_PACKAGE_NAME,
"Node name not remapped to invalid name: '%s'", node_name);
1596 RCL_SET_ERROR_MSG(
"failed to allocate node name");
1600 rule->
impl->
type = RCL_NODENAME_REMAP;
1607 _rcl_parse_nodename_prefix(
1613 const char * token = NULL;
1616 assert(NULL != lex_lookahead);
1617 assert(rcutils_allocator_is_valid(&allocator));
1618 assert(NULL != node_name);
1619 assert(NULL == *node_name);
1633 *node_name = rcutils_strndup(token, length, allocator);
1634 if (NULL == *node_name) {
1635 RCL_SET_ERROR_MSG(
"failed to allocate node name");
1649 _rcl_parse_remap_nodename_prefix(
1654 assert(NULL != lex_lookahead);
1655 assert(NULL != rule);
1657 rcl_ret_t ret = _rcl_parse_nodename_prefix(
1676 _rcl_parse_remap_begin_remap_rule(
1685 assert(NULL != lex_lookahead);
1686 assert(NULL != rule);
1694 ret = _rcl_parse_remap_nodename_prefix(lex_lookahead, rule);
1707 ret = _rcl_parse_remap_nodename_replacement(lex_lookahead, rule);
1712 ret = _rcl_parse_remap_namespace_replacement(lex_lookahead, rule);
1717 ret = _rcl_parse_remap_name_remap(lex_lookahead, rule);
1733 _rcl_parse_log_level_name(
1736 char ** logger_name)
1741 assert(NULL != lex_lookahead);
1742 assert(rcutils_allocator_is_valid(allocator));
1743 assert(NULL != logger_name);
1744 assert(NULL == *logger_name);
1747 if (NULL == name_start) {
1748 RCL_SET_ERROR_MSG(
"failed to get start of logger name");
1776 const size_t length = (size_t)(name_end - name_start);
1777 *logger_name = rcutils_strndup(name_start, length, *allocator);
1778 if (NULL == *logger_name) {
1779 RCL_SET_ERROR_MSG(
"failed to copy logger name");
1787 _rcl_parse_log_level(
1798 char * logger_name = NULL;
1800 rcutils_ret_t rcutils_ret = RCUTILS_RET_OK;
1809 ret = _rcl_parse_log_level_name(&lex_lookahead, allocator, &logger_name);
1811 if (strlen(logger_name) == 0) {
1812 RCL_SET_ERROR_MSG(
"Argument has an invalid logger item that name is empty");
1823 const char * level_token;
1824 size_t level_token_length;
1838 rcutils_ret = rcutils_logging_severity_level_from_string(
1839 level_token, *allocator, &level);
1840 if (RCUTILS_RET_OK == rcutils_ret) {
1848 rcutils_ret = rcutils_logging_severity_level_from_string(
1849 arg, *allocator, &level);
1850 if (RCUTILS_RET_OK == rcutils_ret) {
1853 RCUTILS_LOG_DEBUG_NAMED(
1854 ROS_PACKAGE_NAME,
"Minimum default log level will be replaced from %d to %d",
1863 if (RCUTILS_RET_OK != rcutils_ret) {
1864 RCL_SET_ERROR_MSG(
"Argument does not use a valid severity level");
1870 allocator->deallocate(logger_name, allocator->state);
1875 RCUTILS_LOG_ERROR_NAMED(ROS_PACKAGE_NAME,
"Failed to fini lookahead2 after error occurred");
1885 _rcl_parse_remap_rule(
1895 if (NULL == output_rule->
impl) {
1899 output_rule->
impl->
type = RCL_UNKNOWN_REMAP;
1908 ret = _rcl_parse_remap_begin_remap_rule(&lex_lookahead, output_rule);
1913 RCUTILS_LOG_ERROR_NAMED(
1914 ROS_PACKAGE_NAME,
"Failed to fini lookahead2 after error occurred");
1926 RCUTILS_LOG_ERROR_NAMED(
1927 ROS_PACKAGE_NAME,
"Failed to fini remap rule after error occurred");
1934 _rcl_parse_param_rule(
1936 rcl_params_t * params)
1950 char * node_name = NULL;
1951 char * param_name = NULL;
1960 ret = _rcl_parse_nodename_prefix(&lex_lookahead, params->allocator, &node_name);
1968 node_name = rcutils_strdup(
"/**", params->allocator);
1969 if (NULL == node_name) {
1977 ret = _rcl_parse_param_name(&lex_lookahead, params->allocator, ¶m_name);
1992 if (!rcl_parse_yaml_value(node_name, param_name, yaml_value, params)) {
1998 params->allocator.deallocate(param_name, params->allocator.state);
1999 params->allocator.deallocate(node_name, params->allocator.state);
2002 RCUTILS_LOG_ERROR_NAMED(ROS_PACKAGE_NAME,
"Failed to fini lookahead2 after error occurred");
2011 _rcl_parse_param_file(
2014 rcl_params_t * params,
2020 *param_file = rcutils_strdup(arg, allocator);
2021 if (NULL == *param_file) {
2022 RCL_SET_ERROR_MSG(
"Failed to allocate memory for parameters file path");
2025 if (!rcl_parse_yaml_file(*param_file, params)) {
2026 allocator.deallocate(*param_file, allocator.state);
2035 _rcl_parse_external_log_file_name(
2038 char ** log_file_name_prefix)
2043 *log_file_name_prefix = rcutils_strdup(arg, allocator);
2044 if (NULL == *log_file_name_prefix) {
2045 RCL_SET_ERROR_MSG(
"Failed to allocate memory for external log file name prefix");
2052 _rcl_parse_external_log_config_file(
2055 char ** log_config_file)
2060 *log_config_file = rcutils_strdup(arg, allocator);
2062 if (NULL == *log_config_file) {
2063 RCL_SET_ERROR_MSG(
"Failed to allocate memory for external log config file");
2078 *enclave = rcutils_strdup(arg, allocator);
2079 if (NULL == *enclave) {
2080 RCL_SET_ERROR_MSG(
"Failed to allocate memory for enclave name");
2087 _rcl_parse_disabling_flag(
2089 const char * suffix,
2096 const size_t enable_prefix_len = strlen(RCL_ENABLE_FLAG_PREFIX);
2098 strncmp(RCL_ENABLE_FLAG_PREFIX, arg, enable_prefix_len) == 0 &&
2099 strcmp(suffix, arg + enable_prefix_len) == 0)
2105 const size_t disable_prefix_len = strlen(RCL_DISABLE_FLAG_PREFIX);
2107 strncmp(RCL_DISABLE_FLAG_PREFIX, arg, disable_prefix_len) == 0 &&
2108 strcmp(suffix, arg + disable_prefix_len) == 0)
2114 RCL_SET_ERROR_MSG_WITH_FORMAT_STRING(
2115 "Argument is not a %s%s nor a %s%s flag.",
2116 RCL_ENABLE_FLAG_PREFIX, suffix,
2117 RCL_DISABLE_FLAG_PREFIX, suffix);
2125 if (NULL == args->
impl) {
#define RCL_CHECK_ALLOCATOR_WITH_MSG(allocator, msg, fail_statement)
Check that the given allocator is initialized, or fail with a message.
rcutils_allocator_t rcl_allocator_t
Encapsulation of an allocator.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_arguments_get_unparsed_ros(const rcl_arguments_t *args, rcl_allocator_t allocator, int **output_unparsed_ros_indices)
Return a list of indices to unknown ROS specific arguments that were left unparsed.
#define RCL_ROS_ARGS_EXPLICIT_END_TOKEN
The token that delineates the explicit end of ROS arguments.
RCL_PUBLIC RCL_WARN_UNUSED int rcl_arguments_get_count_unparsed(const rcl_arguments_t *args)
Return the number of arguments that were not ROS specific arguments.
#define RCL_LOG_LEVEL_FLAG
The ROS flag that precedes the ROS logging level to set.
#define RCL_LOG_ROSOUT_FLAG_SUFFIX
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_arguments_get_param_files(const rcl_arguments_t *arguments, rcl_allocator_t allocator, char ***parameter_files)
Return a list of yaml parameter file paths specified on the command line.
#define RCL_EXTERNAL_LOG_FILE_NAME_PREFIX
The ROS log file name prefix to configure external logging.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_arguments_copy(const rcl_arguments_t *args, rcl_arguments_t *args_out)
Copy one arguments structure into another.
#define RCL_PARAM_FLAG
The ROS flag that precedes the setting of a ROS parameter.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_arguments_get_param_overrides(const rcl_arguments_t *arguments, rcl_params_t **parameter_overrides)
Return all parameter overrides parsed from the command line.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_arguments_get_log_levels(const rcl_arguments_t *arguments, rcl_log_levels_t *log_levels)
Return log levels parsed from the command line.
#define RCL_ROS_ARGS_FLAG
The command-line flag that delineates the start of ROS arguments.
#define RCL_LOG_EXT_LIB_FLAG_SUFFIX
#define RCL_SHORT_PARAM_FLAG
The short version of the ROS flag that precedes the setting of a ROS parameter.
#define RCL_ENCLAVE_FLAG
The ROS flag that precedes the name of a ROS security enclave.
#define RCL_LOG_STDOUT_FLAG_SUFFIX
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_parse_arguments(int argc, const char *const *argv, rcl_allocator_t allocator, rcl_arguments_t *args_output)
Parse command line arguments into a structure usable by code.
#define RCL_REMAP_FLAG
The ROS flag that precedes a ROS remapping rule.
#define RCL_EXTERNAL_LOG_CONFIG_FLAG
The ROS flag that precedes the name of a configuration file to configure logging.
#define RCL_SHORT_REMAP_FLAG
The short version of the ROS flag that precedes a ROS remapping rule.
#define RCL_SHORT_ENCLAVE_FLAG
The short version of the ROS flag that precedes the name of a ROS security enclave.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_arguments_fini(rcl_arguments_t *args)
Reclaim resources held inside rcl_arguments_t structure.
RCL_PUBLIC RCL_WARN_UNUSED int rcl_arguments_get_param_files_count(const rcl_arguments_t *args)
Return the number of parameter yaml files given in the arguments.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_arguments_get_unparsed(const rcl_arguments_t *args, rcl_allocator_t allocator, int **output_unparsed_indices)
Return a list of indices to non ROS specific arguments.
RCL_PUBLIC RCL_WARN_UNUSED int rcl_arguments_get_count_unparsed_ros(const rcl_arguments_t *args)
Return the number of ROS specific arguments that were not successfully parsed.
#define RCL_PARAM_FILE_FLAG
The ROS flag that precedes a path to a file containing ROS parameters.
RCL_PUBLIC RCL_WARN_UNUSED rcl_arguments_t rcl_get_zero_initialized_arguments(void)
Return a rcl_arguments_t struct with members initialized to NULL.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_remove_ros_arguments(const char *const *argv, const rcl_arguments_t *args, rcl_allocator_t allocator, int *nonros_argc, const char ***nonros_argv)
Return a list of arguments with ROS-specific arguments removed.
@ RCL_LEXEME_TOKEN
a name between slashes, must match (([a-zA-Z](_)?)|_)([0-9a-zA-Z](_)?)*
@ RCL_LEXEME_EOF
Indicates end of input has been reached.
@ RCL_LEXEME_URL_TOPIC
rostopic://
@ RCL_LEXEME_URL_SERVICE
rosservice://
@ RCL_LEXEME_TILDE_SLASH
~/
@ RCL_LEXEME_FORWARD_SLASH
/
@ RCL_LEXEME_NODE
__node or __name
@ RCL_LEXEME_WILD_MULTI
**
enum rcl_lexeme_e rcl_lexeme_t
Type of lexeme found by lexical analysis.
RCL_PUBLIC RCL_WARN_UNUSED rcl_lexer_lookahead2_t rcl_get_zero_initialized_lexer_lookahead2(void)
Get a zero initialized rcl_lexer_lookahead2_t instance.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_lookahead2_fini(rcl_lexer_lookahead2_t *buffer)
Finalize an instance of an rcl_lexer_lookahead2_t structure.
RCL_PUBLIC RCL_WARN_UNUSED const char * rcl_lexer_lookahead2_get_text(const rcl_lexer_lookahead2_t *buffer)
Get the text at the point where it is currently being analyzed.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_lookahead2_peek2(rcl_lexer_lookahead2_t *buffer, rcl_lexeme_t *next_type1, rcl_lexeme_t *next_type2)
Look ahead at the next two lexemes in the string.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_lookahead2_accept(rcl_lexer_lookahead2_t *buffer, const char **lexeme_text, size_t *lexeme_text_length)
Accept a lexeme and advance analysis.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_lookahead2_expect(rcl_lexer_lookahead2_t *buffer, rcl_lexeme_t type, const char **lexeme_text, size_t *lexeme_text_length)
Require the next lexeme to be a certain type and advance analysis.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_lookahead2_peek(rcl_lexer_lookahead2_t *buffer, rcl_lexeme_t *next_type)
Look ahead at the next lexeme in the string.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_lexer_lookahead2_init(rcl_lexer_lookahead2_t *buffer, const char *text, rcl_allocator_t allocator)
Initialize an rcl_lexer_lookahead2_t instance.
RCL_PUBLIC rcl_ret_t rcl_log_levels_fini(rcl_log_levels_t *log_levels)
Reclaim resources held inside rcl_log_levels_t structure.
enum RCUTILS_LOG_SEVERITY rcl_log_severity_t
typedef for RCUTILS_LOG_SEVERITY;
RCL_PUBLIC rcl_ret_t rcl_log_levels_add_logger_setting(rcl_log_levels_t *log_levels, const char *logger_name, rcl_log_severity_t log_level)
Add logger setting with a name and a level.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_log_levels_init(rcl_log_levels_t *log_levels, const rcl_allocator_t *allocator, size_t logger_count)
Initialize a log levels structure.
RCL_PUBLIC rcl_ret_t rcl_log_levels_shrink_to_size(rcl_log_levels_t *log_levels)
Shrink log levels structure.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_log_levels_copy(const rcl_log_levels_t *src, rcl_log_levels_t *dst)
Copy one log levels structure into another.
RCL_PUBLIC RCL_WARN_UNUSED rcl_log_levels_t rcl_get_zero_initialized_log_levels(void)
Return a rcl_log_levels_t struct with members initialized to zero value.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_remap_fini(rcl_remap_t *remap)
Reclaim resources held inside rcl_remap_t structure.
RCL_PUBLIC RCL_WARN_UNUSED rcl_remap_t rcl_get_zero_initialized_remap(void)
Return a rcl_remap_t struct with members initialized to NULL.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_remap_copy(const rcl_remap_t *rule, rcl_remap_t *rule_out)
Copy one remap structure into another.
char * external_log_config_file
A file used to configure the external logging library.
rcl_log_levels_t log_levels
Log levels parsed from arguments.
rcl_params_t * parameter_overrides
Parameter override rules parsed from arguments.
int num_unparsed_args
Length of unparsed_args.
int num_param_files_args
Length of parameter_files.
bool log_rosout_disabled
A boolean value indicating if the rosout topic handler should be used for log output.
bool log_stdout_disabled
A boolean value indicating if the standard out handler should be used for log output.
rcl_allocator_t allocator
Allocator used to allocate objects in this struct.
int * unparsed_args
Array of indices to non-ROS arguments.
int * unparsed_ros_args
Array of indices to unknown ROS specific arguments.
char * enclave
Enclave to be used.
bool log_ext_lib_disabled
A boolean value indicating if the external lib handler should be used for log output.
rcl_remap_t * remap_rules
Array of rules for name remapping.
int num_remap_rules
Length of remap_rules.
int num_unparsed_ros_args
Length of unparsed_ros_args.
char * external_log_file_name_prefix
A prefix used to external log file name.
char ** parameter_files
Array of yaml parameter file paths.
Hold output of parsing command line arguments.
rcl_arguments_impl_t * impl
Private implementation pointer.
Track lexical analysis and allow looking ahead 2 lexemes.
Hold default logger level and other logger setting.
rcl_allocator_t allocator
Allocator used to allocate objects in this struct.
rcl_logger_setting_t * logger_settings
Array of logger setting.
rcl_log_severity_t default_logger_level
Minimum default logger level severity.
char * replacement
Replacement portion of a rule.
char * node_name
A node name that this rule is limited to, or NULL if it applies to any node.
rcl_allocator_t allocator
Allocator used to allocate objects in this struct.
char * match
Match portion of a rule, or NULL if node name or namespace replacement.
rcl_remap_type_t type
Bitmask indicating what type of rule this is.
rcl_remap_impl_t * impl
Private implementation pointer.
#define RCL_RET_INVALID_LOG_LEVEL_RULE
Argument is not a valid log level rule.
#define RCL_RET_INVALID_PARAM_RULE
Argument is not a valid parameter rule.
#define RCL_RET_WRONG_LEXEME
Expected one type of lexeme but got another.
#define RCL_RET_INVALID_ROS_ARGS
Found invalid ros argument while parsing.
#define RCL_RET_INVALID_REMAP_RULE
Argument is not a valid remap rule.
#define RCL_RET_OK
Success return code.
#define RCL_RET_BAD_ALLOC
Failed to allocate memory return code.
#define RCL_RET_INVALID_ARGUMENT
Invalid argument return code.
#define RCL_RET_ERROR
Unspecified error return code.
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.