Commit 4a1f3570c1ecef915166671eec3b111a7bba6569

Authored by perry.werneck@gmail.com
1 parent 2980094c

Implementando biblioteca básica para android

src/android/jni/Android.mk
... ... @@ -26,11 +26,14 @@
26 26 LOCAL_PATH := $(call my-dir)
27 27  
28 28 include $(CLEAR_VARS)
29   -include ../lib3270/sources.mak
  29 +
  30 +# include ../lib3270/sources.mak
  31 +TERMINAL_SOURCES= bounds.c XtGlue.c ctlr.c util.c toggles.c screen.c selection.c kybd.c telnet.c \
  32 + host.c sf.c ansi.c log.c resolver.c xio.c tables.c
30 33  
31 34 LOCAL_CFLAGS=-I../include
32 35 LOCAL_MODULE := lib3270
33   -LOCAL_SRC_FILES := $(foreach SRC, $(SOURCES), ../../lib3270/$(SRC))
  36 +LOCAL_SRC_FILES := $(foreach SRC, $(TERMINAL_SOURCES), ../../lib3270/$(SRC))
34 37  
35 38 include $(BUILD_SHARED_LIBRARY)
36 39  
... ...
src/include/lib3270/config.h.in
... ... @@ -44,17 +44,20 @@
44 44  
45 45 #undef HAVE_GNOME
46 46  
47   - #undef HAVE_LIBSSL
48   -
49 47 /* Optional parts. */
50   - #define X3270_TRACE
51 48 #undef X3270_DBCS
52 49 #undef X3270_SCRIPT
53 50  
54 51 #define X3270_TN3270E
55 52 #define X3270_ANSI
56 53 #define X3270_APL
  54 +
  55 +#ifndef ANDROID
  56 + #undef HAVE_LIBSSL
  57 + #define X3270_TRACE
57 58 #define X3270_FT
  59 +#endif // ANDROID
  60 +
58 61 /* #define X3270_PRINTER */
59 62  
60 63 #undef HAVE_IGEMAC
... ...
src/include/lib3270/session.h
... ... @@ -80,6 +80,8 @@
80 80 int bgthread : 1; /**< Running on a background thread ? */
81 81 int selected : 1; /**< Has selected region? */
82 82 int rectsel : 1; /**< Selected region is a rectangle ? */
  83 + int vcontrol : 1; /**< Visible control ? */
  84 +
83 85  
84 86 LIB3270_SSL_STATE secure;
85 87  
... ...
src/lib3270/XtGlue.c
... ... @@ -34,15 +34,18 @@
34 34  
35 35 #include "globals.h"
36 36 #include "api.h"
37   -#if defined(_WIN32) /*[*/
38   -#include "appres.h"
39   -#include "trace_dsc.h"
40   -#include "xioc.h"
41   -#endif /*]*/
  37 +#include <malloc.h>
  38 +
  39 +#if defined(_WIN32)
  40 + #include "appres.h"
  41 + #include "trace_dsc.h"
  42 + #include "xioc.h"
  43 +#endif
  44 +
42 45 #include "utilc.h"
43 46  
44 47 #include <stdio.h>
45   -#include <stdlib.h>
  48 +// #include <stdlib.h>
46 49 #include <string.h>
47 50 #include <errno.h>
48 51 #include "X11keysym.h"
... ... @@ -78,6 +81,10 @@
78 81  
79 82 #define MILLION 1000000L
80 83  
  84 +/*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/
  85 +
  86 + H3270 h3270;
  87 +
81 88 /*---[ Callbacks ]------------------------------------------------------------------------------------------*/
82 89  
83 90 static void DefaultRemoveTimeOut(unsigned long timer);
... ...
src/lib3270/ctlr.c
... ... @@ -477,7 +477,7 @@ void ctlr_erase(H3270 *session, int alt)
477 477 /* Going from maximum to 24x80. */
478 478 if (session->maxROWS > 24 || session->maxCOLS > 80)
479 479 {
480   - if (visible_control)
  480 + if(session->vcontrol)
481 481 {
482 482 ctlr_blanks();
483 483 screen_disp(session);
... ... @@ -2282,7 +2282,7 @@ ps_process(void)
2282 2282 ;
2283 2283 // sms_continue();
2284 2284  
2285   -#if defined(X3270_FT) /*[*/
  2285 +#if defined(X3270_FT)
2286 2286 /* Process file transfers. */
2287 2287 if (lib3270_get_ft_state(&h3270) != LIB3270_FT_STATE_NONE && /* transfer in progress */
2288 2288 h3270.formatted && /* screen is formatted */
... ... @@ -2292,7 +2292,7 @@ ps_process(void)
2292 2292 h3270.ea_buf[1919].fa && FA_IS_SKIP(h3270.ea_buf[1919].fa)) {
2293 2293 ft_cut_data();
2294 2294 }
2295   -#endif /*]*/
  2295 +#endif
2296 2296 }
2297 2297  
2298 2298 /*
... ... @@ -2666,9 +2666,10 @@ ctlr_shrink(void)
2666 2666 {
2667 2667 int baddr;
2668 2668  
2669   - for (baddr = 0; baddr < h3270.rows*h3270.cols; baddr++) {
  2669 + for (baddr = 0; baddr < h3270.rows*h3270.cols; baddr++)
  2670 + {
2670 2671 if (!h3270.ea_buf[baddr].fa)
2671   - h3270.ea_buf[baddr].cc = visible_control? EBC_space : EBC_null;
  2672 + h3270.ea_buf[baddr].cc = h3270.vcontrol ? EBC_space : EBC_null;
2672 2673 }
2673 2674 ALL_CHANGED;
2674 2675 screen_disp(&h3270);
... ...
src/lib3270/ft.c
... ... @@ -36,6 +36,7 @@
36 36 #include "globals.h"
37 37  
38 38 #include <errno.h>
  39 +#include <malloc.h>
39 40  
40 41 #include "appres.h"
41 42 #include "actionsc.h"
... ...
src/lib3270/ft_cut.c
... ... @@ -36,6 +36,7 @@
36 36 */
37 37  
38 38 #include <errno.h>
  39 +#include <malloc.h>
39 40  
40 41 #include "globals.h"
41 42  
... ...
src/lib3270/ft_dft.c
... ... @@ -55,6 +55,7 @@
55 55 #include "utilc.h"
56 56  
57 57 #include <errno.h>
  58 +#include <malloc.h>
58 59  
59 60 extern unsigned char aid;
60 61  
... ...
src/lib3270/globals.h
... ... @@ -106,7 +106,7 @@
106 106 * Prerequisite #includes.
107 107 */
108 108 #include <stdio.h> /* Unix standard I/O library */
109   -#include <stdlib.h> /* Other Unix library functions */
  109 +// #include <stdlib.h> /* Other Unix library functions */
110 110 #include <unistd.h> /* Unix system calls */
111 111 #include <ctype.h> /* Character classes */
112 112 #include <string.h> /* String manipulations */
... ... @@ -248,7 +248,7 @@ LIB3270_INTERNAL Boolean *standard_font;
248 248 LIB3270_INTERNAL Boolean std_ds_host;
249 249 LIB3270_INTERNAL char *termtype;
250 250 LIB3270_INTERNAL Widget toplevel;
251   -LIB3270_INTERNAL Boolean visible_control;
  251 +// LIB3270_INTERNAL Boolean visible_control;
252 252 LIB3270_INTERNAL int *xtra_width;
253 253  
254 254 /*
... ...
src/lib3270/glue.c
... ... @@ -100,7 +100,6 @@
100 100 #define LAST_ARG "--"
101 101  
102 102 /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/
103   - H3270 h3270;
104 103 const char * programname;
105 104 AppRes appres;
106 105 int children = 0;
... ... @@ -798,8 +797,6 @@ int *char_width = &amp;cw;
798 797 static int ch = 7;
799 798 int *char_height = &ch;
800 799  
801   -Boolean visible_control = False;
802   -
803 800 // Boolean flipped = False;
804 801  
805 802 /* Replacements for functions in popups.c. */
... ...
src/lib3270/host.c
... ... @@ -52,6 +52,7 @@
52 52 #include "xioc.h"
53 53  
54 54 #include <errno.h>
  55 +#include <malloc.h>
55 56  
56 57 #define RECONNECT_MS 2000 /* 2 sec before reconnecting to host */
57 58 #define RECONNECT_ERR_MS 5000 /* 5 sec before reconnecting to host */
... ...
src/lib3270/init.c
... ... @@ -35,6 +35,8 @@
35 35 #include "appres.h"
36 36 #include "charsetc.h"
37 37  
  38 +#include <malloc.h>
  39 +
38 40 /*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/
39 41  
40 42 static int parse_model_number(H3270 *session, const char *m);
... ...
src/lib3270/paste.c
... ... @@ -45,9 +45,10 @@
45 45 #endif
46 46  
47 47 #include <fcntl.h>
  48 +#include <malloc.h>
  49 +
48 50 #include "3270ds.h"
49 51 #include "appres.h"
50   -// #include "ctlr.h"
51 52 #include "resources.h"
52 53  
53 54 #include "actionsc.h"
... ...
src/lib3270/proxy.c
... ... @@ -46,6 +46,8 @@
46 46 #include <winsock2.h>
47 47 #include <ws2tcpip.h>
48 48 #else /*][*/
  49 +
  50 +#include <malloc.h>
49 51 #include <sys/socket.h>
50 52 #include <sys/ioctl.h>
51 53 #include <netinet/in.h>
... ...
src/lib3270/rpq.c
... ... @@ -48,6 +48,8 @@
48 48 #include <netdb.h>
49 49 #endif /*]*/
50 50  
  51 +#include <stdlib.h>
  52 +
51 53 #include "api.h"
52 54  
53 55 #include <assert.h>
... ...
src/lib3270/selection.c
... ... @@ -29,6 +29,7 @@
29 29  
30 30 #include "globals.h"
31 31 #include "appres.h"
  32 + #include <malloc.h>
32 33 #include <lib3270.h>
33 34 #include <lib3270/session.h>
34 35 #include <lib3270/selection.h>
... ...
src/lib3270/telnet.c
... ... @@ -38,10 +38,14 @@
38 38 */
39 39  
40 40 #if defined(_WIN32)
41   - #include <winsock2.h>
42   - #include <windows.h>
  41 + #include <winsock2.h>
  42 + #include <windows.h>
43 43 #endif
44 44  
  45 +#ifndef ANDROID
  46 + #include <stdlib.h>
  47 +#endif // !ANDROID
  48 +
45 49 #include <lib3270/config.h>
46 50 #if defined(HAVE_LIBSSL)
47 51 #include <openssl/ssl.h>
... ... @@ -533,9 +537,12 @@ int net_connect(H3270 *session, const char *host, char *portname, Boolean ls, Bo
533 537  
534 538 /* get the passthru host and port number */
535 539 if (session->passthru_host) {
536   - const char *hn;
  540 + const char *hn = CN;
537 541  
  542 +#ifndef ANDROID
538 543 hn = getenv("INTERNET_HOST");
  544 +#endif // ANDROID
  545 +
539 546 if (hn == CN)
540 547 hn = "internet-gateway";
541 548  
... ... @@ -3432,7 +3439,7 @@ int net_getsockname(const H3270 *session, void *buf, int *len)
3432 3439 char *
3433 3440 net_proxy_type(void)
3434 3441 {
3435   - if (proxy_type > 0)
  3442 + if (proxy_type > 0)
3436 3443 return proxy_type_name(proxy_type);
3437 3444 else
3438 3445 return NULL;
... ...
src/lib3270/toggle.h
... ... @@ -55,7 +55,7 @@
55 55 #define MARGINED_PASTE LIB3270_TOGGLE_MARGINED_PASTE
56 56 #define RECTANGLE_SELECT LIB3270_TOGGLE_RECTANGLE_SELECT
57 57 #define CROSSHAIR LIB3270_TOGGLE_CROSSHAIR
58   - #define VISIBLE_CONTROL LIB3270_TOGGLE_VISIBLE_CONTROL
  58 +// #define VISIBLE_CONTROL LIB3270_TOGGLE_VISIBLE_CONTROL
59 59 #define AID_WAIT LIB3270_TOGGLE_AID_WAIT
60 60 #define FULL_SCREEN LIB3270_TOGGLE_FULL_SCREEN
61 61 #define RECONNECT LIB3270_TOGGLE_RECONNECT
... ...
src/lib3270/util.c
... ... @@ -53,6 +53,10 @@
53 53 #include <pwd.h>
54 54 #endif // _WIN32
55 55  
  56 +#ifndef ANDROID
  57 + #include <stdlib.h>
  58 +#endif // !ANDROID
  59 +
56 60 #include <stdarg.h>
57 61 #include "resources.h"
58 62  
... ... @@ -516,7 +520,7 @@ get_message(const char *key)
516 520 #endif
517 521 */
518 522  
519   -#define ex_getenv getenv
  523 +// #define ex_getenv getenv
520 524  
521 525 /* Variable and tilde substitution functions. */
522 526 static char *
... ... @@ -602,7 +606,10 @@ var_subst(const char *s)
602 606 vn = Malloc(vn_len + 1);
603 607 (void) strncpy(vn, vn_start, vn_len);
604 608 vn[vn_len] = '\0';
605   - if ((vv = ex_getenv(vn))) {
  609 +
  610 +#ifndef ANDROID
  611 + if((vv = getenv(vn)))
  612 + {
606 613 *o = '\0';
607 614 o_len = o_len
608 615 - 1 /* '$' */
... ... @@ -615,6 +622,8 @@ var_subst(const char *s)
615 622 (void) strcpy(o, vv);
616 623 o += strlen(vv);
617 624 }
  625 +#endif // !ANDROID
  626 +
618 627 Free(vn);
619 628 if (state == VS_VNB) {
620 629 state = VS_BASE;
... ...