Commit b1e611d3aa1766cdb19ac25166a74febd72439fc
1 parent
e035bbac
Exists in
master
and in
3 other branches
Adding utilities do build filenames.
Showing
5 changed files
with
76 additions
and
0 deletions
Show diff stats
lib3270.cbp
... | ... | @@ -157,6 +157,9 @@ |
157 | 157 | <Unit filename="src/lib3270/linux/event_dispatcher.c"> |
158 | 158 | <Option compilerVar="CC" /> |
159 | 159 | </Unit> |
160 | + <Unit filename="src/lib3270/linux/util.c"> | |
161 | + <Option compilerVar="CC" /> | |
162 | + </Unit> | |
160 | 163 | <Unit filename="src/lib3270/log.c"> |
161 | 164 | <Option compilerVar="CC" /> |
162 | 165 | </Unit> | ... | ... |
src/include/lib3270.h
... | ... | @@ -66,6 +66,8 @@ |
66 | 66 | |
67 | 67 | #endif |
68 | 68 | |
69 | + #define LIB3270_STRINGIZE(x) #x | |
70 | + #define LIB3270_STRINGIZE_VALUE_OF(x) LIB3270_STRINGIZE(x) | |
69 | 71 | |
70 | 72 | /** |
71 | 73 | * @brief BIND definitions. |
... | ... | @@ -1330,6 +1332,14 @@ |
1330 | 1332 | LIB3270_EXPORT const char * lib3270_win32_local_charset(void); |
1331 | 1333 | #endif // WIn32 |
1332 | 1334 | |
1335 | + /** | |
1336 | + * @brief Build filename on "DATADIR". | |
1337 | + * | |
1338 | + * @return Full path for the file (release it with lib3270_free). | |
1339 | + * | |
1340 | + */ | |
1341 | + LIB3270_EXPORT char * lib3270_build_data_filename(const char *name); | |
1342 | + | |
1333 | 1343 | #ifdef __cplusplus |
1334 | 1344 | } |
1335 | 1345 | #endif | ... | ... |
src/lib3270/Makefile.in
... | ... | @@ -118,6 +118,7 @@ $(OBJDBG)/%.o: \ |
118 | 118 | $(CFLAGS) \ |
119 | 119 | -Wall -Wextra -fstack-check \ |
120 | 120 | -DDEBUG=1 \ |
121 | + -DDATADIR=. \ | |
121 | 122 | -o $@ -c $< |
122 | 123 | |
123 | 124 | $(OBJDBG)/%.o: \ |
... | ... | @@ -138,6 +139,7 @@ $(OBJRLS)/%.o: \ |
138 | 139 | @$(CC) \ |
139 | 140 | $(CFLAGS) \ |
140 | 141 | -DNDEBUG=1 \ |
142 | + -DDATADIR=$(datarootdir)/pw3270 \ | |
141 | 143 | -o $@ -c $< |
142 | 144 | |
143 | 145 | $(OBJRLS)/%.o: \ | ... | ... |
... | ... | @@ -0,0 +1,42 @@ |
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. Registro no INPI sob | |
5 | + * o nome G3270. | |
6 | + * | |
7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | + * | |
9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | + * Free Software Foundation. | |
12 | + * | |
13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | + * obter mais detalhes. | |
17 | + * | |
18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | + * | |
22 | + * Este programa está nomeado como - e possui - linhas de código. | |
23 | + * | |
24 | + * Contatos: | |
25 | + * | |
26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | + * | |
29 | + */ | |
30 | + | |
31 | +/** | |
32 | + * @brief Linux Utility functions. | |
33 | + */ | |
34 | + | |
35 | + | |
36 | +#include <config.h> | |
37 | +#include "../private.h" | |
38 | + | |
39 | +char * lib3270_build_data_filename(const char *name) | |
40 | +{ | |
41 | + return lib3270_strdup_printf("%s/%s",LIB3270_STRINGIZE_VALUE_OF(DATADIR),name); | |
42 | +} | ... | ... |
src/lib3270/windows/util.c
... | ... | @@ -208,3 +208,22 @@ int gettimeofday(struct timeval *tv, void *ignored unused) |
208 | 208 | return 0; |
209 | 209 | } |
210 | 210 | |
211 | +char * lib3270_build_data_filename(const char *name) | |
212 | +{ | |
213 | + // https://github.com/GNOME/glib/blob/master/glib/gwin32.c | |
214 | + | |
215 | + char *p; | |
216 | + wchar_t wc_fn[MAX_PATH]; | |
217 | + | |
218 | + if (!GetModuleFileNameW(NULL, wc_fn, MAX_PATH)) | |
219 | + return NULL; | |
220 | + | |
221 | + if((p = strrchr (filename, '\\')) != NULL) | |
222 | + *p = '\0'; | |
223 | + | |
224 | + if((p = strrchr (filename, '/')) != NULL) | |
225 | + *p = '\0'; | |
226 | + | |
227 | + return lib3270_strdup_printf("%s\\%s",wc_fn,name); | |
228 | + | |
229 | +} | ... | ... |