Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
shell_history.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef SHELL_HISTORY_H__
8#define SHELL_HISTORY_H__
9
10#include <zephyr/kernel.h>
11#include <zephyr/sys/util.h>
12#include <zephyr/sys/dlist.h>
14#include <stdbool.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20
25};
26
33#define Z_SHELL_HISTORY_DEFINE(_name, _size) \
34 static uint8_t __noinit __aligned(sizeof(void *)) \
35 _name##_ring_buf_data[_size]; \
36 static struct ring_buf _name##_ring_buf = \
37 { \
38 .size = _size, \
39 .buffer = _name##_ring_buf_data \
40 }; \
41 static struct shell_history _name = { \
42 .ring_buf = &_name##_ring_buf \
43 }
44
45
51void z_shell_history_init(struct shell_history *history);
52
61void z_shell_history_purge(struct shell_history *history);
62
68void z_shell_history_mode_exit(struct shell_history *history);
69
82bool z_shell_history_get(struct shell_history *history, bool up,
83 uint8_t *dst, uint16_t *len);
84
95void z_shell_history_put(struct shell_history *history, uint8_t *line,
96 size_t len);
97
105static inline bool z_shell_history_active(struct shell_history *history)
106{
107 return (history->current) ? true : false;
108}
109
110#ifdef __cplusplus
111}
112#endif
113
114#endif /* SHELL_HISTORY_H__ */
struct _dnode sys_dnode_t
Doubly-linked list node structure.
Definition: dlist.h:54
struct _dnode sys_dlist_t
Doubly-linked list structure.
Definition: dlist.h:50
Public kernel APIs.
#define true
Definition: stdbool.h:14
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
A structure to represent a ring buffer.
Definition: ring_buffer.h:41
Definition: shell_history.h:21
sys_dnode_t * current
Definition: shell_history.h:24
struct ring_buf * ring_buf
Definition: shell_history.h:22
sys_dlist_t list
Definition: shell_history.h:23
Misc utilities.