shell_server_pty.c
Go to the documentation of this file.
1 /**
2  * @file shell_server_pty.c
3  * @brief Pseudo-terminal emulation
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2019-2026 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.6.8
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL SHELL_TRACE_LEVEL
33 
34 //Dependencies
35 #include "ssh/ssh.h"
36 #include "shell/shell_server.h"
37 #include "shell/shell_server_pty.h"
39 #include "debug.h"
40 
41 //Check SSH stack configuration
42 #if (SHELL_SERVER_SUPPORT == ENABLED)
43 
44 
45 /**
46  * @brief Process window resize event
47  * @param[in] session Handle referencing an shell session
48  * @return Error code
49  **/
50 
52 {
53  error_t error;
54  uint_t x;
55  uint_t y;
56  uint_t cursorPos;
57  char_t buffer[30];
58  size_t n = 0;
59  size_t i;
60  uint32_t newTermWidth;
61  uint32_t newTermHeight;
62 
63  //Acknowledge window resize event
64  session->windowResize = FALSE;
65 
66  //Retrieve the new dimensions of the terminal
67  newTermWidth = session->newTermWidth;
68  newTermHeight = session->newTermHeight;
69 
70  //Check client's identification string
71  if(osStrstr(session->channel->connection->remoteId, "Bitvise") != NULL ||
72  osStrstr(session->channel->connection->remoteId, "PuTTY") != NULL ||
73  osStrstr(session->channel->connection->remoteId, "SmartFTP") != NULL ||
74  osStrstr(session->channel->connection->remoteId, "libssh2") != NULL)
75  {
76  //Determine the current position of the cursor
77  cursorPos = session->promptLen + session->bufferPos;
78  y = cursorPos / session->termWidth;
79 
80  //Clear command line
81  n += osSprintf(buffer + n, "\r");
82 
83  if(y > 0)
84  {
85  n += osSprintf(buffer + n, VT100_MOVE_CURSOR_UP_N, y);
86  }
87 
88  n += osSprintf(buffer + n, VT100_CLEAR_SCREEN_DOWN);
89 
90  error = sshWriteChannel(session->channel, buffer, osStrlen(buffer),
91  NULL, 0);
92 
93  //Check status code
94  if(!error)
95  {
96  //Display shell prompt
97  error = sshWriteChannel(session->channel, session->prompt,
98  session->promptLen, NULL, 0);
99  }
100 
101  //Check status code
102  if(!error)
103  {
104  //Display command line
105  error = sshWriteChannel(session->channel, session->buffer,
106  session->bufferLen, NULL, 0);
107  }
108 
109  //Check status code
110  if(!error)
111  {
112  //Determine the current position of the cursor
113  cursorPos = session->promptLen + session->bufferLen;
114 
115  //Wrap to the next line if necessary
116  if((cursorPos % newTermWidth) == 0)
117  {
118  error = sshWriteChannel(session->channel, " \r", 2, NULL, 0);
119  }
120  }
121  }
122  else if(osStrstr(session->channel->connection->remoteId, "TTSSH") != NULL)
123  {
124  //Clear screen
126 
127  error = sshWriteChannel(session->channel, buffer, osStrlen(buffer),
128  NULL, 0);
129 
130  //Check status code
131  if(!error)
132  {
133  //Display shell prompt
134  error = sshWriteChannel(session->channel, session->prompt,
135  session->promptLen, NULL, 0);
136  }
137 
138  //Display command line
139  for(i = 0; i < session->bufferLen && !error; )
140  {
141  //Determine the current position of the cursor
142  cursorPos = session->promptLen + i;
143  n = cursorPos % newTermWidth;
144  n = newTermWidth - n;
145 
146  n = MIN(n, session->bufferLen - i);
147 
148  error = sshWriteChannel(session->channel, session->buffer + i, n,
149  NULL, 0);
150 
151  i += n;
152 
153  //Check status code
154  if(!error)
155  {
156  //Determine the current position of the cursor
157  cursorPos = session->promptLen + i;
158 
159  //Wrap to the next line if necessary
160  if((cursorPos % newTermWidth) == 0)
161  {
162  error = sshWriteChannel(session->channel, "\r\n", 2, NULL, 0);
163  }
164  }
165  }
166 
167  //Check status code
168  if(!error)
169  {
170  //Determine the current position of the cursor
171  cursorPos = session->promptLen + session->bufferPos;
172  x = cursorPos % newTermWidth;
173  y = cursorPos / newTermWidth;
174 
175  //Set cursor to home
176  n = osSprintf(buffer, VT100_HOME);
177 
178  //Move cursor to the desired position
179  if(y > 0)
180  {
181  n += osSprintf(buffer + n, VT100_MOVE_CURSOR_DOWN_N, y);
182  }
183 
184  if(x > 0)
185  {
186  n += osSprintf(buffer + n, VT100_MOVE_CURSOR_RIGHT_N, x);
187  }
188 
189  error = sshWriteChannel(session->channel, buffer, osStrlen(buffer),
190  NULL, 0);
191  }
192  }
193  else
194  {
195  //Ignore window resize event
196  error = NO_ERROR;
197  }
198 
199  //Update the dimensions of the terminal
200  session->termWidth = newTermWidth;
201  session->termHeight = newTermHeight;
202 
203  //Return status code
204  return error;
205 }
206 
207 
208 /**
209  * @brief Process received character
210  * @param[in] session Handle referencing an shell session
211  * @return Error code
212  **/
213 
215 {
216  error_t error;
217  size_t n;
218  char_t c;
219  SshChannel *channel;
220 
221  //Retrieve SSH channel handle
222  channel = session->channel;
223 
224  //Read a single character
225  error = sshReadChannel(channel, &c, 1, &n, 0);
226 
227  //Check status code
228  if(error == NO_ERROR)
229  {
230  //Check character code
231  if(c == session->backspaceCode)
232  {
233  //Process backspace key
234  error = shellServerProcessBackspaceKey(session);
235  }
236  else if(c == session->deleteCode)
237  {
238  //Process delete key
239  error = shellServerProcessDeleteKey(session);
240  }
241  else if(session->escSeqLen > 0)
242  {
243  //Limit the length of the multibyte escape sequence
244  if(session->escSeqLen < SHELL_SERVER_MAX_ESC_SEQ_LEN)
245  {
246  session->escSeq[session->escSeqLen++] = c;
247  session->escSeq[session->escSeqLen] = '\0';
248  }
249 
250  //End of escape sequence?
251  if(isalpha(c) || c == '~')
252  {
253  //Decode multibyte escape sequence
254  if(osStrcmp(session->escSeq, VT100_DELETE) == 0)
255  {
256  error = shellServerProcessDeleteKey(session);
257  }
258  else if(osStrcmp(session->escSeq, VT100_MOVE_CURSOR_LEFT) == 0)
259  {
260  error = shellServerProcessLeftKey(session);
261  }
262  else if(osStrcmp(session->escSeq, VT100_MOVE_CURSOR_RIGHT) == 0)
263  {
264  error = shellServerProcessRightKey(session);
265  }
266 
267  if(osStrcmp(session->escSeq, VT100_MOVE_CURSOR_UP) == 0)
268  {
269  error = shellServerProcessUpKey(session);
270  }
271  else if(osStrcmp(session->escSeq, VT100_MOVE_CURSOR_DOWN) == 0)
272  {
273  error = shellServerProcessDownKey(session);
274  }
275 
276  if(osStrcmp(session->escSeq, VT100_PAGE_UP) == 0)
277  {
278  error = shellServerProcessPageUpKey(session);
279  }
280  else if(osStrcmp(session->escSeq, VT100_PAGE_DOWN) == 0)
281  {
282  error = shellServerProcessPageDownKey(session);
283  }
284  else
285  {
286  //Unknown escape sequence
287  }
288 
289  //Clear escape sequence
290  session->escSeqLen = 0;
291  }
292  }
293  else if(c == VT100_ESC_CODE)
294  {
295  //Escape sequences start with an escape character
296  session->escSeq[0] = c;
297  session->escSeqLen = 1;
298  }
299  else if(c == '\r')
300  {
301  //Send a CRLF sequence to the client
302  error = sshWriteChannel(channel, "\r\n", 2, NULL, 0);
303 
304  //Check status code
305  if(!error)
306  {
307  //Properly terminate the command line with a NULL character
308  session->buffer[session->bufferLen] = '\0';
309  //Add command line to history
310  shellServerAddCommandLine(session, session->buffer);
311 
312  //Process command line
313  error = shellServerProcessCommandLine(session, session->buffer);
314  }
315 
316  //Check status code
317  if(!error)
318  {
319  //Display shell prompt
320  error = sshWriteChannel(channel, session->prompt,
321  osStrlen(session->prompt), NULL, 0);
322  }
323 
324  //Flush the receive buffer and wait for the next command line
325  session->bufferLen = 0;
326  session->bufferPos = 0;
327  }
328  else
329  {
330  //Insert character at current position
331  error = shellServerInsertChar(session, c);
332  }
333  }
334  else if(error == ERROR_TIMEOUT)
335  {
336  //Wait for the next character
337  error = NO_ERROR;
338  }
339  else
340  {
341  //A communication error has occurred
342  }
343 
344  //Return status code
345  return error;
346 }
347 
348 
349 /**
350  * @brief Insert character at current position
351  * @param[in] session Handle referencing an shell session
352  * @param[in] c Character to be inserted
353  * @return Error code
354  **/
355 
357 {
358  error_t error;
359  uint_t cursorPos;
360  char_t buffer[7];
361 
362  //Initialize status code
363  error = NO_ERROR;
364 
365  //Limit the length of the command line
366  if(session->bufferLen < (SHELL_SERVER_BUFFER_SIZE - 1))
367  {
368  //Check the position where the character is to be inserted
369  if(session->bufferPos < session->bufferLen)
370  {
371  //Make room for the character
372  osMemmove(session->buffer + session->bufferPos + 1,
373  session->buffer + session->bufferPos,
374  session->bufferLen - session->bufferPos);
375  }
376 
377  //Insert character at current position
378  session->buffer[session->bufferPos] = c;
379 
380  //Update the length of the command line
381  session->bufferLen++;
382  session->bufferPos++;
383 
384  //Determine the current position of the cursor
385  cursorPos = session->promptLen + session->bufferPos;
386 
387  //Echo back the character to the client
388  buffer[0] = c;
389  buffer[1] = '\0';
390 
391  if((cursorPos % session->termWidth) == 0)
392  {
393  osStrcat(buffer, "\r\n");
394  }
395 
396  if(session->bufferPos < session->bufferLen)
397  {
399  }
400 
401  error = sshWriteChannel(session->channel, buffer, osStrlen(buffer),
402  NULL, 0);
403 
404  //Check the position where the character is to be inserted
405  if(session->bufferPos < session->bufferLen)
406  {
407  //Check status code
408  if(!error)
409  {
410  error = sshWriteChannel(session->channel,
411  session->buffer + session->bufferPos,
412  session->bufferLen - session->bufferPos, NULL, 0);
413  }
414 
415  //Check status code
416  if(!error)
417  {
419 
420  error = sshWriteChannel(session->channel, buffer,
421  osStrlen(buffer), NULL, 0);
422  }
423  }
424  }
425 
426  //Return status code
427  return error;
428 }
429 
430 
431 /**
432  * @brief Process backspace key
433  * @param[in] session Handle referencing an shell session
434  * @return Error code
435  **/
436 
438 {
439  error_t error;
440  uint_t cursorPos;
441  char_t buffer[20];
442 
443  //Initialize status code
444  error = NO_ERROR;
445 
446  //Check the length of the command line
447  if(session->bufferPos > 0)
448  {
449  //Determine the current position of the cursor
450  cursorPos = session->promptLen + session->bufferPos;
451 
452  //Moving left at the edge of the screen wraps to the previous line
453  if((cursorPos % session->termWidth) == 0)
454  {
456  (uint_t) (session->termWidth - 1));
457  }
458  else
459  {
460  osStrcpy(buffer, VT100_BACKSPACE);
461  }
462 
463  //Check the position where the character is to be deleted
464  if(session->bufferPos < session->bufferLen)
465  {
467 
468  error = sshWriteChannel(session->channel, buffer, osStrlen(buffer),
469  NULL, 0);
470 
471  //Check status code
472  if(!error)
473  {
474  error = sshWriteChannel(session->channel,
475  session->buffer + session->bufferPos,
476  session->bufferLen - session->bufferPos, NULL, 0);
477  }
478 
479  //Check status code
480  if(!error)
481  {
482  osStrcpy(buffer, " " VT100_RESTORE_CURSOR_POS);
483 
484  error = sshWriteChannel(session->channel, buffer, osStrlen(buffer),
485  NULL, 0);
486  }
487 
488  //Delete character at current position
489  osMemmove(session->buffer + session->bufferPos - 1,
490  session->buffer + session->bufferPos,
491  session->bufferLen - session->bufferPos);
492  }
493  else
494  {
496 
497  error = sshWriteChannel(session->channel, buffer, osStrlen(buffer),
498  NULL, 0);
499  }
500 
501  //Update the length of the command line
502  session->bufferLen--;
503  session->bufferPos--;
504  }
505 
506  //Return status code
507  return error;
508 }
509 
510 
511 /**
512  * @brief Process delete key
513  * @param[in] session Handle referencing an shell session
514  * @return Error code
515  **/
516 
518 {
519  error_t error;
520  char_t buffer[5];
521 
522  //Initialize status code
523  error = NO_ERROR;
524 
525  //Check the position where the character is to be deleted
526  if(session->bufferPos < session->bufferLen)
527  {
528  //Save cursor position
530 
531  error = sshWriteChannel(session->channel, buffer, osStrlen(buffer),
532  NULL, 0);
533 
534  //Check status code
535  if(!error)
536  {
537  error = sshWriteChannel(session->channel,
538  session->buffer + session->bufferPos + 1,
539  session->bufferLen - session->bufferPos - 1, NULL, 0);
540  }
541 
542  //Check status code
543  if(!error)
544  {
545  osStrcpy(buffer, " " VT100_RESTORE_CURSOR_POS);
546 
547  error = sshWriteChannel(session->channel, buffer, osStrlen(buffer),
548  NULL, 0);
549  }
550 
551  //Delete character at current position
552  osMemmove(session->buffer + session->bufferPos,
553  session->buffer + session->bufferPos + 1,
554  session->bufferLen - session->bufferPos);
555 
556  //Update the length of the command line
557  session->bufferLen--;
558  }
559 
560  //Return status code
561  return error;
562 }
563 
564 
565 /**
566  * @brief Process left key
567  * @param[in] session Handle referencing an shell session
568  * @return Error code
569  **/
570 
572 {
573  error_t error;
574  uint_t cursorPos;
575  char_t buffer[17];
576 
577  //Initialize status code
578  error = NO_ERROR;
579 
580  //Check the length of the command line
581  if(session->bufferPos > 0)
582  {
583  //Determine the current position of the cursor
584  cursorPos = session->promptLen + session->bufferPos;
585 
586  //Moving left at the edge of the screen wraps to the previous line
587  if((cursorPos % session->termWidth) == 0)
588  {
590  (uint_t) (session->termWidth - 1));
591  }
592  else
593  {
594  osStrcpy(buffer, VT100_BACKSPACE);
595  }
596 
597  error = sshWriteChannel(session->channel, buffer, osStrlen(buffer),
598  NULL, 0);
599 
600  //Update current position
601  session->bufferPos--;
602  }
603 
604  //Return status code
605  return error;
606 }
607 
608 
609 /**
610  * @brief Process right key
611  * @param[in] session Handle referencing an shell session
612  * @return Error code
613  **/
614 
616 {
617  error_t error;
618  uint_t cursorPos;
619  char_t buffer[4];
620 
621  //Initialize status code
622  error = NO_ERROR;
623 
624  //Check current position
625  if(session->bufferPos < session->bufferLen)
626  {
627  //Determine the current position of the cursor
628  cursorPos = session->promptLen + session->bufferPos;
629 
630  //Moving right at the edge of the screen wraps to the next line
631  if((cursorPos % session->termWidth) == (session->termWidth - 1))
632  {
633  osStrcpy(buffer, "\r\n");
634  }
635  else
636  {
638  }
639 
640  error = sshWriteChannel(session->channel, buffer, osStrlen(buffer),
641  NULL, 0);
642 
643  //Update current position
644  session->bufferPos++;
645  }
646 
647  //Return status code
648  return error;
649 }
650 
651 
652 /**
653  * @brief Process up key
654  * @param[in] session Handle referencing an shell session
655  * @return Error code
656  **/
657 
659 {
660 #if (SHELL_SERVER_HISTORY_SUPPORT == ENABLED)
661  error_t error;
662  size_t n;
663  const char_t *p;
664 
665  //Retrieve the previous command line from history
666  error = shellServerGetPrevCommandLine(session, &p, &n);
667 
668  //Any entry found in history?
669  if(!error)
670  {
671  //Restore command line
672  error = shellRestoreCommandLine(session, p, n);
673  }
674  else
675  {
676  //The command history is empty
677  error = NO_ERROR;
678  }
679 
680  //Return status code
681  return error;
682 #else
683  //Ignore up key
684  return NO_ERROR;
685 #endif
686 }
687 
688 
689 /**
690  * @brief Process down key
691  * @param[in] session Handle referencing an shell session
692  * @return Error code
693  **/
694 
696 {
697 #if (SHELL_SERVER_HISTORY_SUPPORT == ENABLED)
698  error_t error;
699  size_t n;
700  const char_t *p;
701 
702  //Retrieve the next command line from history
703  error = shellServerGetNextCommandLine(session, &p, &n);
704 
705  //Any entry found in history?
706  if(!error)
707  {
708  //Restore command line
709  error = shellRestoreCommandLine(session, p, n);
710  }
711  else
712  {
713  //The command history is empty
714  error = NO_ERROR;
715  }
716 
717  //Return status code
718  return error;
719 #else
720  //Ignore down key
721  return NO_ERROR;
722 #endif
723 }
724 
725 
726 /**
727  * @brief Process page up key
728  * @param[in] session Handle referencing an shell session
729  * @return Error code
730  **/
731 
733 {
734 #if (SHELL_SERVER_HISTORY_SUPPORT == ENABLED)
735  error_t error;
736  size_t n;
737  const char_t *p;
738 
739  //Retrieve the first command line from history
740  error = shellServerGetFirstCommandLine(session, &p, &n);
741 
742  //Any entry found in history?
743  if(!error)
744  {
745  //Restore command line
746  error = shellRestoreCommandLine(session, p, n);
747  }
748  else
749  {
750  //The command history is empty
751  error = NO_ERROR;
752  }
753 
754  //Return status code
755  return error;
756 #else
757  //Ignore page up key
758  return NO_ERROR;
759 #endif
760 }
761 
762 
763 /**
764  * @brief Process page down key
765  * @param[in] session Handle referencing an shell session
766  * @return Error code
767  **/
768 
770 {
771 #if (SHELL_SERVER_HISTORY_SUPPORT == ENABLED)
772  error_t error;
773  size_t n;
774  const char_t *p;
775 
776  //Retrieve the last command line from history
777  error = shellServerGetLastCommandLine(session, &p, &n);
778 
779  //Any entry found in history?
780  if(!error)
781  {
782  //Restore command line
783  error = shellRestoreCommandLine(session, p, n);
784  }
785  else
786  {
787  //The command history is empty
788  error = NO_ERROR;
789  }
790 
791  //Return status code
792  return error;
793 #else
794  //Ignore page down key
795  return NO_ERROR;
796 #endif
797 }
798 
799 
800 /**
801  * @brief Clear command line
802  * @param[in] session Handle referencing an shell session
803  * @return error code
804  **/
805 
807 {
808  error_t error;
809  uint_t y;
810  uint_t cursorPos;
811  char_t buffer[18];
812  size_t n;
813 
814  //Determine the current position of the cursor
815  cursorPos = session->promptLen + session->bufferPos;
816  y = cursorPos / session->termWidth;
817 
818  //Flush buffer
819  session->bufferLen = 0;
820  session->bufferPos = 0;
821 
822  //Clear command line
823  n = osSprintf(buffer, "\r");
824 
825  if(y > 0)
826  {
827  n += osSprintf(buffer + n, VT100_MOVE_CURSOR_UP_N, y);
828  }
829 
830  n += osSprintf(buffer + n, VT100_CLEAR_SCREEN_DOWN);
831 
832  error = sshWriteChannel(session->channel, buffer, osStrlen(buffer),
833  NULL, 0);
834 
835  //Check status code
836  if(!error)
837  {
838  //Display shell prompt
839  error = sshWriteChannel(session->channel, session->prompt,
840  session->promptLen, NULL, 0);
841  }
842 
843  //Return status code
844  return error;
845 }
846 
847 
848 /**
849  * @brief Restore command line
850  * @param[in] session Handle referencing an shell session
851  * @param[in] commandLine Pointer to the command line
852  * @param[in] length Length of the command line
853  * @return error code
854  **/
855 
857  const char_t *commandLine, size_t length)
858 {
859  error_t error;
860  uint_t cursorPos;
861 
862  //The command line must fit in the buffer, including the NULL terminator
863  //added when the command is executed
865  {
866  //Clear entire line
867  error = shellClearCommandLine(session);
868 
869  //Check status code
870  if(!error)
871  {
872  //Restore command line
873  osMemcpy(session->buffer, commandLine, length);
874  session->bufferLen = length;
875  session->bufferPos = length;
876 
877  //Display command line
878  error = sshWriteChannel(session->channel, session->buffer,
879  session->bufferLen, NULL, 0);
880  }
881 
882  //Check status code
883  if(!error)
884  {
885  //Determine the current position of the cursor
886  cursorPos = session->promptLen + session->bufferLen;
887 
888  //Wrap to the next line if necessary
889  if((cursorPos % session->termWidth) == 0)
890  {
891  error = sshWriteChannel(session->channel, " \r", 2, NULL, 0);
892  }
893  }
894  }
895  else
896  {
897  //A longer entry is not restored, rather than truncated
898  error = NO_ERROR;
899  }
900 
901  //Return status code
902  return error;
903 }
904 
905 #endif
error_t shellServerProcessDeleteKey(ShellServerSession *session)
Process delete key.
uint8_t p
Definition: ndp.h:300
uint8_t x
Definition: lldp_ext_med.h:211
error_t shellServerGetPrevCommandLine(ShellServerSession *session, const char_t **commandLine, size_t *length)
Extract previous command line from history.
#define VT100_MOVE_CURSOR_UP_N
#define VT100_PAGE_DOWN
#define osStrcmp(s1, s2)
Definition: os_port.h:177
#define osStrlen(s)
Definition: os_port.h:171
error_t shellServerProcessPageDownKey(ShellServerSession *session)
Process page down key.
#define VT100_CLEAR_ENTIRE_SCREEN
error_t shellServerGetLastCommandLine(ShellServerSession *session, const char_t **commandLine, size_t *length)
Extract last command line from history.
error_t shellClearCommandLine(ShellServerSession *session)
Clear command line.
error_t sshReadChannel(SshChannel *channel, void *data, size_t size, size_t *received, uint_t flags)
Receive data from the specified channel.
Definition: ssh.c:2336
error_t shellServerProcessPageUpKey(ShellServerSession *session)
Process page up key.
Helper functions for SSH secure shell server.
#define VT100_MOVE_CURSOR_UP
error_t shellServerProcessUpKey(ShellServerSession *session)
Process up key.
SSH secure shell server.
#define FALSE
Definition: os_port.h:46
Pseudo-terminal emulation.
#define osMemcpy(dest, src, length)
Definition: os_port.h:147
#define VT100_MOVE_CURSOR_DOWN_N
error_t
Error codes.
Definition: error.h:43
#define osSprintf(dest,...)
Definition: os_port.h:237
#define SHELL_SERVER_BUFFER_SIZE
Definition: shell_server.h:72
#define VT100_MOVE_CURSOR_RIGHT
#define VT100_ESC_CODE
error_t sshWriteChannel(SshChannel *channel, const void *data, size_t length, size_t *written, uint_t flags)
Write data to the specified channel.
Definition: ssh.c:2203
error_t shellServerProcessRightKey(ShellServerSession *session)
Process right key.
#define SHELL_SERVER_MAX_ESC_SEQ_LEN
Definition: shell_server.h:123
uint8_t length
Definition: tcp.h:375
#define MIN(a, b)
Definition: os_port.h:63
error_t shellServerInsertChar(ShellServerSession *session, char_t c)
Insert character at current position.
#define VT100_MOVE_CURSOR_LEFT
@ ERROR_TIMEOUT
Definition: error.h:95
char char_t
Definition: compiler_port.h:55
#define osStrcat(s1, s2)
Definition: os_port.h:225
error_t shellServerProcessDownKey(ShellServerSession *session)
Process down key.
uint8_t n
#define ShellServerSession
Definition: shell_server.h:131
#define VT100_CLEAR_SCREEN_DOWN
void shellServerAddCommandLine(ShellServerSession *session, const char_t *commandLine)
Add command line to history.
#define VT100_HOME
#define VT100_PAGE_UP
error_t shellServerGetNextCommandLine(ShellServerSession *session, const char_t **commandLine, size_t *length)
Extract next command line from history.
#define VT100_MOVE_CURSOR_DOWN
error_t shellServerProcessLeftKey(ShellServerSession *session)
Process left key.
#define VT100_DELETE
#define osStrstr(s1, s2)
Definition: os_port.h:207
error_t shellServerProcessWindowResize(ShellServerSession *session)
Process window resize event.
unsigned int uint_t
Definition: compiler_port.h:57
Secure Shell (SSH)
error_t shellServerProcessBackspaceKey(ShellServerSession *session)
Process backspace key.
#define VT100_RESTORE_CURSOR_POS
#define osStrcpy(s1, s2)
Definition: os_port.h:213
error_t shellServerProcessChar(ShellServerSession *session)
Process received character.
@ NO_ERROR
Success.
Definition: error.h:44
uint8_t c
Definition: ndp.h:514
error_t shellServerGetFirstCommandLine(ShellServerSession *session, const char_t **commandLine, size_t *length)
Extract first command line from history.
Debugging facilities.
#define osMemmove(dest, src, length)
Definition: os_port.h:153
error_t shellServerProcessCommandLine(ShellServerSession *session, char_t *commandLine)
Command line processing.
error_t shellRestoreCommandLine(ShellServerSession *session, const char_t *commandLine, size_t length)
Restore command line.
#define SshChannel
Definition: ssh.h:1062
#define VT100_MOVE_CURSOR_RIGHT_N
#define VT100_BACKSPACE
#define VT100_SAVE_CURSOR_POS