Implemented FormID counter.
This commit is contained in:
@@ -44,6 +44,7 @@ void print_type4(Type4 val);
|
||||
Timestamp convert_ts(uint16_t ts);
|
||||
void print_callback(Node n, void *_);
|
||||
void dc_size_cb(Node n, void *dc_size_ptr);
|
||||
void formid_count_cb(Node n, void *count_ptr);
|
||||
|
||||
//
|
||||
// === FUNCTIONS ===
|
||||
@@ -95,6 +96,7 @@ size_t espr_decompressed_size(char *data, size_t size) {
|
||||
return dc_size;
|
||||
}
|
||||
|
||||
// Adds the size of every node up, reading decompressed size from compressed records.
|
||||
void dc_size_cb(Node n, void *dc_size_ptr) {
|
||||
size_t *dcsp = dc_size_ptr;
|
||||
switch (n.type) {
|
||||
@@ -116,6 +118,23 @@ void dc_size_cb(Node n, void *dc_size_ptr) {
|
||||
}
|
||||
}
|
||||
|
||||
size_t espr_formid_count(char *data, size_t size) {
|
||||
size_t count = 0;
|
||||
espr_walk(data, size, formid_count_cb, &count);
|
||||
return count;
|
||||
}
|
||||
|
||||
/* FormID <-> Record relationship should be bijective. I do not believe
|
||||
* groups have formids, and every record should have a unique formid,
|
||||
* otherwise there would be clashes in the id space.
|
||||
*/
|
||||
void formid_count_cb(Node n, void *count_ptr) {
|
||||
size_t *c = count_ptr;
|
||||
if (n.type == NT_RECORD) {
|
||||
(*c)++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Unknown data will be some concatenation of groups and records.
|
||||
*
|
||||
* `walk_concat` will call the appropriate walking function
|
||||
|
||||
Reference in New Issue
Block a user