Pathmaker Programming Guide

Coding Custom Services
Creating Services and Servers
4–40 067868 Tandem Computers Incorporated
Example 4: Insert.
?section svc-004
/*
Transaction logic module for service : SVC-004
Insert employee record.
*/
void svc_004setup ( T9154_SERVICE_CONTROL *control )
{
}
void svc_004cleanup ( T9154_SERVICE_CONTROL *control )
{
}
void svc_004 ( T9154_SERVICE_REQUEST *request,
T9154_SERVICE_REPLY *reply,
T9154_SERVICE_CONTROL *control )
{
short cc;
reply->t9154_header.reply_code = REPLY_LONG;
if ( lfwrite ( &control->file.employee_file,
&request->employee_rec,
sizeof request->employee_rec ))
{
reply->t9154_header.reply_code = REPLY_SHORT;
return;
}
if ( lfseekkey ( &control->file.employee_file,
(short) 0,
LFSK_EXACT,
&request->employee_rec.emp_no,
sizeof request->employee_rec.emp_no,
NULL,
0,
0 ))
{
reply->t9154_header.reply_code = REPLY_SHORT;
return;
}
cc = ( lfread ( &control->file.employee_file,
&reply->employee_rec, sizeof reply->employee_rec));
if (cc != LFE_OK)
{
%INVOKE "evaluate-read-error"
return;
}
else
svc_advisory (REPLY_NORMAL, "Record inserted OK");
}