Following is a summary of the steps that enable you to call a Prolog predicate from a C function:
extern/1
to declare the
predicate callable from foreign functions, establishing an argument
passing interface (see fli-ffp-ppc).
QP_predicate()
or QP_pred()
. This
provides C with a "handle" on the Prolog predicate that is used to
make the actual call. (see fli-ffp-ccp-lcp).
QP_query()
. If QP_query()
returns successfully, output results will
have been left in C variables according to the specified interface.
QP_open_query()
. This function initiates a query, returning a
query identifier, which is passed to QP_next_solution()
, which is
called once for each solution requested. When a solution is returned,
output results are left in C variables according to the specified
interface. When sufficient solutions have been returned, or there are
no more solutions, the query identifier is passed to either
QP_cut_query()
or QP_close_query()
to terminate the query.