diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/vy_adapter.cpp | 48 | ||||
-rw-r--r-- | src/vy_adapter.h | 2 |
2 files changed, 50 insertions, 0 deletions
diff --git a/src/vy_adapter.cpp b/src/vy_adapter.cpp index dd66dfb..49e186d 100644 --- a/src/vy_adapter.cpp +++ b/src/vy_adapter.cpp @@ -136,6 +136,30 @@ vy_in_session(uint64_t handle) } const char * +vy_validate_path(uint64_t handle, const void** path_ptr, size_t len) +{ + Cstore *cstore = cstore_of_handle(handle); + const char **path = (const char **) path_ptr; + Cpath path_comps = Cpath(path, len); + const char *out_data; + std::string out_str = ""; + int res; + + out_stream = stdout; + stdout_redirect redirect = stdout_redirect(); + + res = cstore->validateSetPath(path_comps); + if (!res) { + out_str = "\nInvalid set path: " + path_comps.to_string() + "\n"; + out_str.append(redirect.get_redirected_output()); + } + + out_data = out_data_copy(out_str); + out_stream = NULL; + return out_data; +} + +const char * vy_set_path(uint64_t handle, const void** path_ptr, size_t len) { Cstore *cstore = cstore_of_handle(handle); @@ -148,6 +172,30 @@ vy_set_path(uint64_t handle, const void** path_ptr, size_t len) out_stream = stdout; stdout_redirect redirect = stdout_redirect(); + res = cstore->setCfgPath(path_comps); + if (!res) { + out_str = "\nSet config path failed: " + path_comps.to_string() + "\n"; + out_str.append(redirect.get_redirected_output()); + } + + out_data = out_data_copy(out_str); + out_stream = NULL; + return out_data; +} + +const char * +vy_legacy_set_path(uint64_t handle, const void** path_ptr, size_t len) +{ + Cstore *cstore = cstore_of_handle(handle); + const char **path = (const char **) path_ptr; + Cpath path_comps = Cpath(path, len); + const char *out_data; + std::string out_str = ""; + int res; + + out_stream = stdout; + stdout_redirect redirect = stdout_redirect(); + res = cstore->validateSetPath(path_comps); if (!res) { out_str = "\nInvalid set path: " + path_comps.to_string() + "\n"; diff --git a/src/vy_adapter.h b/src/vy_adapter.h index fba6368..636c303 100644 --- a/src/vy_adapter.h +++ b/src/vy_adapter.h @@ -22,7 +22,9 @@ extern "C" { uint64_t vy_cstore_init(void); void vy_cstore_free(uint64_t); int vy_in_session(uint64_t); +const char *vy_validate_path(uint64_t, const void **, size_t); const char *vy_set_path(uint64_t, const void **, size_t); +const char *vy_legacy_set_path(uint64_t, const void **, size_t); const char *vy_delete_path(uint64_t, const void **, size_t); #ifdef __cplusplus |