let load_dynlinks () =
let rec check_list f cur =
match cur with
| x :: l ->
if f x then
check_list f l
else false
| [] -> true
in
let load_library name dynload =
try
List.iter (fun path ->
try
let get_file =
(fun f -> Printf.sprintf "%s/%s%s" path f dynlink_suffix)
in
if check_list
(fun file -> Sys.file_exists (get_file file))
dynload.files then
begin
List.iter (fun file ->
Dynlink.loadfile (get_file file))
dynload.files;
raise (Done path)
end
with
| Dynlink.Error e ->
dyn_log#f 3 "Error while loading dynamic %s at %s" name path;
dyn_log#f 4 "%s" (Dynlink.error_message e)) dynload.path;
dyn_log#f 3 "Could not find dynamic module for %s." name
with
| Done path ->
dyn_log#f 3 "Loaded dynamic %s from %s" name path;
dynload.load ()
in
Hashtbl.iter load_library dynlink_list