implement saving and restoring input, at least for string (file not tested)

This commit is contained in:
2021-11-27 01:37:16 +01:00
parent 877c98d262
commit 8d66238f47
5 changed files with 136 additions and 36 deletions
+7 -5
View File
@@ -15,17 +15,19 @@ typedef bool (*fh_input_refill_t)(struct fh_thread_s *fh, struct fh_input_spec_s
/** Spec free func */
typedef void (*fh_input_free_t)(void *spec);
typedef void (*fh_input_start_t)(struct fh_thread_s *fh, struct fh_input_spec_s *spec);
typedef void (*fh_input_void_method_t)(struct fh_thread_s *fh, struct fh_input_spec_s *spec);
typedef void (*fh_input_pushpop_t)(struct fh_thread_s *fh, struct fh_input_spec_s *spec);
typedef enum fh_error (*fh_input_error_method_t)(struct fh_thread_s *fh, struct fh_input_spec_s *spec);
struct fh_input_spec_s {
struct fh_input_spec_s *previous;
fh_input_refill_t refill_input_buffer;
fh_input_start_t start;
fh_input_void_method_t start;
fh_input_free_t free_self;
fh_input_pushpop_t push_prepare;
fh_input_pushpop_t pop_restore;
fh_input_void_method_t push_prepare;
fh_input_void_method_t pop_restore;
fh_input_error_method_t save_input;
fh_input_error_method_t restore_input;
uint32_t linenum;
char *cwd; // CWD of the input, used for relative includes. malloc'd (strdup)