diff options
Diffstat (limited to 'src/intf.c')
-rw-r--r-- | src/intf.c | 61 |
1 files changed, 55 insertions, 6 deletions
@@ -95,7 +95,7 @@ static int init_mgroup(struct tsnif_handle *h) return trans_send(&h->trans, &msg); } -int tsnif_init(struct tsnif_handle *h, struct tsnif_ops *ops) +int tsnif_init(struct tsnif_handle *h, struct tsnif_ops *ops, struct tsnif_np_args *np) { int err; @@ -106,6 +106,10 @@ int tsnif_init(struct tsnif_handle *h, struct tsnif_ops *ops) h->ops = ops; INIT_LIST_HEAD(&h->terms); + err = tsnif_np_init(h, np); + if (h->np_only) + return err; + err = trans_init(&h->trans, trans_cb); if (err) return err; @@ -115,17 +119,42 @@ int tsnif_init(struct tsnif_handle *h, struct tsnif_ops *ops) int tsnif_close(struct tsnif_handle *h) { + int err; + + err = tsnif_np_close(h); + if (h->np_only) + return err; + return trans_close(&h->trans); } -int tsnif_process(struct tsnif_handle *h) +int tsnif_process(struct tsnif_handle *h, fd_set *set) { - return trans_process(&h->trans); + int err; + + err = tsnif_np_process(h, set); + + if (h->np_only) + return err; + + return trans_process(&h->trans, set); } -int tsnif_fd(struct tsnif_handle *h) +int tsnif_fd(struct tsnif_handle *h, fd_set *set) { - return trans_fd(&h->trans); + int fd_np; + int fd_trans; + + FD_ZERO(set); + + fd_np = tsnif_np_fd(h, set); + if (h->np_only) + return fd_np; + + fd_trans = trans_fd(&h->trans); + FD_SET(fd_trans, set); + + return (fd_trans > fd_np ? fd_trans : fd_np); } int tsnif_term_add(struct tsnif_handle *h, struct tsnif_term *term, @@ -153,10 +182,16 @@ int tsnif_term_del(struct tsnif_handle *h, struct tsnif_term *term) return 0; } +enum { + TSNIF_NP_ONLY, + TSNIF_NP_TRANS, +}; + int tsnif_attach(struct tsnif_term *term) { struct trans_msg msg; struct tsnif_handle *h = term->handle; + int ret; TSNIF_DEBUG(INTF, "type %d, idx %d\n", term->type, term->idx); @@ -170,6 +205,10 @@ int tsnif_attach(struct tsnif_term *term) msg.idx = term->idx; msg.cmd = TSNIF_CMD_ATTACH; + ret = tsnif_np_send(h, &msg); + if (h->np_only) + return ret; + return trans_send(&h->trans, &msg); } @@ -177,6 +216,7 @@ int tsnif_detach(struct tsnif_term *term) { struct trans_msg msg; struct tsnif_handle *h = term->handle; + int ret; TSNIF_DEBUG(INTF, "type %d, idx %d\n", term->type, term->idx); @@ -190,18 +230,27 @@ int tsnif_detach(struct tsnif_term *term) msg.idx = term->idx; msg.cmd = TSNIF_CMD_DETACH; + ret = tsnif_np_send(h, &msg); + if (h->np_only) + return ret; + return trans_send(&h->trans, &msg); } int tsnif_list(struct tsnif_handle *h) { struct trans_msg msg; + int ret; TSNIF_DEBUG(INTF, "sending list command\n"); memset(&msg, 0x0, sizeof(msg)); msg.cmd = TSNIF_CMD_TTY_LIST; + ret = tsnif_np_send(h, &msg); + if (h->np_only) + return ret; + return trans_send(&h->trans, &msg); } @@ -216,5 +265,5 @@ int tsnif_enum(struct tsnif_handle *h, cb_tsnif_enum_t cb) break; } - return err;; + return err; } |