Pathmaker Programming Guide
Coding Custom Services
Creating Services and Servers
067868 Tandem Computers Incorporated 4–39
Example 3: Read Previous Approximate.
?section svc-003
/*
Transaction logic module for service : SVC-003
List previous by employee name on a nonunique
alternate key.
*/
%INVOKE "defines" <−− Macro invocation.
void svc_003setup ( T9154_SERVICE_CONTROL *control )
{
}
void svc_003cleanup ( T9154_SERVICE_CONTROL *control )
{
}
void svc_003 ( 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_PREVAPPROX,
&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, "Previous employee record
read");
}