Pathmaker Programming Guide

Coding Custom Services
Creating Services and Servers
4–38 067868 Tandem Computers Incorporated
Example 2: Read Next Approximate.
?section svc-002
/*
Transaction logic module for service : SVC-002
List next by employee name on a nonunique
alternate key.
*/
%INVOKE "defines" <−− Macro invocation.
void svc_002setup ( T9154_SERVICE_CONTROL *control )
{
}
void svc_002cleanup ( T9154_SERVICE_CONTROL *control )
{
}
void svc_002 ( T9154_SERVICE_REQUEST *request,
T9154_SERVICE_REPLY *reply,
T9154_SERVICE_CONTROL *control )
{
short cc;
reply->t9154_header.reply_code = REPLY_LONG;
if ( lfseekkey ( &control->file.employee_file,
(short) 'en', <−− 'en', the keytag is
case sensitive.
LFSK_NEXTAPPROX,
&request->employee_rec.empname,
EMPNAMELEN, <--- Length of employee name.
&request->employee_rec.emp_no,
sizeof request->employee_rec.emp_no,
EMPNAMELEN ))
{
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, "Next employee record
read");
}