changed author email
[guish.git] / src / sourcedriver.h
blobf72846a9e05b1c3f7b20c11966977dff37e0daca
1 /*************************************************************************
2 * Copyright (C) 2024 Francesco Palumbo <phranz.dev@gmail.com>, Naples (Italy)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *************************************************************************/
18 #ifndef SOURCEDRIVER_H
19 #define SOURCEDRIVER_H
21 typedef struct vec_sourcedata_t vec_sourcedata_t;
23 enum sources {
24 S_NOSRC,
25 S_SOURCE,
26 S_CMDLINE,
27 S_TTY,
28 S_STDIN,
29 S_ALL,
32 typedef struct head_t {
33 size_t pos;
34 int c;
35 int o;
36 } head_t;
38 typedef struct sourcedata_t {
39 int s;
40 char* d;
41 char* n;
42 FILE* i;
43 head_t h;
44 struct sourcedata_t* p;
45 unsigned long long lineno;
46 int nb;
48 void (*free)(struct sourcedata_t*);
49 } sourcedata_t;
51 sourcedata_t* sourcedata_t_init(sourcedata_t*);
52 void sourcedata_t_free(sourcedata_t*);
54 void sourcedriver_init();
55 void sourcedriver_free();
56 void sinfo(const char*, unsigned long long);
57 int new_source(int, void*);
58 sourcedata_t* evalsrc(char*, unsigned long, char*);
59 void push(int);
60 head_t* pull();
61 int source_exahusted();
62 void next_source();
64 #define valid_source() (current && current->s != S_NOSRC)
66 #endif