25
25
******************************************************************************
28
#define GII_DLINIT_SYM "GIIdlinit"
30
28
#include "config.h"
30
#include <ggi/internal/gg.h>
31
31
#include <ggi/internal/gii.h>
32
32
#include <ggi/internal/gii_debug.h>
33
#include <ggi/internal/gg_replace.h>
35
36
#include <stdlib.h>
36
37
#include <string.h>
39
39
/* Open the dynamic libary requested
41
gii_dlhandle *_giiLoadDL(const char *name, const char *version)
41
gii_dlhandle *_giiLoadDL(const char *name)
43
43
gii_dlhandle hand,*hp;
45
GIIDPRINT_LIBS("_giiLoadDL(\"%s\",\"%s\") called \n", name,
46
version ? version : "(NULL)");
48
hand.handle=ggMLoadModule(_giiconfhandle, name, version, 0);
50
GIIDPRINT_LIBS("hand.handle=%p\n",hand.handle);
51
if (hand.handle==NULL)
54
hand.init = ggGetSymbolAddress(hand.handle, GII_DLINIT_SYM);
56
GIIDPRINT_LIBS("hand.init=%p\n",hand.init);
57
if (hand.init == NULL ||
58
(hp = (gii_dlhandle *) malloc(sizeof(gii_dlhandle))) == NULL) {
59
ggFreeModule(hand.handle);
44
struct gg_location_iter match;
46
DPRINT_LIBS("_giiLoadDL(\"%s\") called \n", name);
50
match.config = _giiconfhandle;
51
ggConfigIterLocation(&match);
52
GG_ITER_FOREACH(&match) {
53
DPRINT_LIBS("match: location=\"%s\" symbol=\"%s\"\n",
54
match.location, match.symbol);
55
if ((hand.handle = ggGetScope(match.location)) == NULL) {
56
DPRINT_LIBS("cannot open bundle at \"%s\".\n",match.location);
59
match.symbol = match.symbol ? match.symbol : GII_DLINIT_SYM;
60
if ((hand.init = ggFromScope(hand.handle, match.symbol)) == NULL) {
61
DPRINT_LIBS("symbol \"%s\" not found.\n", match.symbol);
62
ggDelScope(hand.handle);
65
if ((hp = malloc(sizeof(*hp))) == NULL) {
66
DPRINT_LIBS("mem error.\n");
67
ggDelScope(hand.handle);
70
memcpy(hp, &hand, sizeof(gii_dlhandle));
62
memcpy(hp, &hand, sizeof(gii_dlhandle));
67
77
int _giiCloseDL(gii_dlhandle *hand) {
68
ggFreeModule(hand->handle);
78
ggDelScope(hand->handle);