2009-11-21 Samuel Thibault <samuel.thibault@ens-lyon.org>
[grub2.git] / include / grub / reader.h
blobc7e67bf5e4f0850a870c94b761b04b52a0f02d2e
1 /* reader.h - prototypes for command line reader. */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2009 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef GRUB_READER_HEADER
21 #define GRUB_READER_HEADER 1
23 #include <grub/types.h>
24 #include <grub/err.h>
25 #include <grub/handler.h>
27 typedef grub_err_t (*grub_reader_getline_t) (char **, int);
29 struct grub_reader
31 /* The next reader. */
32 struct grub_parser *next;
34 /* The reader name. */
35 const char *name;
37 /* Initialize the reader. */
38 grub_err_t (*init) (void);
40 /* Clean up the reader. */
41 grub_err_t (*fini) (void);
43 grub_reader_getline_t read_line;
45 typedef struct grub_reader *grub_reader_t;
47 extern struct grub_handler_class EXPORT_VAR(grub_reader_class);
49 grub_err_t EXPORT_FUNC(grub_reader_loop) (grub_reader_getline_t getline);
51 static inline void
52 grub_reader_register (const char *name __attribute__ ((unused)),
53 grub_reader_t reader)
55 grub_handler_register (&grub_reader_class, GRUB_AS_HANDLER (reader));
58 static inline void
59 grub_reader_unregister (grub_reader_t reader)
61 grub_handler_unregister (&grub_reader_class, GRUB_AS_HANDLER (reader));
64 static inline grub_reader_t
65 grub_reader_get_current (void)
67 return (grub_reader_t) grub_reader_class.cur_handler;
70 static inline grub_err_t
71 grub_reader_set_current (grub_reader_t reader)
73 return grub_handler_set_current (&grub_reader_class,
74 GRUB_AS_HANDLER (reader));
77 void grub_register_rescue_reader (void);
79 #endif /* ! GRUB_READER_HEADER */