static void setup_input(client_t *c) { int fd; fd = fileno(stdin); c->brl = brl_create_with_murphy(fd, "disconnected", c->ml, process_input, c); if (c->brl != NULL) brl_show_prompt(c->brl); else { fprintf(stderr, "Failed to initialize breedline for console input."); exit(1); } }
int brl_read_line(brl_t *brl, char *buf, size_t size) { if (brl->ml == NULL && brl->ml_ops == NULL) { reset_input(brl); enable_rawmode(brl); brl_show_prompt(brl); redraw_prompt(brl); _brl_process_input(brl); if (brl->data > 0) snprintf(buf, size, "%s", brl->buf); else buf[0] = '\0'; brl_hide_prompt(brl); restore_rawmode(brl); return brl->data; } else { errno = EINPROGRESS; return -1; } }
static void show_prompt(client_t *c) { if (c->brl != NULL) brl_show_prompt(c->brl); }