ESP Tree view.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <string.h>
|
||||
#include <intrin.h>
|
||||
#include <ammintrin.h>
|
||||
#include <crtdbg.h>
|
||||
|
||||
#include <io.h>
|
||||
|
||||
@@ -468,8 +469,10 @@ void litcopy(struct str_buf *sb, struct str_lit lit)
|
||||
|
||||
void num_str(struct str_buf *sb, unsigned long num, int radix)
|
||||
{
|
||||
_CrtSetDebugFillThreshold(0);
|
||||
errno_t ret = _ultoa_s(num, sb->buf, sb->size, radix);
|
||||
assert(ret == 0);
|
||||
_CrtSetDebugFillThreshold(SIZE_MAX);
|
||||
int len = (int)strlen(sb->buf);
|
||||
sb->size -= len;
|
||||
sb->buf += len;
|
||||
@@ -629,6 +632,8 @@ Timestamp convert_ts(uint16_t ts)
|
||||
|
||||
MetaTree espr_create_tree(SizedBuf in, SizedBuf tree)
|
||||
{
|
||||
MetaTree mtree = { .esp = in, .tree = tree };
|
||||
|
||||
// create root node
|
||||
MetaNode *root = NULL;
|
||||
{
|
||||
@@ -641,7 +646,10 @@ MetaTree espr_create_tree(SizedBuf in, SizedBuf tree)
|
||||
struct walker_callbacks cb = { .pre = create_tree_cb, .data = &tree };
|
||||
espr_walk(in, cb, root);
|
||||
|
||||
return (MetaTree) { .root = root, .size = in.size };
|
||||
mtree.root = root;
|
||||
mtree.size = in.size;
|
||||
|
||||
return mtree;
|
||||
}
|
||||
|
||||
void create_tree_cb(
|
||||
@@ -667,7 +675,6 @@ void create_tree_cb(
|
||||
// construct new node
|
||||
*m = (MetaNode){ 0 }; // zero/null unused
|
||||
m->n = n;
|
||||
m->parent = p;
|
||||
m->prev = p->last_child;
|
||||
// the linked list of children may not already exist
|
||||
if (p->last_child)
|
||||
@@ -730,3 +737,33 @@ void serialize_cb(MetaNode *m, void *data) {
|
||||
}
|
||||
}
|
||||
|
||||
void espr_meta_string(MetaNode *m, SizedBuf str_buf)
|
||||
{
|
||||
// root node
|
||||
if (!m->n.data) {
|
||||
snprintf(str_buf.data, str_buf.size, "Root");
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[1024] = { 0 };
|
||||
struct str_buf sb = { .buf = buf, .size = 1024 };
|
||||
|
||||
switch (m->n.type) {
|
||||
case NT_GROUP:
|
||||
{
|
||||
group_label_str(&sb, m->n.header.group);
|
||||
const char *lbl = group_type_strings[m->n.header.group->type].lit;
|
||||
snprintf(str_buf.data, str_buf.size, "GRUP; %s; %s", lbl, buf);
|
||||
break;
|
||||
}
|
||||
case NT_RECORD:
|
||||
{
|
||||
type_str(&sb, m->n.header.record->type);
|
||||
snprintf(str_buf.data, str_buf.size, "%s; FormID[%08x]", buf, m->n.header.record->formid);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user