This commit is contained in:
Олег Бородин
2025-10-01 11:21:05 +02:00
commit 9abd8a5e19
50 changed files with 12685 additions and 0 deletions

41
libxtools/tconfig.c Normal file
View File

@@ -0,0 +1,41 @@
/*
* Copyright 2023 Oleg Borodin <borodin@unix7.org>
*/
#include <stdio.h>
#include <tclexer.h>
#include <tccomp.h>
#include <bstream.h>
#include <vmapper.h>
#include <tconfig.h>
void tconfig_init(tconfig_t* tconfig) {
bstream_init(&(tconfig->stream));
vmapper_init(&(tconfig->mapper));
tclexer_init(&(tconfig->lexer), &(tconfig->stream));
tccomp_init(&(tconfig->comp), &(tconfig->lexer), &(tconfig->mapper));
}
int tconfig_bind(tconfig_t* tconfig, int type, char* name, void* ptr) {
vmapper_t* vmapper = &(tconfig->mapper);
return vmapper_bind(vmapper, type, name, ptr);
}
ssize_t tconfig_read(tconfig_t* tconfig, char* filename) {
bstream_t* stream = &(tconfig->stream);
return bstream_fread(stream, filename);
}
int tconfig_parse(tconfig_t* tconfig) {
return tccomp_parse(&(tconfig->comp));
}
void tconfig_destroy(tconfig_t* tconfig) {
tccomp_destroy(&(tconfig->comp));
tclexer_destroy(&(tconfig->lexer));
bstream_destroy(&(tconfig->stream));
vmapper_destroy(&(tconfig->mapper));
}