OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gdb-7.2/] [readline/] [examples/] [rltest.c] - Blame information for rev 865

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
/* **************************************************************** */
2
/*                                                                  */
3
/*                      Testing Readline                            */
4
/*                                                                  */
5
/* **************************************************************** */
6
 
7
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
8
 
9
   This file is part of the GNU Readline Library, a library for
10
   reading lines of text with interactive input and history editing.
11
 
12
   The GNU Readline Library is free software; you can redistribute it
13
   and/or modify it under the terms of the GNU General Public License
14
   as published by the Free Software Foundation; either version 2, or
15
   (at your option) any later version.
16
 
17
   The GNU Readline Library is distributed in the hope that it will be
18
   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
19
   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
   GNU General Public License for more details.
21
 
22
   The GNU General Public License is often shipped with GNU software, and
23
   is generally kept in a file called COPYING or LICENSE.  If you do not
24
   have a copy of the license, write to the Free Software Foundation,
25
   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
26
 
27
#if defined (HAVE_CONFIG_H)
28
#include <config.h>
29
#endif
30
 
31
#include <stdio.h>
32
#include <sys/types.h>
33
 
34
#ifdef HAVE_STDLIB_H
35
#  include <stdlib.h>
36
#else 
37
extern void exit();
38
#endif
39
 
40
#ifdef READLINE_LIBRARY
41
#  include "readline.h"
42
#  include "history.h"
43
#else
44
#  include <readline/readline.h>
45
#  include <readline/history.h>
46
#endif
47
 
48
extern HIST_ENTRY **history_list ();
49
 
50
main ()
51
{
52
  char *temp, *prompt;
53
  int done;
54
 
55
  temp = (char *)NULL;
56
  prompt = "readline$ ";
57
  done = 0;
58
 
59
  while (!done)
60
    {
61
      temp = readline (prompt);
62
 
63
      /* Test for EOF. */
64
      if (!temp)
65
        exit (1);
66
 
67
      /* If there is anything on the line, print it and remember it. */
68
      if (*temp)
69
        {
70
          fprintf (stderr, "%s\r\n", temp);
71
          add_history (temp);
72
        }
73
 
74
      /* Check for `command' that we handle. */
75
      if (strcmp (temp, "quit") == 0)
76
        done = 1;
77
 
78
      if (strcmp (temp, "list") == 0)
79
        {
80
          HIST_ENTRY **list;
81
          register int i;
82
 
83
          list = history_list ();
84
          if (list)
85
            {
86
              for (i = 0; list[i]; i++)
87
                fprintf (stderr, "%d: %s\r\n", i, list[i]->line);
88
            }
89
        }
90
      free (temp);
91
    }
92
  exit (0);
93
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.