996
|
1 /* -*- mode: C; coding: utf-8; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
|
|
2 *
|
|
3 * cfunge - A standard-conforming Befunge93/98/109 interpreter in C.
|
|
4 * Copyright (C) 2008-2009 Arvid Norlander <anmaster AT tele2 DOT se>
|
|
5 *
|
|
6 * This program 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 the proxy's option) any later version. Arvid Norlander is a
|
|
10 * proxy who can decide which future versions of the GNU General Public
|
|
11 * License can be used.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20 */
|
|
21
|
|
22 /**
|
|
23 * @file
|
|
24 * The file input.c contains functions for reading user input from STDIN,
|
|
25 * buffered as needed.
|
|
26 */
|
|
27
|
|
28 #ifndef FUNGE_HAD_SRC_INPUT_H
|
|
29 #define FUNGE_HAD_SRC_INPUT_H
|
|
30
|
|
31 #include "global.h"
|
|
32 #include <stdbool.h>
|
|
33
|
|
34 /**
|
|
35 * Return type of input_getint()
|
|
36 */
|
|
37 typedef enum ret_getint {
|
|
38 rgi_success = 0, ///< Successfully got an integer
|
|
39 rgi_eof = 1, ///< We got an EOF and should reflect
|
|
40 rgi_noint = 2, ///< We didn't get an int, please call us again.
|
|
41 } ret_getint;
|
|
42
|
|
43 /**
|
|
44 * For use in input instruction & and in some fingerprints.
|
|
45 * @param value Pointer to some memory to place the read integer in.
|
|
46 * @param base What base to read the number as.
|
|
47 * @return
|
|
48 * Returns rgi_success if it got an integer in the given base, otherwise
|
|
49 * rgi_noint or rgi_eof.
|
|
50 * @note The read integer is returned in the value parameter.
|
|
51 */
|
|
52 FUNGE_ATTR_NONNULL FUNGE_ATTR_WARN_UNUSED FUNGE_ATTR_FAST
|
|
53 ret_getint input_getint(funge_cell * restrict value, int base);
|
|
54
|
|
55 /**
|
|
56 * For use in input instruction ~ and in some fingerprints.
|
|
57 * This uses a buffer and read in one line (if the buffer is empty,
|
|
58 * otherwise it reuse the values from the old buffer).
|
|
59 * @param chr Pointer to a funge_cell to return value in.
|
|
60 * @return True if we got a char, false if we got EOF and should reflect.
|
|
61 */
|
|
62 FUNGE_ATTR_NONNULL FUNGE_ATTR_WARN_UNUSED FUNGE_ATTR_FAST
|
|
63 bool input_getchar(funge_cell * restrict chr);
|
|
64
|
|
65 /**
|
|
66 * For use in input some fingerprints.
|
|
67 * This will return the whole buffer.
|
|
68 * @param str Pointer to a string pointer to fill in.
|
|
69 * @return True if we got a string, false if we got EOF and should reflect.
|
|
70 */
|
|
71 FUNGE_ATTR_NONNULL FUNGE_ATTR_WARN_UNUSED FUNGE_ATTR_FAST
|
|
72 bool input_getline(unsigned char ** str);
|
|
73
|
|
74 #endif
|