added error descr storing into tccomp
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <tconfig.h>
|
||||
|
||||
void tconfig_init(tconfig_t * tconfig) {
|
||||
tconfig->errstr = NULL;
|
||||
bstream_init(&(tconfig->stream));
|
||||
vmapper_init(&(tconfig->mapper));
|
||||
tclexer_init(&(tconfig->lexer), &(tconfig->stream));
|
||||
@@ -20,19 +21,27 @@ void tconfig_init(tconfig_t * tconfig) {
|
||||
|
||||
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) {
|
||||
char* tconfig_geterr(tconfig_t * tconfig) {
|
||||
return tconfig->errstr;
|
||||
}
|
||||
|
||||
return tccomp_parse(&(tconfig->comp));
|
||||
int tconfig_parse(tconfig_t * tconfig) {
|
||||
int res = 0;
|
||||
if ((res = tccomp_parse(&(tconfig->comp))) < 0) {
|
||||
if ((tconfig->errstr = tccomp_geterr(&(tconfig->comp))) == NULL) {
|
||||
tconfig->errstr = "Unknown config parsing errror";
|
||||
}
|
||||
return res;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tconfig_destroy(tconfig_t * tconfig) {
|
||||
|
||||
Reference in New Issue
Block a user