pty.h 998 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include <kernel/fs.h>
  3. #include <kernel/ringbuffer.h>
  4. #include <sys/ioctl.h>
  5. #include <sys/termios.h>
  6. typedef struct pty {
  7. /* the PTY number */
  8. int name;
  9. /* Master and slave endpoints */
  10. fs_node_t * master;
  11. fs_node_t * slave;
  12. /* term io "window size" struct (width/height) */
  13. struct winsize size;
  14. /* termios data structure */
  15. struct termios tios;
  16. /* directional pipes */
  17. ring_buffer_t * in;
  18. ring_buffer_t * out;
  19. char * canon_buffer;
  20. size_t canon_bufsize;
  21. size_t canon_buflen;
  22. pid_t ct_proc; /* Controlling process (shell) */
  23. pid_t fg_proc; /* Foreground process (might also be shell) */
  24. void (*write_in)(struct pty *, uint8_t);
  25. void (*write_out)(struct pty *, uint8_t);
  26. int next_is_verbatim;
  27. void (*fill_name)(struct pty *, char *);
  28. } pty_t;
  29. void tty_output_process_slave(pty_t * pty, uint8_t c);
  30. void tty_output_process(pty_t * pty, uint8_t c);
  31. void tty_input_process(pty_t * pty, uint8_t c);
  32. pty_t * pty_new(struct winsize * size);