~ubuntu-branches/debian/sid/grub2/sid-200907171837

« back to all changes in this revision

Viewing changes to commands/read.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Millan
  • Date: 2009-07-02 13:23:51 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702132351-tanpn0ryyijp93gu
Tags: 1.96+20090702-1
* New SVN snapshot.
* rules: Remove duplicated files in sparc64-ieee1275 port.
* rules: Comment out -DGRUB_ASSUME_LINUX_HAS_FB_SUPPORT=1 setting.  We'll
  re-evaluate using it when it's more mature.  (Closes: #535026).

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <grub/dl.h>
21
21
#include <grub/misc.h>
22
22
#include <grub/mm.h>
23
 
#include <grub/normal.h>
 
23
#include <grub/env.h>
24
24
#include <grub/term.h>
25
25
#include <grub/types.h>
 
26
#include <grub/command.h>
26
27
 
27
28
static char *
28
29
grub_getline (void)
30
31
  int i;
31
32
  char *line;
32
33
  char *tmp;
 
34
  char c;
33
35
 
34
36
  i = 0;
35
37
  line = grub_malloc (1 + i + sizeof('\0'));
36
38
  if (! line)
37
39
    return NULL;
38
40
 
39
 
  while ((line[i - 1] != '\n') && (line[i - 1] != '\r'))
 
41
  while (1)
40
42
    {
41
 
      line[i] = grub_getkey ();
42
 
      if (grub_isprint (line[i]))
43
 
        grub_putchar (line[i]);
 
43
      c = grub_getkey ();
 
44
      if ((c == '\n') || (c == '\r'))
 
45
        break;
 
46
 
 
47
      line[i] = c;
 
48
      if (grub_isprint (c))
 
49
        grub_putchar (c);
44
50
      i++;
45
51
      tmp = grub_realloc (line, 1 + i + sizeof('\0'));
46
52
      if (! tmp)
56
62
}
57
63
 
58
64
static grub_err_t
59
 
grub_cmd_read (struct grub_arg_list *state UNUSED, int argc, char **args)
 
65
grub_cmd_read (grub_command_t cmd UNUSED, int argc, char **args)
60
66
{
61
67
  char *line = grub_getline ();
62
68
  if (! line)
68
74
  return 0;
69
75
}
70
76
 
 
77
static grub_command_t cmd;
71
78
 
72
79
GRUB_MOD_INIT(read)
73
80
{
74
 
  grub_register_command ("read", grub_cmd_read, GRUB_COMMAND_FLAG_CMDLINE,
75
 
                         "read [ENVVAR]", "Set variable with user input", 0);
 
81
  cmd = grub_register_command ("read", grub_cmd_read,
 
82
                               "read [ENVVAR]",
 
83
                               "Set variable with user input");
76
84
}
77
85
 
78
86
GRUB_MOD_FINI(read)
79
87
{
80
 
  grub_unregister_command ("read");
 
88
  grub_unregister_command (cmd);
81
89
}