Commit a092bc914fb0271de71fe4073e62b32fb043d790
1 parent
d22279b2
Exists in
master
and in
3 other branches
Removendo includes obsoletas, sessão passa a ser criada automaticamente caso alg…
…uma função da lib seja chamada com NULL no handle
Showing
28 changed files
with
139 additions
and
133 deletions
Show diff stats
actionsc.h
... | ... | @@ -17,27 +17,21 @@ |
17 | 17 | * Global declarations for actions.c. |
18 | 18 | */ |
19 | 19 | |
20 | +#error Deprecated | |
21 | + | |
20 | 22 | // extern enum iaction ia_cause; |
21 | 23 | |
22 | -extern int actioncount; | |
24 | +// extern int actioncount; | |
23 | 25 | // extern XtActionsRec *actions; |
24 | 26 | |
25 | 27 | // extern const char *ia_name[]; |
26 | 28 | |
27 | -// #if defined(X3270_TRACE) /*[*/ | |
28 | -// extern void action_debug(XtActionProc action, XEvent *event, String *params, Cardinal *num_params); | |
29 | -// #else /*][*/ | |
30 | -// #define action_debug(a, e, p, n) | |
31 | -// #endif /*]*/ | |
32 | - | |
33 | -extern void action_init(void); | |
29 | +// extern void action_init(void); | |
34 | 30 | |
35 | 31 | // extern void action_internal(XtActionProc action, enum iaction cause, const char *parm1, const char *parm2); |
36 | 32 | |
37 | -#define action_name(x) #x | |
38 | -// extern const char *action_name(XtActionProc action); | |
39 | -// extern int check_usage(XtActionProc action, Cardinal nargs, Cardinal nargs_min, Cardinal nargs_max); | |
33 | +// #define action_name(x) #x | |
40 | 34 | |
41 | -extern Boolean event_is_meta(int state); | |
35 | +// extern Boolean event_is_meta(int state); | |
42 | 36 | |
43 | 37 | ... | ... |
ansi.c
... | ... | @@ -153,7 +153,7 @@ |
153 | 153 | // #define OIA_FLAG_SECURE LIB3270_FLAG_SECURE |
154 | 154 | #define OIA_FLAG_TYPEAHEAD LIB3270_FLAG_TYPEAHEAD |
155 | 155 | // #define OIA_FLAG_PRINTER LIB3270_FLAG_PRINTER |
156 | - #define OIA_FLAG_REVERSE LIB3270_FLAG_REVERSE | |
156 | +// #define OIA_FLAG_REVERSE LIB3270_FLAG_REVERSE | |
157 | 157 | #define OIA_FLAG_USER LIB3270_FLAG_COUNT |
158 | 158 | #define OIA_FLAG LIB3270_FLAG |
159 | 159 | ... | ... |
charsetc.h
childc.h
ctlr.c
ctlrc.h
... | ... | @@ -72,14 +72,14 @@ LIB3270_INTERNAL void ctlr_erase(H3270 *session, int alt); |
72 | 72 | LIB3270_INTERNAL void ticking_start(H3270 *session, Boolean anyway); |
73 | 73 | |
74 | 74 | enum dbcs_state { |
75 | - DBCS_NONE = 0, /* position is not DBCS */ | |
76 | - DBCS_LEFT, /* position is left half of DBCS character */ | |
77 | - DBCS_RIGHT, /* position is right half of DBCS character */ | |
78 | - DBCS_SI, /* position is SI terminating DBCS subfield */ | |
79 | - DBCS_SB, /* position is SBCS character after the SI */ | |
80 | - DBCS_LEFT_WRAP, /* position is left half of split DBCS */ | |
81 | - DBCS_RIGHT_WRAP, /* position is right half of split DBCS */ | |
82 | - DBCS_DEAD /* position is dead left-half DBCS */ | |
75 | + DBCS_NONE = 0, /**< position is not DBCS */ | |
76 | + DBCS_LEFT, /**< position is left half of DBCS character */ | |
77 | + DBCS_RIGHT, /**< position is right half of DBCS character */ | |
78 | + DBCS_SI, /**< position is SI terminating DBCS subfield */ | |
79 | + DBCS_SB, /**< position is SBCS character after the SI */ | |
80 | + DBCS_LEFT_WRAP, /**< position is left half of split DBCS */ | |
81 | + DBCS_RIGHT_WRAP, /**< position is right half of split DBCS */ | |
82 | + DBCS_DEAD /**< position is dead left-half DBCS */ | |
83 | 83 | }; |
84 | 84 | #define IS_LEFT(d) ((d) == DBCS_LEFT || (d) == DBCS_LEFT_WRAP) |
85 | 85 | #define IS_RIGHT(d) ((d) == DBCS_RIGHT || (d) == DBCS_RIGHT_WRAP) | ... | ... |
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 | #endif // HAVE_MALLOC_H |
42 | 42 | |
43 | 43 | //#include "appres.h" |
44 | -#include "actionsc.h" | |
44 | +//#include "actionsc.h" | |
45 | 45 | #include "ft_cutc.h" |
46 | 46 | #include "ft_dftc.h" |
47 | 47 | #include "ftc.h" |
... | ... | @@ -52,7 +52,7 @@ |
52 | 52 | #endif |
53 | 53 | */ |
54 | 54 | #include "kybdc.h" |
55 | -#include "objects.h" | |
55 | +// #include "objects.h" | |
56 | 56 | #include "popupsc.h" |
57 | 57 | #include "screenc.h" |
58 | 58 | #include "tablesc.h" | ... | ... |
ft_cut.c
ft_dft.c
globals.h
glue.c
... | ... | @@ -53,11 +53,11 @@ |
53 | 53 | #include "3270ds.h" |
54 | 54 | #include "resources.h" |
55 | 55 | |
56 | -#include "actionsc.h" | |
56 | +//#include "actionsc.h" | |
57 | 57 | #include "ansic.h" |
58 | 58 | #include "charsetc.h" |
59 | 59 | #include "ctlrc.h" |
60 | -#include "gluec.h" | |
60 | +// #include "gluec.h" | |
61 | 61 | #include "hostc.h" |
62 | 62 | // #include "keymapc.h" |
63 | 63 | #include "kybdc.h" |
... | ... | @@ -71,7 +71,7 @@ |
71 | 71 | #include "trace_dsc.h" |
72 | 72 | #include "utilc.h" |
73 | 73 | // #include "idlec.h" |
74 | -#include "printerc.h" | |
74 | +// #include "printerc.h" | |
75 | 75 | |
76 | 76 | #if defined(X3270_FT) |
77 | 77 | #include "ftc.h" | ... | ... |
gluec.h
... | ... | @@ -21,11 +21,13 @@ |
21 | 21 | // extern int parse_command_line(int argc, const char **argv, const char **cl_hostname); |
22 | 22 | // extern int parse_program_parameters(int argc, const char **argv); |
23 | 23 | // LIB3270_INTERNAL void parse_xrm(const char *arg, const char *where); |
24 | -LIB3270_INTERNAL void notify_ssl_error(H3270 *session, const char *title, const char *msg, const char *state, const char *alert); | |
24 | +// LIB3270_INTERNAL void notify_ssl_error(H3270 *session, const char *title, const char *msg, const char *state, const char *alert); | |
25 | 25 | |
26 | 26 | /* XtGlue.c */ |
27 | -LIB3270_INTERNAL void (*Warning_redirect)(const char *); | |
27 | +// LIB3270_INTERNAL void (*Warning_redirect)(const char *); | |
28 | 28 | |
29 | -#if !defined(_WIN32) /*[*/ | |
30 | -LIB3270_INTERNAL int select_setup(int *nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, struct timeval **timeout, struct timeval *timebuf); | |
31 | -#endif /*]*/ | |
29 | +// #if !defined(_WIN32) | |
30 | +// LIB3270_INTERNAL int select_setup(int *nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, struct timeval **timeout, struct timeval *timebuf); | |
31 | +// #endif | |
32 | + | |
33 | +#error Deprecated | ... | ... |
host.c
icmdc.h
keypadc.h
kybd.c
... | ... | @@ -59,7 +59,7 @@ struct ta; |
59 | 59 | // #include "ctlr.h" |
60 | 60 | #include "resources.h" |
61 | 61 | |
62 | -#include "actionsc.h" | |
62 | +//#include "actionsc.h" | |
63 | 63 | #include "ansic.h" |
64 | 64 | //#include "aplc.h" |
65 | 65 | #include "ctlrc.h" |
... | ... | @@ -68,7 +68,7 @@ struct ta; |
68 | 68 | // #include "keypadc.h" |
69 | 69 | #include "kybdc.h" |
70 | 70 | #include "popupsc.h" |
71 | -#include "printc.h" | |
71 | +// #include "printc.h" | |
72 | 72 | #include "screenc.h" |
73 | 73 | // #if defined(X3270_DISPLAY) /*[*/ |
74 | 74 | // #include "selectc.h" | ... | ... |
localdefs.h
... | ... | @@ -33,12 +33,12 @@ |
33 | 33 | /* These first definitions were cribbed from X11 -- but no X code is used. */ |
34 | 34 | #define False 0 |
35 | 35 | #define True 1 |
36 | -typedef void *XtPointer; | |
37 | -typedef void *Widget; | |
38 | -typedef void *XEvent; | |
36 | +//typedef void *XtPointer; | |
37 | +// typedef void *Widget; | |
38 | +// typedef void *XEvent; | |
39 | 39 | typedef char Boolean; |
40 | 40 | typedef char *String; |
41 | -typedef unsigned int Cardinal; | |
41 | +// typedef unsigned int Cardinal; | |
42 | 42 | typedef unsigned long KeySym; |
43 | 43 | #define Bool int |
44 | 44 | ... | ... |
objects.h
... | ... | @@ -20,7 +20,9 @@ |
20 | 20 | // #define ObjConfirmButton "confirmButton" |
21 | 21 | // #define ObjConfirm2Button "confirm2Button" |
22 | 22 | // #define ObjCancelButton "cancelButton" |
23 | -#define ObjDialog "dialog" | |
23 | +// #define ObjDialog "dialog" | |
24 | 24 | // #define ObjSmallLabel "smallLabel" |
25 | -#define ObjNameLabel "nameLabel" | |
26 | -#define ObjDataLabel "dataLabel" | |
25 | +// #define ObjNameLabel "nameLabel" | |
26 | +// #define ObjDataLabel "dataLabel" | |
27 | + | |
28 | +#error Deprecated | ... | ... |
paste.c
... | ... | @@ -49,7 +49,7 @@ |
49 | 49 | #include "3270ds.h" |
50 | 50 | #include "resources.h" |
51 | 51 | |
52 | -#include "actionsc.h" | |
52 | +//#include "actionsc.h" | |
53 | 53 | #include "ansic.h" |
54 | 54 | //#include "aplc.h" |
55 | 55 | #include "ctlrc.h" |
... | ... | @@ -58,7 +58,7 @@ |
58 | 58 | // #include "keypadc.h" |
59 | 59 | #include "kybdc.h" |
60 | 60 | #include "popupsc.h" |
61 | -#include "printc.h" | |
61 | +// #include "printc.h" | |
62 | 62 | #include "screenc.h" |
63 | 63 | |
64 | 64 | /* | ... | ... |
printc.h
... | ... | @@ -18,13 +18,10 @@ |
18 | 18 | */ |
19 | 19 | |
20 | 20 | // LIB3270_INTERNAL Boolean fprint_screen(FILE *f, Boolean even_if_empty, Boolean use_html); |
21 | -LIB3270_INTERNAL void PrintText_action(Widget w, XEvent *event, String *params, | |
22 | - Cardinal *num_params); | |
23 | -LIB3270_INTERNAL void PrintWindow_action(Widget w, XEvent *event, String *params, | |
24 | - Cardinal *num_params); | |
25 | -LIB3270_INTERNAL void print_text_option(Widget w, XtPointer client_data, | |
26 | - XtPointer call_data); | |
27 | -LIB3270_INTERNAL void print_window_option(Widget w, XtPointer client_data, | |
28 | - XtPointer call_data); | |
29 | -LIB3270_INTERNAL void save_text_option(Widget w, XtPointer client_data, | |
30 | - XtPointer call_data); | |
21 | +// LIB3270_INTERNAL void PrintText_action(Widget w, XEvent *event, String *params,Cardinal *num_params); | |
22 | +// LIB3270_INTERNAL void PrintWindow_action(Widget w, XEvent *event, String *params,Cardinal *num_params); | |
23 | +// LIB3270_INTERNAL void print_text_option(Widget w, XtPointer client_data,XtPointer call_data); | |
24 | +// LIB3270_INTERNAL void print_window_option(Widget w, XtPointer client_data,XtPointer call_data); | |
25 | +// LIB3270_INTERNAL void save_text_option(Widget w, XtPointer client_data,XtPointer call_data); | |
26 | + | |
27 | +#error Deprecated | ... | ... |
printerc.h
savec.h
screen.c
scrollc.h
session.c
... | ... | @@ -48,7 +48,7 @@ |
48 | 48 | |
49 | 49 | /*---[ Globals ]--------------------------------------------------------------------------------------------------------------*/ |
50 | 50 | |
51 | - static H3270 h3270; | |
51 | + static H3270 *default_session = NULL; | |
52 | 52 | |
53 | 53 | /*---[ Statics ]--------------------------------------------------------------------------------------------------------------*/ |
54 | 54 | |
... | ... | @@ -60,6 +60,9 @@ void lib3270_session_free(H3270 *h) |
60 | 60 | { |
61 | 61 | int f; |
62 | 62 | |
63 | + if(!h) | |
64 | + return; | |
65 | + | |
63 | 66 | // Terminate session |
64 | 67 | if(lib3270_connected(h)) |
65 | 68 | lib3270_disconnect(h); |
... | ... | @@ -91,6 +94,11 @@ void lib3270_session_free(H3270 *h) |
91 | 94 | release_pointer(h->buffer[f]); |
92 | 95 | } |
93 | 96 | |
97 | + if(h == default_session) | |
98 | + default_session = NULL; | |
99 | + | |
100 | + lib3270_free(h); | |
101 | + | |
94 | 102 | } |
95 | 103 | |
96 | 104 | static void update_char(H3270 *session, int addr, unsigned char chr, unsigned short attr, unsigned char cursor) |
... | ... | @@ -169,45 +177,45 @@ static void lib3270_session_init(H3270 *hSession, const char *model) |
169 | 177 | initialize_tables(hSession); |
170 | 178 | |
171 | 179 | // Default calls |
172 | - hSession->write = lib3270_sock_send; | |
173 | - hSession->disconnect = lib3270_sock_disconnect; | |
174 | - hSession->update = update_char; | |
175 | - hSession->update_model = update_model; | |
176 | - hSession->update_cursor = update_cursor; | |
177 | - hSession->set_selection = nop_char; | |
178 | - hSession->ctlr_done = nop; | |
179 | - hSession->changed = changed; | |
180 | - hSession->erase = screen_disp; | |
181 | - hSession->suspend = nop; | |
182 | - hSession->resume = screen_disp; | |
183 | - hSession->update_oia = update_oia; | |
184 | - hSession->update_selection = update_selection; | |
185 | - hSession->cursor = set_cursor; | |
186 | - hSession->message = message; | |
187 | - hSession->update_ssl = update_ssl; | |
188 | - hSession->display = screen_disp; | |
189 | - hSession->set_width = set_width; | |
180 | + hSession->write = lib3270_sock_send; | |
181 | + hSession->disconnect = lib3270_sock_disconnect; | |
182 | + hSession->update = update_char; | |
183 | + hSession->update_model = update_model; | |
184 | + hSession->update_cursor = update_cursor; | |
185 | + hSession->set_selection = nop_char; | |
186 | + hSession->ctlr_done = nop; | |
187 | + hSession->changed = changed; | |
188 | + hSession->erase = screen_disp; | |
189 | + hSession->suspend = nop; | |
190 | + hSession->resume = screen_disp; | |
191 | + hSession->update_oia = update_oia; | |
192 | + hSession->update_selection = update_selection; | |
193 | + hSession->cursor = set_cursor; | |
194 | + hSession->message = message; | |
195 | + hSession->update_ssl = update_ssl; | |
196 | + hSession->display = screen_disp; | |
197 | + hSession->set_width = set_width; | |
190 | 198 | |
191 | 199 | // Set the defaults. |
192 | - hSession->extended = 1; | |
193 | - hSession->typeahead = 1; | |
194 | - hSession->oerr_lock = 1; | |
195 | - hSession->unlock_delay = 1; | |
196 | - hSession->icrnl = 1; | |
197 | - hSession->onlcr = 1; | |
198 | - hSession->host_charset = "bracket"; | |
199 | - hSession->sock = -1; | |
200 | - hSession->model_num = -1; | |
201 | - hSession->cstate = LIB3270_NOT_CONNECTED; | |
202 | - hSession->oia_status = -1; | |
203 | - hSession->kybdlock = KL_NOT_CONNECTED; | |
204 | - hSession->aid = AID_NO; | |
205 | - hSession->reply_mode = SF_SRM_FIELD; | |
206 | - hSession->linemode = 1; | |
207 | - hSession->tn3270e_submode = E_NONE; | |
208 | - hSession->scroll_top = -1; | |
209 | - hSession->scroll_bottom = -1; | |
210 | - hSession->wraparound_mode = 1; | |
200 | + hSession->extended = 1; | |
201 | + hSession->typeahead = 1; | |
202 | + hSession->oerr_lock = 1; | |
203 | + hSession->unlock_delay = 1; | |
204 | + hSession->icrnl = 1; | |
205 | + hSession->onlcr = 1; | |
206 | + hSession->host_charset = "bracket"; | |
207 | + hSession->sock = -1; | |
208 | + hSession->model_num = -1; | |
209 | + hSession->cstate = LIB3270_NOT_CONNECTED; | |
210 | + hSession->oia_status = -1; | |
211 | + hSession->kybdlock = KL_NOT_CONNECTED; | |
212 | + hSession->aid = AID_NO; | |
213 | + hSession->reply_mode = SF_SRM_FIELD; | |
214 | + hSession->linemode = 1; | |
215 | + hSession->tn3270e_submode = E_NONE; | |
216 | + hSession->scroll_top = -1; | |
217 | + hSession->scroll_bottom = -1; | |
218 | + hSession->wraparound_mode = 1; | |
211 | 219 | hSession->saved_wraparound_mode = 1; |
212 | 220 | hSession->once_cset = -1; |
213 | 221 | hSession->state = LIB3270_ANSI_STATE_DATA; |
... | ... | @@ -222,19 +230,6 @@ static void lib3270_session_init(H3270 *hSession, const char *model) |
222 | 230 | #endif // _WIN32 |
223 | 231 | |
224 | 232 | |
225 | -/* | |
226 | -#if !defined(_WIN32) | |
227 | - hSession->host_charset = "bracket"; | |
228 | -#else | |
229 | - | |
230 | - if (is_nt) | |
231 | - hSession->host_charset = "bracket"; | |
232 | - else | |
233 | - hSession->host_charset = "bracket437"; | |
234 | -#endif | |
235 | -*/ | |
236 | - | |
237 | - | |
238 | 233 | // Initialize toggles |
239 | 234 | initialize_toggles(hSession); |
240 | 235 | |
... | ... | @@ -296,20 +291,18 @@ static void lib3270_session_init(H3270 *hSession, const char *model) |
296 | 291 | |
297 | 292 | H3270 * lib3270_session_new(const char *model) |
298 | 293 | { |
299 | - static int configured = 0; | |
300 | - | |
301 | - H3270 *hSession = &h3270; | |
294 | + H3270 * hSession; | |
302 | 295 | |
303 | - trace("%s - configured=%d",__FUNCTION__,configured); | |
296 | + trace("%s - configured=%s",__FUNCTION__,default_session ? "Yes" : "No"); | |
304 | 297 | |
305 | - if(configured) | |
298 | + if(default_session) | |
306 | 299 | { |
307 | 300 | // TODO (perry#5#): Allocate a new structure. |
308 | 301 | errno = EBUSY; |
309 | - return hSession; | |
302 | + return lib3270_get_default_session_handle(); | |
310 | 303 | } |
311 | 304 | |
312 | - configured = 1; | |
305 | + hSession = default_session = lib3270_malloc(sizeof(H3270)); | |
313 | 306 | |
314 | 307 | lib3270_session_init(hSession, model); |
315 | 308 | |
... | ... | @@ -343,10 +336,14 @@ H3270 * lib3270_session_new(const char *model) |
343 | 336 | return hSession; |
344 | 337 | } |
345 | 338 | |
346 | - /* | |
347 | -- * Parse the model number. | |
348 | -- * Returns -1 (error), 0 (default), or the specified number. | |
349 | -- */ | |
339 | + /** | |
340 | + * Parse the model number. | |
341 | + * | |
342 | + * @param session Session Handle. | |
343 | + * @param m Model number. | |
344 | + * | |
345 | + * @return -1 (error), 0 (default), or the specified number. | |
346 | + */ | |
350 | 347 | static int parse_model_number(H3270 *session, const char *m) |
351 | 348 | { |
352 | 349 | int sl; |
... | ... | @@ -426,17 +423,17 @@ void check_session_handle(H3270 **hSession) |
426 | 423 | if(*hSession) |
427 | 424 | return; |
428 | 425 | |
429 | -#ifdef DEBUG | |
430 | - trace("** %s called with hSession == NULL",fname); | |
431 | -#endif | |
426 | + *hSession = lib3270_get_default_session_handle(); | |
432 | 427 | |
433 | - *hSession = &h3270; | |
428 | + lib3270_write_log(*hSession,"%s called with empty session",__FUNCTION__); | |
434 | 429 | } |
435 | 430 | |
436 | - | |
437 | 431 | LIB3270_EXPORT H3270 * lib3270_get_default_session_handle(void) |
438 | 432 | { |
439 | - return &h3270; | |
433 | + if(default_session) | |
434 | + return default_session; | |
435 | + | |
436 | + return lib3270_session_new(""); | |
440 | 437 | } |
441 | 438 | |
442 | 439 | LIB3270_EXPORT void * lib3270_get_widget(H3270 *h) | ... | ... |
toggles.c
trace_ds.c
... | ... | @@ -54,16 +54,16 @@ |
54 | 54 | #include <fcntl.h> |
55 | 55 | #include "3270ds.h" |
56 | 56 | //#include "appres.h" |
57 | -#include "objects.h" | |
57 | +// #include "objects.h" | |
58 | 58 | #include "resources.h" |
59 | 59 | // #include "ctlr.h" |
60 | 60 | |
61 | 61 | #include "charsetc.h" |
62 | -#include "childc.h" | |
62 | +// #include "childc.h" | |
63 | 63 | #include "ctlrc.h" |
64 | 64 | #include "popupsc.h" |
65 | -#include "printc.h" | |
66 | -#include "savec.h" | |
65 | +// #include "printc.h" | |
66 | +// #include "savec.h" | |
67 | 67 | #include "tablesc.h" |
68 | 68 | #include "telnetc.h" |
69 | 69 | #include "trace_dsc.h" | ... | ... |