--------------------------------------------------------------------------- | Facility : libnform | Function : int form_driver(FORM * form,int c) | | Description : This is the workhorse of the forms system. It checks | to determine whether the character c is a request or | data. If it is a request, the form driver executes |
| 3677 | | Function : int form_driver(FORM * form,int c) |
| 3678 | | |
| 3679 | | Description : This is the workhorse of the forms system. It checks |
| 3680 | | to determine whether the character c is a request or |
| 3681 | | data. If it is a request, the form driver executes |
| 3682 | | the request and returns the result. If it is data |
| 3683 | | (printable character), it enters the data into the |
| 3684 | | current position in the current field. If it is not |
| 3685 | | recognized, the form driver assumes it is an application |
| 3686 | | defined command and returns E_UNKNOWN_COMMAND. |
| 3687 | | Application defined command should be defined relative |
| 3688 | | to MAX_FORM_COMMAND, the maximum value of a request. |
| 3689 | | |
| 3690 | | Return Values : E_OK - success |
| 3691 | | E_SYSTEM_ERROR - system error |
| 3692 | | E_BAD_ARGUMENT - an argument is incorrect |
| 3693 | | E_NOT_POSTED - form is not posted |
| 3694 | | E_INVALID_FIELD - field contents are invalid |
| 3695 | | E_BAD_STATE - called from inside a hook routine |
| 3696 | | E_REQUEST_DENIED - request failed |
| 3697 | | E_UNKNOWN_COMMAND - command not known |
| 3698 | +--------------------------------------------------------------------------*/ |
| 3699 | int form_driver(FORM * form, int c) |
| 3700 | { |
| 3701 | const Binding_Info* BI = (Binding_Info *)0; |
| 3702 | int res = E_UNKNOWN_COMMAND; |
| 3703 | |
| 3704 | if (!form) |
| 3705 | RETURN(E_BAD_ARGUMENT); |
| 3706 | |
| 3707 | if (!(form->field)) |
| 3708 | RETURN(E_NOT_CONNECTED); |
| 3709 | |
| 3710 | assert(form->page != 0); |
| 3711 | |
| 3712 | if (c==FIRST_ACTIVE_MAGIC) |
| 3713 | { |
| 3714 | form->current = _nc_First_Active_Field(form); |
| 3715 | return E_OK; |
| 3716 | } |
| 3717 | |
| 3718 | assert(form->current && |
| 3719 | form->current->buf && |
| 3720 | (form->current->form == form) |
| 3721 | ); |
| 3722 | |
| 3723 | if ( form->status & _IN_DRIVER ) |
| 3724 | RETURN(E_BAD_STATE); |
| 3725 | |
| 3726 | if ( !( form->status & _POSTED ) ) |
| 3727 | RETURN(E_NOT_POSTED); |
| 3728 | |
| 3729 | if ((c>=MIN_FORM_COMMAND && c<=MAX_FORM_COMMAND) && |
| 3730 | ((bindings[c-MIN_FORM_COMMAND].keycode & Key_Mask) == c)) |
| 3731 | BI = &(bindings[c-MIN_FORM_COMMAND]); |
| 3732 | |
| 3733 | if (BI) |
| 3734 | { |
| 3735 | typedef int (*Generic_Method)(int (* const)(FORM *),FORM *); |
| 3736 | static const Generic_Method Generic_Methods[] = |
no test coverage detected
searching dependent graphs…