Apply suggestion from Andrew for srcdir functionality.
[openais.git] / lcr / libtest_b.c
blob977bf3549a7054cb0c6693a2836e4a807a78d247
1 /*
2 * Copyright (C) 2006 Steven Dake (sdake@mvista.com)
4 * This software licensed under BSD license, the text of which follows:
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * - Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * - Neither the name of the MontaVista Software, Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from this
16 * software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
30 #include <stdio.h>
31 #include "lcr_comp.h"
34 * Version 0 of the interface
36 static int iface1_constructor (void *context);
38 static void iface1_destructor (void *context);
40 static void iface1_func1 (void);
42 static void iface1_func2 (void);
44 static void iface1_func3 (void);
47 * Version 1 of the interface
49 static int iface1_ver1_constructor (void *context);
51 static void iface1_ver1_destructor (void *context);
53 static void iface1_ver1_func1 (void);
55 static void iface1_ver1_func2 (void);
57 static void iface1_ver1_func3 (void);
59 struct iface_list {
60 void (*iface1_func1)(void);
61 void (*iface1_func2)(void);
62 void (*iface1_func3)(void);
65 struct iface_ver1_list {
66 void (*iface1_ver1_func1)(void);
67 void (*iface1_ver1_func2)(void);
68 void (*iface1_ver1_func3)(void);
71 struct iface_list iface_list = {
72 .iface1_func1 = iface1_func1,
73 .iface1_func2 = iface1_func2,
74 .iface1_func3 = iface1_func3,
77 struct iface_list iface_ver1_list = {
78 .iface1_func1 = iface1_ver1_func1,
79 .iface1_func2 = iface1_ver1_func2,
80 .iface1_func3 = iface1_ver1_func3,
83 struct lcr_iface iface1[2]= {
85 * Version 0
88 .name = "B_iface1",
89 .version = 0,
90 .versions_replace = 0,
91 .versions_replace_count = 0,
92 .dependencies = 0,
93 .dependency_count = 0,
94 .constructor = iface1_constructor,
95 .destructor = iface1_destructor,
96 .interfaces = NULL
99 * Version 1
102 .name = "B_iface1",
103 .version = 1,
104 .versions_replace = 0,
105 .versions_replace_count = 0,
106 .dependencies = 0,
107 .dependency_count = 0,
108 .constructor = iface1_ver1_constructor,
109 .destructor = iface1_ver1_destructor,
110 .interfaces = NULL
114 struct lcr_comp test_comp = {
115 .iface_count = 2,
116 .ifaces = iface1
119 static int iface1_constructor (void *context)
121 printf ("B - version 0 constructor context %p\n", context);
122 return (0);
125 static void iface1_destructor (void *context)
127 printf ("B - version 0 destructor context %p\n", context);
130 static void iface1_func1 (void) {
131 printf ("B - version 0 func1\n");
134 static void iface1_func2 (void) {
135 printf ("B - version 0 func2\n");
138 static void iface1_func3 (void) {
139 printf ("B - version 0 func3\n");
142 static int iface1_ver1_constructor (void *context)
144 printf ("B - version 1 constructor context %p\n", context);
145 return (0);
148 static void iface1_ver1_destructor (void *context)
150 printf ("B - version 1 destructor context %p\n", context);
153 static void iface1_ver1_func1 (void) {
154 printf ("B - version 1 func1\n");
157 static void iface1_ver1_func2 (void) {
158 printf ("B - version 1 func2\n");
161 static void iface1_ver1_func3 (void) {
162 printf ("B - version 1 func3\n");
165 __attribute__ ((constructor)) static void register_this_component (void)
167 lcr_interfaces_set (&iface1[0], &iface_list);
168 lcr_interfaces_set (&iface1[1], &iface_ver1_list);
170 lcr_component_register (&test_comp);