diff --git a/include/shell/shell.h b/include/shell/shell.h index 0589099ebe..e86a8c246a 100644 --- a/include/shell/shell.h +++ b/include/shell/shell.h @@ -711,8 +711,8 @@ struct shell { k_thread_stack_t *stack; }; -extern void shell_print_stream(const void *user_ctx, const char *data, - size_t data_len); +extern void z_shell_print_stream(const void *user_ctx, const char *data, + size_t data_len); /** * @brief Macro for defining a shell instance. * @@ -730,14 +730,14 @@ extern void shell_print_stream(const void *user_ctx, const char *data, _log_queue_size, _log_timeout, _shell_flag) \ static const struct shell _name; \ static struct shell_ctx UTIL_CAT(_name, _ctx); \ - static uint8_t _name##_out_buffer[CONFIG_SHELL_PRINTF_BUFF_SIZE]; \ + static uint8_t _name##_out_buffer[CONFIG_SHELL_PRINTF_BUFF_SIZE]; \ SHELL_LOG_BACKEND_DEFINE(_name, _name##_out_buffer, \ CONFIG_SHELL_PRINTF_BUFF_SIZE, \ _log_queue_size, _log_timeout); \ SHELL_HISTORY_DEFINE(_name##_history, CONFIG_SHELL_HISTORY_BUFFER); \ - SHELL_FPRINTF_DEFINE(_name##_fprintf, &_name, _name##_out_buffer, \ + Z_SHELL_FPRINTF_DEFINE(_name##_fprintf, &_name, _name##_out_buffer, \ CONFIG_SHELL_PRINTF_BUFF_SIZE, \ - true, shell_print_stream); \ + true, z_shell_print_stream); \ LOG_INSTANCE_REGISTER(shell, _name, CONFIG_SHELL_LOG_LEVEL); \ SHELL_STATS_DEFINE(_name); \ static K_KERNEL_STACK_DEFINE(_name##_stack, CONFIG_SHELL_STACK_SIZE); \ diff --git a/include/shell/shell_fprintf.h b/include/shell/shell_fprintf.h index 1d600662b3..2fbeab4dea 100644 --- a/include/shell/shell_fprintf.h +++ b/include/shell/shell_fprintf.h @@ -16,8 +16,8 @@ extern "C" { #endif typedef void (*shell_fprintf_fwrite)(const void *user_ctx, - const char *data, - size_t length); + const char *data, + size_t length); struct shell_fprintf_control_block { size_t buffer_cnt; @@ -44,7 +44,7 @@ struct shell_fprintf { * @param _autoflush Indicator if buffer shall be automatically flush. * @param _fwrite Pointer to function sending data stream. */ -#define SHELL_FPRINTF_DEFINE(_name, _user_ctx, _buf, _size, \ +#define Z_SHELL_FPRINTF_DEFINE(_name, _user_ctx, _buf, _size, \ _autoflush, _fwrite) \ static struct shell_fprintf_control_block \ _name##_shell_fprintf_ctx = { \ @@ -66,15 +66,15 @@ struct shell_fprintf { * @param fmt Format string. * @param args List of parameters to print. */ -void shell_fprintf_fmt(const struct shell_fprintf *sh_fprintf, - char const *fmt, va_list args); +void z_shell_fprintf_fmt(const struct shell_fprintf *sh_fprintf, + char const *fmt, va_list args); /** * @brief function flushing data stored in io_buffer. * * @param sh_fprintf fprintf instance */ -void shell_fprintf_buffer_flush(const struct shell_fprintf *sh_fprintf); +void z_shell_fprintf_buffer_flush(const struct shell_fprintf *sh_fprintf); #ifdef __cplusplus } diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index a6a738e5c2..737f443165 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -68,9 +68,9 @@ static int cmd_precheck(const struct shell *shell, bool arg_cnt_ok) { if (!arg_cnt_ok) { - shell_internal_fprintf(shell, SHELL_ERROR, - "%s: wrong parameter count\n", - shell->ctx->active_cmd.syntax); + z_shell_fprintf(shell, SHELL_ERROR, + "%s: wrong parameter count\n", + shell->ctx->active_cmd.syntax); if (IS_ENABLED(CONFIG_SHELL_HELP_ON_WRONG_ARGUMENT_COUNT)) { shell_internal_help_print(shell); @@ -89,8 +89,8 @@ static inline void state_set(const struct shell *shell, enum shell_state state) if (state == SHELL_STATE_ACTIVE) { cmd_buffer_clear(shell); if (flag_print_noinit_get(shell)) { - shell_internal_fprintf(shell, SHELL_WARNING, "%s", - SHELL_MSG_BACKEND_NOT_ACTIVE); + z_shell_fprintf(shell, SHELL_WARNING, "%s", + SHELL_MSG_BACKEND_NOT_ACTIVE); flag_print_noinit_set(shell, false); } shell_print_prompt_and_cmd(shell); @@ -132,10 +132,9 @@ static void tab_item_print(const struct shell *shell, const char *option, diff = longest_option - shell_strlen(option); if (shell->ctx->vt100_ctx.printed_cmd++ % columns == 0U) { - shell_internal_fprintf(shell, SHELL_OPTION, "\n%s%s", tab, - option); + z_shell_fprintf(shell, SHELL_OPTION, "\n%s%s", tab, option); } else { - shell_internal_fprintf(shell, SHELL_OPTION, "%s", option); + z_shell_fprintf(shell, SHELL_OPTION, "%s", option); } shell_op_cursor_horiz_move(shell, diff); @@ -515,8 +514,8 @@ static int exec_cmd(const struct shell *shell, size_t argc, const char **argv, shell_internal_help_print(shell); return SHELL_CMD_HELP_PRINTED; } else { - shell_internal_fprintf(shell, SHELL_ERROR, - SHELL_MSG_SPECIFY_SUBCOMMAND); + z_shell_fprintf(shell, SHELL_ERROR, + SHELL_MSG_SPECIFY_SUBCOMMAND); return -ENOEXEC; } } @@ -578,7 +577,7 @@ static bool wildcard_check_report(const struct shell *shell, bool found, shell_op_cursor_end_move(shell); shell_op_cond_next_line(shell); - shell_internal_fprintf(shell, SHELL_ERROR, + z_shell_fprintf(shell, SHELL_ERROR, "Error: requested multiple function executions\n"); return false; } @@ -656,9 +655,8 @@ static int execute(const struct shell *shell) if (argc == 0) { return -ENOEXEC; } else if ((argc == 1) && (quote != 0)) { - shell_internal_fprintf(shell, SHELL_ERROR, - "not terminated: %c\n", - quote); + z_shell_fprintf(shell, SHELL_ERROR, + "not terminated: %c\n", quote); return -ENOEXEC; } @@ -674,8 +672,8 @@ static int execute(const struct shell *shell) return SHELL_CMD_HELP_PRINTED; } - shell_internal_fprintf(shell, SHELL_ERROR, - SHELL_MSG_SPECIFY_SUBCOMMAND); + z_shell_fprintf(shell, SHELL_ERROR, + SHELL_MSG_SPECIFY_SUBCOMMAND); return -ENOEXEC; } @@ -721,9 +719,9 @@ static int execute(const struct shell *shell) if (cmd_lvl == 0 && (!shell_in_select_mode(shell) || shell->ctx->selected_cmd->handler == NULL)) { - shell_internal_fprintf(shell, SHELL_ERROR, - "%s%s\n", argv[0], - SHELL_MSG_CMD_NOT_FOUND); + z_shell_fprintf(shell, SHELL_ERROR, + "%s%s\n", argv[0], + SHELL_MSG_CMD_NOT_FOUND); } /* last handler found - no need to search commands in @@ -743,8 +741,8 @@ static int execute(const struct shell *shell) * there was more characters remaining. It means that number of * arguments exceeds the limit. */ - shell_internal_fprintf(shell, SHELL_ERROR, - "%s\n", SHELL_MSG_TOO_MANY_ARGS); + z_shell_fprintf(shell, SHELL_ERROR, "%s\n", + SHELL_MSG_TOO_MANY_ARGS); return -ENOEXEC; } @@ -821,7 +819,7 @@ static void alt_metakeys_handle(const struct shell *shell, char data) IS_ENABLED(CONFIG_SHELL_CMDS_SELECT)) { if (selected_cmd_get(shell) != NULL) { shell_cmd_line_erase(shell); - shell_internal_fprintf(shell, SHELL_WARNING, + z_shell_fprintf(shell, SHELL_WARNING, "Restored default root commands\n"); shell->ctx->selected_cmd = NULL; shell_print_prompt_and_cmd(shell); @@ -1264,8 +1262,8 @@ void shell_thread(void *shell_handle, void *arg_log_backend, if (err != 0) { k_mutex_lock(&shell->ctx->wr_mtx, K_FOREVER); - shell_internal_fprintf(shell, SHELL_ERROR, - "Shell thread error: %d", err); + z_shell_fprintf(shell, SHELL_ERROR, + "Shell thread error: %d", err); k_mutex_unlock(&shell->ctx->wr_mtx); return; } @@ -1424,7 +1422,7 @@ void shell_vfprintf(const struct shell *shell, enum shell_vt100_color color, if (!flag_cmd_ctx_get(shell)) { shell_cmd_line_erase(shell); } - shell_internal_vfprintf(shell, color, fmt, args); + z_shell_vfprintf(shell, color, fmt, args); if (!flag_cmd_ctx_get(shell)) { shell_print_prompt_and_cmd(shell); } diff --git a/subsys/shell/shell_fprintf.c b/subsys/shell/shell_fprintf.c index 897d341e3c..4fdd088739 100644 --- a/subsys/shell/shell_fprintf.c +++ b/subsys/shell/shell_fprintf.c @@ -24,24 +24,24 @@ static int out_func(int c, void *ctx) sh_fprintf->ctrl_blk->buffer_cnt++; if (sh_fprintf->ctrl_blk->buffer_cnt == sh_fprintf->buffer_size) { - shell_fprintf_buffer_flush(sh_fprintf); + z_shell_fprintf_buffer_flush(sh_fprintf); } return 0; } -void shell_fprintf_fmt(const struct shell_fprintf *sh_fprintf, - const char *fmt, va_list args) +void z_shell_fprintf_fmt(const struct shell_fprintf *sh_fprintf, + const char *fmt, va_list args) { (void)cbvprintf(out_func, (void *)sh_fprintf, fmt, args); if (sh_fprintf->ctrl_blk->autoflush) { - shell_fprintf_buffer_flush(sh_fprintf); + z_shell_fprintf_buffer_flush(sh_fprintf); } } -void shell_fprintf_buffer_flush(const struct shell_fprintf *sh_fprintf) +void z_shell_fprintf_buffer_flush(const struct shell_fprintf *sh_fprintf) { sh_fprintf->fwrite(sh_fprintf->user_ctx, sh_fprintf->buffer, sh_fprintf->ctrl_blk->buffer_cnt); diff --git a/subsys/shell/shell_help.c b/subsys/shell/shell_help.c index 847b615459..31f77708e8 100644 --- a/subsys/shell/shell_help.c +++ b/subsys/shell/shell_help.c @@ -120,20 +120,18 @@ static void help_item_print(const struct shell *shell, const char *item_name, !IS_ENABLED(CONFIG_ARCH_POSIX) && !IS_ENABLED(CONFIG_CBPRINTF_NANO)) { /* print option name */ - shell_internal_fprintf(shell, SHELL_NORMAL, "%s%-*s%s:", - tabulator, - item_name_width, item_name, - tabulator); + z_shell_fprintf(shell, SHELL_NORMAL, "%s%-*s%s:", tabulator, + item_name_width, item_name, tabulator); } else { uint16_t tmp = item_name_width - strlen(item_name); char space = ' '; - shell_internal_fprintf(shell, SHELL_NORMAL, "%s%s", tabulator, - item_name); + z_shell_fprintf(shell, SHELL_NORMAL, "%s%s", tabulator, + item_name); for (uint16_t i = 0; i < tmp; i++) { shell_write(shell, &space, 1); } - shell_internal_fprintf(shell, SHELL_NORMAL, "%s:", tabulator); + z_shell_fprintf(shell, SHELL_NORMAL, "%s:", tabulator); } if (item_help == NULL) { @@ -167,7 +165,7 @@ void shell_help_subcmd_print(const struct shell *shell, } if (description != NULL) { - shell_internal_fprintf(shell, SHELL_NORMAL, description); + z_shell_fprintf(shell, SHELL_NORMAL, description); } /* Printing subcommands and help string (if exists). */ @@ -186,8 +184,7 @@ void shell_help_cmd_print(const struct shell *shell, field_width = shell_strlen(cmd->syntax) + shell_strlen(cmd_sep); - shell_internal_fprintf(shell, SHELL_NORMAL, "%s%s", - cmd->syntax, cmd_sep); + z_shell_fprintf(shell, SHELL_NORMAL, "%s%s", cmd->syntax, cmd_sep); formatted_text_print(shell, cmd->help, field_width, false); } diff --git a/subsys/shell/shell_log_backend.c b/subsys/shell/shell_log_backend.c index 54b2f7ca74..2380e5dcdf 100644 --- a/subsys/shell/shell_log_backend.c +++ b/subsys/shell/shell_log_backend.c @@ -11,7 +11,7 @@ int shell_log_backend_output_func(uint8_t *data, size_t length, void *ctx) { - shell_print_stream(ctx, data, length); + z_shell_print_stream(ctx, data, length); return length; } diff --git a/subsys/shell/shell_ops.c b/subsys/shell/shell_ops.c index 90bb3a53d6..e2dbc6e6f4 100644 --- a/subsys/shell/shell_ops.c +++ b/subsys/shell/shell_ops.c @@ -178,7 +178,7 @@ void shell_op_word_remove(const struct shell *shell) /* Update display. */ shell_op_cursor_move(shell, -chars_to_delete); cursor_save(shell); - shell_internal_fprintf(shell, SHELL_NORMAL, "%s", str + 1); + z_shell_fprintf(shell, SHELL_NORMAL, "%s", str + 1); clear_eos(shell); cursor_restore(shell); } @@ -223,7 +223,7 @@ static void reprint_from_cursor(const struct shell *shell, uint16_t diff, clear_eos(shell); } - shell_internal_fprintf(shell, SHELL_NORMAL, "%s", + z_shell_fprintf(shell, SHELL_NORMAL, "%s", &shell->ctx->cmd_buff[shell->ctx->cmd_buff_pos]); shell->ctx->cmd_buff_pos = shell->ctx->cmd_buff_len; @@ -336,7 +336,7 @@ void shell_cmd_line_erase(const struct shell *shell) static void print_prompt(const struct shell *shell) { - shell_internal_fprintf(shell, SHELL_INFO, "%s", shell->ctx->prompt); + z_shell_fprintf(shell, SHELL_INFO, "%s", shell->ctx->prompt); } void shell_print_cmd(const struct shell *shell) @@ -393,10 +393,9 @@ void shell_write(const struct shell *shell, const void *data, } /* Function shall be only used by the fprintf module. */ -void shell_print_stream(const void *user_ctx, const char *data, - size_t data_len) +void z_shell_print_stream(const void *user_ctx, const char *data, size_t len) { - shell_write((const struct shell *) user_ctx, data, data_len); + shell_write((const struct shell *) user_ctx, data, len); } static void vt100_bgcolor_set(const struct shell *shell, @@ -444,9 +443,8 @@ void shell_vt100_colors_restore(const struct shell *shell, vt100_bgcolor_set(shell, color->bgcol); } -void shell_internal_vfprintf(const struct shell *shell, - enum shell_vt100_color color, const char *fmt, - va_list args) +void z_shell_vfprintf(const struct shell *shell, enum shell_vt100_color color, + const char *fmt, va_list args) { if (IS_ENABLED(CONFIG_SHELL_VT100_COLORS) && shell->ctx->internal.flags.use_colors && @@ -456,15 +454,15 @@ void shell_internal_vfprintf(const struct shell *shell, shell_vt100_colors_store(shell, &col); shell_vt100_color_set(shell, color); - shell_fprintf_fmt(shell->fprintf_ctx, fmt, args); + z_shell_fprintf_fmt(shell->fprintf_ctx, fmt, args); shell_vt100_colors_restore(shell, &col); } else { - shell_fprintf_fmt(shell->fprintf_ctx, fmt, args); + z_shell_fprintf_fmt(shell->fprintf_ctx, fmt, args); } } -void shell_internal_fprintf(const struct shell *shell, +void z_shell_fprintf(const struct shell *shell, enum shell_vt100_color color, const char *fmt, ...) { @@ -477,6 +475,6 @@ void shell_internal_fprintf(const struct shell *shell, va_list args; va_start(args, fmt); - shell_internal_vfprintf(shell, color, fmt, args); + z_shell_vfprintf(shell, color, fmt, args); va_end(args); } diff --git a/subsys/shell/shell_ops.h b/subsys/shell/shell_ops.h index 680c320bfb..5c7be04752 100644 --- a/subsys/shell/shell_ops.h +++ b/subsys/shell/shell_ops.h @@ -21,7 +21,7 @@ static inline void shell_raw_fprintf(const struct shell_fprintf *const ctx, va_list args; va_start(args, fmt); - shell_fprintf_fmt(ctx, fmt, args); + z_shell_fprintf_fmt(ctx, fmt, args); va_end(args); } @@ -245,10 +245,9 @@ void shell_write(const struct shell *shell, const void *data, * * @param[in] p_user_ctx Pointer to the context for the shell instance. * @param[in] p_data Pointer to the data buffer. - * @param[in] data_len Data buffer size. + * @param[in] len Data buffer size. */ -void shell_print_stream(const void *user_ctx, const char *data, - size_t data_len); +void z_shell_print_stream(const void *user_ctx, const char *data, size_t len); /** @internal @brief Function for setting font color */ void shell_vt100_color_set(const struct shell *shell, @@ -266,13 +265,11 @@ void shell_vt100_colors_restore(const struct shell *shell, /* This function can be called only within shell thread but not from command * handlers. */ -void shell_internal_fprintf(const struct shell *shell, - enum shell_vt100_color color, - const char *fmt, ...); +void z_shell_fprintf(const struct shell *shell, enum shell_vt100_color color, + const char *fmt, ...); -void shell_internal_vfprintf(const struct shell *shell, - enum shell_vt100_color color, const char *fmt, - va_list args); +void z_shell_vfprintf(const struct shell *shell, enum shell_vt100_color color, + const char *fmt, va_list args); #ifdef __cplusplus } diff --git a/subsys/shell/shell_utils.h b/subsys/shell/shell_utils.h index 9bacb2ee75..f9c2215080 100644 --- a/subsys/shell/shell_utils.h +++ b/subsys/shell/shell_utils.h @@ -86,7 +86,7 @@ void shell_spaces_trim(char *str); static inline void transport_buffer_flush(const struct shell *shell) { - shell_fprintf_buffer_flush(shell->fprintf_ctx); + z_shell_fprintf_buffer_flush(shell->fprintf_ctx); } void shell_cmd_trim(const struct shell *shell); diff --git a/subsys/shell/shell_wildcard.c b/subsys/shell/shell_wildcard.c index aed8c69be3..6144b91f75 100644 --- a/subsys/shell/shell_wildcard.c +++ b/subsys/shell/shell_wildcard.c @@ -83,12 +83,10 @@ static enum shell_wildcard_status commands_expand(const struct shell *shell, &shell->ctx->cmd_tmp_buff_len, entry->syntax, pattern); if (ret_val == SHELL_WILDCARD_CMD_MISSING_SPACE) { - shell_internal_fprintf(shell, - SHELL_WARNING, - "Command buffer is too short to" - " expand all commands matching" - " wildcard pattern: %s\n", - pattern); + z_shell_fprintf(shell, SHELL_WARNING, + "Command buffer is too short to" + " expand all commands matching" + " wildcard pattern: %s\n", pattern); break; } else if (ret_val != SHELL_WILDCARD_CMD_ADDED) { break;