19char * Yap_FindExecutable(
void)
25Yap_LoadForeignFile(
char *file,
int flags)
32Yap_CallForeignFile(
void *handle,
char *f)
38Yap_CloseForeignFile(
void *handle)
51 char *proc_name, YapInitProc *init_proc )
55 int init_missing = -1;
64 const char *file = AtomName(ofiles->name);
65 valid_fname = Yap_findFile(file, NULL, NULL, LOCAL_FileNameBuf,
true, YAP_OBJ,
true,
true);
68 strcpy( LOCAL_ErrorSay,
"%% Trying to open non-existing file in LoadForeign" );
72 ofiles->handle = Yap_AllocCodeSpace(
sizeof(shl_t) );
73 *(shl_t *)ofiles->handle = shl_load( LOCAL_FileNameBuf, BIND_DEFERRED, 0 );
74 if( *(shl_t *)ofiles->handle == NULL ) {
75 strncpy( LOCAL_ErrorSay, strerror(errno), MAX_ERROR_MSG_SIZE );
80 init_missing = shl_findsym( ofiles->handle, proc_name,
81 TYPE_PROCEDURE, init_proc );
84 ofiles = ofiles->next;
88 strcpy( LOCAL_ErrorSay,
"Could not locate initialization routine" );
93 char *s = AtomName(lib->s);
96 strcpy( LOCAL_FileNameBuf,
"lib" );
97 strcat( LOCAL_FileNameBuf, s+2 );
98 strcat( LOCAL_FileNameBuf,
".sl" );
101 strcpy( LOCAL_FileNameBuf, s );
104 *(shl_t *)libs->handle = shl_load( LOCAL_FileNameBuf, BIND_DEFERRED, 0 );
105 if( *(shl_t *)libs->handle == NULL ) {
106 strncpy( LOCAL_ErrorSay, strerror(errno), MAX_ERROR_MSG_SIZE );
113 return LOAD_SUCCEEDED;
119 char *proc_name, YapInitProc *init_proc)
121 return LoadForeign(ofiles, libs, proc_name, init_proc);
125Yap_ShutdownLoadForeign(
void )
130 f_code = ForeignCodeLoaded;
131 while( f_code != NULL ) {
136 err = shl_unload( *(shl_t *)objs->handle );
142 Yap_FreeCodeSpace( objs->handle );
148 err = shl_unload( *(shl_t *)libs->handle );
154 Yap_FreeCodeSpace( libs->handle );
157 f_code = f_code->next;
163 char *proc_name, YapInitProc *init_proc)
165 ShutdownLoadForeign();
166 return( LoadForeign( ofiles, libs, proc_name, init_proc ) );
load_foreign_files/3 has works for the following configurations: