32Yap_FindExecutable(
void)
34 enum { BUFFERSIZE = 1024 };
35 char *buf = malloc(BUFFERSIZE);
37 if (!GetModuleFileName(NULL, buf, BUFFERSIZE-1))
44Yap_LoadForeignFile(
char *file,
int flags)
46 char *buf = malloc(1024);
47 void *ptr= (
void *)LoadLibrary(file);
49 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
51 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 1023,
58Yap_CallForeignFile(
void *handle,
char *f)
60 YapInitProc proc = (YapInitProc)GetProcAddress((HMODULE)handle, f);
68Yap_CloseForeignFile(
void *handle)
70 return FreeLibrary((HMODULE)handle);
79 const char *proc_name, YapInitProc *init_proc)
85 if (*init_proc == NULL &&
86 (*init_proc = (YapInitProc)GetProcAddress((HMODULE)handle, proc_name)))
88 YapInitProc f = *init_proc;
93 const char *file = AtomName(ofiles->name);
95 (handle=LoadLibrary(file)) != 0)
97 LOCAL_ErrorMessage = NULL;
98 if (*init_proc == NULL)
99 *init_proc = (YapInitProc)GetProcAddress((HMODULE)handle, proc_name);
101 char *buf = malloc(1024);
102 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
103 NULL, GetLastError(),
104 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 1023,
108 ofiles = ofiles->next;
114 const char * s = AtomName(libs->name);
117 strcat(LOCAL_FileNameBuf,s+2);
118 strcat(LOCAL_FileNameBuf,
".dll");
120 strcpy(LOCAL_FileNameBuf,s);
123 if((handle=LoadLibrary(LOCAL_FileNameBuf)) == 0)
129 if (*init_proc == NULL)
130 *init_proc = (YapInitProc)GetProcAddress((HMODULE)handle, proc_name);
135 if(*init_proc == NULL) {
136 LOCAL_ErrorMessage =
"Could not locate initialization routine";
140 return LOAD_SUCCEEDED;
145 char *proc_name, YapInitProc *init_proc)
147 return LoadForeign(ofiles, libs, proc_name, init_proc);
151Yap_ShutdownLoadForeign(
void)
157 char *proc_name, YapInitProc *init_proc)
159 return(LoadForeign(ofiles,libs, proc_name, init_proc));
load_foreign_files/3 has works for the following configurations:
const char * Yap_AbsoluteFile(const char *spec, bool ok)
generate absolute path, if ok first expand SICStus Prolog style