adds working FST reader implementation

This commit is contained in:
2023-02-27 13:09:38 +01:00
parent 299f76323f
commit e44e4d0a05
12 changed files with 321 additions and 197 deletions

View File

@ -5,7 +5,7 @@ project (fstlib VERSION 1.0.0)
set(BUILD_SHARED_LIBS ON)
find_package(ZLIB REQUIRED)
add_library(fstapi fstapi.c lz4.c fastlz.c)
add_library(fstapi fstapi.c lz4.c fastlz.c fst_helper.c)
target_include_directories(fstapi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIRS})
target_link_libraries(fstapi PRIVATE ${ZLIB_LIBRARIES})
# hack to avoid creating dummy config.h

View File

@ -0,0 +1,2 @@
cmake -B build -S . -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=../../linux-x86-64
cmake --build build --target install

View File

@ -0,0 +1,31 @@
#include "fstapi.h"
int getHierType(struct fstHier * hier){
return hier->htyp;
}
void getHierScope(struct fstHier* h, struct fstHierScope* scope){
if(h->htyp==FST_HT_SCOPE)
*scope=h->u.scope;
}
void getHierVar(struct fstHier* h, struct fstHierVar* var){
if(h->htyp==FST_HT_VAR)
*var=h->u.var;
}
void getHierAttr(struct fstHier* h, struct fstHierAttr* attr){
if(h->htyp==FST_HT_ATTRBEGIN)
*attr=h->u.attr;
}
typedef void (*value_change_callback)(uint64_t time, fstHandle facidx, const char *value);
static void forward_cb(void *user_callback_data_pointer, uint64_t time, fstHandle facidx, const unsigned char *value) {
//fprintf(stderr, "val: %s @ %ld\n", value, time);
((value_change_callback)user_callback_data_pointer)(time, facidx, value);
}
void iterateValueChanges(void* ctx, value_change_callback vcc) {
fstReaderIterBlocks(ctx, forward_cb, vcc, NULL);
}