OSI/MHS Management Programming Manual
Examples
OSI/MHS Management Programming Manual—424824-001
C-45
Example in C
/* Any SQL error (other than row not found) is returned as the error code. */
/***************************************************************************/
int validate_mta_request (int passw_command,
zmhs_ddl_local_mta_name_def *local_mta_name,
zmhs_ddl_remote_mta_name_def *remote_mta_name,
zmhs_ddl_passw_def *req_passw_in,
zmhs_ddl_passw_def *rsp_passw_out,
bool *req_valid)
{
int sql_error;
zmhs_ddl_passw_def req_password;
sql_error = 0;
*req_valid = FALSE;
memset (mtpwtabl_row.local_mta_name,
BLANKS,
sizeof (mtpwtabl_row.local_mta_name));
memset (mtpwtabl_row.remote_mta_name,
BLANKS,
sizeof (mtpwtabl_row.remote_mta_name));
memset (&req_password, BLANKS, sizeof (zmhs_ddl_passw_def));
memcpy (mtpwtabl_row.local_mta_name,
local_mta_name->zmta_name.zstring,
local_mta_name->zmta_name.zlength);
memcpy (mtpwtabl_row.remote_mta_name,
remote_mta_name->zmta_name.zstring,
remote_mta_name->zmta_name.zlength);
if (passw_command == ZMHS_VAL_PASSW_MTA_INDICATION ||
passw_command == ZMHS_VAL_PASSW_MTA_CONFIRM)
{
memcpy (req_password.zstring,
req_passw_in->zstring,
req_passw_in->zlength);
}
exec sql begin work;
/* obtain the row corresponding to the remote MTA */
exec sql
select our_password,
our_password_rsp,
their_password,
their_password_rsp
into :mtpwtabl_row.our_password,
:mtpwtabl_row.our_password_rsp,
:mtpwtabl_row.their_password,
:mtpwtabl_row.their_password_rsp
from =mtpwtabl
where (local_mta_name = :mtpwtabl_row.local_mta_name AND
remote_mta_name = :mtpwtabl_row.remote_mta_name);
*req_valid = (sqlcode == 0);
sql_error = (sqlcode == SQL_ROW_NOT_FOUND_ERROR) ? 0 : sqlcode;
exec sql commit work;
if (!*req_valid ||
sql_error != 0)
{
return sql_error;
}
/* For INDICATION and CONFIRM, validate the password in the request
* with the password in the MTPWTABL row.
* For REQUEST and RESPONSE, copy the password from the MTPWTABL