Gazelle Target API Reference
The Gazelle Target API contains a set of core routines which you
implement to allow Gazelle to access a data source. It also contains
utilities for constructing result records. Here's a summary of the
routines in the Target API. For an overview of developing Target API
implementations, look
here.
The Core Routines
void *target_connect(Dict *params)
Description
Called when the client connects to Gazelle.
Parameters
: a dictionary of parameter
values from the top level of the configuration file.
Return Value
A "state pointer" containing any information the target implementation
wants to keep track of between target API calls.
int target_search(const char *q,
Dict *params, void *state)
Description
Called when the client issues a search request.
Parameters
-
q:
the translated query, generated by Gazelle's template-based query translating
engine.
state: the state pointer
returned by the call to target_connect.
Return Value
The number of records which matched the query.
target_record *target_present(long int ix,
int bf, void *state)
Description
Called each time the client wishes to retrieve a record from the set
of records which matched the query.
Parameters
-
ix:
the ordinal, zero-based index of the desired record.
bf:
either TARGET_BRIEF or TARGET_FULL, indicating whether
the target is requesting a summary (brief) record, or a complete (full)
record.
state: the state pointer
returned by the call to target_connect.
Return Value
A target_record,
which can be constructed from a null-terminated string or other character
data using several utility functions for constructing target_records
(see below).
int target_disconnect(void *state)
Description
Called when the client disconnects. Should clean up any resources associated
with this client interaction and free the state pointer. Should return
non-zero for success and zero for a fatal condition.
Parameters
state: the state pointer
returned by the call to target_connect.
Return Value
Nonzero if successful, zero if a fatal condition has arisen.
Target Record Constructors
These are used when returning records from
target_present.
target_record *target_record_new(char *data, size_t len, char *syntax);
Description
Construct a target record from a given buffer in the given syntax.
Parameters
-
data: the contents of the
record.
-
len: the length of the record in
bytes.
-
syntax: the record syntax (must
be a valid Z39.50 OID. Use constants such as HTML_OID or
SUTRS_OID, unless you know what you're doing.
Return Value
A new target_record data structure.
target_record *target_record_newText(char *data, char *syntax);
Description
Construct a target record from a given null-terminated string in the given syntax.
Parameters
-
data: the contents of the
record as a null-terminated string.
-
syntax: the record syntax (must
be a valid Z39.50 OID. Use constants such as HTML_OID or
SUTRS_OID, unless you know what you're doing.
Return Value
A new target_record data structure.
target_record *target_record_newPlainText(char *data);
Description
Construct a target record from a given null-terminated string in
plaintext syntax.
Parameters
-
data: the contents of the
record as a null-terminated string.
Return Value
A new target_record data structure.