Adding console I/O via the `SHELL`. Demonstration of [http_tcp_demo.c](https://git.kolibrios.org/KolibriOS/kolibrios/src/branch/main/programs/develop/ktcc/libc.obj/samples/http_tcp_demo.c): <video src="attachments/847d7d19-3d67-480d-80c8-6d678af61a43" title="Запись экрана от 2026-03-07 13-55-50.mp4" controls></video> - [x] output - [x] multithread - [x] add mutex - [x] multithread tests Reviewed-on: #354 Reviewed-by: Mikhail Frolov <mixa.frolov2003@gmail.com> Reviewed-by: Kiril Lipatov <lipatov.kiril@gmail.com> Co-authored-by: Egor00f <y.yarin@inbox.ru>
23 lines
709 B
C
23 lines
709 B
C
#include <shell_api.h>
|
|
#include <string.h>
|
|
|
|
void shell_write_string(const char *s, size_t len)
|
|
{
|
|
__shell_init();
|
|
if (__shell_is_init == __SHELL_INIT_OK)
|
|
{
|
|
if (len > SHELL_SHM_MAX - 1)
|
|
{
|
|
shell_write_string(s, SHELL_SHM_MAX - 1); // Outputs as much as it can.
|
|
shell_write_string(s + (SHELL_SHM_MAX - 1), len - (SHELL_SHM_MAX - 1)); // Outputs the rest.
|
|
}
|
|
else
|
|
{
|
|
memset(__shell_shm, 0, SHELL_SHM_MAX); // without int shell show \t, \n, lose chars and other trash
|
|
memcpy(__shell_shm + 1, s, len);
|
|
*__shell_shm = SHELL_PUTS;
|
|
__SHELL_WAIT();
|
|
}
|
|
}
|
|
}
|