YAZ  5.23.1
zoom-z3950.c
Go to the documentation of this file.
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data
3  * See the file LICENSE for details.
4  */
9 #if HAVE_CONFIG_H
10 #include <config.h>
11 #endif
12 
13 #include <assert.h>
14 #include <string.h>
15 #include <errno.h>
16 #include "zoom-p.h"
17 
18 #include <yaz/yaz-util.h>
19 #include <yaz/xmalloc.h>
20 #include <yaz/otherinfo.h>
21 #include <yaz/log.h>
22 #include <yaz/pquery.h>
23 #include <yaz/marcdisp.h>
24 #include <yaz/diagbib1.h>
25 #include <yaz/charneg.h>
26 #include <yaz/ill.h>
27 #include <yaz/query-charset.h>
28 #include <yaz/copy_types.h>
29 #include <yaz/snprintf.h>
30 #include <yaz/facet.h>
31 
32 #include <yaz/shptr.h>
33 
34 /*
35  * This wrapper is just for logging failed lookups. It would be nicer
36  * if it could cause failure when a lookup fails, but that's hard.
37  */
39  oid_class oid_class, const char *str)
40 {
41  Odr_oid *res = yaz_string_to_oid_odr(yaz_oid_std(), oid_class, str,
42  c->odr_out);
43  if (res == 0)
44  yaz_log(YLOG_WARN, "%p OID lookup (%d, '%s') failed",
45  c, (int) oid_class, str);
46  return res;
47 }
48 
50 {
51  const char *str;
54 
55  str = ZOOM_options_get(p->options, "package-name");
56  if (str && *str)
57  req->packageName = odr_strdup(p->odr_out, str);
58 
59  str = ZOOM_options_get(p->options, "user-id");
60  if (str)
61  req->userId = odr_strdup_null(p->odr_out, str);
62 
63  req->packageType = odr_oiddup(p->odr_out, oid);
64 
65  str = ZOOM_options_get(p->options, "function");
66  if (str)
67  {
68  if (!strcmp (str, "create"))
70  if (!strcmp (str, "delete"))
72  if (!strcmp (str, "modify"))
74  }
75 
76  str = ZOOM_options_get(p->options, "waitAction");
77  if (str)
78  {
79  if (!strcmp (str, "wait"))
81  if (!strcmp (str, "waitIfPossible"))
83  if (!strcmp (str, "dontWait"))
85  if (!strcmp (str, "dontReturnPackage"))
87  }
88  return apdu;
89 }
90 
91 static const char *ill_array_lookup(void *clientData, const char *idx)
92 {
93  ZOOM_package p = (ZOOM_package) clientData;
94  return ZOOM_options_get(p->options, idx+4);
95 }
96 
98 {
99  ODR out = p->odr_out;
100  ILL_Request *req;
101  Z_External *r = 0;
102  struct ill_get_ctl ctl;
103 
104  ctl.odr = p->odr_out;
105  ctl.clientData = p;
106  ctl.f = ill_array_lookup;
107 
108  req = ill_get_ILLRequest(&ctl, "ill", 0);
109 
110  if (!ill_Request(out, &req, 0, 0))
111  {
112  int ill_request_size;
113  char *ill_request_buf = odr_getbuf(out, &ill_request_size, 0);
114  if (ill_request_buf)
115  odr_setbuf(out, ill_request_buf, ill_request_size, 1);
116  return 0;
117  }
118  else
119  {
120  int illRequest_size = 0;
121  char *illRequest_buf = odr_getbuf(out, &illRequest_size, 0);
122 
123  r = (Z_External *) odr_malloc(out, sizeof(*r));
125  r->indirect_reference = 0;
126  r->descriptor = 0;
128 
129  r->u.single_ASN1_type =
130  odr_create_Odr_oct(out, illRequest_buf, illRequest_size);
131  }
132  return r;
133 }
134 
136 {
137  Z_ItemOrder *req = (Z_ItemOrder *) odr_malloc(p->odr_out, sizeof(*req));
138  const char *str;
139  int len;
140 
142  req->u.esRequest = (Z_IORequest *)
143  odr_malloc(p->odr_out,sizeof(Z_IORequest));
144 
145  /* to keep part ... */
148  req->u.esRequest->toKeep->supplDescription = 0;
149  req->u.esRequest->toKeep->contact = (Z_IOContact *)
150  odr_malloc(p->odr_out, sizeof(*req->u.esRequest->toKeep->contact));
151 
152  str = ZOOM_options_get(p->options, "contact-name");
153  req->u.esRequest->toKeep->contact->name =
154  odr_strdup_null(p->odr_out, str);
155 
156  str = ZOOM_options_get(p->options, "contact-phone");
157  req->u.esRequest->toKeep->contact->phone =
158  odr_strdup_null(p->odr_out, str);
159 
160  str = ZOOM_options_get(p->options, "contact-email");
161  req->u.esRequest->toKeep->contact->email =
162  odr_strdup_null(p->odr_out, str);
163 
164  req->u.esRequest->toKeep->addlBilling = 0;
165 
166  /* not to keep part ... */
169 
170  str = ZOOM_options_get(p->options, "itemorder-setname");
171  if (!str)
172  str = "default";
173 
174  if (!*str)
175  req->u.esRequest->notToKeep->resultSetItem = 0;
176  else
177  {
179  odr_malloc(p->odr_out, sizeof(Z_IOResultSetItem));
180 
182  odr_strdup(p->odr_out, str);
184  odr_intdup(p->odr_out, 0);
185 
186  str = ZOOM_options_get(p->options, "itemorder-item");
188  (str ? atoi(str) : 1);
189  }
190 
191  str = ZOOM_options_getl(p->options, "doc", &len);
192  if (str)
193  {
195  z_ext_record_xml(p->odr_out, str, len);
196  }
197  else
199 
200  return req;
201 }
202 
204  Z_ESAdminOriginPartToKeep **toKeepP,
205  Z_ESAdminOriginPartNotToKeep **notToKeepP)
206 {
208  if (apdu)
209  {
211  Z_ESAdminOriginPartNotToKeep *notToKeep;
212  Z_External *r = (Z_External *) odr_malloc(p->odr_out, sizeof(*r));
213  const char *first_db = "Default";
214  int num_db;
216  p->options, &num_db,
217  p->odr_out);
218  if (num_db > 0)
219  first_db = db[0];
220 
222  r->descriptor = 0;
223  r->indirect_reference = 0;
225 
226  r->u.adminService = (Z_Admin *)
227  odr_malloc(p->odr_out, sizeof(*r->u.adminService));
230  odr_malloc(p->odr_out, sizeof(*r->u.adminService->u.esRequest));
231 
232  toKeep = r->u.adminService->u.esRequest->toKeep =
234  odr_malloc(p->odr_out, sizeof(*r->u.adminService->u.esRequest->toKeep));
235  toKeep->which = type;
236  toKeep->databaseName = odr_strdup(p->odr_out, first_db);
237  toKeep->u.create = odr_nullval();
239 
240  r->u.adminService->u.esRequest->notToKeep = notToKeep =
242  odr_malloc(p->odr_out,
243  sizeof(*r->u.adminService->u.esRequest->notToKeep));
245  notToKeep->u.recordsWillFollow = odr_nullval();
246  if (toKeepP)
247  *toKeepP = toKeep;
248  if (notToKeepP)
249  *notToKeepP = notToKeep;
250  }
251  return apdu;
252 }
253 
255 {
258  Z_External *ext = (Z_External *) odr_malloc(p->odr_out, sizeof(*ext));
259  int len;
260  const char *doc = ZOOM_options_getl(p->options, "doc", &len);
261 
262  if (!doc)
263  {
264  doc = "";
265  len = 0;
266  }
267 
268  req->taskSpecificParameters = ext;
269  ext->direct_reference = req->packageType;
270  ext->descriptor = 0;
271  ext->indirect_reference = 0;
272 
273  ext->which = Z_External_octet;
274  ext->u.single_ASN1_type = odr_create_Odr_oct(p->odr_out, doc, len);
275  return apdu;
276 }
277 
279 {
280  Z_APDU *apdu = 0;
281  const char *first_db = "Default";
282  int num_db;
284  &num_db, p->odr_out);
285  const char *action = ZOOM_options_get(p->options, "action");
286  int recordIdOpaque_len;
287  const char *recordIdOpaque = ZOOM_options_getl(p->options, "recordIdOpaque",
288  &recordIdOpaque_len);
289  const char *recordIdNumber = ZOOM_options_get(p->options, "recordIdNumber");
290  int record_len;
291  const char *record_buf = ZOOM_options_getl(p->options, "record",
292  &record_len);
293  int recordOpaque_len;
294  const char *recordOpaque_buf = ZOOM_options_getl(p->options, "recordOpaque",
295  &recordOpaque_len);
296  const char *syntax_str = ZOOM_options_get(p->options, "syntax");
297  const char *version = ZOOM_options_get(p->options, "updateVersion");
298 
299  const char *correlationInfo_note =
300  ZOOM_options_get(p->options, "correlationInfo.note");
301  const char *correlationInfo_id =
302  ZOOM_options_get(p->options, "correlationInfo.id");
303  int action_no = -1;
304  Odr_oid *syntax_oid = 0;
305  const Odr_oid *package_oid = yaz_oid_extserv_database_update;
306 
307  if (!version)
308  version = "3";
309  if (!syntax_str)
310  syntax_str = "xml";
311  if (!record_buf && !recordOpaque_buf)
312  {
313  record_buf = "void";
314  record_len = 4;
315  syntax_str = "SUTRS";
316  }
317 
318  if (syntax_str)
319  {
320  syntax_oid = yaz_string_to_oid_odr(yaz_oid_std(),
321  CLASS_RECSYN, syntax_str,
322  p->odr_out);
323  }
324  if (!syntax_oid)
325  {
327  return 0;
328  }
329 
330  if (num_db > 0)
331  first_db = db[0];
332 
333  switch (*version)
334  {
335  case '1':
337  /* old update does not support specialUpdate */
338  if (!action)
339  action = "recordInsert";
340  break;
341  case '2':
342  if (!action)
343  action = "specialUpdate";
345  break;
346  case '3':
347  if (!action)
348  action = "specialUpdate";
349  package_oid = yaz_oid_extserv_database_update;
350  break;
351  default:
353  return 0;
354  }
355 
356  if (!strcmp(action, "recordInsert"))
358  else if (!strcmp(action, "recordReplace"))
360  else if (!strcmp(action, "recordDelete"))
362  else if (!strcmp(action, "elementUpdate"))
364  else if (!strcmp(action, "specialUpdate"))
366  else
367  {
369  return 0;
370  }
371 
372  apdu = create_es_package(p, package_oid);
373  if (apdu)
374  {
375  Z_IUOriginPartToKeep *toKeep;
376  Z_IUSuppliedRecords *notToKeep;
377  Z_External *r = (Z_External *)
378  odr_malloc(p->odr_out, sizeof(*r));
379  const char *elementSetName =
380  ZOOM_options_get(p->options, "elementSetName");
381 
383 
384  r->direct_reference = odr_oiddup(p->odr_out, package_oid);
385  r->descriptor = 0;
387  r->indirect_reference = 0;
388  r->u.update = (Z_IUUpdate *)
389  odr_malloc(p->odr_out, sizeof(*r->u.update));
390 
393  odr_malloc(p->odr_out, sizeof(*r->u.update->u.esRequest));
394  toKeep = r->u.update->u.esRequest->toKeep =
396  odr_malloc(p->odr_out, sizeof(*toKeep));
397 
398  toKeep->databaseName = odr_strdup(p->odr_out, first_db);
399  toKeep->schema = 0;
400 
401  toKeep->elementSetName = odr_strdup_null(p->odr_out, elementSetName);
402 
403  toKeep->actionQualifier = 0;
404  toKeep->action = odr_intdup(p->odr_out, action_no);
405 
406  notToKeep = r->u.update->u.esRequest->notToKeep =
408  odr_malloc(p->odr_out, sizeof(*notToKeep));
409  notToKeep->num = 1;
410  notToKeep->elements = (Z_IUSuppliedRecords_elem **)
411  odr_malloc(p->odr_out, sizeof(*notToKeep->elements));
412  notToKeep->elements[0] = (Z_IUSuppliedRecords_elem *)
413  odr_malloc(p->odr_out, sizeof(**notToKeep->elements));
415  if (recordIdOpaque)
416  {
417  notToKeep->elements[0]->u.opaque =
418  odr_create_Odr_oct(p->odr_out, recordIdOpaque,
419  recordIdOpaque_len);
420  }
421  else if (recordIdNumber)
422  {
424 
425  notToKeep->elements[0]->u.number =
426  odr_intdup(p->odr_out, atoi(recordIdNumber));
427  }
428  else
429  notToKeep->elements[0]->u.opaque = 0;
430  notToKeep->elements[0]->supplementalId = 0;
431  if (correlationInfo_note || correlationInfo_id)
432  {
434  ci = notToKeep->elements[0]->correlationInfo =
435  (Z_IUCorrelationInfo *) odr_malloc(p->odr_out, sizeof(*ci));
436  ci->note = odr_strdup_null(p->odr_out, correlationInfo_note);
437  ci->id = correlationInfo_id ?
438  odr_intdup(p->odr_out, atoi(correlationInfo_id)) : 0;
439  }
440  else
441  notToKeep->elements[0]->correlationInfo = 0;
442  if (recordOpaque_buf)
443  {
444  notToKeep->elements[0]->record =
445  z_ext_record_oid_any(p->odr_out, syntax_oid,
446  recordOpaque_buf, recordOpaque_len);
447  }
448  else
449  {
450  notToKeep->elements[0]->record =
451  z_ext_record_oid(p->odr_out, syntax_oid,
452  record_buf, record_len);
453  }
454  }
455  if (0 && apdu)
456  {
457  ODR print = odr_createmem(ODR_PRINT);
458 
459  z_APDU(print, &apdu, 0, 0);
460  odr_destroy(print);
461  }
462  return apdu;
463 }
464 
465 
467 {
468  int i;
469  for (i = 0; i < 200; i++)
470  {
471  size_t len;
472  Odr_oid *oid;
473  Z_OtherInformation **oi;
474  char buf[80];
475  const char *val;
476  const char *cp;
477 
478  sprintf(buf, "otherInfo%d", i);
479  val = ZOOM_options_get(c->options, buf);
480  if (!val)
481  break;
482  cp = strchr(val, ':');
483  if (!cp)
484  continue;
485  len = cp - val;
486  if (len >= sizeof(buf))
487  len = sizeof(buf)-1;
488  memcpy(buf, val, len);
489  buf[len] = '\0';
490 
492  buf, out);
493  if (!oid)
494  continue;
495 
496  yaz_oi_APDU(a, &oi);
497  yaz_oi_set_string_oid(oi, out, oid, 1, cp+1);
498  }
499 }
500 
501 
502 
503 static int encode_APDU(ZOOM_connection c, Z_APDU *a, ODR out)
504 {
505  assert(a);
506  if (c->cookie_out)
507  {
508  Z_OtherInformation **oi;
509  yaz_oi_APDU(a, &oi);
511  1, c->cookie_out);
512  }
513  if (c->client_IP && a->which == Z_APDU_initRequest)
514  {
515  Z_OtherInformation **oi;
516  yaz_oi_APDU(a, &oi);
518  1, c->client_IP);
519  }
520  otherInfo_attach(c, a, out);
521  if (!z_APDU(out, &a, 0, 0))
522  {
523  FILE *outf = fopen("/tmp/apdu.txt", "a");
524  if (a && outf)
525  {
526  ODR odr_pr = odr_createmem(ODR_PRINT);
527  fprintf(outf, "a=%p\n", a);
528  odr_setprint(odr_pr, outf);
529  z_APDU(odr_pr, &a, 0, 0);
530  odr_destroy(odr_pr);
531  }
532  yaz_log(c->log_api, "%p encoding_APDU: encoding failed", c);
534  odr_reset(out);
535  return -1;
536  }
537  if (c->odr_print)
538  z_APDU(c->odr_print, &a, 0, 0);
539  if (c->odr_save)
540  z_APDU(c->odr_save, &a, 0, 0);
541  yaz_log(c->log_details, "%p encoding_APDU encoding OK", c);
542  return 0;
543 }
544 
546 {
547  ZOOM_Event event;
548  assert(a);
549  if (encode_APDU(c, a, c->odr_out))
550  return zoom_complete;
551  yaz_log(c->log_details, "%p send APDU type=%d", c, a->which);
552  c->buf_out = odr_getbuf(c->odr_out, &c->len_out, 0);
554  ZOOM_connection_put_event(c, event);
555  odr_reset(c->odr_out);
556  return ZOOM_send_buf(c);
557 }
558 
560 {
562  Z_InitRequest *ireq = apdu->u.initRequest;
564  odr_malloc(c->odr_out, sizeof(*auth));
565 
572 
576 
577  ireq->implementationId =
578  odr_prepend(c->odr_out,
579  ZOOM_options_get(c->options, "implementationId"),
580  ireq->implementationId);
581 
582  ireq->implementationName =
583  odr_prepend(c->odr_out,
584  ZOOM_options_get(c->options, "implementationName"),
585  odr_prepend(c->odr_out, "ZOOM-C",
586  ireq->implementationName));
587 
588  ireq->implementationVersion =
589  odr_prepend(c->odr_out,
590  ZOOM_options_get(c->options, "implementationVersion"),
591  ireq->implementationVersion);
592 
595 
596  if (c->group || c->password)
597  {
598  Z_IdPass *pass = (Z_IdPass *) odr_malloc(c->odr_out, sizeof(*pass));
599  pass->groupId = odr_strdup_null(c->odr_out, c->group);
600  pass->userId = odr_strdup_null(c->odr_out, c->user);
601  pass->password = odr_strdup_null(c->odr_out, c->password);
603  auth->u.idPass = pass;
604  ireq->idAuthentication = auth;
605  }
606  else if (c->user)
607  {
609  auth->u.open = odr_strdup(c->odr_out, c->user);
610  ireq->idAuthentication = auth;
611  }
612  if (c->proxy_mode)
613  {
616  }
617  if (c->charset || c->lang)
618  {
619  Z_OtherInformation **oi;
620  Z_OtherInformationUnit *oi_unit;
621 
622  yaz_oi_APDU(apdu, &oi);
623 
624  if ((oi_unit = yaz_oi_update(oi, c->odr_out, NULL, 0, 0)))
625  {
630  c->charset, c->lang, 1);
631  }
632  }
633  assert(apdu);
634  return send_APDU(c, apdu);
635 }
636 
638 {
639  ZOOM_resultset r;
640  int lslb, ssub, mspn;
641  const char *syntax;
642  const char *schema;
643  Z_APDU *apdu;
644  Z_SearchRequest *search_req;
645  const char *elementSetName;
646  const char *smallSetElementSetName;
647  const char *mediumSetElementSetName;
648 
649  assert(c->tasks);
650  assert(c->tasks->which == ZOOM_TASK_SEARCH);
651  r = c->tasks->u.search.resultset;
652 
654  search_req = apdu->u.searchRequest;
655 
656  yaz_log(c->log_details, "%p Z3950_send_search set=%p", c, r);
657 
658  elementSetName = c->tasks->u.search.elementSetName;
659  smallSetElementSetName =
660  ZOOM_options_get(r->options, "smallSetElementSetName");
661  mediumSetElementSetName =
662  ZOOM_options_get(r->options, "mediumSetElementSetName");
663 
664  if (!smallSetElementSetName)
665  smallSetElementSetName = elementSetName;
666 
667  if (!mediumSetElementSetName)
668  mediumSetElementSetName = elementSetName;
669 
670  if (r->req_facets)
671  {
672  Z_FacetList *facet_list =
674  if (facet_list)
675  {
676  Z_OtherInformation **oi = &search_req->additionalSearchInfo;
677  yaz_oi_set_facetlist(oi, c->odr_out, facet_list);
678  }
679  else
680  yaz_log(YLOG_WARN, "Unable to parse facets: %s", r->req_facets);
681  }
682 
683  assert(r);
684  assert(r->query);
685 
686  /* prepare query for the search request */
687  search_req->query = ZOOM_query_get_Z_Query(r->query);
688  if (!search_req->query)
689  {
691  return zoom_complete;
692  }
693  if (search_req->query->which == Z_Query_type_1 ||
694  search_req->query->which == Z_Query_type_101)
695  {
696  const char *cp = ZOOM_options_get(r->options, "rpnCharset");
697  if (cp)
698  {
699  yaz_iconv_t cd = yaz_iconv_open(cp, "UTF-8");
700  if (cd)
701  {
702  int r;
703  search_req->query = yaz_copy_Z_Query(search_req->query,
704  c->odr_out);
705 
707  search_req->query->u.type_1,
708  c->odr_out, cd);
709  yaz_iconv_close(cd);
710  if (r)
711  { /* query could not be char converted */
713  return zoom_complete;
714  }
715  }
716  }
717  }
718  search_req->databaseNames = r->databaseNames;
719  search_req->num_databaseNames = r->num_databaseNames;
720 
721  /* get syntax (no need to provide unless piggyback is in effect) */
722  syntax = c->tasks->u.search.syntax;
723 
724  schema = c->tasks->u.search.schema;
725 
726  lslb = ZOOM_options_get_int(r->options, "largeSetLowerBound", -1);
727  ssub = ZOOM_options_get_int(r->options, "smallSetUpperBound", -1);
728  mspn = ZOOM_options_get_int(r->options, "mediumSetPresentNumber", -1);
729  if (lslb != -1 && ssub != -1 && mspn != -1)
730  {
731  /* So're a Z39.50 expert? Let's hope you don't do sort */
732  *search_req->largeSetLowerBound = lslb;
733  *search_req->smallSetUpperBound = ssub;
734  *search_req->mediumSetPresentNumber = mspn;
735  }
736  else if (c->tasks->u.search.start == 0 && c->tasks->u.search.count > 0
737  && r->piggyback && !r->r_sort_spec && !schema)
738  {
739  /* Regular piggyback - do it unless we're going to do sort */
740  *search_req->largeSetLowerBound = 2000000000;
741  *search_req->smallSetUpperBound = 1;
742  *search_req->mediumSetPresentNumber =
743  r->step>0 ? r->step : c->tasks->u.search.count;
744  }
745  else
746  {
747  /* non-piggyback. Need not provide elementsets or syntaxes .. */
748  smallSetElementSetName = 0;
749  mediumSetElementSetName = 0;
750  syntax = 0;
751  }
752  if (smallSetElementSetName && *smallSetElementSetName)
753  {
755  odr_malloc(c->odr_out, sizeof(*esn));
756 
758  esn->u.generic = odr_strdup(c->odr_out, smallSetElementSetName);
759  search_req->smallSetElementSetNames = esn;
760  }
761  if (mediumSetElementSetName && *mediumSetElementSetName)
762  {
764  odr_malloc(c->odr_out, sizeof(*esn));
765 
767  esn->u.generic = odr_strdup(c->odr_out, mediumSetElementSetName);
768  search_req->mediumSetElementSetNames = esn;
769  }
770  if (syntax)
771  search_req->preferredRecordSyntax =
773 
774  if (!r->setname)
775  {
777  {
778  char setname[14];
779  int ord;
780  /* find the lowest unused ordinal so that we re-use
781  result sets on the server. */
782  for (ord = 1; ; ord++)
783  {
784  ZOOM_resultset rp;
785  sprintf(setname, "%d", ord);
786  for (rp = c->resultsets; rp; rp = rp->next)
787  if (rp->setname && !strcmp(rp->setname, setname))
788  break;
789  if (!rp)
790  break;
791  }
792  r->setname = odr_strdup(r->odr, setname);
793  yaz_log(c->log_details, "%p ZOOM_connection_send_search: "
794  "allocating set %s", c, r->setname);
795  }
796  else
797  {
798  yaz_log(c->log_details, "%p ZOOM_connection_send_search: using "
799  "default set", c);
800  r->setname = odr_strdup(r->odr, "default");
801  }
802  ZOOM_options_set(r->options, "setname", r->setname);
803  }
804  search_req->resultSetName = odr_strdup(c->odr_out, r->setname);
805  return send_APDU(c, apdu);
806 }
807 
809 {
810  ZOOM_scanset scan;
812  Z_ScanRequest *req = apdu->u.scanRequest;
813  Z_Query *z_query;
814 
815  yaz_log(c->log_details, "%p send_scan", c);
816  if (!c->tasks)
817  return zoom_complete;
818  assert (c->tasks->which == ZOOM_TASK_SCAN);
819  scan = c->tasks->u.scan.scan;
820 
821  z_query = ZOOM_query_get_Z_Query(scan->query);
822 
823  /* Z39.50 scan can only carry RPN */
824  if (z_query->which == Z_Query_type_1 ||
825  z_query->which == Z_Query_type_101)
826  {
827  Z_RPNQuery *rpn = z_query->u.type_1;
828  const char *cp = ZOOM_options_get(scan->options, "rpnCharset");
829  if (cp)
830  {
831  yaz_iconv_t cd = yaz_iconv_open(cp, "UTF-8");
832  if (cd)
833  {
834  rpn = yaz_copy_z_RPNQuery(rpn, c->odr_out);
835 
837  rpn, c->odr_out, cd);
838  yaz_iconv_close(cd);
839  }
840  }
841  req->attributeSet = rpn->attributeSetId;
842  if (!req->attributeSet)
846  {
847  req->termListAndStartPoint =
849  }
850  else
851  {
853  return zoom_complete;
854  }
855  }
856  else
857  {
859  return zoom_complete;
860  }
861 
862  *req->numberOfTermsRequested =
863  ZOOM_options_get_int(scan->options, "number", 20);
864 
866  odr_intdup(c->odr_out,
867  ZOOM_options_get_int(scan->options, "position", 1));
868 
869  req->stepSize =
870  odr_intdup(c->odr_out,
871  ZOOM_options_get_int(scan->options, "stepSize", 0));
872 
873  req->databaseNames = scan->databaseNames;
875 
876  return send_APDU(c, apdu);
877 }
878 
879 ZOOM_API(void)
881 {
882  Z_APDU *apdu = 0;
883  ZOOM_connection c;
884  if (!p)
885  return;
886  c = p->connection;
887  odr_reset(p->odr_out);
888  xfree(p->buf_out);
889  p->buf_out = 0;
890  if (!strcmp(type, "itemorder"))
891  {
893  if (apdu)
894  {
895  Z_External *r = (Z_External *) odr_malloc(p->odr_out, sizeof(*r));
896 
897  r->direct_reference =
899  r->descriptor = 0;
901  r->indirect_reference = 0;
902  r->u.itemOrder = encode_item_order(p);
903 
905  }
906  }
907  else if (!strcmp(type, "create")) /* create database */
908  {
910  0, 0);
911  }
912  else if (!strcmp(type, "drop")) /* drop database */
913  {
915  0, 0);
916  }
917  else if (!strcmp(type, "commit")) /* commit changes */
918  {
920  0, 0);
921  }
922  else if (!strcmp(type, "update")) /* update record(s) */
923  {
924  apdu = create_update_package(p);
925  }
926  else if (!strcmp(type, "xmlupdate"))
927  {
928  apdu = create_xmlupdate_package(p);
929  }
930  if (apdu)
931  {
932  if (encode_APDU(p->connection, apdu, p->odr_out) == 0)
933  {
934  char *buf;
935 
937  task->u.package = p;
938  buf = odr_getbuf(p->odr_out, &p->len_out, 0);
939  p->buf_out = (char *) xmalloc(p->len_out);
940  memcpy(p->buf_out, buf, p->len_out);
941 
942  (p->refcount)++;
943  if (!c->async)
944  {
945  while (ZOOM_event(1, &c))
946  ;
947  }
948  }
949  }
950 }
951 
953  int present_phase);
954 
956 {
957  char oid_name_buf[OID_STR_MAX];
958  const char *oid_name;
959  char *addinfo = 0;
960 
961  oid_name = yaz_oid_to_string_buf(r->diagnosticSetId, 0, oid_name_buf);
962  switch (r->which)
963  {
965  addinfo = r->u.v2Addinfo;
966  break;
968  addinfo = r->u.v3Addinfo;
969  break;
970  }
971  xfree(c->addinfo);
972  c->addinfo = 0;
973  ZOOM_set_dset_error(c, *r->condition, oid_name, addinfo, 0);
974 }
975 
977 {
978  if (p->which != Z_DiagRec_defaultFormat)
980  else
982 }
983 
986 {
987  if (utp && utp->targetPart)
988  {
989  Z_IUTargetPart *targetPart = utp->targetPart;
990  switch (*targetPart->updateStatus)
991  {
994  "updateStatus", "success");
995  break;
998  "updateStatus", "partial");
999  break;
1002  "updateStatus", "failure");
1003  if (targetPart->globalDiagnostics &&
1004  targetPart->num_globalDiagnostics > 0)
1005  response_diag(c, targetPart->globalDiagnostics[0]);
1006  break;
1007  }
1008  /* NOTE: Individual record status, surrogate diagnostics, and supplemental diagnostics ARE NOT REPORTED. */
1009  }
1010  return 1;
1011 }
1012 
1014  Z_TaskPackage *taskPackage)
1015 {
1016  Odr_oct *id = taskPackage->targetReference;
1017  if (id)
1019  "targetReference", (char*) id->buf, id->len);
1020  switch (*taskPackage->taskStatus)
1021  {
1022  case Z_TaskPackage_pending:
1023  ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "pending");
1024  break;
1025  case Z_TaskPackage_active:
1026  ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "active");
1027  break;
1029  ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "complete");
1030  break;
1031  case Z_TaskPackage_aborted:
1032  ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "aborted");
1033  if (taskPackage->num_packageDiagnostics &&
1034  taskPackage->packageDiagnostics )
1035  response_diag(c, taskPackage->packageDiagnostics[0]);
1036  break;
1037  }
1038  /* NOTE: Only Update implemented, no others. */
1039  if (taskPackage->taskSpecificParameters->which == Z_External_update)
1040  {
1041  Z_IUUpdateTaskPackage *utp =
1042  taskPackage->taskSpecificParameters->u.update->u.taskPackage;
1044  }
1045  return 1;
1046 }
1047 
1050 {
1051  if (!c->tasks)
1052  return;
1053  assert(c->tasks->which == ZOOM_TASK_PACKAGE);
1054  switch (*res->operationStatus)
1055  {
1057  ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "done");
1058  break;
1060  ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "accepted");
1061  break;
1063  ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "failure");
1064  if (res->diagnostics && res->num_diagnostics > 0)
1065  response_diag(c, res->diagnostics[0]);
1066  break;
1067  }
1068  if (res->taskPackage &&
1070  {
1071  Z_TaskPackage *taskPackage = res->taskPackage->u.extendedService;
1072  es_response_taskpackage(c, taskPackage);
1073  }
1074  if (res->taskPackage &&
1076  {
1077  Odr_oct *doc = res->taskPackage->u.octet_aligned;
1079  "xmlUpdateDoc", (char*) doc->buf, doc->len);
1080  }
1081 }
1082 
1083 static char *get_term_cstr(ODR odr, Z_Term *term)
1084 {
1085  switch (term->which)
1086  {
1087  case Z_Term_general:
1088  return odr_strdupn(odr, term->u.general->buf, term->u.general->len);
1089  break;
1091  return odr_strdup(odr, term->u.characterString);
1092  }
1093  return 0;
1094 }
1095 
1097 {
1098  int i;
1099  struct yaz_facet_attr attr_values;
1100  ZOOM_facet_field facet_field = odr_malloc(odr, sizeof(*facet_field));
1101  yaz_facet_attr_init(&attr_values);
1102  yaz_facet_attr_get_z_attributes(facet->attributes, &attr_values);
1103  facet_field->facet_name = odr_strdup(odr, attr_values.useattr);
1104  facet_field->num_terms = facet->num_terms;
1105  yaz_log(YLOG_DEBUG, "ZOOM_facet_field %s %d terms %d",
1106  attr_values.useattr, attr_values.limit, facet->num_terms);
1107  facet_field->facet_terms =
1108  odr_malloc(odr, facet->num_terms * sizeof(*facet_field->facet_terms));
1109  for (i = 0 ; i < facet->num_terms; i++)
1110  {
1111  Z_FacetTerm *facetTerm = facet->terms[i];
1112  facet_field->facet_terms[i].frequency = *facetTerm->count;
1113  facet_field->facet_terms[i].term = get_term_cstr(odr, facetTerm->term);
1114  yaz_log(YLOG_DEBUG, " term[%d] %s %d",
1115  i, facet_field->facet_terms[i].term,
1116  facet_field->facet_terms[i].frequency);
1117  }
1118  return facet_field;
1119 }
1120 
1121 /* Can be share with SOLR/SRU/SRW requests */
1123 {
1124  int j;
1125  r->num_res_facets = fl->num;
1126  yaz_log(YLOG_DEBUG, "Facets found: %d", fl->num);
1127  r->res_facets = odr_malloc(r->odr, fl->num * sizeof(*r->res_facets));
1128  r->facets_names = odr_malloc(r->odr, fl->num * sizeof(*r->facets_names));
1129  for (j = 0; j < fl->num; j++)
1130  {
1131  r->res_facets[j] = get_zoom_facet_field(r->odr, fl->elements[j]);
1132  if (!r->res_facets[j])
1133  {
1134  r->facets_names[j] = 0;
1135  yaz_log(YLOG_DEBUG, "Facet field missing on index %d !", j);
1136  }
1137  else
1138  r->facets_names[j] = (char *)
1140  }
1141 }
1142 
1144  Z_OtherInformation *o)
1145 {
1146  int i;
1147  for (i = 0; o && i < o->num_elements; i++)
1148  {
1150  {
1152  if (ext->which == Z_External_userFacets)
1153  {
1155  }
1156  }
1157  }
1158 }
1159 
1161  Z_Term *term)
1162 {
1163  switch (term->which)
1164  {
1165  case Z_Term_general:
1166  ZOOM_options_setl(opt, name,
1167  term->u.general->buf, term->u.general->len);
1168  break;
1170  ZOOM_options_set(opt, name, term->u.characterString);
1171  break;
1172  case Z_Term_numeric:
1173  ZOOM_options_set_int(opt, name, *term->u.numeric);
1174  break;
1175  }
1176 }
1177 
1178 static void handle_queryExpression(ZOOM_options opt, const char *name,
1179  Z_QueryExpression *exp)
1180 {
1181  char opt_name[80];
1182 
1183  switch (exp->which)
1184  {
1186  if (exp->u.term && exp->u.term->queryTerm)
1187  {
1188  sprintf(opt_name, "%s.term", name);
1189  handle_queryExpressionTerm(opt, opt_name, exp->u.term->queryTerm);
1190  }
1191  break;
1193  break;
1194  }
1195 }
1196 
1197 
1199  Z_OtherInformation *o)
1200 {
1201  int i;
1202  for (i = 0; o && i < o->num_elements; i++)
1203  {
1205  {
1207 
1208  if (ext->which == Z_External_searchResult1)
1209  {
1210  int j;
1211  Z_SearchInfoReport *sr = ext->u.searchResult1;
1212 
1213  if (sr->num)
1215  resultset->options, "searchresult.size", sr->num);
1216 
1217  for (j = 0; j < sr->num; j++)
1218  {
1219  Z_SearchInfoReport_s *ent =
1220  ext->u.searchResult1->elements[j];
1221  char pref[80];
1222 
1223  sprintf(pref, "searchresult.%d", j);
1224 
1225  if (ent->subqueryId)
1226  {
1227  char opt_name[80];
1228  sprintf(opt_name, "%s.id", pref);
1229  ZOOM_options_set(resultset->options, opt_name,
1230  ent->subqueryId);
1231  }
1232  if (ent->subqueryExpression)
1233  {
1234  char opt_name[80];
1235  sprintf(opt_name, "%s.subquery", pref);
1236  handle_queryExpression(resultset->options, opt_name,
1237  ent->subqueryExpression);
1238  }
1239  if (ent->subqueryInterpretation)
1240  {
1241  char opt_name[80];
1242  sprintf(opt_name, "%s.interpretation", pref);
1243  handle_queryExpression(resultset->options, opt_name,
1244  ent->subqueryInterpretation);
1245  }
1246  if (ent->subqueryRecommendation)
1247  {
1248  char opt_name[80];
1249  sprintf(opt_name, "%s.recommendation", pref);
1250  handle_queryExpression(resultset->options, opt_name,
1251  ent->subqueryRecommendation);
1252  }
1253  if (ent->subqueryCount)
1254  {
1255  char opt_name[80];
1256  sprintf(opt_name, "%s.count", pref);
1257  ZOOM_options_set_int(resultset->options, opt_name,
1258  *ent->subqueryCount);
1259  }
1260  }
1261  }
1262  }
1263  }
1264 }
1265 
1267  Z_SearchResponse *sr)
1268 {
1269  ZOOM_resultset resultset;
1270  ZOOM_Event event;
1271  const char *resultCountPrecision = "exact";
1272 
1273  if (!c->tasks || c->tasks->which != ZOOM_TASK_SEARCH)
1274  return;
1275 
1276  resultset = c->tasks->u.search.resultset;
1277 
1278  if (resultset->live_set == 0)
1279  {
1281  ZOOM_connection_put_event(c, event);
1282  }
1283  if (sr->resultSetStatus)
1284  {
1286  resultCountPrecision = "estimate";
1287  ZOOM_options_set_int(resultset->options, "resultSetStatus",
1288  *sr->resultSetStatus);
1289  }
1290  if (sr->presentStatus)
1291  {
1292  ZOOM_options_set_int(resultset->options, "presentStatus",
1293  *sr->presentStatus);
1294  }
1295  ZOOM_options_set(resultset->options, "resultCountPrecision",
1296  resultCountPrecision);
1298 
1300 
1301  resultset->size = *sr->resultCount;
1302 
1304  resultCountPrecision);
1305  resultset->live_set = 2;
1306  handle_Z3950_records(c, sr->records, 0);
1307 }
1308 
1310 {
1311  if (res->diagnostics && res->num_diagnostics > 0)
1312  {
1313  response_diag(c, res->diagnostics[0]);
1315  }
1316 }
1317 
1319 {
1320  NMEM nmem = odr_extract_mem(c->odr_in);
1321  ZOOM_scanset scan;
1322 
1323  if (!c->tasks || c->tasks->which != ZOOM_TASK_SCAN)
1324  return;
1325  scan = c->tasks->u.scan.scan;
1326 
1327  if (res->entries && res->entries->nonsurrogateDiagnostics)
1329  scan->scan_response = res;
1330  scan->srw_scan_response = 0;
1331  nmem_transfer(odr_getmem(scan->odr), nmem);
1332  if (res->stepSize)
1333  ZOOM_options_set_int(scan->options, "stepSize", *res->stepSize);
1334  if (res->positionOfTerm)
1335  ZOOM_options_set_int(scan->options, "position", *res->positionOfTerm);
1336  if (res->scanStatus)
1337  ZOOM_options_set_int(scan->options, "scanStatus", *res->scanStatus);
1338  if (res->numberOfEntriesReturned)
1339  ZOOM_options_set_int(scan->options, "number",
1340  *res->numberOfEntriesReturned);
1341  nmem_destroy(nmem);
1342 }
1343 
1345  int present_phase)
1346 {
1347  ZOOM_resultset resultset;
1348  int *start, *count;
1349  const char *syntax = 0, *elementSetName = 0, *schema = 0;
1350 
1351  if (!c->tasks || c->tasks->which != ZOOM_TASK_SEARCH)
1352  return ;
1353 
1354  resultset = c->tasks->u.search.resultset;
1355  start = &c->tasks->u.search.start;
1356  count = &c->tasks->u.search.count;
1357  syntax = c->tasks->u.search.syntax;
1358  elementSetName = c->tasks->u.search.elementSetName;
1359  schema = c->tasks->u.search.schema;
1360 
1361  if (sr && sr->which == Z_Records_NSD)
1362  {
1365  }
1366  else if (sr && sr->which == Z_Records_multipleNSD)
1367  {
1370  else
1373  }
1374  else
1375  {
1376  if (*count + *start > resultset->size)
1377  *count = resultset->size - *start;
1378  if (*count < 0)
1379  *count = 0;
1380  if (sr && sr->which == Z_Records_DBOSD)
1381  {
1382  int i;
1383  NMEM nmem = odr_extract_mem(c->odr_in);
1386  for (i = 0; i < p->num_records; i++)
1387  {
1388  ZOOM_record_cache_add(resultset, p->records[i], i + *start,
1389  syntax, elementSetName, schema, 0);
1390  }
1391  *count -= i;
1392  if (*count < 0)
1393  *count = 0;
1394  *start += i;
1395  yaz_log(c->log_details,
1396  "handle_records resultset=%p start=%d count=%d",
1397  resultset, *start, *count);
1398 
1399  /* transfer our response to search_nmem .. we need it later */
1400  nmem_transfer(odr_getmem(resultset->odr), nmem);
1401  nmem_destroy(nmem);
1402  if (present_phase && p->num_records == 0)
1403  {
1404  /* present response and we didn't get any records! */
1405  Z_NamePlusRecord *myrec =
1407  resultset->odr, 0,
1409  "ZOOM C generated. Present phase and no records");
1410  ZOOM_record_cache_add(resultset, myrec, *start,
1411  syntax, elementSetName, schema, 0);
1412  *count = 0;
1413  }
1414  }
1415  else if (present_phase)
1416  {
1417  /* present response and we didn't get any records! */
1418  Z_NamePlusRecord *myrec =
1420  resultset->odr, 0,
1422  "ZOOM C generated: Present response and no records");
1423  ZOOM_record_cache_add(resultset, myrec, *start,
1424  syntax, elementSetName, schema, 0);
1425  *count = 0;
1426  }
1427  }
1428 }
1429 
1431  Z_PresentResponse *pr)
1432 {
1433  handle_Z3950_records(c, pr->records, 1);
1434 }
1435 
1436 static void set_init_option(const char *name, void *clientData)
1437 {
1438  ZOOM_connection c = (ZOOM_connection) clientData;
1439  char buf[80];
1440 
1441  sprintf(buf, "init_opt_%.70s", name);
1442  ZOOM_connection_option_set(c, buf, "1");
1443 }
1444 
1446 {
1447  if (c->error)
1448  resultset->r_sort_spec = 0;
1449  if (resultset->r_sort_spec)
1450  {
1452  Z_SortRequest *req = apdu->u.sortRequest;
1453 
1454  yaz_log(c->log_details, "%p send_Z3950_sort set=%p", c, resultset);
1455 
1456  req->num_inputResultSetNames = 1;
1458  odr_malloc(c->odr_out, sizeof(*req->inputResultSetNames));
1459  req->inputResultSetNames[0] =
1460  odr_strdup(c->odr_out, resultset->setname);
1461  req->sortedResultSetName = odr_strdup(c->odr_out, resultset->setname);
1462  req->sortSequence = resultset->r_sort_spec;
1463  resultset->r_sort_spec = 0;
1464  return send_APDU(c, apdu);
1465  }
1466  return zoom_complete;
1467 }
1468 
1470 {
1472  Z_PresentRequest *req = apdu->u.presentRequest;
1473  ZOOM_resultset resultset = c->tasks->u.search.resultset;
1474  const char *syntax = c->tasks->u.search.syntax;
1475  const char *elementSetName = c->tasks->u.search.elementSetName;
1476  const char *schema = c->tasks->u.search.schema;
1477 
1478  yaz_log(c->log_details, "%p Z3950_send_present", c);
1479 
1480  *req->resultSetStartPoint = c->tasks->u.search.start + 1;
1481 
1482  if (resultset->step > 0 && resultset->step < c->tasks->u.search.count)
1483  *req->numberOfRecordsRequested = resultset->step;
1484  else
1485  *req->numberOfRecordsRequested = c->tasks->u.search.count;
1486 
1487  if (*req->numberOfRecordsRequested + c->tasks->u.search.start > resultset->size)
1488  *req->numberOfRecordsRequested = resultset->size - c->tasks->u.search.start;
1489  assert(*req->numberOfRecordsRequested > 0);
1490 
1491  if (syntax && *syntax)
1492  req->preferredRecordSyntax =
1494 
1495  if (schema && *schema)
1496  {
1498  odr_malloc(c->odr_out, sizeof(*compo));
1499 
1500  req->recordComposition = compo;
1501  compo->which = Z_RecordComp_complex;
1502  compo->u.complex = (Z_CompSpec *)
1503  odr_malloc(c->odr_out, sizeof(*compo->u.complex));
1504  compo->u.complex->selectAlternativeSyntax = (bool_t *)
1505  odr_malloc(c->odr_out, sizeof(bool_t));
1506  *compo->u.complex->selectAlternativeSyntax = 0;
1507 
1508  compo->u.complex->generic = (Z_Specification *)
1509  odr_malloc(c->odr_out, sizeof(*compo->u.complex->generic));
1510 
1511  compo->u.complex->generic->which = Z_Schema_oid;
1512  compo->u.complex->generic->schema.oid = (Odr_oid *)
1514 
1515  if (!compo->u.complex->generic->schema.oid)
1516  {
1517  /* OID wasn't a schema! Try record syntax instead. */
1518 
1519  compo->u.complex->generic->schema.oid = (Odr_oid *)
1521  }
1522  if (elementSetName && *elementSetName)
1523  {
1524  compo->u.complex->generic->elementSpec = (Z_ElementSpec *)
1525  odr_malloc(c->odr_out, sizeof(Z_ElementSpec));
1526  compo->u.complex->generic->elementSpec->which =
1529  odr_strdup(c->odr_out, elementSetName);
1530  }
1531  else
1532  compo->u.complex->generic->elementSpec = 0;
1533  compo->u.complex->num_dbSpecific = 0;
1534  compo->u.complex->dbSpecific = 0;
1535  compo->u.complex->num_recordSyntax = 0;
1536  compo->u.complex->recordSyntax = 0;
1537  }
1538  else if (elementSetName && *elementSetName)
1539  {
1541  odr_malloc(c->odr_out, sizeof(*esn));
1543  odr_malloc(c->odr_out, sizeof(*compo));
1544 
1546  esn->u.generic = odr_strdup(c->odr_out, elementSetName);
1547  compo->which = Z_RecordComp_simple;
1548  compo->u.simple = esn;
1549  req->recordComposition = compo;
1550  }
1551  req->resultSetId = odr_strdup(c->odr_out, resultset->setname);
1552  return send_APDU(c, apdu);
1553 }
1554 
1556 {
1557  int i = 0;
1558  const char *syntax = 0;
1559  const char *elementSetName = 0;
1560  const char *schema = 0;
1561  ZOOM_resultset resultset;
1562  int *start, *count;
1563 
1564  if (!c->tasks || c->tasks->which == ZOOM_TASK_SORT)
1565  return zoom_complete;
1566  assert(c->tasks->which == ZOOM_TASK_SEARCH);
1567  resultset = c->tasks->u.search.resultset;
1568  start = &c->tasks->u.search.start;
1569  count = &c->tasks->u.search.count;
1570  syntax = c->tasks->u.search.syntax;
1571  elementSetName = c->tasks->u.search.elementSetName;
1572  schema = c->tasks->u.search.schema;
1573 
1574  yaz_log(c->log_details, "%p ZOOM_connection_Z3950_search start=%d count=%d",
1575  c, *start, *count);
1576 
1577  ZOOM_memcached_search(c, resultset);
1578 
1579  if (*start < 0 || *count < 0)
1580  {
1582  "start/count < 0", 0);
1583  }
1584 
1585  if (resultset->live_set)
1586  {
1587  if (*start >= resultset->size)
1588  *count = 0;
1589  else if (*start + *count >= resultset->size)
1590  *count = resultset->size - *start;
1591  }
1592 
1593  if (c->error) /* don't continue on error */
1594  return zoom_complete;
1595 
1596  for (i = 0; i < *count; i++)
1597  {
1598  ZOOM_record rec =
1599  ZOOM_record_cache_lookup(resultset, i + *start,
1600  syntax, elementSetName, schema);
1601  if (!rec)
1602  break;
1603  }
1604  *start += i;
1605  *count -= i;
1606 
1607  if (*count == 0 && resultset->live_set)
1608  return zoom_complete;
1609 
1610  if (resultset->live_set == 2)
1611  return Z3950_send_present(c);
1612  else
1613  return Z3950_send_search(c);
1614 }
1615 
1617 {
1618  zoom_ret r = zoom_complete;
1619 
1620  if (c->tasks && c->tasks->which == ZOOM_TASK_SEARCH)
1621  r = send_Z3950_sort(c, c->tasks->u.search.resultset);
1622  if (r == zoom_complete)
1624  return r;
1625 }
1626 
1628 {
1629  Z_InitResponse *initrs;
1630 
1632  yaz_log(c->log_details, "%p handle_Z3950_apdu apdu->which=%d",
1633  c, apdu->which);
1634  switch (apdu->which)
1635  {
1636  case Z_APDU_initResponse:
1637  yaz_log(c->log_api, "%p handle_Z3950_apdu: Received Init response", c);
1638  initrs = apdu->u.initResponse;
1639  ZOOM_connection_option_set(c, "serverImplementationId",
1640  initrs->implementationId ?
1641  initrs->implementationId : "");
1642  ZOOM_connection_option_set(c, "serverImplementationName",
1643  initrs->implementationName ?
1644  initrs->implementationName : "");
1645  ZOOM_connection_option_set(c, "serverImplementationVersion",
1646  initrs->implementationVersion ?
1647  initrs->implementationVersion : "");
1648  /* Set the three old options too, for old applications */
1649  ZOOM_connection_option_set(c, "targetImplementationId",
1650  initrs->implementationId ?
1651  initrs->implementationId : "");
1652  ZOOM_connection_option_set(c, "targetImplementationName",
1653  initrs->implementationName ?
1654  initrs->implementationName : "");
1655  ZOOM_connection_option_set(c, "targetImplementationVersion",
1656  initrs->implementationVersion ?
1657  initrs->implementationVersion : "");
1658 
1659  /* Make initrs->options available as ZOOM-level options */
1660  yaz_init_opt_decode(initrs->options, set_init_option, (void*) c);
1661 
1662  if (!*initrs->result)
1663  {
1664  Z_DefaultDiagFormat *df = yaz_decode_init_diag(0, initrs);
1665  if (df)
1666  response_default_diag(c, df);
1667  else
1668  ZOOM_set_error(c, ZOOM_ERROR_INIT, 0); /* default error */
1669  }
1670  else
1671  {
1672  char *cookie =
1674  yaz_oid_userinfo_cookie, 1, 0);
1675  xfree(c->cookie_in);
1676  c->cookie_in = 0;
1677  if (cookie)
1678  c->cookie_in = xstrdup(cookie);
1681  c->support_named_resultsets = 1;
1682  if (c->tasks)
1683  {
1684  assert(c->tasks->which == ZOOM_TASK_CONNECT);
1686  }
1688  }
1690  {
1691  NMEM tmpmem = nmem_create();
1694 
1695  if (p)
1696  {
1697  char *charset = NULL, *lang = NULL;
1698  int sel;
1699 
1700  yaz_get_response_charneg(tmpmem, p, &charset, &lang, &sel);
1701  yaz_log(c->log_details, "%p handle_Z3950_apdu target accepted: "
1702  "charset %s, language %s, select %d",
1703  c,
1704  charset ? charset : "none", lang ? lang : "none", sel);
1705  if (charset)
1706  ZOOM_connection_option_set(c, "negotiation-charset",
1707  charset);
1708  if (lang)
1709  ZOOM_connection_option_set(c, "negotiation-lang",
1710  lang);
1711 
1713  c, "negotiation-charset-in-effect-for-records",
1714  (sel != 0) ? "1" : "0");
1715  nmem_destroy(tmpmem);
1716  }
1717  }
1718  break;
1719  case Z_APDU_searchResponse:
1720  yaz_log(c->log_api, "%p handle_Z3950_apdu Search response", c);
1724  break;
1726  yaz_log(c->log_api, "%p handle_Z3950_apdu Present response", c);
1730  break;
1731  case Z_APDU_sortResponse:
1732  yaz_log(c->log_api, "%p handle_Z3950_apdu Sort response", c);
1736  break;
1737  case Z_APDU_scanResponse:
1738  yaz_log(c->log_api, "%p handle_Z3950_apdu Scan response", c);
1741  break;
1743  yaz_log(c->log_api, "%p handle_Z3950_apdu Extended Services response", c);
1746  break;
1747  case Z_APDU_close:
1748  yaz_log(c->log_api, "%p handle_Z3950_apdu Close PDU", c);
1749  if (!ZOOM_test_reconnect(c))
1750  {
1753  }
1754  break;
1755  default:
1756  yaz_log(c->log_api, "%p Received unknown PDU", c);
1759  }
1760 }
1761 
1762 /*
1763  * Local variables:
1764  * c-basic-offset: 4
1765  * c-file-style: "Stroustrup"
1766  * indent-tabs-mode: nil
1767  * End:
1768  * vim: shiftwidth=4 tabstop=8 expandtab
1769  */
1770 
Z_Operand * simple
Definition: z-core.h:502
#define Z_APDU_scanResponse
Definition: z-core.h:365
static void handle_queryExpression(ZOOM_options opt, const char *name, Z_QueryExpression *exp)
Definition: zoom-z3950.c:1178
ZOOM_options_get_int(ZOOM_options opt, const char *name, int defa)
Definition: zoom-opt.c:235
union Z_Records::@56 u
Odr_int * resultCount
Definition: z-core.h:625
Z_AttributesPlusTerm * termListAndStartPoint
Definition: z-core.h:949
#define Z_ExtendedServicesResponse_failure
Definition: z-core.h:1145
Odr_int * condition
Definition: z-core.h:743
Shared pointer macros.
union Z_ElementSetNames::@61 u
int num_globalDiagnostics
Definition: zes-update.h:97
char Z_InternationalString
Definition: z-core.h:301
MARC conversion.
int which
Definition: z-core.h:510
char * buf
Definition: odr.h:101
ZOOM_resultset resultsets
Definition: zoom-p.h:108
#define Z_APDU_searchResponse
Definition: z-core.h:352
ZOOM_connection_close(ZOOM_connection c)
#define ODR_MASK_GET(mask, num)
Definition: odr.h:211
Odr_oid ** recordSyntax
Definition: z-core.h:796
ZOOM_options options
Definition: zoom-p.h:174
#define Z_SearchResponse_estimate
Definition: z-core.h:632
Odr_int * resultSetStatus
Definition: z-core.h:633
int num_diagRecs
Definition: z-core.h:688
Z_IUOriginPartToKeep * toKeep
Definition: zes-update.h:58
Z_InternationalString * groupId
Definition: z-core.h:392
#define Z_DefaultDiagFormat_v3Addinfo
Definition: z-core.h:749
struct ZOOM_connection_p * ZOOM_connection
Definition: zoom.h:52
Z_AttributeList * attributes
Definition: z-facet-1.h:36
Z_InternationalString * subqueryId
Definition: z-uifr1.h:43
Z_ItemOrder * itemOrder
Definition: prt-ext.h:118
static void handle_Z3950_present_response(ZOOM_connection c, Z_PresentResponse *pr)
Definition: zoom-z3950.c:1430
Z_Query * ZOOM_query_get_Z_Query(ZOOM_query s)
Definition: zoom-query.c:129
#define YLOG_DEBUG
log level: debugging
Definition: log.h:44
#define Z_Schema_oid
Definition: z-core.h:814
void yaz_facet_attr_get_z_attributes(const Z_AttributeList *attributes, struct yaz_facet_attr *av)
Definition: facet.c:147
Odr_int * stepSize
Definition: z-core.h:950
Z_InternationalString * elementSetName
Definition: zes-update.h:86
ZOOM_query query
Definition: zoom-p.h:135
#define Z_Term_general
Definition: z-core.h:547
Z_IUUpdateTaskPackage * taskPackage
Definition: zes-update.h:71
Z_ElementSetNames * smallSetElementSetNames
Definition: z-core.h:460
static zoom_ret Z3950_send_search(ZOOM_connection c)
Definition: zoom-z3950.c:637
Z_InternationalString * implementationName
Definition: z-core.h:419
int num_diagnostics
Definition: z-core.h:1055
int num_databaseNames
Definition: zoom-p.h:146
#define ODR_PRINT
Definition: odr.h:97
#define Z_IUOriginPartToKeep_recordInsert
Definition: zes-update.h:78
#define ZOOM_TASK_PACKAGE
Definition: zoom-p.h:211
#define Z_IUOriginPartToKeep_elementUpdate
Definition: zes-update.h:81
union Z_ESAdminOriginPartNotToKeep::@112 u
Z_ScanResponse * scan_response
Definition: zoom-p.h:177
#define Z_IUTargetPart_partial
Definition: zes-update.h:94
char * odr_strdup(ODR o, const char *str)
Definition: odr_mem.c:36
Z_InternationalString * implementationVersion
Definition: z-core.h:386
#define Z_IUUpdate_esRequest
Definition: zes-update.h:72
static zoom_ret send_Z3950_sort_present(ZOOM_connection c)
Definition: zoom-z3950.c:1616
Header for errno utilities.
#define Z_ExtendedServicesRequest_delete
Definition: z-core.h:1122
Z_InternationalString * resultSetName
Definition: z-core.h:457
#define ZOOM_TASK_CONNECT
Definition: zoom-p.h:206
Odr_oid * preferredRecordSyntax
Definition: z-core.h:658
ZOOM_options_getl(ZOOM_options opt, const char *name, int *lenp)
Definition: zoom-opt.c:186
Z_QueryExpression * subqueryRecommendation
Definition: z-uifr1.h:47
Z_InternationalString * note
Definition: zes-update.h:136
#define Z_ExtendedServicesRequest_dontWait
Definition: z-core.h:1134
#define Z_APDU_searchRequest
Definition: z-core.h:351
#define Z_Query_type_1
Definition: z-core.h:479
static int es_response_taskpackage(ZOOM_connection c, Z_TaskPackage *taskPackage)
Definition: zoom-z3950.c:1013
struct ZOOM_task_p::@6::@7 search
Z_InternationalString * generic
Definition: z-core.h:771
int num_inputResultSetNames
Definition: z-core.h:1037
int yaz_query_charset_convert_rpnquery_check(Z_RPNQuery *q, ODR o, yaz_iconv_t cd)
Definition: query-charset.c:96
char * odr_getbuf(ODR o, int *len, int *size)
Definition: odr.c:277
Z_Records * records
Definition: z-core.h:678
int start
Definition: facet.h:62
#define ZOOM_ERROR_DECODE
Definition: zoom.h:131
Z_Query * query
Definition: z-core.h:463
ZOOM_options options
Definition: zoom-p.h:107
void ZOOM_memcached_hitcount(ZOOM_connection c, ZOOM_resultset resultset, Z_OtherInformation *oi, const char *precision)
void ZOOM_set_dset_error(ZOOM_connection c, int error, const char *dset, const char *addinfo, const char *addinfo2)
Definition: zoom-c.c:54
Internal header for ZOOM implementation.
#define Z_DiagRec_defaultFormat
Definition: z-core.h:736
void nmem_destroy(NMEM n)
destroys NMEM handle and memory associated with it
Definition: nmem.c:204
const char * yaz_oid_to_string_buf(const Odr_oid *oid, oid_class *oclass, char *buf)
maps any OID to string (named or dot-notation)
Definition: oid_db.c:99
Z_PresentRequest * presentRequest
Definition: z-core.h:328
int num_res_facets
Definition: zoom-p.h:154
Odr_oid * direct_reference
Definition: prt-ext.h:60
Odr_int * item
Definition: zes-order.h:113
Z_ProtocolVersion * protocolVersion
Definition: z-core.h:413
Z_Records * records
Definition: z-core.h:635
#define Z_DefaultDiagFormat_v2Addinfo
Definition: z-core.h:748
int which
Definition: z-core.h:322
#define Z_ElementSetNames_generic
Definition: z-core.h:773
int support_named_resultsets
Definition: zoom-p.h:100
ZOOM_record ZOOM_record_cache_lookup(ZOOM_resultset r, int pos, const char *syntax, const char *elementSetName, const char *schema)
ILL Package utilities.
Z_NamePlusRecord ** records
Definition: z-core.h:684
yaz_iconv_t yaz_iconv_open(const char *tocode, const char *fromcode)
just like iconv_open(3)
Definition: siconv.c:95
static zoom_ret send_APDU(ZOOM_connection c, Z_APDU *a)
Definition: zoom-z3950.c:545
Z_OtherInformation * otherInfo
Definition: z-core.h:388
#define Z_Options_present
Definition: z-core.h:430
void yaz_get_response_charneg(NMEM mem, Z_CharSetandLanguageNegotiation *p, char **charset, char **lang, int *selected)
Definition: charneg.c:387
char * name
Definition: initopt.c:18
Odr_int * mediumSetPresentNumber
Definition: z-core.h:455
static Z_ItemOrder * encode_item_order(ZOOM_package p)
Definition: zoom-z3950.c:135
union Z_IUSuppliedRecords_elem::@129 u
zoom_ret ZOOM_connection_Z3950_send_init(ZOOM_connection c)
Definition: zoom-z3950.c:559
Z_QueryExpressionTerm * term
Definition: z-uifr1.h:88
Header for PQF parsing.
Z_Admin * adminService
Definition: prt-ext.h:128
#define Z_ESAdminOriginPartToKeep_create
Definition: zes-admin.h:77
Z_SearchInfoReport_s ** elements
Definition: z-uifr1.h:55
Header for common YAZ utilities.
Z_InternationalString * email
Definition: zes-order.h:74
#define Z_External_searchResult1
Definition: prt-ext.h:81
Z_Close * close
Definition: z-core.h:346
#define Z_ExtendedServicesRequest_waitIfPossible
Definition: z-core.h:1133
Copies various Z39.50 types.
Z_InitRequest * initRequest
Definition: z-core.h:324
Z_RPNStructure * RPNStructure
Definition: z-core.h:490
Z_ExtendedServicesResponse * extendedServicesResponse
Definition: z-core.h:345
void yaz_oi_APDU(Z_APDU *apdu, Z_OtherInformation ***oip)
Definition: otherinfo.c:18
Z_OtherInformation * otherInfo
Definition: z-core.h:422
ZOOM_task ZOOM_connection_add_task(ZOOM_connection c, int which)
Definition: zoom-c.c:153
#define Z_APDU_initResponse
Definition: z-core.h:350
ZOOM_package_send(ZOOM_package p, const char *type)
Definition: zoom-z3950.c:880
const Odr_oid yaz_oid_extserv_item_order[]
Definition: oid_std.c:101
zoom_ret ZOOM_connection_Z3950_search(ZOOM_connection c)
Definition: zoom-z3950.c:1555
Odr_int * numberOfTermsRequested
Definition: z-core.h:951
Z_OtherInformation * additionalSearchInfo
Definition: z-core.h:636
#define xstrdup(s)
utility macro which calls xstrdup_f
Definition: xmalloc.h:55
static Z_APDU * create_xmlupdate_package(ZOOM_package p)
Definition: zoom-z3950.c:254
short Odr_oid
Definition: oid_util.h:42
#define ZOOM_ERROR_INIT
Definition: zoom.h:133
void ZOOM_connection_remove_tasks(ZOOM_connection c)
Definition: zoom-c.c:223
const Odr_oid yaz_oid_extserv_database_update[]
Definition: oid_std.c:104
void odr_setprint(ODR o, FILE *file)
Definition: odr.c:164
#define Z_Query_type_101
Definition: z-core.h:482
union Z_Specification::@63 schema
#define Z_IUOriginPartToKeep_recordReplace
Definition: zes-update.h:79
Z_InternationalString * resultSetId
Definition: zes-order.h:112
Z_InternationalString * password
Definition: z-core.h:394
Z_ElementSpec * elementSpec
Definition: z-core.h:817
#define Z_ExtendedServicesRequest_create
Definition: z-core.h:1121
static Z_APDU * create_es_package(ZOOM_package p, const Odr_oid *oid)
Definition: zoom-z3950.c:49
Odr_oid * oid
Definition: z-core.h:812
Z_InternationalString * databaseName
Definition: zes-admin.h:84
Z_IUOriginPartNotToKeep * notToKeep
Definition: zes-update.h:59
char * charset
Definition: zoom-p.h:87
#define ODR_MASK_SET(mask, num)
Definition: odr.h:204
Z_InternationalString * packageName
Definition: z-core.h:1126
ZOOM_options options
Definition: zoom-p.h:187
Z_SortResponse * sortResponse
Definition: z-core.h:342
Z_AttributesPlusTerm * attributesPlusTerm
Definition: z-core.h:512
static void response_diag(ZOOM_connection c, Z_DiagRec *p)
Definition: zoom-z3950.c:976
void * clientData
Definition: ill.h:43
#define Z_External_userFacets
Definition: prt-ext.h:100
#define Z_Options_scan
Definition: z-core.h:436
Z_SRW_scanResponse * srw_scan_response
Definition: zoom-p.h:178
void * odr_malloc(ODR o, size_t size)
Definition: odr_mem.c:31
#define Z_RecordComp_simple
Definition: z-core.h:645
Z_RPNQuery * type_1
Definition: z-core.h:472
Z_RPNQuery * yaz_copy_z_RPNQuery(Z_RPNQuery *q, ODR out)
int num_terms
Definition: z-facet-1.h:37
static Z_External * encode_ill_request(ZOOM_package p)
Definition: zoom-z3950.c:97
void yaz_oi_set_facetlist(Z_OtherInformation **otherInformation, ODR odr, Z_FacetList *facet_list)
Definition: facet.c:23
ZOOM_connection connection
Definition: zoom-p.h:188
Odr_oct * general
Definition: z-core.h:539
ZOOM_scanset scan
Definition: zoom-p.h:209
ZOOM_task tasks
Definition: zoom-p.h:106
Odr_int * taskStatus
Definition: z-estask.h:37
zoom_ret ZOOM_connection_Z3950_send_scan(ZOOM_connection c)
Definition: zoom-z3950.c:808
Z_NamePlusRecordList * databaseOrSurDiagnostics
Definition: z-core.h:695
union Z_External::@30 u
const Odr_oid yaz_oid_extserv_xml_es[]
Definition: oid_std.c:149
Z_IUSuppliedRecords_elem ** elements
Definition: zes-update.h:132
Z_InternationalString ** inputResultSetNames
Definition: z-core.h:1038
int which
Definition: prt-ext.h:63
Odr_oid * yaz_string_to_oid_odr(yaz_oid_db_t oid_list, oid_class oclass, const char *name, ODR o)
creates ODR malloc&#39;ed OID from string
Definition: oid_db.c:72
Z_InternationalString * implementationName
Definition: z-core.h:385
#define Z_Options_namedResultSets
Definition: z-core.h:442
#define Z_TaskPackage_pending
Definition: z-estask.h:33
#define ZOOM_EVENT_RECV_SEARCH
Definition: zoom.h:160
Z_External * yaz_set_proposal_charneg_list(ODR o, const char *delim, const char *charset_list, const char *lang_list, int selected)
Definition: charneg.c:174
#define Z_Options_extendedServices
Definition: z-core.h:438
void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr, int pos, const char *syntax, const char *elementSetName, const char *schema, Z_SRW_diagnostic *diag)
#define Z_External_extendedService
Definition: prt-ext.h:75
Odr_int * numeric
Definition: z-core.h:540
Z_IUUpdate * update
Definition: prt-ext.h:125
int ill_Request(ODR o, ILL_Request **p, int opt, const char *name)
Definition: ill-core.c:66
int num_databaseNames
Definition: zoom-p.h:181
const Odr_oid yaz_oid_extserv_admin[]
Definition: oid_std.c:107
Odr_int * numberOfEntriesReturned
Definition: z-core.h:967
int yaz_iconv_close(yaz_iconv_t cd)
just like iconv_close(3)
Definition: siconv.c:284
char * cookie_out
Definition: zoom-p.h:89
#define Z_RecordComp_complex
Definition: z-core.h:646
char * setname
Definition: zoom-p.h:140
int which
Definition: z-core.h:537
Z_Query * yaz_copy_Z_Query(Z_Query *q, ODR out)
Definition: copy_types.c:70
#define Z_Records_multipleNSD
Definition: z-core.h:700
char * client_IP
Definition: zoom-p.h:91
Header for Z39.50 OtherInfo utilities.
Z_DiagRec ** diagRecs
Definition: z-core.h:689
Z_IOOriginPartNotToKeep * notToKeep
Definition: zes-order.h:53
int ZOOM_test_reconnect(ZOOM_connection c)
Definition: zoom-c.c:904
ZOOM_options_get(ZOOM_options opt, const char *name)
Definition: zoom-opt.c:216
Z_SortKeySpecList * sortSequence
Definition: z-core.h:1040
const Odr_oid yaz_oid_extserv_database_update_first_version[]
Definition: oid_std.c:102
Z_PresentResponse * presentResponse
Definition: z-core.h:329
Z_QueryExpression * subqueryInterpretation
Definition: z-uifr1.h:46
#define Z_IUTargetPart_failure
Definition: zes-update.h:95
Odr_null * odr_nullval(void)
Definition: odr.c:30
#define Z_Term_numeric
Definition: z-core.h:548
NMEM odr_extract_mem(ODR o)
Definition: odr_mem.c:23
Odr_int * resultSetStartPoint
Definition: z-core.h:653
zoom_ret ZOOM_send_buf(ZOOM_connection c)
Definition: zoom-c.c:1763
Definition: z-core.h:536
#define YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS
Definition: diagbib1.h:24
static void handle_Z3950_sort_response(ZOOM_connection c, Z_SortResponse *res)
Definition: zoom-z3950.c:1309
union Z_DefaultDiagFormat::@60 u
ZOOM_connection_set_mask(ZOOM_connection c, int mask)
set socket mask for connection (DO NOT call outside zoom)
Z_IdPass * idPass
Definition: z-core.h:401
void odr_setbuf(ODR o, char *buf, int len, int can_grow)
Definition: odr.c:267
ZOOM_facet_field * res_facets
Definition: zoom-p.h:153
Query to WRBUF (to strings)
union Z_DiagRec::@59 u
#define Z_Admin_esRequest
Definition: zes-admin.h:57
#define YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE
Definition: diagbib1.h:23
Z_Specification * generic
Definition: z-core.h:792
#define Z_TaskPackage_active
Definition: z-estask.h:34
Z_External * supplDescription
Definition: zes-order.h:100
Z_DefaultDiagFormat * yaz_decode_init_diag(int no, Z_InitResponse *initrs)
returns diagnostics from an init response
Definition: init_diag.c:32
Z_IdAuthentication * idAuthentication
Definition: z-core.h:383
Odr_int * stepSize
Definition: z-core.h:958
static char * get_term_cstr(ODR odr, Z_Term *term)
Definition: zoom-z3950.c:1083
void odr_reset(ODR o)
Definition: odr.c:226
Z_IUSuppliedRecordsId * supplementalId
Definition: zes-update.h:125
yaz_oid_db_t yaz_oid_std(void)
returns standard OID database
Definition: oid_db.c:33
Z_IUUpdateEsRequest * esRequest
Definition: zes-update.h:70
#define Z_QueryExpression_query
Definition: z-uifr1.h:91
Odr_int * subqueryCount
Definition: z-uifr1.h:48
int which
Definition: z-core.h:469
#define Z_Records_NSD
Definition: z-core.h:699
Z_ElementSetNames * mediumSetElementSetNames
Definition: z-core.h:461
ZOOM_package package
Definition: zoom-p.h:212
Z_ExtendedServicesRequest * extendedServicesRequest
Definition: z-core.h:344
#define xfree(x)
utility macro which calls xfree_f
Definition: xmalloc.h:53
#define Z_Options_negotiationModel
Definition: z-core.h:445
Z_APDU * create_admin_package(ZOOM_package p, int type, Z_ESAdminOriginPartToKeep **toKeepP, Z_ESAdminOriginPartNotToKeep **notToKeepP)
Definition: zoom-z3950.c:203
static Odr_oid * zoom_yaz_str_to_z3950oid(ZOOM_connection c, oid_class oid_class, const char *str)
Definition: zoom-z3950.c:38
enum l_file_type type
Definition: log.c:45
Z_APDU * zget_APDU(ODR o, int which)
Definition: zget.c:410
Z_PresentStatus * presentStatus
Definition: z-core.h:634
#define Z_ProtocolVersion_3
Definition: z-core.h:427
Z_External * itemRequest
Definition: zes-order.h:118
Z_DiagRec ** diagnostics
Definition: z-core.h:1148
#define ZOOM_EVENT_SEND_APDU
Definition: zoom.h:157
struct ZOOM_package_p * ZOOM_package
Definition: zoom.h:57
Odr_any * single_ASN1_type
Definition: prt-ext.h:104
Z_FacetList * yaz_pqf_parse_facet_list(ODR o, const char *qbuf)
Definition: pquery.c:882
char * buf_out
Definition: zoom-p.h:82
void ZOOM_handle_facet_list(ZOOM_resultset r, Z_FacetList *fl)
Definition: zoom-z3950.c:1122
ZOOM_Event ZOOM_Event_create(int kind)
Definition: zoom-event.c:42
static int encode_APDU(ZOOM_connection c, Z_APDU *a, ODR out)
Definition: zoom-z3950.c:503
Odr_bool * result
Definition: z-core.h:417
Z_External * z_ext_record_xml(ODR o, const char *buf, int len)
encodes EXTERNAL XML record
Definition: prt-ext.c:368
#define Z_APDU_extendedServicesRequest
Definition: z-core.h:369
int which
Definition: z-core.h:732
zoom_ret
Definition: zoom-p.h:222
Odr_int size
Definition: zoom-p.h:137
Z_InternationalString * implementationId
Definition: z-core.h:384
#define ZOOM_ERROR_UNSUPPORTED_QUERY
Definition: zoom.h:137
char * v2Addinfo
Definition: z-core.h:746
void ZOOM_connection_put_event(ZOOM_connection c, ZOOM_Event event)
Definition: zoom-event.c:73
static void handle_Z3950_records(ZOOM_connection c, Z_Records *sr, int present_phase)
Definition: zoom-z3950.c:1344
Z_External * externallyDefinedInfo
Definition: z-core.h:1285
Z_External * z_ext_record_oid_any(ODR o, const Odr_oid *oid, const char *buf, int len)
encodes EXTERNAL record as ANY
Definition: prt-ext.c:344
#define Z_External_ESAdmin
Definition: prt-ext.h:85
char * descriptor
Definition: prt-ext.h:62
Z_InternationalString * v3Addinfo
Definition: z-core.h:747
#define Z_TaskPackage_complete
Definition: z-estask.h:35
Z_DiagRecs * multipleNonSurDiagnostics
Definition: z-core.h:697
#define Z_ProtocolVersion_1
Definition: z-core.h:425
Z_IORequest * esRequest
Definition: zes-order.h:64
union Z_Query::@48 u
char ** databaseNames
Definition: zoom-p.h:180
static void handle_Z3950_es_response(ZOOM_connection c, Z_ExtendedServicesResponse *res)
Definition: zoom-z3950.c:1048
int which
Definition: zoom-p.h:195
ZOOM_connection_exec_task(ZOOM_connection c)
executes non-blocking tasks for connection
Definition: zoom-c.c:1435
Z_AdminEsRequest * esRequest
Definition: zes-admin.h:55
const Odr_oid yaz_oid_userinfo_proxy[]
Definition: oid_std.c:114
char * addinfo
Definition: zoom-p.h:70
Odr_oct * targetReference
Definition: z-estask.h:31
Definition: odr.h:99
const Odr_oid yaz_oid_userinfo_client_ip[]
Definition: oid_std.c:116
#define ZOOM_API(x)
Definition: zoom.h:42
char ** ZOOM_connection_get_databases(ZOOM_connection con, ZOOM_options options, int *num, ODR odr)
Definition: zoom-c.c:322
static void set_init_option(const char *name, void *clientData)
Definition: zoom-z3950.c:1436
Header for the facet utilities.
static int es_response_taskpackage_update(ZOOM_connection c, Z_IUUpdateTaskPackage *utp)
Definition: zoom-z3950.c:984
#define Z_External_single
Definition: prt-ext.h:65
Z_ResultSetId * resultSetId
Definition: z-core.h:652
#define OID_STR_MAX
Definition: oid_util.h:40
#define Z_ESAdminOriginPartToKeep_commit
Definition: zes-admin.h:80
void yaz_init_opt_decode(Z_Options *opt, void(*pr)(const char *name, void *clientData), void *clientData)
Decodes Z39.50 Init Options - for printing.
Definition: initopt.c:84
#define Z_ExtendedServicesRequest_wait
Definition: z-core.h:1132
Z_DatabaseName ** databaseNames
Definition: z-core.h:459
Odr_int * updateStatus
Definition: zes-update.h:96
Z_Options * options
Definition: z-core.h:380
Z_OtherInformationUnit * yaz_oi_update(Z_OtherInformation **otherInformationP, ODR odr, const Odr_oid *oid, int categoryValue, int delete_flag)
Definition: otherinfo.c:76
ODR odr
Definition: ill.h:42
Odr_int * indirect_reference
Definition: prt-ext.h:61
#define Z_ElementSpec_elementSetName
Definition: z-core.h:804
Z_InternationalString * userId
Definition: z-core.h:393
Z_DatabaseName ** databaseNames
Definition: z-core.h:947
int z_APDU(ODR o, Z_APDU **p, int opt, const char *name)
Definition: z-core.c:12
Odr_int * preferredPositionInResponse
Definition: z-core.h:952
Z_SortKeySpecList * r_sort_spec
Definition: zoom-p.h:134
typedefZOOM_BEGIN_CDECL struct ZOOM_options_p * ZOOM_options
Definition: zoom.h:50
Z_ElementSetNames * simple
Definition: z-core.h:643
char ** databaseNames
Definition: zoom-p.h:145
int preferred_message_size
Definition: zoom-p.h:104
Z_OtherInformation * additionalSearchInfo
Definition: z-core.h:464
static void handle_Z3950_scan_response(ZOOM_connection c, Z_ScanResponse *res)
Definition: zoom-z3950.c:1318
Z_DiagRec ** globalDiagnostics
Definition: zes-update.h:98
char * password
Definition: zoom-p.h:96
char * group
Definition: zoom-p.h:95
#define Z_IOItemOrder_esRequest
Definition: zes-order.h:66
void ZOOM_memcached_search(ZOOM_connection c, ZOOM_resultset resultset)
Z_InternationalString * databaseName
Definition: zes-update.h:84
Z_SearchResponse * searchResponse
Definition: z-core.h:327
int maximum_record_size
Definition: zoom-p.h:103
#define ZOOM_ERROR_ENCODE
Definition: zoom.h:130
Odr_int * odr_intdup(ODR o, Odr_int v)
Definition: odr_mem.c:51
void odr_destroy(ODR o)
Definition: odr.c:253
union Z_APDU::@46 u
union Z_ESAdminOriginPartToKeep::@111 u
Definition: odr.h:124
int num_databaseNames
Definition: z-core.h:946
ZOOM_facet_field_name(ZOOM_facet_field field)
Definition: zoom-c.c:1034
Odr_int * positionOfTerm
Definition: z-core.h:968
#define Z_ExtendedServicesResponse_done
Definition: z-core.h:1143
Z_FacetList * facetList
Definition: prt-ext.h:146
Z_InternationalString * diagnosticInformation
Definition: z-core.h:1172
#define Z_APDU_extendedServicesResponse
Definition: z-core.h:370
void ZOOM_connection_remove_task(ZOOM_connection c)
Definition: zoom-c.c:183
Z_InternationalString * sortedResultSetName
Definition: z-core.h:1039
#define Z_Records_DBOSD
Definition: z-core.h:698
union Z_IdAuthentication::@47 u
Z_DbSpecific ** dbSpecific
Definition: z-core.h:794
static ZOOM_facet_field get_zoom_facet_field(ODR odr, Z_FacetField *facet)
Definition: zoom-z3950.c:1096
char * yaz_oi_get_string_oid(Z_OtherInformation **otherInformation, const Odr_oid *oid, int categoryValue, int delete_flag)
Definition: otherinfo.c:172
const char * useattr
Definition: facet.h:56
#define Z_Operand_APT
Definition: z-core.h:515
char * host_port
Definition: zoom-p.h:68
oid_class
Definition: oid_db.h:45
Z_QueryExpression * subqueryExpression
Definition: z-uifr1.h:45
#define ZOOM_TASK_SCAN
Definition: zoom-p.h:207
ZOOM_options options
Definition: zoom-p.h:143
char * cookie_in
Definition: zoom-p.h:90
#define Z_IUOriginPartToKeep_recordDelete
Definition: zes-update.h:80
Z_ESAdminOriginPartNotToKeep * notToKeep
Definition: zes-admin.h:44
Z_TaskPackage * extendedService
Definition: prt-ext.h:116
Z_InitResponse * initResponse
Definition: z-core.h:325
char * odr_prepend(ODR o, const char *prefix, const char *old)
Definition: odr_util.c:103
void yaz_facet_attr_init(struct yaz_facet_attr *attr_values)
Definition: facet.c:68
Z_DiagRec ** diagnostics
Definition: z-core.h:1056
Odr_int * smallSetUpperBound
Definition: z-core.h:453
Z_InternationalString * name
Definition: zes-order.h:72
Z_ScanRequest * scanRequest
Definition: z-core.h:339
int opt
Definition: initopt.c:19
union Z_RPNStructure::@49 u
Z_DiagRec ** packageDiagnostics
Definition: z-estask.h:39
char * user
Definition: zoom-p.h:94
union Z_QueryExpression::@108 u
#define xmalloc(x)
utility macro which calls malloc_f
Definition: xmalloc.h:49
Odr_oid * odr_oiddup(ODR odr, const Odr_oid *o)
Definition: odr_util.c:60
Z_FacetField ** elements
Definition: z-facet-1.h:32
zoom_ret send_Z3950_sort(ZOOM_connection c, ZOOM_resultset resultset)
Definition: zoom-z3950.c:1445
static void response_default_diag(ZOOM_connection c, Z_DefaultDiagFormat *r)
Definition: zoom-z3950.c:955
Z_AttributeSetId * attributeSet
Definition: z-core.h:948
Z_DefaultDiagFormat * defaultFormat
Definition: z-core.h:734
Z_IUCorrelationInfo * correlationInfo
Definition: zes-update.h:126
#define Z_External_octet
Definition: prt-ext.h:66
Z_NamePlusRecord * zget_surrogateDiagRec(ODR o, const char *dbname, int error, const char *addinfo)
Creates Surrogate Diagnostic Records.
Definition: zget.c:529
Z_InternationalString * userId
Definition: z-core.h:1127
#define Z_APDU_sortRequest
Definition: z-core.h:366
#define Z_APDU_close
Definition: z-core.h:371
Header for memory handling functions.
Z_InternationalString * implementationId
Definition: z-core.h:418
int num_packageDiagnostics
Definition: z-estask.h:38
union ZOOM_task_p::@6 u
void ZOOM_handle_facet_result(ZOOM_connection c, ZOOM_resultset r, Z_OtherInformation *o)
Definition: zoom-z3950.c:1143
Z_RecordComposition * recordComposition
Definition: z-core.h:657
Z_InternationalString * implementationVersion
Definition: z-core.h:420
Z_SearchInfoReport * searchResult1
Definition: prt-ext.h:124
#define ZOOM_TASK_SEARCH
Definition: zoom-p.h:197
#define Z_IdAuthentication_open
Definition: z-core.h:404
Z_ProtocolVersion * protocolVersion
Definition: z-core.h:379
Z_External * taskSpecificParameters
Definition: z-estask.h:40
#define Z_Term_characterString
Definition: z-core.h:549
#define Z_QueryExpression_term
Definition: z-uifr1.h:90
static void otherInfo_attach(ZOOM_connection c, Z_APDU *a, ODR out)
Definition: zoom-z3950.c:466
Odr_int * preferredMessageSize
Definition: z-core.h:381
NMEM nmem_create(void)
returns new NMEM handle
Definition: nmem.c:181
union Z_OtherInformationUnit::@74 information
char * lang
Definition: zoom-p.h:88
ZOOM_query query
Definition: zoom-p.h:176
#define YLOG_WARN
log level: warning
Definition: log.h:46
structure for all known EXTERNALs
Definition: prt-ext.h:58
#define odr_getmem(o)
Definition: odr.h:216
#define ZOOM_ERROR_ES_INVALID_SYNTAX
Definition: zoom.h:145
Odr_int * count
Definition: z-facet-1.h:43
Definition: cookie.c:16
static void handle_queryExpressionTerm(ZOOM_options opt, const char *name, Z_Term *term)
Definition: zoom-z3950.c:1160
#define Z_IdAuthentication_idPass
Definition: z-core.h:405
#define Z_OtherInfo_externallyDefinedInfo
Definition: z-core.h:1289
Z_SortRequest * sortRequest
Definition: z-core.h:341
ZOOM_resultset next
Definition: zoom-p.h:151
static const char * ill_array_lookup(void *clientData, const char *idx)
Definition: zoom-z3950.c:91
union Z_IUUpdate::@127 u
void yaz_log(int level, const char *fmt,...)
Writes log message.
Definition: log.c:485
Z_InternationalString * phone
Definition: zes-order.h:73
#define Z_APDU_sortResponse
Definition: z-core.h:367
ZOOM_options_set_int(ZOOM_options opt, const char *name, int value)
Definition: zoom-opt.c:245
static void handle_Z3950_search_response(ZOOM_connection c, Z_SearchResponse *sr)
Definition: zoom-z3950.c:1266
void ZOOM_set_error(ZOOM_connection c, int error, const char *addinfo)
Definition: zoom-c.c:98
int which
Definition: z-core.h:693
const Odr_oid yaz_oid_attset_bib_1[]
Definition: oid_std.c:13
Odr_oid * preferredRecordSyntax
Definition: z-core.h:462
union Z_IOItemOrder::@118 u
ZOOM_options_setl(ZOOM_options opt, const char *name, const char *value, int len)
Definition: zoom-opt.c:160
#define Z_ExtendedServicesResponse_accepted
Definition: z-core.h:1144
#define ZOOM_ERROR_CONNECTION_LOST
Definition: zoom.h:132
int num_databaseNames
Definition: z-core.h:458
void nmem_transfer(NMEM dst, NMEM src)
transfers memory from one NMEM handle to another
Definition: nmem.c:216
Z_External * actionQualifier
Definition: zes-update.h:87
Odr_oid * diagnosticSetId
Definition: z-core.h:742
int which
Definition: zes-admin.h:53
Odr_int * scanStatus
Definition: z-core.h:966
#define Z_IUSuppliedRecords_elem_number
Definition: zes-update.h:121
#define Z_IUSuppliedRecords_elem_opaque
Definition: zes-update.h:123
Definition: z-core.h:321
Z_Options * options
Definition: z-core.h:414
Odr_int * maximumRecordSize
Definition: z-core.h:382
int num_recordSyntax
Definition: z-core.h:795
const Odr_oid yaz_oid_general_isoill_1[]
Definition: oid_std.c:10
const Odr_oid yaz_oid_extserv_database_update_second_version[]
Definition: oid_std.c:103
ODR odr_createmem(int direction)
Definition: odr.c:200
Odr_int * numberOfRecordsRequested
Definition: z-core.h:654
#define Z_Options_sort
Definition: z-core.h:437
void yaz_query_charset_convert_rpnquery(Z_RPNQuery *q, ODR o, yaz_iconv_t cd)
#define Z_ESAdminOriginPartToKeep_drop
Definition: zes-admin.h:76
#define ZOOM_ERROR_ES_INVALID_VERSION
Definition: zoom.h:144
#define Z_RPNStructure_simple
Definition: z-core.h:504
union Z_Operand::@50 u
Z_Term * queryTerm
Definition: z-uifr1.h:81
#define Z_ExtendedServicesRequest_modify
Definition: z-core.h:1123
ZOOM_event(int no, ZOOM_connection *cs)
wait for events on connection(s) (BLOCKING)
Definition: zoom-socket.c:99
union Z_Admin::@110 u
ILL_Request * ill_get_ILLRequest(struct ill_get_ctl *gc, const char *name, const char *sub)
Definition: ill-get.c:477
char ** facets_names
Definition: zoom-p.h:155
Z_DiagRec ** nonsurrogateDiagnostics
Definition: z-core.h:978
#define Z_TaskPackage_aborted
Definition: z-estask.h:36
#define bool_t
Definition: odr.h:52
Z_ESAdminOriginPartToKeep * toKeep
Definition: zes-admin.h:43
union Z_ElementSpec::@62 u
#define Z_APDU_scanRequest
Definition: z-core.h:364
Logging utility.
Z_InternationalString * elementSetName
Definition: z-core.h:802
char * odr_strdup_null(ODR o, const char *str)
Definition: odr_mem.c:41
#define ZOOM_ERROR_ES_INVALID_ACTION
Definition: zoom.h:143
Z_External * taskPackage
Definition: z-core.h:1149
Z_SearchRequest * searchRequest
Definition: z-core.h:326
Z_IUTargetPart * targetPart
Definition: zes-update.h:64
Z_CharSetandLanguageNegotiation * yaz_get_charneg_record(Z_OtherInformation *p)
Definition: charneg.c:260
Z_External * taskSpecificParameters
Definition: z-core.h:1131
Odr_bool * selectAlternativeSyntax
Definition: z-core.h:791
ZOOM_options_set(ZOOM_options opt, const char *name, const char *value)
Definition: zoom-opt.c:180
#define Z_External_itemOrder
Definition: prt-ext.h:76
union Z_RecordComposition::@55 u
void ZOOM_handle_search_result(ZOOM_connection c, ZOOM_resultset resultset, Z_OtherInformation *o)
Definition: zoom-z3950.c:1198
Z_ListEntries * entries
Definition: z-core.h:969
Odr_int * largeSetLowerBound
Definition: z-core.h:454
Z_OtherInformationUnit ** list
Definition: z-core.h:1296
ZOOM_connection_option_set(ZOOM_connection c, const char *key, const char *val)
Definition: zoom-c.c:1801
#define Z_APDU_initRequest
Definition: z-core.h:349
#define ZOOM_TASK_SORT
Definition: zoom-p.h:213
Header for Z39.50 Charset negotiation utilities.
Z_InternationalString * characterString
Definition: z-core.h:541
Z_ScanResponse * scanResponse
Definition: z-core.h:340
#define Z_IUOriginPartToKeep_specialUpdate
Definition: zes-update.h:82
Odr_oct * odr_create_Odr_oct(ODR o, const char *buf, int sz)
Definition: odr_mem.c:66
const Odr_oid yaz_oid_userinfo_cookie[]
Definition: oid_std.c:115
char * odr_strdupn(ODR o, const char *str, size_t n)
Definition: odr_mem.c:46
const char *(* f)(void *clientData, const char *element)
Definition: ill.h:44
Odr_oct * octet_aligned
Definition: prt-ext.h:105
int limit
Definition: facet.h:61
Z_External * z_ext_record_oid(ODR o, const Odr_oid *oid, const char *buf, int len)
encodes EXTERNAL record based on OID (NULL if not known)
Definition: prt-ext.c:338
void ZOOM_handle_Z3950_apdu(ZOOM_connection c, Z_APDU *apdu)
Definition: zoom-z3950.c:1627
static Z_APDU * create_update_package(ZOOM_package p)
Definition: zoom-z3950.c:278
#define Z_APDU_presentResponse
Definition: z-core.h:354
Z_IOContact * contact
Definition: zes-order.h:101
#define Z_ESAdminOriginPartNotToKeep_recordsWillFollow
Definition: zes-admin.h:93
#define Z_ExtendedServicesRequest_dontReturnPackage
Definition: z-core.h:1135
void yaz_oi_set_string_oid(Z_OtherInformation **otherInformation, ODR odr, const Odr_oid *oid, int categoryValue, const char *str)
Definition: otherinfo.c:159
Z_AttributeSetId * attributeSetId
Definition: z-core.h:489
char * req_facets
Definition: zoom-p.h:152
Z_IOOriginPartToKeep * toKeep
Definition: zes-order.h:52
static zoom_ret Z3950_send_present(ZOOM_connection c)
Definition: zoom-z3950.c:1469
Z_IOResultSetItem * resultSetItem
Definition: zes-order.h:117
Header for config file reading utilities.
#define Z_IUTargetPart_success
Definition: zes-update.h:93
int num_dbSpecific
Definition: z-core.h:793
Z_CompSpec * complex
Definition: z-core.h:644
#define Z_Options_search
Definition: z-core.h:429
Diagnostics: Generated by csvtodiag.tcl from ./bib1.csv.
#define Z_ProtocolVersion_2
Definition: z-core.h:426
union Z_Term::@51 u
#define ZOOM_ERROR_INVALID_QUERY
Definition: zoom.h:138
Z_DefaultDiagFormat * nonSurrogateDiagnostic
Definition: z-core.h:696
Z_Term * term
Definition: z-facet-1.h:42
#define Z_External_update
Definition: prt-ext.h:82
Z_FacetTerm ** terms
Definition: z-facet-1.h:38
int len
Definition: odr.h:102
Z_IOBilling * addlBilling
Definition: zes-order.h:102
#define Z_APDU_presentRequest
Definition: z-core.h:353