int main(int argc, char **argv) { #if O_CTRLC main_thread_id = GetCurrentThreadId(); SetConsoleCtrlHandler((PHANDLER_ROUTINE)consoleHandlerRoutine, TRUE); #endif #if O_ANSI_COLORS PL_w32_wrap_ansi_console(); /* decode ANSI color sequences (ESC[...m) */ #endif #ifdef READLINE PL_initialise_hook(install_readline); #endif if ( !PL_initialise(argc, argv) ) PL_halt(1); for(;;) { int status = PL_toplevel() ? 0 : 1; PL_halt(status); } return 0; }
int prolog_debug_from_string(const char *spec, int flag) { const char *end; while((end=strchr(spec, ','))) { if ( end-spec < MAX_TOPIC_LEN ) { char buf[MAX_TOPIC_LEN]; strncpy(buf, spec, end-spec); buf[end-spec] = EOS; if ( !prolog_debug_topic(buf, flag) ) { Sdprintf("ERROR: Unknown debug topic: %s\n", buf); PL_halt(1); } spec = end+1; } else { Sdprintf("ERROR: Invalid debug topic: %s\n", spec); } } if ( !prolog_debug_topic(spec, flag) ) { Sdprintf("ERROR: Unknown debug topic: %s\n", spec); PL_halt(1); } return TRUE; }
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { char * argv[100]; int argc; program = program_name(hInstance); argc = breakargs(program, lpszCmdLine, argv); bind_terminal(); PL_set_prolog_flag("verbose", PL_ATOM, "silent"); /* operate silently */ DEBUG(ok("About to start Prolog with %d arguments", argc)); if ( !PL_initialise(argc, argv) ) { ok("Initialisation failed"); PL_halt(1); } if ( PL_toplevel() ) { PL_halt(0); } else { ok("Toplevel failed"); PL_halt(1); } return 0; }
void SWIPLContainer::__init(int argc, char **argv) { if ( !PL_initialise(argc, argv) ) { qDebug() << "Unable to initialize Prolog engine!"; PL_halt(1); // will terminate the process! return; // we never get here, but still } qDebug() << "Prolog successfully initialized!"; }
int main(int argc, char **argv) { char expression[MAXLINE]; char *e = expression; char *program = argv[0]; char *plav[2]; int n; /* combine all the arguments in a single string */ for(n=1; n<argc; n++) { if ( n != 1 ) *e++ = ' '; strcpy(e, argv[n]); e += strlen(e); } /* make the argument vector for Prolog */ plav[0] = program; plav[1] = NULL; /* initialise Prolog */ if ( !PL_initialise(1, plav) ) PL_halt(1); /* Lookup calc/1 and make the arguments and call */ { predicate_t pred = PL_predicate("calc", 1, "user"); term_t h0 = PL_new_term_refs(1); int rval; PL_put_atom_chars(h0, expression); rval = PL_call_predicate(NULL, PL_Q_NORMAL, pred, h0); PL_halt(rval ? 0 : 1); } return 0; }
int main(int argc, char **argv) { char *program = argv[0]; char *plav[2]; char problem[MAXLINE]; char *p = problem; /* make the argument vector for Prolog */ plav[0] = program; plav[1] = NULL; /* initialize Prolog */ if ( !PL_initialise(1, plav) ) PL_halt(1); /* initialize the input planning problem */ strcpy(p, argv[1]); printf("%s\n", p); /* Lookup solve/1 and make the arguments and call */ predicate_t pred = PL_predicate("solve", 1, "user"); term_t h0 = PL_new_term_refs(1); int rval; PL_put_atom_chars(h0, problem); rval = PL_call_predicate(NULL, PL_Q_NORMAL, pred, h0); PL_halt(rval ? 0 : 1); return 0; }
// ###################################################################### SWIProlog::SWIProlog(int argc, char **argv) { const char *av[10]; int ac = 0; // av[ac++] = argv[0]; av[ac++] = "DefaultProg"; av[ac++] = "-q"; av[ac++] = "-nosignals"; av[ac] = NULL; #ifdef HAVE_SWI_PROLOG_H if (!PL_initialise(ac, av)) { PL_halt(1); LFATAL("Failed to init prolog"); } #else LINFO("SWI prolog not found"); #endif }
static char *prolog_iniciar(modulo_t *modulo, GHashTable *argumentos) { prolog_dato_t *prolog = (prolog_dato_t*)modulo->m_dato; char *av[10]; int ac = 0; av[ac++] = "prolog"; av[ac++] = "-g"; av[ac++] = "true"; av[ac++] = "-f"; av[ac++] = "none"; if(!PL_initialise(ac, av)) { PL_halt(-1); } prolog->m_fid = PL_open_foreign_frame(); g_hash_table_insert(modulo->m_tabla, PUERTO_SALIDA, 0); g_hash_table_insert(modulo->m_tabla, PUERTO_ORDEN, 0); g_hash_table_insert(modulo->m_tabla, PUERTO_PARAMETRO, 0); return "iniciado"; }
void close_store() { if (alive) { PL_halt(PL_toplevel() ? 0 : 1); } }