diff --git a/src/classlib/remote.cc b/src/classlib/remote.cc index 4a0767d..433e40d 100644 --- a/src/classlib/remote.cc +++ b/src/classlib/remote.cc @@ -195,10 +195,8 @@ status = TransactNamedPipe(hPipe,(LPVOID) &packet, cbSize, &packet, sizeof(packet), &cbSize,NULL); - if(status) - return packet.rc; - - throw exception(GetLastError(),"%s","Transaction error"); + if(!status) + throw exception(GetLastError(),"%s","Transaction error"); } diff --git a/src/classlib/session.cc b/src/classlib/session.cc index 4b02373..19da795 100644 --- a/src/classlib/session.cc +++ b/src/classlib/session.cc @@ -48,7 +48,33 @@ #ifdef _WIN32 - #error Implementar + class recursive_mutex { + private: + HANDLE hMutex; + + public: + recursive_mutex() { + hMutex = CreateMutex(NULL,FALSE,NULL); + }; + + ~recursive_mutex() { + CloseHandle(hMutex); + }; + + void lock(void) { + WaitForSingleObject(hMutex,INFINITE); + }; + + void unlock(void) { + ReleaseMutex(hMutex); + }; + + bool try_lock(void) { + if(WaitForSingleObject(hMutex,1) == WAIT_OBJECT_0) + return true; + return false; + }; + }; #else diff --git a/src/include/lib3270/session.h b/src/include/lib3270/session.h index 19c5ff7..565d9ef 100644 --- a/src/include/lib3270/session.h +++ b/src/include/lib3270/session.h @@ -44,36 +44,81 @@ #define LIB3270_TELNET_N_OPTS 256 /** extended attributes */ + struct lib3270_ea; + struct lib3270_text; + + /* struct lib3270_ea { - unsigned char cc; /**< EBCDIC or ASCII character code */ - unsigned char fa; /**< field attribute, it nonzero */ - unsigned char fg; /**< foreground color (0x00 or 0xf) */ - unsigned char bg; /**< background color (0x00 or 0xf) */ - unsigned char gr; /**< ANSI graphics rendition bits */ - unsigned char cs; /**< character set (GE flag, or 0..2) */ - unsigned char ic; /**< input control (DBCS) */ - unsigned char db; /**< DBCS state */ + unsigned char cc; ///< @brief EBCDIC or ASCII character code + unsigned char fa; ///< @brief field attribute, it nonzero + unsigned char fg; ///< @brief foreground color (0x00 or 0xf) + unsigned char bg; ///< @brief background color (0x00 or 0xf) + unsigned char gr; ///< @brief ANSI graphics rendition bits + unsigned char cs; ///< @brief character set (GE flag, or 0..2) + unsigned char ic; ///< @brief input control (DBCS) + unsigned char db; ///< @brief DBCS state }; + */ + /* struct lib3270_text { - unsigned char chr; /**< ASCII character code */ - unsigned short attr; /**< Converted character attribute (color & etc) */ + unsigned char chr; ///< ASCII character code + unsigned short attr; ///< Converted character attribute (color & etc) }; + */ -#ifndef HEADER_SSL_H - #define SSL void -#endif // !HEADER_SSL_H + #ifndef HEADER_SSL_H + #define SSL void + #endif // !HEADER_SSL_H -#ifndef LIB3270_TA - #define LIB3270_TA void -#endif // !LIB3270_TA + #ifndef LIB3270_TA + #define LIB3270_TA void + #endif // !LIB3270_TA #define LIB3270_MB_MAX 16 #define LIB3270_DEFAULT_CGEN 0x02b90000 #define LIB3270_DEFAULT_CSET 0x00000025 + struct lib3270_session_callbacks + { + unsigned short sz; + + int (*write)(H3270 *hSession, unsigned const char *buf, int len); + void (*disconnect)(H3270 *hSession); + + void (*configure)(H3270 *session, unsigned short rows, unsigned short cols); + void (*update)(H3270 *session, int baddr, unsigned char c, unsigned short attr, unsigned char cursor); + void (*changed)(H3270 *session, int offset, int len); + void (*display)(H3270 *session); + void (*set_width)(H3270 *session, int width); + + void (*update_cursor)(H3270 *session, unsigned short row, unsigned short col, unsigned char c, unsigned short attr); + void (*update_oia)(H3270 *session, LIB3270_FLAG id, unsigned char on); + void (*update_toggle)(H3270 *session, LIB3270_TOGGLE ix, unsigned char value, LIB3270_TOGGLE_TYPE reason, const char *name); + void (*update_luname)(H3270 *session, const char *name); + void (*update_status)(H3270 *session, LIB3270_MESSAGE id); + void (*update_connect)(H3270 *session, unsigned char connected); + void (*update_model)(H3270 *session, const char *name, int model, int rows, int cols); + void (*update_selection)(H3270 *session, int start, int end); + void (*update_ssl)(H3270 *session, LIB3270_SSL_STATE state); + + void (*set_timer)(H3270 *session, unsigned char on); + void (*erase)(H3270 *session); + void (*suspend)(H3270 *session); + void (*resume)(H3270 *session); + void (*cursor)(H3270 *session, LIB3270_CURSOR id); + void (*set_selection)(H3270 *session, unsigned char on); + void (*ctlr_done)(H3270 *session); + void (*autostart)(H3270 *session); + int (*print)(H3270 *session); + + void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); + + }; + + struct _h3270 { unsigned short sz; /**< Struct size */ @@ -380,11 +425,13 @@ unsigned long ssl_error; SSL * ssl_con; - // State change callbacks. - struct lib3270_state_callback *st_callbacks[LIB3270_STATE_USER]; - struct lib3270_state_callback *st_last[LIB3270_STATE_USER]; + // Callbacks. + struct lib3270_state_callback * st_callbacks[LIB3270_STATE_USER]; + struct lib3270_state_callback * st_last[LIB3270_STATE_USER]; + struct lib3270_session_callbacks cbk; // Session based callbacks + /* int (*write)(H3270 *hSession, unsigned const char *buf, int len); void (*disconnect)(H3270 *hSession); @@ -415,6 +462,7 @@ int (*print)(H3270 *session); void (*message)(H3270 *session, LIB3270_NOTIFY id , const char *title, const char *message, const char *text); + */ }; diff --git a/src/include/pw3270/hllapi.h b/src/include/pw3270/hllapi.h index d6b7ed4..acd7fef 100644 --- a/src/include/pw3270/hllapi.h +++ b/src/include/pw3270/hllapi.h @@ -169,6 +169,7 @@ extern "C" { HLLAPI_API_CALL hllapi_cmp_text_at(WORD row, WORD col, LPSTR text); HLLAPI_API_CALL hllapi_emulate_input(LPSTR buffer, WORD len, WORD pasting); HLLAPI_API_CALL hllapi_wait_for_ready(WORD seconds); + HLLAPI_API_CALL hllapi_wait_for_change(WORD seconds); HLLAPI_API_CALL hllapi_wait(WORD seconds); HLLAPI_API_CALL hllapi_pfkey(WORD key); HLLAPI_API_CALL hllapi_pakey(WORD key); @@ -209,6 +210,7 @@ extern "C" { HLLAPI_API_CALL hllapi_getcursor(); HLLAPI_API_CALL hllapi_erase_eof(void); HLLAPI_API_CALL hllapi_print(void); + HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms); #ifdef __cplusplus } /* end of extern "C" */ diff --git a/src/include/pw3270/ipcpackets.h b/src/include/pw3270/ipcpackets.h index 1324778..d52c84f 100644 --- a/src/include/pw3270/ipcpackets.h +++ b/src/include/pw3270/ipcpackets.h @@ -189,7 +189,6 @@ struct hllapi_packet_set_text struct hllapi_packet_set_int { unsigned char packet_id; - int rc; int value; }; diff --git a/src/lib3270/ansi.c b/src/lib3270/ansi.c index 91b5b5f..fe8d552 100644 --- a/src/lib3270/ansi.c +++ b/src/lib3270/ansi.c @@ -618,7 +618,7 @@ static enum lib3270_ansi_state ansi_reset(H3270 *hSession, int ig1 unused, int i ctlr_aclear(hSession, 0, hSession->rows * hSession->cols, 1); ctlr_altbuffer(hSession,False); ctlr_clear(hSession,False); - hSession->set_width(hSession,80); + hSession->cbk.set_width(hSession,80); hSession->ansi_reset = 1; } hSession->pmi = 0; @@ -1459,7 +1459,7 @@ dec_set(H3270 *hSession, int ig1 unused, int ig2 unused) if(hSession->allow_wide_mode) { hSession->wide_mode = 1; - hSession->set_width(hSession,132); + hSession->cbk.set_width(hSession,132); } break; case 7: /* wraparound mode */ @@ -1493,7 +1493,7 @@ dec_reset(H3270 *hSession, int ig1 unused, int ig2 unused) if (hSession->allow_wide_mode) { hSession->wide_mode = 0; - hSession->set_width(hSession,80); + hSession->cbk.set_width(hSession,80); } break; case 7: /* no wraparound mode */ @@ -1556,7 +1556,7 @@ dec_restore(H3270 *hSession, int ig1 unused, int ig2 unused) if (hSession->allow_wide_mode) { hSession->wide_mode = hSession->saved_wide_mode; - hSession->set_width(hSession,hSession->wide_mode ? 132 : 80); + hSession->cbk.set_width(hSession,hSession->wide_mode ? 132 : 80); } break; case 7: /* wraparound mode */ diff --git a/src/lib3270/charset.c b/src/lib3270/charset.c index 3373c33..162e1f3 100644 --- a/src/lib3270/charset.c +++ b/src/lib3270/charset.c @@ -401,7 +401,7 @@ LIB3270_ACTION( charsettable ) baddr++; } - hSession->display(hSession); + hSession->cbk.display(hSession); return 0; } diff --git a/src/lib3270/ctlr.c b/src/lib3270/ctlr.c index 569a798..a07d6c5 100644 --- a/src/lib3270/ctlr.c +++ b/src/lib3270/ctlr.c @@ -95,9 +95,9 @@ static const unsigned char code_table[64] = #define IsBlank(c) ((c == EBC_null) || (c == EBC_space)) -#define ALL_CHANGED(h) if(lib3270_in_ansi(h)) (h)->changed(h,0,(h)->rows*(h)->cols); -#define REGION_CHANGED(h, f, l) if(lib3270_in_ansi(h)) (h)->changed(h,f,l) -#define ONE_CHANGED(h,n) if(lib3270_in_ansi(h)) (h)->changed(h,n,n+1); +#define ALL_CHANGED(h) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,0,(h)->rows*(h)->cols); +#define REGION_CHANGED(h, f, l) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,f,l) +#define ONE_CHANGED(h,n) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,n,n+1); #define DECODE_BADDR(c1, c2) \ ((((c1) & 0xC0) == 0x00) ? \ @@ -379,16 +379,6 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) static void set_formatted(H3270 *hSession, int state) { hSession->formatted = state; -/* - int last = (int) hSession->formatted; - hSession->formatted = state; - - if( ((int) hSession->formatted) != last) - { - trace("Screen is now %s",hSession->formatted ? "formatted" : "unformatted"); - hSession->update_formatted(hSession,hSession->formatted); - } -*/ } /** @@ -640,7 +630,7 @@ void ctlr_erase(H3270 *session, int alt) kybd_inhibit(session,False); ctlr_clear(session,True); - session->erase(session); + session->cbk.erase(session); if(alt == session->screen_alt) return; @@ -648,7 +638,7 @@ void ctlr_erase(H3270 *session, int alt) if (alt) { /* Going from 24x80 to maximum. */ - session->display(session); + session->cbk.display(session); set_viewsize(session,session->maxROWS,session->maxCOLS); } @@ -660,7 +650,7 @@ void ctlr_erase(H3270 *session, int alt) if(session->vcontrol) { ctlr_blanks(session); - session->display(session); + session->cbk.display(session); } if(lib3270_get_toggle(session,LIB3270_TOGGLE_ALTSCREEN)) @@ -2465,7 +2455,7 @@ void ctlr_clear(H3270 *session, Boolean can_snap) session->sscp_start = 0; // ALL_CHANGED; - session->erase(session); + session->cbk.erase(session); } /** @@ -2700,7 +2690,7 @@ void ctlr_scroll(H3270 *hSession) /* Clear the last line. */ (void) memset((char *) &hSession->ea_buf[qty], 0, hSession->cols * sizeof(struct lib3270_ea)); - hSession->display(hSession); + hSession->cbk.display(hSession); } #endif /*]*/ @@ -2845,10 +2835,10 @@ void ticking_start(H3270 *hSession, Boolean anyway) { CHECK_SESSION_HANDLE(hSession); - if(hSession->set_timer) + if(hSession->cbk.set_timer) { if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_SHOW_TIMING) || anyway) - hSession->set_timer(hSession,1); + hSession->cbk.set_timer(hSession,1); } else { @@ -2875,9 +2865,9 @@ static void ticking_stop(H3270 *hSession) { CHECK_SESSION_HANDLE(hSession); - if(hSession->set_timer) + if(hSession->cbk.set_timer) { - hSession->set_timer(hSession,0); + hSession->cbk.set_timer(hSession,0); } else { diff --git a/src/lib3270/host.c b/src/lib3270/host.c index 08ae110..b371c54 100644 --- a/src/lib3270/host.c +++ b/src/lib3270/host.c @@ -125,8 +125,8 @@ void lib3270_set_connected(H3270 *hSession) hSession->starting = 1; // Enable autostart lib3270_st_changed(hSession, LIB3270_STATE_CONNECT, True); - if(hSession->update_connect) - hSession->update_connect(hSession,1); + if(hSession->cbk.update_connect) + hSession->cbk.update_connect(hSession,1); } void lib3270_set_disconnected(H3270 *hSession) @@ -143,10 +143,10 @@ void lib3270_set_disconnected(H3270 *hSession) status_changed(hSession,LIB3270_MESSAGE_DISCONNECTED); - if(hSession->update_connect) - hSession->update_connect(hSession,0); + if(hSession->cbk.update_connect) + hSession->cbk.update_connect(hSession,0); - hSession->update_ssl(hSession,hSession->secure); + hSession->cbk.update_ssl(hSession,hSession->secure); } diff --git a/src/lib3270/kybd.c b/src/lib3270/kybd.c index a2d42c9..2ffb146 100644 --- a/src/lib3270/kybd.c +++ b/src/lib3270/kybd.c @@ -1396,7 +1396,7 @@ LIB3270_ACTION( delete ) if (!hSession->ea_buf[baddr].fa) cursor_move(hSession,baddr); } - hSession->display(hSession); + hSession->cbk.display(hSession); return 0; } @@ -1428,7 +1428,7 @@ LIB3270_ACTION( backspace ) DEC_BA(baddr); cursor_move(hSession,baddr); } - hSession->display(hSession); + hSession->cbk.display(hSession); return 0; } @@ -1495,7 +1495,7 @@ static void do_erase(H3270 *hSession) cursor_move(hSession,baddr); (void) do_delete(hSession); } - hSession->display(hSession); + hSession->cbk.display(hSession); } LIB3270_ACTION( erase ) @@ -1876,7 +1876,7 @@ LIB3270_ACTION( dup ) #endif if (key_Character(hSession, EBC_dup, False, False, NULL)) { - hSession->display(hSession); + hSession->cbk.display(hSession); cursor_move(hSession,next_unprotected(hSession,hSession->cursor_addr)); } @@ -2036,7 +2036,7 @@ LIB3270_ACTION( eraseeol ) hSession->ea_buf[hSession->cursor_addr].cc = EBC_si; } (void) ctlr_dbcs_postprocess(hSession); - hSession->display(hSession); + hSession->cbk.display(hSession); return 0; } @@ -2093,7 +2093,7 @@ LIB3270_ACTION( eraseeof ) hSession->ea_buf[hSession->cursor_addr].cc = EBC_si; } (void) ctlr_dbcs_postprocess(hSession); - hSession->display(hSession); + hSession->cbk.display(hSession); return 0; } @@ -2149,7 +2149,7 @@ LIB3270_ACTION( eraseinput ) ctlr_clear(hSession,True); cursor_move(hSession,0); } - hSession->display(hSession); + hSession->cbk.display(hSession); return 0; } @@ -2218,7 +2218,7 @@ LIB3270_ACTION( deleteword ) else do_erase(hSession); } - hSession->display(hSession); + hSession->cbk.display(hSession); return 0; } @@ -2264,7 +2264,7 @@ LIB3270_ACTION( deletefield ) ctlr_add(hSession,baddr, EBC_null, 0); INC_BA(baddr); } - hSession->display(hSession); + hSession->cbk.display(hSession); return 0; } @@ -2909,7 +2909,7 @@ LIB3270_EXPORT int lib3270_emulate_input(H3270 *hSession, const char *s, int len break; } - hSession->display(hSession); + hSession->cbk.display(hSession); return len; } diff --git a/src/lib3270/paste.c b/src/lib3270/paste.c index 49af3db..32fe51f 100644 --- a/src/lib3270/paste.c +++ b/src/lib3270/paste.c @@ -238,12 +238,12 @@ LIB3270_EXPORT int lib3270_set_string_at(H3270 *hSession, int row, int col, cons if(row >= 0 && col >= 0 && row <= hSession->rows && col <= hSession->cols) { - hSession->suspend(hSession); + hSession->cbk.suspend(hSession); hSession->cursor_addr = (row * hSession->cols) + col; rc = set_string(hSession, str); - hSession->resume(hSession); + hSession->cbk.resume(hSession); } return rc; @@ -268,9 +268,9 @@ LIB3270_EXPORT int lib3270_set_string(H3270 *hSession, const unsigned char *str) if(hSession->kybdlock) return -EINVAL; - hSession->suspend(hSession); + hSession->cbk.suspend(hSession); rc = set_string(hSession, str); - hSession->resume(hSession); + hSession->cbk.resume(hSession); return rc; } diff --git a/src/lib3270/private.h b/src/lib3270/private.h index 607bf3e..1c6ec61 100644 --- a/src/lib3270/private.h +++ b/src/lib3270/private.h @@ -114,11 +114,6 @@ #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, @@ -141,16 +136,6 @@ LIB3270_INTERNAL const char * build_rpq_revision; #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; @@ -226,6 +211,28 @@ LIB3270_INTERNAL struct _ansictl char vlnext; } ansictl; +/** extended attributes */ +struct lib3270_ea +{ + unsigned char cc; ///< @brief EBCDIC or ASCII character code + unsigned char fa; ///< @brief field attribute, it nonzero + unsigned char fg; ///< @brief foreground color (0x00 or 0xf) + unsigned char bg; ///< @brief background color (0x00 or 0xf) + unsigned char gr; ///< @brief ANSI graphics rendition bits + unsigned char cs; ///< @brief character set (GE flag, or 0..2) + unsigned char ic; ///< @brief input control (DBCS) + unsigned char db; ///< @brief DBCS state +}; + +struct lib3270_text +{ + unsigned char chr; ///< @brief ASCII character code + unsigned short attr; ///< @brief Converted character attribute (color & etc) +}; + + + + /* default charset translation tables */ // LIB3270_INTERNAL const unsigned short ebc2asc0[256]; // LIB3270_INTERNAL const unsigned short asc2ft0[256]; diff --git a/src/lib3270/screen.c b/src/lib3270/screen.c index 5ef8ed3..6f04f7e 100644 --- a/src/lib3270/screen.c +++ b/src/lib3270/screen.c @@ -104,7 +104,7 @@ static void addch(H3270 *session, int baddr, unsigned char c, unsigned short att session->text[baddr].chr = c; session->text[baddr].attr = attr; - session->update(session,baddr,c,attr,baddr == session->cursor_addr); + session->cbk.update(session,baddr,c,attr,baddr == session->cursor_addr); } LIB3270_EXPORT int lib3270_get_element(H3270 *h, int baddr, unsigned char *c, unsigned short *attr) @@ -140,7 +140,7 @@ int screen_init(H3270 *session) ctlr_reinit(session,-1); /* Finish screen initialization. */ - session->suspend(session); + session->cbk.suspend(session); return 0; } @@ -259,8 +259,8 @@ void update_model_info(H3270 *session, int model, int cols, int rows) /* Update the model name. */ (void) sprintf(session->model_name, "327%c-%d%s",session->m3279 ? '9' : '8',session->model_num,session->extended ? "-E" : ""); - trace("%s: %p",__FUNCTION__,session->update_model); - session->update_model(session, session->model_name,session->model_num,rows,cols); + trace("%s: %p",__FUNCTION__,session->cbk.update_model); + session->cbk.update_model(session, session->model_name,session->model_num,rows,cols); } LIB3270_EXPORT int lib3270_get_contents(H3270 *h, int first, int last, unsigned char *chr, unsigned short *attr) @@ -355,7 +355,7 @@ void screen_update(H3270 *session, int bstart, int bend) len++; } - session->changed(session,first,len); + session->cbk.changed(session,first,len); } if(session->starting && session->formatted && !session->kybdlock && lib3270_in_3270(session)) @@ -364,7 +364,7 @@ void screen_update(H3270 *session, int bstart, int bend) // cursor_move(session,next_unprotected(session,0)); // lib3270_emulate_input(session,"\\n",-1,0); - session->autostart(session); + session->cbk.autostart(session); #ifdef DEBUG { @@ -416,7 +416,7 @@ LIB3270_EXPORT int lib3270_set_cursor_position(H3270 *h, int row, int col) if(baddr != h->cursor_addr) { h->cursor_addr = baddr; - h->update_cursor(h,(unsigned short) row,(unsigned short) col,h->text[baddr].chr,h->text[baddr].attr); + h->cbk.update_cursor(h,(unsigned short) row,(unsigned short) col,h->text[baddr].chr,h->text[baddr].attr); } } @@ -434,7 +434,7 @@ int cursor_move(H3270 *h, int baddr) if(baddr >= 0) { h->cursor_addr = baddr; - h->update_cursor(h,(unsigned short) (baddr/h->cols),(unsigned short) (baddr%h->cols),h->text[baddr].chr,h->text[baddr].attr); + h->cbk.update_cursor(h,(unsigned short) (baddr/h->cols),(unsigned short) (baddr%h->cols),h->text[baddr].chr,h->text[baddr].attr); } return ret; @@ -447,7 +447,7 @@ void set_status(H3270 *session, LIB3270_FLAG id, Boolean on) CHECK_SESSION_HANDLE(session); session->oia_flag[id] = (on != 0); - session->update_oia(session,id,session->oia_flag[id]); + session->cbk.update_oia(session,id,session->oia_flag[id]); } @@ -455,7 +455,7 @@ void status_ctlr_done(H3270 *session) { CHECK_SESSION_HANDLE(session); set_status(session,OIA_FLAG_UNDERA,True); - session->ctlr_done(session); + session->cbk.ctlr_done(session); } void status_oerr(H3270 *session, int error_type) @@ -486,8 +486,8 @@ void status_oerr(H3270 *session, int error_type) void status_connecting(H3270 *session, Boolean on) { - if(session->cursor) - session->cursor(session,on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); + if(session->cbk.cursor) + session->cbk.cursor(session,on ? CURSOR_MODE_LOCKED : CURSOR_MODE_NORMAL); status_changed(session, on ? LIB3270_MESSAGE_CONNECTING : LIB3270_MESSAGE_NONE); } @@ -506,12 +506,12 @@ void status_reset(H3270 *session) } else { - if(session->cursor) - session->cursor(session,CURSOR_MODE_NORMAL); + if(session->cbk.cursor) + session->cbk.cursor(session,CURSOR_MODE_NORMAL); status_changed(session,LIB3270_MESSAGE_NONE); } - session->display(session); + session->cbk.display(session); } @@ -573,7 +573,7 @@ void status_changed(H3270 *session, LIB3270_STATUS id) session->oia_status = id; - session->update_status(session,id); + session->cbk.update_status(session,id); } void status_twait(H3270 *session) @@ -593,8 +593,8 @@ void set_viewsize(H3270 *session, int rows, int cols) session->rows = rows; session->cols = cols; - if(session->configure) - session->configure(session,session->rows,session->cols); + if(session->cbk.configure) + session->cbk.configure(session,session->rows,session->cols); } @@ -602,8 +602,8 @@ void status_lu(H3270 *session, const char *lu) { CHECK_SESSION_HANDLE(session); - if(session->update_luname) - session->update_luname(session,lu); + if(session->cbk.update_luname) + session->cbk.update_luname(session,lu); } @@ -660,8 +660,8 @@ void status_untiming(H3270 *session) { CHECK_SESSION_HANDLE(session); - if(session->set_timer) - session->set_timer(session,0); + if(session->cbk.set_timer) + session->cbk.set_timer(session,0); } static int logpopup(H3270 *session, void *widget, LIB3270_NOTIFY type, const char *title, const char *msg, const char *fmt, va_list arg) @@ -740,8 +740,8 @@ void mcursor_set(H3270 *session,LIB3270_CURSOR m) { CHECK_SESSION_HANDLE(session); - if(session->cursor) - session->cursor(session,m); + if(session->cbk.cursor) + session->cbk.cursor(session,m); } LIB3270_ACTION( testpattern ) @@ -832,7 +832,7 @@ LIB3270_ACTION( testpattern ) hSession->ea_buf[f].gr = gr[grpos]; } - hSession->display(hSession); + hSession->cbk.display(hSession); return 0; } diff --git a/src/lib3270/selection.c b/src/lib3270/selection.c index de2b4f7..ac3f99a 100644 --- a/src/lib3270/selection.c +++ b/src/lib3270/selection.c @@ -104,7 +104,7 @@ static void update_selected_rectangle(H3270 *session) if(!(row >= p[0].row && row <= p[1].row && col >= p[0].col && col <= p[1].col) && (session->text[baddr].attr & LIB3270_ATTR_SELECTED)) { session->text[baddr].attr &= ~LIB3270_ATTR_SELECTED; - session->update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); + session->cbk.update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); } baddr++; } @@ -119,7 +119,7 @@ static void update_selected_rectangle(H3270 *session) if((row >= p[0].row && row <= p[1].row && col >= p[0].col && col <= p[1].col) && !(session->text[baddr].attr & LIB3270_ATTR_SELECTED)) { session->text[baddr].attr |= LIB3270_ATTR_SELECTED; - session->update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); + session->cbk.update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); } baddr++; } @@ -140,7 +140,7 @@ static void update_selected_region(H3270 *session) if(session->text[baddr].attr & LIB3270_ATTR_SELECTED) { session->text[baddr].attr &= ~LIB3270_ATTR_SELECTED; - session->update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); + session->cbk.update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); } } @@ -149,7 +149,7 @@ static void update_selected_region(H3270 *session) if(session->text[baddr].attr & LIB3270_ATTR_SELECTED) { session->text[baddr].attr &= ~LIB3270_ATTR_SELECTED; - session->update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); + session->cbk.update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); } } @@ -159,7 +159,7 @@ static void update_selected_region(H3270 *session) if(!(session->text[baddr].attr & LIB3270_ATTR_SELECTED)) { session->text[baddr].attr |= LIB3270_ATTR_SELECTED; - session->update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); + session->cbk.update(session,baddr,session->text[baddr].chr,session->text[baddr].attr,baddr == session->cursor_addr); } } @@ -191,13 +191,13 @@ LIB3270_EXPORT int lib3270_unselect(H3270 *hSession) if(hSession->text[a].attr & LIB3270_ATTR_SELECTED) { hSession->text[a].attr &= ~LIB3270_ATTR_SELECTED; - if(hSession->update) - hSession->update(hSession,a,hSession->text[a].chr,hSession->text[a].attr,a == hSession->cursor_addr); + if(hSession->cbk.update) + hSession->cbk.update(hSession,a,hSession->text[a].chr,hSession->text[a].attr,a == hSession->cursor_addr); } } - hSession->set_selection(hSession,0); - hSession->update_selection(hSession,-1,-1); + hSession->cbk.set_selection(hSession,0); + hSession->cbk.update_selection(hSession,-1,-1); } return 0; @@ -268,10 +268,10 @@ static void do_select(H3270 *h, int start, int end, int rect) if(!h->selected) { h->selected = 1; - h->set_selection(h,1); + h->cbk.set_selection(h,1); } - h->update_selection(h,start,end); + h->cbk.update_selection(h,start,end); } @@ -602,11 +602,11 @@ static void copy_chr(H3270 *hSession, int from, int to) memcpy(&hSession->ea_buf[to], &hSession->ea_buf[from],sizeof(struct lib3270_ea)); hSession->ea_buf[from].fa = 0; - hSession->update( hSession, - to, - hSession->text[to].chr, - hSession->text[to].attr, - to == hSession->cursor_addr ); + hSession->cbk.update( hSession, + to, + hSession->text[to].chr, + hSession->text[to].attr, + to == hSession->cursor_addr ); } static void clear_chr(H3270 *hSession, int baddr) @@ -616,11 +616,11 @@ static void clear_chr(H3270 *hSession, int baddr) hSession->ea_buf[baddr].cc = EBC_null; hSession->ea_buf[baddr].cs = 0; - hSession->update( hSession, - baddr, - hSession->text[baddr].chr, - hSession->text[baddr].attr, - baddr == hSession->cursor_addr ); + hSession->cbk.update( hSession, + baddr, + hSession->text[baddr].chr, + hSession->text[baddr].attr, + baddr == hSession->cursor_addr ); } int cut_addr(H3270 *hSession, int daddr, int saddr, int maxlen, int *sattr) @@ -727,7 +727,7 @@ char * cut_text(H3270 *hSession, char tok) if(!hSession->ea_buf[daddr].fa) clear_chr(hSession,daddr); - hSession->changed(hSession,0,maxlen); + hSession->cbk.changed(hSession,0,maxlen); lib3270_unselect(hSession); return text; diff --git a/src/lib3270/session.c b/src/lib3270/session.c index 1a9946b..664e0ec 100644 --- a/src/lib3270/session.c +++ b/src/lib3270/session.c @@ -192,28 +192,28 @@ static void lib3270_session_init(H3270 *hSession, const char *model, const char lib3270_set_host_charset(hSession,charset); // Default calls - hSession->write = lib3270_sock_send; - hSession->disconnect = lib3270_sock_disconnect; - hSession->update = update_char; - hSession->update_model = update_model; - hSession->update_cursor = update_cursor; - hSession->set_selection = nop_char; - hSession->ctlr_done = nop; - hSession->changed = changed; - hSession->erase = screen_disp; - hSession->suspend = nop; - hSession->resume = screen_disp; - hSession->update_oia = update_oia; - hSession->update_selection = update_selection; - hSession->cursor = set_cursor; - hSession->message = message; - hSession->update_ssl = update_ssl; - hSession->display = screen_disp; - hSession->set_width = nop_int; - hSession->update_status = (void (*)(H3270 *, LIB3270_STATUS)) nop_int; - hSession->autostart = nop; - hSession->set_timer = set_timer; - hSession->print = print; + hSession->cbk.write = lib3270_sock_send; + hSession->cbk.disconnect = lib3270_sock_disconnect; + hSession->cbk.update = update_char; + hSession->cbk.update_model = update_model; + hSession->cbk.update_cursor = update_cursor; + hSession->cbk.set_selection = nop_char; + hSession->cbk.ctlr_done = nop; + hSession->cbk.changed = changed; + hSession->cbk.erase = screen_disp; + hSession->cbk.suspend = nop; + hSession->cbk.resume = screen_disp; + hSession->cbk.update_oia = update_oia; + hSession->cbk.update_selection = update_selection; + hSession->cbk.cursor = set_cursor; + hSession->cbk.message = message; + hSession->cbk.update_ssl = update_ssl; + hSession->cbk.display = screen_disp; + hSession->cbk.set_width = nop_int; + hSession->cbk.update_status = (void (*)(H3270 *, LIB3270_STATUS)) nop_int; + hSession->cbk.autostart = nop; + hSession->cbk.set_timer = set_timer; + hSession->cbk.print = print; // Set the defaults. hSession->extended = 1; diff --git a/src/lib3270/ssl.c b/src/lib3270/ssl.c index 1a9c168..44e9539 100644 --- a/src/lib3270/ssl.c +++ b/src/lib3270/ssl.c @@ -450,5 +450,5 @@ void set_ssl_state(H3270 *session, LIB3270_SSL_STATE state) session->secure = state; trace_dsn(session,"SSL state changes to %d\n",(int) state); - session->update_ssl(session,session->secure); + session->cbk.update_ssl(session,session->secure); } diff --git a/src/lib3270/telnet.c b/src/lib3270/telnet.c index 7121fe9..1e1844f 100644 --- a/src/lib3270/telnet.c +++ b/src/lib3270/telnet.c @@ -931,7 +931,7 @@ void net_disconnect(H3270 *session) set_ssl_state(session,LIB3270_SSL_UNSECURE); #endif // HAVE_LIBSSL - session->disconnect(session); + session->cbk.disconnect(session); trace_dsn(session,"SENT disconnect\n"); @@ -1032,7 +1032,7 @@ void net_input(H3270 *hSession, int fd, LIB3270_IO_FLAG flag, void *dunno) { (void) ERR_error_string(e, err_buf); trace_dsn(hSession,"RCVD SSL_read error %ld (%s)\n", e,err_buf); - hSession->message(hSession,LIB3270_NOTIFY_ERROR,_( "SSL Error" ),_( "SSL Read error" ),err_buf ); + hSession->cbk.message(hSession,LIB3270_NOTIFY_ERROR,_( "SSL Error" ),_( "SSL Read error" ),err_buf ); } else { @@ -2054,7 +2054,7 @@ static void net_rawout(H3270 *hSession, unsigned const char *buf, size_t len) while (len) { - int nw = hSession->write(hSession,buf,len); + int nw = hSession->cbk.write(hSession,buf,len); if (nw > 0) { diff --git a/src/lib3270/toggles.c b/src/lib3270/toggles.c index 1f94296..b9b5758 100644 --- a/src/lib3270/toggles.c +++ b/src/lib3270/toggles.c @@ -240,8 +240,8 @@ static void toggle_notify(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGG trace("%s: ix=%d upcall=%p",__FUNCTION__,ix,t->upcall); t->upcall(session, t, TT_INTERACTIVE); - if(session->update_toggle) - session->update_toggle(session,ix,t->value,TT_INTERACTIVE,toggle_info[ix].name); + if(session->cbk.update_toggle) + session->cbk.update_toggle(session,ix,t->value,TT_INTERACTIVE,toggle_info[ix].name); } @@ -291,7 +291,7 @@ static void toggle_altscreen(H3270 *session, struct lib3270_toggle *t, LIB3270_T static void toggle_redraw(H3270 *session, struct lib3270_toggle *t, LIB3270_TOGGLE_TYPE tt) { - session->display(session); + session->cbk.display(session); } /* diff --git a/src/lib3270/util.c b/src/lib3270/util.c index 6ea3399..1703899 100644 --- a/src/lib3270/util.c +++ b/src/lib3270/util.c @@ -1009,7 +1009,7 @@ int gettimeofday(struct timeval *tv, void *ignored) { CHECK_SESSION_HANDLE(h); trace("%s(%p)",__FUNCTION__,h); - return h->print(h); + return h->cbk.print(h); } diff --git a/src/plugins/hllapi/calls.cc b/src/plugins/hllapi/calls.cc index 92b66e1..5bfa6e9 100644 --- a/src/plugins/hllapi/calls.cc +++ b/src/plugins/hllapi/calls.cc @@ -228,6 +228,13 @@ return rc; } + HLLAPI_API_CALL hllapi_set_unlock_delay(WORD ms) + { + session::get_default()->set_unlock_delay(ms); + return 0; + } + + HLLAPI_API_CALL hllapi_pfkey(WORD key) { return session::get_default()->pfkey(key); diff --git a/src/plugins/hllapi/hllapi.c b/src/plugins/hllapi/hllapi.c index 2aa6315..eb5286e 100644 --- a/src/plugins/hllapi/hllapi.c +++ b/src/plugins/hllapi/hllapi.c @@ -507,6 +507,7 @@ static int reset_system(char *buffer, unsigned short *length, unsigned short *rc return hllapi_reset(); } + static int pause_system(char *buffer, unsigned short *length, unsigned short *rc) { if(!*length) @@ -529,7 +530,10 @@ static int pause_system(char *buffer, unsigned short *length, unsigned short *rc return hllapi_wait( (*length) / 2); } - // Pause "flexivel", aguarda tela limpa + // Pause "flexivel", aguarda mudança no conteúdo da tela!!! + + #warning Mudar comportamento na lib! + return hllapi_wait_for_ready((*length) / 2); } @@ -550,6 +554,11 @@ static int set_session_parameters(char *buffer, unsigned short *length, unsigned // FPAUSE pause_mode = PAUSE_MODE_FPAUSE; } + else if(!strncasecmp(buffer,"UNLOCKDELAY",*length)) + { + // UNLOCKDELAY + hllapi_set_unlock_delay((WORD) *rc); + } else { return HLLAPI_STATUS_BAD_PARAMETER; diff --git a/src/plugins/hllapi/pluginmain.c b/src/plugins/hllapi/pluginmain.c index db64660..9803f6e 100644 --- a/src/plugins/hllapi/pluginmain.c +++ b/src/plugins/hllapi/pluginmain.c @@ -328,6 +328,11 @@ send_result(source,lib3270_get_secure(lib3270_get_default_session_handle())); break; + case HLLAPI_PACKET_SET_UNLOCK_DELAY: + lib3270_set_unlock_delay(lib3270_get_default_session_handle(),(unsigned short) ((struct hllapi_packet_set_int *) source->buffer)->value); + send_result(source,0); + break; + case HLLAPI_PACKET_SET_TOGGLE: send_result(source,lib3270_set_toggle(lib3270_get_default_session_handle(), (LIB3270_TOGGLE) ((struct hllapi_packet_set *) source->buffer)->id, diff --git a/src/pw3270/v3270/widget.c b/src/pw3270/v3270/widget.c index c288e23..4ea38ba 100644 --- a/src/pw3270/v3270/widget.c +++ b/src/pw3270/v3270/widget.c @@ -930,27 +930,27 @@ static void v3270_init(v3270 *widget) widget->host->user_data = widget; - widget->host->update = v3270_update_char; - widget->host->changed = changed; - widget->host->set_timer = set_timer; - - widget->host->set_selection = set_selection; - widget->host->update_selection = update_selection; - - widget->host->update_luname = update_luname; - widget->host->configure = update_screen_size; - widget->host->update_status = update_message; - widget->host->update_cursor = v3270_update_cursor; - widget->host->update_toggle = update_toggle; - widget->host->update_oia = v3270_update_oia; - widget->host->cursor = select_cursor; - widget->host->update_connect = update_connect; - widget->host->update_model = update_model; - widget->host->changed = changed; - widget->host->ctlr_done = ctlr_done; - widget->host->message = message; - widget->host->update_ssl = v3270_update_ssl; - widget->host->print = emit_print_signal; + widget->host->cbk.update = v3270_update_char; + widget->host->cbk.changed = changed; + widget->host->cbk.set_timer = set_timer; + + widget->host->cbk.set_selection = set_selection; + widget->host->cbk.update_selection = update_selection; + + widget->host->cbk.update_luname = update_luname; + widget->host->cbk.configure = update_screen_size; + widget->host->cbk.update_status = update_message; + widget->host->cbk.update_cursor = v3270_update_cursor; + widget->host->cbk.update_toggle = update_toggle; + widget->host->cbk.update_oia = v3270_update_oia; + widget->host->cbk.cursor = select_cursor; + widget->host->cbk.update_connect = update_connect; + widget->host->cbk.update_model = update_model; + widget->host->cbk.changed = changed; + widget->host->cbk.ctlr_done = ctlr_done; + widget->host->cbk.message = message; + widget->host->cbk.update_ssl = v3270_update_ssl; + widget->host->cbk.print = emit_print_signal; // Reset timer -- libgit2 0.21.2