YAZ  5.26.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 Update0");
632  Z_IU0UpdateEsRequest *esRequest = up->u.esRequest;
633  Z_IU0OriginPartToKeep *toKeep = esRequest->toKeep;
634  if (toKeep->action)
635  {
636  yaz_log(log_level, "action " ODR_INT_PRINTF, *toKeep->action);
637  }
638  rr->errcode = -2;
639  rr->errstring= "xxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyy";
640  }
642  {
644  yaz_log(log_level, "Received DB Update");
645  if (up->which == Z_IUUpdate_esRequest)
646  {
647  Z_IUUpdateEsRequest *esRequest = up->u.esRequest;
648  Z_IUOriginPartToKeep *toKeep = esRequest->toKeep;
649  Z_IUSuppliedRecords *notToKeep = esRequest->notToKeep;
650 
651  yaz_log(log_level, "action");
652  if (toKeep->action)
653  {
654  switch (*toKeep->action)
655  {
657  yaz_log(log_level, " recordInsert");
658  break;
660  yaz_log(log_level, " recordReplace");
661  break;
663  yaz_log(log_level, " recordDelete");
664  break;
666  yaz_log(log_level, " elementUpdate");
667  break;
669  yaz_log(log_level, " specialUpdate");
670  break;
671  default:
672  yaz_log(log_level, " unknown (" ODR_INT_PRINTF ")",
673  *toKeep->action);
674  }
675  }
676  if (toKeep->databaseName)
677  {
678  yaz_log(log_level, "database: %s", toKeep->databaseName);
679  if (!strcmp(toKeep->databaseName, "fault"))
680  {
682  rr->errstring = toKeep->databaseName;
683  }
684  if (!strcmp(toKeep->databaseName, "accept"))
685  rr->errcode = -1;
686  }
687  if (toKeep)
688  {
689  Z_External *ext = (Z_External *)
690  odr_malloc(rr->stream, sizeof(*ext));
692  odr_malloc(rr->stream, sizeof(*keep));
693  Z_IUTargetPart *targetPart = (Z_IUTargetPart *)
694  odr_malloc(rr->stream, sizeof(*targetPart));
695 
696  rr->taskPackage = (Z_TaskPackage *)
697  odr_malloc(rr->stream, sizeof(*rr->taskPackage));
698  rr->taskPackage->packageType =
699  odr_oiddup(rr->stream, rr->esr->packageType);
700  rr->taskPackage->packageName = 0;
701  rr->taskPackage->userId = 0;
702  rr->taskPackage->retentionTime = 0;
703  rr->taskPackage->permissions = 0;
704  rr->taskPackage->description = 0;
706  odr_create_Odr_oct(rr->stream, "123", 3);
707  rr->taskPackage->creationDateTime = 0;
708  rr->taskPackage->taskStatus = odr_intdup(rr->stream, 0);
711 
712  ext->direct_reference =
713  odr_oiddup(rr->stream, rr->esr->packageType);
714  ext->indirect_reference = 0;
715  ext->descriptor = 0;
716  ext->which = Z_External_update;
717  ext->u.update = (Z_IUUpdate *)
718  odr_malloc(rr->stream, sizeof(*ext->u.update));
722  ext->u.update->u.taskPackage->originPart = keep;
723  ext->u.update->u.taskPackage->targetPart = targetPart;
724 
725  keep->action = odr_intdup(rr->stream, *toKeep->action);
726  keep->databaseName =
727  odr_strdup(rr->stream, toKeep->databaseName);
728  keep->schema = 0;
729  keep->elementSetName = 0;
730  keep->actionQualifier = 0;
731 
732  targetPart->updateStatus = odr_intdup(rr->stream, 1);
733  targetPart->num_globalDiagnostics = 0;
734  targetPart->globalDiagnostics = (Z_DiagRec **) odr_nullval();
735  targetPart->num_taskPackageRecords = 1;
736  targetPart->taskPackageRecords =
738  odr_malloc(rr->stream,
740  targetPart->taskPackageRecords[0] =
742  odr_malloc(rr->stream,
744 
745  targetPart->taskPackageRecords[0]->which =
747  targetPart->taskPackageRecords[0]->u.record =
748  z_ext_record_sutrs(rr->stream, "test", 4);
749  targetPart->taskPackageRecords[0]->correlationInfo = 0;
750  targetPart->taskPackageRecords[0]->recordStatus =
751  odr_intdup(rr->stream,
754  = 0;
755 
756  targetPart->taskPackageRecords[0]->supplementalDiagnostics = 0;
757  }
758  if (notToKeep)
759  {
760  int i;
761  for (i = 0; i < notToKeep->num; i++)
762  {
763  Z_External *rec = notToKeep->elements[i]->record;
764 
765  if (rec->direct_reference)
766  {
767  char oid_name_str[OID_STR_MAX];
768  const char *oid_name
769  = oid_name = yaz_oid_to_string_buf(
770  rec->direct_reference, 0,
771  oid_name_str);
772  if (oid_name)
773  yaz_log(log_level, "record %d type %s", i,
774  oid_name);
775  }
776  switch (rec->which)
777  {
778  case Z_External_sutrs:
779  if (rec->u.octet_aligned->len > 170)
780  yaz_log(log_level, "%d bytes:\n%.168s ...",
781  rec->u.sutrs->len,
782  rec->u.sutrs->buf);
783  else
784  yaz_log(log_level, "%d bytes:\n%s",
785  rec->u.sutrs->len,
786  rec->u.sutrs->buf);
787  break;
788  case Z_External_octet :
789  if (rec->u.octet_aligned->len > 170)
790  yaz_log(log_level, "%d bytes:\n%.168s ...",
791  rec->u.octet_aligned->len,
792  rec->u.octet_aligned->buf);
793  else
794  yaz_log(log_level, "%d bytes\n%s",
795  rec->u.octet_aligned->len,
796  rec->u.octet_aligned->buf);
797  }
798  }
799  }
800  }
801  }
802  return 0;
803 }
804 
805 /* result set delete */
806 int ztest_delete(void *handle, bend_delete_rr *rr)
807 {
808  if (rr->num_setnames == 1 && !strcmp(rr->setnames[0], "1"))
810  else
812  return 0;
813 }
814 
815 /* Our sort handler really doesn't sort... */
816 int ztest_sort(void *handle, bend_sort_rr *rr)
817 {
818  rr->errcode = 0;
820  return 0;
821 }
822 
823 
824 /* present request handler */
825 int ztest_present(void *handle, bend_present_rr *rr)
826 {
827  struct session_handle *sh = (struct session_handle*) handle;
828  struct result_set *set = get_set(sh, rr->setname);
829 
830  if (!set)
831  {
833  rr->errstring = odr_strdup(rr->stream, rr->setname);
834  return 0;
835  }
836  do_delay(&set->present_delay);
837  return 0;
838 }
839 
840 /* retrieval of a single record (present, and piggy back search) */
841 int ztest_fetch(void *handle, bend_fetch_rr *r)
842 {
843  struct session_handle *sh = (struct session_handle*) handle;
844  char *cp;
845  const Odr_oid *oid = r->request_format;
846  struct result_set *set = get_set(sh, r->setname);
847  const char *esn = yaz_get_esn(r->comp);
848 
849  if (!set)
850  {
852  r->errstring = odr_strdup(r->stream, r->setname);
853  return 0;
854  }
855  do_delay(&set->fetch_delay);
856  r->last_in_set = 0;
857  r->basename = set->db;
859 
860  if (r->number < 1 || r->number > set->hits)
861  {
863  return 0;
864  }
865  if (!oid || yaz_oid_is_iso2709(oid))
866  {
867  cp = dummy_marc_record(r->number, r->stream);
868  if (!cp)
869  {
871  r->surrogate_flag = 1;
872  return 0;
873  }
874  else
875  {
876  r->len = strlen(cp);
877  r->record = cp;
879  }
880  }
881  else if (!oid_oidcmp(oid, yaz_oid_recsyn_opac))
882  {
883  cp = dummy_marc_record(r->number, r->stream);
884  if (!cp)
885  {
887  r->surrogate_flag = 1;
888  return 0;
889  }
890  r->record = (char *) dummy_opac(r->number, r->stream, cp);
891  r->len = -1;
892  }
893  else if (!oid_oidcmp(oid, yaz_oid_recsyn_sutrs))
894  {
895  /* this section returns a small record */
896  char buf[100];
897 
898  sprintf(buf, "This is dummy SUTRS record number %d\n", r->number);
899 
900  r->len = strlen(buf);
901  r->record = (char *) odr_malloc(r->stream, r->len+1);
902  strcpy(r->record, buf);
903  }
904  else if (!oid_oidcmp(oid, yaz_oid_recsyn_grs_1))
905  {
906  r->len = -1;
907  r->record = (char*) dummy_grs_record(r->number, r->stream);
908  if (!r->record)
909  {
911  r->surrogate_flag = 1;
912  return 0;
913  }
914  }
915  else if (!oid_oidcmp(oid, yaz_oid_recsyn_postscript))
916  {
917  char fname[20];
918  FILE *f;
919  long size;
920 
921  sprintf(fname, "part.%d.ps", r->number);
922  f = fopen(fname, "rb");
923  if (!f)
924  {
926  r->surrogate_flag = 1;
927  return 0;
928  }
929  fseek(f, 0L, SEEK_END);
930  size = ftell(f);
931  if (size <= 0 || size >= 5000000)
932  {
934  r->surrogate_flag = 1;
935  }
936  fseek(f, 0L, SEEK_SET);
937  r->record = (char*) odr_malloc(r->stream, size);
938  r->len = size;
939  if (fread(r->record, size, 1, f) != 1)
940  {
942  r->surrogate_flag = 1;
943  }
944  fclose(f);
945  }
946  else if (!oid_oidcmp(oid, yaz_oid_recsyn_xml))
947  {
948  if ((cp = dummy_xml_record(r->number, r->stream, esn)))
949  {
950  r->len = strlen(cp);
951  r->record = cp;
952  r->schema = "info:srw/schema/1/marcxml-1.1";
953  }
954  else
955  {
957  r->surrogate_flag = 1;
958  return 0;
959  }
960  }
961  else if (!oid_oidcmp(oid, yaz_oid_recsyn_json))
962  {
963  if ((cp = dummy_json_record(r->number, r->stream, esn)))
964  {
965  r->len = strlen(cp);
966  r->record = cp;
967  r->schema = "info:srw/schema/1/marcxml-1.1";
968  }
969  else
970  {
972  r->surrogate_flag = 1;
973  return 0;
974  }
975  }
976  else
977  {
978  char buf[OID_STR_MAX];
980  r->errstring = odr_strdup(r->stream, oid_oid_to_dotstring(oid, buf));
981  return 0;
982  }
983  r->errcode = 0;
984  return 0;
985 }
986 
987 /*
988  * silly dummy-scan what reads words from a file.
989  */
990 int ztest_scan(void *handle, bend_scan_rr *q)
991 {
992  static FILE *f = 0;
993  static struct scan_entry list[200];
994  static char entries[200][80];
995  int hits[200];
996  char term[80], *p;
997  int i, pos;
998  int term_position_req = q->term_position;
999  int num_entries_req = q->num_entries;
1000 
1001  /* Throw Database unavailable if other than Default or Slow */
1002  if (!yaz_matchstr(q->basenames[0], "Default"))
1003  ; /* Default is OK in our test */
1004  else if (check_slow(q->basenames[0], 0 /* no assoc for scan */))
1005  ;
1006  else
1007  {
1009  q->errstring = q->basenames[0];
1010  return 0;
1011  }
1012 
1013  q->errcode = 0;
1014  q->errstring = 0;
1015  q->entries = list;
1017  if (!f && !(f = fopen("dummy-words", "r")))
1018  {
1019  perror("dummy-words");
1020  exit(1);
1021  }
1022  if (q->num_entries > 200)
1023  {
1025  return 0;
1026  }
1027  if (q->term)
1028  {
1029  int len;
1030  if (q->term->term->which != Z_Term_general)
1031  {
1033  return 0;
1034  }
1035  if (*q->step_size != 0)
1036  {
1038  return 0;
1039  }
1040  len = q->term->term->u.general->len;
1041  if (len >= (int ) sizeof(term))
1042  len = sizeof(term)-1;
1043  memcpy(term, q->term->term->u.general->buf, len);
1044  term[len] = '\0';
1045  }
1046  else if (q->scanClause)
1047  {
1048  strncpy(term, q->scanClause, sizeof(term)-1);
1049  term[sizeof(term)-1] = '\0';
1050  }
1051  else
1052  strcpy(term, "0");
1053 
1054  for (p = term; *p; p++)
1055  if (yaz_islower(*p))
1056  *p = yaz_toupper(*p);
1057 
1058  fseek(f, 0, SEEK_SET);
1059  q->num_entries = 0;
1060 
1061  for (i = 0, pos = 0; fscanf(f, " %79[^:]:%d", entries[pos], &hits[pos]) == 2;
1062  i++, pos < 199 ? pos++ : (pos = 0))
1063  {
1064  if (!q->num_entries && strcmp(entries[pos], term) >= 0) /* s-point fnd */
1065  {
1066  if ((q->term_position = term_position_req) > i + 1)
1067  {
1068  q->term_position = i + 1;
1070  }
1071  for (; q->num_entries < q->term_position; q->num_entries++)
1072  {
1073  int po;
1074 
1075  po = pos - q->term_position + q->num_entries+1; /* find pos */
1076  if (po < 0)
1077  po += 200;
1078 
1079  if (!strcmp(term, "SD") && q->num_entries == 2)
1080  {
1081  list[q->num_entries].term = entries[pos];
1082  list[q->num_entries].occurrences = -1;
1083  list[q->num_entries].errcode =
1085  list[q->num_entries].errstring = "SD for Scan Term";
1086  }
1087  else
1088  {
1089  list[q->num_entries].term = entries[po];
1090  list[q->num_entries].occurrences = hits[po];
1091  }
1092  }
1093  }
1094  else if (q->num_entries)
1095  {
1096  list[q->num_entries].term = entries[pos];
1097  list[q->num_entries].occurrences = hits[pos];
1098  q->num_entries++;
1099  }
1100  if (q->num_entries >= num_entries_req)
1101  break;
1102  }
1104  if (feof(f))
1106  return 0;
1107 }
1108 
1109 int ztest_explain(void *handle, bend_explain_rr *rr)
1110 {
1111  if (rr->database && !strcmp(rr->database, "Default"))
1112  {
1113  rr->explain_buf = "<explain>\n"
1114  "\t<serverInfo>\n"
1115  "\t\t<host>localhost</host>\n"
1116  "\t\t<port>210</port>\n"
1117  "\t</serverInfo>\n"
1118  "</explain>\n";
1119  }
1120  return 0;
1121 }
1122 
1123 int ztest_update(void *handle, bend_update_rr *rr)
1124 {
1125  rr->operation_status = "success";
1126  return 0;
1127 }
1128 
1130 {
1132  odr_malloc(q->stream, sizeof(*r));
1133  struct session_handle *sh = xmalloc(sizeof(*sh));
1134 
1135  sh->result_sets = 0;
1136 
1137  if (!log_level_set)
1138  {
1140  log_level_set=1;
1141  }
1142 
1143  r->errcode = 0;
1144  r->errstring = 0;
1145  r->handle = sh; /* tell GFS about our handle */
1146  q->bend_sort = ztest_sort; /* register sort handler */
1147  q->bend_search = ztest_search; /* register search handler */
1148  q->bend_present = ztest_present; /* register present handle */
1151  q->bend_fetch = ztest_fetch;
1152  q->bend_scan = ztest_scan;
1153 #if 0
1155 #endif
1158 
1159  q->query_charset = "ISO-8859-1";
1160  q->records_in_same_charset = 0;
1161  q->named_result_sets = 1;
1162 
1163  return r;
1164 }
1165 
1166 void bend_close(void *handle)
1167 {
1168  struct session_handle *sh = (struct session_handle*) handle;
1169  remove_sets(sh);
1170  xfree(sh); /* release our session */
1171  return;
1172 }
1173 
1174 int main(int argc, char **argv)
1175 {
1176  yaz_enable_panic_backtrace(argv[0]);
1177 
1178  return statserv_main(argc, argv, bend_init, bend_close);
1179 }
1180 /*
1181  * Local variables:
1182  * c-basic-offset: 4
1183  * c-file-style: "Stroustrup"
1184  * indent-tabs-mode: nil
1185  * End:
1186  * vim: shiftwidth=4 tabstop=8 expandtab
1187  */
1188 
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:816
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:990
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:1109
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
Z_IU0OriginPartToKeep * toKeep
Definition: zes-update0.h:55
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:806
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
union Z_IU0Update::@131 u
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:825
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
#define Z_External_update0
Definition: prt-ext.h:86
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:1123
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:1166
#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
Z_IU0Update * update0
Definition: prt-ext.h:130
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:1129
#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
Z_IU0UpdateEsRequest * esRequest
Definition: zes-update0.h:67
#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:1174
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:841
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:3530
#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