blob: ae8f8a5afc31d144e51816e2ad72e690b1fe18f5 [file] [log] [blame]
/*
* Copyright (c) 2023 Meta
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef SHELL_BACKEND_H__
#define SHELL_BACKEND_H__
#include <zephyr/types.h>
#include <zephyr/shell/shell.h>
#include <zephyr/sys/iterable_sections.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Get backend.
*
* @param[in] idx Pointer to the backend instance.
*
* @return Pointer to the backend instance.
*/
static inline const struct shell *shell_backend_get(uint32_t idx)
{
const struct shell *backend;
STRUCT_SECTION_GET(shell, idx, &backend);
return backend;
}
/**
* @brief Get number of backends.
*
* @return Number of backends.
*/
static inline int shell_backend_count_get(void)
{
int cnt;
STRUCT_SECTION_COUNT(shell, &cnt);
return cnt;
}
/**
* @brief Get backend by name.
*
* @param[in] backend_name Name of the backend as defined by the SHELL_DEFINE.
*
* @retval Pointer to the backend instance if found, NULL if backend is not found.
*/
const struct shell *shell_backend_get_by_name(const char *backend_name);
#ifdef __cplusplus
}
#endif
#endif /* SHELL_BACKEND_H__ */