Pathmaker Programming Guide

Coding Custom Services
Creating Services and Servers
067868 Tandem Computers Incorporated 4–37
Examples of C Service Code Using Common Service Utility Library Functions
These code excerpts show examples of C service code that uses various functions
provided in the common service utility library to access Enscribe files.
Example 1: Read Approximate.
?section svc-001
/*
Transaction logic module for service : SVC-001
List first by employee name on a nonunique
alternate key.
*/
void svc_001setup ( T9154_SERVICE_CONTROL *control )
{
}
void svc_001cleanup ( T9154_SERVICE_CONTROL *control )
{
}
void svc_001 ( 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_APPROX,
NULL,
0,
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, "First employee record
read");
}