/*
- * Copyright (c) 1995-1997, Index Data.
+ * Copyright (c) 1995-1998, Index Data.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation, in whole or in part, for any purpose, is hereby granted,
* OF THIS SOFTWARE.
*
* $Log: backend.h,v $
- * Revision 1.16 1997-09-17 12:10:31 adam
+ * Revision 1.17 1998-01-29 13:15:35 adam
+ * Implemented sort for the backend interface.
+ *
+ * Revision 1.16 1997/09/17 12:10:31 adam
* YAZ version 1.4.
*
*/
extern "C" {
#endif
-typedef struct bend_initrequest
-{
- char *configname;
- Z_IdAuthentication *auth;
- ODR stream; /* encoding stream */
-} bend_initrequest;
-
-typedef struct bend_initresult
-{
- int errcode; /* 0==OK */
- char *errstring; /* system error string or NULL */
- void *handle; /* private handle to the backend module */
-} bend_initresult;
-
-YAZ_EXPORT bend_initresult MDF *bend_init(bend_initrequest *r);
typedef struct bend_searchrequest
{
YAZ_EXPORT void bend_close(void *handle);
+typedef struct bend_sortrequest
+{
+ int num_input_setnames;
+ char **input_setnames;
+ char *output_setname;
+ Z_SortKeySpecList *sort_sequence;
+ ODR stream;
+} bend_sortrequest;
+
+typedef struct bend_sortresult
+{
+ int sort_status;
+ int errcode;
+ char *errstring;
+} bend_sortresult;
+
+typedef struct bend_initrequest
+{
+ char *configname;
+ Z_IdAuthentication *auth;
+ ODR stream; /* encoding stream */
+
+ int (*bend_sort) (void *handle, bend_sortrequest *req,
+ bend_sortresult *res);
+} bend_initrequest;
+
+typedef struct bend_initresult
+{
+ int errcode; /* 0==OK */
+ char *errstring; /* system error string or NULL */
+ void *handle; /* private handle to the backend module */
+} bend_initresult;
+
+YAZ_EXPORT bend_initresult MDF *bend_init(bend_initrequest *r);
+
#ifdef __cplusplus
}
#endif
/*
- * Copyright (c) 1995, Index Data
+ * Copyright (c) 1995-1998, Index Data
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: seshigh.c,v $
- * Revision 1.69 1997-09-30 11:48:12 adam
+ * Revision 1.70 1998-01-29 13:15:35 adam
+ * Implemented sort for the backend interface.
+ *
+ * Revision 1.69 1997/09/30 11:48:12 adam
* Fixed bug introduced by previous commit.
*
* Revision 1.68 1997/09/29 13:18:59 adam
static Z_APDU *process_presentRequest(association *assoc, request *reqb,
int *fd);
static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd);
+static Z_APDU *process_sortRequest(association *assoc, request *reqb, int *fd);
static void process_close(association *assoc, request *reqb);
static FILE *apduf = 0; /* for use in static mode */
res = process_presentRequest(assoc, req, &fd); break;
case Z_APDU_scanRequest:
res = process_scanRequest(assoc, req, &fd); break;
+ case Z_APDU_sortRequest:
+ if (assoc->bend_sort)
+ res = process_sortRequest(assoc, req, &fd);
+ else
+ {
+ logf(LOG_WARN, "Cannot handle SORT APDU");
+ return -1;
+ }
+ break;
case Z_APDU_close:
process_close(assoc, req); return 0;
default:
binitreq.stream = assoc->encode;
binitreq.configname = "default-config";
binitreq.auth = req->idAuthentication;
+ binitreq.bend_sort = NULL;
if (!(binitres = bend_init(&binitreq)))
{
logf(LOG_WARN, "Bad response from backend.");
}
assoc->backend = binitres->handle;
+ if ((assoc->bend_sort = binitreq.bend_sort))
+ logf (LOG_DEBUG, "Sort handler installed");
resp->referenceId = req->referenceId;
*options = '\0';
/* let's tell the client what we can do */
ODR_MASK_SET(resp->options, Z_Options_concurrentOperations);
strcat(options, " concurop");
}
-
+ if (ODR_MASK_GET(req->options, Z_Options_sort && binitreq.bend_sort))
+ {
+ ODR_MASK_SET(resp->options, Z_Options_sort);
+ strcat(options, " sort");
+ }
if (ODR_MASK_GET(req->protocolVersion, Z_ProtocolVersion_1))
{
ODR_MASK_SET(resp->protocolVersion, Z_ProtocolVersion_1);
bend_scanresult *srs;
oident *attset;
- logf(LOG_LOG, "Got scanrequest");
+ logf(LOG_LOG, "Got ScanRequest");
*scanStatus = Z_Scan_failure;
*numberOfEntriesReturned = 0;
return apdu;
}
+static Z_APDU *process_sortRequest(association *assoc, request *reqb,
+ int *fd)
+{
+ Z_SortRequest *req = reqb->request->u.sortRequest;
+ Z_SortResponse *res = odr_malloc (assoc->encode, sizeof(*res));
+ bend_sortrequest bsrq;
+ bend_sortresult *bsrt;
+ Z_APDU *apdu = odr_malloc (assoc->encode, sizeof(*apdu));
+
+ logf(LOG_LOG, "Got SortRequest.");
+
+ bsrq.num_input_setnames = req->inputResultSetNames->num_strings;
+ bsrq.input_setnames = req->inputResultSetNames->strings;
+ bsrq.output_setname = req->sortedResultSetName;
+ bsrq.sort_sequence = req->sortSequence;
+ bsrq.stream = assoc->encode;
+
+ bsrt = odr_malloc (assoc->encode, sizeof(*bsrt));
+ bsrt->sort_status = Z_SortStatus_failure;
+ bsrt->errcode = 0;
+ bsrt->errstring = 0;
+
+ (*assoc->bend_sort)(assoc->backend, &bsrq, bsrt);
+
+ res->referenceId = req->referenceId;
+ res->sortStatus = odr_malloc (assoc->encode, sizeof(*res->sortStatus));
+ *res->sortStatus = bsrt->sort_status;
+ res->resultSetStatus = 0;
+ if (bsrt->errcode)
+ res->diagnostics = diagrecs(assoc, bsrt->errcode, bsrt->errstring);
+ res->otherInfo = 0;
+
+ apdu->which = Z_APDU_sortResponse;
+ apdu->u.sortResponse = res;
+ return apdu;
+}
+
static void process_close(association *assoc, request *reqb)
{
Z_Close *req = reqb->request->u.close;
"unspecified"
};
- logf(LOG_LOG, "Got close, reason %s, message %s",
+ logf(LOG_LOG, "Got Close, reason %s, message %s",
reasons[*req->closeReason], req->diagnosticInformation ?
req->diagnosticInformation : "NULL");
if (assoc->version < 3) /* to make do_force respond with close */