adds working FST reader implementation
This commit is contained in:
@ -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
|
||||
|
@ -0,0 +1,2 @@
|
||||
cmake -B build -S . -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=../../linux-x86-64
|
||||
cmake --build build --target install
|
@ -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);
|
||||
}
|
Reference in New Issue
Block a user