From 2ac1f6bac849e8a9479a2cc3e12357a0a143ed2a Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Mon, 28 Nov 2022 10:06:31 -0700 Subject: [PATCH] Wrapped PH7_VM_CONFIG_IMPORT_PATH --- cgo.c | 4 ++++ cgo.h | 1 + ph7.go | 7 ++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cgo.c b/cgo.c index 6700e0c..cd7326e 100644 --- a/cgo.c +++ b/cgo.c @@ -23,3 +23,7 @@ int vm_config_err_report(ph7_vm *pVm) { int vm_output_length(ph7_vm *pVm, unsigned int *pLength) { return ph7_vm_config(pVm, PH7_VM_OUTPUT_LENGTH, pLength); } + +int vm_add_import_path(ph7_vm *pVm, const char *zIncludePath) { + return ph7_vm_config(pVm, PH7_VM_CONFIG_IMPORT_PATH, zIncludePath); +} \ No newline at end of file diff --git a/cgo.h b/cgo.h index f0ceffd..7794615 100644 --- a/cgo.h +++ b/cgo.h @@ -5,6 +5,7 @@ int engine_config_err_log(ph7 *pEngine, const char **pzPtr, int *pLen); int vm_extract_output(ph7_vm *pVm, const char **pzPtr, int *pLen); int vm_config_err_report(ph7_vm *pVm); int vm_output_length(ph7_vm *pVm, unsigned int *pLength); +int vm_add_import_path(ph7_vm *pVm, const char *zIncludePath); extern int write_vm_output(void*, unsigned int, void*); int vm_set_output_callback(ph7_vm *pVm, void *pUserData); diff --git a/ph7.go b/ph7.go index ca1382c..7336a39 100644 --- a/ph7.go +++ b/ph7.go @@ -493,7 +493,12 @@ func (vm *VM) SetOutputWriter(w io.Writer) error { return newError(C.vm_set_output_callback(vm.ptr, vm.pointerKey)) } -// TODO PH7_VM_CONFIG_IMPORT_PATH +func (vm *VM) AddImportPath(path string) error { + cpath := C.CString(path) + defer C.free(unsafe.Pointer(cpath)) + return newError(C.vm_add_import_path(vm.ptr, cpath)) +} + // TODO PH7_VM_CONFIG_RECURSION_DEPTH func (vm *VM) OutputLength() (uint, error) {