~ubuntu-branches/ubuntu/trusty/libgii/trusty

« back to all changes in this revision

Viewing changes to gii/dl.c

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2006-10-17 19:36:15 UTC
  • mfrom: (3.1.3 edgy)
  • Revision ID: james.westby@ubuntu.com-20061017193615-6civk5a1i4n1kyb0
Tags: 1:1.0.1-3
Fixed "ggtick is missing". Closes: #388682.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: dl.c,v 1.3.2.1 2003/11/13 21:40:12 cegger Exp $
 
1
/* $Id: dl.c,v 1.13 2005/09/03 18:16:24 soyt Exp $
2
2
******************************************************************************
3
3
 
4
4
   Input library for GGI. Library extensions dynamic loading.
25
25
******************************************************************************
26
26
*/
27
27
 
28
 
#define GII_DLINIT_SYM         "GIIdlinit"
29
 
 
30
28
#include "config.h"
 
29
 
 
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>
33
34
 
34
35
#include <stdio.h>
35
36
#include <stdlib.h>
36
37
#include <string.h>
37
38
 
38
 
 
39
39
/* Open the dynamic libary requested
40
40
 */
41
 
gii_dlhandle *_giiLoadDL(const char *name, const char *version)
 
41
gii_dlhandle *_giiLoadDL(const char *name)
42
42
{
43
43
        gii_dlhandle hand,*hp;
44
 
 
45
 
        GIIDPRINT_LIBS("_giiLoadDL(\"%s\",\"%s\") called \n", name,
46
 
                       version ? version : "(NULL)");
47
 
 
48
 
        hand.handle=ggMLoadModule(_giiconfhandle, name, version, 0);
49
 
 
50
 
        GIIDPRINT_LIBS("hand.handle=%p\n",hand.handle);
51
 
        if (hand.handle==NULL) 
52
 
                return NULL;
53
 
 
54
 
        hand.init = ggGetSymbolAddress(hand.handle, GII_DLINIT_SYM);
55
 
 
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);
60
 
                return NULL;
 
44
        struct gg_location_iter match;
 
45
        
 
46
        DPRINT_LIBS("_giiLoadDL(\"%s\") called \n", name);
 
47
        
 
48
        hp = NULL;
 
49
        match.name = 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);
 
57
                        continue;
 
58
                }
 
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);
 
63
                        continue;
 
64
                }
 
65
                if ((hp = malloc(sizeof(*hp))) == NULL) {
 
66
                        DPRINT_LIBS("mem error.\n");
 
67
                        ggDelScope(hand.handle);
 
68
                        break;
 
69
                }
 
70
                memcpy(hp, &hand, sizeof(gii_dlhandle));
 
71
                break;
61
72
        }
62
 
        memcpy(hp, &hand, sizeof(gii_dlhandle));
63
 
 
 
73
        GG_ITER_DONE(&match);
64
74
        return hp;
65
75
}
66
76
 
67
77
int _giiCloseDL(gii_dlhandle *hand) {
68
 
        ggFreeModule(hand->handle);
 
78
        ggDelScope(hand->handle);
69
79
        return 0;
70
80
}