diff options
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | lib/bindings.ml | 9 |
2 files changed, 15 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index ae5d6bc..cdfb586 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libvyosconfig0 (0.0.2) unstable; urgency=medium + + * Add support for node renaming. + + -- Daniil Baturin <daniil@baturin.org> Sun, 02 Sep 2018 13:04:28 +0200 + libvyosconfig0 (0.0.1) unstable; urgency=low * Created the package diff --git a/lib/bindings.ml b/lib/bindings.ml index 4b8d04b..e2a0e71 100644 --- a/lib/bindings.ml +++ b/lib/bindings.ml @@ -64,6 +64,14 @@ let delete_node c_ptr path = Root.set c_ptr new_ct; 0 (* return 0 *) +let rename_node c_ptr path newname = + let ct = Root.get c_ptr in + let path = Pcre.split ~rex:(Pcre.regexp "\\s+") path in + if not (Vytree.exists ct path) then 1 else + let new_ct = Vytree.rename ct path newname in + Root.set c_ptr new_ct; + 0 (* return 0 *) + let set_tag c_ptr path = let ct = Root.get c_ptr in let path = Pcre.split ~rex:(Pcre.regexp "\\s+") path in @@ -124,6 +132,7 @@ struct let () = I.internal "set_valueless" ((ptr void) @-> string @-> returning int) set_valueless let () = I.internal "delete_value" ((ptr void) @-> string @-> string @-> returning int) delete_value let () = I.internal "delete_node" ((ptr void) @-> string @-> returning int) delete_node + let () = I.internal "rename_node" ((ptr void) @-> string @-> string @-> returning int) rename_node let () = I.internal "set_tag" ((ptr void) @-> string @-> returning int) set_tag let () = I.internal "is_tag" ((ptr void) @-> string @-> returning int) is_tag let () = I.internal "exists" ((ptr void) @-> string @-> returning int) exists |