-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgcode-input.h
More file actions
59 lines (49 loc) · 2.13 KB
/
Copy pathgcode-input.h
File metadata and controls
59 lines (49 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
============================================================================
Name : gcode-input.h
Author : Radu - Eosif Mihailescu
Version : 1.0 (2012-08-11)
Copyright : (C) 2012 Radu - Eosif Mihailescu <radu.mihailescu@linux360.ro>
Description : G-Code Input API Header
============================================================================
*/
#ifndef GCODE_INPUT_H_
#define GCODE_INPUT_H_
#include <stdint.h>
#include "gcode-commons.h"
typedef struct {
long offset; /* "long" as per man fseek */
uint16_t program;
} TGCodeProgramIndexEntry;
/* Gets the input ready to stream data in, takes opaque pointer to data store */
bool init_input(void *data);
/* Reset input, rewinding it to the top. Next character fetched will be first
* character of program */
bool rewind_input(void);
/* Seek input to offset. Next character fetched will be the one at
* offset. Note that offset has no relation to N word */
bool seek_input(long offset);
/* Return current position of input as an opaque offset usable for
* seek_input() later on */
long tell_input(void);
/* Fetch the next character of input or EOF */
char fetch_char_input(void);
/* Fetch a complete line of input, stripped of whitespace, comments and \n;
* returns false if there's no more input to read.
* Call with NULL if you don't care about the line's program contents and only
* want to detect syntax errors.
* line[] is assumed to be at most 256 characters long. */
bool fetch_line_input(char *line);
/* Where does O<n> start? */
long get_program_input(uint16_t program);
/* Splices data into the input stream. After the call, fetch_char_input() will
* operate on data instead of the input file (which remains otherwise open and
* unaffected). When '\0' is read from data, input is switched back to the
* input file and data is free()d.
* Calling subprograms from spliced code results in undefined behavior.
* Returns true if successful, false if already spliced. */
bool splice_input(const char *data);
/* Returns true exactly once if the end of the input splice was reached */
bool end_of_spliced_input(void);
bool done_input(void);
#endif /* GCODE_INPUT_H_ */