Commit 6bcd7cf1839f0f972ab12e489f580ceec93a38bc
1 parent
b7ff1ded
Exists in
develop
Splitting field methods out of ctlr.c, cleaning code.
Showing
2 changed files
with
6 additions
and
232 deletions
Show diff stats
lib3270.cbp
| @@ -86,6 +86,9 @@ | @@ -86,6 +86,9 @@ | ||
| 86 | <Unit filename="src/core/cursor.c"> | 86 | <Unit filename="src/core/cursor.c"> |
| 87 | <Option compilerVar="CC" /> | 87 | <Option compilerVar="CC" /> |
| 88 | </Unit> | 88 | </Unit> |
| 89 | + <Unit filename="src/core/field.c"> | ||
| 90 | + <Option compilerVar="CC" /> | ||
| 91 | + </Unit> | ||
| 89 | <Unit filename="src/core/ft/ft.c"> | 92 | <Unit filename="src/core/ft/ft.c"> |
| 90 | <Option compilerVar="CC" /> | 93 | <Option compilerVar="CC" /> |
| 91 | </Unit> | 94 | </Unit> |
src/core/ctlr.c
| @@ -46,7 +46,6 @@ | @@ -46,7 +46,6 @@ | ||
| 46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
| 47 | #include "3270ds.h" | 47 | #include "3270ds.h" |
| 48 | #include "screen.h" | 48 | #include "screen.h" |
| 49 | -//#include "resources.h" | ||
| 50 | 49 | ||
| 51 | #include "ctlrc.h" | 50 | #include "ctlrc.h" |
| 52 | #include "ftc.h" | 51 | #include "ftc.h" |
| @@ -65,15 +64,13 @@ | @@ -65,15 +64,13 @@ | ||
| 65 | #include "widec.h" | 64 | #include "widec.h" |
| 66 | #include "screenc.h" | 65 | #include "screenc.h" |
| 67 | 66 | ||
| 68 | -// Boolean dbcs = False; | ||
| 69 | 67 | ||
| 70 | -/* Statics */ | 68 | +// Statics |
| 71 | static void update_formatted(H3270 *session); | 69 | static void update_formatted(H3270 *session); |
| 72 | static void set_formatted(H3270 *hSession, int state); | 70 | static void set_formatted(H3270 *hSession, int state); |
| 73 | static void ctlr_blanks(H3270 *session); | 71 | static void ctlr_blanks(H3270 *session); |
| 74 | static void ctlr_half_connect(H3270 *session, int ignored, void *dunno); | 72 | static void ctlr_half_connect(H3270 *session, int ignored, void *dunno); |
| 75 | static void ctlr_connect(H3270 *session, int ignored, void *dunno); | 73 | static void ctlr_connect(H3270 *session, int ignored, void *dunno); |
| 76 | -//static void ticking_stop(H3270 *session); | ||
| 77 | static void ctlr_add_ic(H3270 *session, int baddr, unsigned char ic); | 74 | static void ctlr_add_ic(H3270 *session, int baddr, unsigned char ic); |
| 78 | 75 | ||
| 79 | /** | 76 | /** |
| @@ -92,8 +89,6 @@ static const unsigned char code_table[64] = { | @@ -92,8 +89,6 @@ static const unsigned char code_table[64] = { | ||
| 92 | }; | 89 | }; |
| 93 | 90 | ||
| 94 | #define IsBlank(c) ((c == EBC_null) || (c == EBC_space)) | 91 | #define IsBlank(c) ((c == EBC_null) || (c == EBC_space)) |
| 95 | - | ||
| 96 | - | ||
| 97 | #define ALL_CHANGED(h) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,0,(h)->view.rows*(h)->view.cols); | 92 | #define ALL_CHANGED(h) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,0,(h)->view.rows*(h)->view.cols); |
| 98 | #define REGION_CHANGED(h, f, l) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,f,l) | 93 | #define REGION_CHANGED(h, f, l) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,f,l) |
| 99 | #define ONE_CHANGED(h,n) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,n,n+1); | 94 | #define ONE_CHANGED(h,n) if(lib3270_in_ansi(h)) (h)->cbk.changed(h,n,n+1); |
| @@ -179,8 +174,6 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) { | @@ -179,8 +174,6 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) { | ||
| 179 | ovc, ovr | 174 | ovc, ovr |
| 180 | ); | 175 | ); |
| 181 | 176 | ||
| 182 | - // popup_an_error(session,"Invalid %s %dx%d:\nNegative or zero",ResOversize, ovc, ovr); | ||
| 183 | - | ||
| 184 | } else if (ovc * ovr >= 0x4000) { | 177 | } else if (ovc * ovr >= 0x4000) { |
| 185 | lib3270_popup_dialog( | 178 | lib3270_popup_dialog( |
| 186 | session, | 179 | session, |
| @@ -191,8 +184,6 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) { | @@ -191,8 +184,6 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) { | ||
| 191 | ovc, ovr | 184 | ovc, ovr |
| 192 | ); | 185 | ); |
| 193 | 186 | ||
| 194 | -// popup_an_error(session,"Invalid %s %dx%d:\nToo big",ResOversize, ovc, ovr); | ||
| 195 | - | ||
| 196 | } else if (ovc < session->max.cols) { | 187 | } else if (ovc < session->max.cols) { |
| 197 | 188 | ||
| 198 | lib3270_popup_dialog( | 189 | lib3270_popup_dialog( |
| @@ -204,7 +195,6 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) { | @@ -204,7 +195,6 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) { | ||
| 204 | ovc, session->model_num, session->max.cols | 195 | ovc, session->model_num, session->max.cols |
| 205 | ); | 196 | ); |
| 206 | 197 | ||
| 207 | -// popup_an_error(session,"Invalid %s cols (%d):\nLess than model %d cols (%d)",ResOversize, ovc, session->model_num, session->maxCOLS); | ||
| 208 | } else if (ovr < session->max.rows) { | 198 | } else if (ovr < session->max.rows) { |
| 209 | 199 | ||
| 210 | lib3270_popup_dialog( | 200 | lib3270_popup_dialog( |
| @@ -216,10 +206,10 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) { | @@ -216,10 +206,10 @@ void ctlr_set_rows_cols(H3270 *session, int mn, int ovc, int ovr) { | ||
| 216 | ovr, session->model_num, session->max.rows | 206 | ovr, session->model_num, session->max.rows |
| 217 | ); | 207 | ); |
| 218 | 208 | ||
| 219 | -// popup_an_error(session,"Invalid %s rows (%d):\nLess than model %d rows (%d)",ResOversize, ovr, session->model_num, session->maxROWS); | ||
| 220 | - | ||
| 221 | } else { | 209 | } else { |
| 210 | + | ||
| 222 | update_model_info(session,mn,session->oversize.cols = ovc,session->oversize.rows = ovr); | 211 | update_model_info(session,mn,session->oversize.cols = ovc,session->oversize.rows = ovr); |
| 212 | + | ||
| 223 | } | 213 | } |
| 224 | } | 214 | } |
| 225 | 215 | ||
| @@ -271,8 +261,6 @@ static void ctlr_half_connect(H3270 *hSession, int GNUC_UNUSED(ignored), void GN | @@ -271,8 +261,6 @@ static void ctlr_half_connect(H3270 *hSession, int GNUC_UNUSED(ignored), void GN | ||
| 271 | /// | 261 | /// |
| 272 | static void ctlr_connect(H3270 *hSession, int GNUC_UNUSED(ignored), void GNUC_UNUSED(*dunno)) { | 262 | static void ctlr_connect(H3270 *hSession, int GNUC_UNUSED(ignored), void GNUC_UNUSED(*dunno)) { |
| 273 | hSession->cbk.set_timer(hSession,0); | 263 | hSession->cbk.set_timer(hSession,0); |
| 274 | -// ticking_stop(hSession); | ||
| 275 | -// status_untiming(hSession); | ||
| 276 | 264 | ||
| 277 | if (hSession->ever_3270) | 265 | if (hSession->ever_3270) |
| 278 | hSession->ea_buf[-1].fa = FA_PRINTABLE | FA_MODIFY; | 266 | hSession->ea_buf[-1].fa = FA_PRINTABLE | FA_MODIFY; |
| @@ -293,218 +281,6 @@ static void ctlr_connect(H3270 *hSession, int GNUC_UNUSED(ignored), void GNUC_UN | @@ -293,218 +281,6 @@ static void ctlr_connect(H3270 *hSession, int GNUC_UNUSED(ignored), void GNUC_UN | ||
| 293 | hSession->crm_nattr = 0; | 281 | hSession->crm_nattr = 0; |
| 294 | } | 282 | } |
| 295 | 283 | ||
| 296 | -LIB3270_EXPORT int lib3270_is_formatted(const H3270 *hSession) { | ||
| 297 | - if(check_online_session(hSession)) | ||
| 298 | - return 0; | ||
| 299 | - | ||
| 300 | - return hSession->formatted ? 1 : 0; | ||
| 301 | -} | ||
| 302 | - | ||
| 303 | -/** | ||
| 304 | - * @brief Get field address. | ||
| 305 | - * | ||
| 306 | - * @return Negative on error(sets errno) or field address. | ||
| 307 | - * | ||
| 308 | - */ | ||
| 309 | -LIB3270_EXPORT int lib3270_get_field_start(H3270 *hSession, int baddr) { | ||
| 310 | - int sbaddr; | ||
| 311 | - | ||
| 312 | - if(check_online_session(hSession)) | ||
| 313 | - return - errno; | ||
| 314 | - | ||
| 315 | - if (!hSession->formatted) | ||
| 316 | - return - (errno = ENOTSUP); | ||
| 317 | - | ||
| 318 | - if(baddr < 0) | ||
| 319 | - baddr = hSession->cursor_addr; | ||
| 320 | - | ||
| 321 | - sbaddr = baddr; | ||
| 322 | - do { | ||
| 323 | - if(hSession->ea_buf[baddr].fa) | ||
| 324 | - return baddr; | ||
| 325 | - DEC_BA(baddr); | ||
| 326 | - } while (baddr != sbaddr); | ||
| 327 | - | ||
| 328 | - return -1; | ||
| 329 | - | ||
| 330 | -} | ||
| 331 | - | ||
| 332 | -LIB3270_EXPORT int lib3270_get_field_len(H3270 *hSession, int baddr) { | ||
| 333 | - int saddr; | ||
| 334 | - int addr; | ||
| 335 | - int width = 0; | ||
| 336 | - | ||
| 337 | - if(check_online_session(hSession)) | ||
| 338 | - return - errno; | ||
| 339 | - | ||
| 340 | - if (!hSession->formatted) | ||
| 341 | - return - (errno = ENOTSUP); | ||
| 342 | - | ||
| 343 | - if(baddr < 0) | ||
| 344 | - baddr = hSession->cursor_addr; | ||
| 345 | - | ||
| 346 | - addr = lib3270_field_addr(hSession,baddr); | ||
| 347 | - if(addr < 0) | ||
| 348 | - return addr; | ||
| 349 | - | ||
| 350 | - saddr = addr; | ||
| 351 | - INC_BA(addr); | ||
| 352 | - do { | ||
| 353 | - if(hSession->ea_buf[addr].fa) | ||
| 354 | - return width; | ||
| 355 | - INC_BA(addr); | ||
| 356 | - width++; | ||
| 357 | - } while (addr != saddr); | ||
| 358 | - | ||
| 359 | - return -(errno = ENODATA); | ||
| 360 | -} | ||
| 361 | - | ||
| 362 | -LIB3270_EXPORT int lib3270_field_addr(const H3270 *hSession, int baddr) { | ||
| 363 | - int sbaddr; | ||
| 364 | - | ||
| 365 | - if(!lib3270_is_connected(hSession)) | ||
| 366 | - return -(errno = ENOTCONN); | ||
| 367 | - | ||
| 368 | - if(!hSession->formatted) | ||
| 369 | - return -(errno = ENOTSUP); | ||
| 370 | - | ||
| 371 | - if(baddr < 0) | ||
| 372 | - baddr = lib3270_get_cursor_address(hSession); | ||
| 373 | - | ||
| 374 | - if(baddr > lib3270_get_length(hSession)) | ||
| 375 | - return -(errno = EOVERFLOW); | ||
| 376 | - | ||
| 377 | - sbaddr = baddr; | ||
| 378 | - do { | ||
| 379 | - if(hSession->ea_buf[baddr].fa) | ||
| 380 | - return baddr; | ||
| 381 | - DEC_BA(baddr); | ||
| 382 | - } while (baddr != sbaddr); | ||
| 383 | - | ||
| 384 | - return -(errno = ENODATA); | ||
| 385 | -} | ||
| 386 | - | ||
| 387 | -LIB3270_EXPORT LIB3270_FIELD_ATTRIBUTE lib3270_get_field_attribute(H3270 *hSession, int baddr) { | ||
| 388 | - int sbaddr; | ||
| 389 | - | ||
| 390 | - FAIL_IF_NOT_ONLINE(hSession); | ||
| 391 | - | ||
| 392 | - if(!hSession->formatted) { | ||
| 393 | - errno = ENOTCONN; | ||
| 394 | - return LIB3270_FIELD_ATTRIBUTE_INVALID; | ||
| 395 | - } | ||
| 396 | - | ||
| 397 | - if(baddr < 0) | ||
| 398 | - baddr = lib3270_get_cursor_address(hSession); | ||
| 399 | - | ||
| 400 | - sbaddr = baddr; | ||
| 401 | - do { | ||
| 402 | - if(hSession->ea_buf[baddr].fa) | ||
| 403 | - return (LIB3270_FIELD_ATTRIBUTE) hSession->ea_buf[baddr].fa; | ||
| 404 | - | ||
| 405 | - DEC_BA(baddr); | ||
| 406 | - } while (baddr != sbaddr); | ||
| 407 | - | ||
| 408 | - errno = EINVAL; | ||
| 409 | - return LIB3270_FIELD_ATTRIBUTE_INVALID; | ||
| 410 | - | ||
| 411 | -} | ||
| 412 | - | ||
| 413 | -/** | ||
| 414 | - * @brief Get the length of the field at given buffer address. | ||
| 415 | - * | ||
| 416 | - * @param hSession Session handle. | ||
| 417 | - * @param addr Buffer address of the field. | ||
| 418 | - * | ||
| 419 | - * @return field length or negative if invalid or not connected (sets errno). | ||
| 420 | - * | ||
| 421 | - */ | ||
| 422 | -int lib3270_field_length(H3270 *hSession, int baddr) { | ||
| 423 | - int saddr; | ||
| 424 | - int addr; | ||
| 425 | - int width = 0; | ||
| 426 | - | ||
| 427 | - addr = lib3270_field_addr(hSession,baddr); | ||
| 428 | - if(addr < 0) | ||
| 429 | - return addr; | ||
| 430 | - | ||
| 431 | - saddr = addr; | ||
| 432 | - INC_BA(addr); | ||
| 433 | - do { | ||
| 434 | - if(hSession->ea_buf[addr].fa) | ||
| 435 | - return width; | ||
| 436 | - INC_BA(addr); | ||
| 437 | - width++; | ||
| 438 | - } while (addr != saddr); | ||
| 439 | - | ||
| 440 | - return -(errno = EINVAL); | ||
| 441 | - | ||
| 442 | -} | ||
| 443 | - | ||
| 444 | -/** | ||
| 445 | - * @brief Find the field attribute for the given buffer address. | ||
| 446 | - * | ||
| 447 | - * @return Field attribute. | ||
| 448 | - * | ||
| 449 | - */ | ||
| 450 | -unsigned char get_field_attribute(H3270 *hSession, int baddr) { | ||
| 451 | - baddr = lib3270_field_addr(hSession,baddr); | ||
| 452 | - if(baddr < 0) | ||
| 453 | - return 0; | ||
| 454 | - return hSession->ea_buf[baddr].fa; | ||
| 455 | -} | ||
| 456 | - | ||
| 457 | -/** | ||
| 458 | - * @brief Find the next unprotected field. | ||
| 459 | - * | ||
| 460 | - * @param hSession Session handle. | ||
| 461 | - * @param baddr0 Search start addr (-1 to use current cursor position). | ||
| 462 | - * | ||
| 463 | - * @return address following the unprotected attribute byte, or 0 if no nonzero-width unprotected field can be found, negative if failed. | ||
| 464 | - * | ||
| 465 | - */ | ||
| 466 | -LIB3270_EXPORT int lib3270_get_next_unprotected(H3270 *hSession, int baddr0) { | ||
| 467 | - register int baddr, nbaddr; | ||
| 468 | - | ||
| 469 | - FAIL_IF_NOT_ONLINE(hSession); | ||
| 470 | - | ||
| 471 | - if(!hSession->formatted) | ||
| 472 | - return -(errno = ENOTSUP); | ||
| 473 | - | ||
| 474 | - if(baddr0 < 0) | ||
| 475 | - baddr0 = hSession->cursor_addr; | ||
| 476 | - | ||
| 477 | - nbaddr = baddr0; | ||
| 478 | - do { | ||
| 479 | - baddr = nbaddr; | ||
| 480 | - INC_BA(nbaddr); | ||
| 481 | - if(hSession->ea_buf[baddr].fa &&!FA_IS_PROTECTED(hSession->ea_buf[baddr].fa) &&!hSession->ea_buf[nbaddr].fa) | ||
| 482 | - return nbaddr; | ||
| 483 | - } while (nbaddr != baddr0); | ||
| 484 | - | ||
| 485 | - return 0; | ||
| 486 | -} | ||
| 487 | - | ||
| 488 | -LIB3270_EXPORT int lib3270_get_is_protected_at(const H3270 *h, unsigned int row, unsigned int col) { | ||
| 489 | - return lib3270_get_is_protected(h, lib3270_translate_to_address(h,row,col)); | ||
| 490 | -} | ||
| 491 | - | ||
| 492 | -LIB3270_EXPORT int lib3270_get_is_protected(const H3270 *hSession, int baddr) { | ||
| 493 | - FAIL_IF_NOT_ONLINE(hSession); | ||
| 494 | - | ||
| 495 | - if(baddr < 0) | ||
| 496 | - baddr = hSession->cursor_addr; | ||
| 497 | - | ||
| 498 | - int faddr = lib3270_field_addr(hSession,baddr); | ||
| 499 | - | ||
| 500 | - return FA_IS_PROTECTED(hSession->ea_buf[faddr].fa) ? 1 : 0; | ||
| 501 | -} | ||
| 502 | - | ||
| 503 | -LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr) { | ||
| 504 | - return lib3270_get_is_protected(h, baddr); | ||
| 505 | -} | ||
| 506 | - | ||
| 507 | - | ||
| 508 | /** | 284 | /** |
| 509 | * @brief Perform an erase command, which may include changing the (virtual) screen size. | 285 | * @brief Perform an erase command, which may include changing the (virtual) screen size. |
| 510 | * | 286 | * |
| @@ -1777,9 +1553,6 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | @@ -1777,9 +1553,6 @@ enum pds ctlr_write(H3270 *hSession, unsigned char buf[], int buflen, Boolean er | ||
| 1777 | 1553 | ||
| 1778 | ps_process(hSession); | 1554 | ps_process(hSession); |
| 1779 | 1555 | ||
| 1780 | - /* Let a script go. */ | ||
| 1781 | -// sms_host_output(); | ||
| 1782 | - | ||
| 1783 | /* Tell 'em what happened. */ | 1556 | /* Tell 'em what happened. */ |
| 1784 | return rv; | 1557 | return rv; |
| 1785 | } | 1558 | } |
| @@ -1800,7 +1573,6 @@ void ctlr_write_sscp_lu(H3270 *hSession, unsigned char buf[], int buflen) { | @@ -1800,7 +1573,6 @@ void ctlr_write_sscp_lu(H3270 *hSession, unsigned char buf[], int buflen) { | ||
| 1800 | unsigned char *cp = buf; | 1573 | unsigned char *cp = buf; |
| 1801 | int s_row; | 1574 | int s_row; |
| 1802 | unsigned char c; | 1575 | unsigned char c; |
| 1803 | -// int baddr; | ||
| 1804 | 1576 | ||
| 1805 | /* | 1577 | /* |
| 1806 | * The 3174 Functionl Description says that anything but NL, NULL, FM, | 1578 | * The 3174 Functionl Description says that anything but NL, NULL, FM, |
| @@ -1846,7 +1618,6 @@ void ctlr_write_sscp_lu(H3270 *hSession, unsigned char buf[], int buflen) { | @@ -1846,7 +1618,6 @@ void ctlr_write_sscp_lu(H3270 *hSession, unsigned char buf[], int buflen) { | ||
| 1846 | break; | 1618 | break; |
| 1847 | 1619 | ||
| 1848 | case ORDER_SBA: | 1620 | case ORDER_SBA: |
| 1849 | -// baddr = DECODE_BADDR(*(cp+1), *(cp+2)); | ||
| 1850 | trace_ds(hSession," SetBufferAddress%s [ignored]\n", rcba(hSession,DECODE_BADDR(*(cp+1), *(cp+2)))); | 1621 | trace_ds(hSession," SetBufferAddress%s [ignored]\n", rcba(hSession,DECODE_BADDR(*(cp+1), *(cp+2)))); |
| 1851 | cp += 2; | 1622 | cp += 2; |
| 1852 | i += 2; | 1623 | i += 2; |