#ifndef	_EPP_PAL_H
#define	_EPP_PAL_H

/*
 * Parameters specyfication:
 *
 * UPPERCASE CHARACTER:	Transfer data from Prolog to C.
 * lowercase character:	Transfer data from C to Prolog.
 *
 * l / L:		long		/	long*
 * s / S:		const char*	/	const char**
 * f / F:		double		/	double*
 * p / P:		void*		/	void**
 *   _			<NONE>		/ 	<NONE>
 *
 */

#include <stdarg.h>
#include <epp/epp_config.h>
#include <epp/epp_pal_swi.h>

#define	PL_TRUE		1
#define	PL_FALSE	0
#define	PL_ERROR_PROLOG	-1
#define	PL_ERROR_PAL	-2

extern	int	pl_init_from_state(const char *statefile);
extern	int	pl_shutdown(void);
extern	int	pl_register_predicate(const char *name, unsigned int arity, pl_predicate (*function)());
extern	int	pl_console(void);

extern	int	pl_attach_engine(void);		/* Attach Prolog engine to the calling thread. */
extern	int	pl_detach_engine(void);		/* Dettach Prolog engine from the calling thread. */
extern	int	pl_is_engine_attached(void);	/* Returns PL_TRUE if current thread has Prolog engine */
extern	int	pl_is_engine_idle(void);	/* Returns PL_TRUE if current thread has Prolog engine and it is idle */

extern	int 	pl_call(const char *predicate, const char *params_spec, ...);
extern	int 	pl_vcall(const char *predicate, const char *params_spec, va_list args);
extern	int	pl_open_query(pl_query *query, const char *predicate, const char *params_spec, ...);
extern	int	pl_vopen_query(pl_query *query, const char *predicate, const char *params_spec, va_list args);
extern	int	pl_next_solution(pl_query *query);
extern	void	pl_close_query(pl_query *query);

extern	int	pl_term2long(long *i, pl_term t);
extern	int	pl_term2string(const char **s, pl_term t);
extern	int	pl_term2float(double *d, pl_term t);
extern	int	pl_term2pointer(void **p, pl_term t);

extern	int	pl_long2term(pl_term t, long i);
extern	int	pl_string2term(pl_term t, const char *s);
extern	int	pl_float2term(pl_term t, double d);
extern	int	pl_pointer2term(pl_term t, void *p);

extern	int	pl_longUterm(pl_term t, long i);
extern	int	pl_stringUterm(pl_term t, const char *s);
extern	int	pl_floatUterm(pl_term t, double d);
extern	int	pl_pointerUterm(pl_term t, void *p);

#endif
