#include <stdio.h>
#include <malloc.h>
#include <epp/epp.h>

pl_predicate hello_predicate(pl_term a) {
    const char *str;
    
    if (pl_term2string(&str, a) == PL_TRUE) {
	printf("Hello %s !\n", str); free(str);
	return(PL_TRUE);
    }
    
    return(PL_FALSE);
}

int main(int argc, char *argv[]) {
    /* Register Predicate */
    pl_register_predicate("hello", 1, hello_predicate);

    /* Initialise Prolog */
    pl_init_from_state(*argv);
    
    printf("Type: \"hello('World').\" to begin !\n\n");

    /* Run console */
    pl_console();

    /* Shutdown Prolog */
    pl_shutdown();

    return(0);
}
