Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
example-plugin.c
Go to the documentation of this file.
1 /*
2  ExamplePlugin - example plugin for testing the interface/plugin system
3 
4  Copyright (C) Lumiera.org
5  2008, Christian Thaeter <ct@pipapo.org>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
31 #include <stdio.h>
32 
35 
36 #include "interface/say-hello.h"
37 
38 
40 
43 {
45 
46  fprintf (stderr, "opened %p global interfaces %p\n", self, interfaces);
47  return self;
48 }
49 
50 void
52 {
53  fprintf (stderr, "closed %p\n", self);
54 }
55 
56 void hallo (void)
57 {
58  printf ("Hallo Welt!\n");
59 }
60 
61 void tschuess (const char* m)
62 {
63  printf ("Tschuess %s\n", m);
64 }
65 
66 void hello (void)
67 {
68  printf ("Hello World!\n");
69 }
70 
71 void bye (const char* m)
72 {
73  printf ("Bye %s\n", m);
74 }
75 
76 
77 void yeahbabe (void)
78 {
79  LUMIERA_INTERFACE_HANDLE (lumieraorg_testhello, 0) german =
80  LUMIERA_INTERFACE_OPEN (lumieraorg_testhello, 0, 0, lumieraorg_hello_german);
81 
82  LUMIERA_INTERFACE_HANDLE (lumieraorg_testhello, 0) english =
83  LUMIERA_INTERFACE_OPEN (lumieraorg_testhello, 0, 0, lumieraorg_hello_english);
84 
85  LUMIERA_INTERFACE_HANDLE (lumieraorg_configuration, 0) config =
86  LUMIERA_INTERFACE_OPEN (lumieraorg_configuration, 0, 0, lumieraorg_configuration);
87 
88  const char* path;
89  if (config->wordlist_get ("config.path", &path))
90  printf ("config path is: %s\n", path);
91  if (config->wordlist_get ("plugin.path", &path))
92  printf ("plugin path is: %s\n", path);
93 
94  LUMIERA_INTERFACE_CLOSE (config);
95 
96  german->hello ();
97  english->hello ();
98  english->goodbye ("World!");
99  german->goodbye ("Welt!");
100 
101  LUMIERA_INTERFACE_CLOSE (german);
102  LUMIERA_INTERFACE_CLOSE (english);
103 }
104 
105 
106 
107 LUMIERA_INTERFACE_INSTANCE (lumieraorg_interfacedescriptor, 0,
108  lumieraorg_exampleplugin_descriptor,
109  NULL, NULL, NULL,
110  LUMIERA_INTERFACE_INLINE (name,
111  const char*, (LumieraInterface iface),
112  {(void)iface; return "LumieraTest";}
113  ),
114  LUMIERA_INTERFACE_INLINE (brief,
115  const char*, (LumieraInterface iface),
116  {(void)iface; return "Lumiera Test suite examples";}
117  ),
118  LUMIERA_INTERFACE_INLINE (homepage,
119  const char*, (LumieraInterface iface),
120  {(void)iface; return "http://www.lumiera.org/develompent.html";}
121  ),
122  LUMIERA_INTERFACE_INLINE (version,
123  const char*, (LumieraInterface iface),
124  {(void)iface; return "No Version";}
125  ),
126  LUMIERA_INTERFACE_INLINE (author,
127  const char*, (LumieraInterface iface),
128  {(void)iface; return "Christian Thaeter";}
129  ),
130  LUMIERA_INTERFACE_INLINE (email,
131  const char*, (LumieraInterface iface),
132  {(void)iface; return "ct@pipapo.org";}
133  ),
134  LUMIERA_INTERFACE_INLINE (copyright,
135  const char*, (LumieraInterface iface),
136  {
137  (void)iface;
138  return
139  "Copyright (C) Lumiera.org\n"
140  " 2008 Christian Thaeter <ct@pipapo.org>";
141  }
142  ),
143  LUMIERA_INTERFACE_INLINE (license,
144  const char*, (LumieraInterface iface),
145  {
146  (void)iface;
147  return
148  "This program is free software; you can redistribute it and/or modify\n"
149  "it under the terms of the GNU General Public License as published by\n"
150  "the Free Software Foundation; either version 2 of the License, or\n"
151  "(at your option) any later version.\n"
152  "\n"
153  "This program is distributed in the hope that it will be useful,\n"
154  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
155  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
156  "GNU General Public License for more details.\n"
157  "\n"
158  "You should have received a copy of the GNU General Public License\n"
159  "along with this program; if not, write to the Free Software\n"
160  "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA";
161  }
162  ),
163 
164  LUMIERA_INTERFACE_INLINE (state,
165  int, (LumieraInterface iface),
166  {(void)iface; return LUMIERA_INTERFACE_EXPERIMENTAL;}
167  ),
168 
169  LUMIERA_INTERFACE_INLINE (versioncmp,
170  int, (const char* a, const char* b),
171  {(void)a;(void)b; return 0;}
172  )
173  );
174 
175 
177  LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0,
178  lumieraorg_hello_german,
179  LUMIERA_INTERFACE_REF (lumieraorg_interfacedescriptor, 0, lumieraorg_exampleplugin_descriptor),
180  myopen,
181  myclose,
182  LUMIERA_INTERFACE_MAP (hello,
183  hallo),
184  LUMIERA_INTERFACE_MAP (goodbye,
185  tschuess)
186  ),
187  LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0,
188  lumieraorg_hello_english,
189  LUMIERA_INTERFACE_REF (lumieraorg_interfacedescriptor, 0, lumieraorg_exampleplugin_descriptor),
190  myopen,
191  myclose,
192  LUMIERA_INTERFACE_MAP (hello,
193  hello),
194  LUMIERA_INTERFACE_MAP (goodbye,
195  bye)
196  ),
197  LUMIERA_INTERFACE_DEFINE (lumieraorg_testtest, 0,
198  lumieraorg_test_both,
199  LUMIERA_INTERFACE_REF (lumieraorg_interfacedescriptor, 0, lumieraorg_exampleplugin_descriptor),
200  myopen,
201  myclose,
202  LUMIERA_INTERFACE_MAP (testit,
203  yeahbabe)
204  )
205  )
void hello(void)
#define LUMIERA_INTERFACE_CLOSE(handle)
Definition: interface.h:345
void bye(const char *m)
LumieraInterface myopen(LumieraInterface self, LumieraInterface interfaces)
Not finished development code.
#define LUMIERA_INTERFACE_OPEN(interface, version, minminor, name)
Definition: interface.h:342
#define LUMIERA_PLUGIN_STORE_INTERFACEHANDLE(name)
Definition: interface.h:326
A mock interface to support testing of the interface system.
return NULL
Definition: llist.h:596
#define LUMIERA_INTERFACE_REF(iname, version, dname)
Return a reference (pointer) to an interface implementation.
Definition: interface.h:128
void tschuess(const char *m)
void hallo(void)
void myclose(LumieraInterface self)
LUMIERA_INTERFACE_INSTANCE(lumieraorg_interfacedescriptor, 0, lumieraorg_exampleplugin_descriptor, NULL, NULL, NULL, LUMIERA_INTERFACE_INLINE(name, const char *,(LumieraInterface iface),{(void) iface;return"LumieraTest";}), LUMIERA_INTERFACE_INLINE(brief, const char *,(LumieraInterface iface),{(void) iface;return"Lumiera Test suite examples";}), LUMIERA_INTERFACE_INLINE(homepage, const char *,(LumieraInterface iface),{(void) iface;return"http://www.lumiera.org/develompent.html";}), LUMIERA_INTERFACE_INLINE(version, const char *,(LumieraInterface iface),{(void) iface;return"No Version";}), LUMIERA_INTERFACE_INLINE(author, const char *,(LumieraInterface iface),{(void) iface;return"Christian Thaeter";}), LUMIERA_INTERFACE_INLINE(email, const char *,(LumieraInterface iface),{(void) iface;return"ct@pipapo.org";}), LUMIERA_INTERFACE_INLINE(copyright, const char *,(LumieraInterface iface),{(void) iface;return"Copyright (C) Lumiera.org\n"" 2008 Christian Thaeter <ct@pipapo.org>";}), LUMIERA_INTERFACE_INLINE(license, const char *,(LumieraInterface iface),{(void) iface;return"This program is free software; you can redistribute it and/or modify\n""it under the terms of the GNU General Public License as published by\n""the Free Software Foundation; either version 2 of the License, or\n""(at your option) any later version.\n""\n""This program is distributed in the hope that it will be useful,\n""but WITHOUT ANY WARRANTY; without even the implied warranty of\n""MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n""GNU General Public License for more details.\n""\n""You should have received a copy of the GNU General Public License\n""along with this program; if not, write to the Free Software\n""Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA";}), LUMIERA_INTERFACE_INLINE(state, int,(LumieraInterface iface),{(void) iface;return LUMIERA_INTERFACE_EXPERIMENTAL;}), LUMIERA_INTERFACE_INLINE(versioncmp, int,(const char *a, const char *b),{(void) a;(void) b;return 0;}))
A data record to describe interface, interface instances and plug-in instances.
External interface to the lumiera configuration system.
LUMIERA_PLUGIN_INTERFACEHANDLE
#define LUMIERA_INTERFACE_HANDLE(interface, version)
create a handle for a interface (WIP)
Definition: interface.h:356
#define LUMIERA_EXPORT(...)
Generate interface container suitable for enumerating interfaces.
Definition: interface.h:282
lumiera_interface * LumieraInterface
Definition: interface.h:364
void yeahbabe(void)