#include <cmdline_socket.h>
#include <cmdline.h>
+static void
+validate_buffer(struct rdline *rdl, const char *buf,
+ __attribute__((unused)) unsigned int size)
+{
+ int i;
+
+ printf("Buffer is <%s> (read from callback)\n", buf);
+ for (i = 0; i < 100; i++) {
+ rdline_asyncpager_printf(rdl, "foo%d\n", i);
+ }
+}
+
int main(void)
{
struct termios oldterm, term;
tcsetattr(0, TCSANOW, &term);
setbuf(stdin, NULL);
- rdline_init(&rdl, 0, 1, NULL, NULL, NULL);
- while (rdline(&rdl, "prompt> ") == RDLINE_RES_VALIDATED)
- printf("Buffer is <%s>\n", rdline_get_buffer(&rdl));
+ rdline_init(&rdl, 0, 1, validate_buffer, NULL, NULL);
+ while (rdline(&rdl, "prompt> ") == RDLINE_RES_VALIDATED) {
+ printf("Buffer is <%s> (read from main loop)\n",
+ rdline_get_buffer(&rdl));
+ }
tcsetattr(0, TCSANOW, &oldterm);
return 0;