12 void wjson(
SemTable *sem,
T *t,
char *n,
int i) {
14 char json[100000] = {0};
17 sprintf(fn,
"web/%s_%d.json",n,i);
19 sprintf(fn,
"web/%s.json",n);
20 writeFile(fn,json,strlen(json));
23 void dump2json(
SemTable *sem,
T *t,
char *n) {
25 char json[1000000] = {0};
27 sprintf(fn,
"web/%s.json",n);
28 writeFile(fn,json,strlen(json));
32 T *makeDelta(
Symbol sym,
int *path,
T *t,
int count) {
34 _t_new(d,TREE_DELTA_PATH,path,
sizeof(
int)*(
_t_path_depth(path)+1));
37 _t_newi(d,TREE_DELTA_COUNT,count);
41 char *G_visdump_fn = 0;
42 int G_visdump_count = 0;
44 void _visdump(
SemTable *sem,
T *x,
int *path) {
45 T *delta = makeDelta(TREE_DELTA_REPLACE,path,x,1);
46 wjson(sem,delta,G_visdump_fn,G_visdump_count++);
51 if (G_visdump_count) {
58 #include "../src/process.h"
59 #include "../src/receptor.h"
61 void _test_reduce_signals(
Receptor *r) {
67 T *signals = r->pending_signals;
71 if (err) raise_error(
"delivery error: %d",err);
76 char *doSys(
char *cmd) {
77 FILE *pipe = popen(cmd,
"r");
78 if (!pipe) raise_error(
"Error running %s\n",cmd);
81 char *buffer = malloc(sz);
83 while (fgets(buf, 255, pipe) != NULL) {
86 int increase_by = l < sz ? sz : l*2;
87 remaining += increase_by;
89 buffer = realloc(buffer,sz);
91 memcpy(&buffer[sz-remaining],buf,l);
94 buffer[sz-remaining] = 0;
T * _t_new_root(Symbol symbol)
T * _t_detach_by_idx(T *t, int i)
int _t_path_depth(int *p)
int contexts_count
number of active processes
char * _t2rawjson(SemTable *sem, T *t, int level, char *buf)
char * _t2json(SemTable *sem, T *t, int level, char *buf)
Error _r_deliver(Receptor *r, T *signal)