diff --git a/Makefile.in b/Makefile.in index 8e5f283..9c406cd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -113,73 +113,102 @@ include sources.mak #---[ Misc targets ]----------------------------------------------------------- -Release: $(BINRLS)/lib3270@DLLEXT@ +Release: \ + $(BINRLS)/lib3270@DLLEXT@ + +install: \ + Release -install: Release $(MKDIR) $(DESTDIR)$(libdir) $(INSTALL_PROGRAM) $(BINRLS)/lib3270@DLLEXT@.$(PACKAGE_VERSION) $(DESTDIR)$(libdir) $(LN_S) lib3270@DLLEXT@.$(PACKAGE_VERSION) $(DESTDIR)$(libdir)/lib3270@DLLEXT@.@MAJOR_VERSION@ $(LN_S) lib3270@DLLEXT@.@MAJOR_VERSION@ $(DESTDIR)$(libdir)/lib3270@DLLEXT@ -Debug: $(BINDBG)/lib3270@DLLEXT@ +Debug: \ + $(BINDBG)/lib3270@DLLEXT@ + +$(BINDBG)/lib3270@DLLEXT@: \ + $(BINDBG)/lib3270@DLLEXT@.$(PACKAGE_VERSION) -$(BINDBG)/lib3270@DLLEXT@: $(BINDBG)/lib3270@DLLEXT@.$(PACKAGE_VERSION) @rm -f $@ @cd $(BINDBG) && $(LN_S) lib3270@DLLEXT@.$(PACKAGE_VERSION) lib3270@DLLEXT@ -$(BINDBG)/lib3270@DLLEXT@.$(PACKAGE_VERSION): $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) +$(BINDBG)/lib3270@DLLEXT@.$(PACKAGE_VERSION): \ + $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) + @echo " CCLD `basename $@`" @$(MKDIR) `dirname $@` @$(LD) $(DLL_FLAGS) $(LDFLAGS) @LDSOFLAGS@ @LDLIBFLAGS@ -o $@ $^ $(LIBS) -$(BINRLS)/lib3270@DLLEXT@: $(BINRLS)/lib3270@DLLEXT@.$(PACKAGE_VERSION) +$(BINRLS)/lib3270@DLLEXT@: \ + $(BINRLS)/lib3270@DLLEXT@.$(PACKAGE_VERSION) + @rm -f $@ @cd $(BINRLS) && $(LN_S) lib3270@DLLEXT@.$(PACKAGE_VERSION) lib3270@DLLEXT@ -$(BINRLS)/lib3270@DLLEXT@.$(PACKAGE_VERSION): $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC)@OBJEXT@) +$(BINRLS)/lib3270@DLLEXT@.$(PACKAGE_VERSION): \ + $(foreach SRC, $(basename $(SOURCES)), $(OBJRLS)/$(SRC)@OBJEXT@) + @echo " CCLD `basename $@`" @$(MKDIR) `dirname $@` @$(LD) $(DLL_FLAGS) $(LDFLAGS) @LDSOFLAGS@ @LDLIBFLAGS@ -o $@ $^ $(LIBS) @$(STRIP) $@ -$(BINDBG)/testprogram$(EXEEXT): $(OBJDBG)/testprogram.o $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) +$(BINDBG)/testprogram$(EXEEXT): \ + $(OBJDBG)/testprogram.o $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) + @echo " CCLD `basename $@`" @$(MKDIR) `dirname $@` @$(LD) -o $@ $^ $(LIBS) -$(BINDIR)/pot/lib3270.pot: $(foreach SRC, $(basename $(SOURCES)), $(TMPDIR)/pot/$(SRC).pot) +$(BINDIR)/pot/lib3270.pot: \ + $(foreach SRC, $(basename $(SOURCES)), $(TMPDIR)/pot/$(SRC).pot) + @rm -f $@ @mkdir -p `dirname $@` @$(MSGCAT) --sort-output $^ > $@ -test: $(BINDBG)/testprogram$(EXEEXT) +test: \ + $(BINDBG)/testprogram$(EXEEXT) + +run: \ + $(BINDBG)/testprogram$(EXEEXT) -run: $(BINDBG)/testprogram$(EXEEXT) ifeq ($(VALGRIND),no) @PATH="$(BINDIR)/Debug@DLLDIR@:$(PATH)" "$(BINDBG)/testprogram$(EXEEXT)" else @PATH="$(BINDIR)/Debug@DLLDIR@:$(PATH)" G_DEBUG=gc-friendly G_SLICE=always-malloc \$(VALGRIND) --leak-check=full --suppressions=valgrind.suppression --gen-suppressions=all $(BINDBG)/testprogram$(EXEEXT) endif -memchk: $(BINDBG)/testprogram$(EXEEXT) +memchk: \ + $(BINDBG)/testprogram$(EXEEXT) + ifeq ($(VALGRIND),no) @cd "$(ROOTDIR)" ; .bin/Debug/testprogram$(EXEEXT) else @cd "$(ROOTDIR)" ; \$(VALGRIND) --leak-check=full --gen-suppressions=all $(BINDBG)/testprogram$(EXEEXT) endif -version.c: ./mkversion.sh +version.c: \ + ./mkversion.sh + @echo " GEN $@" @chmod +x ./mkversion.sh @./mkversion.sh -fallbacks.c: X3270.xad mkfb.c +fallbacks.c: \ + X3270.xad mkfb.c + @echo " GEN $@" @$(MKDIR) $(BINDIR) @$(HOST_CC) -g -o $(BINDIR)/mkfb@EXEEXT@ mkfb.c @$(BINDIR)/mkfb@EXEEXT@ -c X3270.xad $@ -cleantest: clean +cleantest: \ + clean + +cleanDebug: \ + clean clean: @rm -fr .obj @@ -190,3 +219,4 @@ clean: @rm -f fallbacks.c @rm -f lib3270.pot @rm -fr debian + diff --git a/actions.c b/actions.c index bdf830e..85a6c7c 100644 --- a/actions.c +++ b/actions.c @@ -27,7 +27,7 @@ * */ -#include "globals.h" +#include "private.h" #include /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ diff --git a/ansi.c b/ansi.c index 5d81578..91b5b5f 100644 --- a/ansi.c +++ b/ansi.c @@ -34,7 +34,7 @@ * ANSI terminal emulation. */ -#include "globals.h" +#include "private.h" #if defined(X3270_ANSI) /*[*/ diff --git a/bounds.c b/bounds.c index 2f62e30..41d314f 100644 --- a/bounds.c +++ b/bounds.c @@ -30,7 +30,7 @@ * */ -#include "globals.h" +#include "private.h" /*--[ Implement ]------------------------------------------------------------------------------------*/ diff --git a/charset.c b/charset.c index ee3dd0f..3373c33 100644 --- a/charset.c +++ b/charset.c @@ -34,7 +34,7 @@ * This module handles character sets. */ -#include "globals.h" +#include "private.h" #include "X11keysym.h" #include diff --git a/connect.c b/connect.c index 59f32c5..193c92f 100644 --- a/connect.c +++ b/connect.c @@ -39,7 +39,7 @@ #endif -#include "globals.h" +#include "private.h" #include #if defined(_WIN32) diff --git a/ctlr.c b/ctlr.c index 997052d..3b21e79 100644 --- a/ctlr.c +++ b/ctlr.c @@ -37,7 +37,7 @@ * */ -#include "globals.h" +#include "private.h" #include #include #include "3270ds.h" diff --git a/ft.c b/ft.c index fcf1057..c7dab90 100644 --- a/ft.c +++ b/ft.c @@ -32,7 +32,7 @@ #include #include #include -#include "globals.h" +#include "private.h" #include #include diff --git a/ft_cut.c b/ft_cut.c index d5628bf..9cbc3d0 100644 --- a/ft_cut.c +++ b/ft_cut.c @@ -37,7 +37,7 @@ #include -#include "globals.h" +#include "private.h" #if defined(X3270_FT) /*[*/ diff --git a/ft_dft.c b/ft_dft.c index be6fadf..b846544 100644 --- a/ft_dft.c +++ b/ft_dft.c @@ -35,7 +35,7 @@ */ #include -#include "globals.h" +#include "private.h" #if defined(X3270_FT) /*[*/ diff --git a/globals.h b/globals.h deleted file mode 100644 index eea3ecb..0000000 --- a/globals.h +++ /dev/null @@ -1,271 +0,0 @@ -/* - * "Software G3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a - * aplicativos mainframe. Registro no INPI sob o nome G3270. - * - * Copyright (C) <2008> - * - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela - * Free Software Foundation. - * - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para - * obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin - * St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Este programa está nomeado como globals.h e possui 315 linhas de código. - * - * Contatos: - * - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) - * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) - * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) - * - */ - -/* Autoconf settings. */ -#include /* autoconf settings */ -#include /* lib3270 API calls and defs */ -#include "api.h" - -#if defined(X3270_TN3270E) && !defined(X3270_ANSI) /*[*/ - #define X3270_ANSI 1 /* RFC2355 requires NVT mode */ -#endif /*]*/ - -#if defined(HAVE_VASPRINTF) && !defined(_GNU_SOURCE) /*[*/ - #define _GNU_SOURCE /* vasprintf isn't POSIX */ -#endif /*]*/ - -/* - * gettext stuff - */ -#ifdef ANDROID - #undef HAVE_LIBINTL - #undef HAVE_LIBSSL -#endif - -#ifdef HAVE_LIBINTL - #include - #define _( x ) gettext(x) - #define N_( x ) x -#else - #define _( x ) x - #define N_( x ) x -#endif // HAVE_LIBINTL - -#define action_name(x) #x - -/* - * OS-specific #defines. Except for the blocking-connect workarounds, these - * should be replaced with autoconf probes as soon as possible. - */ - -/* - * BLOCKING_CONNECT_ONLY - * Use only blocking sockets. - */ -#if defined(sco) /*[*/ - #define BLOCKING_CONNECT_ONLY 1 -#endif /*]*/ - -#if defined(apollo) /*[*/ - #define BLOCKING_CONNECT_ONLY 1 -#endif /*]*/ - -/* - * Compiler-specific #defines. - */ - -/* 'unused' explicitly flags an unused parameter */ -#if defined(__GNUC__) /*[*/ - #define unused __attribute__((__unused__)) - #define printflike(s,f) __attribute__ ((__format__ (__printf__, s, f))) -#else /*][*/ - #define unused /* nothing */ - #define printflike(s, f) /* nothing */ -#endif /*]*/ - - - -/* - * Prerequisite #includes. - */ -#include /* Unix standard I/O library */ -#include /* Unix system calls */ -#include /* Character classes */ -#include /* String manipulations */ -#include /* Basic system data types */ -#include /* System time-related data types */ -#include /* C library time functions */ -#include "localdefs.h" /* {s,tcl,c}3270-specific defines */ - -/* - * Cancel out contradictory parts. - */ -#if !defined(X3270_DISPLAY) /*[*/ - #undef X3270_KEYPAD - #undef X3270_MENUS -#endif /*]*/ - -/* Functions we may need to supply. */ -#if defined(NEED_STRTOK_R) /*[*/ - extern char *strtok_r(char *str, const char *sep, char **last); -#endif /*]*/ - -/* types of internal actions */ -enum iaction { - IA_STRING, IA_PASTE, IA_REDRAW, - IA_KEYPAD, IA_DEFAULT, IA_KEY, - IA_MACRO, IA_SCRIPT, IA_PEEK, - IA_TYPEAHEAD, IA_FT, IA_COMMAND, IA_KEYMAP, - IA_IDLE -}; - -// Version strings -LIB3270_INTERNAL const char * build; -LIB3270_INTERNAL const char * app_defaults_version; -LIB3270_INTERNAL const char * sccsid; -LIB3270_INTERNAL const char * build_rpq_timestamp; -LIB3270_INTERNAL const char * build_rpq_version; -LIB3270_INTERNAL const char * build_rpq_revision; - -#if defined(X3270_DBCS) /*[*/ - LIB3270_INTERNAL Boolean dbcs; -#endif /*]*/ - - -#if defined(X3270_DBCS) /*[*/ - LIB3270_INTERNAL char *full_efontname_dbcs; -#endif /*]*/ - - -/* keyboard modifer bitmap */ -#define ShiftKeyDown 0x01 -#define MetaKeyDown 0x02 -#define AltKeyDown 0x04 - -/* toggle names */ -struct toggle_name { - const char *name; - int index; -}; - - -/* input key type */ - -/* Naming convention for private actions. */ -#define PA_PFX "PA-" - -/* Shorthand macros */ - -#define CN ((char *) NULL) -#define PN ((XtPointer) NULL) -#define Replace(var, value) { lib3270_free(var); var = (value); }; - -/* Configuration change masks. */ -#define NO_CHANGE 0x0000 /* no change */ -#define MODEL_CHANGE 0x0001 /* screen dimensions changed */ -#define FONT_CHANGE 0x0002 /* emulator font changed */ -#define COLOR_CHANGE 0x0004 /* color scheme or 3278/9 mode changed */ -#define SCROLL_CHANGE 0x0008 /* scrollbar snapped on or off */ -#define CHARSET_CHANGE 0x0010 /* character set changed */ -#define ALL_CHANGE 0xffff /* everything changed */ - -/* Portability macros */ - -/* Equivalent of setlinebuf */ - -#if defined(_IOLBF) /*[*/ - #define SETLINEBUF(s) setvbuf(s, (char *)NULL, _IOLBF, BUFSIZ) -#else /*][*/ - #define SETLINEBUF(s) setlinebuf(s) -#endif /*]*/ - -/* Motorola version of gettimeofday */ - -#if defined(MOTOROLA) - #define gettimeofday(tp,tz) gettimeofday(tp) -#endif - -/* Default DFT file transfer buffer size. */ -#if defined(X3270_FT) && !defined(DFT_BUF) /*[*/ - #define DFT_BUF (4 * 1024) -#endif /*]*/ - -/* DBCS Preedit Types */ -#if defined(X3270_DBCS) /*[*/ - #define PT_ROOT "Root" - #define PT_OVER_THE_SPOT "OverTheSpot" - #define PT_OFF_THE_SPOT "OffTheSpot" - #define PT_ON_THE_SPOT "OnTheSpot" -#endif /*]*/ - -/** input key type */ -enum keytype -{ - KT_STD, - KT_GE -}; - -LIB3270_INTERNAL struct _ansictl -{ - char vintr; - char vquit; - char verase; - char vkill; - char veof; - char vwerase; - char vrprnt; - char vlnext; -} ansictl; - -/* default charset translation tables */ -// LIB3270_INTERNAL const unsigned short ebc2asc0[256]; -// LIB3270_INTERNAL const unsigned short asc2ft0[256]; - - -/* Library internal calls */ -LIB3270_INTERNAL void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped); -LIB3270_INTERNAL void lib3270_initialize(void); -LIB3270_INTERNAL int cursor_move(H3270 *session, int baddr); - -LIB3270_INTERNAL void toggle_rectselect(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE tt); -LIB3270_INTERNAL void remove_input_calls(H3270 *session); - -LIB3270_INTERNAL int lib3270_sock_send(H3270 *hSession, unsigned const char *buf, int len); -LIB3270_INTERNAL void lib3270_sock_disconnect(H3270 *hSession); - -#if defined(DEBUG) - #define CHECK_SESSION_HANDLE(x) check_session_handle(&x,__FUNCTION__); - LIB3270_INTERNAL void check_session_handle(H3270 **hSession, const char *fname); -#else - #define CHECK_SESSION_HANDLE(x) check_session_handle(&x); - LIB3270_INTERNAL void check_session_handle(H3270 **hSession); -#endif // DEBUG - -LIB3270_INTERNAL int non_blocking(H3270 *session, Boolean on); - -#if defined(HAVE_LIBSSL) /*[*/ - - LIB3270_INTERNAL int ssl_init(H3270 *session); - LIB3270_INTERNAL int ssl_negotiate(H3270 *hSession); - LIB3270_INTERNAL void set_ssl_state(H3270 *session, LIB3270_SSL_STATE state); - - - #if OPENSSL_VERSION_NUMBER >= 0x00907000L /*[*/ - #define INFO_CONST const - #else /*][*/ - #define INFO_CONST - #endif /*]*/ - - LIB3270_INTERNAL void ssl_info_callback(INFO_CONST SSL *s, int where, int ret); - -#endif /*]*/ - diff --git a/glue.c b/glue.c index 6114ecd..87b952c 100644 --- a/glue.c +++ b/glue.c @@ -38,7 +38,7 @@ -#include "globals.h" +#include "private.h" #if !defined(_WIN32) /*[*/ #include diff --git a/host.c b/host.c index bfc4cf7..08ae110 100644 --- a/host.c +++ b/host.c @@ -39,7 +39,7 @@ */ #include -#include "globals.h" +#include "private.h" // #include "appres.h" #include "resources.h" diff --git a/html.c b/html.c index aee2a6d..761ebda 100644 --- a/html.c +++ b/html.c @@ -33,7 +33,7 @@ #include "3270ds.h" #include - #include "globals.h" + #include "private.h" #include "utilc.h" struct chr_xlat diff --git a/iocalls.c b/iocalls.c index c9124e3..f9bf97d 100644 --- a/iocalls.c +++ b/iocalls.c @@ -29,7 +29,7 @@ * */ -#include "globals.h" +#include "private.h" #include #include #include "xioc.h" @@ -45,15 +45,14 @@ /*---[ Standard calls ]-------------------------------------------------------------------------------------*/ // Timeout calls -static void internal_remove_timeout(void *timer); -static void * internal_add_timeout(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); +static void internal_remove_timeout(void *timer); +static void * internal_add_timeout(unsigned long interval_ms, H3270 *session, void (*proc)(H3270 *session)); -static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata ); -static void internal_remove_poll(void *id); +static void * internal_add_poll(H3270 *session, int fd, LIB3270_IO_FLAG flag, void(*proc)(H3270 *, int, LIB3270_IO_FLAG, void *), void *userdata ); +static void internal_remove_poll(void *id); static int internal_wait(H3270 *hSession, int seconds); -static int internal_event_dispatcher(H3270 *hSession, int block); static void internal_ring_bell(H3270 *); /*---[ Active callbacks ]-----------------------------------------------------------------------------------*/ @@ -74,7 +73,7 @@ static void internal_ring_bell(H3270 *); = internal_wait; static int (*event_dispatcher)(H3270 *hSession,int wait) - = internal_event_dispatcher; + = lib3270_default_event_dispatcher; static void (*ring_bell)(H3270 *) = internal_ring_bell; @@ -318,7 +317,7 @@ LIB3270_EXPORT void * lib3270_add_poll_fd(H3270 *session, int fd, LIB3270_IO_FL } /* Event dispatcher. */ -static int internal_event_dispatcher(H3270 *hSession, int block) +int lib3270_default_event_dispatcher(H3270 *hSession, int block) { #if defined(_WIN32) unsigned long long now; @@ -704,11 +703,6 @@ LIB3270_EXPORT int lib3270_register_handlers(const struct lib3270_callbacks *cbk } - -LIB3270_EXPORT void lib3270_iterate(int block) { - event_dispatcher(NULL,block); -} - LIB3270_EXPORT void lib3270_main_iterate(H3270 *hSession, int block) { CHECK_SESSION_HANDLE(hSession); diff --git a/kybd.c b/kybd.c index 6c6e22b..f3d0345 100644 --- a/kybd.c +++ b/kybd.c @@ -38,7 +38,7 @@ struct ta; #define LIB3270_TA struct ta -#include "globals.h" +#include "private.h" #include #ifndef ANDROID diff --git a/lib3270.cbp b/lib3270.cbp index 0088feb..8575c95 100644 --- a/lib3270.cbp +++ b/lib3270.cbp @@ -110,7 +110,6 @@ - @@ -135,6 +134,9 @@ + + @@ -149,6 +151,7 @@ + diff --git a/macros.c b/macros.c index 21c11af..936e44f 100644 --- a/macros.c +++ b/macros.c @@ -38,7 +38,7 @@ #include #include #include - #include "globals.h" + #include "private.h" #include "utilc.h" #include "api.h" diff --git a/mkfb.c b/mkfb.c index 73c1888..6ca813c 100644 --- a/mkfb.c +++ b/mkfb.c @@ -386,7 +386,7 @@ main(int argc, char *argv[]) fprintf(t, "/* This file was created automatically from %s by mkfb. */\n\n", filename); if (cmode) { - fprintf(t, "#include \"globals.h\"\n"); + fprintf(t, "#include \"private.h\"\n"); fprintf(t, "static unsigned char fsd[] = {\n"); } else { fprintf(t, "unsigned char common_fallbacks[] = {\n"); @@ -640,7 +640,7 @@ FILE * osx_tmpfile( void ) { int fd = -1; FILE *file = NULL; - + do { char *tempname = tempnam(NULL,"XXXXXX"); @@ -648,8 +648,8 @@ FILE * osx_tmpfile( void ) return NULL; fd = open (tempname,O_CREAT | O_EXCL | O_RDWR,S_IREAD | S_IWRITE); } while (fd < 0 && errno == EEXIST); - - + + file = fdopen (fd, "w+b"); if (file == NULL) { @@ -657,7 +657,7 @@ FILE * osx_tmpfile( void ) close (fd); errno = save_errno; } - + return file; } diff --git a/options.c b/options.c index 5da612a..45ed145 100644 --- a/options.c +++ b/options.c @@ -29,7 +29,7 @@ * */ -#include "globals.h" +#include "private.h" /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ diff --git a/paste.c b/paste.c index 512a008..49af3db 100644 --- a/paste.c +++ b/paste.c @@ -30,7 +30,7 @@ * */ -#include "globals.h" +#include "private.h" /* #if defined(X3270_DISPLAY) diff --git a/print.c b/print.c index 0a219fa..743a380 100644 --- a/print.c +++ b/print.c @@ -35,4 +35,4 @@ * Screen printing functions. */ -#include "globals.h" +#include "private.h" diff --git a/printer.c b/printer.c index 1ead606..f031864 100644 --- a/printer.c +++ b/printer.c @@ -36,7 +36,7 @@ * Printer session support */ -#include "globals.h" +#include "private.h" #if (defined(C3270) || defined(X3270_DISPLAY)) && defined(X3270_PRINTER) /*[*/ diff --git a/private.h b/private.h new file mode 100644 index 0000000..607bf3e --- /dev/null +++ b/private.h @@ -0,0 +1,273 @@ +/* + * "Software G3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a + * aplicativos mainframe. Registro no INPI sob o nome G3270. + * + * Copyright (C) <2008> + * + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela + * Free Software Foundation. + * + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para + * obter mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin + * St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Este programa está nomeado como private.h e possui - linhas de código. + * + * Contatos: + * + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) + * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) + * licinio@bb.com.br (Licínio Luis Branco) + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) + * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) + * + */ + +/* Autoconf settings. */ +#include /* autoconf settings */ +#include /* lib3270 API calls and defs */ +#include "api.h" + +#if defined(X3270_TN3270E) && !defined(X3270_ANSI) /*[*/ + #define X3270_ANSI 1 /* RFC2355 requires NVT mode */ +#endif /*]*/ + +#if defined(HAVE_VASPRINTF) && !defined(_GNU_SOURCE) /*[*/ + #define _GNU_SOURCE /* vasprintf isn't POSIX */ +#endif /*]*/ + +/* + * gettext stuff + */ +#ifdef ANDROID + #undef HAVE_LIBINTL + #undef HAVE_LIBSSL +#endif + +#ifdef HAVE_LIBINTL + #include + #define _( x ) gettext(x) + #define N_( x ) x +#else + #define _( x ) x + #define N_( x ) x +#endif // HAVE_LIBINTL + +#define action_name(x) #x + +/* + * OS-specific #defines. Except for the blocking-connect workarounds, these + * should be replaced with autoconf probes as soon as possible. + */ + +/* + * BLOCKING_CONNECT_ONLY + * Use only blocking sockets. + */ +#if defined(sco) /*[*/ + #define BLOCKING_CONNECT_ONLY 1 +#endif /*]*/ + +#if defined(apollo) /*[*/ + #define BLOCKING_CONNECT_ONLY 1 +#endif /*]*/ + +/* + * Compiler-specific #defines. + */ + +/* 'unused' explicitly flags an unused parameter */ +#if defined(__GNUC__) /*[*/ + #define unused __attribute__((__unused__)) + #define printflike(s,f) __attribute__ ((__format__ (__printf__, s, f))) +#else /*][*/ + #define unused /* nothing */ + #define printflike(s, f) /* nothing */ +#endif /*]*/ + + + +/* + * Prerequisite #includes. + */ +#include /* Unix standard I/O library */ +#include /* Unix system calls */ +#include /* Character classes */ +#include /* String manipulations */ +#include /* Basic system data types */ +#include /* System time-related data types */ +#include /* C library time functions */ +#include "localdefs.h" /* {s,tcl,c}3270-specific defines */ + +/* + * Cancel out contradictory parts. + */ +#if !defined(X3270_DISPLAY) /*[*/ + #undef X3270_KEYPAD + #undef X3270_MENUS +#endif /*]*/ + +/* Functions we may need to supply. */ +#if defined(NEED_STRTOK_R) /*[*/ + extern char *strtok_r(char *str, const char *sep, char **last); +#endif /*]*/ + +/* types of internal actions */ +enum iaction { + IA_STRING, IA_PASTE, IA_REDRAW, + IA_KEYPAD, IA_DEFAULT, IA_KEY, + IA_MACRO, IA_SCRIPT, IA_PEEK, + IA_TYPEAHEAD, IA_FT, IA_COMMAND, IA_KEYMAP, + IA_IDLE +}; + +// Version strings +LIB3270_INTERNAL const char * build; +LIB3270_INTERNAL const char * app_defaults_version; +LIB3270_INTERNAL const char * sccsid; +LIB3270_INTERNAL const char * build_rpq_timestamp; +LIB3270_INTERNAL const char * build_rpq_version; +LIB3270_INTERNAL const char * build_rpq_revision; + +#if defined(X3270_DBCS) /*[*/ + LIB3270_INTERNAL Boolean dbcs; +#endif /*]*/ + + +#if defined(X3270_DBCS) /*[*/ + LIB3270_INTERNAL char *full_efontname_dbcs; +#endif /*]*/ + + +/* keyboard modifer bitmap */ +#define ShiftKeyDown 0x01 +#define MetaKeyDown 0x02 +#define AltKeyDown 0x04 + +/* toggle names */ +struct toggle_name { + const char *name; + int index; +}; + + +/* input key type */ + +/* Naming convention for private actions. */ +#define PA_PFX "PA-" + +/* Shorthand macros */ + +#define CN ((char *) NULL) +#define PN ((XtPointer) NULL) +#define Replace(var, value) { lib3270_free(var); var = (value); }; + +/* Configuration change masks. */ +#define NO_CHANGE 0x0000 /* no change */ +#define MODEL_CHANGE 0x0001 /* screen dimensions changed */ +#define FONT_CHANGE 0x0002 /* emulator font changed */ +#define COLOR_CHANGE 0x0004 /* color scheme or 3278/9 mode changed */ +#define SCROLL_CHANGE 0x0008 /* scrollbar snapped on or off */ +#define CHARSET_CHANGE 0x0010 /* character set changed */ +#define ALL_CHANGE 0xffff /* everything changed */ + +/* Portability macros */ + +/* Equivalent of setlinebuf */ + +#if defined(_IOLBF) /*[*/ + #define SETLINEBUF(s) setvbuf(s, (char *)NULL, _IOLBF, BUFSIZ) +#else /*][*/ + #define SETLINEBUF(s) setlinebuf(s) +#endif /*]*/ + +/* Motorola version of gettimeofday */ + +#if defined(MOTOROLA) + #define gettimeofday(tp,tz) gettimeofday(tp) +#endif + +/* Default DFT file transfer buffer size. */ +#if defined(X3270_FT) && !defined(DFT_BUF) /*[*/ + #define DFT_BUF (4 * 1024) +#endif /*]*/ + +/* DBCS Preedit Types */ +#if defined(X3270_DBCS) /*[*/ + #define PT_ROOT "Root" + #define PT_OVER_THE_SPOT "OverTheSpot" + #define PT_OFF_THE_SPOT "OffTheSpot" + #define PT_ON_THE_SPOT "OnTheSpot" +#endif /*]*/ + +/** input key type */ +enum keytype +{ + KT_STD, + KT_GE +}; + +LIB3270_INTERNAL struct _ansictl +{ + char vintr; + char vquit; + char verase; + char vkill; + char veof; + char vwerase; + char vrprnt; + char vlnext; +} ansictl; + +/* default charset translation tables */ +// LIB3270_INTERNAL const unsigned short ebc2asc0[256]; +// LIB3270_INTERNAL const unsigned short asc2ft0[256]; + + +/* Library internal calls */ +LIB3270_INTERNAL void key_ACharacter(H3270 *hSession, unsigned char c, enum keytype keytype, enum iaction cause,Boolean *skipped); +LIB3270_INTERNAL void lib3270_initialize(void); +LIB3270_INTERNAL int cursor_move(H3270 *session, int baddr); + +LIB3270_INTERNAL void toggle_rectselect(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE tt); +LIB3270_INTERNAL void remove_input_calls(H3270 *session); + +LIB3270_INTERNAL int lib3270_sock_send(H3270 *hSession, unsigned const char *buf, int len); +LIB3270_INTERNAL void lib3270_sock_disconnect(H3270 *hSession); + +LIB3270_INTERNAL int lib3270_default_event_dispatcher(H3270 *hSession, int block); + +#if defined(DEBUG) + #define CHECK_SESSION_HANDLE(x) check_session_handle(&x,__FUNCTION__); + LIB3270_INTERNAL void check_session_handle(H3270 **hSession, const char *fname); +#else + #define CHECK_SESSION_HANDLE(x) check_session_handle(&x); + LIB3270_INTERNAL void check_session_handle(H3270 **hSession); +#endif // DEBUG + +LIB3270_INTERNAL int non_blocking(H3270 *session, Boolean on); + +#if defined(HAVE_LIBSSL) /*[*/ + + LIB3270_INTERNAL int ssl_init(H3270 *session); + LIB3270_INTERNAL int ssl_negotiate(H3270 *hSession); + LIB3270_INTERNAL void set_ssl_state(H3270 *session, LIB3270_SSL_STATE state); + + + #if OPENSSL_VERSION_NUMBER >= 0x00907000L /*[*/ + #define INFO_CONST const + #else /*][*/ + #define INFO_CONST + #endif /*]*/ + + LIB3270_INTERNAL void ssl_info_callback(INFO_CONST SSL *s, int where, int ret); + +#endif /*]*/ + diff --git a/proxy.c b/proxy.c index cf93c58..258356b 100644 --- a/proxy.c +++ b/proxy.c @@ -42,7 +42,7 @@ #include #endif // _WIN32 -#include "globals.h" +#include "private.h" #include "utilc.h" //#include "appres.h" diff --git a/resolver.c b/resolver.c index 087bcc9..8a4e2df 100644 --- a/resolver.c +++ b/resolver.c @@ -45,11 +45,11 @@ #include #include - #include "globals.h" + #include "private.h" #else - #include "globals.h" + #include "private.h" #include #include diff --git a/resources.c b/resources.c index afc8201..2dbae92 100644 --- a/resources.c +++ b/resources.c @@ -34,7 +34,7 @@ #include #include -#include "globals.h" +#include "private.h" #include "utilc.h" extern String fallbacks[]; diff --git a/rpq.c b/rpq.c index 24c446a..bda90d3 100644 --- a/rpq.c +++ b/rpq.c @@ -36,7 +36,7 @@ * */ -#include "globals.h" +#include "private.h" #include #if !defined(_WIN32) /*[*/ #include diff --git a/screen.c b/screen.c index 52eed45..5ef8ed3 100644 --- a/screen.c +++ b/screen.c @@ -35,7 +35,7 @@ * Screen drawing */ -#include "globals.h" +#include "private.h" #include //#include "appres.h" #include "3270ds.h" diff --git a/see.c b/see.c index 2749eb1..bba981a 100644 --- a/see.c +++ b/see.c @@ -36,7 +36,7 @@ * */ -#include "globals.h" +#include "private.h" #if defined(X3270_TRACE) /*[*/ diff --git a/selection.c b/selection.c index 9b0dfe9..de2b4f7 100644 --- a/selection.c +++ b/selection.c @@ -27,7 +27,7 @@ * */ - #include "globals.h" + #include "private.h" // #include "appres.h" #include #include diff --git a/session.c b/session.c index a1bcc76..3bfa2e3 100644 --- a/session.c +++ b/session.c @@ -33,7 +33,7 @@ #include #endif // !ANDROID -#include "globals.h" +#include "private.h" // #include "charsetc.h" #include "kybdc.h" #include "ansic.h" diff --git a/sf.c b/sf.c index afe2139..978a4e1 100644 --- a/sf.c +++ b/sf.c @@ -36,7 +36,7 @@ * */ -#include "globals.h" +#include "private.h" #include #if !defined(_WIN32) /*[*/ #include diff --git a/ssl.c b/ssl.c index fea99b0..1a9c168 100644 --- a/ssl.c +++ b/ssl.c @@ -41,7 +41,7 @@ #include #endif -#include "globals.h" +#include "private.h" #include #include #include diff --git a/state.c b/state.c index ed42b06..aadae0b 100644 --- a/state.c +++ b/state.c @@ -27,7 +27,7 @@ * */ -#include "globals.h" +#include "private.h" /*---[ Implement ]------------------------------------------------------------------------------------------------------------*/ diff --git a/telnet.c b/telnet.c index b761960..f13248c 100644 --- a/telnet.c +++ b/telnet.c @@ -51,7 +51,7 @@ #include #endif -#include "globals.h" +#include "private.h" #include #if defined(_WIN32) diff --git a/testprogram.c b/testprogram.c index 055347b..247f68c 100644 --- a/testprogram.c +++ b/testprogram.c @@ -1,9 +1,10 @@ #include #include +#include // #include -#include "globals.h" +#include "private.h" #include #define MAX_ARGS 10 @@ -23,6 +24,7 @@ int main(int numpar, char *param[]) { H3270 * h; int rc = 0; + const char * url = getenv("LIB3270HOST"); // char line[4096]; // pthread_t thread; @@ -36,7 +38,7 @@ int main(int numpar, char *param[]) // pthread_create(&thread, NULL, mainloop, NULL); // pthread_detach(thread); - lib3270_set_url(h,"tn3270://fandezhi.efglobe.com"); + lib3270_set_url(h,url ? url : "tn3270://fandezhi.efglobe.com"); rc = lib3270_connect(h,1); printf("\nConnect exits with rc=%d\n",rc); diff --git a/toggles.c b/toggles.c index 9f9fbfc..1f94296 100644 --- a/toggles.c +++ b/toggles.c @@ -45,7 +45,7 @@ #include #include "toggle.h" -#include "globals.h" +#include "private.h" #include "ansic.h" #include "ctlrc.h" diff --git a/trace_ds.c b/trace_ds.c index 1cbbb64..829136d 100644 --- a/trace_ds.c +++ b/trace_ds.c @@ -37,7 +37,7 @@ * */ -#include "globals.h" +#include "private.h" #include #if defined(X3270_TRACE) /*[*/ diff --git a/utf8.c b/utf8.c index 23b3202..5c6d0ad 100644 --- a/utf8.c +++ b/utf8.c @@ -36,7 +36,7 @@ * UTF-8 conversions */ -#include "globals.h" +#include "private.h" #include "api.h" #include "popupsc.h" diff --git a/util.c b/util.c index f6815fb..6ea3399 100644 --- a/util.c +++ b/util.c @@ -43,7 +43,7 @@ #include #endif // _WIN32 -#include "globals.h" +#include "private.h" #if defined(_WIN32) -- libgit2 0.21.2