-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidator.c
More file actions
73 lines (54 loc) · 1.26 KB
/
validator.c
File metadata and controls
73 lines (54 loc) · 1.26 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
60
61
62
63
64
65
66
67
68
69
70
71
72
/******************************************/
#include "splinter.h"
/******************************************/
// This is work in progress.
uint_t stats_memory_used = 0;
void * splinter_memory_alloc(uint_t size) {
void * ptr;
if (!size) return NULL;
if ((ptr = calloc(1, size)) != NULL) {
stats_memory_used += 1;
} else {
debug(DEBUG_ALL, "could not alloc %lu bytes", size);
}
return ptr;
}
void * splinter_memory_free(void *p) {
if (p) {
free(p);
stats_memory_used -= 1;
}
return NULL;
}
int splinter_debug_level = 99;
int splinter_test_mode = 0;
char * splinter_find_variable(char * name) {
return getenv(name);
}
uint_t splinter_find_symbol(char * name) {
if (!name) return 0;
return 0;
}
static int i = 0;
static char in[64*1024];
static char out[64*1024];
static void out_char(int c) {
out[i++] = (char)(c & 0xff);
}
int main(int argc, char ** argv) {
int err, len = read(0, in, 64*1024);
if (len < 1) return -1;
in[len] = 0;
if (strings_init(STRING_BUFF)
|| atoms_init(MAX_ATOMS)
|| symbols_init(MAX_SYMBOLS))
exit(-1);
splinter_stats_dump();
err = validate_expression("test", in, out_char);
if (err == 0) {
out[i] = 0;
fprintf(stderr, "---\n%s\n---\n", out);
return 0;
}
return -1;
}