summaryrefslogtreecommitdiffstats
path: root/examples/rlbasic.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 12:43:23 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 12:43:23 +0000
commitc2e5be2aa0fbd926b07f764ffbc8359d3246342f (patch)
tree3d8907d9f67b8c8d9a407c60f5c09c947ce8a151 /examples/rlbasic.c
parentInitial commit. (diff)
downloadreadline-c2e5be2aa0fbd926b07f764ffbc8359d3246342f.tar.xz
readline-c2e5be2aa0fbd926b07f764ffbc8359d3246342f.zip
Adding upstream version 8.1.upstream/8.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--examples/rlbasic.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/rlbasic.c b/examples/rlbasic.c
new file mode 100644
index 0000000..6a9601f
--- /dev/null
+++ b/examples/rlbasic.c
@@ -0,0 +1,29 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+#if defined (READLINE_LIBRARY)
+# include "readline.h"
+# include "history.h"
+#else
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif
+
+int
+main (int c, char **v)
+{
+ char *input;
+
+ for (;;) {
+ input = readline ((char *)NULL);
+ if (input == 0)
+ break;
+ printf ("%s\n", input);
+ if (strcmp (input, "exit") == 0)
+ break;
+ free (input);
+ }
+ exit (0);
+}