Changing Prolog's Control Flow from C

If the application has a toplevel, the function QP_action() can be called from C to alter Prolog's flow of control. This function allows the user to make Prolog abort, exit, suspend execution, turn on debugging, or prompt for the desired action. To use it, use #include <quintus/quintus.h> in your C source code. This file should be installed in a central place; if not, there should be a copy of it in the embed directory (refer to int-dir for location). quintus.h defines the following constants:

*Abort to the current break level
*Abort to top level
Stop (suspend) process
Do nothing
Exit Prolog immediately
Present action menu
Turn on trace mode
Turn on debugging

To change Prolog's control flow in a given instance, call QP_action() with one of these constants; for example,

     #include <quintus/quintus.h>
     void abort_execution(){

Some calls to QP_action() do not normally return, for example when the QP_ABORT constant is specified. However, calls to QP_action() from an interrupt handler must be viewed as requests. They are requests that will definitely be honored, but not always at the time of the call to QP_action(). Therefore calls to QP_action() should be prepared for the function to return.

It is currently not possible to call Prolog from an interrupt handler.

For systems that do not have a toplevel, the actions marked with an asterisk will have no effect other than to make QP_action() return QP_ERROR.

What does it mean to have a toplevel? If the application is calling the function QP_toplevel(), then the application has a toplevel. The development system and runtime systems both call QP_toplevel(). An exit from either of these environments is effectively a return from QP_toplevel(). An embedded application may or may not call QP_toplevel(). One of the things QP_toplevel() does is establish signal handlers. Another thing it does is establish a place for QP_action() to jump to, the actions marked with an asterik are essentially a jump to the toplevel, and will not work in systems without a toplevel. For more about QP_toplevel(), see cfu-ref-toplevel.