1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* Copyright (C) 2001 Alan Robertson <alanr@unix.sh>
* This software licensed under the GNU LGPL.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <lha_internal.h>
#include <stdio.h>
#include <pils/generic.h>
#define MOD "/home/alanr/modules"
GHashTable* test1functions = NULL;
long one = 1;
long two = 2;
long three = 3;
long four = 4;
static int TestCallBack
( GenericPILCallbackType t
, PILPluginUniv* univ
, const char * iftype
, const char * ifname
, void* userptr
);
static PILGenericIfMgmtRqst RegRqsts [] =
{ {"test", &test1functions, &one, TestCallBack, &two},
{NULL, NULL, NULL, NULL, NULL}
};
int
main(int argc, char ** argv)
{
PILPluginUniv * u;
PIL_rc rc;
int j;
u = NewPILPluginUniv(MOD);
/* PILSetDebugLevel(u, NULL, NULL, 0); */
PILLogMemStats();
if ((rc = PILLoadPlugin(u, "InterfaceMgr", "generic", &RegRqsts))
!= PIL_OK) {
fprintf(stderr, "generic plugin load Error = [%s]\n"
, lt_dlerror());
/*exit(1);*/
}
/* PILSetDebugLevel(u, NULL, NULL, 0); */
for (j=0; j < 10; ++j) {
PILLogMemStats();
fprintf(stderr, "****Loading plugin test/test\n");
if ((rc = PILLoadPlugin(u, "test", "test", NULL)) != PIL_OK) {
printf("ERROR: test plugin load error = [%d/%s]\n"
, rc, lt_dlerror());
}
PILLogMemStats();
fprintf(stderr, "****UN-loading plugin test/test\n");
if ((rc = PILIncrIFRefCount(u, "test", "test", -1))!= PIL_OK){
printf("ERROR: test plugin UNload error = [%d/%s]\n"
, rc, lt_dlerror());
}
}
PILLogMemStats();
DelPILPluginUniv(u); u = NULL;
PILLogMemStats();
return 0;
}
static int
TestCallBack
( GenericPILCallbackType t
, PILPluginUniv* univ
, const char * iftype
, const char * ifname
, void* userptr)
{
char cbbuf[32];
switch(t) {
case PIL_REGISTER:
snprintf(cbbuf, sizeof(cbbuf), "PIL_REGISTER");
break;
case PIL_UNREGISTER:
snprintf(cbbuf, sizeof(cbbuf), "PIL_UNREGISTER");
break;
default:
snprintf(cbbuf, sizeof(cbbuf), "type [%d?]", t);
break;
}
fprintf(stderr, "Callback: (%s, univ: 0x%lx, module: %s/%s, user ptr: 0x%lx (%ld))\n"
, cbbuf
, (unsigned long) univ
, iftype, ifname
, (unsigned long)userptr
, (*((long *)userptr)));
return PIL_OK;
}
|