~ampelbein/ubuntu/oneiric/heartbeat/lp-770743

« back to all changes in this revision

Viewing changes to lib/pils/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Ante Karamatic
  • Date: 2010-02-17 21:59:18 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100217215918-06paxph5do4saw8v
Tags: 3.0.2-0ubuntu1
* New upstream release
* Drop hard dep on pacemaker for heartbet; moved to Recommends
* debian/heartbeat.install:
  - follow upstream changes
* debian/control:
  - added docbook-xsl and xsltproc to build depends

Show diffs side-by-side

added added

removed removed

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