Commit 95eb08ec45f885f5a38c15d58e1ea30c2567426c
1 parent
b37bf534
Exists in
master
and in
5 other branches
Ajustando Makefile para gerar plugin em modo debug
Showing
2 changed files
with
167 additions
and
2 deletions
Show diff stats
Makefile.in
1 | - | |
2 | 1 | # |
3 | 2 | # "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 |
4 | 3 | # (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a |
... | ... | @@ -102,7 +101,6 @@ ifneq ($(CONVERT),no) |
102 | 101 | @$(CONVERT) --format=png --output=$@ $< |
103 | 102 | endif |
104 | 103 | |
105 | - | |
106 | 104 | debian/%.install: src/%/Makefile |
107 | 105 | @$(MAKE) DEBDIR=../../debian -C $(dir $^) ../../$@ |
108 | 106 | |
... | ... | @@ -125,6 +123,9 @@ $(BINDIR)/Release/$(localedir)/%/LC_MESSAGES/$(PACKAGE_NAME).mo: po/%.po |
125 | 123 | src/tools/%@EXEEXT@: src/tools/%.c |
126 | 124 | @make -C src/tools $(notdir $@) |
127 | 125 | |
126 | +$(BINDIR)/Debug/plugins/%@DLLEXT@: src/plugins/%/* $(BINDIR)/Debug/$(PACKAGE_TARNAME)$(EXEEXT) | |
127 | + @make BINDIR="../../../$(BINDIR)" PW3270_LIBS="-L../../../$(BINDIR)/Debug@DLLDIR@ -l3270 -lpw3270" PW3270_CFLAGS="-I../../../src/include" -C $(dir $<) Debug | |
128 | + | |
128 | 129 | #---[ Release targets ]-------------------------------------------------------- |
129 | 130 | |
130 | 131 | all: $(BINDIR)/Release/$(PACKAGE_TARNAME)$(EXEEXT) locale filelist |
... | ... | @@ -311,6 +312,7 @@ distclean: clean |
311 | 312 | @rm -fr autom4te.cache |
312 | 313 | @rm -f *.pc |
313 | 314 | @rm -f $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar* |
315 | + @find ./src -name "Makefile" -exec rm -f {} \; | |
314 | 316 | |
315 | 317 | @rm -f Makefile |
316 | 318 | @echo "$@" | ... | ... |
... | ... | @@ -0,0 +1,163 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como plugin.c e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * licinio@bb.com.br (Licínio Luis Branco) | |
28 | + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
29 | + * | |
30 | + */ | |
31 | + | |
32 | +#include "globals.h" | |
33 | +#include "pw3270/plugin.h" | |
34 | + | |
35 | +/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
36 | + | |
37 | + static guint nPlugin = 0; /**< Number of active plugins */ | |
38 | + static GModule **hPlugin = NULL; /**< Plugin handles */ | |
39 | + | |
40 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
41 | + | |
42 | + static void load(const gchar *path, GtkWidget *widget) | |
43 | + { | |
44 | + GDir * dir; | |
45 | + const gchar * name; | |
46 | + GError * err = NULL; | |
47 | + GList * lst = NULL; | |
48 | + | |
49 | + trace("Loading plugins from %s",path); | |
50 | + | |
51 | + dir = g_dir_open(path,0,&err); | |
52 | + if(!dir) | |
53 | + { | |
54 | + g_warning("%s",err->message); | |
55 | + g_error_free(err); | |
56 | + return; | |
57 | + } | |
58 | + | |
59 | + name = g_dir_read_name(dir); | |
60 | + while(name) | |
61 | + { | |
62 | + gchar *filename = g_build_filename(path,name,NULL); | |
63 | + | |
64 | + if(g_str_has_suffix(filename,G_MODULE_SUFFIX)) | |
65 | + { | |
66 | + GModule *handle = g_module_open(filename,G_MODULE_BIND_LOCAL); | |
67 | + if(handle) | |
68 | + { | |
69 | + int (*init)(GtkWidget *); | |
70 | + | |
71 | + if(g_module_symbol(handle, "pw3270_plugin_init", (gpointer) &init)) | |
72 | + { | |
73 | + if(init(widget)) | |
74 | + { | |
75 | + // Plugin init fails | |
76 | + g_module_close(handle); | |
77 | + } | |
78 | + else | |
79 | + { | |
80 | + // Plugin init is ok, save handle | |
81 | + lst = g_list_append(lst,handle); | |
82 | + } | |
83 | + } | |
84 | + else | |
85 | + { | |
86 | + // No plugin init warn and save it anyway | |
87 | + g_warning("No pw3270_plugin_init() method in %s",filename); | |
88 | + lst = g_list_append(lst,handle); | |
89 | + } | |
90 | + } | |
91 | + } | |
92 | + g_free(filename); | |
93 | + name = g_dir_read_name(dir); | |
94 | + } | |
95 | + | |
96 | + g_dir_close(dir); | |
97 | + | |
98 | + if(lst) | |
99 | + { | |
100 | + // At least one plugin was loaded, save handle, start it | |
101 | + GList *l = g_list_first(lst); | |
102 | + int f; | |
103 | + | |
104 | + nPlugin = g_list_length(lst); | |
105 | + g_message("%d plugin(s) loaded",nPlugin); | |
106 | + hPlugin = g_malloc0(nPlugin * sizeof(GModule *)); | |
107 | + | |
108 | + for(f=0;f<nPlugin && l;f++) | |
109 | + { | |
110 | + void (*start)(GtkWidget *); | |
111 | + | |
112 | + hPlugin[f] = (GModule *) l->data; | |
113 | + | |
114 | + l = g_list_next(l); | |
115 | + | |
116 | + if(g_module_symbol(hPlugin[f], "pw3270_plugin_start", (gpointer) &start)) | |
117 | + start(widget); | |
118 | + } | |
119 | + | |
120 | + g_list_free(lst); | |
121 | + } | |
122 | + | |
123 | + } | |
124 | + | |
125 | + G_GNUC_INTERNAL void init_plugins(GtkWidget *widget) | |
126 | + { | |
127 | +#ifdef DEBUG | |
128 | + load("." G_DIR_SEPARATOR_S "plugins", widget); | |
129 | +#endif | |
130 | + | |
131 | + } | |
132 | + | |
133 | + G_GNUC_INTERNAL void deinit_plugins(GtkWidget *widget) | |
134 | + { | |
135 | + int f; | |
136 | + | |
137 | + if(!hPlugin) | |
138 | + return; | |
139 | + | |
140 | + trace("Unloading %d plugin(s)",nPlugin); | |
141 | + | |
142 | + for(f=0;f<nPlugin;f++) | |
143 | + { | |
144 | + void (*stop)(GtkWidget *); | |
145 | + | |
146 | + if(g_module_symbol(hPlugin[f], "pw3270_plugin_stop", (gpointer) &stop)) | |
147 | + stop(widget); | |
148 | + } | |
149 | + | |
150 | + for(f=0;f<nPlugin;f++) | |
151 | + { | |
152 | + void (*deinit)(GtkWidget *); | |
153 | + | |
154 | + if(g_module_symbol(hPlugin[f], "pw3270_plugin_deinit", (gpointer) &deinit)) | |
155 | + deinit(widget); | |
156 | + | |
157 | + g_module_close(hPlugin[f]); | |
158 | + } | |
159 | + | |
160 | + g_free(hPlugin); | |
161 | + hPlugin = NULL; | |
162 | + nPlugin = 0; | |
163 | + } | ... | ... |