From 2347f103755804ac8dea62ab3e16e12d8b9e996b Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Fri, 3 Aug 2012 12:39:36 +0000 Subject: [PATCH] Alterando macros para suportar multi-sessão --- pw3270.cbp | 2 +- src/include/lib3270/3270ds.h | 333 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/lib3270/3270ds.h | 333 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib3270/ansi.c | 2 +- src/lib3270/ctlr.c | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------ src/lib3270/ctlrc.h | 4 ++-- src/lib3270/ft_cut.c | 7 +------ src/lib3270/ft_dft.c | 2 +- src/lib3270/glue.c | 3 +-- src/lib3270/html.c | 2 +- src/lib3270/kybd.c | 580 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/lib3270/paste.c | 85 ++++++++++++++++++++++++++++++++++++++++++------------------------------------------- src/lib3270/proxy.c | 2 +- src/lib3270/rpq.c | 3 +-- src/lib3270/screen.c | 2 +- src/lib3270/see.c | 2 +- src/lib3270/session.c | 2 +- src/lib3270/sf.c | 2 +- src/lib3270/telnet.c | 10 +++++----- src/lib3270/trace_ds.c | 2 +- 20 files changed, 799 insertions(+), 744 deletions(-) delete mode 100644 src/include/lib3270/3270ds.h create mode 100644 src/lib3270/3270ds.h diff --git a/pw3270.cbp b/pw3270.cbp index 2a02ae5..3d882ef 100644 --- a/pw3270.cbp +++ b/pw3270.cbp @@ -55,7 +55,6 @@ - @@ -71,6 +70,7 @@ + diff --git a/src/include/lib3270/3270ds.h b/src/include/lib3270/3270ds.h deleted file mode 100644 index 8c71b3f..0000000 --- a/src/include/lib3270/3270ds.h +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Modifications Copyright 1993, 1994, 1995, 1999, 2000, 2002, 2003, 2004, - * 2005 by Paul Mattes. - * RPQNAMES modifications Copyright 2004 by Don Russell. - * Original X11 Port Copyright 1990 by Jeff Sparkes. - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appear in all copies and that - * both that copyright notice and this permission notice appear in - * supporting documentation. - * - * Copyright 1989 by Georgia Tech Research Corporation, Atlanta, GA 30332. - * All Rights Reserved. GTRC hereby grants public use of this software. - * Derivative works based on this software must incorporate this copyright - * notice. - * - * x3270, c3270, s3270, tcl3270 and pr3287 are distributed in the hope that - * they will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * file LICENSE for more details. - */ - -/* - * 3270ds.h - * - * Header file for the 3270 Data Stream Protocol. - */ - -/* 3270 commands */ -#define CMD_W 0x01 /* write */ -#define CMD_RB 0x02 /* read buffer */ -#define CMD_NOP 0x03 /* no-op */ -#define CMD_EW 0x05 /* erase/write */ -#define CMD_RM 0x06 /* read modified */ -#define CMD_EWA 0x0d /* erase/write alternate */ -#define CMD_RMA 0x0e /* read modified all */ -#define CMD_EAU 0x0f /* erase all unprotected */ -#define CMD_WSF 0x11 /* write structured field */ - -/* SNA 3270 commands */ -#define SNA_CMD_RMA 0x6e /* read modified all */ -#define SNA_CMD_EAU 0x6f /* erase all unprotected */ -#define SNA_CMD_EWA 0x7e /* erase/write alternate */ -#define SNA_CMD_W 0xf1 /* write */ -#define SNA_CMD_RB 0xf2 /* read buffer */ -#define SNA_CMD_WSF 0xf3 /* write structured field */ -#define SNA_CMD_EW 0xf5 /* erase/write */ -#define SNA_CMD_RM 0xf6 /* read modified */ - -/* 3270 orders */ -#define ORDER_PT 0x05 /* program tab */ -#define ORDER_GE 0x08 /* graphic escape */ -#define ORDER_SBA 0x11 /* set buffer address */ -#define ORDER_EUA 0x12 /* erase unprotected to address */ -#define ORDER_IC 0x13 /* insert cursor */ -#define ORDER_SF 0x1d /* start field */ -#define ORDER_SA 0x28 /* set attribute */ -#define ORDER_SFE 0x29 /* start field extended */ -#define ORDER_YALE 0x2b /* Yale sub command */ -#define ORDER_MF 0x2c /* modify field */ -#define ORDER_RA 0x3c /* repeat to address */ - -#define FCORDER_NULL 0x00 /* format control: null */ -#define FCORDER_FF 0x0c /* form feed */ -#define FCORDER_CR 0x0d /* carriage return */ -#define FCORDER_SO 0x0e /* shift out (DBCS subfield) */ -#define FCORDER_SI 0x0f /* shift in (DBCS end) */ -#define FCORDER_NL 0x15 /* new line */ -#define FCORDER_EM 0x19 /* end of medium */ -#define FCORDER_DUP 0x1c /* duplicate */ -#define FCORDER_FM 0x1e /* field mark */ -#define FCORDER_SUB 0x3f /* substitute */ -#define FCORDER_EO 0xff /* eight ones */ - -/* SCS control code, some overlap orders */ -#define SCS_BS 0x16 /* Back Space */ -#define SCS_BEL 0x2f /* Bell Function */ -#define SCS_CR 0x0d /* Carriage Return */ -#define SCS_ENP 0x14 /* Enable Presentation */ -#define SCS_FF 0x0c /* Forms Feed */ -#define SCS_GE 0x08 /* Graphic Escape */ -#define SCS_HT 0x05 /* Horizontal Tab */ -#define SCS_INP 0x24 /* Inhibit Presentation */ -#define SCS_IRS 0x1e /* Interchange-Record Separator */ -#define SCS_LF 0x25 /* Line Feed */ -#define SCS_NL 0x15 /* New Line */ -#define SCS_SA 0x28 /* Set Attribute: */ -#define SCS_SA_RESET 0x00 /* Reset all */ -#define SCS_SA_HIGHLIGHT 0x41 /* Highlighting */ -#define SCS_SA_CS 0x42 /* Character set */ -#define SCS_SA_GRID 0xc2 /* Grid */ -#define SCS_SET 0x2b /* Set: */ -#define SCS_SHF 0xc1 /* Horizontal format */ -#define SCS_SLD 0xc6 /* Line Density */ -#define SCS_SVF 0xc2 /* Vertical Format */ -#define SCS_SO 0x0e /* Shift out (DBCS subfield start) */ -#define SCS_SI 0x0f /* Shift in (DBCS subfield end) */ -#define SCS_TRN 0x35 /* Transparent */ -#define SCS_VCS 0x04 /* Vertical Channel Select */ -#define SCS_VT 0x0b /* Vertical Tab */ - -/* Structured fields */ -#define SF_READ_PART 0x01 /* read partition */ -#define SF_RP_QUERY 0x02 /* query */ -#define SF_RP_QLIST 0x03 /* query list */ -#define SF_RPQ_LIST 0x00 /* QCODE list */ -#define SF_RPQ_EQUIV 0x40 /* equivalent+ QCODE list */ -#define SF_RPQ_ALL 0x80 /* all */ -#define SF_ERASE_RESET 0x03 /* erase/reset */ -#define SF_ER_DEFAULT 0x00 /* default */ -#define SF_ER_ALT 0x80 /* alternate */ -#define SF_SET_REPLY_MODE 0x09 /* set reply mode */ -#define SF_SRM_FIELD 0x00 /* field */ -#define SF_SRM_XFIELD 0x01 /* extended field */ -#define SF_SRM_CHAR 0x02 /* character */ -#define SF_CREATE_PART 0x0c /* create partition */ -#define CPFLAG_PROT 0x40 /* protected flag */ -#define CPFLAG_COPY_PS 0x20 /* local copy to presentation space */ -#define CPFLAG_BASE 0x07 /* base character set index */ -#define SF_OUTBOUND_DS 0x40 /* outbound 3270 DS */ -#define SF_TRANSFER_DATA 0xd0 /* file transfer open request */ - -/* Query replies */ -#define QR_SUMMARY 0x80 /* summary */ -#define QR_USABLE_AREA 0x81 /* usable area */ -#define QR_ALPHA_PART 0x84 /* alphanumeric partitions */ -#define QR_CHARSETS 0x85 /* character sets */ -#define QR_COLOR 0x86 /* color */ -#define QR_HIGHLIGHTING 0x87 /* highlighting */ -#define QR_REPLY_MODES 0x88 /* reply modes */ -#define QR_DBCS_ASIA 0x91 /* DBCS-Asia */ -#define QR_PC3270 0x93 /* PC3270 */ -#define QR_DDM 0x95 /* distributed data management */ -#define QR_RPQNAMES 0xa1 /* RPQ names */ -#define QR_IMP_PART 0xa6 /* implicit partition */ -#define QR_NULL 0xff /* null */ - -#define BA_TO_ROW(ba) ((ba) / h3270.cols) -#define BA_TO_COL(ba) ((ba) % h3270.cols) -#define ROWCOL_TO_BA(r,c) (((r) * h3270.cols) + c) -#define INC_BA(ba) { (ba) = ((ba) + 1) % (h3270.cols * h3270.rows); } -#define DEC_BA(ba) { (ba) = (ba) ? (ba - 1) : ((h3270.cols*h3270.rows) - 1); } - -/** Field attributes. */ -#define FA_PRINTABLE 0xc0 /**< these make the character "printable" */ -#define FA_PROTECT 0x20 /**< unprotected (0) / protected (1) */ -#define FA_NUMERIC 0x10 /**< alphanumeric (0) /numeric (1) */ -#define FA_INTENSITY 0x0c /**< display/selector pen detectable: */ -#define FA_INT_NORM_NSEL 0x00 /**< 00 normal, non-detect */ -#define FA_INT_NORM_SEL 0x04 /**< 01 normal, detectable */ -#define FA_INT_HIGH_SEL 0x08 /**< 10 intensified, detectable */ -#define FA_INT_ZERO_NSEL 0x0c /**< 11 nondisplay, non-detect */ -#define FA_RESERVED 0x02 /**< must be 0 */ -#define FA_MODIFY 0x01 /**< modified (1) */ - -/* Bits in the field attribute that are stored. */ -#define FA_MASK (FA_PROTECT | FA_NUMERIC | FA_INTENSITY | FA_MODIFY) - -/* Tests for various attribute properties. */ -#define FA_IS_MODIFIED(c) ((c) & FA_MODIFY) -#define FA_IS_NUMERIC(c) ((c) & FA_NUMERIC) -#define FA_IS_PROTECTED(c) ((c) & FA_PROTECT) -#define FA_IS_SKIP(c) (((c) & FA_PROTECT) && ((c) & FA_NUMERIC)) - -#define FA_IS_ZERO(c) \ - (((c) & FA_INTENSITY) == FA_INT_ZERO_NSEL) -#define FA_IS_HIGH(c) \ - (((c) & FA_INTENSITY) == FA_INT_HIGH_SEL) -#define FA_IS_NORMAL(c) \ - ( \ - ((c) & FA_INTENSITY) == FA_INT_NORM_NSEL \ - || \ - ((c) & FA_INTENSITY) == FA_INT_NORM_SEL \ - ) -#define FA_IS_SELECTABLE(c) \ - ( \ - ((c) & FA_INTENSITY) == FA_INT_NORM_SEL \ - || \ - ((c) & FA_INTENSITY) == FA_INT_HIGH_SEL \ - ) -#define FA_IS_INTENSE(c) \ - ((c & FA_INT_HIGH_SEL) == FA_INT_HIGH_SEL) - -/* Extended attributes */ -#define XA_ALL 0x00 -#define XA_3270 0xc0 -#define XA_VALIDATION 0xc1 -#define XAV_FILL 0x04 -#define XAV_ENTRY 0x02 -#define XAV_TRIGGER 0x01 -#define XA_OUTLINING 0xc2 -#define XAO_UNDERLINE 0x01 -#define XAO_RIGHT 0x02 -#define XAO_OVERLINE 0x04 -#define XAO_LEFT 0x08 -#define XA_HIGHLIGHTING 0x41 -#define XAH_DEFAULT 0x00 -#define XAH_NORMAL 0xf0 -#define XAH_BLINK 0xf1 -#define XAH_REVERSE 0xf2 -#define XAH_UNDERSCORE 0xf4 -#define XAH_INTENSIFY 0xf8 -#define XA_FOREGROUND 0x42 -#define XAC_DEFAULT 0x00 -#define XA_CHARSET 0x43 -#define XA_BACKGROUND 0x45 -#define XA_TRANSPARENCY 0x46 -#define XAT_DEFAULT 0x00 -#define XAT_OR 0xf0 -#define XAT_XOR 0xf1 -#define XAT_OPAQUE 0xff -#define XA_INPUT_CONTROL 0xfe -#define XAI_DISABLED 0x00 -#define XAI_ENABLED 0x01 - -/* WCC definitions */ -#define WCC_RESET(c) ((c) & 0x40) -#define WCC_START_PRINTER(c) ((c) & 0x08) -#define WCC_SOUND_ALARM(c) ((c) & 0x04) -#define WCC_KEYBOARD_RESTORE(c) ((c) & 0x02) -#define WCC_RESET_MDT(c) ((c) & 0x01) - -/* AIDs */ -#define AID_NO 0x60 /* no AID generated */ -#define AID_QREPLY 0x61 -#define AID_ENTER 0x7d -#define AID_PF1 0xf1 -#define AID_PF2 0xf2 -#define AID_PF3 0xf3 -#define AID_PF4 0xf4 -#define AID_PF5 0xf5 -#define AID_PF6 0xf6 -#define AID_PF7 0xf7 -#define AID_PF8 0xf8 -#define AID_PF9 0xf9 -#define AID_PF10 0x7a -#define AID_PF11 0x7b -#define AID_PF12 0x7c -#define AID_PF13 0xc1 -#define AID_PF14 0xc2 -#define AID_PF15 0xc3 -#define AID_PF16 0xc4 -#define AID_PF17 0xc5 -#define AID_PF18 0xc6 -#define AID_PF19 0xc7 -#define AID_PF20 0xc8 -#define AID_PF21 0xc9 -#define AID_PF22 0x4a -#define AID_PF23 0x4b -#define AID_PF24 0x4c -#define AID_OICR 0xe6 -#define AID_MSR_MHS 0xe7 -#define AID_SELECT 0x7e -#define AID_PA1 0x6c -#define AID_PA2 0x6e -#define AID_PA3 0x6b -#define AID_CLEAR 0x6d -#define AID_SYSREQ 0xf0 - -#define AID_SF 0x88 -#define SFID_QREPLY 0x81 - -/* Colors */ -#define COLOR_NEUTRAL_BLACK 0 -#define COLOR_BLUE 1 -#define COLOR_RED 2 -#define COLOR_PINK 3 -#define COLOR_GREEN 4 -#define COLOR_TURQUOISE 5 -#define COLOR_YELLOW 6 -#define COLOR_NEUTRAL_WHITE 7 -#define COLOR_BLACK 8 -#define COLOR_DEEP_BLUE 9 -#define COLOR_ORANGE 10 -#define COLOR_PURPLE 11 -#define COLOR_PALE_GREEN 12 -#define COLOR_PALE_TURQUOISE 13 -#define COLOR_GREY 14 -#define COLOR_WHITE 15 - -/* Data stream manipulation macros. */ -#define MASK32 0xff000000U -#define MASK24 0x00ff0000U -#define MASK16 0x0000ff00U -#define MASK08 0x000000ffU -#define MINUS1 0xffffffffU - -#define SET16(ptr, val) { \ - *((ptr)++) = ((val) & MASK16) >> 8; \ - *((ptr)++) = ((val) & MASK08); \ -} -#define GET16(val, ptr) { \ - (val) = *((ptr)+1); \ - (val) += *(ptr) << 8; \ -} -#define SET32(ptr, val) { \ - *((ptr)++) = ((val) & MASK32) >> 24; \ - *((ptr)++) = ((val) & MASK24) >> 16; \ - *((ptr)++) = ((val) & MASK16) >> 8; \ - *((ptr)++) = ((val) & MASK08); \ -} -#define HIGH8(s) (((s) >> 8) & 0xff) -#define LOW8(s) ((s) & 0xff) - -/* Other EBCDIC control codes. */ -#define EBC_null 0x00 -#define EBC_ff 0x0c -#define EBC_cr 0x0d -#define EBC_so 0x0e -#define EBC_si 0x0f -#define EBC_nl 0x15 -#define EBC_em 0x19 -#define EBC_dup 0x1c -#define EBC_fm 0x1e -#define EBC_space 0x40 -#define EBC_nobreakspace 0x41 -#define EBC_period 0x4b -#define EBC_ampersand 0x50 -#define EBC_underscore 0x6d -#define EBC_greater 0x6e -#define EBC_question 0x6f -#define EBC_Yacute 0xad -#define EBC_diaeresis 0xbd -#define EBC_minus 0xca -#define EBC_0 0xf0 -#define EBC_9 0xf9 -#define EBC_eo 0xff - -/* BIND definitions. */ -#define BIND_RU LIB3270_BIND_RU -#define BIND_OFF_PLU_NAME_LEN LIB3270_BIND_OFF_PLU_NAME_LEN -#define BIND_OFF_PLU_NAME LIB3270_BIND_OFF_PLU_NAME -#define BIND_PLU_NAME_MAX LIB3270_BIND_PLU_NAME_MAX diff --git a/src/lib3270/3270ds.h b/src/lib3270/3270ds.h new file mode 100644 index 0000000..aed8344 --- /dev/null +++ b/src/lib3270/3270ds.h @@ -0,0 +1,333 @@ +/* + * Modifications Copyright 1993, 1994, 1995, 1999, 2000, 2002, 2003, 2004, + * 2005 by Paul Mattes. + * RPQNAMES modifications Copyright 2004 by Don Russell. + * Original X11 Port Copyright 1990 by Jeff Sparkes. + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation. + * + * Copyright 1989 by Georgia Tech Research Corporation, Atlanta, GA 30332. + * All Rights Reserved. GTRC hereby grants public use of this software. + * Derivative works based on this software must incorporate this copyright + * notice. + * + * x3270, c3270, s3270, tcl3270 and pr3287 are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * file LICENSE for more details. + */ + +/* + * 3270ds.h + * + * Header file for the 3270 Data Stream Protocol. + */ + +/* 3270 commands */ +#define CMD_W 0x01 /* write */ +#define CMD_RB 0x02 /* read buffer */ +#define CMD_NOP 0x03 /* no-op */ +#define CMD_EW 0x05 /* erase/write */ +#define CMD_RM 0x06 /* read modified */ +#define CMD_EWA 0x0d /* erase/write alternate */ +#define CMD_RMA 0x0e /* read modified all */ +#define CMD_EAU 0x0f /* erase all unprotected */ +#define CMD_WSF 0x11 /* write structured field */ + +/* SNA 3270 commands */ +#define SNA_CMD_RMA 0x6e /* read modified all */ +#define SNA_CMD_EAU 0x6f /* erase all unprotected */ +#define SNA_CMD_EWA 0x7e /* erase/write alternate */ +#define SNA_CMD_W 0xf1 /* write */ +#define SNA_CMD_RB 0xf2 /* read buffer */ +#define SNA_CMD_WSF 0xf3 /* write structured field */ +#define SNA_CMD_EW 0xf5 /* erase/write */ +#define SNA_CMD_RM 0xf6 /* read modified */ + +/* 3270 orders */ +#define ORDER_PT 0x05 /* program tab */ +#define ORDER_GE 0x08 /* graphic escape */ +#define ORDER_SBA 0x11 /* set buffer address */ +#define ORDER_EUA 0x12 /* erase unprotected to address */ +#define ORDER_IC 0x13 /* insert cursor */ +#define ORDER_SF 0x1d /* start field */ +#define ORDER_SA 0x28 /* set attribute */ +#define ORDER_SFE 0x29 /* start field extended */ +#define ORDER_YALE 0x2b /* Yale sub command */ +#define ORDER_MF 0x2c /* modify field */ +#define ORDER_RA 0x3c /* repeat to address */ + +#define FCORDER_NULL 0x00 /* format control: null */ +#define FCORDER_FF 0x0c /* form feed */ +#define FCORDER_CR 0x0d /* carriage return */ +#define FCORDER_SO 0x0e /* shift out (DBCS subfield) */ +#define FCORDER_SI 0x0f /* shift in (DBCS end) */ +#define FCORDER_NL 0x15 /* new line */ +#define FCORDER_EM 0x19 /* end of medium */ +#define FCORDER_DUP 0x1c /* duplicate */ +#define FCORDER_FM 0x1e /* field mark */ +#define FCORDER_SUB 0x3f /* substitute */ +#define FCORDER_EO 0xff /* eight ones */ + +/* SCS control code, some overlap orders */ +#define SCS_BS 0x16 /* Back Space */ +#define SCS_BEL 0x2f /* Bell Function */ +#define SCS_CR 0x0d /* Carriage Return */ +#define SCS_ENP 0x14 /* Enable Presentation */ +#define SCS_FF 0x0c /* Forms Feed */ +#define SCS_GE 0x08 /* Graphic Escape */ +#define SCS_HT 0x05 /* Horizontal Tab */ +#define SCS_INP 0x24 /* Inhibit Presentation */ +#define SCS_IRS 0x1e /* Interchange-Record Separator */ +#define SCS_LF 0x25 /* Line Feed */ +#define SCS_NL 0x15 /* New Line */ +#define SCS_SA 0x28 /* Set Attribute: */ +#define SCS_SA_RESET 0x00 /* Reset all */ +#define SCS_SA_HIGHLIGHT 0x41 /* Highlighting */ +#define SCS_SA_CS 0x42 /* Character set */ +#define SCS_SA_GRID 0xc2 /* Grid */ +#define SCS_SET 0x2b /* Set: */ +#define SCS_SHF 0xc1 /* Horizontal format */ +#define SCS_SLD 0xc6 /* Line Density */ +#define SCS_SVF 0xc2 /* Vertical Format */ +#define SCS_SO 0x0e /* Shift out (DBCS subfield start) */ +#define SCS_SI 0x0f /* Shift in (DBCS subfield end) */ +#define SCS_TRN 0x35 /* Transparent */ +#define SCS_VCS 0x04 /* Vertical Channel Select */ +#define SCS_VT 0x0b /* Vertical Tab */ + +/* Structured fields */ +#define SF_READ_PART 0x01 /* read partition */ +#define SF_RP_QUERY 0x02 /* query */ +#define SF_RP_QLIST 0x03 /* query list */ +#define SF_RPQ_LIST 0x00 /* QCODE list */ +#define SF_RPQ_EQUIV 0x40 /* equivalent+ QCODE list */ +#define SF_RPQ_ALL 0x80 /* all */ +#define SF_ERASE_RESET 0x03 /* erase/reset */ +#define SF_ER_DEFAULT 0x00 /* default */ +#define SF_ER_ALT 0x80 /* alternate */ +#define SF_SET_REPLY_MODE 0x09 /* set reply mode */ +#define SF_SRM_FIELD 0x00 /* field */ +#define SF_SRM_XFIELD 0x01 /* extended field */ +#define SF_SRM_CHAR 0x02 /* character */ +#define SF_CREATE_PART 0x0c /* create partition */ +#define CPFLAG_PROT 0x40 /* protected flag */ +#define CPFLAG_COPY_PS 0x20 /* local copy to presentation space */ +#define CPFLAG_BASE 0x07 /* base character set index */ +#define SF_OUTBOUND_DS 0x40 /* outbound 3270 DS */ +#define SF_TRANSFER_DATA 0xd0 /* file transfer open request */ + +/* Query replies */ +#define QR_SUMMARY 0x80 /* summary */ +#define QR_USABLE_AREA 0x81 /* usable area */ +#define QR_ALPHA_PART 0x84 /* alphanumeric partitions */ +#define QR_CHARSETS 0x85 /* character sets */ +#define QR_COLOR 0x86 /* color */ +#define QR_HIGHLIGHTING 0x87 /* highlighting */ +#define QR_REPLY_MODES 0x88 /* reply modes */ +#define QR_DBCS_ASIA 0x91 /* DBCS-Asia */ +#define QR_PC3270 0x93 /* PC3270 */ +#define QR_DDM 0x95 /* distributed data management */ +#define QR_RPQNAMES 0xa1 /* RPQ names */ +#define QR_IMP_PART 0xa6 /* implicit partition */ +#define QR_NULL 0xff /* null */ + +#define BA_TO_ROW(ba) ((ba) / hSession->cols) +#define BA_TO_COL(ba) ((ba) % hSession->cols) +#define ROWCOL_TO_BA(r,c) (((r) * hSession->cols) + c) +#define INC_BA(ba) { (ba) = ((ba) + 1) % (hSession->cols * hSession->rows); } +#define DEC_BA(ba) { (ba) = (ba) ? (ba - 1) : ((hSession->cols*hSession->rows) - 1); } + +/** Field attributes. */ +#define FA_PRINTABLE 0xc0 /**< these make the character "printable" */ +#define FA_PROTECT 0x20 /**< unprotected (0) / protected (1) */ +#define FA_NUMERIC 0x10 /**< alphanumeric (0) /numeric (1) */ +#define FA_INTENSITY 0x0c /**< display/selector pen detectable: */ +#define FA_INT_NORM_NSEL 0x00 /**< 00 normal, non-detect */ +#define FA_INT_NORM_SEL 0x04 /**< 01 normal, detectable */ +#define FA_INT_HIGH_SEL 0x08 /**< 10 intensified, detectable */ +#define FA_INT_ZERO_NSEL 0x0c /**< 11 nondisplay, non-detect */ +#define FA_RESERVED 0x02 /**< must be 0 */ +#define FA_MODIFY 0x01 /**< modified (1) */ + +/* Bits in the field attribute that are stored. */ +#define FA_MASK (FA_PROTECT | FA_NUMERIC | FA_INTENSITY | FA_MODIFY) + +/* Tests for various attribute properties. */ +#define FA_IS_MODIFIED(c) ((c) & FA_MODIFY) +#define FA_IS_NUMERIC(c) ((c) & FA_NUMERIC) +#define FA_IS_PROTECTED(c) ((c) & FA_PROTECT) +#define FA_IS_SKIP(c) (((c) & FA_PROTECT) && ((c) & FA_NUMERIC)) + +#define FA_IS_ZERO(c) \ + (((c) & FA_INTENSITY) == FA_INT_ZERO_NSEL) +#define FA_IS_HIGH(c) \ + (((c) & FA_INTENSITY) == FA_INT_HIGH_SEL) +#define FA_IS_NORMAL(c) \ + ( \ + ((c) & FA_INTENSITY) == FA_INT_NORM_NSEL \ + || \ + ((c) & FA_INTENSITY) == FA_INT_NORM_SEL \ + ) +#define FA_IS_SELECTABLE(c) \ + ( \ + ((c) & FA_INTENSITY) == FA_INT_NORM_SEL \ + || \ + ((c) & FA_INTENSITY) == FA_INT_HIGH_SEL \ + ) +#define FA_IS_INTENSE(c) \ + ((c & FA_INT_HIGH_SEL) == FA_INT_HIGH_SEL) + +/* Extended attributes */ +#define XA_ALL 0x00 +#define XA_3270 0xc0 +#define XA_VALIDATION 0xc1 +#define XAV_FILL 0x04 +#define XAV_ENTRY 0x02 +#define XAV_TRIGGER 0x01 +#define XA_OUTLINING 0xc2 +#define XAO_UNDERLINE 0x01 +#define XAO_RIGHT 0x02 +#define XAO_OVERLINE 0x04 +#define XAO_LEFT 0x08 +#define XA_HIGHLIGHTING 0x41 +#define XAH_DEFAULT 0x00 +#define XAH_NORMAL 0xf0 +#define XAH_BLINK 0xf1 +#define XAH_REVERSE 0xf2 +#define XAH_UNDERSCORE 0xf4 +#define XAH_INTENSIFY 0xf8 +#define XA_FOREGROUND 0x42 +#define XAC_DEFAULT 0x00 +#define XA_CHARSET 0x43 +#define XA_BACKGROUND 0x45 +#define XA_TRANSPARENCY 0x46 +#define XAT_DEFAULT 0x00 +#define XAT_OR 0xf0 +#define XAT_XOR 0xf1 +#define XAT_OPAQUE 0xff +#define XA_INPUT_CONTROL 0xfe +#define XAI_DISABLED 0x00 +#define XAI_ENABLED 0x01 + +/* WCC definitions */ +#define WCC_RESET(c) ((c) & 0x40) +#define WCC_START_PRINTER(c) ((c) & 0x08) +#define WCC_SOUND_ALARM(c) ((c) & 0x04) +#define WCC_KEYBOARD_RESTORE(c) ((c) & 0x02) +#define WCC_RESET_MDT(c) ((c) & 0x01) + +/* AIDs */ +#define AID_NO 0x60 /* no AID generated */ +#define AID_QREPLY 0x61 +#define AID_ENTER 0x7d +#define AID_PF1 0xf1 +#define AID_PF2 0xf2 +#define AID_PF3 0xf3 +#define AID_PF4 0xf4 +#define AID_PF5 0xf5 +#define AID_PF6 0xf6 +#define AID_PF7 0xf7 +#define AID_PF8 0xf8 +#define AID_PF9 0xf9 +#define AID_PF10 0x7a +#define AID_PF11 0x7b +#define AID_PF12 0x7c +#define AID_PF13 0xc1 +#define AID_PF14 0xc2 +#define AID_PF15 0xc3 +#define AID_PF16 0xc4 +#define AID_PF17 0xc5 +#define AID_PF18 0xc6 +#define AID_PF19 0xc7 +#define AID_PF20 0xc8 +#define AID_PF21 0xc9 +#define AID_PF22 0x4a +#define AID_PF23 0x4b +#define AID_PF24 0x4c +#define AID_OICR 0xe6 +#define AID_MSR_MHS 0xe7 +#define AID_SELECT 0x7e +#define AID_PA1 0x6c +#define AID_PA2 0x6e +#define AID_PA3 0x6b +#define AID_CLEAR 0x6d +#define AID_SYSREQ 0xf0 + +#define AID_SF 0x88 +#define SFID_QREPLY 0x81 + +/* Colors */ +#define COLOR_NEUTRAL_BLACK 0 +#define COLOR_BLUE 1 +#define COLOR_RED 2 +#define COLOR_PINK 3 +#define COLOR_GREEN 4 +#define COLOR_TURQUOISE 5 +#define COLOR_YELLOW 6 +#define COLOR_NEUTRAL_WHITE 7 +#define COLOR_BLACK 8 +#define COLOR_DEEP_BLUE 9 +#define COLOR_ORANGE 10 +#define COLOR_PURPLE 11 +#define COLOR_PALE_GREEN 12 +#define COLOR_PALE_TURQUOISE 13 +#define COLOR_GREY 14 +#define COLOR_WHITE 15 + +/* Data stream manipulation macros. */ +#define MASK32 0xff000000U +#define MASK24 0x00ff0000U +#define MASK16 0x0000ff00U +#define MASK08 0x000000ffU +#define MINUS1 0xffffffffU + +#define SET16(ptr, val) { \ + *((ptr)++) = ((val) & MASK16) >> 8; \ + *((ptr)++) = ((val) & MASK08); \ +} +#define GET16(val, ptr) { \ + (val) = *((ptr)+1); \ + (val) += *(ptr) << 8; \ +} +#define SET32(ptr, val) { \ + *((ptr)++) = ((val) & MASK32) >> 24; \ + *((ptr)++) = ((val) & MASK24) >> 16; \ + *((ptr)++) = ((val) & MASK16) >> 8; \ + *((ptr)++) = ((val) & MASK08); \ +} +#define HIGH8(s) (((s) >> 8) & 0xff) +#define LOW8(s) ((s) & 0xff) + +/* Other EBCDIC control codes. */ +#define EBC_null 0x00 +#define EBC_ff 0x0c +#define EBC_cr 0x0d +#define EBC_so 0x0e +#define EBC_si 0x0f +#define EBC_nl 0x15 +#define EBC_em 0x19 +#define EBC_dup 0x1c +#define EBC_fm 0x1e +#define EBC_space 0x40 +#define EBC_nobreakspace 0x41 +#define EBC_period 0x4b +#define EBC_ampersand 0x50 +#define EBC_underscore 0x6d +#define EBC_greater 0x6e +#define EBC_question 0x6f +#define EBC_Yacute 0xad +#define EBC_diaeresis 0xbd +#define EBC_minus 0xca +#define EBC_0 0xf0 +#define EBC_9 0xf9 +#define EBC_eo 0xff + +/* BIND definitions. */ +#define BIND_RU LIB3270_BIND_RU +#define BIND_OFF_PLU_NAME_LEN LIB3270_BIND_OFF_PLU_NAME_LEN +#define BIND_OFF_PLU_NAME LIB3270_BIND_OFF_PLU_NAME +#define BIND_PLU_NAME_MAX LIB3270_BIND_PLU_NAME_MAX diff --git a/src/lib3270/ansi.c b/src/lib3270/ansi.c index 3dfe3a6..5567ff6 100644 --- a/src/lib3270/ansi.c +++ b/src/lib3270/ansi.c @@ -1177,7 +1177,7 @@ ansi_printing(H3270 *hSession, int ig1 unused, int ig2 unused) ctlr_add(hSession,hSession->cursor_addr, ebc_ch, default_cs); #if defined(X3270_DBCS) /*[*/ if (default_cs == CS_DBCS) - (void) ctlr_dbcs_postprocess(); + (void) ctlr_dbcs_postprocess(hSession); #endif /*]*/ break; } diff --git a/src/lib3270/ctlr.c b/src/lib3270/ctlr.c index b66ad45..3104bf9 100644 --- a/src/lib3270/ctlr.c +++ b/src/lib3270/ctlr.c @@ -40,7 +40,7 @@ #include "globals.h" #include -#include +#include "3270ds.h" //#include "appres.h" // #include "ctlr.h" #include "screen.h" @@ -237,19 +237,19 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) * Set the formatted screen flag. A formatted screen is a screen that * has at least one field somewhere on it. */ -static void set_formatted(H3270 *session) +static void set_formatted(H3270 *hSession) { register int baddr; - CHECK_SESSION_HANDLE(session); + CHECK_SESSION_HANDLE(hSession); - session->formatted = False; + hSession->formatted = False; baddr = 0; do { - if(session->ea_buf[baddr].fa) + if(hSession->ea_buf[baddr].fa) { - session->formatted = True; + hSession->formatted = True; break; } INC_BA(baddr); @@ -259,53 +259,53 @@ static void set_formatted(H3270 *session) /* * Called when a host is half connected. */ -static void ctlr_half_connect(H3270 *session, int ignored unused, void *dunno) +static void ctlr_half_connect(H3270 *hSession, int ignored unused, void *dunno) { - ticking_start(session,True); + ticking_start(hSession,True); } /* * Called when a host connects, disconnects, or changes ANSI/3270 modes. */ -static void ctlr_connect(H3270 *session, int ignored unused, void *dunno) +static void ctlr_connect(H3270 *hSession, int ignored unused, void *dunno) { - ticking_stop(session); - status_untiming(session); + ticking_stop(hSession); + status_untiming(hSession); - if (session->ever_3270) - session->ea_buf[-1].fa = FA_PRINTABLE | FA_MODIFY; + if (hSession->ever_3270) + hSession->ea_buf[-1].fa = FA_PRINTABLE | FA_MODIFY; else - session->ea_buf[-1].fa = FA_PRINTABLE | FA_PROTECT; - if (!IN_3270 || (IN_SSCP && (session->kybdlock & KL_OIA_TWAIT))) + hSession->ea_buf[-1].fa = FA_PRINTABLE | FA_PROTECT; + if (!IN_3270 || (IN_SSCP && (hSession->kybdlock & KL_OIA_TWAIT))) { - lib3270_kybdlock_clear(session,KL_OIA_TWAIT); - status_reset(session); + lib3270_kybdlock_clear(hSession,KL_OIA_TWAIT); + status_reset(hSession); } - session->default_fg = 0x00; - session->default_bg = 0x00; - session->default_gr = 0x00; - session->default_cs = 0x00; - session->default_ic = 0x00; - session->reply_mode = SF_SRM_FIELD; - session->crm_nattr = 0; + hSession->default_fg = 0x00; + hSession->default_bg = 0x00; + hSession->default_gr = 0x00; + hSession->default_cs = 0x00; + hSession->default_ic = 0x00; + hSession->reply_mode = SF_SRM_FIELD; + hSession->crm_nattr = 0; } -LIB3270_EXPORT int lib3270_field_addr(H3270 *h, int baddr) +LIB3270_EXPORT int lib3270_field_addr(H3270 *hSession, int baddr) { int sbaddr; - CHECK_SESSION_HANDLE(h); + CHECK_SESSION_HANDLE(hSession); - if (!h->formatted) + if (!hSession->formatted) return -1; sbaddr = baddr; do { - if(h->ea_buf[baddr].fa) + if(hSession->ea_buf[baddr].fa) return baddr; DEC_BA(baddr); } while (baddr != sbaddr); @@ -316,23 +316,24 @@ LIB3270_EXPORT int lib3270_field_addr(H3270 *h, int baddr) /* * Get Field width */ -int lib3270_field_length(H3270 *h, int baddr) +int lib3270_field_length(H3270 *hSession, int baddr) { int saddr; int addr; int width = 0; - CHECK_SESSION_HANDLE(h); + CHECK_SESSION_HANDLE(hSession); - addr = find_field_attribute(h,baddr); + addr = find_field_attribute(hSession,baddr); if(addr < 0) return -1; saddr = addr; INC_BA(addr); - do { - if(h->ea_buf[addr].fa) + do + { + if(hSession->ea_buf[addr].fa) return width; INC_BA(addr); width++; @@ -346,9 +347,9 @@ int lib3270_field_length(H3270 *h, int baddr) * Find the field attribute for the given buffer address. Return its address * rather than its value. */ -unsigned char get_field_attribute(H3270 *h, int baddr) +unsigned char get_field_attribute(H3270 *hSession, int baddr) { - return h->ea_buf[find_field_attribute(h,baddr)].fa; + return hSession->ea_buf[find_field_attribute(hSession,baddr)].fa; } /* @@ -356,7 +357,7 @@ unsigned char get_field_attribute(H3270 *h, int baddr) * unprotected attribute byte, or 0 if no nonzero-width unprotected field * can be found. */ -int next_unprotected(H3270 *session, int baddr0) +int next_unprotected(H3270 *hSession, int baddr0) { register int baddr, nbaddr; @@ -365,7 +366,7 @@ int next_unprotected(H3270 *session, int baddr0) { baddr = nbaddr; INC_BA(nbaddr); - if(session->ea_buf[baddr].fa &&!FA_IS_PROTECTED(session->ea_buf[baddr].fa) &&!session->ea_buf[nbaddr].fa) + if(hSession->ea_buf[baddr].fa &&!FA_IS_PROTECTED(hSession->ea_buf[baddr].fa) &&!hSession->ea_buf[nbaddr].fa) return nbaddr; } while (nbaddr != baddr0); @@ -1267,7 +1268,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er trace_ds(hSession,"%s",rcba(hSession,baddr)); previous = ORDER; - if (baddr >= h3270.cols * h3270.rows) + if (baddr >= hSession->cols * hSession->rows) { ABORT_WRITE("invalid EUA address"); } @@ -1283,16 +1284,15 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er } do { - if (h3270.ea_buf[h3270.buffer_addr].fa) - current_fa = h3270.ea_buf[h3270.buffer_addr].fa; + if (hSession->ea_buf[hSession->buffer_addr].fa) + current_fa = hSession->ea_buf[hSession->buffer_addr].fa; else if (!FA_IS_PROTECTED(current_fa)) { - ctlr_add(&h3270,h3270.buffer_addr, EBC_null, - CS_BASE); + ctlr_add(hSession,hSession->buffer_addr, EBC_null,CS_BASE); } - INC_BA(h3270.buffer_addr); - } while (h3270.buffer_addr != baddr); - current_fa = get_field_attribute(hSession,h3270.buffer_addr); + INC_BA(hSession->buffer_addr); + } while (hSession->buffer_addr != baddr); + current_fa = get_field_attribute(hSession,hSession->buffer_addr); last_cmd = True; last_zpt = False; break; @@ -1308,14 +1308,14 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er if (*cp) trace_ds(hSession,"'"); - ctlr_add(hSession,h3270.buffer_addr, *cp, CS_GE); - ctlr_add_fg(hSession,h3270.buffer_addr, h3270.default_fg); - ctlr_add_bg(hSession,h3270.buffer_addr, h3270.default_bg); - ctlr_add_gr(hSession,h3270.buffer_addr, h3270.default_gr); - ctlr_add_ic(hSession,h3270.buffer_addr, h3270.default_ic); - INC_BA(h3270.buffer_addr); + ctlr_add(hSession,hSession->buffer_addr, *cp, CS_GE); + ctlr_add_fg(hSession,hSession->buffer_addr, hSession->default_fg); + ctlr_add_bg(hSession,hSession->buffer_addr, hSession->default_bg); + ctlr_add_gr(hSession,hSession->buffer_addr, hSession->default_gr); + ctlr_add_ic(hSession,hSession->buffer_addr, hSession->default_ic); + INC_BA(hSession->buffer_addr); - current_fa = get_field_attribute(hSession,h3270.buffer_addr); + current_fa = get_field_attribute(hSession,hSession->buffer_addr); last_cmd = False; last_zpt = False; break; @@ -1323,11 +1323,11 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er case ORDER_MF: /* modify field */ END_TEXT("ModifyField"); if (previous != SBA) - trace_ds(hSession,"%s",rcba(hSession,h3270.buffer_addr)); + trace_ds(hSession,"%s",rcba(hSession,hSession->buffer_addr)); previous = ORDER; cp++; na = *cp; - if (h3270.ea_buf[h3270.buffer_addr].fa) + if (hSession->ea_buf[hSession->buffer_addr].fa) { for (i = 0; i < (int)na; i++) { @@ -1336,8 +1336,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er { trace_ds(hSession," 3270"); cp++; - ctlr_add_fa(hSession,h3270.buffer_addr, *cp, - h3270.ea_buf[h3270.buffer_addr].cs); + ctlr_add_fa(hSession,hSession->buffer_addr, *cp,hSession->ea_buf[hSession->buffer_addr].cs); trace_ds(hSession,"%s",see_attr(*cp)); } else if (*cp == XA_FOREGROUND) @@ -1456,12 +1455,12 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er } if (!any_fa) START_FIELD(0); - ctlr_add_cs(&h3270,h3270.buffer_addr, efa_cs); - ctlr_add_fg(&h3270,h3270.buffer_addr, efa_fg); - ctlr_add_bg(&h3270,h3270.buffer_addr, efa_bg); - ctlr_add_gr(&h3270,h3270.buffer_addr, efa_gr); - ctlr_add_ic(&h3270,h3270.buffer_addr, efa_ic); - INC_BA(h3270.buffer_addr); + ctlr_add_cs(hSession,h3270.buffer_addr, efa_cs); + ctlr_add_fg(hSession,h3270.buffer_addr, efa_fg); + ctlr_add_bg(hSession,h3270.buffer_addr, efa_bg); + ctlr_add_gr(hSession,h3270.buffer_addr, efa_gr); + ctlr_add_ic(hSession,h3270.buffer_addr, efa_ic); + INC_BA(hSession->buffer_addr); last_cmd = True; last_zpt = False; break; @@ -1526,12 +1525,12 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er if (h3270.default_cs == CS_DBCS || d != DBCS_NONE) { ABORT_WRITE("invalid format control order in DBCS field"); } - ctlr_add(&h3270,h3270.buffer_addr, *cp, h3270.default_cs); - ctlr_add_fg(&h3270,h3270.buffer_addr, h3270.default_fg); - ctlr_add_bg(&h3270,h3270.buffer_addr, h3270.default_bg); - ctlr_add_gr(&h3270,h3270.buffer_addr, h3270.default_gr); - ctlr_add_ic(&h3270,h3270.buffer_addr, h3270.default_ic); - INC_BA(h3270.buffer_addr); + ctlr_add(&h3270,hSession->buffer_addr, *cp, hSession->default_cs); + ctlr_add_fg(&h3270,hSession->buffer_addr, hSession->default_fg); + ctlr_add_bg(&h3270,hSession->buffer_addr, hSession->default_bg); + ctlr_add_gr(&h3270,hSession->buffer_addr, hSession->default_gr); + ctlr_add_ic(&h3270,hSession->buffer_addr, hSession->default_ic); + INC_BA(hSession->buffer_addr); last_cmd = True; last_zpt = False; break; @@ -1555,7 +1554,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er ctlr_add_bg(&h3270,h3270.buffer_addr, h3270.default_bg); ctlr_add_gr(&h3270,h3270.buffer_addr, h3270.default_gr); ctlr_add_ic(&h3270,h3270.buffer_addr, h3270.default_ic); - INC_BA(h3270.buffer_addr); + INC_BA(hSession->buffer_addr); last_cmd = True; last_zpt = False; break; @@ -1594,7 +1593,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er ctlr_add_bg(&h3270,h3270.buffer_addr, h3270.default_bg); ctlr_add_gr(&h3270,h3270.buffer_addr, h3270.default_gr); ctlr_add_ic(&h3270,h3270.buffer_addr, h3270.default_ic); - INC_BA(h3270.buffer_addr); + INC_BA(hSession->buffer_addr); last_cmd = True; last_zpt = False; break; @@ -1646,14 +1645,14 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er ctlr_add_bg(&h3270,h3270.buffer_addr, h3270.default_bg); ctlr_add_gr(&h3270,h3270.buffer_addr, h3270.default_gr); ctlr_add_ic(&h3270,h3270.buffer_addr, h3270.default_ic); - INC_BA(h3270.buffer_addr); + INC_BA(hSession->buffer_addr); if (add_dbcs) { ctlr_add(&h3270,h3270.buffer_addr, add_c2, h3270.default_cs); ctlr_add_fg(&h3270,h3270.buffer_addr, h3270.default_fg); ctlr_add_bg(&h3270,h3270.buffer_addr, h3270.default_bg); ctlr_add_gr(&h3270,h3270.buffer_addr, h3270.default_gr); ctlr_add_ic(&h3270,h3270.buffer_addr, h3270.default_ic); - INC_BA(h3270.buffer_addr); + INC_BA(hSession->buffer_addr); } last_cmd = False; last_zpt = False; @@ -1703,7 +1702,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er ctlr_add_bg(&h3270,h3270.buffer_addr, h3270.default_bg); ctlr_add_gr(&h3270,h3270.buffer_addr, h3270.default_gr); ctlr_add_ic(&h3270,h3270.buffer_addr, h3270.default_ic); - INC_BA(h3270.buffer_addr); + INC_BA(hSession->buffer_addr); #if defined(X3270_DBCS) /*[*/ if (add_dbcs) { ctlr_add(h3270.buffer_addr, add_c2, h3270.default_cs); @@ -1711,7 +1710,7 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er ctlr_add_bg(h3270.buffer_addr, h3270.default_bg); ctlr_add_gr(h3270.buffer_addr, h3270.default_gr); ctlr_add_ic(&h3270,h3270.buffer_addr, h3270.default_ic); - INC_BA(h3270.buffer_addr); + INC_BA(hSession->buffer_addr); } #endif /*]*/ last_cmd = False; @@ -1733,10 +1732,10 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er lib3270_ring_bell(hSession); /* Set up the DBCS state. */ - if (ctlr_dbcs_postprocess() < 0 && rv == PDS_OKAY_NO_OUTPUT) + if (ctlr_dbcs_postprocess(hSession) < 0 && rv == PDS_OKAY_NO_OUTPUT) rv = PDS_BAD_ADDR; - h3270.trace_primed = 0; + hSession->trace_primed = 0; ps_process(hSession); @@ -1977,16 +1976,14 @@ valid_dbcs_char(unsigned char c1, unsigned char c2) * * Returns 0 for success, -1 for failure. */ -int -ctlr_dbcs_postprocess(void) +int ctlr_dbcs_postprocess(H3270 *hSession) { int baddr; /* current buffer address */ int faddr0; /* address of first field attribute */ int faddr; /* address of current field attribute */ int last_baddr; /* last buffer address to search */ int pbaddr = -1; /* previous buffer address */ - int dbaddr = -1; /* first data position of current DBCS (sub-) - field */ + int dbaddr = -1; /* first data position of current DBCS (sub-) field */ Boolean so = False, si = False; Boolean dbcs_field = False; int rc = 0; @@ -2032,7 +2029,7 @@ ctlr_dbcs_postprocess(void) case EBC_so: /* Two SO's or SO in DBCS field are invalid. */ if (so || dbcs_field) { - trace_ds(&h3270,"DBCS postprocess: invalid SO found at %s\n", rcba(baddr)); + trace_ds(hSession,"DBCS postprocess: invalid SO found at %s\n", rcba(baddr)); rc = -1; } else { dbaddr = baddr; @@ -2045,7 +2042,7 @@ ctlr_dbcs_postprocess(void) case EBC_si: /* Two SI's or SI in DBCS field are invalid. */ if (si || dbcs_field) { - trace_ds(&h3270,"Postprocess: Invalid SO found at %s\n", rcba(baddr)); + trace_ds(hSession,"Postprocess: Invalid SO found at %s\n", rcba(baddr)); rc = -1; ea_buf[baddr].db = DBCS_NONE; } else { @@ -2058,7 +2055,7 @@ ctlr_dbcs_postprocess(void) default: /* Non-base CS in DBCS subfield is invalid. */ if (so && ea_buf[baddr].cs != CS_BASE) { - trace_ds(&h3270,"DBCS postprocess: invalid character set found at %s\n",rcba(baddr)); + trace_ds(hSession,"DBCS postprocess: invalid character set found at %s\n",rcba(baddr)); rc = -1; ea_buf[baddr].cs = CS_BASE; } @@ -2109,7 +2106,7 @@ ctlr_dbcs_postprocess(void) !IS_RIGHT(ea_buf[baddr].db) && ea_buf[pbaddr].db != DBCS_DEAD) { if (!ea_buf[baddr].fa) { - trace_ds(&h3270,"DBCS postprocess: dead position at %s\n", rcba(pbaddr)); + trace_ds(hSession,"DBCS postprocess: dead position at %s\n", rcba(pbaddr)); rc = -1; } ea_buf[pbaddr].cc = EBC_null; diff --git a/src/lib3270/ctlrc.h b/src/lib3270/ctlrc.h index b6b6167..ca2cd44 100644 --- a/src/lib3270/ctlrc.h +++ b/src/lib3270/ctlrc.h @@ -91,9 +91,9 @@ enum dbcs_why { DBCS_FIELD, DBCS_SUBFIELD, DBCS_ATTRIBUTE }; #if defined(X3270_DBCS) /*[*/ LIB3270_INTERNAL enum dbcs_state ctlr_dbcs_state(int baddr); LIB3270_INTERNAL enum dbcs_state ctlr_lookleft_state(int baddr, enum dbcs_why *why); - LIB3270_INTERNAL int ctlr_dbcs_postprocess(void); + LIB3270_INTERNAL int ctlr_dbcs_postprocess(H3270 *hSession); #else /*][*/ #define ctlr_dbcs_state(b) DBCS_NONE #define ctlr_lookleft_state(b, w) DBCS_NONE - #define ctlr_dbcs_postprocess() 0 + #define ctlr_dbcs_postprocess(hSession) 0 #endif /*]*/ diff --git a/src/lib3270/ft_cut.c b/src/lib3270/ft_cut.c index 3e2320a..de63f2c 100644 --- a/src/lib3270/ft_cut.c +++ b/src/lib3270/ft_cut.c @@ -41,12 +41,7 @@ #if defined(X3270_FT) /*[*/ -// #include - -//#include "appres.h" -// #include "ctlr.h" -#include - +#include "3270ds.h" #include "actionsc.h" #include "ctlrc.h" #include "ft_cutc.h" diff --git a/src/lib3270/ft_dft.c b/src/lib3270/ft_dft.c index d514b42..f7555ec 100644 --- a/src/lib3270/ft_dft.c +++ b/src/lib3270/ft_dft.c @@ -42,7 +42,7 @@ #if defined(X3270_FT) /*[*/ //#include "appres.h" -#include +#include "3270ds.h" #include "ft_dft_ds.h" #include "actionsc.h" diff --git a/src/lib3270/glue.c b/src/lib3270/glue.c index 5281daa..af5ff90 100644 --- a/src/lib3270/glue.c +++ b/src/lib3270/glue.c @@ -51,8 +51,7 @@ #include #include -//#include "appres.h" -#include +#include "3270ds.h" #include "resources.h" #include "actionsc.h" diff --git a/src/lib3270/html.c b/src/lib3270/html.c index 9bcc2db..ad12abb 100644 --- a/src/lib3270/html.c +++ b/src/lib3270/html.c @@ -30,7 +30,7 @@ #include #include #include - #include +#include "3270ds.h" #include #include "globals.h" diff --git a/src/lib3270/kybd.c b/src/lib3270/kybd.c index 05172d8..d167cf3 100644 --- a/src/lib3270/kybd.c +++ b/src/lib3270/kybd.c @@ -54,7 +54,7 @@ struct ta; // #include #include -#include +#include "3270ds.h" // #include "appres.h" // #include "ctlr.h" #include "resources.h" @@ -982,7 +982,7 @@ static Boolean key_Character(H3270 *hSession, int code, Boolean with_ge, Boolean cursor_move(hSession,baddr); } - (void) ctlr_dbcs_postprocess(); + (void) ctlr_dbcs_postprocess(hSession); return True; } @@ -1367,7 +1367,7 @@ static Boolean do_delete(H3270 *hSession) mdt_set(hSession,hSession->cursor_addr); /* Patch up the DBCS state for display. */ - (void) ctlr_dbcs_postprocess(); + (void) ctlr_dbcs_postprocess(hSession); return True; } @@ -1650,22 +1650,30 @@ static int nu_word(H3270 *hSession, int baddr) return -1; } -/* Find the next word in this field, or -1 */ -static int -nt_word(int baddr) +/** + * Find the next word in this field + * + * @return Next word or -1 + */ +static int nt_word(H3270 *hSession, int baddr) { int baddr0 = baddr; unsigned char c; Boolean in_word = True; - do { - c = h3270.ea_buf[baddr].cc; - if (h3270.ea_buf[baddr].fa) + do + { + c = hSession->ea_buf[baddr].cc; + + if (hSession->ea_buf[baddr].fa) return -1; - if (in_word) { + + if (in_word) + { if (c == EBC_space || c == EBC_null) in_word = False; - } else { + } else + { if (c != EBC_space && c != EBC_null) return baddr; } @@ -1707,7 +1715,7 @@ LIB3270_ACTION( nextword ) } /* If there's another word in this field, go to it. */ - baddr = nt_word(hSession->cursor_addr); + baddr = nt_word(hSession,hSession->cursor_addr); if (baddr != -1) { cursor_move(hSession,baddr); return 0; @@ -1985,22 +1993,22 @@ LIB3270_ACTION( eraseeol ) return 0; #endif /*]*/ - baddr = h3270.cursor_addr; - fa = get_field_attribute(&h3270,baddr); - if (FA_IS_PROTECTED(fa) || h3270.ea_buf[baddr].fa) + baddr = hSession->cursor_addr; + fa = get_field_attribute(hSession,baddr); + if (FA_IS_PROTECTED(fa) || hSession->ea_buf[baddr].fa) { - operator_error(&h3270,KL_OERR_PROTECTED); + operator_error(hSession,KL_OERR_PROTECTED); return -1; } - if (h3270.formatted) + if (hSession->formatted) { /* erase to next field attribute or current line */ do { - ctlr_add(&h3270,baddr, EBC_null, 0); + ctlr_add(hSession,baddr, EBC_null, 0); INC_BA(baddr); - } while (!h3270.ea_buf[baddr].fa && BA_TO_COL(baddr) > 0); + } while (!hSession->ea_buf[baddr].fa && BA_TO_COL(baddr) > 0); mdt_set(hSession,hSession->cursor_addr); } @@ -2009,23 +2017,25 @@ LIB3270_ACTION( eraseeol ) /* erase to end of current line */ do { - ctlr_add(&h3270,baddr, EBC_null, 0); + ctlr_add(hSession,baddr, EBC_null, 0); INC_BA(baddr); } while(baddr != 0 && BA_TO_COL(baddr) > 0); } /* If the cursor was in a DBCS subfield, re-create the SI. */ d = ctlr_lookleft_state(cursor_addr, &why); - if (IS_DBCS(d) && why == DBCS_SUBFIELD) { - if (d == DBCS_RIGHT) { - baddr = h3270.cursor_addr; + if (IS_DBCS(d) && why == DBCS_SUBFIELD) + { + if (d == DBCS_RIGHT) + { + baddr = hSession->cursor_addr; DEC_BA(baddr); - h3270.ea_buf[baddr].cc = EBC_si; + hSession->ea_buf[baddr].cc = EBC_si; } else - h3270.ea_buf[h3270.cursor_addr].cc = EBC_si; + hSession->ea_buf[hSession->cursor_addr].cc = EBC_si; } - (void) ctlr_dbcs_postprocess(); - h3270.display(&h3270); + (void) ctlr_dbcs_postprocess(hSession); + hSession->display(hSession); return 0; } @@ -2079,7 +2089,7 @@ LIB3270_ACTION( eraseeof ) } else h3270.ea_buf[hSession->cursor_addr].cc = EBC_si; } - (void) ctlr_dbcs_postprocess(); + (void) ctlr_dbcs_postprocess(hSession); hSession->display(hSession); return 0; } @@ -2440,7 +2450,7 @@ static Boolean remargin(H3270 *hSession, int lmargin) return True; } -LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int pasting) +LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, char *s, int len, int pasting) { enum { BASE, BACKSLASH, BACKX, BACKP, BACKPA, BACKPF, OCTAL, HEX, XGE } state = BASE; int literal = 0; @@ -2462,10 +2472,10 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p char *ws; #endif /*]*/ - CHECK_SESSION_HANDLE(session); + CHECK_SESSION_HANDLE(hSession); - orig_addr = session->cursor_addr; - orig_col = BA_TO_COL(session->cursor_addr); + orig_addr = hSession->cursor_addr; + orig_col = BA_TO_COL(hSession->cursor_addr); if(len < 0) len = strlen(s); @@ -2474,12 +2484,14 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p * Convert from a multi-byte string to a Unicode string. */ #if defined(X3270_DBCS) /*[*/ - if (len > w_ibuf_len) { + if (len > w_ibuf_len) + { w_ibuf_len = len; w_ibuf = (UChar *)Realloc(w_ibuf, w_ibuf_len * sizeof(UChar)); } len = mb_to_unicode(s, len, w_ibuf, w_ibuf_len, NULL); - if (len < 0) { + if (len < 0) + { return 0; /* failed */ } ws = w_ibuf; @@ -2491,13 +2503,14 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p * In the switch statements below, "break" generally means "consume * this character," while "continue" means "rescan this character." */ - while (len) { + while (len) + { /* * It isn't possible to unlock the keyboard from a string, * so if the keyboard is locked, it's fatal */ - if (session->kybdlock) + if (hSession->kybdlock) { trace_event(" keyboard locked, string dropped\n"); return 0; @@ -2506,13 +2519,13 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p if (pasting && IN_3270) { /* Check for cursor wrap to top of screen. */ - if (session->cursor_addr < orig_addr) + if (hSession->cursor_addr < orig_addr) return len-1; /* wrapped */ /* Jump cursor over left margin. */ - if (lib3270_get_toggle(&h3270,LIB3270_TOGGLE_MARGINED_PASTE) && - BA_TO_COL(session->cursor_addr) < orig_col) { - if (!remargin(&h3270,orig_col)) + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_MARGINED_PASTE) && BA_TO_COL(hSession->cursor_addr) < orig_col) + { + if (!remargin(hSession,orig_col)) return len-1; skipped = True; } @@ -2520,59 +2533,73 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p c = *ws; - switch (state) { + switch (state) + { case BASE: - switch (c) { - case '\b': - lib3270_cursor_left(session); + switch (c) + { + case '\b': + lib3270_cursor_left(hSession); skipped = False; break; - case '\f': - if (pasting) { - key_ACharacter(session,(unsigned char) ' ',KT_STD, ia, &skipped); - } else { - lib3270_clear(session); + + case '\f': + if (pasting) + { + key_ACharacter(hSession,(unsigned char) ' ',KT_STD, ia, &skipped); + } else + { + lib3270_clear(hSession); skipped = False; if (IN_3270) return len-1; } break; - case '\n': - if (pasting) { + + case '\n': + if (pasting) + { if (!skipped) - lib3270_cursor_newline(session); -// action_internal(Newline_action,ia, CN, CN); + lib3270_cursor_newline(hSession); skipped = False; - } else { - lib3270_enter(session); + } + else + { + lib3270_enter(hSession); skipped = False; if (IN_3270) return len-1; } break; - case '\r': /* ignored */ + + case '\r': /* ignored */ break; - case '\t': - lib3270_nextfield(session); + + case '\t': + lib3270_nextfield(hSession); skipped = False; break; - case '\\': /* backslashes are NOT special when - pasting */ + + case '\\': /* backslashes are NOT special when pasting */ if (!pasting) state = BACKSLASH; else - key_ACharacter(session,(unsigned char) c,KT_STD, ia, &skipped); + key_ACharacter(hSession,(unsigned char) c,KT_STD, ia, &skipped); break; - case '\033': /* ESC is special only when pasting */ + + case '\033': /* ESC is special only when pasting */ if (pasting) state = XGE; break; - case '[': /* APL left bracket */ - key_ACharacter(session,(unsigned char) c, KT_STD, ia, &skipped); + + case '[': /* APL left bracket */ + key_ACharacter(hSession,(unsigned char) c, KT_STD, ia, &skipped); break; - case ']': /* APL right bracket */ - key_ACharacter(session,(unsigned char) c, KT_STD, ia, &skipped); + + case ']': /* APL right bracket */ + key_ACharacter(hSession,(unsigned char) c, KT_STD, ia, &skipped); break; + default: /* #if defined(X3270_DBCS) @@ -2593,232 +2620,271 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *session, char *s, int len, int p break; } #endif */ - key_ACharacter(session,(unsigned char) c, KT_STD, ia, &skipped); + key_ACharacter(hSession,(unsigned char) c, KT_STD, ia, &skipped); break; } break; + case BACKSLASH: /* last character was a backslash */ - switch (c) { - case 'a': - popup_an_error(session,"%s: Bell not supported",action_name(String_action)); -// cancel_if_idle_command(); - state = BASE; - break; - case 'b': - lib3270_cursor_left(session); -// action_internal(Left_action, ia, CN, CN); - skipped = False; - state = BASE; - break; - case 'f': - lib3270_clear(session); - skipped = False; - state = BASE; - if (IN_3270) - return len-1; - else + switch (c) + { + case 'a': + popup_an_error(hSession,_( "%s: Bell not supported" ),action_name(String_action)); + state = BASE; break; - case 'n': - lib3270_enter(session); - skipped = False; - state = BASE; - if (IN_3270) - return len-1; - else + + case 'b': + lib3270_cursor_left(hSession); + skipped = False; + state = BASE; break; - case 'p': - state = BACKP; - break; - case 'r': - lib3270_cursor_newline(session); -// action_internal(Newline_action, ia, CN, CN); + case 'f': + lib3270_clear(hSession); + skipped = False; + state = BASE; + if (IN_3270) + return len-1; + else + break; + + case 'n': + lib3270_enter(hSession); + skipped = False; + state = BASE; + if (IN_3270) + return len-1; + else + break; + + case 'p': + state = BACKP; + break; + + case 'r': + lib3270_cursor_newline(hSession); skipped = False; state = BASE; break; - case 't': - lib3270_nextfield(session); - skipped = False; - state = BASE; - break; - case 'T': - lib3270_nextfield(session); - skipped = False; - state = BASE; - break; - case 'v': - popup_an_error(NULL,"%s: Vertical tab not supported",action_name(String_action)); -// cancel_if_idle_command(); - state = BASE; - break; - case 'x': - state = BACKX; - break; - case '\\': - key_ACharacter(session,(unsigned char) c, KT_STD, ia,&skipped); - state = BASE; + case 't': + lib3270_nextfield(hSession); + skipped = False; + state = BASE; + break; + + case 'T': + lib3270_nextfield(hSession); + skipped = False; + state = BASE; + break; + + case 'v': + popup_an_error(hSession,_( "%s: Vertical tab not supported" ),action_name(String_action)); + state = BASE; + break; + + case 'x': + state = BACKX; + break; + + case '\\': + key_ACharacter(hSession,(unsigned char) c, KT_STD, ia,&skipped); + state = BASE; + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + state = OCTAL; + literal = 0; + nc = 0; + continue; + + default: + state = BASE; + continue; + } break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - state = OCTAL; - literal = 0; - nc = 0; - continue; - default: - state = BASE; - continue; - } - break; + case BACKP: /* last two characters were "\p" */ - switch (c) { - case 'a': - literal = 0; - nc = 0; - state = BACKPA; - break; - case 'f': - literal = 0; - nc = 0; - state = BACKPF; - break; - default: - popup_an_error(NULL,"%s: Unknown character after \\p", - action_name(String_action)); -// cancel_if_idle_command(); - state = BASE; + switch (c) + { + case 'a': + literal = 0; + nc = 0; + state = BACKPA; + break; + + case 'f': + literal = 0; + nc = 0; + state = BACKPF; + break; + + default: + popup_an_error(hSession,_( "%s: Unknown character after \\p" ),action_name(String_action)); + state = BASE; + break; + } break; - } - break; + case BACKPF: /* last three characters were "\pf" */ - if (nc < 2 && isdigit(c)) { - literal = (literal * 10) + (c - '0'); - nc++; - } else if (!nc) { - popup_an_error(NULL,"%s: Unknown character after \\pf", - action_name(String_action)); -// cancel_if_idle_command(); - state = BASE; - } else { - do_pf(literal); - skipped = False; - if (IN_3270) - return len-1; - state = BASE; - continue; - } - break; + if (nc < 2 && isdigit(c)) + { + literal = (literal * 10) + (c - '0'); + nc++; + } + else if (!nc) + { + popup_an_error(hSession,_( "%s: Unknown character after \\pf" ),action_name(String_action)); + state = BASE; + } + else + { + do_pf(literal); + skipped = False; + if (IN_3270) + return len-1; + state = BASE; + continue; + } + break; + case BACKPA: /* last three characters were "\pa" */ - if (nc < 1 && isdigit(c)) { - literal = (literal * 10) + (c - '0'); - nc++; - } else if (!nc) { - popup_an_error(NULL,"%s: Unknown character after \\pa", - action_name(String_action)); -// cancel_if_idle_command(); - state = BASE; - } else { - do_pa(literal); - skipped = False; - if (IN_3270) - return len-1; - state = BASE; - continue; - } - break; + if (nc < 1 && isdigit(c)) + { + literal = (literal * 10) + (c - '0'); + nc++; + } + else if (!nc) + { + popup_an_error(hSession,_( "%s: Unknown character after \\pa" ),action_name(String_action)); + state = BASE; + } + else + { + do_pa(literal); + skipped = False; + if (IN_3270) + return len-1; + state = BASE; + continue; + } + break; + case BACKX: /* last two characters were "\x" */ - if (isxdigit(c)) { - state = HEX; - literal = 0; - nc = 0; - continue; - } else { - popup_an_error(session,_( "%s: Missing hex digits after \\x" ),action_name(String_action)); -// cancel_if_idle_command(); - state = BASE; + if (isxdigit(c)) + { + state = HEX; + literal = 0; + nc = 0; + continue; + } + else + { + popup_an_error(hSession,_( "%s: Missing hex digits after \\x" ),action_name(String_action)); + state = BASE; + continue; + } continue; - } + case OCTAL: /* have seen \ and one or more octal digits */ - if (nc < 3 && isdigit(c) && c < '8') { - literal = (literal * 8) + FROM_HEX(c); - nc++; - break; - } else { - key_ACharacter(session,(unsigned char) literal, KT_STD,ia, &skipped); - state = BASE; - continue; - } + if (nc < 3 && isdigit(c) && c < '8') + { + literal = (literal * 8) + FROM_HEX(c); + nc++; + break; + } + else + { + key_ACharacter(hSession,(unsigned char) literal, KT_STD,ia, &skipped); + state = BASE; + continue; + } + case HEX: /* have seen \ and one or more hex digits */ - if (nc < 2 && isxdigit(c)) { - literal = (literal * 16) + FROM_HEX(c); - nc++; - break; - } else { - key_ACharacter(session,(unsigned char) literal, KT_STD, ia, &skipped); - state = BASE; - continue; - } + if (nc < 2 && isxdigit(c)) + { + literal = (literal * 16) + FROM_HEX(c); + nc++; + break; + } + else + { + key_ACharacter(hSession,(unsigned char) literal, KT_STD, ia, &skipped); + state = BASE; + continue; + } + case XGE: /* have seen ESC */ - switch (c) { - case ';': /* FM */ - key_Character(session, EBC_fm, False, True, &skipped); - break; - case '*': /* DUP */ - key_Character(session, EBC_dup, False, True, &skipped); - break; - default: - key_ACharacter(session,(unsigned char) c, KT_GE, ia,&skipped); + switch (c) + { + case ';': /* FM */ + key_Character(hSession, EBC_fm, False, True, &skipped); + break; + + case '*': /* DUP */ + key_Character(hSession, EBC_dup, False, True, &skipped); + break; + + default: + key_ACharacter(hSession,(unsigned char) c, KT_GE, ia,&skipped); + break; + } + state = BASE; break; - } - state = BASE; - break; } ws++; len--; } - switch (state) { + switch (state) + { case BASE: - if (lib3270_get_toggle(session,LIB3270_TOGGLE_MARGINED_PASTE) && - BA_TO_COL(session->cursor_addr) < orig_col) { - (void) remargin(session,orig_col); - } - break; + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_MARGINED_PASTE) && BA_TO_COL(hSession->cursor_addr) < orig_col) + { + (void) remargin(hSession,orig_col); + } + break; + case OCTAL: case HEX: - key_ACharacter(session,(unsigned char) literal, KT_STD, ia, &skipped); - state = BASE; - if (lib3270_get_toggle(session,LIB3270_TOGGLE_MARGINED_PASTE) && - BA_TO_COL(session->cursor_addr) < orig_col) { - (void) remargin(session,orig_col); - } - break; - case BACKPF: - if (nc > 0) { - do_pf(literal); + key_ACharacter(hSession,(unsigned char) literal, KT_STD, ia, &skipped); state = BASE; - } - break; + if (lib3270_get_toggle(hSession,LIB3270_TOGGLE_MARGINED_PASTE) && BA_TO_COL(hSession->cursor_addr) < orig_col) + { + (void) remargin(hSession,orig_col); + } + break; + + case BACKPF: + if (nc > 0) + { + do_pf(literal); + state = BASE; + } + break; + case BACKPA: - if (nc > 0) { - do_pa(literal); - state = BASE; - } - break; + if (nc > 0) + { + do_pa(literal); + state = BASE; + } + break; + default: - popup_an_error(NULL,"%s: Missing data after \\", - action_name(String_action)); -// cancel_if_idle_command(); - break; + popup_an_error(hSession,"%s: Missing data after \\",action_name(String_action)); + break; } - session->display(session); + hSession->display(hSession); return len; } diff --git a/src/lib3270/paste.c b/src/lib3270/paste.c index e8cd313..5b5bf28 100644 --- a/src/lib3270/paste.c +++ b/src/lib3270/paste.c @@ -46,8 +46,7 @@ #include -#include -//#include "appres.h" +#include "3270ds.h" #include "resources.h" #include "actionsc.h" @@ -99,16 +98,16 @@ * Move the cursor back within the legal paste area. * Returns a Boolean indicating success. */ - static int remargin(H3270 *session, int lmargin) + static int remargin(H3270 *hSession, int lmargin) { int ever = False; int baddr, b0 = 0; int faddr; unsigned char fa; - if(lib3270_get_toggle(session,LIB3270_TOGGLE_MARGINED_PASTE)) + if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_MARGINED_PASTE)) { - baddr = session->cursor_addr; + baddr = hSession->cursor_addr; while(BA_TO_COL(baddr) < lmargin) { baddr = ROWCOL_TO_BA(BA_TO_ROW(baddr), lmargin); @@ -118,46 +117,46 @@ ever = True; } - faddr = find_field_attribute(session,baddr); - fa = session->ea_buf[faddr].fa; + faddr = find_field_attribute(hSession,baddr); + fa = hSession->ea_buf[faddr].fa; if (faddr == baddr || FA_IS_PROTECTED(fa)) { - baddr = next_unprotected(session,baddr); + baddr = next_unprotected(hSession,baddr); if (baddr <= b0) return 0; } } - cursor_move(session,baddr); + cursor_move(hSession,baddr); } return -1; } - static int paste_char(H3270 *session, PASTE_DATA *data, unsigned char c) + static int paste_char(H3270 *hSession, PASTE_DATA *data, unsigned char c) { - if(lib3270_get_toggle(session,LIB3270_TOGGLE_SMART_PASTE)) + if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_SMART_PASTE)) { - int faddr = find_field_attribute(session,session->cursor_addr); - if(FA_IS_PROTECTED(session->ea_buf[faddr].fa)) - session->cursor_addr++; + int faddr = find_field_attribute(hSession,hSession->cursor_addr); + if(FA_IS_PROTECTED(hSession->ea_buf[faddr].fa)) + hSession->cursor_addr++; else - key_ACharacter(session, c, KT_STD, IA_PASTE, NULL); + key_ACharacter(hSession, c, KT_STD, IA_PASTE, NULL); } else { - key_ACharacter(session, c, KT_STD, IA_PASTE, NULL); + key_ACharacter(hSession, c, KT_STD, IA_PASTE, NULL); } data->qtd++; - if(BA_TO_ROW(session->cursor_addr) != data->row) + if(BA_TO_ROW(hSession->cursor_addr) != data->row) { - trace("Row changed from %d to %d",data->row,BA_TO_ROW(session->cursor_addr)); - if(!remargin(session,data->orig_col)) + trace("Row changed from %d to %d",data->row,BA_TO_ROW(hSession->cursor_addr)); + if(!remargin(hSession,data->orig_col)) return 0; - data->row = BA_TO_ROW(session->cursor_addr); + data->row = BA_TO_ROW(hSession->cursor_addr); return '\n'; } @@ -167,35 +166,35 @@ /** * Set string at cursor position. * - * @param h Session handle. - * @param str String to set + * @param hSession Session handle. + * @param str String to set * * @return Number of characters inserted; <0 in case of error. * */ -LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) +LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str) { PASTE_DATA data; unsigned char last = 1; - CHECK_SESSION_HANDLE(h); + CHECK_SESSION_HANDLE(hSession); memset(&data,0,sizeof(data)); - data.row = BA_TO_ROW(h->cursor_addr); - data.orig_addr = h->cursor_addr; - data.orig_col = BA_TO_COL(h->cursor_addr); + data.row = BA_TO_ROW(hSession->cursor_addr); + data.orig_addr = hSession->cursor_addr; + data.orig_col = BA_TO_COL(hSession->cursor_addr); - if(h->kybdlock) + if(hSession->kybdlock) return -EINVAL; - h->suspend(h); + hSession->suspend(hSession); - while(*str && last && !h->kybdlock && h->cursor_addr >= data.orig_addr) + while(*str && last && !hSession->kybdlock && hSession->cursor_addr >= data.orig_addr) { switch(*str) { case '\t': - last = paste_char(h,&data, ' '); + last = paste_char(hSession,&data, ' '); break; case '\n': @@ -205,37 +204,37 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *h, const unsigned char *str) int faddr; unsigned char fa; - baddr = (h->cursor_addr + h->cols) % (h->cols * h->rows); /* down */ - baddr = (baddr / h->cols) * h->cols; /* 1st col */ - faddr = find_field_attribute(h,baddr); - fa = h->ea_buf[faddr].fa; + baddr = (hSession->cursor_addr + hSession->cols) % (hSession->cols * hSession->rows); /* down */ + baddr = (baddr / hSession->cols) * hSession->cols; /* 1st col */ + faddr = find_field_attribute(hSession,baddr); + fa = hSession->ea_buf[faddr].fa; if (faddr != baddr && !FA_IS_PROTECTED(fa)) - cursor_move(h,baddr); + cursor_move(hSession,baddr); else - cursor_move(h,next_unprotected(h,baddr)); - data.row = BA_TO_ROW(h->cursor_addr); + cursor_move(hSession,next_unprotected(hSession,baddr)); + data.row = BA_TO_ROW(hSession->cursor_addr); } last = ' '; data.qtd++; break; default: - last = paste_char(h,&data, *str); + last = paste_char(hSession,&data, *str); } str++; - if(IN_3270 && lib3270_get_toggle(h,LIB3270_TOGGLE_MARGINED_PASTE) && BA_TO_COL(h->cursor_addr) < data.orig_col) + if(IN_3270 && lib3270_get_toggle(hSession,LIB3270_TOGGLE_MARGINED_PASTE) && BA_TO_COL(hSession->cursor_addr) < data.orig_col) { - if(!remargin(h,data.orig_col)) + if(!remargin(hSession,data.orig_col)) last = 0; } - if(h->cursor_addr == data.orig_addr) + if(hSession->cursor_addr == data.orig_addr) break; } - h->resume(h); + hSession->resume(hSession); return data.qtd; } diff --git a/src/lib3270/proxy.c b/src/lib3270/proxy.c index 7d13590..34ebeb2 100644 --- a/src/lib3270/proxy.c +++ b/src/lib3270/proxy.c @@ -70,7 +70,7 @@ #include "api.h" -#include +#include "3270ds.h" #include "popupsc.h" #include "proxyc.h" #include "resolverc.h" diff --git a/src/lib3270/rpq.c b/src/lib3270/rpq.c index ff518c0..2e252ab 100644 --- a/src/lib3270/rpq.c +++ b/src/lib3270/rpq.c @@ -56,8 +56,7 @@ #include #include -#include -//#include "appres.h" +#include "3270ds.h" #include "popupsc.h" #include "tablesc.h" diff --git a/src/lib3270/screen.c b/src/lib3270/screen.c index 5570199..76be4fe 100644 --- a/src/lib3270/screen.c +++ b/src/lib3270/screen.c @@ -38,7 +38,7 @@ #include "globals.h" #include //#include "appres.h" -#include +#include "3270ds.h" #include "resources.h" // #include "ctlr.h" diff --git a/src/lib3270/see.c b/src/lib3270/see.c index cdabcbf..f5b0d68 100644 --- a/src/lib3270/see.c +++ b/src/lib3270/see.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include "3270ds.h" #include "tablesc.h" #if !defined(PR3287) /*[*/ diff --git a/src/lib3270/session.c b/src/lib3270/session.c index 8d1b3db..7a303a0 100644 --- a/src/lib3270/session.c +++ b/src/lib3270/session.c @@ -43,7 +43,7 @@ #include "ctlrc.h" #include "ftc.h" #include "kybdc.h" -#include +#include "3270ds.h" /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ diff --git a/src/lib3270/sf.c b/src/lib3270/sf.c index aa8e613..c9d2833 100644 --- a/src/lib3270/sf.c +++ b/src/lib3270/sf.c @@ -42,7 +42,7 @@ #if !defined(_WIN32) /*[*/ #include #endif /*]*/ -#include +#include "3270ds.h" // #include "appres.h" #include "screen.h" // #include "ctlr.h" diff --git a/src/lib3270/telnet.c b/src/lib3270/telnet.c index b6c85bd..593c28f 100644 --- a/src/lib3270/telnet.c +++ b/src/lib3270/telnet.c @@ -81,7 +81,7 @@ // #include #include "tn3270e.h" -#include +#include "3270ds.h" // #include "appres.h" @@ -1001,7 +1001,7 @@ LIB3270_EXPORT void lib3270_data_recv(H3270 *hSession, size_t nr, const unsigned { if(telnet_fsm(hSession,*cp)) { - (void) ctlr_dbcs_postprocess(); + (void) ctlr_dbcs_postprocess(hSession); host_disconnect(hSession,True); return; } @@ -1010,7 +1010,7 @@ LIB3270_EXPORT void lib3270_data_recv(H3270 *hSession, size_t nr, const unsigned #if defined(X3270_ANSI) if (IN_ANSI) { - (void) ctlr_dbcs_postprocess(); + (void) ctlr_dbcs_postprocess(hSession); } if (hSession->ansi_data) @@ -1135,7 +1135,7 @@ void net_input(H3270 *session) { if (telnet_fsm(session,*cp)) { - (void) ctlr_dbcs_postprocess(); + (void) ctlr_dbcs_postprocess(hSession); host_disconnect(session,True); return; } @@ -1144,7 +1144,7 @@ void net_input(H3270 *session) #if defined(X3270_ANSI) if (IN_ANSI) { - (void) ctlr_dbcs_postprocess(); + (void) ctlr_dbcs_postprocess(hSession); } if (session->ansi_data) diff --git a/src/lib3270/trace_ds.c b/src/lib3270/trace_ds.c index 01823e9..1936eec 100644 --- a/src/lib3270/trace_ds.c +++ b/src/lib3270/trace_ds.c @@ -52,7 +52,7 @@ #include #include #include -#include +#include "3270ds.h" //#include "appres.h" #include "objects.h" #include "resources.h" -- libgit2 0.21.2