.TH "ttypt/axil-tty.h" 3 "axil-tty" \" -*- nroff -*- .ad l .nh .SH NAME ttypt/axil-tty.h \- WebSocket-to-PTY bridge module for axil\&. .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br .SS "Functions" .in +1c .ti -1c .RI "\fBXY_DECL\fP (int, axil_tty_exec, socket_t, fd, char **, argv)" .br .ti -1c .RI "\fBXY_DECL\fP (int, axil_tty_shell, socket_t, fd)" .br .ti -1c .RI "\fBXY_DECL\fP (int, axil_tty_active, socket_t, fd)" .br .ti -1c .RI "\fBXY_DECL\fP (int, axil_tty_owns, socket_t, fd)" .br .ti -1c .RI "\fBXY_DECL\fP (int, axil_tty_attach, socket_t, fd)" .br .ti -1c .RI "\fBXY_DECL\fP (int, axil_tty_input, socket_t, fd, unsigned char *, input, int, nread)" .br .ti -1c .RI "int \fBaxil_tty_handle_tty\fP (socket_t cfd, char *body)" .br .in -1c .SH "Detailed Description" .PP WebSocket-to-PTY bridge module for axil\&. Bridges browser terminal sessions (WebSocket) to PTYs on the server: telnet negotiation (NAWS, ECHO, SGA), a login-shell \fRsh\fP handler, and browser terminal assets\&. Registers a \fRGET:/tty\fP upgrade handler; callers dispatch through the xy bus\&. .SH "Function Documentation" .PP .SS "int axil_tty_handle_tty (socket_t cfd, char * body)" Serve this module's \fRGET:/tty\fP route: the browser terminal page, or a WebSocket upgrade when the request carries one\&. .PP Exported so a host module that embeds this one (axil-nd) can register the route itself rather than depending on the nested xy_load() that installs it as a side effect\&. axil_register_handler() is last-wins, so registering it from both places is safe\&. .SS "XY_DECL (int , axil_tty_active , socket_t , fd )" Check if a PTY child process is active on fd\&. Returns 1 if active, 0 otherwise\&. .SS "XY_DECL (int , axil_tty_attach , socket_t , fd )" Negotiate terminal options on a client socket this module does not own\&. .PP Creates the per-connection state if absent and sends the same negotiation our own route sends on connect: \fRWILL ECHO\fP (once per socket, guarded so a later axil_tty_exec()/command_pty() is not a second statement of the same policy), \fRWONT SGA\fP, and \fRDO NAWS\fP\&. Returns 0, or -1 if the state could not be created\&. .PP No PTY is opened and no descriptor is claimed -- this is negotiation only\&. Use it from on_axil_connect() so a socket shared with a host module (axil-nd runs its game and its shell on one /nd socket) gets a real terminal negotiation and a window size, instead of the host reimplementing the telnet options\&. The PTY, and the \fRWILL ECHO\fP that belongs to it, still come from axil_tty_shell()/axil_tty_exec()\&. .SS "XY_DECL (int , axil_tty_exec , socket_t , fd , char ** , argv )" Open a PTY and exec argv on fd\&. argv[0]==NULL uses the user's login shell\&. .PP argv[0] should be a full path, as with axil's own popen2(); the child is run with this module's curated environment (HOME, USER, SHELL, TERM, \&.\&.\&.)\&. A bare name still resolves, but via the server's own PATH and without that environment\&. .SS "XY_DECL (int , axil_tty_input , socket_t , fd , unsigned char * , input , int , nread )" Feed client input to the PTY bridge on fd, consuming any telnet options\&. .PP Consumes IAC sequences (NAWS updates the window size and may auto-spawn the shell, DO/DONT/WILL are dropped) and writes whatever follows to the PTY\&. This is the body of the on_axil_parse hook, exported for callers that receive client bytes by some other route\&. .PP Returns -1 when a PTY child consumed the input (caller must not also treat it as a command), otherwise the number of leading bytes consumed as telnet options, which is 0 when the whole buffer is PTY input\&. \fRinput\fP is not modified\&. .SS "XY_DECL (int , axil_tty_owns , socket_t , fd )" Check if this module owns the WebSocket on fd, i\&.e\&. the client connected to our own \fRGET:/tty\fP route\&. Returns 1 if owned, 0 otherwise\&. .PP Ownership here means the route, not the reading\&. axil decodes WebSocket frames and delivers each payload to on_axil_parse, which is axil_tty_input() -- for our own route and for a borrowed socket alike\&. No module needs axil_fd_watch() to receive client bytes, and a module that claims a client socket with axil_fd_watch() stops receiving them: the flag takes the descriptor out of descr_read() and gives it to axil_fd_tick() instead\&. .SS "XY_DECL (int , axil_tty_shell , socket_t , fd )" Open a PTY shell (login shell) on fd\&. .SH "Author" .PP Generated automatically by Doxygen for axil-tty from the source code\&.