<commit_before>/*  $Id$

    Copyright (c) 1990 <NAME>. All rights reserved.
    <EMAIL>

    Purpose: Front-end for loading shared libraries
*/

:- module(shlib,
	  [ load_foreign_library/1,	% :LibFile
	    load_foreign_library/2,	% :LibFile, +InstallFunc
	    unload_foreign_library/1,	% +LibFile
	    unload_foreign_library/1,	% +LibFile, +UninstallFunc
	    current_foreign_library/2,	% ?LibFile, ?Public
	    reload_foreign_libraries/0
	  ]).

:- module_transparent
	load_foreign_library/1,
	load_foreign_library/2.

:- dynamic
	current_library/6,		% Lib x Entry x Path x
					% Module x Handle x Public
	fpublic/1.
:- volatile
	current_library/6,
	fpublic/1.


:- (   (feature(dll, true) ; feature(open_shared_object, true))
   ->  true
   ;   format(user_error,
	      'library(shlib): warning: need .dll or .so based interface',
	      [])
   ).

		 /*******************************
		 *	     DISPATCHING	*
		 *******************************/

open_goal(Lib, Handle, open_dll(Lib, Handle)) :-
	feature(dll, true), !.
open_goal(Lib, Handle, open_shared_object(Lib, Handle)) :-
	feature(open_shared_object, true).

call_goal(Handle, Function, call_dll_function(Handle, Function)) :-
	feature(dll, true), !.
call_goal(Handle, Function, call_shared_object_function(Handle, Function)) :-
	feature(open_shared_object, true), !.

close_goal(Handle, close_dll(Handle)) :-
	feature(dll, true), !.
close_goal(Handle, close_shared_object(Handle)) :-
	feature(open_shared_object, true), !.

extensions(['.so']) :-
	feature(open_shared_object, true), !.
extensions(['.dll']) :-
	feature(dll, true).

find_library(Spec, Lib) :-
	extensions(Exts),
	absolute_file_name(Spec,
			   [ extensions(Exts),
			     access(read)
			   ], Lib), !.
find_library(Spec, Spec) :-
	atom(Spec), !.			% use machines finding schema
find_library(foreign(Spec), Spec) :-
	atom(Spec), !.			% use machines finding schema
find_library(Spec, _) :-
	'$warning'('load_foreign_library/1: Cannot find ~w: no such file',
		   [Spec]),
	fail.

<commit_msg>* Fixed for new behaviour of absolute_file_name/3<commit_after>/*  $Id$

    Copyright (c) 1990 <NAME>. All rights reserved.
    <EMAIL>

    Purpose: Front-end for loading shared libraries
*/

:- module(shlib,
	  [ load_foreign_library/1,	% :LibFile
	    load_foreign_library/2,	% :LibFile, +InstallFunc
	    unload_foreign_library/1,	% +LibFile
	    unload_foreign_library/1,	% +LibFile, +UninstallFunc
	    current_foreign_library/2,	% ?LibFile, ?Public
	    reload_foreign_libraries/0
	  ]).

:- module_transparent
	load_foreign_library/1,
	load_foreign_library/2.

:- dynamic
	current_library/6,		% Lib x Entry x Path x
					% Module x Handle x Public
	fpublic/1.
:- volatile
	current_library/6,
	fpublic/1.


:- (   (feature(dll, true) ; feature(open_shared_object, true))
   ->  true
   ;   format(user_error,
	      'library(shlib): warning: need .dll or .so based interface',
	      [])
   ).

		 /*******************************
		 *	     DISPATCHING	*
		 *******************************/

open_goal(Lib, Handle, open_dll(Lib, Handle)) :-
	feature(dll, true), !.
open_goal(Lib, Handle, open_shared_object(Lib, Handle)) :-
	feature(open_shared_object, true).

call_goal(Handle, Function, call_dll_function(Handle, Function)) :-
	feature(dll, true), !.
call_goal(Handle, Function, call_shared_object_function(Handle, Function)) :-
	feature(open_shared_object, true), !.

close_goal(Handle, close_dll(Handle)) :-
	feature(dll, true), !.
close_goal(Handle, close_shared_object(Handle)) :-
	feature(open_shared_object, true), !.

find_library(Spec, Lib) :-
	absolute_file_name(Spec,
			   [ file_type(executable),
			     access(read),
			     file_errors(fail)
			   ], Lib), !.
find_library(Spec, Spec) :-
	atom(Spec), !.			% use machines finding schema
find_library(foreign(Spec), Spec) :-
	atom(Spec), !.			% use machines finding schema
find_library(Spec, _) :-
	throw(error(existence_error(source_sink, Spec), _)).


{'fraction_non_alphanumeric': 0.1690319310694374, 'fraction_numerical': 0.008616320324379118, 'mean_word_length': 4.034438775510204, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2921823', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1338, 'n_words': 264}