diff --git a/src/include/ftc.h b/src/include/ftc.h index 584de4c..30bb167 100644 --- a/src/include/ftc.h +++ b/src/include/ftc.h @@ -32,7 +32,7 @@ LIB3270_INTERNAL void ft_init(H3270 *hSession); - LIB3270_INTERNAL void ft_aborting(H3270FT *h); + LIB3270_INTERNAL void ft_aborting(H3270FT *h, const char *reason); LIB3270_INTERNAL void ft_complete(H3270FT *h, const char *errmsg); LIB3270_INTERNAL void ft_failed(H3270FT *h, const char *errmsg); LIB3270_INTERNAL void ft_message(H3270FT *h, const char *msg); diff --git a/src/include/lib3270/filetransfer.h b/src/include/lib3270/filetransfer.h index 2f9ff8a..70e02b5 100644 --- a/src/include/lib3270/filetransfer.h +++ b/src/include/lib3270/filetransfer.h @@ -94,7 +94,7 @@ void (*message)(H3270 *hSession, const char *msg, void *userdata); void (*update)(H3270 *hSession, unsigned long current, unsigned long length, double kbytes_sec, void *userdata); void (*running)(H3270 *hSession, int is_cut, void *userdata); - void (*aborting)(H3270 *hSession, void *userdata); + void (*aborting)(H3270 *hSession, const char *reason, void *userdata); void (*state_changed)(H3270 *hSession, LIB3270_FT_STATE state, const char *text, void *userdata); }; @@ -185,9 +185,9 @@ LIB3270_EXPORT H3270FT * lib3270_ft_new(H3270 *hSession, LIB3270_FT_OPTION flags, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft, const char **msg); LIB3270_EXPORT int lib3270_ft_start(H3270 *hSession); - LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession); + LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession, const char *reason); - LIB3270_EXPORT int lib3270_ft_cancel(H3270 *hSession, int force); + LIB3270_EXPORT int lib3270_ft_cancel(H3270 *hSession, int force, const char *reason); LIB3270_EXPORT void lib3270_ft_set_user_data(H3270 *h, void *ptr); LIB3270_EXPORT void * lib3270_ft_get_user_data(H3270 *h); diff --git a/src/lib3270/ft.c b/src/lib3270/ft.c index f673152..cf9543c 100644 --- a/src/lib3270/ft.c +++ b/src/lib3270/ft.c @@ -135,7 +135,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); lib3270_register_schange(hSession, LIB3270_STATE_3270_MODE, ( void (*)(H3270 *, int, void *)) ft_in3270, NULL); } - LIB3270_EXPORT int lib3270_ft_cancel(H3270 *hSession, int force) + LIB3270_EXPORT int lib3270_ft_cancel(H3270 *hSession, int force, const char *reason) { H3270FT *ft; @@ -143,12 +143,12 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); ft = get_ft_handle(hSession); if(!ft) - return EINVAL; + return errno = EINVAL; if (ft->state == LIB3270_FT_STATE_RUNNING) { set_ft_state(ft,LIB3270_FT_STATE_ABORT_WAIT); - ft->cbk.aborting(hSession,ft->user_data); + ft->cbk.aborting(hSession,reason,ft->user_data); return 0; } @@ -156,7 +156,10 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); return errno = EBUSY; // Impatient user or hung host -- just clean up. - ft_failed(ft, N_("Cancelled by user") ); + if(!reason) + reason = _("Cancelled by user"); + + ft_failed(ft, reason); return 0; } @@ -186,7 +189,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); } - static void def_aborting(H3270 *hSession unused, void *userdata unused) + static void def_aborting(H3270 *hSession unused, const char *reason unused, void *userdata unused) { } @@ -569,7 +572,7 @@ void ft_failed(H3270FT *ft, const char *errmsg) ft->cbk.failed(ft->host,ft->ft_length,finish(ft),errmsg ? errmsg : N_("Transfer failed"),ft->user_data); } -LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession) +LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession, const char *reason) { H3270FT *session; @@ -581,7 +584,7 @@ LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession) if (session->state != LIB3270_FT_STATE_NONE) { - lib3270_ft_cancel(hSession,1); + lib3270_ft_cancel(hSession,1,reason); } if(session->local_file) @@ -653,13 +656,13 @@ LIB3270_EXPORT struct lib3270_ft_callbacks * lib3270_get_ft_callbacks(H3270 *ses // Process a protocol-generated abort. -void ft_aborting(H3270FT *h) +void ft_aborting(H3270FT *h, const char *reason) { if (h->state == FT_RUNNING || h->state == FT_ABORT_WAIT) { set_ft_state(h,FT_ABORT_SENT); h->cbk.message(h->host,N_("Aborting..."),h->user_data); - h->cbk.aborting(h->host,h->user_data); + h->cbk.aborting(h->host,reason,h->user_data); } } diff --git a/src/lib3270/ft_cut.c b/src/lib3270/ft_cut.c index 9faa809..a2d967c 100644 --- a/src/lib3270/ft_cut.c +++ b/src/lib3270/ft_cut.c @@ -569,7 +569,7 @@ static void cut_abort(H3270 *hSession, unsigned short reason, const char *fmt, . lib3270_pfkey(hSession,2); /* Update the in-progress pop-up. */ - ft_aborting(ft); + ft_aborting(ft,ft->saved_errmsg); } /** diff --git a/src/lib3270/ft_dft.c b/src/lib3270/ft_dft.c index 1a4a2f1..8f23919 100644 --- a/src/lib3270/ft_dft.c +++ b/src/lib3270/ft_dft.c @@ -558,7 +558,7 @@ static void dft_abort(H3270 *hSession, unsigned short code, const char *fmt, ... net_output(hSession); /* Update the pop-up and state. */ - ft_aborting(ft); + ft_aborting(ft,ft->abort_string); } /* Returns the number of bytes in s, limited by len, that aren't CRs or ^Zs. */ -- libgit2 0.21.2