- 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
- BLOBS: Using atoms to store arbitrary binary data
- Exchanging GMP numbers
- Calling Prolog from C
- Discarding Data
- 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
11.4.16 Environment Control from Foreign Code
- int PL_action(int, ...)
- Perform some action on the Prolog system. int describes the
action. Remaining arguments depend on the requested action. The actions
are listed below:
- PL_ACTION_TRACE
- Start Prolog tracer (trace/0). Requires no arguments.
- PL_ACTION_DEBUG
- Switch on Prolog debug mode (debug/0). Requires no arguments.
- PL_ACTION_BACKTRACE
- Print backtrace on current output stream. The argument (an
int
) is the number of frames printed. - PL_ACTION_HALT
- Halt Prolog execution. This action should be called rather than Unix
exit() to give Prolog the opportunity to clean up. This call does not
return. The argument (an
int
) is the exit code. See halt/1. - PL_ACTION_ABORT
- Generate a Prolog abort (abort/0). This call does not return. Requires no arguments.
- PL_ACTION_BREAK
- Create a standard Prolog break environment (break/0). Returns after the user types the end-of-file character. Requires no arguments.
- PL_ACTION_GUIAPP
- Windows: Used to indicate to the kernel that the application is a GUI application if the argument is not 0, and a console application if the argument is 0. If a fatal error occurs, the system uses a windows messagebox to report this on a GUI application, and otherwise simply prints the error and exits.
- PL_ACTION_TRADITIONAL
- Same effect as using --traditional. Must be called before PL_initialise().
- PL_ACTION_WRITE
- Write the argument, a
char *
to the current output stream. - PL_ACTION_FLUSH
- Flush the current output stream. Requires no arguments.
- PL_ACTION_ATTACH_CONSOLE
- Attach a console to a thread if it does not have one. See attach_console/0.
- PL_GMP_SET_ALLOC_FUNCTIONS
- Takes an integer argument. If
TRUE
, the GMP allocations are immediately bound to the Prolog functions. IfFALSE
, SWI-Prolog will never rebind the GMP allocation functions. See mp_set_memory_functions() in the GMP documentation. The action returnsFALSE
if there is no GMP support or GMP is already initialised.