YAZ  5.23.1
ztest.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  */
8 #if HAVE_CONFIG_H
9 #include <config.h>
10 #endif
11 
12 
13 #include <stdio.h>
14 #include <math.h>
15 #include <stdlib.h>
16 
17 #if HAVE_SYS_TIME_H
18 #include <sys/time.h>
19 #endif
20 #if HAVE_UNISTD_H
21 #include <unistd.h>
22 #endif
23 #if HAVE_SYS_SELECT_H
24 #include <sys/select.h>
25 #endif
26 #ifdef WIN32
27 #include <windows.h>
28 #endif
29 
30 #include <yaz/log.h>
31 #include <yaz/backend.h>
32 #include <yaz/ill.h>
33 #include <yaz/diagbib1.h>
34 #include <yaz/otherinfo.h>
35 #include <yaz/facet.h>
36 #include <yaz/backtrace.h>
37 
38 #include "ztest.h"
39 
40 static int log_level=0;
41 static int log_level_set=0;
42 
43 struct delay {
44  double d1;
45  double d2;
46 };
47 
48 struct result_set {
49  char *name;
50  char *db;
52  struct delay search_delay;
53  struct delay present_delay;
54  struct delay fetch_delay;
55  struct result_set *next;
56 };
57 
60 };
61 
62 int ztest_search(void *handle, bend_search_rr *rr);
63 int ztest_sort(void *handle, bend_sort_rr *rr);
64 int ztest_present(void *handle, bend_present_rr *rr);
65 int ztest_esrequest(void *handle, bend_esrequest_rr *rr);
66 int ztest_delete(void *handle, bend_delete_rr *rr);
67 
68 static struct result_set *get_set(struct session_handle *sh, const char *name)
69 {
70  struct result_set *set = sh->result_sets;
71  for (; set; set = set->next)
72  if (!strcmp(name, set->name))
73  return set;
74  return 0;
75 }
76 
77 static void remove_sets(struct session_handle *sh)
78 {
79  struct result_set *set = sh->result_sets;
80  while (set)
81  {
82  struct result_set *set_next = set->next;
83  xfree(set->name);
84  xfree(set->db);
85  xfree(set);
86  set = set_next;
87  }
88  sh->result_sets = 0;
89 }
90 
100 static Odr_int get_term_hit(Z_RPNStructure *s, unsigned *hash)
101 {
102  Odr_int h = -1;
103  switch(s->which)
104  {
106  if (s->u.simple->which == Z_Operand_APT)
107  {
109  if (apt->term->which == Z_Term_general)
110  {
111  Odr_oct *oct = apt->term->u.general;
112  if (oct->len > 0 && oct->buf[0] >= '0' && oct->buf[0] <= '9')
113  {
114  WRBUF hits_str = wrbuf_alloc();
115  wrbuf_write(hits_str, (const char *) oct->buf, oct->len);
116  h = odr_atoi(wrbuf_cstr(hits_str));
117  wrbuf_destroy(hits_str);
118  }
119  else
120  {
121  int i;
122  for (i = 0; i < oct->len; i++)
123  *hash = *hash * 65509 + oct->buf[i];
124  }
125  }
126  }
127  break;
129  h = get_term_hit(s->u.complex->s1, hash);
130  if (h == -1)
131  h = get_term_hit(s->u.complex->s2, hash);
132  break;
133  }
134  return h;
135 }
136 
147 {
148  if (q->which == Z_Query_type_1 || q->which == Z_Query_type_101)
149  {
150  unsigned hash = 0;
151  Odr_int h = -1;
152  h = get_term_hit(q->u.type_1->RPNStructure, &hash);
153  if (h == -1)
154  h = hash % 24;
155  return h;
156  }
157  else if (q->which == Z_Query_type_104 &&
159  {
160  unsigned hash = 0;
161  const char *cql = q->u.type_104->u.cql;
162  int i;
163  for (i = 0; cql[i]; i++)
164  hash = hash * 65509 + cql[i];
165  return hash % 24;
166  }
167  else
168  return 24;
169 }
170 
180 static int check_slow(const char *basename, bend_association association)
181 {
182  if (strncmp(basename, "Slow", 4) == 0)
183  {
184 #if HAVE_UNISTD_H
185  int i, w = 3;
186  if (basename[4])
187  sscanf(basename+4, "%d", &w);
188  /* wait up to 3 seconds and check if connection is still alive */
189  for (i = 0; i < w; i++)
190  {
191  if (association && !bend_assoc_is_alive(association))
192  {
193  yaz_log(YLOG_LOG, "search aborted");
194  break;
195  }
196  sleep(1);
197  }
198 #endif
199  return 1;
200  }
201  return 0;
202 }
203 
204 static int strcmp_prefix(const char *s, const char *p)
205 {
206  size_t l = strlen(p);
207  if (strlen(s) >= l && !memcmp(s, p, l))
208  return 1;
209  return 0;
210 }
211 
212 static void init_delay(struct delay *delayp)
213 {
214  delayp->d1 = delayp->d2 = 0.0;
215 }
216 
217 static int parse_delay(struct delay *delayp, const char *value)
218 {
219  if (sscanf(value, "%lf:%lf", &delayp->d1, &delayp->d2) == 2)
220  ;
221  else if (sscanf(value, "%lf", &delayp->d1) == 1)
222  delayp->d2 = 0.0;
223  else
224  return -1;
225  return 0;
226 }
227 
228 static void ztest_sleep(double d)
229 {
230 #ifdef WIN32
231  Sleep( (DWORD) (d * 1000));
232 #else
233  struct timeval tv;
234  tv.tv_sec = d;
235  tv.tv_usec = (d - (long) d) * 1000000;
236  select(0, 0, 0, 0, &tv);
237 #endif
238 }
239 
240 static void do_delay(const struct delay *delayp)
241 {
242  double d = delayp->d1;
243 
244  if (d > 0.0)
245  {
246  if (delayp->d2 > d)
247  d += (rand()) * (delayp->d2 - d) / RAND_MAX;
248  ztest_sleep(d);
249  }
250 }
251 
252 static void addterms(ODR odr, Z_FacetField *facet_field, const char *facet_name)
253 {
254  int index;
255  int freq = 100;
256  int length = strlen(facet_name) + 10;
257  char *key = odr_malloc(odr, length);
258  key[0] = '\0';
259  for (index = 0; index < facet_field->num_terms; index++)
260  {
261  Z_FacetTerm *facet_term;
262  sprintf(key, "%s%d", facet_name, index);
263  yaz_log(YLOG_DEBUG, "facet add term %s %d %s", facet_name, index, key);
264 
265  facet_term = facet_term_create_cstr(odr, key, freq);
266  freq = freq - 10 ;
267  facet_field_term_set(odr, facet_field, facet_term, index);
268  }
269 }
270 
272  int index, new_index = 0;
273  Z_FacetList *new_list = facet_list_create(odr, facet_list->num);
274 
275  for (index = 0; index < facet_list->num; index++) {
276  struct yaz_facet_attr attrvalues;
277  yaz_facet_attr_init(&attrvalues);
278  attrvalues.limit = 10;
280  &attrvalues);
281  yaz_log(YLOG_LOG, "Attributes: %s limit=%d start=%d sort=%d",
282  attrvalues.useattr ? attrvalues.useattr : "NONE",
283  attrvalues.limit,
284  attrvalues.start,
285  attrvalues.sortorder);
286  if (attrvalues.errstring)
287  yaz_log(YLOG_LOG, "Error parsing attributes: %s", attrvalues.errstring);
288  if (attrvalues.limit > 0 && attrvalues.useattr) {
289  new_list->elements[new_index] = facet_field_create(odr, facet_list->elements[index]->attributes, attrvalues.limit);
290  addterms(odr, new_list->elements[new_index], attrvalues.useattr);
291  new_index++;
292  }
293  else {
294  yaz_log(YLOG_DEBUG, "Facet: skipping %s due to 0 limit.", attrvalues.useattr);
295  }
296 
297  }
298  new_list->num = new_index;
299  if (new_index > 0) {
300  Z_OtherInformation *oi = odr_malloc(odr, sizeof(*oi));
301  Z_OtherInformationUnit *oiu = odr_malloc(odr, sizeof(*oiu));
302  oi->num_elements = 1;
303  oi->list = odr_malloc(odr, oi->num_elements * sizeof(*oi->list));
304  oiu->category = 0;
311  oiu->information.externallyDefinedInfo->u.facetList = new_list;
312  oi->list[0] = oiu;
313  return oi;
314  }
315  return 0;
316 }
317 
318 static void echo_extra_args(ODR stream,
319  Z_SRW_extra_arg *extra_args, char **extra_response)
320 {
321  if (extra_args)
322  {
323  Z_SRW_extra_arg *a;
324  WRBUF response_xml = wrbuf_alloc();
325  wrbuf_puts(response_xml, "<extra>");
326  for (a = extra_args; a; a = a->next)
327  {
328  wrbuf_puts(response_xml, "<extra name=\"");
329  wrbuf_xmlputs(response_xml, a->name);
330  wrbuf_puts(response_xml, "\"");
331  if (a->value)
332  {
333  wrbuf_puts(response_xml, " value=\"");
334  wrbuf_xmlputs(response_xml, a->value);
335  wrbuf_puts(response_xml, "\"");
336  }
337  wrbuf_puts(response_xml, "/>");
338  }
339  wrbuf_puts(response_xml, "</extra>");
340  *extra_response = odr_strdup(stream, wrbuf_cstr(response_xml));
341  wrbuf_destroy(response_xml);
342  }
343 
344 }
345 
346 int ztest_search(void *handle, bend_search_rr *rr)
347 {
348  struct session_handle *sh = (struct session_handle*) handle;
349  struct result_set *new_set;
350  const char *db, *db_sep;
351 
352  if (rr->num_bases != 1)
353  {
355  return 0;
356  }
357 
358  db = rr->basenames[0];
359 
360  /* Allow Default, db.* and Slow */
361  if (strcmp_prefix(db, "Default"))
362  ; /* Default is OK in our test */
363  else if (strcmp_prefix(db, "db"))
364  ; /* db.* is OK in our test */
365  else if (check_slow(rr->basenames[0], rr->association))
366  {
367  rr->estimated_hit_count = 1;
368  }
369  else
370  {
372  rr->errstring = rr->basenames[0];
373  return 0;
374  }
375 
376  new_set = get_set(sh, rr->setname);
377  if (new_set)
378  {
379  if (!rr->replace_set)
380  {
382  return 0;
383  }
384  xfree(new_set->db);
385  }
386  else
387  {
388  new_set = xmalloc(sizeof(*new_set));
389  new_set->next = sh->result_sets;
390  sh->result_sets = new_set;
391  new_set->name = xstrdup(rr->setname);
392  }
393  new_set->hits = 0;
394  new_set->db = xstrdup(db);
395  init_delay(&new_set->search_delay);
396  init_delay(&new_set->present_delay);
397  init_delay(&new_set->fetch_delay);
398 
399  db_sep = strchr(db, '?');
400  if (db_sep)
401  {
402  char **names;
403  char **values;
404  int no_parms = yaz_uri_to_array(db_sep+1, rr->stream, &names, &values);
405  int i;
406  for (i = 0; i < no_parms; i++)
407  {
408  const char *name = names[i];
409  const char *value = values[i];
410  if (!strcmp(name, "seed"))
411  srand(atoi(value));
412  else if (!strcmp(name, "search-delay"))
413  parse_delay(&new_set->search_delay, value);
414  else if (!strcmp(name, "present-delay"))
415  parse_delay(&new_set->present_delay, value);
416  else if (!strcmp(name, "fetch-delay"))
417  parse_delay(&new_set->fetch_delay, value);
418  else
419  {
421  rr->errstring = odr_strdup(rr->stream, name);
422  }
423  }
424  }
425 
427  rr->hits = get_hit_count(rr->query);
428 
429  if (1)
430  {
431  Z_FacetList *facet_list = yaz_oi_get_facetlist(&rr->search_input);
432  if (facet_list) {
433  yaz_log(YLOG_LOG, "%d Facets in search request.", facet_list->num);
434  rr->search_info = build_facet_response(rr->stream, facet_list);
435  }
436  else
437  yaz_log(YLOG_DEBUG, "No facets parsed search request.");
438 
439  }
440  do_delay(&new_set->search_delay);
441  new_set->hits = rr->hits;
442 
443  return 0;
444 }
445 
446 
447 /* this huge function handles extended services */
448 int ztest_esrequest(void *handle, bend_esrequest_rr *rr)
449 {
450  if (rr->esr->packageName)
451  yaz_log(log_level, "packagename: %s", rr->esr->packageName);
452  yaz_log(log_level, "Waitaction: " ODR_INT_PRINTF, *rr->esr->waitAction);
453 
454 
455  yaz_log(log_level, "function: " ODR_INT_PRINTF, *rr->esr->function);
456 
457  if (!rr->esr->taskSpecificParameters)
458  {
459  yaz_log(log_level, "No task specific parameters");
460  }
462  {
464  yaz_log(log_level, "Received ItemOrder");
465  if (it->which == Z_IOItemOrder_esRequest)
466  {
467  Z_IORequest *ir = it->u.esRequest;
468  Z_IOOriginPartToKeep *k = ir->toKeep;
470  const char *xml_in_response = 0;
471 
472  if (k && k->contact)
473  {
474  if (k->contact->name)
475  yaz_log(log_level, "contact name %s", k->contact->name);
476  if (k->contact->phone)
477  yaz_log(log_level, "contact phone %s", k->contact->phone);
478  if (k->contact->email)
479  yaz_log(log_level, "contact email %s", k->contact->email);
480  }
481  if (k->addlBilling)
482  {
483  yaz_log(log_level, "Billing info (not shown)");
484  }
485 
486  if (n->resultSetItem)
487  {
488  yaz_log(log_level, "resultsetItem");
489  yaz_log(log_level, "setId: %s", n->resultSetItem->resultSetId);
491  }
492  if (n->itemRequest)
493  {
494  Z_External *r = (Z_External*) n->itemRequest;
495  ILL_ItemRequest *item_req = 0;
496  ILL_APDU *ill_apdu = 0;
497  if (r->direct_reference)
498  {
499  char oid_name_str[OID_STR_MAX];
500  oid_class oclass;
501  const char *oid_name =
503  &oclass, oid_name_str);
504  if (oid_name)
505  yaz_log(log_level, "OID %s", oid_name);
507  {
508  yaz_log(log_level, "ILL XML request");
509  if (r->which == Z_External_octet)
510  yaz_log(log_level, "%.*s",
511  r->u.octet_aligned->len,
512  r->u.octet_aligned->buf);
513  xml_in_response = "<dummy>x</dummy>";
514  }
517  {
518  yaz_log(log_level, "Decode ItemRequest begin");
519  if (r->which == ODR_EXTERNAL_single)
520  {
521  odr_setbuf(rr->decode,
522  (char *) r->u.single_ASN1_type->buf,
523  r->u.single_ASN1_type->len, 0);
524 
525  if (!ill_ItemRequest(rr->decode, &item_req, 0, 0))
526  {
528  "Couldn't decode ItemRequest %s near %ld",
530  (long) odr_offset(rr->decode));
531  }
532  else
533  yaz_log(log_level, "Decode ItemRequest OK");
534  if (rr->print)
535  {
536  ill_ItemRequest(rr->print, &item_req, 0,
537  "ItemRequest");
538  odr_reset(rr->print);
539  }
540  }
541  if (!item_req && r->which == ODR_EXTERNAL_single)
542  {
543  yaz_log(log_level, "Decode ILL APDU begin");
544  odr_setbuf(rr->decode,
545  (char*) r->u.single_ASN1_type->buf,
546  r->u.single_ASN1_type->len, 0);
547 
548  if (!ill_APDU(rr->decode, &ill_apdu, 0, 0))
549  {
551  "Couldn't decode ILL APDU %s near %ld",
553  (long) odr_offset(rr->decode));
554  yaz_log(log_level, "PDU dump:");
556  (char *) r->u.single_ASN1_type->buf,
557  r->u.single_ASN1_type->len);
558  }
559  else
560  yaz_log(log_level, "Decode ILL APDU OK");
561  if (rr->print)
562  {
563  ill_APDU(rr->print, &ill_apdu, 0,
564  "ILL APDU");
565  odr_reset(rr->print);
566  }
567  }
568  }
569  }
570  if (item_req)
571  {
572  yaz_log(log_level, "ILL protocol version = "
574  *item_req->protocol_version_num);
575  }
576  }
577  if (k)
578  {
579 
580  Z_External *ext = (Z_External *)
581  odr_malloc(rr->stream, sizeof(*ext));
583  odr_malloc(rr->stream, sizeof(*keep));
584  Z_IOTargetPart *targetPart = (Z_IOTargetPart *)
585  odr_malloc(rr->stream, sizeof(*targetPart));
586 
587  rr->taskPackage = (Z_TaskPackage *)
588  odr_malloc(rr->stream, sizeof(*rr->taskPackage));
589  rr->taskPackage->packageType =
590  odr_oiddup(rr->stream, rr->esr->packageType);
591  rr->taskPackage->packageName = 0;
592  rr->taskPackage->userId = 0;
593  rr->taskPackage->retentionTime = 0;
594  rr->taskPackage->permissions = 0;
595  rr->taskPackage->description = 0;
597  odr_create_Odr_oct(rr->stream, "911", 3);
598  rr->taskPackage->creationDateTime = 0;
599  rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0);
602 
603  ext->direct_reference =
604  odr_oiddup(rr->stream, rr->esr->packageType);
605  ext->indirect_reference = 0;
606  ext->descriptor = 0;
608  ext->u.itemOrder = (Z_ItemOrder *)
609  odr_malloc(rr->stream, sizeof(*ext->u.update));
612  odr_malloc(rr->stream, sizeof(Z_IOTaskPackage));
613  ext->u.itemOrder->u.taskPackage->originPart = k;
614  ext->u.itemOrder->u.taskPackage->targetPart = targetPart;
615 
616  if (xml_in_response)
617  targetPart->itemRequest =
618  z_ext_record_xml(rr->stream, xml_in_response,
619  strlen(xml_in_response));
620  else
621  targetPart->itemRequest = 0;
622 
623  targetPart->statusOrErrorReport = 0;
624  targetPart->auxiliaryStatus = 0;
625  }
626  }
627  }
629  {
631  yaz_log(log_level, "Received DB Update");
632  if (up->which == Z_IUUpdate_esRequest)
633  {
634  Z_IUUpdateEsRequest *esRequest = up->u.esRequest;
635  Z_IUOriginPartToKeep *toKeep = esRequest->toKeep;
636  Z_IUSuppliedRecords *notToKeep = esRequest->notToKeep;
637 
638  yaz_log(log_level, "action");
639  if (toKeep->action)
640  {
641  switch (*toKeep->action)
642  {
644  yaz_log(log_level, " recordInsert");
645  break;
647  yaz_log(log_level, " recordReplace");
648  break;
650  yaz_log(log_level, " recordDelete");
651  break;
653  yaz_log(log_level, " elementUpdate");
654  break;
656  yaz_log(log_level, " specialUpdate");
657  break;
658  default:
659  yaz_log(log_level, " unknown (" ODR_INT_PRINTF ")",
660  *toKeep->action);
661  }
662  }
663  if (toKeep->databaseName)
664  {
665  yaz_log(log_level, "database: %s", toKeep->databaseName);
666  if (!strcmp(toKeep->databaseName, "fault"))
667  {
669  rr->errstring = toKeep->databaseName;
670  }
671  if (!strcmp(toKeep->databaseName, "accept"))
672  rr->errcode = -1;
673  }
674  if (toKeep)
675  {
676  Z_External *ext = (Z_External *)
677  odr_malloc(rr->stream, sizeof(*ext));
679  odr_malloc(rr->stream, sizeof(*keep));
680  Z_IUTargetPart *targetPart = (Z_IUTargetPart *)
681  odr_malloc(rr->stream, sizeof(*targetPart));
682 
683  rr->taskPackage = (Z_TaskPackage *)
684  odr_malloc(rr->stream, sizeof(*rr->taskPackage));
685  rr->taskPackage->packageType =
686  odr_oiddup(rr->stream, rr->esr->packageType);
687  rr->taskPackage->packageName = 0;
688  rr->taskPackage->userId = 0;
689  rr->taskPackage->retentionTime = 0;
690  rr->taskPackage->permissions = 0;
691  rr->taskPackage->description = 0;
693  odr_create_Odr_oct(rr->stream, "123", 3);
694  rr->taskPackage->creationDateTime = 0;
695  rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0);
698 
699  ext->direct_reference =
700  odr_oiddup(rr->stream, rr->esr->packageType);
701  ext->indirect_reference = 0;
702  ext->descriptor = 0;
703  ext->which = Z_External_update;
704  ext->u.update = (Z_IUUpdate *)
705  odr_malloc(rr->stream, sizeof(*ext->u.update));
709  ext->u.update->u.taskPackage->originPart = keep;
710  ext->u.update->u.taskPackage->targetPart = targetPart;
711 
712  keep->action = odr_intdup(rr->stream, *toKeep->action);
713  keep->databaseName =
714  odr_strdup(rr->stream, toKeep->databaseName);
715  keep->schema = 0;
716  keep->elementSetName = 0;
717  keep->actionQualifier = 0;
718 
719  targetPart->updateStatus = odr_intdup(rr->stream, 1);
720  targetPart->num_globalDiagnostics = 0;
721  targetPart->globalDiagnostics = (Z_DiagRec **) odr_nullval();
722  targetPart->num_taskPackageRecords = 1;
723  targetPart->taskPackageRecords =
725  odr_malloc(rr->stream,
727  targetPart->taskPackageRecords[0] =
729  odr_malloc(rr->stream,
731 
732  targetPart->taskPackageRecords[0]->which =
734  targetPart->taskPackageRecords[0]->u.record =
735  z_ext_record_sutrs(rr->stream, "test", 4);
736  targetPart->taskPackageRecords[0]->correlationInfo = 0;
737  targetPart->taskPackageRecords[0]->recordStatus =
738  odr_intdup(rr->stream,
741  = 0;
742 
743  targetPart->taskPackageRecords[0]->supplementalDiagnostics = 0;
744  }
745  if (notToKeep)
746  {
747  int i;
748  for (i = 0; i < notToKeep->num; i++)
749  {
750  Z_External *rec = notToKeep->elements[i]->record;
751 
752  if (rec->direct_reference)
753  {
754  char oid_name_str[OID_STR_MAX];
755  const char *oid_name
756  = oid_name = yaz_oid_to_string_buf(
757  rec->direct_reference, 0,
758  oid_name_str);
759  if (oid_name)
760  yaz_log(log_level, "record %d type %s", i,
761  oid_name);
762  }
763  switch (rec->which)
764  {
765  case Z_External_sutrs:
766  if (rec->u.octet_aligned->len > 170)
767  yaz_log(log_level, "%d bytes:\n%.168s ...",
768  rec->u.sutrs->len,
769  rec->u.sutrs->buf);
770  else
771  yaz_log(log_level, "%d bytes:\n%s",
772  rec->u.sutrs->len,
773  rec->u.sutrs->buf);
774  break;
775  case Z_External_octet :
776  if (rec->u.octet_aligned->len > 170)
777  yaz_log(log_level, "%d bytes:\n%.168s ...",
778  rec->u.octet_aligned->len,
779  rec->u.octet_aligned->buf);
780  else
781  yaz_log(log_level, "%d bytes\n%s",
782  rec->u.octet_aligned->len,
783  rec->u.octet_aligned->buf);
784  }
785  }
786  }
787  }
788  }
789  return 0;
790 }
791 
792 /* result set delete */
793 int ztest_delete(void *handle, bend_delete_rr *rr)
794 {
795  if (rr->num_setnames == 1 && !strcmp(rr->setnames[0], "1"))
797  else
799  return 0;
800 }
801 
802 /* Our sort handler really doesn't sort... */
803 int ztest_sort(void *handle, bend_sort_rr *rr)
804 {
805  rr->errcode = 0;
807  return 0;
808 }
809 
810 
811 /* present request handler */
812 int ztest_present(void *handle, bend_present_rr *rr)
813 {
814  struct session_handle *sh = (struct session_handle*) handle;
815  struct result_set *set = get_set(sh, rr->setname);
816 
817  if (!set)
818  {
820  rr->errstring = odr_strdup(rr->stream, rr->setname);
821  return 0;
822  }
823  do_delay(&set->present_delay);
824  return 0;
825 }
826 
827 /* retrieval of a single record (present, and piggy back search) */
828 int ztest_fetch(void *handle, bend_fetch_rr *r)
829 {
830  struct session_handle *sh = (struct session_handle*) handle;
831  char *cp;
832  const Odr_oid *oid = r->request_format;
833  struct result_set *set = get_set(sh, r->setname);
834  const char *esn = yaz_get_esn(r->comp);
835 
836  if (!set)
837  {
839  r->errstring = odr_strdup(r->stream, r->setname);
840  return 0;
841  }
842  do_delay(&set->fetch_delay);
843  r->last_in_set = 0;
844  r->basename = set->db;
846 
847  if (r->number < 1 || r->number > set->hits)
848  {
850  return 0;
851  }
852  if (!oid || yaz_oid_is_iso2709(oid))
853  {
854  cp = dummy_marc_record(r->number, r->stream);
855  if (!cp)
856  {
858  r->surrogate_flag = 1;
859  return 0;
860  }
861  else
862  {
863  r->len = strlen(cp);
864  r->record = cp;
866  }
867  }
868  else if (!oid_oidcmp(oid, yaz_oid_recsyn_opac))
869  {
870  cp = dummy_marc_record(r->number, r->stream);
871  if (!cp)
872  {
874  r->surrogate_flag = 1;
875  return 0;
876  }
877  r->record = (char *) dummy_opac(r->number, r->stream, cp);
878  r->len = -1;
879  }
880  else if (!oid_oidcmp(oid, yaz_oid_recsyn_sutrs))
881  {
882  /* this section returns a small record */
883  char buf[100];
884 
885  sprintf(buf, "This is dummy SUTRS record number %d\n", r->number);
886 
887  r->len = strlen(buf);
888  r->record = (char *) odr_malloc(r->stream, r->len+1);
889  strcpy(r->record, buf);
890  }
891  else if (!oid_oidcmp(oid, yaz_oid_recsyn_grs_1))
892  {
893  r->len = -1;
894  r->record = (char*) dummy_grs_record(r->number, r->stream);
895  if (!r->record)
896  {
898  r->surrogate_flag = 1;
899  return 0;
900  }
901  }
902  else if (!oid_oidcmp(oid, yaz_oid_recsyn_postscript))
903  {
904  char fname[20];
905  FILE *f;
906  long size;
907 
908  sprintf(fname, "part.%d.ps", r->number);
909  f = fopen(fname, "rb");
910  if (!f)
911  {
913  r->surrogate_flag = 1;
914  return 0;
915  }
916  fseek(f, 0L, SEEK_END);
917  size = ftell(f);
918  if (size <= 0 || size >= 5000000)
919  {
921  r->surrogate_flag = 1;
922  }
923  fseek(f, 0L, SEEK_SET);
924  r->record = (char*) odr_malloc(r->stream, size);
925  r->len = size;
926  if (fread(r->record, size, 1, f) != 1)
927  {
929  r->surrogate_flag = 1;
930  }
931  fclose(f);
932  }
933  else if (!oid_oidcmp(oid, yaz_oid_recsyn_xml))
934  {
935  if ((cp = dummy_xml_record(r->number, r->stream, esn)))
936  {
937  r->len = strlen(cp);
938  r->record = cp;
939  r->schema = "info:srw/schema/1/marcxml-1.1";
940  }
941  else
942  {
944  r->surrogate_flag = 1;
945  return 0;
946  }
947  }
948  else if (!oid_oidcmp(oid, yaz_oid_recsyn_json))
949  {
950  if ((cp = dummy_json_record(r->number, r->stream, esn)))
951  {
952  r->len = strlen(cp);
953  r->record = cp;
954  r->schema = "info:srw/schema/1/marcxml-1.1";
955  }
956  else
957  {
959  r->surrogate_flag = 1;
960  return 0;
961  }
962  }
963  else
964  {
965  char buf[OID_STR_MAX];
967  r->errstring = odr_strdup(r->stream, oid_oid_to_dotstring(oid, buf));
968  return 0;
969  }
970  r->errcode = 0;
971  return 0;
972 }
973 
974 /*
975  * silly dummy-scan what reads words from a file.
976  */
977 int ztest_scan(void *handle, bend_scan_rr *q)
978 {
979  static FILE *f = 0;
980  static struct scan_entry list[200];
981  static char entries[200][80];
982  int hits[200];
983  char term[80], *p;
984  int i, pos;
985  int term_position_req = q->term_position;
986  int num_entries_req = q->num_entries;
987 
988  /* Throw Database unavailable if other than Default or Slow */
989  if (!yaz_matchstr(q->basenames[0], "Default"))
990  ; /* Default is OK in our test */
991  else if (check_slow(q->basenames[0], 0 /* no assoc for scan */))
992  ;
993  else
994  {
996  q->errstring = q->basenames[0];
997  return 0;
998  }
999 
1000  q->errcode = 0;
1001  q->errstring = 0;
1002  q->entries = list;
1004  if (!f && !(f = fopen("dummy-words", "r")))
1005  {
1006  perror("dummy-words");
1007  exit(1);
1008  }
1009  if (q->num_entries > 200)
1010  {
1012  return 0;
1013  }
1014  if (q->term)
1015  {
1016  int len;
1017  if (q->term->term->which != Z_Term_general)
1018  {
1020  return 0;
1021  }
1022  if (*q->step_size != 0)
1023  {
1025  return 0;
1026  }
1027  len = q->term->term->u.general->len;
1028  if (len >= (int ) sizeof(term))
1029  len = sizeof(term)-1;
1030  memcpy(term, q->term->term->u.general->buf, len);
1031  term[len] = '\0';
1032  }
1033  else if (q->scanClause)
1034  {
1035  strncpy(term, q->scanClause, sizeof(term)-1);
1036  term[sizeof(term)-1] = '\0';
1037  }
1038  else
1039  strcpy(term, "0");
1040 
1041  for (p = term; *p; p++)
1042  if (yaz_islower(*p))
1043  *p = yaz_toupper(*p);
1044 
1045  fseek(f, 0, SEEK_SET);
1046  q->num_entries = 0;
1047 
1048  for (i = 0, pos = 0; fscanf(f, " %79[^:]:%d", entries[pos], &hits[pos]) == 2;
1049  i++, pos < 199 ? pos++ : (pos = 0))
1050  {
1051  if (!q->num_entries && strcmp(entries[pos], term) >= 0) /* s-point fnd */
1052  {
1053  if ((q->term_position = term_position_req) > i + 1)
1054  {
1055  q->term_position = i + 1;
1057  }
1058  for (; q->num_entries < q->term_position; q->num_entries++)
1059  {
1060  int po;
1061 
1062  po = pos - q->term_position + q->num_entries+1; /* find pos */
1063  if (po < 0)
1064  po += 200;
1065 
1066  if (!strcmp(term, "SD") && q->num_entries == 2)
1067  {
1068  list[q->num_entries].term = entries[pos];
1069  list[q->num_entries].occurrences = -1;
1070  list[q->num_entries].errcode =
1072  list[q->num_entries].errstring = "SD for Scan Term";
1073  }
1074  else
1075  {
1076  list[q->num_entries].term = entries[po];
1077  list[q->num_entries].occurrences = hits[po];
1078  }
1079  }
1080  }
1081  else if (q->num_entries)
1082  {
1083  list[q->num_entries].term = entries[pos];
1084  list[q->num_entries].occurrences = hits[pos];
1085  q->num_entries++;
1086  }
1087  if (q->num_entries >= num_entries_req)
1088  break;
1089  }
1091  if (feof(f))
1093  return 0;
1094 }
1095 
1096 int ztest_explain(void *handle, bend_explain_rr *rr)
1097 {
1098  if (rr->database && !strcmp(rr->database, "Default"))
1099  {
1100  rr->explain_buf = "<explain>\n"
1101  "\t<serverInfo>\n"
1102  "\t\t<host>localhost</host>\n"
1103  "\t\t<port>210</port>\n"
1104  "\t</serverInfo>\n"
1105  "</explain>\n";
1106  }
1107  return 0;
1108 }
1109 
1110 int ztest_update(void *handle, bend_update_rr *rr)
1111 {
1112  rr->operation_status = "success";
1113  return 0;
1114 }
1115 
1117 {
1119  odr_malloc(q->stream, sizeof(*r));
1120  struct session_handle *sh = xmalloc(sizeof(*sh));
1121 
1122  sh->result_sets = 0;
1123 
1124  if (!log_level_set)
1125  {
1127  log_level_set=1;
1128  }
1129 
1130  r->errcode = 0;
1131  r->errstring = 0;
1132  r->handle = sh; /* tell GFS about our handle */
1133  q->bend_sort = ztest_sort; /* register sort handler */
1134  q->bend_search = ztest_search; /* register search handler */
1135  q->bend_present = ztest_present; /* register present handle */
1138  q->bend_fetch = ztest_fetch;
1139  q->bend_scan = ztest_scan;
1140 #if 0
1142 #endif
1145 
1146  q->query_charset = "ISO-8859-1";
1147  q->records_in_same_charset = 0;
1148  q->named_result_sets = 1;
1149 
1150  return r;
1151 }
1152 
1153 void bend_close(void *handle)
1154 {
1155  struct session_handle *sh = (struct session_handle*) handle;
1156  remove_sets(sh);
1157  xfree(sh); /* release our session */
1158  return;
1159 }
1160 
1161 int main(int argc, char **argv)
1162 {
1163  yaz_enable_panic_backtrace(argv[0]);
1164 
1165  return statserv_main(argc, argv, bend_init, bend_close);
1166 }
1167 /*
1168  * Local variables:
1169  * c-basic-offset: 4
1170  * c-file-style: "Stroustrup"
1171  * indent-tabs-mode: nil
1172  * End:
1173  * vim: shiftwidth=4 tabstop=8 expandtab
1174  */
1175 
Z_TaskPackage * taskPackage
Definition: backend.h:222
Z_Operand * simple
Definition: z-core.h:502
int ztest_sort(void *handle, bend_sort_rr *rr)
Definition: ztest.c:803
const Odr_oid yaz_oid_recsyn_usmarc[]
Definition: oid_std.c:43
Z_OtherInformation * build_facet_response(ODR odr, Z_FacetList *facet_list)
Definition: ztest.c:271
char * db
Definition: ztest.c:50
#define Z_DeleteStatus_resultSetDidNotExist
Definition: z-core.h:851
char ** setnames
Definition: backend.h:185
const Odr_oid yaz_oid_recsyn_grs_1[]
Definition: oid_std.c:72
int num_globalDiagnostics
Definition: zes-update.h:97
int errcode
Definition: backend.h:150
int ztest_scan(void *handle, bend_scan_rr *q)
Definition: ztest.c:977
int surrogate_flag
Definition: backend.h:114
int which
Definition: z-core.h:510
char * buf
Definition: odr.h:101
int ztest_explain(void *handle, bend_explain_rr *rr)
Definition: ztest.c:1096
char * errstring
Definition: backend.h:151
Z_IUOriginPartToKeep * toKeep
Definition: zes-update.h:58
Z_OtherInformation * search_info
Definition: backend.h:69
Z_Permissions * permissions
Definition: z-estask.h:29
Z_AttributeList * attributes
Definition: z-facet-1.h:36
char * term
Definition: backend.h:120
Z_OtherInformation * search_input
Definition: backend.h:77
bend_association association
Definition: backend.h:65
Z_ItemOrder * itemOrder
Definition: prt-ext.h:118
#define YLOG_DEBUG
log level: debugging
Definition: log.h:44
void yaz_facet_attr_get_z_attributes(const Z_AttributeList *attributes, struct yaz_facet_attr *av)
Definition: facet.c:147
Z_InternationalString * elementSetName
Definition: zes-update.h:86
#define Z_Term_general
Definition: z-core.h:547
Z_IUUpdateTaskPackage * taskPackage
Definition: zes-update.h:71
Z_Complex * complex
Definition: z-core.h:503
backtrace handling
int records_in_same_charset
whether query_charset also applies to records
Definition: backend.h:286
const Odr_oid yaz_oid_recsyn_postscript[]
Definition: oid_std.c:76
const Odr_oid yaz_oid_recsyn_opac[]
Definition: oid_std.c:69
#define Z_IUOriginPartToKeep_recordInsert
Definition: zes-update.h:78
char * errstring
Definition: backend.h:68
#define Z_IUOriginPartToKeep_elementUpdate
Definition: zes-update.h:81
#define Z_SortResponse_success
Definition: z-core.h:1046
const Odr_oid yaz_oid_recsyn_sutrs[]
Definition: oid_std.c:68
char * odr_strdup(ODR o, const char *str)
Definition: odr_mem.c:36
#define Z_IUUpdate_esRequest
Definition: zes-update.h:72
int(* bend_search)(void *handle, bend_search_rr *rr)
SRU/Z39.50 search handler.
Definition: backend.h:295
int ztest_delete(void *handle, bend_delete_rr *rr)
Definition: ztest.c:793
Z_External * itemRequest
Definition: zes-order.h:122
static Odr_int get_hit_count(Z_Query *q)
gets hit count for numeric terms in RPN queries
Definition: ztest.c:146
int odr_offset(ODR o)
Definition: odr.c:285
Z_RPNStructure * s2
Definition: z-core.h:495
Z_InfoCategory * category
Definition: z-core.h:1280
#define Z_Query_type_1
Definition: z-core.h:479
char * errstring
Definition: backend.h:94
#define Z_External_CQL
Definition: prt-ext.h:93
Z_IOTaskPackage * taskPackage
Definition: zes-order.h:65
char * record
Definition: backend.h:109
int replace_set
Definition: backend.h:56
int start
Definition: facet.h:62
#define yaz_toupper(x)
Definition: yaz-iconv.h:88
const char * wrbuf_cstr(WRBUF b)
returns WRBUF content as C-string
Definition: wrbuf.c:281
#define Z_IUUpdate_taskPackage
Definition: zes-update.h:73
int ztest_present(void *handle, bend_present_rr *rr)
Definition: ztest.c:812
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_InternationalString * userId
Definition: z-estask.h:27
Odr_oid * direct_reference
Definition: prt-ext.h:60
Odr_int * item
Definition: zes-order.h:113
int yaz_oid_is_iso2709(const Odr_oid *oid)
checks if OID refers to MARC transfer syntax
Definition: oid_db.c:119
Z_IUOriginPartToKeep * originPart
Definition: zes-update.h:63
#define YAZ_BIB1_RESOURCES_EXHAUSTED_NO_RESULTS_AVAILABLE
Definition: diagbib1.h:41
ILL Package utilities.
Z_SRW_extra_arg * extra_args
Definition: backend.h:75
int oid_oidcmp(const Odr_oid *o1, const Odr_oid *o2)
compares OIDs
Definition: oid_util.c:34
char * name
Definition: initopt.c:18
Z_Query * query
Definition: backend.h:60
char * errstring
Definition: backend.h:221
void wrbuf_puts(WRBUF b, const char *buf)
appends C-string to WRBUF
Definition: wrbuf.c:89
Odr_oid * output_format
Definition: backend.h:111
Z_InternationalString * email
Definition: zes-order.h:74
static void ztest_sleep(double d)
Definition: ztest.c:228
Z_RPNStructure * RPNStructure
Definition: z-core.h:490
static void remove_sets(struct session_handle *sh)
Definition: ztest.c:77
Odr_oid * packageType
Definition: z-estask.h:25
static int log_level
Definition: ztest.c:40
#define xstrdup(s)
utility macro which calls xstrdup_f
Definition: xmalloc.h:55
Information for SRU record update handler.
Definition: backend.h:159
result for init handler (must be filled by handler)
Definition: backend.h:320
short Odr_oid
Definition: oid_util.h:42
int num_entries
Definition: backend.h:144
int(* bend_delete)(void *handle, bend_delete_rr *rr)
Z39.50 delete result set handler.
Definition: backend.h:303
int errcode
Definition: backend.h:122
#define Z_Query_type_101
Definition: z-core.h:482
nmem_int_t Odr_int
Definition: odr.h:47
#define Z_IUOriginPartToKeep_recordReplace
Definition: zes-update.h:79
static void echo_extra_args(ODR stream, Z_SRW_extra_arg *extra_args, char **extra_response)
Definition: ztest.c:318
char * errstring
Definition: backend.h:123
Z_InternationalString * resultSetId
Definition: zes-order.h:112
Information for SRU / Z39.50 scan handler.
Definition: backend.h:133
const char * yaz_get_esn(Z_RecordComposition *comp)
get element set name from RecordComposition
Definition: elementset.c:16
Z_External * statusOrErrorReport
Definition: zes-order.h:123
void wrbuf_write(WRBUF b, const char *buf, size_t size)
append constant size buffer to WRBUF
Definition: wrbuf.c:68
Z_GenericRecord * dummy_grs_record(int num, ODR o)
Definition: read-grs.c:100
#define YLOG_LOG
log level: log (regular)
Definition: log.h:48
string buffer
Definition: wrbuf.h:42
Z_IOTargetPart * targetPart
Definition: zes-order.h:58
Z_IUOriginPartNotToKeep * notToKeep
Definition: zes-update.h:59
int named_result_sets
whether named result sets are supported (0=disable, 1=enable)
Definition: backend.h:316
Z_InternationalString * packageName
Definition: z-core.h:1126
static int parse_delay(struct delay *delayp, const char *value)
Definition: ztest.c:217
Z_FacetList * facet_list_create(ODR odr, int num_facets)
Definition: facet.c:215
Z_AttributesPlusTerm * attributesPlusTerm
Definition: z-core.h:512
Information for the Init handler.
Definition: backend.h:251
Z_External * type_104
Definition: z-core.h:477
#define Z_External_userFacets
Definition: prt-ext.h:100
#define Z_Query_type_104
Definition: z-core.h:484
void * odr_malloc(ODR o, size_t size)
Definition: odr_mem.c:31
Z_RPNQuery * type_1
Definition: z-core.h:472
ODR stream
encoding stream (for results)
Definition: backend.h:256
int(* bend_scan)(void *handle, bend_scan_rr *rr)
Z39.50 scan handler.
Definition: backend.h:305
int num_terms
Definition: z-facet-1.h:37
int(* bend_esrequest)(void *handle, bend_esrequest_rr *rr)
Z39.50 extended services handler.
Definition: backend.h:301
#define YAZ_BIB1_SCAN_UNSUPP_VALUE_OF_POSITION_IN_RESPONSE
Definition: diagbib1.h:108
#define Z_RPNStructure_complex
Definition: z-core.h:505
const Odr_oid yaz_oid_recsyn_xml[]
Definition: oid_std.c:89
Odr_oid * request_format
Definition: backend.h:102
Odr_oct * general
Definition: z-core.h:539
int ztest_update(void *handle, bend_update_rr *rr)
Definition: ztest.c:1110
Z_IntUnit * retentionTime
Definition: z-estask.h:28
Information for fetch record handler.
Definition: backend.h:98
static void addterms(ODR odr, Z_FacetField *facet_field, const char *facet_name)
Definition: ztest.c:252
Odr_int * taskStatus
Definition: z-estask.h:37
union Z_External::@30 u
int(* bend_explain)(void *handle, bend_explain_rr *rr)
SRU explain handler.
Definition: backend.h:309
Z_IUSuppliedRecords_elem ** elements
Definition: zes-update.h:132
int which
Definition: prt-ext.h:63
char * oid_oid_to_dotstring(const Odr_oid *oid, char *oidbuf)
converts OID to string (dot notation)
Definition: oid_util.c:59
void facet_field_term_set(ODR odr, Z_FacetField *field, Z_FacetTerm *facet_term, int index)
Definition: facet.c:208
Z_IUUpdate * update
Definition: prt-ext.h:125
void bend_close(void *handle)
Definition: ztest.c:1153
#define Z_IOItemOrder_taskPackage
Definition: zes-order.h:67
int(* bend_present)(void *handle, bend_present_rr *rr)
SRU/Z39.50 present handler.
Definition: backend.h:299
Information for Z39.50 extended services handler.
Definition: backend.h:210
int which
Definition: z-core.h:537
int odr_geterror(ODR o)
Definition: odr.c:78
Header for Z39.50 OtherInfo utilities.
Z_IOOriginPartNotToKeep * notToKeep
Definition: zes-order.h:53
char * dummy_xml_record(int num, ODR odr, const char *esn)
Definition: read-marc.c:1667
Odr_null * odr_nullval(void)
Definition: odr.c:30
Definition: ztest.c:43
#define YAZ_BIB1_RESULT_SET_EXISTS_AND_REPLACE_INDICATOR_OFF
Definition: diagbib1.h:31
#define YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS
Definition: diagbib1.h:24
Z_InternationalString * packageName
Definition: z-estask.h:26
int estimated_hit_count
Definition: backend.h:73
struct result_set * result_sets
Definition: ztest.c:59
static int strcmp_prefix(const char *s, const char *p)
Definition: ztest.c:204
struct delay fetch_delay
Definition: ztest.c:54
void odr_setbuf(ODR o, char *buf, int len, int can_grow)
Definition: odr.c:267
char * basename
Definition: backend.h:107
#define YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE
Definition: diagbib1.h:23
struct scan_entry * entries
Definition: backend.h:148
void odr_reset(ODR o)
Definition: odr.c:226
Z_IUUpdateEsRequest * esRequest
Definition: zes-update.h:70
int which
Definition: z-core.h:469
char * dummy_marc_record(int num, ODR odr)
Definition: read-marc.c:1582
char * errstring
Definition: facet.h:55
bend_initresult * bend_init(bend_initrequest *q)
Definition: ztest.c:1116
#define xfree(x)
utility macro which calls xfree_f
Definition: xmalloc.h:53
Z_External * itemRequest
Definition: zes-order.h:118
char * database
Definition: backend.h:240
Information for Z39.50 delete result set handler.
Definition: backend.h:182
Odr_any * single_ASN1_type
Definition: prt-ext.h:104
struct delay present_delay
Definition: ztest.c:53
char * query_charset
character set (encoding) for query terms
Definition: backend.h:279
Z_External * z_ext_record_xml(ODR o, const char *buf, int len)
encodes EXTERNAL XML record
Definition: prt-ext.c:368
static struct result_set * get_set(struct session_handle *sh, const char *name)
Definition: ztest.c:68
Z_FacetField * facet_field_create(ODR odr, Z_AttributeList *attributes, int num_terms)
Definition: facet.c:198
char * extra_response_data
Definition: backend.h:76
void wrbuf_destroy(WRBUF b)
destroy WRBUF and its buffer
Definition: wrbuf.c:38
Internal header for yaz-ztest.
static int log_level_set
Definition: ztest.c:41
Z_External * externallyDefinedInfo
Definition: z-core.h:1285
#define YAZ_BIB1_TERM_TYPE_UNSUPP
Definition: diagbib1.h:104
char * descriptor
Definition: prt-ext.h:62
struct delay search_delay
Definition: ztest.c:52
Odr_int * auxiliaryStatus
Definition: zes-order.h:129
int delete_status
Definition: backend.h:187
Z_IORequest * esRequest
Definition: zes-order.h:64
union Z_Query::@48 u
Z_IUCorrelationInfo * correlationInfo
Definition: zes-update.h:153
Information for SRU Explain handler.
Definition: backend.h:235
char * explain_buf
Definition: backend.h:239
int term_position
Definition: backend.h:143
int ztest_esrequest(void *handle, bend_esrequest_rr *rr)
Definition: ztest.c:448
Z_ExtendedServicesRequest * esr
Definition: backend.h:213
int odr_dumpBER(FILE *f, const char *buf, int len)
Definition: dumpber.c:129
static void do_delay(const struct delay *delayp)
Definition: ztest.c:240
Odr_int hits
Definition: ztest.c:51
char * operation_status
Definition: backend.h:166
Odr_oct * targetReference
Definition: z-estask.h:31
Definition: odr.h:99
union Z_IUTaskPackageRecordStructure::@130 u
Header for the facet utilities.
#define YAZ_BIB1_DATABASE_UNAVAILABLE
Definition: diagbib1.h:53
#define OID_STR_MAX
Definition: oid_util.h:40
double d2
Definition: ztest.c:45
char * errstring
Definition: backend.h:323
Information for Z39.50/SRU search handler.
Definition: backend.h:54
static int check_slow(const char *basename, bend_association association)
checks if it&#39;s a dummy Slow database
Definition: ztest.c:180
Odr_int * updateStatus
Definition: zes-update.h:96
Odr_int * indirect_reference
Definition: prt-ext.h:61
#define Z_DeleteStatus_success
Definition: z-core.h:850
int(* bend_fetch)(void *handle, bend_fetch_rr *rr)
SRU/Z39.50 fetch handler.
Definition: backend.h:297
Z_SRW_extra_arg * next
Definition: srw.h:175
#define ODR_INT_PRINTF
Definition: odr.h:49
Z_InternationalString * description
Definition: z-estask.h:30
Z_DiagRec ** globalDiagnostics
Definition: zes-update.h:98
char * odr_errmsg(int n)
Definition: odr.c:52
#define Z_IOItemOrder_esRequest
Definition: zes-order.h:66
Z_InternationalString * databaseName
Definition: zes-update.h:84
Z_RecordComposition * comp
Definition: backend.h:103
Odr_int * odr_intdup(ODR o, Odr_int v)
Definition: odr_mem.c:51
int(* bend_srw_scan)(void *handle, bend_scan_rr *rr)
SRU scan handler.
Definition: backend.h:311
int main(int argc, char **argv)
Definition: ztest.c:1161
int ill_APDU(ODR o, ILL_APDU **p, int opt, const char *name)
Definition: ill-core.c:12
char * setname
Definition: backend.h:83
char * dummy_json_record(int num, ODR odr, const char *esn)
Definition: read-marc.c:1725
int(* bend_sort)(void *handle, bend_sort_rr *rr)
Z39.50 sort handler.
Definition: backend.h:293
Definition: odr.h:124
Z_FacetList * facetList
Definition: prt-ext.h:146
int(* bend_srw_update)(void *handle, bend_update_rr *rr)
SRU record update handler.
Definition: backend.h:313
#define YAZ_BIB1_ONLY_ZERO_STEP_SIZE_SUPPORTED_FOR_SCAN
Definition: diagbib1.h:80
int num_setnames
Definition: backend.h:184
#define yaz_islower(x)
Definition: yaz-iconv.h:91
int ztest_fetch(void *handle, bend_fetch_rr *r)
Definition: ztest.c:828
const Odr_oid yaz_oid_recsyn_json[]
Definition: oid_std.c:88
char * setname
Definition: backend.h:99
const char * useattr
Definition: facet.h:56
#define Z_Operand_APT
Definition: z-core.h:515
int yaz_uri_to_array(const char *path, ODR o, char ***name, char ***val)
Definition: uri.c:121
Z_DiagRec ** supplementalDiagnostics
Definition: zes-update.h:160
oid_class
Definition: oid_db.h:45
int yaz_matchstr(const char *s1, const char *s2)
match strings - independent of case and &#39;-&#39;
Definition: matchstr.c:42
#define Z_IUOriginPartToKeep_recordDelete
Definition: zes-update.h:80
bend_scan_status status
Definition: backend.h:149
double d1
Definition: ztest.c:44
void yaz_facet_attr_init(struct yaz_facet_attr *attr_values)
Definition: facet.c:68
Z_InternationalString * name
Definition: zes-order.h:72
static void init_delay(struct delay *delayp)
Definition: ztest.c:212
union Z_RPNStructure::@49 u
Z_DiagRec ** packageDiagnostics
Definition: z-estask.h:39
#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
#define Z_External_octet
Definition: prt-ext.h:66
char ** basenames
Definition: backend.h:135
Z_External * taskSpecificParameters
Definition: z-estask.h:40
FILE * yaz_log_file(void)
returns FILE handle for log or NULL if no file is in use
Definition: log.c:136
Z_SRW_extra_arg * extra_args
Definition: backend.h:154
union Z_OtherInformationUnit::@74 information
char * name
Definition: srw.h:173
structure for all known EXTERNALs
Definition: prt-ext.h:58
#define Z_OtherInfo_externallyDefinedInfo
Definition: z-core.h:1289
int * step_size
Definition: backend.h:142
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
char ** basenames
Definition: backend.h:58
#define YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP
Definition: diagbib1.h:33
int num_taskPackageRecords
Definition: zes-update.h:99
#define YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST
Definition: diagbib1.h:40
#define Z_IUTaskPackageRecordStructure_success
Definition: zes-update.h:154
union Z_IOItemOrder::@118 u
Z_External * z_ext_record_sutrs(ODR o, const char *buf, int len)
encodes EXTERNAL SUTRS record
Definition: prt-ext.c:373
int ztest_search(void *handle, bend_search_rr *rr)
Definition: ztest.c:346
Odr_int occurrences
Definition: backend.h:121
#define ODR_EXTERNAL_single
Definition: odr.h:299
Z_External * actionQualifier
Definition: zes-update.h:87
Z_IOOriginPartToKeep * originPart
Definition: zes-order.h:57
Z_FacetTerm * facet_term_create_cstr(ODR odr, const char *cstr, Odr_int freq)
Definition: facet.c:189
const Odr_oid yaz_oid_general_isoill_1[]
Definition: oid_std.c:10
Z_FacetList * yaz_oi_get_facetlist(Z_OtherInformation **otherInformation)
Definition: facet.c:44
char * name
Definition: ztest.c:49
int yaz_log_module_level(const char *name)
returns level for module
Definition: log.c:584
int sort_status
Definition: backend.h:204
Odr_int odr_atoi(const char *s)
Definition: odr_mem.c:146
Z_AttributesPlusTerm * term
Definition: backend.h:138
Z_OPACRecord * dummy_opac(int num, ODR odr, const char *marc_input)
Definition: dummy-opac.c:18
#define Z_RPNStructure_simple
Definition: z-core.h:504
Z_InternationalString * cql
Definition: prt-ext.h:138
char * extra_response_data
Definition: backend.h:155
char * scanClause
Definition: backend.h:152
union Z_Operand::@50 u
void wrbuf_xmlputs(WRBUF b, const char *cp)
writes C-String to WRBUF and XML encode (as CDATA)
Definition: wrbuf.c:138
Z_SUTRS * sutrs
Definition: prt-ext.h:109
char * schema
Definition: backend.h:115
#define Z_External_sutrs
Definition: prt-ext.h:69
#define YAZ_BIB1_SERVICE_UNSUPP_FOR_THIS_DATABASE
Definition: diagbib1.h:147
static Odr_int get_term_hit(Z_RPNStructure *s, unsigned *hash)
use term value as hit count
Definition: ztest.c:100
Header for GFS.
#define YAZ_BIB1_RECORD_SYNTAX_UNSUPP
Definition: diagbib1.h:114
Logging utility.
const Odr_oid yaz_oid_userinfo_facet_1[]
Definition: oid_std.c:118
Z_IUTargetPart * targetPart
Definition: zes-update.h:64
Z_External * taskSpecificParameters
Definition: z-core.h:1131
Odr_int hits
Definition: backend.h:66
#define Z_External_itemOrder
Definition: prt-ext.h:76
Information for Z39.50 sort handler.
Definition: backend.h:194
int sortorder
Definition: facet.h:60
Z_OtherInformationUnit ** list
Definition: z-core.h:1296
#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
Odr_oct * octet_aligned
Definition: prt-ext.h:105
int limit
Definition: facet.h:61
Z_IOContact * contact
Definition: zes-order.h:101
char * value
Definition: srw.h:174
struct result_set * next
Definition: ztest.c:55
void yaz_enable_panic_backtrace(const char *progname)
enables backtrace when SIGSEGV/SIGABRT/.. signal is received
Definition: backtrace.c:190
WRBUF wrbuf_alloc(void)
construct WRBUF
Definition: wrbuf.c:25
Z_IOOriginPartToKeep * toKeep
Definition: zes-order.h:52
Z_IOResultSetItem * resultSetItem
Definition: zes-order.h:117
int errcode
Definition: backend.h:205
char * setname
Definition: backend.h:55
char * errstring
Definition: backend.h:113
void * handle
Definition: backend.h:324
Diagnostics: Generated by csvtodiag.tcl from ./bib1.csv.
int bend_assoc_is_alive(bend_association assoc)
Definition: seshigh.c:3514
#define Z_IUTaskPackageRecordStructure_record
Definition: zes-update.h:150
Information for scan entry.
Definition: backend.h:119
int last_in_set
Definition: backend.h:110
Z_IUTaskPackageRecordStructure ** taskPackageRecords
Definition: zes-update.h:100
Z_RPNStructure * s1
Definition: z-core.h:494
Information for present handler. Does not replace bend_fetch.
Definition: backend.h:82
union Z_Term::@51 u
char * creationDateTime
Definition: z-estask.h:32
int ill_ItemRequest(ODR o, ILL_ItemRequest **p, int opt, const char *name)
Definition: item-req.c:12
int statserv_main(int argc, char **argv, bend_initresult *(*bend_init)(bend_initrequest *r), void(*bend_close)(void *handle))
Definition: statserv.c:1504
int num_bases
Definition: backend.h:57
ODR stream
Definition: backend.h:139
#define Z_External_update
Definition: prt-ext.h:82
int len
Definition: odr.h:102
Z_IOBilling * addlBilling
Definition: zes-order.h:102