return cmdline_complete(cl, buf, state, dstbuf, dstsize);
}
-void
+int
cmdline_write_char(struct rdline *rdl, char c)
{
+ int ret = -1;
struct cmdline *cl = rdl->opaque;
- if (cl->s_out >= 0) {
- write(cl->s_out, &c, 1);
- }
+
+ if (cl->s_out >= 0)
+ ret = write(cl->s_out, &c, 1);
+
+ return ret;
}
c = -1;
while (1) {
- read(cl->s_in, &c, 1);
- if (cmdline_in(cl, &c, 1) < 0) {
+ if (read(cl->s_in, &c, 1) < 0)
+ break;
+ if (cmdline_in(cl, &c, 1) < 0)
break;
- }
}
cmdline_free(cl);
}
void cmdline_free(struct cmdline *cl);
void cmdline_printf(const struct cmdline *cl, const char *fmt, ...);
int cmdline_in(struct cmdline *cl, const char *buf, int size);
-void cmdline_write_char(struct rdline *rdl, char c);
+int cmdline_write_char(struct rdline *rdl, char c);
void cmdline_interact(struct cmdline *cl);
void cmdline_quit(struct cmdline *cl);