Commit 5c65532df3f8784879d26866f0ec95a9af773e23
1 parent
3d961503
Exists in
master
and in
3 other branches
Reativando aplicativo de teste.
Showing
3 changed files
with
50 additions
and
688 deletions
Show diff stats
Makefile.in
... | ... | @@ -279,9 +279,22 @@ install-devel: \ |
279 | 279 | #---[ Debug Targets ]-------------------------------------------------------------------- |
280 | 280 | |
281 | 281 | Debug: \ |
282 | - $(BINDBG)/@DLLPREFIX@$(LIBNAME)@DLLEXT@ \ | |
282 | + $(BINDBG)/@DLLPREFIX@$(LIBNAME)@EXEEXT@ | |
283 | + | |
284 | +$(BINDBG)/@DLLPREFIX@$(LIBNAME)@EXEEXT@: \ | |
285 | + $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC).o) \ | |
283 | 286 | $(foreach SRC, $(basename $(TEST_SOURCES)), $(OBJDBG)/$(SRC).o) |
284 | - | |
287 | + | |
288 | + @$(MKDIR) `dirname $@` | |
289 | + @echo $< ... | |
290 | + $(LD) -o $@ $^ $(LDFLAGS) $(LIBS) | |
291 | + | |
292 | +run: \ | |
293 | + $(BINDBG)/@DLLPREFIX@$(LIBNAME)@EXEEXT@ | |
294 | + | |
295 | + @LD_LIBRARY_PATH=$(BINDBG) \ | |
296 | + $(BINDBG)/@DLLPREFIX@$(LIBNAME)@EXEEXT@ | |
297 | + | |
285 | 298 | |
286 | 299 | $(BINDBG)/@DLLPREFIX@$(LIBNAME)@DLLEXT@: \ |
287 | 300 | $(BINDBG)/@DLLPREFIX@$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@ | ... | ... |
src/lib3270/mkfb.c
... | ... | @@ -1,664 +0,0 @@ |
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 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 mkfb.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 | -/* | |
33 | - * mkfb.c | |
34 | - * Utility to create RDB string definitions from a simple #ifdef'd .ad | |
35 | - * file | |
36 | - */ | |
37 | - | |
38 | -#include "../include/config.h" | |
39 | - | |
40 | - | |
41 | -#if defined( WIN32 ) | |
42 | - #include <windows.h> | |
43 | - #define tmpfile w32_tmpfile | |
44 | -#elif defined( __APPLE__ ) | |
45 | - #define tmpfile osx_tmpfile | |
46 | -#endif // OS | |
47 | - | |
48 | -#include <sys/stat.h> | |
49 | -#include <fcntl.h> | |
50 | - | |
51 | -#include <stdio.h> | |
52 | -#include <string.h> | |
53 | -#include <ctype.h> | |
54 | -#include <stdlib.h> | |
55 | -#include <errno.h> | |
56 | - | |
57 | -#define BUFSZ 1024 /* input line buffer size */ | |
58 | -#define ARRSZ 8192 /* output array size */ | |
59 | -#define SSSZ 10 /* maximum nested ifdef */ | |
60 | - | |
61 | -unsigned aix[ARRSZ]; /* fallback array indices */ | |
62 | -unsigned xlno[ARRSZ]; /* fallback array line numbers */ | |
63 | -unsigned n_fallbacks = 0; /* number of fallback entries */ | |
64 | - | |
65 | -/* ifdef state stack */ | |
66 | -#define MODE_COLOR 0x00000001 | |
67 | -#define MODE_FT 0x00000002 | |
68 | -#define MODE_TRACE 0x00000004 | |
69 | -#define MODE_MENUS 0x00000008 | |
70 | -#define MODE_ANSI 0x00000010 | |
71 | -#define MODE_KEYPAD 0x00000020 | |
72 | -#define MODE_APL 0x00000040 | |
73 | -#define MODE_PRINTER 0x00000080 | |
74 | -#define MODE_STANDALONE 0x00000100 | |
75 | -#define MODE_SCRIPT 0x00000200 | |
76 | -#define MODE_DBCS 0x00000400 | |
77 | -#define MODE__WIN32 0x00000800 | |
78 | - | |
79 | -#define MODEMASK 0x00000fff | |
80 | - | |
81 | -struct { | |
82 | - unsigned long ifdefs; | |
83 | - unsigned long ifndefs; | |
84 | - unsigned lno; | |
85 | -} ss[SSSZ]; | |
86 | -int ssp = 0; | |
87 | - | |
88 | -struct { | |
89 | - const char *name; | |
90 | - unsigned long mask; | |
91 | -} parts[] = { | |
92 | - { "COLOR", MODE_COLOR }, | |
93 | - { "X3270_FT", MODE_FT }, | |
94 | - { "X3270_TRACE", MODE_TRACE }, | |
95 | - { "X3270_MENUS", MODE_MENUS }, | |
96 | - { "X3270_ANSI", MODE_ANSI }, | |
97 | - { "X3270_KEYPAD", MODE_KEYPAD }, | |
98 | - { "X3270_APL", MODE_APL }, | |
99 | - { "X3270_PRINTER", MODE_PRINTER }, | |
100 | - { "STANDALONE", MODE_STANDALONE }, | |
101 | - { "X3270_SCRIPT", MODE_SCRIPT }, | |
102 | - { "X3270_DBCS", MODE_DBCS }, | |
103 | - { "_WIN32", MODE__WIN32 } | |
104 | -}; | |
105 | -#define NPARTS (sizeof(parts)/sizeof(parts[0])) | |
106 | - | |
107 | -unsigned long is_defined = | |
108 | - MODE_COLOR | | |
109 | -#if defined(X3270_FT) | |
110 | - MODE_FT | |
111 | -#else | |
112 | - 0 | |
113 | -#endif | |
114 | -| | |
115 | -#if defined(X3270_TRACE) | |
116 | - MODE_TRACE | |
117 | -#else | |
118 | - 0 | |
119 | -#endif | |
120 | -| | |
121 | -#if defined(X3270_MENUS) | |
122 | - MODE_MENUS | |
123 | -#else | |
124 | - 0 | |
125 | -#endif | |
126 | -| | |
127 | -#if defined(X3270_ANSI) | |
128 | - MODE_ANSI | |
129 | -#else | |
130 | - 0 | |
131 | -#endif | |
132 | -| | |
133 | -#if defined(X3270_KEYPAD) | |
134 | - MODE_KEYPAD | |
135 | -#else | |
136 | - 0 | |
137 | -#endif | |
138 | -| | |
139 | -#if defined(X3270_APL) | |
140 | - MODE_APL | |
141 | -#else | |
142 | - 0 | |
143 | -#endif | |
144 | -| | |
145 | -#if defined(X3270_PRINTER) | |
146 | - MODE_PRINTER | |
147 | -#else | |
148 | - 0 | |
149 | -#endif | |
150 | -| | |
151 | -#if defined(X3270_SCRIPT) | |
152 | - MODE_SCRIPT | |
153 | -#else | |
154 | - 0 | |
155 | -#endif | |
156 | -| | |
157 | -#if defined(X3270_DBCS) | |
158 | - MODE_DBCS | |
159 | -#else | |
160 | - 0 | |
161 | -#endif | |
162 | -| | |
163 | -#if defined(_WIN32) | |
164 | - MODE__WIN32 | |
165 | -#else | |
166 | - 0 | |
167 | -#endif | |
168 | - ; | |
169 | -unsigned long is_undefined; | |
170 | - | |
171 | -char *me; | |
172 | - | |
173 | -void emit(FILE *t, int ix, char c); | |
174 | - | |
175 | -void | |
176 | -usage(void) | |
177 | -{ | |
178 | - fprintf(stderr, "usage: %s [infile [outfile]]\n", me); | |
179 | - exit(1); | |
180 | -} | |
181 | - | |
182 | -int | |
183 | -main(int argc, char *argv[]) | |
184 | -{ | |
185 | - char buf[BUFSZ]; | |
186 | - int lno = 0; | |
187 | - int cc = 0; | |
188 | - int i; | |
189 | - int continued = 0; | |
190 | - const char *filename = "standard input"; | |
191 | - FILE *u, *t, *tc = NULL, *tm = NULL, *o; | |
192 | - int cmode = 0; | |
193 | - unsigned long ifdefs; | |
194 | - unsigned long ifndefs; | |
195 | - int last_continue = 0; | |
196 | - | |
197 | - /* Parse arguments. */ | |
198 | - if ((me = strrchr(argv[0], '/')) != (char *)NULL) | |
199 | - me++; | |
200 | - else | |
201 | - me = argv[0]; | |
202 | - if (argc > 1 && !strcmp(argv[1], "-c")) { | |
203 | - cmode = 1; | |
204 | - is_defined |= MODE_STANDALONE; | |
205 | - argc--; | |
206 | - argv++; | |
207 | - } | |
208 | - switch (argc) { | |
209 | - case 1: | |
210 | - break; | |
211 | - case 2: | |
212 | - case 3: | |
213 | - if (strcmp(argv[1], "-")) { | |
214 | - if (freopen(argv[1], "r", stdin) == (FILE *)NULL) { | |
215 | - perror(argv[1]); | |
216 | - exit(1); | |
217 | - } | |
218 | - filename = argv[1]; | |
219 | - } | |
220 | - break; | |
221 | - default: | |
222 | - usage(); | |
223 | - } | |
224 | - | |
225 | - is_undefined = MODE_COLOR | (~is_defined & MODEMASK); | |
226 | - | |
227 | - /* Do #ifdef, comment and whitespace processing first. */ | |
228 | - u = tmpfile(); | |
229 | - if (u == NULL) { | |
230 | - perror("tmpfile"); | |
231 | - exit(1); | |
232 | - } | |
233 | - | |
234 | - while (fgets(buf, BUFSZ, stdin) != (char *)NULL) { | |
235 | - char *s = buf; | |
236 | - int sl; | |
237 | - int i; | |
238 | - | |
239 | - lno++; | |
240 | - | |
241 | - /* Skip leading white space. */ | |
242 | - while (isspace(*s)) | |
243 | - s++; | |
244 | - if (cmode && | |
245 | - (!strncmp(s, "x3270.", 6) || !strncmp(s, "x3270*", 6))) { | |
246 | - s += 6; | |
247 | - } | |
248 | - | |
249 | - /* Remove trailing white space. */ | |
250 | - while ((sl = strlen(s)) && isspace(s[sl-1])) | |
251 | - s[sl-1] = '\0'; | |
252 | - | |
253 | - /* Skip comments and empty lines. */ | |
254 | - if ((!last_continue && *s == '!') || !*s) | |
255 | - continue; | |
256 | - | |
257 | - /* Check for simple if[n]defs. */ | |
258 | - if (*s == '#') { | |
259 | - int ifnd = 1; | |
260 | - | |
261 | - if (!strncmp(s, "#ifdef ", 7) || | |
262 | - !(ifnd = strncmp(s, "#ifndef ", 8))) { | |
263 | - char *tk; | |
264 | - | |
265 | - if (ssp >= SSSZ) { | |
266 | - fprintf(stderr, | |
267 | - "%s, line %d: Stack overflow\n", | |
268 | - filename, lno); | |
269 | - exit(1); | |
270 | - } | |
271 | - ss[ssp].ifdefs = 0L; | |
272 | - ss[ssp].ifndefs = 0L; | |
273 | - ss[ssp].lno = lno; | |
274 | - | |
275 | - tk = s + 7 + !ifnd; | |
276 | - for (i = 0; i < NPARTS; i++) { | |
277 | - if (!strcmp(tk, parts[i].name)) { | |
278 | - if (!ifnd) | |
279 | - ss[ssp++].ifndefs = | |
280 | - parts[i].mask; | |
281 | - else | |
282 | - ss[ssp++].ifdefs = | |
283 | - parts[i].mask; | |
284 | - break; | |
285 | - } | |
286 | - } | |
287 | - if (i >= NPARTS) { | |
288 | - fprintf(stderr, | |
289 | - "%s, line %d: Unknown condition\n", | |
290 | - filename, lno); | |
291 | - exit(1); | |
292 | - } | |
293 | - continue; | |
294 | - } | |
295 | - | |
296 | - else if (!strcmp(s, "#else")) { | |
297 | - unsigned long tmp; | |
298 | - | |
299 | - if (!ssp) { | |
300 | - fprintf(stderr, | |
301 | - "%s, line %d: Missing #if[n]def\n", | |
302 | - filename, lno); | |
303 | - exit(1); | |
304 | - } | |
305 | - tmp = ss[ssp-1].ifdefs; | |
306 | - ss[ssp-1].ifdefs = ss[ssp-1].ifndefs; | |
307 | - ss[ssp-1].ifndefs = tmp; | |
308 | - } else if (!strcmp(s, "#endif")) { | |
309 | - if (!ssp) { | |
310 | - fprintf(stderr, | |
311 | - "%s, line %d: Missing #if[n]def\n", | |
312 | - filename, lno); | |
313 | - exit(1); | |
314 | - } | |
315 | - ssp--; | |
316 | - } else { | |
317 | - fprintf(stderr, | |
318 | - "%s, line %d: Unrecognized # directive\n", | |
319 | - filename, lno); | |
320 | - exit(1); | |
321 | - } | |
322 | - continue; | |
323 | - } | |
324 | - | |
325 | - /* Figure out if there's anything to emit. */ | |
326 | - | |
327 | - /* First, look for contradictions. */ | |
328 | - ifdefs = 0; | |
329 | - ifndefs = 0; | |
330 | - for (i = 0; i < ssp; i++) { | |
331 | - ifdefs |= ss[i].ifdefs; | |
332 | - ifndefs |= ss[i].ifndefs; | |
333 | - } | |
334 | - if (ifdefs & ifndefs) { | |
335 | -#ifdef DEBUG_IFDEFS | |
336 | - fprintf(stderr, "contradiction, line %d\n", lno); | |
337 | -#endif | |
338 | - continue; | |
339 | - } | |
340 | - | |
341 | - /* Then, apply the actual values. */ | |
342 | - if (ifdefs && (ifdefs & is_defined) != ifdefs) { | |
343 | -#ifdef DEBUG_IFDEFS | |
344 | - fprintf(stderr, "ifdef failed, line %d\n", lno); | |
345 | -#endif | |
346 | - continue; | |
347 | - } | |
348 | - if (ifndefs && (ifndefs & is_undefined) != ifndefs) { | |
349 | -#ifdef DEBUG_IFDEFS | |
350 | - fprintf(stderr, "ifndef failed, line %d\n", lno); | |
351 | -#endif | |
352 | - continue; | |
353 | - } | |
354 | - | |
355 | - /* Emit the text. */ | |
356 | - fprintf(u, "%lx %lx %d\n%s\n", ifdefs, ifndefs, lno, s); | |
357 | - last_continue = strlen(s) > 0 && s[strlen(s) - 1] == '\\'; | |
358 | - } | |
359 | - if (ssp) { | |
360 | - fprintf(stderr, "%d missing #endif(s) in %s\n", ssp, filename); | |
361 | - fprintf(stderr, "last #ifdef was at line %u\n", ss[ssp-1].lno); | |
362 | - exit(1); | |
363 | - } | |
364 | - | |
365 | - /* Re-scan, emitting code this time. */ | |
366 | - rewind(u); | |
367 | - t = tmpfile(); | |
368 | - if (t == NULL) { | |
369 | - perror("tmpfile"); | |
370 | - exit(1); | |
371 | - } | |
372 | - if (!cmode) { | |
373 | - tc = tmpfile(); | |
374 | - if (tc == NULL) { | |
375 | - perror("tmpfile"); | |
376 | - exit(1); | |
377 | - } | |
378 | - tm = tmpfile(); | |
379 | - if (tm == NULL) { | |
380 | - perror("tmpfile"); | |
381 | - exit(1); | |
382 | - } | |
383 | - } | |
384 | - | |
385 | - /* Emit the initial boilerplate. */ | |
386 | - fprintf(t, "/* This file was created automatically from %s by mkfb. */\n\n", | |
387 | - filename); | |
388 | - if (cmode) { | |
389 | - fprintf(t, "#include \"private.h\"\n"); | |
390 | - fprintf(t, "static unsigned char fsd[] = {\n"); | |
391 | - } else { | |
392 | - fprintf(t, "unsigned char common_fallbacks[] = {\n"); | |
393 | - fprintf(tc, "unsigned char color_fallbacks[] = {\n"); | |
394 | - fprintf(tm, "unsigned char mono_fallbacks[] = {\n"); | |
395 | - } | |
396 | - | |
397 | - /* Scan the file, emitting the fsd array and creating the indices. */ | |
398 | - while (fscanf(u, "%lx %lx %d\n", &ifdefs, &ifndefs, &lno) == 3) { | |
399 | - char *s = buf; | |
400 | - char c; | |
401 | - int white; | |
402 | - FILE *t_this = t; | |
403 | - int ix = 0; | |
404 | - | |
405 | - if (fgets(buf, BUFSZ, u) == NULL) | |
406 | - break; | |
407 | - if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n') | |
408 | - buf[strlen(buf)-1] = '\0'; | |
409 | - | |
410 | -#if 0 | |
411 | - fprintf(stderr, "%lx %lx %d %s\n", ifdefs, ifndefs, lno, buf); | |
412 | -#endif | |
413 | - | |
414 | - /* Add array offsets. */ | |
415 | - if (cmode) { | |
416 | - /* Ignore color. Accumulate offsets into an array. */ | |
417 | - if (n_fallbacks >= ARRSZ) { | |
418 | - fprintf(stderr, "%s, line %d: Buffer overflow\n", filename, lno); | |
419 | - exit(1); | |
420 | - } | |
421 | - aix[n_fallbacks] = cc; | |
422 | - xlno[n_fallbacks++] = lno; | |
423 | - } else { | |
424 | - /* Use color to decide which file to write into. */ | |
425 | - if (!(ifdefs & MODE_COLOR) && !(ifndefs & MODE_COLOR)) { | |
426 | - /* Both. */ | |
427 | - t_this = t; | |
428 | - ix = 0; | |
429 | - } else if (ifdefs & MODE_COLOR) { | |
430 | - /* Just color. */ | |
431 | - t_this = tc; | |
432 | - ix = 1; | |
433 | - } else { | |
434 | - /* Just mono. */ | |
435 | - t_this = tm; | |
436 | - ix = 2; | |
437 | - } | |
438 | - } | |
439 | - | |
440 | - continued = 0; | |
441 | - white = 0; | |
442 | - while ((c = *s++) != '\0') { | |
443 | - if (c == ' ' || c == '\t') | |
444 | - white++; | |
445 | - else if (white) { | |
446 | - emit(t_this, ix, ' '); | |
447 | - cc++; | |
448 | - white = 0; | |
449 | - } | |
450 | - switch (c) { | |
451 | - case ' ': | |
452 | - case '\t': | |
453 | - break; | |
454 | - case '#': | |
455 | - if (!cmode) { | |
456 | - emit(t_this, ix, '\\'); | |
457 | - emit(t_this, ix, '#'); | |
458 | - cc += 2; | |
459 | - } else { | |
460 | - emit(t_this, ix, c); | |
461 | - cc++; | |
462 | - } | |
463 | - break; | |
464 | - case '\\': | |
465 | - if (*s == '\0') { | |
466 | - continued = 1; | |
467 | - break; | |
468 | - } else if (cmode) { | |
469 | - switch ((c = *s++)) { | |
470 | - case 't': | |
471 | - c = '\t'; | |
472 | - break; | |
473 | - case 'n': | |
474 | - c = '\n'; | |
475 | - break; | |
476 | - default: | |
477 | - break; | |
478 | - } | |
479 | - } | |
480 | - /* else fall through */ | |
481 | - default: | |
482 | - emit(t_this, ix, c); | |
483 | - cc++; | |
484 | - break; | |
485 | - } | |
486 | - } | |
487 | - if (white) { | |
488 | - emit(t_this, ix, ' '); | |
489 | - cc++; | |
490 | - white = 0; | |
491 | - } | |
492 | - if (!continued) { | |
493 | - if (cmode) | |
494 | - emit(t_this, ix, 0); | |
495 | - else | |
496 | - emit(t_this, ix, '\n'); | |
497 | - cc++; | |
498 | - } | |
499 | - } | |
500 | - fclose(u); | |
501 | - if (cmode) | |
502 | - fprintf(t, "};\n\n"); | |
503 | - else { | |
504 | - emit(t, 0, 0); | |
505 | - fprintf(t, "};\n\n"); | |
506 | - emit(tc, 0, 0); | |
507 | - fprintf(tc, "};\n\n"); | |
508 | - emit(tm, 0, 0); | |
509 | - fprintf(tm, "};\n\n"); | |
510 | - } | |
511 | - | |
512 | - | |
513 | - /* Open the output file. */ | |
514 | - if (argc == 3) { | |
515 | - o = fopen(argv[2], "w"); | |
516 | - if (o == NULL) { | |
517 | - perror(argv[2]); | |
518 | - exit(1); | |
519 | - } | |
520 | - } else | |
521 | - o = stdout; | |
522 | - | |
523 | - /* Copy tmp to output. */ | |
524 | - rewind(t); | |
525 | - if (!cmode) { | |
526 | - rewind(tc); | |
527 | - rewind(tm); | |
528 | - } | |
529 | - while (fgets(buf, sizeof(buf), t) != NULL) { | |
530 | - fprintf(o, "%s", buf); | |
531 | - } | |
532 | - if (!cmode) { | |
533 | - while (fgets(buf, sizeof(buf), tc) != NULL) { | |
534 | - fprintf(o, "%s", buf); | |
535 | - } | |
536 | - while (fgets(buf, sizeof(buf), tm) != NULL) { | |
537 | - fprintf(o, "%s", buf); | |
538 | - } | |
539 | - } | |
540 | - | |
541 | - if (cmode) { | |
542 | - /* Emit the fallback array. */ | |
543 | - fprintf(o, "String fallbacks[%u] = {\n", n_fallbacks + 1); | |
544 | - for (i = 0; i < n_fallbacks; i++) { | |
545 | - fprintf(o, "\t(String)&fsd[%u], /* line %u */\n", | |
546 | - aix[i], | |
547 | - xlno[i]); | |
548 | - } | |
549 | - fprintf(o, "\t(String)NULL\n};\n\n"); | |
550 | - | |
551 | - /* Emit some test code. */ | |
552 | - fprintf(o, "%s", "#if defined(DUMP) /*[*/\n\ | |
553 | -#include <stdio.h>\n\ | |
554 | -int\n\ | |
555 | -main(int argc, char *argv[])\n\ | |
556 | -{\n\ | |
557 | - int i;\n\ | |
558 | -\n\ | |
559 | - for (i = 0; fallbacks[i] != NULL; i++)\n\ | |
560 | - printf(\"%d: %s\\n\", i, fallbacks[i]);\n\ | |
561 | - return 0;\n\ | |
562 | -}\n"); | |
563 | - fprintf(o, "#endif /*]*/\n\n"); | |
564 | - } | |
565 | - | |
566 | - if (o != stdout) | |
567 | - fclose(o); | |
568 | - fclose(t); | |
569 | - if (!cmode) { | |
570 | - fclose(tc); | |
571 | - fclose(tm); | |
572 | - } | |
573 | - | |
574 | - return 0; | |
575 | -} | |
576 | - | |
577 | -static int n_out[3] = { 0, 0, 0 }; | |
578 | - | |
579 | -void | |
580 | -emit(FILE *t, int ix, char c) | |
581 | -{ | |
582 | - if (n_out[ix] >= 19) { | |
583 | - fprintf(t, "\n"); | |
584 | - n_out[ix] = 0; | |
585 | - } | |
586 | - fprintf(t, "%3d,", (unsigned char)c); | |
587 | - n_out[ix]++; | |
588 | -} | |
589 | - | |
590 | -#if defined(_WIN32) | |
591 | -FILE * w32_tmpfile( void ) | |
592 | -{ | |
593 | - char *dir; | |
594 | - char *xtemplate; | |
595 | - DWORD retval; | |
596 | - size_t len; | |
597 | - int fd; | |
598 | - FILE *file = NULL; | |
599 | - | |
600 | - dir = (char *) malloc(PATH_MAX); | |
601 | - xtemplate = (char *) malloc(PATH_MAX); | |
602 | - | |
603 | - /* Find Windows temporary file directory. | |
604 | - We provide this as the directory argument to path_search | |
605 | - because Windows defines P_tmpdir to "\\" and will therefore | |
606 | - try to put all temporary files in the root (unless $TMPDIR | |
607 | - is set). */ | |
608 | - retval = GetTempPath (PATH_MAX, dir); | |
609 | - if (retval == 0 || retval >= PATH_MAX - 1) | |
610 | - goto done; | |
611 | - | |
612 | - do | |
613 | - { | |
614 | - char *tempname = tempnam(dir,"XXXXXX"); | |
615 | - if(!tempname) | |
616 | - goto done; | |
617 | - | |
618 | - fd = _open (tempname,_O_BINARY | _O_CREAT | _O_TEMPORARY | _O_EXCL | _O_RDWR,_S_IREAD | _S_IWRITE); | |
619 | - } | |
620 | - while (fd < 0 && errno == EEXIST); | |
621 | - | |
622 | - if (fd < 0) | |
623 | - goto done; | |
624 | - | |
625 | - file = _fdopen (fd, "w+b"); | |
626 | - if (file == NULL) | |
627 | - { | |
628 | - int save_errno = errno; | |
629 | - _close (fd); | |
630 | - errno = save_errno; | |
631 | - } | |
632 | - | |
633 | - done: | |
634 | - free(xtemplate); | |
635 | - free(dir); | |
636 | - return file; | |
637 | -} | |
638 | -#elif defined( __APPLE__ ) | |
639 | -FILE * osx_tmpfile( void ) | |
640 | -{ | |
641 | - int fd = -1; | |
642 | - FILE *file = NULL; | |
643 | - | |
644 | - do | |
645 | - { | |
646 | - char *tempname = tempnam(NULL,"XXXXXX"); | |
647 | - if(!tempname) | |
648 | - return NULL; | |
649 | - fd = open (tempname,O_CREAT | O_EXCL | O_RDWR,S_IREAD | S_IWRITE); | |
650 | - } while (fd < 0 && errno == EEXIST); | |
651 | - | |
652 | - | |
653 | - file = fdopen (fd, "w+b"); | |
654 | - if (file == NULL) | |
655 | - { | |
656 | - int save_errno = errno; | |
657 | - close (fd); | |
658 | - errno = save_errno; | |
659 | - } | |
660 | - | |
661 | - return file; | |
662 | -} | |
663 | - | |
664 | -#endif // _WIN32 |
src/lib3270/session.c
... | ... | @@ -185,6 +185,18 @@ static void nop_int(H3270 *session, int width) |
185 | 185 | return; |
186 | 186 | } |
187 | 187 | |
188 | +#ifdef HAVE_LIBSSL | |
189 | +static void set_peer_certificate(const X509 *cert unused) | |
190 | +{ | |
191 | + | |
192 | +} | |
193 | +#else | |
194 | +static void set_peer_certificate)(const void *cert unused) | |
195 | +{ | |
196 | + | |
197 | +} | |
198 | +#endif // HAVE_LIBSSL | |
199 | + | |
188 | 200 | static void lib3270_session_init(H3270 *hSession, const char *model, const char *charset) |
189 | 201 | { |
190 | 202 | int f; |
... | ... | @@ -195,28 +207,29 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char |
195 | 207 | lib3270_set_host_charset(hSession,charset); |
196 | 208 | |
197 | 209 | // Default calls |
198 | - hSession->cbk.write = lib3270_sock_send; | |
199 | - hSession->cbk.disconnect = lib3270_sock_disconnect; | |
200 | - hSession->cbk.update = update_char; | |
201 | - hSession->cbk.update_model = update_model; | |
202 | - hSession->cbk.update_cursor = update_cursor; | |
203 | - hSession->cbk.set_selection = nop_char; | |
204 | - hSession->cbk.ctlr_done = nop; | |
205 | - hSession->cbk.changed = changed; | |
206 | - hSession->cbk.erase = screen_disp; | |
207 | - hSession->cbk.suspend = nop; | |
208 | - hSession->cbk.resume = screen_disp; | |
209 | - hSession->cbk.update_oia = update_oia; | |
210 | - hSession->cbk.update_selection = update_selection; | |
211 | - hSession->cbk.cursor = set_cursor; | |
212 | - hSession->cbk.message = message; | |
213 | - hSession->cbk.update_ssl = update_ssl; | |
214 | - hSession->cbk.display = screen_disp; | |
215 | - hSession->cbk.set_width = nop_int; | |
216 | - hSession->cbk.update_status = (void (*)(H3270 *, LIB3270_MESSAGE)) nop_int; | |
217 | - hSession->cbk.autostart = nop; | |
218 | - hSession->cbk.set_timer = set_timer; | |
219 | - hSession->cbk.print = print; | |
210 | + hSession->cbk.write = lib3270_sock_send; | |
211 | + hSession->cbk.disconnect = lib3270_sock_disconnect; | |
212 | + hSession->cbk.update = update_char; | |
213 | + hSession->cbk.update_model = update_model; | |
214 | + hSession->cbk.update_cursor = update_cursor; | |
215 | + hSession->cbk.set_selection = nop_char; | |
216 | + hSession->cbk.ctlr_done = nop; | |
217 | + hSession->cbk.changed = changed; | |
218 | + hSession->cbk.erase = screen_disp; | |
219 | + hSession->cbk.suspend = nop; | |
220 | + hSession->cbk.resume = screen_disp; | |
221 | + hSession->cbk.update_oia = update_oia; | |
222 | + hSession->cbk.update_selection = update_selection; | |
223 | + hSession->cbk.cursor = set_cursor; | |
224 | + hSession->cbk.message = message; | |
225 | + hSession->cbk.update_ssl = update_ssl; | |
226 | + hSession->cbk.display = screen_disp; | |
227 | + hSession->cbk.set_width = nop_int; | |
228 | + hSession->cbk.update_status = (void (*)(H3270 *, LIB3270_MESSAGE)) nop_int; | |
229 | + hSession->cbk.autostart = nop; | |
230 | + hSession->cbk.set_timer = set_timer; | |
231 | + hSession->cbk.print = print; | |
232 | + hSession->cbk.set_peer_certificate = set_peer_certificate; | |
220 | 233 | |
221 | 234 | // Set the defaults. |
222 | 235 | hSession->extended = 1; | ... | ... |