shell_server_pty.h File Reference

Pseudo-terminal emulation. More...

Go to the source code of this file.

Macros

#define VT100_BS_CODE   0x08
 
#define VT100_ESC_CODE   0x1B
 
#define VT100_DEL_CODE   0x7F
 
#define VT100_BACKSPACE   "\x08"
 
#define VT100_ESC   "\x1b"
 
#define VT100_CLEAR_SCREEN_DOWN   VT100_ESC "[J"
 
#define VT100_CLEAR_SCREEN_UP   VT100_ESC "[1J"
 
#define VT100_CLEAR_ENTIRE_SCREEN   VT100_ESC "[2J"
 
#define VT100_CLEAR_LINE_RIGHT   VT100_ESC "[K"
 
#define VT100_CLEAR_LINE_LEFT   VT100_ESC "[1K"
 
#define VT100_CLEAR_ENTIRE_LINE   VT100_ESC "[2K"
 
#define VT100_MOVE_CURSOR_UP   VT100_ESC "[A"
 
#define VT100_MOVE_CURSOR_UP_N   VT100_ESC "[%uA"
 
#define VT100_MOVE_CURSOR_DOWN   VT100_ESC "[B"
 
#define VT100_MOVE_CURSOR_DOWN_N   VT100_ESC "[%uB"
 
#define VT100_MOVE_CURSOR_RIGHT   VT100_ESC "[C"
 
#define VT100_MOVE_CURSOR_RIGHT_N   VT100_ESC "[%uC"
 
#define VT100_MOVE_CURSOR_LEFT   VT100_ESC "[D"
 
#define VT100_MOVE_CURSOR_LEFT_N   VT100_ESC "[%uD"
 
#define VT100_SAVE_CURSOR_POS   VT100_ESC "[s"
 
#define VT100_RESTORE_CURSOR_POS   VT100_ESC "[u"
 
#define VT100_INSERT   VT100_ESC "[2~"
 
#define VT100_DELETE   VT100_ESC "[3~"
 
#define VT100_PAGE_UP   VT100_ESC "[5~"
 
#define VT100_PAGE_DOWN   VT100_ESC "[6~"
 
#define VT100_HOME   VT100_ESC "[H"
 
#define VT100_END   VT100_ESC "[F"
 
#define VT100_F1   VT100_ESC "OP"
 
#define VT100_F2   VT100_ESC "OQ"
 
#define VT100_F3   VT100_ESC "OR"
 
#define VT100_F4   VT100_ESC "OS"
 
#define VT100_F5   VT100_ESC "[15~"
 
#define VT100_F6   VT100_ESC "[17~"
 
#define VT100_F7   VT100_ESC "[18~"
 
#define VT100_F8   VT100_ESC "[19~"
 
#define VT100_F9   VT100_ESC "[20~"
 
#define VT100_F10   VT100_ESC "[21~"
 
#define VT100_F11   VT100_ESC "[23~"
 
#define VT100_F12   VT100_ESC "[24~"
 

Enumerations

enum  ShellTermModes {
  SHELL_TERM_MODE_TTY_OP_END = 0, SHELL_TERM_MODE_VINTR = 1, SHELL_TERM_MODE_VQUIT = 2, SHELL_TERM_MODE_VERASE = 3,
  SHELL_TERM_MODE_VKILL = 4, SHELL_TERM_MODE_VEOF = 5, SHELL_TERM_MODE_VEOL = 6, SHELL_TERM_MODE_VEOL2 = 7,
  SHELL_TERM_MODE_VSTART = 8, SHELL_TERM_MODE_VSTOP = 9, SHELL_TERM_MODE_VSUSP = 10, SHELL_TERM_MODE_VDSUSP = 11,
  SHELL_TERM_MODE_VREPRINT = 12, SHELL_TERM_MODE_VWERASE = 13, SHELL_TERM_MODE_VLNEXT = 14, SHELL_TERM_MODE_VFLUSH = 15,
  SHELL_TERM_MODE_VSWTCH = 16, SHELL_TERM_MODE_VSTATUS = 17, SHELL_TERM_MODE_VDISCARD = 18, SHELL_TERM_MODE_IGNPAR = 30,
  SHELL_TERM_MODE_PARMRK = 31, SHELL_TERM_MODE_INPCK = 32, SHELL_TERM_MODE_ISTRIP = 33, SHELL_TERM_MODE_INLCR = 34,
  SHELL_TERM_MODE_IGNCR = 35, SHELL_TERM_MODE_ICRNL = 36, SHELL_TERM_MODE_IUCLC = 37, SHELL_TERM_MODE_IXON = 38,
  SHELL_TERM_MODE_IXANY = 39, SHELL_TERM_MODE_IXOFF = 40, SHELL_TERM_MODE_IMAXBEL = 41, SHELL_TERM_MODE_ISIG = 50,
  SHELL_TERM_MODE_ICANON = 51, SHELL_TERM_MODE_XCASE = 52, SHELL_TERM_MODE_ECHO = 53, SHELL_TERM_MODE_ECHOE = 54,
  SHELL_TERM_MODE_ECHOK = 55, SHELL_TERM_MODE_ECHONL = 56, SHELL_TERM_MODE_NOFLSH = 57, SHELL_TERM_MODE_TOSTOP = 58,
  SHELL_TERM_MODE_IEXTEN = 59, SHELL_TERM_MODE_ECHOCTL = 60, SHELL_TERM_MODE_ECHOKE = 61, SHELL_TERM_MODE_PENDIN = 62,
  SHELL_TERM_MODE_OPOST = 70, SHELL_TERM_MODE_OLCUC = 71, SHELL_TERM_MODE_ONLCR = 72, SHELL_TERM_MODE_OCRNL = 73,
  SHELL_TERM_MODE_ONOCR = 74, SHELL_TERM_MODE_ONLRET = 75, SHELL_TERM_MODE_CS7 = 90, SHELL_TERM_MODE_CS8 = 91,
  SHELL_TERM_MODE_PARENB = 92, SHELL_TERM_MODE_PARODD = 93, SHELL_TERM_MODE_TTY_OP_ISPEED = 128, SHELL_TERM_MODE_TTY_OP_OSPEED = 129
}
 Encoded terminal modes. More...
 

Functions

error_t shellServerProcessWindowResize (ShellServerSession *session)
 Process window resize event. More...
 
error_t shellServerProcessChar (ShellServerSession *session)
 Process received character. More...
 
error_t shellServerInsertChar (ShellServerSession *session, char_t c)
 Insert character at current position. More...
 
error_t shellServerProcessBackspaceKey (ShellServerSession *session)
 Process backspace key. More...
 
error_t shellServerProcessDeleteKey (ShellServerSession *session)
 Process delete key. More...
 
error_t shellServerProcessLeftKey (ShellServerSession *session)
 Process left key. More...
 
error_t shellServerProcessRightKey (ShellServerSession *session)
 Process right key. More...
 
error_t shellServerProcessUpKey (ShellServerSession *session)
 Process up key. More...
 
error_t shellServerProcessDownKey (ShellServerSession *session)
 Process down key. More...
 
error_t shellServerProcessPageUpKey (ShellServerSession *session)
 Process page up key. More...
 
error_t shellServerProcessPageDownKey (ShellServerSession *session)
 Process page down key. More...
 
error_t shellClearCommandLine (ShellServerSession *session)
 Clear command line. More...
 
error_t shellRestoreCommandLine (ShellServerSession *session, const char_t *commandLine, size_t length)
 Restore command line. More...
 

Detailed Description

Pseudo-terminal emulation.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneSSH Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.4

Definition in file shell_server_pty.h.

Macro Definition Documentation

◆ VT100_BACKSPACE

#define VT100_BACKSPACE   "\x08"

Definition at line 43 of file shell_server_pty.h.

◆ VT100_BS_CODE

#define VT100_BS_CODE   0x08

Definition at line 38 of file shell_server_pty.h.

◆ VT100_CLEAR_ENTIRE_LINE

#define VT100_CLEAR_ENTIRE_LINE   VT100_ESC "[2K"

Definition at line 50 of file shell_server_pty.h.

◆ VT100_CLEAR_ENTIRE_SCREEN

#define VT100_CLEAR_ENTIRE_SCREEN   VT100_ESC "[2J"

Definition at line 47 of file shell_server_pty.h.

◆ VT100_CLEAR_LINE_LEFT

#define VT100_CLEAR_LINE_LEFT   VT100_ESC "[1K"

Definition at line 49 of file shell_server_pty.h.

◆ VT100_CLEAR_LINE_RIGHT

#define VT100_CLEAR_LINE_RIGHT   VT100_ESC "[K"

Definition at line 48 of file shell_server_pty.h.

◆ VT100_CLEAR_SCREEN_DOWN

#define VT100_CLEAR_SCREEN_DOWN   VT100_ESC "[J"

Definition at line 45 of file shell_server_pty.h.

◆ VT100_CLEAR_SCREEN_UP

#define VT100_CLEAR_SCREEN_UP   VT100_ESC "[1J"

Definition at line 46 of file shell_server_pty.h.

◆ VT100_DEL_CODE

#define VT100_DEL_CODE   0x7F

Definition at line 40 of file shell_server_pty.h.

◆ VT100_DELETE

#define VT100_DELETE   VT100_ESC "[3~"

Definition at line 62 of file shell_server_pty.h.

◆ VT100_END

#define VT100_END   VT100_ESC "[F"

Definition at line 66 of file shell_server_pty.h.

◆ VT100_ESC

#define VT100_ESC   "\x1b"

Definition at line 44 of file shell_server_pty.h.

◆ VT100_ESC_CODE

#define VT100_ESC_CODE   0x1B

Definition at line 39 of file shell_server_pty.h.

◆ VT100_F1

#define VT100_F1   VT100_ESC "OP"

Definition at line 67 of file shell_server_pty.h.

◆ VT100_F10

#define VT100_F10   VT100_ESC "[21~"

Definition at line 76 of file shell_server_pty.h.

◆ VT100_F11

#define VT100_F11   VT100_ESC "[23~"

Definition at line 77 of file shell_server_pty.h.

◆ VT100_F12

#define VT100_F12   VT100_ESC "[24~"

Definition at line 78 of file shell_server_pty.h.

◆ VT100_F2

#define VT100_F2   VT100_ESC "OQ"

Definition at line 68 of file shell_server_pty.h.

◆ VT100_F3

#define VT100_F3   VT100_ESC "OR"

Definition at line 69 of file shell_server_pty.h.

◆ VT100_F4

#define VT100_F4   VT100_ESC "OS"

Definition at line 70 of file shell_server_pty.h.

◆ VT100_F5

#define VT100_F5   VT100_ESC "[15~"

Definition at line 71 of file shell_server_pty.h.

◆ VT100_F6

#define VT100_F6   VT100_ESC "[17~"

Definition at line 72 of file shell_server_pty.h.

◆ VT100_F7

#define VT100_F7   VT100_ESC "[18~"

Definition at line 73 of file shell_server_pty.h.

◆ VT100_F8

#define VT100_F8   VT100_ESC "[19~"

Definition at line 74 of file shell_server_pty.h.

◆ VT100_F9

#define VT100_F9   VT100_ESC "[20~"

Definition at line 75 of file shell_server_pty.h.

◆ VT100_HOME

#define VT100_HOME   VT100_ESC "[H"

Definition at line 65 of file shell_server_pty.h.

◆ VT100_INSERT

#define VT100_INSERT   VT100_ESC "[2~"

Definition at line 61 of file shell_server_pty.h.

◆ VT100_MOVE_CURSOR_DOWN

#define VT100_MOVE_CURSOR_DOWN   VT100_ESC "[B"

Definition at line 53 of file shell_server_pty.h.

◆ VT100_MOVE_CURSOR_DOWN_N

#define VT100_MOVE_CURSOR_DOWN_N   VT100_ESC "[%uB"

Definition at line 54 of file shell_server_pty.h.

◆ VT100_MOVE_CURSOR_LEFT

#define VT100_MOVE_CURSOR_LEFT   VT100_ESC "[D"

Definition at line 57 of file shell_server_pty.h.

◆ VT100_MOVE_CURSOR_LEFT_N

#define VT100_MOVE_CURSOR_LEFT_N   VT100_ESC "[%uD"

Definition at line 58 of file shell_server_pty.h.

◆ VT100_MOVE_CURSOR_RIGHT

#define VT100_MOVE_CURSOR_RIGHT   VT100_ESC "[C"

Definition at line 55 of file shell_server_pty.h.

◆ VT100_MOVE_CURSOR_RIGHT_N

#define VT100_MOVE_CURSOR_RIGHT_N   VT100_ESC "[%uC"

Definition at line 56 of file shell_server_pty.h.

◆ VT100_MOVE_CURSOR_UP

#define VT100_MOVE_CURSOR_UP   VT100_ESC "[A"

Definition at line 51 of file shell_server_pty.h.

◆ VT100_MOVE_CURSOR_UP_N

#define VT100_MOVE_CURSOR_UP_N   VT100_ESC "[%uA"

Definition at line 52 of file shell_server_pty.h.

◆ VT100_PAGE_DOWN

#define VT100_PAGE_DOWN   VT100_ESC "[6~"

Definition at line 64 of file shell_server_pty.h.

◆ VT100_PAGE_UP

#define VT100_PAGE_UP   VT100_ESC "[5~"

Definition at line 63 of file shell_server_pty.h.

◆ VT100_RESTORE_CURSOR_POS

#define VT100_RESTORE_CURSOR_POS   VT100_ESC "[u"

Definition at line 60 of file shell_server_pty.h.

◆ VT100_SAVE_CURSOR_POS

#define VT100_SAVE_CURSOR_POS   VT100_ESC "[s"

Definition at line 59 of file shell_server_pty.h.

Enumeration Type Documentation

◆ ShellTermModes

Encoded terminal modes.

Enumerator
SHELL_TERM_MODE_TTY_OP_END 
SHELL_TERM_MODE_VINTR 
SHELL_TERM_MODE_VQUIT 
SHELL_TERM_MODE_VERASE 
SHELL_TERM_MODE_VKILL 
SHELL_TERM_MODE_VEOF 
SHELL_TERM_MODE_VEOL 
SHELL_TERM_MODE_VEOL2 
SHELL_TERM_MODE_VSTART 
SHELL_TERM_MODE_VSTOP 
SHELL_TERM_MODE_VSUSP 
SHELL_TERM_MODE_VDSUSP 
SHELL_TERM_MODE_VREPRINT 
SHELL_TERM_MODE_VWERASE 
SHELL_TERM_MODE_VLNEXT 
SHELL_TERM_MODE_VFLUSH 
SHELL_TERM_MODE_VSWTCH 
SHELL_TERM_MODE_VSTATUS 
SHELL_TERM_MODE_VDISCARD 
SHELL_TERM_MODE_IGNPAR 
SHELL_TERM_MODE_PARMRK 
SHELL_TERM_MODE_INPCK 
SHELL_TERM_MODE_ISTRIP 
SHELL_TERM_MODE_INLCR 
SHELL_TERM_MODE_IGNCR 
SHELL_TERM_MODE_ICRNL 
SHELL_TERM_MODE_IUCLC 
SHELL_TERM_MODE_IXON 
SHELL_TERM_MODE_IXANY 
SHELL_TERM_MODE_IXOFF 
SHELL_TERM_MODE_IMAXBEL 
SHELL_TERM_MODE_ISIG 
SHELL_TERM_MODE_ICANON 
SHELL_TERM_MODE_XCASE 
SHELL_TERM_MODE_ECHO 
SHELL_TERM_MODE_ECHOE 
SHELL_TERM_MODE_ECHOK 
SHELL_TERM_MODE_ECHONL 
SHELL_TERM_MODE_NOFLSH 
SHELL_TERM_MODE_TOSTOP 
SHELL_TERM_MODE_IEXTEN 
SHELL_TERM_MODE_ECHOCTL 
SHELL_TERM_MODE_ECHOKE 
SHELL_TERM_MODE_PENDIN 
SHELL_TERM_MODE_OPOST 
SHELL_TERM_MODE_OLCUC 
SHELL_TERM_MODE_ONLCR 
SHELL_TERM_MODE_OCRNL 
SHELL_TERM_MODE_ONOCR 
SHELL_TERM_MODE_ONLRET 
SHELL_TERM_MODE_CS7 
SHELL_TERM_MODE_CS8 
SHELL_TERM_MODE_PARENB 
SHELL_TERM_MODE_PARODD 
SHELL_TERM_MODE_TTY_OP_ISPEED 
SHELL_TERM_MODE_TTY_OP_OSPEED 

Definition at line 90 of file shell_server_pty.h.

Function Documentation

◆ shellClearCommandLine()

error_t shellClearCommandLine ( ShellServerSession session)

Clear command line.

Parameters
[in]sessionHandle referencing an shell session
Returns
error code

Definition at line 803 of file shell_server_pty.c.

◆ shellRestoreCommandLine()

error_t shellRestoreCommandLine ( ShellServerSession session,
const char_t commandLine,
size_t  length 
)

Restore command line.

Parameters
[in]sessionHandle referencing an shell session
[in]commandLinePointer to the command line
[in]lengthLength of the command line
Returns
error code

Definition at line 853 of file shell_server_pty.c.

◆ shellServerInsertChar()

error_t shellServerInsertChar ( ShellServerSession session,
char_t  c 
)

Insert character at current position.

Parameters
[in]sessionHandle referencing an shell session
[in]cCharacter to be inserted
Returns
Error code

Definition at line 353 of file shell_server_pty.c.

◆ shellServerProcessBackspaceKey()

error_t shellServerProcessBackspaceKey ( ShellServerSession session)

Process backspace key.

Parameters
[in]sessionHandle referencing an shell session
Returns
Error code

Definition at line 434 of file shell_server_pty.c.

◆ shellServerProcessChar()

error_t shellServerProcessChar ( ShellServerSession session)

Process received character.

Parameters
[in]sessionHandle referencing an shell session
Returns
Error code

Definition at line 214 of file shell_server_pty.c.

◆ shellServerProcessDeleteKey()

error_t shellServerProcessDeleteKey ( ShellServerSession session)

Process delete key.

Parameters
[in]sessionHandle referencing an shell session
Returns
Error code

Definition at line 514 of file shell_server_pty.c.

◆ shellServerProcessDownKey()

error_t shellServerProcessDownKey ( ShellServerSession session)

Process down key.

Parameters
[in]sessionHandle referencing an shell session
Returns
Error code

Definition at line 692 of file shell_server_pty.c.

◆ shellServerProcessLeftKey()

error_t shellServerProcessLeftKey ( ShellServerSession session)

Process left key.

Parameters
[in]sessionHandle referencing an shell session
Returns
Error code

Definition at line 568 of file shell_server_pty.c.

◆ shellServerProcessPageDownKey()

error_t shellServerProcessPageDownKey ( ShellServerSession session)

Process page down key.

Parameters
[in]sessionHandle referencing an shell session
Returns
Error code

Definition at line 766 of file shell_server_pty.c.

◆ shellServerProcessPageUpKey()

error_t shellServerProcessPageUpKey ( ShellServerSession session)

Process page up key.

Parameters
[in]sessionHandle referencing an shell session
Returns
Error code

Definition at line 729 of file shell_server_pty.c.

◆ shellServerProcessRightKey()

error_t shellServerProcessRightKey ( ShellServerSession session)

Process right key.

Parameters
[in]sessionHandle referencing an shell session
Returns
Error code

Definition at line 612 of file shell_server_pty.c.

◆ shellServerProcessUpKey()

error_t shellServerProcessUpKey ( ShellServerSession session)

Process up key.

Parameters
[in]sessionHandle referencing an shell session
Returns
Error code

Definition at line 655 of file shell_server_pty.c.

◆ shellServerProcessWindowResize()

error_t shellServerProcessWindowResize ( ShellServerSession session)

Process window resize event.

Parameters
[in]sessionHandle referencing an shell session
Returns
Error code

Definition at line 51 of file shell_server_pty.c.