2 * Copyright (C) 1995-2002, Index Data
5 * $Id: zebraapi.c,v 1.54 2002-04-05 12:49:51 adam Exp $
18 #include <yaz/diagbib1.h>
22 static Res zebra_open_res (ZebraHandle zh);
23 static void zebra_close_res (ZebraHandle zh);
25 static void zebra_chdir (ZebraService zh)
27 const char *dir = res_get (zh->global_res, "chdir");
30 logf (LOG_DEBUG, "chdir %s", dir);
38 static void zebra_flush_reg (ZebraHandle zh)
40 zebraExplain_flush (zh->reg->zei, 1, zh);
42 extract_flushWriteKeys (zh);
43 zebra_index_merge (zh);
46 static struct zebra_register *zebra_register_open (ZebraService zs,
48 int rw, int useshadow,
50 const char *reg_path);
51 static void zebra_register_close (ZebraService zs, struct zebra_register *reg);
53 static int zebra_begin_read (ZebraHandle zh);
54 static void zebra_end_read (ZebraHandle zh);
56 ZebraHandle zebra_open (ZebraService zs)
63 zh = (ZebraHandle) xmalloc (sizeof(*zh));
64 yaz_log (LOG_LOG, "zebra_open zs=%p returns %p", zs, zh);
67 zh->reg = 0; /* no register attached yet */
74 zh->reg_name = xstrdup ("");
76 zh->num_basenames = 0;
84 zh->admin_databaseName = 0;
86 zebra_mutex_cond_lock (&zs->session_lock);
88 zh->next = zs->sessions;
91 zebra_mutex_cond_unlock (&zs->session_lock);
96 ZebraService zebra_start (const char *configName)
100 yaz_log (LOG_LOG, "zebra_start %s", configName);
102 if (!(res = res_open (configName, 0)))
103 yaz_log (LOG_WARN, "Cannot read resources `%s'", configName);
106 ZebraService zh = xmalloc (sizeof(*zh));
108 yaz_log (LOG_LOG, "Read resources `%s'", configName);
110 zh->global_res = res;
111 zh->configName = xstrdup(configName);
116 zebra_mutex_cond_init (&zh->session_lock);
117 if (!res_get (zh->global_res, "passwd"))
118 zh->passwd_db = NULL;
121 zh->passwd_db = passwd_db_open ();
123 logf (LOG_WARN|LOG_ERRNO, "passwd_db_open failed");
125 passwd_db_file (zh->passwd_db,
126 res_get (zh->global_res, "passwd"));
128 zh->path_root = res_get (zh->global_res, "root");
135 struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
136 int rw, int useshadow, Res res,
137 const char *reg_path)
139 struct zebra_register *reg;
140 int record_compression = REC_COMPRESS_NONE;
141 char *recordCompression = 0;
143 reg = xmalloc (sizeof(*reg));
146 reg->name = xstrdup (name);
153 yaz_log (LOG_LOG, "zebra_register_open rw = %d useshadow=%d p=%p",
156 reg->dh = data1_create ();
159 reg->bfs = bfs_create (res_get (res, "register"), reg_path);
162 data1_destroy(reg->dh);
166 bf_cache (reg->bfs, res_get (res, "shadow"));
167 data1_set_tabpath (reg->dh, res_get(res, "profilePath"));
168 data1_set_tabroot (reg->dh, reg_path);
169 reg->recTypes = recTypes_init (reg->dh);
170 recTypes_default_handlers (reg->recTypes);
172 reg->zebra_maps = zebra_maps_open (res, reg_path);
173 reg->rank_classes = NULL;
177 reg->keys.buf_max = 0;
191 zebraRankInstall (reg, rank1_class);
193 recordCompression = res_get_def (res, "recordCompression", "none");
194 if (!strcmp (recordCompression, "none"))
195 record_compression = REC_COMPRESS_NONE;
196 if (!strcmp (recordCompression, "bzip2"))
197 record_compression = REC_COMPRESS_BZIP2;
199 if (!(reg->records = rec_open (reg->bfs, rw, record_compression)))
201 logf (LOG_WARN, "rec_open");
206 reg->matchDict = dict_open (reg->bfs, GMATCH_DICT, 20, 1, 0);
208 if (!(reg->dict = dict_open (reg->bfs, FNAME_DICT, 40, rw, 0)))
210 logf (LOG_WARN, "dict_open");
213 if (!(reg->sortIdx = sortIdx_open (reg->bfs, rw)))
215 logf (LOG_WARN, "sortIdx_open");
218 if (res_get_match (res, "isam", "s", ISAM_DEFAULT))
220 struct ISAMS_M_s isams_m;
221 if (!(reg->isams = isams_open (reg->bfs, FNAME_ISAMS, rw,
222 key_isams_m(res, &isams_m))))
224 logf (LOG_WARN, "isams_open");
228 else if (res_get_match (res, "isam", "i", ISAM_DEFAULT))
230 if (!(reg->isam = is_open (reg->bfs, FNAME_ISAM, key_compare, rw,
231 sizeof (struct it_key), res)))
233 logf (LOG_WARN, "is_open");
237 else if (res_get_match (res, "isam", "c", ISAM_DEFAULT))
239 struct ISAMC_M_s isamc_m;
240 if (!(reg->isamc = isc_open (reg->bfs, FNAME_ISAMC,
241 rw, key_isamc_m(res, &isamc_m))))
243 logf (LOG_WARN, "isc_open");
247 else if (res_get_match (res, "isam", "d", ISAM_DEFAULT))
249 struct ISAMD_M_s isamd_m;
251 if (!(reg->isamd = isamd_open (reg->bfs, FNAME_ISAMD,
252 rw, key_isamd_m(res, &isamd_m))))
254 logf (LOG_WARN, "isamd_open");
258 reg->zei = zebraExplain_open (reg->records, reg->dh,
263 logf (LOG_WARN, "Cannot obtain EXPLAIN information");
267 yaz_log (LOG_LOG, "zebra_register_open ok p=%p", reg);
271 void zebra_admin_shutdown (ZebraHandle zh)
273 zebra_mutex_cond_lock (&zh->service->session_lock);
274 zh->service->stop_flag = 1;
275 zebra_mutex_cond_unlock (&zh->service->session_lock);
278 void zebra_admin_start (ZebraHandle zh)
280 ZebraService zs = zh->service;
282 zebra_mutex_cond_lock (&zs->session_lock);
283 zebra_mutex_cond_unlock (&zs->session_lock);
286 static void zebra_register_close (ZebraService zs, struct zebra_register *reg)
288 yaz_log(LOG_LOG, "zebra_register_close p=%p", reg);
293 zebraExplain_close (reg->zei, 0);
294 dict_close (reg->dict);
296 dict_close (reg->matchDict);
297 sortIdx_close (reg->sortIdx);
299 isams_close (reg->isams);
301 is_close (reg->isam);
303 isc_close (reg->isamc);
305 isamd_close (reg->isamd);
306 rec_close (®->records);
309 recTypes_destroy (reg->recTypes);
310 zebra_maps_close (reg->zebra_maps);
311 zebraRankDestroy (reg);
312 bfs_destroy (reg->bfs);
313 data1_destroy (reg->dh);
315 xfree (reg->key_buf);
318 yaz_log (LOG_LOG, "zebra_register_close 2");
321 void zebra_stop(ZebraService zs)
325 yaz_log (LOG_LOG, "zebra_stop");
327 zebra_mutex_cond_lock (&zs->session_lock);
330 zebra_close (zs->sessions);
333 zebra_mutex_cond_unlock (&zs->session_lock);
335 zebra_mutex_cond_destroy (&zs->session_lock);
338 passwd_db_close (zs->passwd_db);
340 res_close (zs->global_res);
341 xfree (zs->configName);
342 xfree (zs->path_root);
346 void zebra_close (ZebraHandle zh)
349 struct zebra_session **sp;
355 yaz_log (LOG_LOG, "zebra_close zh=%p", zh);
358 resultSetDestroy (zh, -1, 0, 0);
362 zebra_register_close (zh->service, zh->reg);
363 zebra_close_res (zh);
365 xfree (zh->admin_databaseName);
366 zebra_mutex_cond_lock (&zs->session_lock);
367 zebra_lock_destroy (zh->lock_normal);
368 zebra_lock_destroy (zh->lock_shadow);
380 // if (!zs->sessions && zs->stop_flag)
381 // zebra_register_deactivate(zs);
382 zebra_mutex_cond_unlock (&zs->session_lock);
383 xfree (zh->reg_name);
385 yaz_log (LOG_LOG, "zebra_close zh=%p end", zh);}
387 struct map_baseinfo {
393 char **new_basenames;
397 static Res zebra_open_res (ZebraHandle zh)
403 sprintf (fname, "%.200s/zebra.cfg", zh->path_reg);
404 res = res_open (fname, zh->service->global_res);
406 res = zh->service->global_res;
408 else if (*zh->reg_name == 0)
410 res = zh->service->global_res;
414 yaz_log (LOG_WARN, "no register root specified");
415 return 0; /* no path for register - fail! */
420 static void zebra_close_res (ZebraHandle zh)
422 if (zh->res != zh->service->global_res)
427 static int zebra_select_register (ZebraHandle zh, const char *new_reg)
429 if (zh->res && strcmp (zh->reg_name, new_reg) == 0)
433 assert (zh->reg == 0);
434 assert (*zh->reg_name == 0);
440 resultSetInvalidate (zh);
441 zebra_register_close (zh->service, zh->reg);
446 xfree (zh->reg_name);
447 zh->reg_name = xstrdup (new_reg);
449 xfree (zh->path_reg);
451 if (zh->service->path_root)
453 zh->path_reg = xmalloc (strlen(zh->service->path_root) +
454 strlen(zh->reg_name) + 3);
455 strcpy (zh->path_reg, zh->service->path_root);
458 strcat (zh->path_reg, "/");
459 strcat (zh->path_reg, zh->reg_name);
462 zh->res = zebra_open_res (zh);
465 zebra_lock_destroy (zh->lock_normal);
469 zebra_lock_destroy (zh->lock_shadow);
475 const char *lock_area =res_get (zh->res, "lockDir");
477 if (!lock_area && zh->path_reg)
478 res_put (zh->res, "lockDir", zh->path_reg);
479 sprintf (fname, "norm.%s.LCK", zh->reg_name);
481 zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0);
483 sprintf (fname, "shadow.%s.LCK", zh->reg_name);
485 zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0);
491 void map_basenames_func (void *vp, const char *name, const char *value)
493 struct map_baseinfo *p = (struct map_baseinfo *) vp;
495 char fromdb[128], todb[8][128];
498 sscanf (value, "%127s %127s %127s %127s %127s %127s %127s %127s %127s",
499 fromdb, todb[0], todb[1], todb[2], todb[3], todb[4],
500 todb[5], todb[6], todb[7]);
504 for (i = 0; i<p->num_bases; i++)
505 if (p->basenames[i] && !strcmp (p->basenames[i], fromdb))
508 for (i = 0; i < no; i++)
510 if (p->new_num_bases == p->new_num_max)
512 p->new_basenames[(p->new_num_bases)++] =
513 nmem_strdup (p->mem, todb[i]);
519 void map_basenames (ZebraHandle zh, ODR stream,
520 int *num_bases, char ***basenames)
522 struct map_baseinfo info;
523 struct map_baseinfo *p = &info;
527 info.num_bases = *num_bases;
528 info.basenames = *basenames;
529 info.new_num_max = 128;
530 info.new_num_bases = 0;
531 info.new_basenames = (char **)
532 odr_malloc (stream, sizeof(*info.new_basenames) * info.new_num_max);
533 info.mem = stream->mem;
535 res_trav (zh->service->global_res, "mapdb", &info, map_basenames_func);
537 for (i = 0; i<p->num_bases; i++)
538 if (p->basenames[i] && p->new_num_bases < p->new_num_max)
540 p->new_basenames[(p->new_num_bases)++] =
541 nmem_strdup (p->mem, p->basenames[i]);
543 *num_bases = info.new_num_bases;
544 *basenames = info.new_basenames;
545 for (i = 0; i<*num_bases; i++)
546 logf (LOG_LOG, "base %s", (*basenames)[i]);
549 int zebra_select_database (ZebraHandle zh, const char *basename)
551 return zebra_select_databases (zh, 1, &basename);
554 int zebra_select_databases (ZebraHandle zh, int num_bases,
555 const char **basenames)
567 for (i = 0; i < zh->num_basenames; i++)
568 xfree (zh->basenames[i]);
569 xfree (zh->basenames);
571 zh->num_basenames = num_bases;
572 zh->basenames = xmalloc (zh->num_basenames * sizeof(*zh->basenames));
573 for (i = 0; i < zh->num_basenames; i++)
574 zh->basenames[i] = xstrdup (basenames[i]);
576 cp = strrchr(basenames[0], '/');
579 len = cp - basenames[0];
580 new_reg = xmalloc (len + 1);
581 memcpy (new_reg, basenames[0], len);
585 new_reg = xstrdup ("");
586 for (i = 1; i<num_bases; i++)
590 cp1 = strrchr (basenames[i], '/');
598 if (len != cp1 - basenames[i] ||
599 memcmp (basenames[i], new_reg, len))
614 zebra_select_register (zh, new_reg);
624 void zebra_search_rpn (ZebraHandle zh, ODR decode, ODR stream,
625 Z_RPNQuery *query, const char *setname, int *hits)
630 if (zebra_begin_read (zh))
632 resultSetAddRPN (zh, decode, stream, query,
633 zh->num_basenames, zh->basenames, setname);
640 void zebra_records_retrieve (ZebraHandle zh, ODR stream,
641 const char *setname, Z_RecordComposition *comp,
642 oid_value input_format, int num_recs,
643 ZebraRetrievalRecord *recs)
651 zh->errString = odr_strdup (stream, setname);
655 if (zebra_begin_read (zh))
658 pos_array = (int *) xmalloc (num_recs * sizeof(*pos_array));
659 for (i = 0; i<num_recs; i++)
660 pos_array[i] = recs[i].position;
661 poset = zebraPosSetCreate (zh, setname, num_recs, pos_array);
664 logf (LOG_DEBUG, "zebraPosSetCreate error");
666 zh->errString = nmem_strdup (stream->mem, setname);
670 for (i = 0; i<num_recs; i++)
675 recs[i].format = VAL_SUTRS;
676 recs[i].len = strlen(poset[i].term);
677 recs[i].buf = poset[i].term;
678 recs[i].base = poset[i].db;
680 else if (poset[i].sysno)
683 zebra_record_fetch (zh, poset[i].sysno, poset[i].score,
684 stream, input_format, comp,
685 &recs[i].format, &recs[i].buf,
688 recs[i].errString = NULL;
694 sprintf (num_str, "%d", pos_array[i]);
696 zh->errString = odr_strdup (stream, num_str);
700 zebraPosSetDestroy (zh, poset, num_recs);
706 void zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
707 oid_value attributeset,
708 int *position, int *num_entries, ZebraScanEntry **entries,
711 if (zebra_begin_read (zh))
717 rpn_scan (zh, stream, zapt, attributeset,
718 zh->num_basenames, zh->basenames, position,
719 num_entries, entries, is_partial);
723 void zebra_sort (ZebraHandle zh, ODR stream,
724 int num_input_setnames, const char **input_setnames,
725 const char *output_setname, Z_SortKeySpecList *sort_sequence,
728 if (zebra_begin_read (zh))
730 resultSetSort (zh, stream->mem, num_input_setnames, input_setnames,
731 output_setname, sort_sequence, sort_status);
735 int zebra_deleleResultSet(ZebraHandle zh, int function,
736 int num_setnames, char **setnames,
740 if (zebra_begin_read(zh))
741 return Z_DeleteStatus_systemProblemAtTarget;
744 case Z_DeleteRequest_list:
745 resultSetDestroy (zh, num_setnames, setnames, statuses);
747 case Z_DeleteRequest_all:
748 resultSetDestroy (zh, -1, 0, statuses);
752 status = Z_DeleteStatus_success;
753 for (i = 0; i<num_setnames; i++)
754 if (statuses[i] == Z_DeleteStatus_resultSetDidNotExist)
755 status = statuses[i];
759 int zebra_errCode (ZebraHandle zh)
764 const char *zebra_errString (ZebraHandle zh)
766 return diagbib1_str (zh->errCode);
769 char *zebra_errAdd (ZebraHandle zh)
771 return zh->errString;
774 int zebra_auth (ZebraHandle zh, const char *user, const char *pass)
776 ZebraService zs = zh->service;
777 if (!zs->passwd_db || !passwd_db_auth (zs->passwd_db, user, pass))
779 logf(LOG_APP,"AUTHOK:%s", user?user:"ANONYMOUS");
783 logf(LOG_APP,"AUTHFAIL:%s", user?user:"ANONYMOUS");
787 void zebra_admin_import_begin (ZebraHandle zh, const char *database)
789 zebra_begin_trans (zh);
790 xfree (zh->admin_databaseName);
791 zh->admin_databaseName = xstrdup(database);
794 void zebra_admin_import_end (ZebraHandle zh)
796 zebra_end_trans (zh);
799 void zebra_admin_import_segment (ZebraHandle zh, Z_Segment *segment)
803 for (i = 0; i<segment->num_segmentRecords; i++)
805 Z_NamePlusRecord *npr = segment->segmentRecords[i];
806 const char *databaseName = npr->databaseName;
809 databaseName = zh->admin_databaseName;
810 printf ("--------------%d--------------------\n", i);
811 if (npr->which == Z_NamePlusRecord_intermediateFragment)
813 Z_FragmentSyntax *fragment = npr->u.intermediateFragment;
814 if (fragment->which == Z_FragmentSyntax_notExternallyTagged)
816 Odr_oct *oct = fragment->u.notExternallyTagged;
817 printf ("%.*s", (oct->len > 100 ? 100 : oct->len) ,
821 extract_rec_in_mem (zh, "grs.sgml",
829 0 /* match criteria */);
835 void zebra_admin_create (ZebraHandle zh, const char *database)
839 zebra_begin_trans (zh);
842 /* announce database */
843 if (zebraExplain_newDatabase (zh->reg->zei, database, 0
844 /* explainDatabase */))
847 zh->errString = "Database already exist";
849 zebra_end_trans (zh);
852 int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
853 const char *input_str, int input_len,
854 char *output_str, int output_len)
857 if (!zh->reg->zebra_maps)
859 wrbuf = zebra_replace(zh->reg->zebra_maps, reg_id, "",
860 input_str, input_len);
863 if (wrbuf_len(wrbuf) >= output_len)
865 if (wrbuf_len(wrbuf))
866 memcpy (output_str, wrbuf_buf(wrbuf), wrbuf_len(wrbuf));
867 output_str[wrbuf_len(wrbuf)] = '\0';
868 return wrbuf_len(wrbuf);
872 void zebra_set_state (ZebraHandle zh, int val, int seqno)
874 char state_fname[256];
879 sprintf (state_fname, "state.%s.LCK", zh->reg_name);
880 fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
881 f = fopen (fname, "w");
883 yaz_log (LOG_LOG, "%c %d %ld", val, seqno, p);
884 fprintf (f, "%c %d %ld\n", val, seqno, p);
889 void zebra_get_state (ZebraHandle zh, char *val, int *seqno)
891 char state_fname[256];
895 sprintf (state_fname, "state.%s.LCK", zh->reg_name);
896 fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
897 f = fopen (fname, "r");
903 fscanf (f, "%c %d", val, seqno);
909 static int zebra_begin_read (ZebraHandle zh)
919 if (zh->trans_no != 1)
921 zebra_flush_reg (zh);
930 zebra_get_state (zh, &val, &seqno);
936 else if (seqno != zh->reg->seqno)
938 yaz_log (LOG_LOG, "reopen seqno cur/old %d/%d",
939 seqno, zh->reg->seqno);
942 else if (zh->reg->last_val != val)
944 yaz_log (LOG_LOG, "reopen last cur/old %d/%d",
945 val, zh->reg->last_val);
952 zebra_lock_r (zh->lock_shadow);
954 zebra_lock_r (zh->lock_normal);
957 zebra_register_close (zh->service, zh->reg);
958 zh->reg = zebra_register_open (zh->service, zh->reg_name,
959 0, val == 'c' ? 1 : 0,
960 zh->res, zh->path_reg);
966 zh->reg->last_val = val;
967 zh->reg->seqno = seqno;
972 static void zebra_end_read (ZebraHandle zh)
976 if (zh->trans_no != 0)
979 zebra_unlock (zh->lock_normal);
980 zebra_unlock (zh->lock_shadow);
983 void zebra_begin_trans (ZebraHandle zh)
993 if (zh->trans_no != 1)
998 yaz_log (LOG_LOG, "zebra_begin_trans");
1004 rval = res_get (zh->res, "shadow");
1006 for (pass = 0; pass < 2; pass++)
1010 zebra_lock_r (zh->lock_normal);
1011 zebra_lock_w (zh->lock_shadow);
1015 zebra_lock_w (zh->lock_normal);
1016 zebra_lock_w (zh->lock_shadow);
1019 zebra_get_state (zh, &val, &seqno);
1022 yaz_log (LOG_LOG, "previous transaction didn't finish commit");
1023 zebra_unlock (zh->lock_shadow);
1024 zebra_unlock (zh->lock_normal);
1028 else if (val == 'd')
1032 BFiles bfs = bfs_create (res_get (zh->res, "shadow"),
1034 yaz_log (LOG_LOG, "previous transaction didn't reach commit");
1035 bf_commitClean (bfs, rval);
1040 yaz_log (LOG_WARN, "your previous transaction didn't finish");
1047 yaz_log (LOG_FATAL, "zebra_begin_trans couldn't finish commit");
1051 zebra_set_state (zh, 'd', seqno);
1053 zh->reg = zebra_register_open (zh->service, zh->reg_name,
1054 1, rval ? 1 : 0, zh->res,
1057 zh->reg->seqno = seqno;
1060 void zebra_end_trans (ZebraHandle zh)
1067 if (zh->trans_no != 0)
1070 yaz_log (LOG_LOG, "zebra_end_trans");
1071 rval = res_get (zh->res, "shadow");
1073 zebra_flush_reg (zh);
1075 zebra_register_close (zh->service, zh->reg);
1078 zebra_get_state (zh, &val, &seqno);
1081 BFiles bfs = bfs_create (rval, zh->path_reg);
1082 yaz_log (LOG_LOG, "deleting shadow stuff val=%c", val);
1083 bf_commitClean (bfs, rval);
1088 zebra_set_state (zh, 'o', seqno);
1090 zebra_unlock (zh->lock_shadow);
1091 zebra_unlock (zh->lock_normal);
1093 #if HAVE_SYS_TIMES_H
1095 logf (LOG_LOG, "user/system: %ld/%ld",
1096 (long) (zh->tms2.tms_utime - zh->tms1.tms_utime),
1097 (long) (zh->tms2.tms_stime - zh->tms1.tms_stime));
1102 void zebra_repository_update (ZebraHandle zh)
1104 zebra_begin_trans (zh);
1105 logf (LOG_LOG, "updating %s", zh->rGroup.path);
1106 repositoryUpdate (zh);
1107 zebra_end_trans (zh);
1110 void zebra_repository_delete (ZebraHandle zh)
1112 logf (LOG_LOG, "deleting %s", zh->rGroup.path);
1113 repositoryDelete (zh);
1116 void zebra_repository_show (ZebraHandle zh)
1118 repositoryShow (zh);
1121 int zebra_commit (ZebraHandle zh)
1133 rval = res_get (zh->res, "shadow");
1136 logf (LOG_WARN, "Cannot perform commit");
1137 logf (LOG_WARN, "No shadow area defined");
1141 zebra_lock_w (zh->lock_normal);
1142 zebra_lock_r (zh->lock_shadow);
1144 bfs = bfs_create (res_get (zh->res, "register"), zh->path_reg);
1146 zebra_get_state (zh, &val, &seqno);
1149 bf_cache (bfs, rval);
1150 if (bf_commitExists (bfs))
1152 zebra_set_state (zh, 'c', seqno);
1154 logf (LOG_LOG, "commit start");
1158 bf_commitExec (bfs);
1162 logf (LOG_LOG, "commit clean");
1163 bf_commitClean (bfs, rval);
1165 zebra_set_state (zh, 'o', seqno);
1169 logf (LOG_LOG, "nothing to commit");
1173 zebra_unlock (zh->lock_shadow);
1174 zebra_unlock (zh->lock_normal);
1178 int zebra_init (ZebraHandle zh)
1188 rval = res_get (zh->res, "shadow");
1190 bfs = bfs_create (res_get (zh->service->global_res, "register"),
1193 bf_cache (bfs, rval);
1197 zebra_set_state (zh, 'o', 0);
1201 int zebra_compact (ZebraHandle zh)
1209 bfs = bfs_create (res_get (zh->res, "register"), zh->path_reg);
1215 int zebra_record_insert (ZebraHandle zh, const char *buf, int len)
1218 zebra_begin_trans (zh);
1219 extract_rec_in_mem (zh, "grs.sgml",
1221 "Default", /* database */
1222 0 /* delete_flag */,
1227 0 /* match criteria */);
1228 zebra_end_trans (zh);
1232 void zebra_set_group (ZebraHandle zh, struct recordGroup *rg)
1234 memcpy (&zh->rGroup, rg, sizeof(*rg));
1237 void zebra_result (ZebraHandle zh, int *code, char **addinfo)
1239 *code = zh->errCode;
1240 *addinfo = zh->errString;