11acd27e7Smillert /* **************************************************************** */
21acd27e7Smillert /* */
31acd27e7Smillert /* Testing Readline */
41acd27e7Smillert /* */
51acd27e7Smillert /* **************************************************************** */
61acd27e7Smillert
7*15b117eaSkettenis /* Copyright (C) 1987-2002 Free Software Foundation, Inc.
8*15b117eaSkettenis
9*15b117eaSkettenis This file is part of the GNU Readline Library, a library for
10*15b117eaSkettenis reading lines of text with interactive input and history editing.
11*15b117eaSkettenis
12*15b117eaSkettenis The GNU Readline Library is free software; you can redistribute it
13*15b117eaSkettenis and/or modify it under the terms of the GNU General Public License
14*15b117eaSkettenis as published by the Free Software Foundation; either version 2, or
15*15b117eaSkettenis (at your option) any later version.
16*15b117eaSkettenis
17*15b117eaSkettenis The GNU Readline Library is distributed in the hope that it will be
18*15b117eaSkettenis useful, but WITHOUT ANY WARRANTY; without even the implied warranty
19*15b117eaSkettenis of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20*15b117eaSkettenis GNU General Public License for more details.
21*15b117eaSkettenis
22*15b117eaSkettenis The GNU General Public License is often shipped with GNU software, and
23*15b117eaSkettenis is generally kept in a file called COPYING or LICENSE. If you do not
24*15b117eaSkettenis have a copy of the license, write to the Free Software Foundation,
25*15b117eaSkettenis 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
26*15b117eaSkettenis
271acd27e7Smillert #if defined (HAVE_CONFIG_H)
281acd27e7Smillert #include <config.h>
291acd27e7Smillert #endif
301acd27e7Smillert
311acd27e7Smillert #include <stdio.h>
321acd27e7Smillert #include <sys/types.h>
331acd27e7Smillert
341acd27e7Smillert #ifdef READLINE_LIBRARY
351acd27e7Smillert # include "readline.h"
361acd27e7Smillert # include "history.h"
371acd27e7Smillert #else
381acd27e7Smillert # include <readline/readline.h>
391acd27e7Smillert # include <readline/history.h>
401acd27e7Smillert #endif
411acd27e7Smillert
421acd27e7Smillert extern HIST_ENTRY **history_list ();
431acd27e7Smillert
main()441acd27e7Smillert main ()
451acd27e7Smillert {
461acd27e7Smillert char *temp, *prompt;
471acd27e7Smillert int done;
481acd27e7Smillert
491acd27e7Smillert temp = (char *)NULL;
501acd27e7Smillert prompt = "readline$ ";
511acd27e7Smillert done = 0;
521acd27e7Smillert
531acd27e7Smillert while (!done)
541acd27e7Smillert {
551acd27e7Smillert temp = readline (prompt);
561acd27e7Smillert
571acd27e7Smillert /* Test for EOF. */
581acd27e7Smillert if (!temp)
591acd27e7Smillert exit (1);
601acd27e7Smillert
611acd27e7Smillert /* If there is anything on the line, print it and remember it. */
621acd27e7Smillert if (*temp)
631acd27e7Smillert {
641acd27e7Smillert fprintf (stderr, "%s\r\n", temp);
651acd27e7Smillert add_history (temp);
661acd27e7Smillert }
671acd27e7Smillert
681acd27e7Smillert /* Check for `command' that we handle. */
691acd27e7Smillert if (strcmp (temp, "quit") == 0)
701acd27e7Smillert done = 1;
711acd27e7Smillert
721acd27e7Smillert if (strcmp (temp, "list") == 0)
731acd27e7Smillert {
741acd27e7Smillert HIST_ENTRY **list;
751acd27e7Smillert register int i;
761acd27e7Smillert
771acd27e7Smillert list = history_list ();
781acd27e7Smillert if (list)
791acd27e7Smillert {
801acd27e7Smillert for (i = 0; list[i]; i++)
811acd27e7Smillert fprintf (stderr, "%d: %s\r\n", i, list[i]->line);
821acd27e7Smillert }
831acd27e7Smillert }
841acd27e7Smillert free (temp);
851acd27e7Smillert }
861acd27e7Smillert exit (0);
871acd27e7Smillert }
88