summaryrefslogtreecommitdiff
path: root/src/adapter/vy_delete.ml
blob: 304e74b9be6ba44ca33a156d509c460807cc6309 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
let () =
    let path_list = Array.to_list (Array.sub Sys.argv 1 (Array.length Sys.argv - 1))
    in
    let () =
        if List.length path_list = 0 then
            (Printf.printf "no path specified\n"; exit 1)
    in
    let handle =
        let h = Vyos1x_adapter.cstore_handle_init () in
        if not (Vyos1x_adapter.cstore_in_config_session_handle h) then
            (Vyos1x_adapter.cstore_handle_free h;
            Printf.printf "not in config session\n"; exit 1)
        else Some h
    in
    let output =
        match handle with
        | Some h -> Vyos1x_adapter.cstore_delete_path h path_list
        | None -> "missing session handle"
    in
    let ret =
        if output = "" then 0
        else 1
    in
    let () =
        match handle with
        | Some h -> Vyos1x_adapter.cstore_handle_free h
        | None -> ()
    in
    let () = print_endline output in
    exit ret