shell_server_pty.h
Go to the documentation of this file.
1 /**
2  * @file shell_server_pty.h
3  * @brief Pseudo-terminal emulation
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneSSH Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _SHELL_SERVER_PTY_H
32 #define _SHELL_SERVER_PTY_H
33 
34 //Dependencies
35 #include "shell/shell_server.h"
36 
37 //Escape character code
38 #define VT100_BS_CODE 0x08
39 #define VT100_ESC_CODE 0x1B
40 #define VT100_DEL_CODE 0x7F
41 
42 //VT100 escape sequences
43 #define VT100_BACKSPACE "\x08"
44 #define VT100_ESC "\x1b"
45 #define VT100_CLEAR_SCREEN_DOWN VT100_ESC "[J"
46 #define VT100_CLEAR_SCREEN_UP VT100_ESC "[1J"
47 #define VT100_CLEAR_ENTIRE_SCREEN VT100_ESC "[2J"
48 #define VT100_CLEAR_LINE_RIGHT VT100_ESC "[K"
49 #define VT100_CLEAR_LINE_LEFT VT100_ESC "[1K"
50 #define VT100_CLEAR_ENTIRE_LINE VT100_ESC "[2K"
51 #define VT100_MOVE_CURSOR_UP VT100_ESC "[A"
52 #define VT100_MOVE_CURSOR_UP_N VT100_ESC "[%uA"
53 #define VT100_MOVE_CURSOR_DOWN VT100_ESC "[B"
54 #define VT100_MOVE_CURSOR_DOWN_N VT100_ESC "[%uB"
55 #define VT100_MOVE_CURSOR_RIGHT VT100_ESC "[C"
56 #define VT100_MOVE_CURSOR_RIGHT_N VT100_ESC "[%uC"
57 #define VT100_MOVE_CURSOR_LEFT VT100_ESC "[D"
58 #define VT100_MOVE_CURSOR_LEFT_N VT100_ESC "[%uD"
59 #define VT100_SAVE_CURSOR_POS VT100_ESC "[s"
60 #define VT100_RESTORE_CURSOR_POS VT100_ESC "[u"
61 #define VT100_INSERT VT100_ESC "[2~"
62 #define VT100_DELETE VT100_ESC "[3~"
63 #define VT100_PAGE_UP VT100_ESC "[5~"
64 #define VT100_PAGE_DOWN VT100_ESC "[6~"
65 #define VT100_HOME VT100_ESC "[H"
66 #define VT100_END VT100_ESC "[F"
67 #define VT100_F1 VT100_ESC "OP"
68 #define VT100_F2 VT100_ESC "OQ"
69 #define VT100_F3 VT100_ESC "OR"
70 #define VT100_F4 VT100_ESC "OS"
71 #define VT100_F5 VT100_ESC "[15~"
72 #define VT100_F6 VT100_ESC "[17~"
73 #define VT100_F7 VT100_ESC "[18~"
74 #define VT100_F8 VT100_ESC "[19~"
75 #define VT100_F9 VT100_ESC "[20~"
76 #define VT100_F10 VT100_ESC "[21~"
77 #define VT100_F11 VT100_ESC "[23~"
78 #define VT100_F12 VT100_ESC "[24~"
79 
80 //C++ guard
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84 
85 
86 /**
87  * @brief Encoded terminal modes
88  **/
89 
90 typedef enum
91 {
149 
150 
151 //Shell server related functions
154 
156 
165 
167 
169  const char_t *commandLine, size_t length);
170 
171 //C++ guard
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 #endif
@ SHELL_TERM_MODE_INPCK
@ SHELL_TERM_MODE_TOSTOP
error_t shellClearCommandLine(ShellServerSession *session)
Clear command line.
error_t shellServerProcessLeftKey(ShellServerSession *session)
Process left key.
@ SHELL_TERM_MODE_IXANY
@ SHELL_TERM_MODE_INLCR
error_t shellServerProcessUpKey(ShellServerSession *session)
Process up key.
@ SHELL_TERM_MODE_VSUSP
@ SHELL_TERM_MODE_VDISCARD
@ SHELL_TERM_MODE_VEOF
@ SHELL_TERM_MODE_ICANON
ShellTermModes
Encoded terminal modes.
error_t shellServerInsertChar(ShellServerSession *session, char_t c)
Insert character at current position.
@ SHELL_TERM_MODE_VSWTCH
@ SHELL_TERM_MODE_ONLCR
@ SHELL_TERM_MODE_ONOCR
@ SHELL_TERM_MODE_ONLRET
@ SHELL_TERM_MODE_ECHONL
@ SHELL_TERM_MODE_ECHOK
SSH secure shell server.
@ SHELL_TERM_MODE_ISIG
@ SHELL_TERM_MODE_OLCUC
error_t shellServerProcessChar(ShellServerSession *session)
Process received character.
@ SHELL_TERM_MODE_VFLUSH
error_t shellRestoreCommandLine(ShellServerSession *session, const char_t *commandLine, size_t length)
Restore command line.
error_t
Error codes.
Definition: error.h:43
@ SHELL_TERM_MODE_VERASE
@ SHELL_TERM_MODE_ICRNL
error_t shellServerProcessDeleteKey(ShellServerSession *session)
Process delete key.
error_t shellServerProcessDownKey(ShellServerSession *session)
Process down key.
@ SHELL_TERM_MODE_IGNPAR
@ SHELL_TERM_MODE_VREPRINT
error_t shellServerProcessPageDownKey(ShellServerSession *session)
Process page down key.
error_t shellServerProcessBackspaceKey(ShellServerSession *session)
Process backspace key.
@ SHELL_TERM_MODE_ECHOCTL
@ SHELL_TERM_MODE_IXON
@ SHELL_TERM_MODE_IEXTEN
@ SHELL_TERM_MODE_VDSUSP
error_t shellServerProcessPageUpKey(ShellServerSession *session)
Process page up key.
@ SHELL_TERM_MODE_IUCLC
uint8_t length
Definition: tcp.h:368
@ SHELL_TERM_MODE_VSTATUS
@ SHELL_TERM_MODE_PARMRK
@ SHELL_TERM_MODE_PARENB
@ SHELL_TERM_MODE_ISTRIP
@ SHELL_TERM_MODE_VLNEXT
@ SHELL_TERM_MODE_VQUIT
@ SHELL_TERM_MODE_VINTR
@ SHELL_TERM_MODE_OCRNL
@ SHELL_TERM_MODE_PENDIN
char char_t
Definition: compiler_port.h:48
error_t shellServerProcessWindowResize(ShellServerSession *session)
Process window resize event.
@ SHELL_TERM_MODE_VEOL
@ SHELL_TERM_MODE_ECHOKE
@ SHELL_TERM_MODE_CS7
@ SHELL_TERM_MODE_VKILL
@ SHELL_TERM_MODE_PARODD
@ SHELL_TERM_MODE_ECHO
#define ShellServerSession
Definition: shell_server.h:121
@ SHELL_TERM_MODE_IXOFF
@ SHELL_TERM_MODE_CS8
@ SHELL_TERM_MODE_VEOL2
@ SHELL_TERM_MODE_IGNCR
@ SHELL_TERM_MODE_VSTOP
@ SHELL_TERM_MODE_OPOST
@ SHELL_TERM_MODE_IMAXBEL
@ SHELL_TERM_MODE_TTY_OP_OSPEED
@ SHELL_TERM_MODE_NOFLSH
@ SHELL_TERM_MODE_XCASE
@ SHELL_TERM_MODE_TTY_OP_END
error_t shellServerProcessRightKey(ShellServerSession *session)
Process right key.
@ SHELL_TERM_MODE_VSTART
@ SHELL_TERM_MODE_VWERASE
@ SHELL_TERM_MODE_ECHOE
uint8_t c
Definition: ndp.h:514
@ SHELL_TERM_MODE_TTY_OP_ISPEED