summaryrefslogtreecommitdiffstats
path: root/readline-4.2
diff options
context:
space:
mode:
authorEric Norum <WENorum@lbl.gov>1999-09-02 14:59:36 +0000
committerEric Norum <WENorum@lbl.gov>1999-09-02 14:59:36 +0000
commit31f926182c95dbc735e0efbc48068606cb641431 (patch)
tree50ecde62c9505ec62a32e1d99935c7820c4b215d /readline-4.2
parentUseful add-on libraries (diff)
downloadrtems-addon-packages-31f926182c95dbc735e0efbc48068606cb641431.tar.bz2
Useful add-on libraries
Diffstat (limited to 'readline-4.2')
-rw-r--r--readline-4.2/examples/rltest.c67
-rw-r--r--readline-4.2/examples/rlversion.c23
2 files changed, 90 insertions, 0 deletions
diff --git a/readline-4.2/examples/rltest.c b/readline-4.2/examples/rltest.c
new file mode 100644
index 0000000..6250f90
--- /dev/null
+++ b/readline-4.2/examples/rltest.c
@@ -0,0 +1,67 @@
+/* **************************************************************** */
+/* */
+/* Testing Readline */
+/* */
+/* **************************************************************** */
+
+#if defined (HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#ifdef READLINE_LIBRARY
+# include "readline.h"
+# include "history.h"
+#else
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif
+
+extern HIST_ENTRY **history_list ();
+
+main ()
+{
+ char *temp, *prompt;
+ int done;
+
+ temp = (char *)NULL;
+ prompt = "readline$ ";
+ done = 0;
+
+ while (!done)
+ {
+ temp = readline (prompt);
+
+ /* Test for EOF. */
+ if (!temp)
+ exit (1);
+
+ /* If there is anything on the line, print it and remember it. */
+ if (*temp)
+ {
+ fprintf (stderr, "%s\r\n", temp);
+ add_history (temp);
+ }
+
+ /* Check for `command' that we handle. */
+ if (strcmp (temp, "quit") == 0)
+ done = 1;
+
+ if (strcmp (temp, "list") == 0)
+ {
+ HIST_ENTRY **list;
+ register int i;
+
+ list = history_list ();
+ if (list)
+ {
+ for (i = 0; list[i]; i++)
+ fprintf (stderr, "%d: %s\r\n", i, list[i]->line);
+ }
+ }
+ free (temp);
+ }
+ exit (0);
+}
diff --git a/readline-4.2/examples/rlversion.c b/readline-4.2/examples/rlversion.c
new file mode 100644
index 0000000..652d37c
--- /dev/null
+++ b/readline-4.2/examples/rlversion.c
@@ -0,0 +1,23 @@
+/*
+ * rlversion -- print out readline's version number
+ */
+
+#if defined (HAVE_CONFIG_H)
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include "posixstat.h"
+
+#ifdef READLINE_LIBRARY
+# include "readline.h"
+#else
+# include <readline/readline.h>
+#endif
+
+main()
+{
+ printf ("%s\n", rl_library_version ? rl_library_version : "unknown");
+ exit (0);
+}