Skip to content
pi-c Artifact [13815d644c]
Login

Artifact [13815d644c]

Artifact 13815d644c25dfe866a6d8eb4c1b32086e2fbd78c9956a717615c987eb4203ea:


/* /remote-control and pic remote-control (remote.c): how to reach this
 * conversation from a phone over ssh, stage 1 (no relay): the ssh command,
 * a QR code of the ssh:// address, and checks with their fixes. */
#ifndef PIC_TUI_REMOTE_H
#define PIC_TUI_REMOTE_H

typedef struct {
    char user[64];
    char host[256];      /* the Tailscale name when Tailscale is up, else the local host name */
    char url[384];       /* ssh://user@host */
    char then[4096];     /* what to run once logged in (cd ... && pic attach -i -c) */
    char command[8192];  /* ssh user@host -t '...': the whole thing, for any ssh client */
    int tailscale;       /* 1: reachable through Tailscale */
    int ssh_on;          /* 1: something listens on port 22 */
} tui_remote;

/* Fills R for the conversation SESSION (NULL or "": the latest, -c) of
 * WORKSPACE, run there with the pic at SELF. Looks the host up (tailscale
 * status, scutil, gethostname) and tries port 22. Dev builds take the
 * lookups from PIC_TEST_RC ("TAILSCALE_NAME|LOCAL_NAME|SSH": - for no
 * Tailscale, SSH 1 or 0). */
void tui_remote_info(tui_remote *r, const char *self, const char *workspace, const char *session);

/* TEXT as a QR code, two rows of modules per line in half blocks, with a
 * quiet zone of 4. LIGHT_BLOCKS: light modules are the blocks, to be drawn
 * light on dark (the caller colours it); 0: dark modules are the blocks,
 * for a light background. NULL on failure; malloc'd, lines ending in '\n';
 * *rows its line count. */
char *tui_remote_qr(const char *text, int light_blocks, int *rows);

/* The page: the address, the QR code, what to run, the command, the
 * checks; lines ending in '\n'. Each line of the QR code (light_blocks 1)
 * starts with TUI_REMOTE_QR, for the caller to colour white on black. */
#define TUI_REMOTE_QR '\x02'
char *tui_remote_page(const tui_remote *r);

#endif