diff options
author | John Estabrook <jestabro@vyos.io> | 2022-02-08 21:10:19 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2022-04-20 18:09:22 -0500 |
commit | 6fcc55b8b51bdcfaf2e75b254a4a7c9b6b4cb04d (patch) | |
tree | ca5136732ae6da63a4a1929de3389c6356dcb86c /lib/bindings.ml | |
parent | 088e68e98034302a22b10b7f7c51ce9dcf05323c (diff) | |
download | libvyosconfig-6fcc55b8b51bdcfaf2e75b254a4a7c9b6b4cb04d.tar.gz libvyosconfig-6fcc55b8b51bdcfaf2e75b254a4a7c9b6b4cb04d.zip |
configtree: T4235: binding for config tree diff function
(cherry picked from commit 297612c64230008228f77806e575c3831e15476e)
Diffstat (limited to 'lib/bindings.ml')
-rw-r--r-- | lib/bindings.ml | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/bindings.ml b/lib/bindings.ml index 9324282..40ef120 100644 --- a/lib/bindings.ml +++ b/lib/bindings.ml @@ -4,6 +4,7 @@ open Foreign open Vyos1x module CT = Config_tree +module CD = Config_diff let error_message = ref "" @@ -154,6 +155,20 @@ let copy_node c_ptr old_path new_path = 0 with Vytree.Nonexistent_path -> 1 +let diffs path c_ptr_l c_ptr_r = + let path = split_on_whitespace path in + let ct_l = Root.get c_ptr_l in + let ct_r = Root.get c_ptr_r in + try + let ct_add, ct_del, ct_inter = CD.diffs path ct_l ct_r in + let ptr_add = Ctypes.Root.create ct_add in + let ptr_del = Ctypes.Root.create ct_del in + let ptr_inter = Ctypes.Root.create ct_inter in + let ptr_arr = Ctypes.CArray.make (ptr void) ~initial:ptr_add 3 in Ctypes.CArray.set ptr_arr 1 ptr_del; Ctypes.CArray.set ptr_arr 2 ptr_inter; Ctypes.CArray.start ptr_arr + + with + | CD.Incommensurable -> error_message := "Incommensurable"; Ctypes.CArray.start (Ctypes.CArray.make (ptr void) 3) + | CD.Empty_comparison -> error_message := "Empty comparison"; Ctypes.CArray.start (Ctypes.CArray.make (ptr void) 3) module Stubs(I : Cstubs_inverted.INTERNAL) = struct @@ -179,4 +194,5 @@ struct let () = I.internal "list_nodes" ((ptr void) @-> string @-> returning string) list_nodes let () = I.internal "return_value" ((ptr void) @-> string @-> returning string) return_value let () = I.internal "return_values" ((ptr void) @-> string @-> returning string) return_values + let () = I.internal "diffs" (string @-> (ptr void) @-> (ptr void) @-> returning (ptr (ptr void))) diffs end |