- Documentation
- Reference manual
- Foreign Language Interface
- The Foreign Include File
- Argument Passing and Control
- Atoms and functors
- Analysing Terms via the Foreign Interface
- Constructing Terms
- Unifying data
- Convenient functions to generate Prolog exceptions
- Serializing and deserializing Prolog terms
- BLOBS: Using atoms to store arbitrary binary data
- Exchanging GMP numbers
- Calling Prolog from C
- Discarding Data
- String buffering
- Foreign Code and Modules
- Prolog exceptions in foreign code
- Catching Signals (Software Interrupts)
- Miscellaneous
- Errors and warnings
- Environment Control from Foreign Code
- Querying Prolog
- Registering Foreign Predicates
- Foreign Code Hooks
- Storing foreign data
- Embedding SWI-Prolog in other applications
- The Foreign Include File
- Foreign Language Interface
- Packages
- Reference manual
rch, naming conventions, etc., from foreign code.
- int PL_get_file_name(term_t spec, char **name, int flags)
- Translate a Prolog term into a file name. The name is stored in the
buffer stack described with the PL_get_chars()
option
BUF_STACK
. Conversion from the internal UNICODE encoding is done using standard C library functions. flags is a bit-mask controlling the conversion process. Options are:PL_FILE_ABSOLUTE
- Return an absolute path to the requested file.
PL_FILE_OSPATH
- Return the name using the hosting OS conventions. On MS-Windows,
is used to separate directories rather than the canonical\
./
PL_FILE_SEARCH
- Invoke absolute_file_name/3. This implies rules from file_search_path/2 are used.
PL_FILE_EXIST
- Demand the path to refer to an existing entity.
PL_FILE_READ
- Demand read-access on the result.
PL_FILE_WRITE
- Demand write-access on the result.
PL_FILE_EXECUTE
- Demand execute-access on the result.
PL_FILE_NOERRORS
- Do not raise any exceptions.
- int PL_get_file_nameW(term_t spec, wchar_t **name, int flags)
- Same as PL_get_file_name(),
but returns the filename as a wide-character string. This is intended
for Windows to access the Unicode version of the Win32 API. Note that
the flag
PL_FILE_OSPATH
must be provided to fetch a filename in OS native (e.g.,C:\x\y
) notation.
12.4.17.5 Dealing with Prolog flags from C
Foreign code can set or create Prolog flags using PL_set_prolog_flag(). See set_prolog_flag/2 and create_prolog_flag/3. To retrieve the value of a flag you can use PL_current_prolog_flag().
- int PL_set_prolog_flag(const char *name, int type, ...)
- Set/create a Prolog flag from C. name is the name of the
affected flag. type is one of the values below, which also
dictates the type of the final argument. The function returns
TRUE
on success andFALSE
on failure. This function can be called before PL_initialise(), making the flag available to the Prolog startup code.PL_BOOL
- Create a boolean (
true
orfalse
) flag. The argument must be anint
. PL_ATOM
- Create a flag with an atom as value. The argument must be of type
const char *
. PL_INTEGER
- Create a flag with an integer as value. The argument must be of type
intptr_t *
.
- int PL_current_prolog_flag(atom_t name, int type, void *value)
- Retrieve the value of a Prolog flag from C. name is the name
of the flag as an
atom_t
(see current_prolog_flag/2). type specifies the kind of value to be retrieved, it is one of the values below. value is a pointer to a location where to store the value. The user is responsible for making sure this memory location is of the appropriate size/type (see the returned types below to determine the size/type). The function returnsTRUE
on success andFALSE
on failure.PL_ATOM
- Retrieve a flag whose value is an
atom
. The returned value is an atom handle of typeatom_t
. PL_INTEGER
- Retrieve a flag whose value is an
integer
. The returned value is an integer of typeint64_t
. PL_FLOAT
- Retrieve a flag whose value is a
float
. The returned value is a floating point number of typedouble
. PL_TERM
- Retrieve a flag whose value is a
term
. The returned value is a term handle of typeterm_t
.
12.4.18 Errors and warnings
PL_warning()
prints a standard Prolog warning message to the standard error (user_error
)
stream. Please note that new code should consider using