IDZEBRA  2.1.2
api.h
Go to the documentation of this file.
1 /* This file is part of the Zebra server.
2  Copyright (C) Index Data
3 
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8 
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18 */
19 
28 #ifndef IDZEBRA_API_H
29 #define IDZEBRA_API_H
30 
31 #include <yaz/odr.h>
32 #include <yaz/proto.h>
33 #include <idzebra/res.h>
34 #include <idzebra/version.h>
35 #include <idzebra/recctrl.h>
36 
37 YAZ_BEGIN_CDECL
38 
39 typedef struct {
44  long utime;
45  long stime;
47 
49 typedef struct {
50  int errCode; /* non-zero if error when fetching this */
51  char *errString; /* error string */
52  int position; /* position of record in result set (1,2,..) */
53  char *buf; /* record buffer (void pointer really) */
54  int len; /* length */
55  const Odr_oid *format; /* record syntax */
56  char *base;
58  int score;
60 
62 typedef struct {
63  zint occurrences; /* scan term occurrences */
64  char *term; /* scan term string */
65  char *display_term; /* display scan term entry */
67 
71 typedef struct zebra_session *ZebraHandle;
72 
76 typedef struct zebra_service *ZebraService;
77 
83 YAZ_EXPORT
84 ZebraService zebra_start(const char *configName
85  ) ZEBRA_GCC_ATTR((warn_unused_result));
86 
95 YAZ_EXPORT
96 ZebraService zebra_start_res(const char *configName,
97  Res def_res, Res over_res
98  ) ZEBRA_GCC_ATTR((warn_unused_result));
99 
105 YAZ_EXPORT
106 ZEBRA_RES zebra_stop(ZebraService zs);
107 
113 YAZ_EXPORT
114 void zebra_filter_info(ZebraService zs, void *cd,
115  void (*cb)(void *cd, const char *name));
116 
117 
126 YAZ_EXPORT
127 ZebraHandle zebra_open(ZebraService zs, Res res
128  ) ZEBRA_GCC_ATTR((warn_unused_result));
129 
133 YAZ_EXPORT
134 ZEBRA_RES zebra_close(ZebraHandle zh);
135 
139 YAZ_EXPORT
140 int zebra_errCode(ZebraHandle zh);
141 
145 YAZ_EXPORT
146 const char *zebra_errString(ZebraHandle zh);
147 
151 YAZ_EXPORT
152 char *zebra_errAdd(ZebraHandle zh);
153 
159 YAZ_EXPORT
160 void zebra_result(ZebraHandle zh, int *code, char **addinfo);
161 
162 
167 YAZ_EXPORT
168 const char *zebra_get_encoding(ZebraHandle zh);
169 
177 ZEBRA_RES zebra_set_approx_limit(ZebraHandle zh, zint approx_limit);
178 
185 YAZ_EXPORT
186 ZEBRA_RES zebra_search_PQF(ZebraHandle zh, const char *pqf_query,
187  const char *setname, zint *hits);
188 
198 YAZ_EXPORT
199 ZEBRA_RES zebra_search_RPN_x(ZebraHandle zh, ODR o, Z_RPNQuery *query,
200  const char *setname, zint *hits,
201  int *estimated_hit_count,
202  int *partial_resultset);
203 
204 
212 YAZ_EXPORT
213 ZEBRA_RES zebra_search_RPN(ZebraHandle zh, ODR o, Z_RPNQuery *query,
214  const char *setname, zint *hits);
215 
225 YAZ_EXPORT
226 ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream,
227  const char *setname,
228  Z_RecordComposition *comp,
229  const Odr_oid *input_format,
230  int num_recs,
231  ZebraRetrievalRecord *recs);
239 YAZ_EXPORT
240 int zebra_deleteResultSet(ZebraHandle zh, int function,
241  int num_setnames, char **setnames,
242  int *statuses);
243 
244 
254 YAZ_EXPORT
255 ZEBRA_RES zebra_result_set_term_no(ZebraHandle zh, const char *setname,
256  int *num_terms);
257 
276 YAZ_EXPORT
277 ZEBRA_RES zebra_result_set_term_info(ZebraHandle zh, const char *setname,
278  int no, zint *count, int *approx,
279  char *termbuf, size_t *termlen,
280  const char **term_ref_id);
281 
282 
294 YAZ_EXPORT ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream,
295  Z_AttributesPlusTerm *zapt,
296  const Odr_oid *attributeset,
297  int *position, int *num_entries,
298  ZebraScanEntry **entries,
299  int *is_partial,
300  const char *setname);
301 
312 YAZ_EXPORT
313 ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query,
314  int *position, int *num_entries,
315  ZebraScanEntry **entries,
316  int *is_partial, const char *setname);
317 
323 YAZ_EXPORT
324 ZEBRA_RES zebra_auth(ZebraHandle zh, const char *user, const char *pass);
325 
334 YAZ_EXPORT
335 int zebra_string_norm(ZebraHandle zh, const char *index_type,
336  const char *input_str,
337  int input_len, char *output_str, int output_len);
338 
343 YAZ_EXPORT
344 ZEBRA_RES zebra_create_database(ZebraHandle zh, const char *db);
345 
350 YAZ_EXPORT
351 ZEBRA_RES zebra_drop_database(ZebraHandle zh, const char *db);
352 
353 YAZ_EXPORT
354 ZEBRA_RES zebra_admin_shutdown(ZebraHandle zh);
355 
356 YAZ_EXPORT
357 ZEBRA_RES zebra_admin_start(ZebraHandle zh);
358 
359 YAZ_EXPORT
360 ZEBRA_RES zebra_shutdown(ZebraService zs);
361 
362 YAZ_EXPORT
363 ZEBRA_RES zebra_admin_import_begin(ZebraHandle zh, const char *database,
364  const char *record_type);
365 
366 YAZ_EXPORT
368  Z_Segment *segment);
369 
370 YAZ_EXPORT
371 ZEBRA_RES zebra_admin_import_end(ZebraHandle zh);
372 
373 YAZ_EXPORT
374 ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw
375  ) ZEBRA_GCC_ATTR((warn_unused_result));
376 
377 YAZ_EXPORT
378 ZEBRA_RES zebra_end_trans(ZebraHandle zh
379  ) ZEBRA_GCC_ATTR((warn_unused_result));
380 
381 YAZ_EXPORT
383  ZebraTransactionStatus *stat);
384 
385 YAZ_EXPORT
386 ZEBRA_RES zebra_commit(ZebraHandle zh);
387 
388 YAZ_EXPORT
389 ZEBRA_RES zebra_clean(ZebraHandle zh);
390 
391 YAZ_EXPORT
392 ZEBRA_RES zebra_init(ZebraHandle zh);
393 
394 YAZ_EXPORT
395 ZEBRA_RES zebra_compact(ZebraHandle zh);
396 
397 YAZ_EXPORT
398 ZEBRA_RES zebra_repository_index(ZebraHandle zh, const char *path,
399  enum zebra_recctrl_action_t action);
400 
401 YAZ_EXPORT
402 ZEBRA_RES zebra_repository_update(ZebraHandle zh, const char *path);
403 
404 YAZ_EXPORT
405 ZEBRA_RES zebra_repository_delete(ZebraHandle zh, const char *path);
406 
407 YAZ_EXPORT
408 ZEBRA_RES zebra_repository_show(ZebraHandle zh, const char *path);
409 
418 YAZ_EXPORT
419 ZEBRA_RES zebra_add_record(ZebraHandle zh, const char *buf, int buf_size);
420 
431 YAZ_EXPORT
432 ZEBRA_RES zebra_update_record(ZebraHandle zh,
433  enum zebra_recctrl_action_t action,
434  const char *recordType,
435  zint *sysno, const char *match,
436  const char *fname,
437  const char *buf, int buf_size);
438 
439 YAZ_EXPORT
440 ZEBRA_RES zebra_sort(ZebraHandle zh, ODR stream,
441  int num_input_setnames,
442  const char **input_setnames,
443  const char *output_setname,
444  Z_SortKeySpecList *sort_sequence,
445  int *sort_status
446  ) ZEBRA_GCC_ATTR((warn_unused_result));
447 
448 YAZ_EXPORT
449 ZEBRA_RES zebra_select_databases(ZebraHandle zh, int num_bases,
450  const char **basenames
451  ) ZEBRA_GCC_ATTR((warn_unused_result));
452 
453 YAZ_EXPORT
454 ZEBRA_RES zebra_select_database(ZebraHandle zh, const char *basename
455  ) ZEBRA_GCC_ATTR((warn_unused_result));
456 
457 YAZ_EXPORT
458 void zebra_shadow_enable(ZebraHandle zh, int value);
459 
460 YAZ_EXPORT
461 int zebra_register_statistics(ZebraHandle zh, int dumpdict);
462 
463 YAZ_EXPORT
464 ZEBRA_RES zebra_record_encoding(ZebraHandle zh, const char *encoding);
465 
466 YAZ_EXPORT
467 ZEBRA_RES zebra_octet_term_encoding(ZebraHandle zh, const char *encoding);
468 
469 /* Resources */
470 YAZ_EXPORT
471 void zebra_set_resource(ZebraHandle zh, const char *name, const char *value);
472 YAZ_EXPORT
473 const char *zebra_get_resource(ZebraHandle zh,
474  const char *name, const char *defaultvalue);
475 
476 
477 YAZ_EXPORT
478 void zebra_pidfname(ZebraService zs, char *path);
479 
480 typedef struct {
481  char *term;
482  char *db;
484  int score;
486 
487 YAZ_EXPORT
489  const char *name,
490  int num, zint *positions);
491 
492 
493 YAZ_EXPORT
495  const char *name,
496  zint start, int num);
497 
498 YAZ_EXPORT
499 void zebra_meta_records_destroy(ZebraHandle zh, ZebraMetaRecord *records,
500  int num);
501 
502 YAZ_EXPORT
503 struct BFiles_struct *zebra_get_bfs(ZebraHandle zh);
504 
505 YAZ_EXPORT
506 ZEBRA_RES zebra_set_limit(ZebraHandle zh, int complement_flag, zint *ids);
507 
508 YAZ_EXPORT
510  int (*f)(void *client_data),
511  void *client_data);
512 
513 YAZ_EXPORT
514 ZEBRA_RES zebra_register_check(ZebraHandle zh, const char *spec);
515 
516 YAZ_END_CDECL
517 
599 #endif
600 /*
601  * Local variables:
602  * c-basic-offset: 4
603  * c-file-style: "Stroustrup"
604  * indent-tabs-mode: nil
605  * End:
606  * vim: shiftwidth=4 tabstop=8 expandtab
607  */
608 
ZEBRA_RES zebra_update_record(ZebraHandle zh, enum zebra_recctrl_action_t action, const char *recordType, zint *sysno, const char *match, const char *fname, const char *buf, int buf_size)
Updates record.
Definition: zebraapi.c:2610
ZEBRA_RES zebra_begin_trans(ZebraHandle zh, int rw) ZEBRA_GCC_ATTR((warn_unused_result))
Definition: zebraapi.c:1709
ZEBRA_RES zebra_close(ZebraHandle zh)
Destroys Zebra session handle.
Definition: zebraapi.c:656
ZEBRA_RES zebra_init(ZebraHandle zh)
Definition: zebraapi.c:2153
ZEBRA_RES zebra_search_RPN_x(ZebraHandle zh, ODR o, Z_RPNQuery *query, const char *setname, zint *hits, int *estimated_hit_count, int *partial_resultset)
Search using RPN Query structure (from ASN.1)
Definition: zebraapi.c:1078
char * buf
Definition: api.h:53
ZEBRA_RES zebra_sort(ZebraHandle zh, ODR stream, int num_input_setnames, const char **input_setnames, const char *output_setname, Z_SortKeySpecList *sort_sequence, int *sort_status) ZEBRA_GCC_ATTR((warn_unused_result))
Definition: zebraapi.c:1290
ZEBRA_RES zebra_commit(ZebraHandle zh)
Definition: zebraapi.c:2145
ZEBRA_RES zebra_set_break_handler(ZebraHandle zh, int(*f)(void *client_data), void *client_data)
Definition: zebraapi.c:1069
int zebra_errCode(ZebraHandle zh)
Returns error code for last error.
Definition: zebraapi.c:1342
char * errString
Definition: api.h:51
#define ZEBRA_GCC_ATTR(x)
Definition: util.h:41
ZEBRA_RES zebra_set_approx_limit(ZebraHandle zh, zint approx_limit)
Set limit before Zebra does approx hit count.
Definition: zebraapi.c:1055
ZEBRA_RES zebra_record_encoding(ZebraHandle zh, const char *encoding)
Definition: zebraapi.c:2544
int zebra_string_norm(ZebraHandle zh, const char *index_type, const char *input_str, int input_len, char *output_str, int output_len)
Normalize zebra term for register (subject to change!)
Definition: zebraapi.c:1586
ZEBRA_RES zebra_select_databases(ZebraHandle zh, int num_bases, const char **basenames) ZEBRA_GCC_ATTR((warn_unused_result))
Definition: zebraapi.c:947
const char * zebra_get_encoding(ZebraHandle zh)
Returns character set encoding for session.
Definition: zebraapi.c:106
ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query, int *position, int *num_entries, ZebraScanEntry **entries, int *is_partial, const char *setname)
performs Scan (taking PQF string)
Definition: zebraapi.c:1231
ZEBRA_RES zebra_admin_import_begin(ZebraHandle zh, const char *database, const char *record_type)
Definition: zebraapi.c:1403
struct zebra_service * ZebraService
a Zebra Service handle
Definition: api.h:76
ZebraHandle zh
Definition: zebrash.c:64
ZEBRA_RES zebra_create_database(ZebraHandle zh, const char *db)
Creates a database.
Definition: zebraapi.c:1561
char * term
Definition: api.h:64
char * db
Definition: api.h:482
ZEBRA_RES zebra_repository_delete(ZebraHandle zh, const char *path)
Definition: zebraapi.c:2011
zint sysno
Definition: api.h:483
ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res) ZEBRA_GCC_ATTR((warn_unused_result))
Creates a Zebra service with resources.
Definition: zebraapi.c:196
ZEBRA_RES zebra_search_RPN(ZebraHandle zh, ODR o, Z_RPNQuery *query, const char *setname, zint *hits)
Search using RPN Query structure (from ASN.1)
Definition: zebraapi.c:1107
ZEBRA_RES zebra_end_transaction(ZebraHandle zh, ZebraTransactionStatus *stat)
Definition: zebraapi.c:1918
ZebraService zebra_start(const char *configName) ZEBRA_GCC_ATTR((warn_unused_result))
Creates a Zebra Service.
Definition: zebraapi.c:191
ZebraMetaRecord * zebra_meta_records_create(ZebraHandle zh, const char *name, int num, zint *positions)
Definition: zsets.c:418
char * zebra_errAdd(ZebraHandle zh)
Returns additional info for last error.
Definition: zebraapi.c:1362
ZEBRA_RES zebra_auth(ZebraHandle zh, const char *user, const char *pass)
authenticate user. Returns 0 if OK, != 0 on failure
Definition: zebraapi.c:1371
const char * zebra_get_resource(ZebraHandle zh, const char *name, const char *defaultvalue)
Definition: zebraapi.c:2564
Definition: res.c:46
struct BFiles_struct * zebra_get_bfs(ZebraHandle zh)
Definition: zebraapi.c:2732
char * base
Definition: api.h:56
ZEBRA_RES zebra_add_record(ZebraHandle zh, const char *buf, int buf_size)
Simple update record.
Definition: zebraapi.c:2599
ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, const Odr_oid *attributeset, int *position, int *num_entries, ZebraScanEntry **entries, int *is_partial, const char *setname)
performs Scan (Z39.50 style)
Definition: zebraapi.c:1257
ZEBRA_RES zebra_compact(ZebraHandle zh)
Definition: zebraapi.c:2186
ZEBRA_RES zebra_drop_database(ZebraHandle zh, const char *db)
Deletes a database (drop)
Definition: zebraapi.c:1517
ZEBRA_RES zebra_admin_shutdown(ZebraHandle zh)
Definition: zebraapi.c:569
ZEBRA_RES zebra_stop(ZebraService zs)
stops a Zebra service.
Definition: zebraapi.c:626
ZEBRA_RES zebra_admin_import_segment(ZebraHandle zh, Z_Segment *segment)
Definition: zebraapi.c:1420
ZEBRA_RES zebra_set_limit(ZebraHandle zh, int complement_flag, zint *ids)
Definition: zebraapi.c:2743
ZEBRA_RES zebra_admin_import_end(ZebraHandle zh)
Definition: zebraapi.c:1413
const Odr_oid * format
Definition: api.h:55
void zebra_filter_info(ZebraService zs, void *cd, void(*cb)(void *cd, const char *name))
Lists enabled Zebra filters.
Definition: zebraapi.c:305
ZebraService zs
Definition: zebrash.c:63
ZEBRA_RES zebra_result_set_term_info(ZebraHandle zh, const char *setname, int no, zint *count, int *approx, char *termbuf, size_t *termlen, const char **term_ref_id)
returns information about a term assocated with a result set
Definition: zsets.c:1275
ZEBRA_RES zebra_octet_term_encoding(ZebraHandle zh, const char *encoding)
Definition: zebraapi.c:2521
ZEBRA_RES zebra_shutdown(ZebraService zs)
char * term
Definition: api.h:481
ZEBRA_RES zebra_end_trans(ZebraHandle zh) ZEBRA_GCC_ATTR((warn_unused_result))
Definition: zebraapi.c:1909
void zebra_pidfname(ZebraService zs, char *path)
Definition: zebraapi.c:313
ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream, const char *setname, Z_RecordComposition *comp, const Odr_oid *input_format, int num_recs, ZebraRetrievalRecord *recs)
Retrieve records from result set (after search)
Definition: zebraapi.c:1117
void zebra_shadow_enable(ZebraHandle zh, int value)
Definition: zebraapi.c:2514
ZEBRA_RES zebra_search_PQF(ZebraHandle zh, const char *pqf_query, const char *setname, zint *hits)
Search using PQF Query String.
Definition: zebraapi.c:2650
ZEBRA_RES zebra_select_database(ZebraHandle zh, const char *basename) ZEBRA_GCC_ATTR((warn_unused_result))
Definition: zebraapi.c:938
long zint
Zebra integer.
Definition: util.h:66
ZEBRA_RES zebra_repository_index(ZebraHandle zh, const char *path, enum zebra_recctrl_action_t action)
Definition: zebraapi.c:2016
ZEBRA_RES zebra_clean(ZebraHandle zh)
Definition: zebraapi.c:2138
ZebraMetaRecord * zebra_meta_records_create_range(ZebraHandle zh, const char *name, zint start, int num)
Definition: zsets.c:393
ZEBRA_RES zebra_repository_update(ZebraHandle zh, const char *path)
Definition: zebraapi.c:2006
char * display_term
Definition: api.h:65
int zebra_register_statistics(ZebraHandle zh, int dumpdict)
Definition: invstat.c:174
void zebra_result(ZebraHandle zh, int *code, char **addinfo)
Returns error code and additional info for last error.
Definition: zebraapi.c:2499
int score
Definition: api.h:484
const char * zebra_errString(ZebraHandle zh)
Returns error string for last error.
Definition: zebraapi.c:1353
short ZEBRA_RES
Common return type for Zebra API.
Definition: util.h:80
ZEBRA_RES zebra_admin_start(ZebraHandle zh)
Definition: zebraapi.c:580
zebra_recctrl_action_t
Definition: recctrl.h:87
int zebra_deleteResultSet(ZebraHandle zh, int function, int num_setnames, char **setnames, int *statuses)
Deletes one or more resultsets.
Definition: zebraapi.c:1313
zint occurrences
Definition: api.h:63
ZebraHandle zebra_open(ZebraService zs, Res res) ZEBRA_GCC_ATTR((warn_unused_result))
Creates a Zebra session handle within service.
Definition: zebraapi.c:112
ZEBRA_RES zebra_result_set_term_no(ZebraHandle zh, const char *setname, int *num_terms)
returns number of term info terms assocaited with result set
Definition: zsets.c:1262
void zebra_set_resource(ZebraHandle zh, const char *name, const char *value)
Definition: zebraapi.c:2555
ZEBRA_RES zebra_repository_show(ZebraHandle zh, const char *path)
Definition: zebraapi.c:2037
ZEBRA_RES zebra_register_check(ZebraHandle zh, const char *spec)
Definition: zebraapi.c:2412
void zebra_meta_records_destroy(ZebraHandle zh, ZebraMetaRecord *records, int num)
Definition: zsets.c:547
struct zebra_session * ZebraHandle
a Zebra Handle - (session)
Definition: api.h:71