+#include <readline/readline.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+/* Read-Send-Print-Loop */
+void rspl(int pin, int pout)
+{
+ static char *line = (char *)NULL;
+ int exit = 0;
+
+ while (!exit) {
+ if (line) {
+ free(line);
+ line = (char *)NULL;
+ }
+
+ line = readline("gacela>");
+
+ if (line && *line) {
+ add_history(line);
+ if (strcmp(line, "(quit)") == 0)
+ exit = 1;
+ else {
+ write(pout, line, strlen(line));
+ write(pout, "\n", 1);
+ }
+ }
+ }
+}