/*
- * Copyright (C) 1995-1998, Index Data I/S
+ * Copyright (C) 1995-1999, Index Data
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.c,v $
- * Revision 1.58 1998-05-27 16:57:46 adam
+ * Revision 1.67 1999-02-02 14:51:14 adam
+ * Updated WIN32 code specific sections. Changed header.
+ *
+ * Revision 1.66 1998/10/28 10:54:41 adam
+ * SDRKit integration.
+ *
+ * Revision 1.65 1998/10/18 07:54:54 adam
+ * Additional info added for diagnostics 114 (Unsupported use attribute) and
+ * 121 (Unsupported attribute set).
+ *
+ * Revision 1.64 1998/09/22 10:48:21 adam
+ * Minor changes in search API.
+ *
+ * Revision 1.63 1998/09/02 13:53:21 adam
+ * Extra parameter decode added to search routines to implement
+ * persistent queries.
+ *
+ * Revision 1.62 1998/08/06 14:35:28 adam
+ * Routine bend_deleterequest removed.
+ *
+ * Revision 1.61 1998/06/24 12:16:15 adam
+ * Support for relations on text operands. Open range support in
+ * DFA module (i.e. [-j], [g-]).
+ *
+ * Revision 1.60 1998/06/22 11:36:49 adam
+ * Added authentication check facility to zebra.
+ *
+ * Revision 1.59 1998/06/12 12:22:13 adam
+ * Work on Zebra API.
+ *
+ * Revision 1.58 1998/05/27 16:57:46 adam
* Zebra returns surrogate diagnostic for single records when
* appropriate.
*
#include <stdio.h>
#include <assert.h>
#include <fcntl.h>
-#ifdef WINDOWS
+#ifdef WIN32
#include <io.h>
#include <process.h>
#else
#include "zserver.h"
+#ifndef ZEBRASDR
+#define ZEBRASDR 0
+#endif
+#if ZEBRASDR
+#include "zebrasdr.h"
+#endif
+
static int bend_sort (void *handle, bend_sort_rr *rr);
bend_initresult *bend_init (bend_initrequest *q)
bend_initresult *r = odr_malloc (q->stream, sizeof(*r));
ZebraHandle zh;
struct statserv_options_block *sob;
+ char *user = NULL;
+ char *passwd = NULL;
r->errcode = 0;
r->errstring = 0;
logf (LOG_DEBUG, "bend_init");
sob = statserv_getcontrol ();
- if (!(zh = zebra_open (NULL, sob->configname)))
+ if (!(zh = zebra_open (sob->configname)))
{
logf (LOG_FATAL, "Failed to open Zebra `%s'", sob->configname);
r->errcode = 1;
return r;
}
+ if (q->auth)
+ {
+ if (q->auth->which == Z_IdAuthentication_open)
+ {
+ char *openpass = xstrdup (q->auth->u.open);
+ char *cp = strchr (openpass, '/');
+ if (cp)
+ {
+ *cp = '\0';
+ user = nmem_strdup (odr_getmem (q->stream), openpass);
+ passwd = nmem_strdup (odr_getmem (q->stream), cp+1);
+ }
+ xfree (openpass);
+ }
+ }
+ if (zebra_auth (zh, user, passwd))
+ {
+ r->errcode = 222;
+ r->errstring = user;
+ zebra_close (zh);
+ return r;
+ }
r->handle = zh;
return r;
}
switch (q->query->which)
{
case Z_Query_type_1: case Z_Query_type_101:
- zebra_search_rpn (zh, q->stream, q->query->u.type_1,
+ zebra_search_rpn (zh, q->decode, q->stream, q->query->u.type_1,
q->num_bases, q->basenames, q->setname);
r->errcode = zh->errCode;
r->errstring = zh->errString;
r->hits = zh->hits;
break;
+ case Z_Query_type_2:
+ r->errcode = 107;
+ r->errstring = "type-2";
+ break;
default:
r->errcode = 107;
}
return r;
}
-bend_deleteresult *bend_delete (void *handle, bend_deleterequest *q, int *num)
-{
- return 0;
-}
-
bend_scanresult *bend_scan (void *handle, bend_scanrequest *q, int *num)
{
ZebraScanEntry *entries;
{
ZebraHandle zh = handle;
- zebra_sort (zh, rr->stream, rr->num_input_setnames, rr->input_setnames,
+ zebra_sort (zh, rr->stream,
+ rr->num_input_setnames, (const char **) rr->input_setnames,
rr->output_setname, rr->sort_sequence, &rr->sort_status);
rr->errcode = zh->errCode;
rr->errstring = zh->errString;
return 0;
}
-#ifndef WINDOWS
+#ifndef WIN32
static void pre_init (struct statserv_options_block *sob)
{
char *pidfile = "zebrasrv.pid";
sob = statserv_getcontrol ();
strcpy (sob->configname, FNAME_CONFIG);
-#ifndef WINDOWS
+#ifndef WIN32
sob->pre_init = pre_init;
#endif
statserv_setcontrol (sob);
+#if ZEBRASDR
+ zebraSdr_std ();
+#endif
return statserv_main (argc, argv);
}