-struct tty_ops {
- void (*release)(struct tty */*tty*/);
- int (*setattr)(struct tty */*tty*/,
- const struct gprintf_ops */*gops*/, void */*go*/,
- const struct tty_attr */*a*/);
- int (*setmodes)(struct tty */*tty*/,
- const struct gprintf_ops */*gops*/, void */*go*/,
- uint32 /*modes_bic*/, uint32 /*modes_xor*/);
- int (*move)(struct tty */*tty*/,
- const struct gprintf_ops */*gops*/, void */*go*/,
- unsigned /*orig*/, int /*y*/, int /*x*/);
- int (*repeat)(struct tty */*tty*/,
- const struct gprintf_ops */*gops*/, void */*go*/,
- int /*ch*/, unsigned /*n*/);
- int (*erase)(struct tty */*tty*/,
- const struct gprintf_ops */*gops*/, void */*go*/,
- unsigned /*f*/);
- int (*erch)(struct tty */*tty*/,
- const struct gprintf_ops */*gops*/, void */*go*/,
- unsigned /*n*/);
- int (*ins)(struct tty */*tty*/,
- const struct gprintf_ops */*gops*/, void */*go*/,
- unsigned /*f*/, unsigned /*n*/);
- int (*inch)(struct tty */*tty*/,
- const struct gprintf_ops */*gops*/, void */*go*/,
- int /*ch*/);
- int (*del)(struct tty */*tty*/,
- const struct gprintf_ops */*gops*/, void */*go*/,
- unsigned /*f*/, unsigned /*n*/);
- int (*_res0)(void), (*_res1)(void), (*_res2)(void), (*_res3)(void);
-};
+/*----- Lifecycle and maintenance -----------------------------------------*/
+
+/* --- @tty_open@ --- *
+ *
+ * Arguments: @FILE *fp@ = stream open on terminal, or null
+ * @unsigned f@ = flags (@TTF_...@)
+ * @const unsigned *backends@ = ordered list of backends to try
+ *
+ * Returns: Pointer to terminal control block, or null on error.
+ *
+ * Use: Open a terminal and return a @struct tty *@ terminal control
+ * block pointer.
+ *
+ * If @fp@ is provided, then it will be used for terminal
+ * output. If @fp@ is @stdout@, then input (not currently
+ * supported) will come from @stdin@; otherwise, input comes
+ * from @fp@. If @fp@ is null and @TTF_OPEN@ is set, then
+ * @tty_open@ will attempt to open a terminal for itself: if
+ * @stdin@ is interactive then it used for input; if @stdout@ --
+ * or, failing that, @stderr@ -- is interactive, then it is used
+ * for output; otherwise %|/dev/tty|% is opened and used. If
+ * @fp@ is null and @TTF_OPEN@ is not set, then a usable
+ * terminal control block is still returned, but output cannot
+ * be sent directly to the terminal -- since there isn't one.
+ *
+ * If @TTF_BORROW@ is set, then the stream will not be closed by
+ * @tty_close@. (This flag is ignored if @fp@ is null.)
+ *
+ * If @beckends@ is provided, then it points to a vector of
+ * @TTBK_...@ constants describing the backends to be tried in
+ * order. The vector is terminated by @TTBK_END@; if this is
+ * found, then a null pointer is returned.
+ *
+ * A null control block pointer is valid for all @tty@
+ * functions: most will just immediately report failure, but
+ * there won't be any crashing.
+ */