Commit 833c6421672272ee9e6cc378c8af8655eec949aa
1 parent
ea7d3f30
Exists in
master
and in
3 other branches
Adding reason message in FT callbacks.
Showing
5 changed files
with
18 additions
and
15 deletions
Show diff stats
src/include/ftc.h
@@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
32 | 32 | ||
33 | LIB3270_INTERNAL void ft_init(H3270 *hSession); | 33 | LIB3270_INTERNAL void ft_init(H3270 *hSession); |
34 | 34 | ||
35 | - LIB3270_INTERNAL void ft_aborting(H3270FT *h); | 35 | + LIB3270_INTERNAL void ft_aborting(H3270FT *h, const char *reason); |
36 | LIB3270_INTERNAL void ft_complete(H3270FT *h, const char *errmsg); | 36 | LIB3270_INTERNAL void ft_complete(H3270FT *h, const char *errmsg); |
37 | LIB3270_INTERNAL void ft_failed(H3270FT *h, const char *errmsg); | 37 | LIB3270_INTERNAL void ft_failed(H3270FT *h, const char *errmsg); |
38 | LIB3270_INTERNAL void ft_message(H3270FT *h, const char *msg); | 38 | LIB3270_INTERNAL void ft_message(H3270FT *h, const char *msg); |
src/include/lib3270/filetransfer.h
@@ -94,7 +94,7 @@ | @@ -94,7 +94,7 @@ | ||
94 | void (*message)(H3270 *hSession, const char *msg, void *userdata); | 94 | void (*message)(H3270 *hSession, const char *msg, void *userdata); |
95 | void (*update)(H3270 *hSession, unsigned long current, unsigned long length, double kbytes_sec, void *userdata); | 95 | void (*update)(H3270 *hSession, unsigned long current, unsigned long length, double kbytes_sec, void *userdata); |
96 | void (*running)(H3270 *hSession, int is_cut, void *userdata); | 96 | void (*running)(H3270 *hSession, int is_cut, void *userdata); |
97 | - void (*aborting)(H3270 *hSession, void *userdata); | 97 | + void (*aborting)(H3270 *hSession, const char *reason, void *userdata); |
98 | void (*state_changed)(H3270 *hSession, LIB3270_FT_STATE state, const char *text, void *userdata); | 98 | void (*state_changed)(H3270 *hSession, LIB3270_FT_STATE state, const char *text, void *userdata); |
99 | }; | 99 | }; |
100 | 100 | ||
@@ -185,9 +185,9 @@ | @@ -185,9 +185,9 @@ | ||
185 | 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); | 185 | 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); |
186 | 186 | ||
187 | LIB3270_EXPORT int lib3270_ft_start(H3270 *hSession); | 187 | LIB3270_EXPORT int lib3270_ft_start(H3270 *hSession); |
188 | - LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession); | 188 | + LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession, const char *reason); |
189 | 189 | ||
190 | - LIB3270_EXPORT int lib3270_ft_cancel(H3270 *hSession, int force); | 190 | + LIB3270_EXPORT int lib3270_ft_cancel(H3270 *hSession, int force, const char *reason); |
191 | 191 | ||
192 | LIB3270_EXPORT void lib3270_ft_set_user_data(H3270 *h, void *ptr); | 192 | LIB3270_EXPORT void lib3270_ft_set_user_data(H3270 *h, void *ptr); |
193 | LIB3270_EXPORT void * lib3270_ft_get_user_data(H3270 *h); | 193 | LIB3270_EXPORT void * lib3270_ft_get_user_data(H3270 *h); |
src/lib3270/ft.c
@@ -135,7 +135,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -135,7 +135,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
135 | lib3270_register_schange(hSession, LIB3270_STATE_3270_MODE, ( void (*)(H3270 *, int, void *)) ft_in3270, NULL); | 135 | lib3270_register_schange(hSession, LIB3270_STATE_3270_MODE, ( void (*)(H3270 *, int, void *)) ft_in3270, NULL); |
136 | } | 136 | } |
137 | 137 | ||
138 | - LIB3270_EXPORT int lib3270_ft_cancel(H3270 *hSession, int force) | 138 | + LIB3270_EXPORT int lib3270_ft_cancel(H3270 *hSession, int force, const char *reason) |
139 | { | 139 | { |
140 | H3270FT *ft; | 140 | H3270FT *ft; |
141 | 141 | ||
@@ -143,12 +143,12 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -143,12 +143,12 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
143 | 143 | ||
144 | ft = get_ft_handle(hSession); | 144 | ft = get_ft_handle(hSession); |
145 | if(!ft) | 145 | if(!ft) |
146 | - return EINVAL; | 146 | + return errno = EINVAL; |
147 | 147 | ||
148 | if (ft->state == LIB3270_FT_STATE_RUNNING) | 148 | if (ft->state == LIB3270_FT_STATE_RUNNING) |
149 | { | 149 | { |
150 | set_ft_state(ft,LIB3270_FT_STATE_ABORT_WAIT); | 150 | set_ft_state(ft,LIB3270_FT_STATE_ABORT_WAIT); |
151 | - ft->cbk.aborting(hSession,ft->user_data); | 151 | + ft->cbk.aborting(hSession,reason,ft->user_data); |
152 | return 0; | 152 | return 0; |
153 | } | 153 | } |
154 | 154 | ||
@@ -156,7 +156,10 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -156,7 +156,10 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
156 | return errno = EBUSY; | 156 | return errno = EBUSY; |
157 | 157 | ||
158 | // Impatient user or hung host -- just clean up. | 158 | // Impatient user or hung host -- just clean up. |
159 | - ft_failed(ft, N_("Cancelled by user") ); | 159 | + if(!reason) |
160 | + reason = _("Cancelled by user"); | ||
161 | + | ||
162 | + ft_failed(ft, reason); | ||
160 | 163 | ||
161 | return 0; | 164 | return 0; |
162 | } | 165 | } |
@@ -186,7 +189,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | @@ -186,7 +189,7 @@ static void set_ft_state(H3270FT *session, LIB3270_FT_STATE state); | ||
186 | 189 | ||
187 | } | 190 | } |
188 | 191 | ||
189 | - static void def_aborting(H3270 *hSession unused, void *userdata unused) | 192 | + static void def_aborting(H3270 *hSession unused, const char *reason unused, void *userdata unused) |
190 | { | 193 | { |
191 | 194 | ||
192 | } | 195 | } |
@@ -569,7 +572,7 @@ void ft_failed(H3270FT *ft, const char *errmsg) | @@ -569,7 +572,7 @@ void ft_failed(H3270FT *ft, const char *errmsg) | ||
569 | ft->cbk.failed(ft->host,ft->ft_length,finish(ft),errmsg ? errmsg : N_("Transfer failed"),ft->user_data); | 572 | ft->cbk.failed(ft->host,ft->ft_length,finish(ft),errmsg ? errmsg : N_("Transfer failed"),ft->user_data); |
570 | } | 573 | } |
571 | 574 | ||
572 | -LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession) | 575 | +LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession, const char *reason) |
573 | { | 576 | { |
574 | H3270FT *session; | 577 | H3270FT *session; |
575 | 578 | ||
@@ -581,7 +584,7 @@ LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession) | @@ -581,7 +584,7 @@ LIB3270_EXPORT int lib3270_ft_destroy(H3270 *hSession) | ||
581 | 584 | ||
582 | if (session->state != LIB3270_FT_STATE_NONE) | 585 | if (session->state != LIB3270_FT_STATE_NONE) |
583 | { | 586 | { |
584 | - lib3270_ft_cancel(hSession,1); | 587 | + lib3270_ft_cancel(hSession,1,reason); |
585 | } | 588 | } |
586 | 589 | ||
587 | if(session->local_file) | 590 | if(session->local_file) |
@@ -653,13 +656,13 @@ LIB3270_EXPORT struct lib3270_ft_callbacks * lib3270_get_ft_callbacks(H3270 *ses | @@ -653,13 +656,13 @@ LIB3270_EXPORT struct lib3270_ft_callbacks * lib3270_get_ft_callbacks(H3270 *ses | ||
653 | 656 | ||
654 | 657 | ||
655 | // Process a protocol-generated abort. | 658 | // Process a protocol-generated abort. |
656 | -void ft_aborting(H3270FT *h) | 659 | +void ft_aborting(H3270FT *h, const char *reason) |
657 | { | 660 | { |
658 | if (h->state == FT_RUNNING || h->state == FT_ABORT_WAIT) | 661 | if (h->state == FT_RUNNING || h->state == FT_ABORT_WAIT) |
659 | { | 662 | { |
660 | set_ft_state(h,FT_ABORT_SENT); | 663 | set_ft_state(h,FT_ABORT_SENT); |
661 | h->cbk.message(h->host,N_("Aborting..."),h->user_data); | 664 | h->cbk.message(h->host,N_("Aborting..."),h->user_data); |
662 | - h->cbk.aborting(h->host,h->user_data); | 665 | + h->cbk.aborting(h->host,reason,h->user_data); |
663 | } | 666 | } |
664 | } | 667 | } |
665 | 668 |
src/lib3270/ft_cut.c
@@ -569,7 +569,7 @@ static void cut_abort(H3270 *hSession, unsigned short reason, const char *fmt, . | @@ -569,7 +569,7 @@ static void cut_abort(H3270 *hSession, unsigned short reason, const char *fmt, . | ||
569 | lib3270_pfkey(hSession,2); | 569 | lib3270_pfkey(hSession,2); |
570 | 570 | ||
571 | /* Update the in-progress pop-up. */ | 571 | /* Update the in-progress pop-up. */ |
572 | - ft_aborting(ft); | 572 | + ft_aborting(ft,ft->saved_errmsg); |
573 | } | 573 | } |
574 | 574 | ||
575 | /** | 575 | /** |
src/lib3270/ft_dft.c
@@ -558,7 +558,7 @@ static void dft_abort(H3270 *hSession, unsigned short code, const char *fmt, ... | @@ -558,7 +558,7 @@ static void dft_abort(H3270 *hSession, unsigned short code, const char *fmt, ... | ||
558 | net_output(hSession); | 558 | net_output(hSession); |
559 | 559 | ||
560 | /* Update the pop-up and state. */ | 560 | /* Update the pop-up and state. */ |
561 | - ft_aborting(ft); | 561 | + ft_aborting(ft,ft->abort_string); |
562 | } | 562 | } |
563 | 563 | ||
564 | /* Returns the number of bytes in s, limited by len, that aren't CRs or ^Zs. */ | 564 | /* Returns the number of bytes in s, limited by len, that aren't CRs or ^Zs. */ |