2 * Copyright (C) 1995-2002, Index Data
5 * $Id: zebraapi.c,v 1.51 2002-04-04 14:14:13 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);
39 static void zebra_flush_reg (ZebraHandle zh)
41 zebraExplain_flush (zh->reg->zei, 1, zh);
43 extract_flushWriteKeys (zh);
44 zebra_index_merge (zh);
48 static struct zebra_register *zebra_register_open (ZebraService zs,
50 int rw, int useshadow,
52 const char *reg_path);
53 static void zebra_register_close (ZebraService zs, struct zebra_register *reg);
55 static int zebra_begin_read (ZebraHandle zh);
56 static void zebra_end_read (ZebraHandle zh);
58 ZebraHandle zebra_open (ZebraService zs)
64 zh = (ZebraHandle) xmalloc (sizeof(*zh));
65 yaz_log (LOG_LOG, "zebra_open zs=%p returns %p", zs, zh);
68 zh->reg = 0; /* no register attached yet */
75 zh->reg_name = xstrdup ("");
77 zh->num_basenames = 0;
85 zh->admin_databaseName = 0;
87 zebra_mutex_cond_lock (&zs->session_lock);
89 zh->next = zs->sessions;
92 zebra_mutex_cond_unlock (&zs->session_lock);
97 ZebraService zebra_start (const char *configName)
99 ZebraService zh = xmalloc (sizeof(*zh));
101 yaz_log (LOG_LOG, "zebra_start %s", configName);
103 zh->configName = xstrdup(configName);
106 if (!(zh->global_res = res_open (zh->configName, 0)))
108 logf (LOG_WARN, "Failed to read resources `%s'", zh->configName);
112 logf (LOG_LOG, "Read resources `%s'", zh->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, res_get (zh->global_res, "passwd"));
127 zh->path_root = res_get (zh->global_res, "root");
132 struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
133 int rw, int useshadow, Res res,
134 const char *reg_path)
136 struct zebra_register *reg;
137 int record_compression = REC_COMPRESS_NONE;
138 char *recordCompression = 0;
140 reg = xmalloc (sizeof(*reg));
143 reg->name = xstrdup (name);
150 yaz_log (LOG_LOG, "zebra_register_open rw = %d useshadow=%d p=%p",
153 reg->dh = data1_create ();
156 reg->bfs = bfs_create (res_get (res, "register"), reg_path);
159 data1_destroy(reg->dh);
163 bf_cache (reg->bfs, res_get (res, "shadow"));
164 data1_set_tabpath (reg->dh, res_get(res, "profilePath"));
165 reg->recTypes = recTypes_init (reg->dh);
166 recTypes_default_handlers (reg->recTypes);
168 reg->zebra_maps = zebra_maps_open (res);
169 reg->rank_classes = NULL;
173 reg->keys.buf_max = 0;
189 zebraRankInstall (reg, rank1_class);
191 recordCompression = res_get_def (res, "recordCompression", "none");
192 if (!strcmp (recordCompression, "none"))
193 record_compression = REC_COMPRESS_NONE;
194 if (!strcmp (recordCompression, "bzip2"))
195 record_compression = REC_COMPRESS_BZIP2;
197 if (!(reg->records = rec_open (reg->bfs, rw, record_compression)))
199 logf (LOG_WARN, "rec_open");
204 reg->matchDict = dict_open (reg->bfs, GMATCH_DICT, 20, 1, 0);
206 if (!(reg->dict = dict_open (reg->bfs, FNAME_DICT, 40, rw, 0)))
208 logf (LOG_WARN, "dict_open");
211 if (!(reg->sortIdx = sortIdx_open (reg->bfs, rw)))
213 logf (LOG_WARN, "sortIdx_open");
216 if (res_get_match (res, "isam", "s", ISAM_DEFAULT))
218 struct ISAMS_M_s isams_m;
219 if (!(reg->isams = isams_open (reg->bfs, FNAME_ISAMS, rw,
220 key_isams_m(res, &isams_m))))
222 logf (LOG_WARN, "isams_open");
227 else if (res_get_match (res, "isam", "i", ISAM_DEFAULT))
229 if (!(reg->isam = is_open (reg->bfs, FNAME_ISAM, key_compare, rw,
230 sizeof (struct it_key), res)))
232 logf (LOG_WARN, "is_open");
236 else if (res_get_match (res, "isam", "c", ISAM_DEFAULT))
238 struct ISAMC_M_s isamc_m;
239 if (!(reg->isamc = isc_open (reg->bfs, FNAME_ISAMC,
240 rw, key_isamc_m(res, &isamc_m))))
242 logf (LOG_WARN, "isc_open");
246 else if (res_get_match (res, "isam", "d", ISAM_DEFAULT))
248 struct ISAMD_M_s isamd_m;
250 if (!(reg->isamd = isamd_open (reg->bfs, FNAME_ISAMD,
251 rw, key_isamd_m(res, &isamd_m))))
253 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);
302 is_close (reg->isam);
304 isc_close (reg->isamc);
306 isamd_close (reg->isamd);
308 rec_close (®->records);
311 recTypes_destroy (reg->recTypes);
312 zebra_maps_close (reg->zebra_maps);
313 zebraRankDestroy (reg);
314 bfs_destroy (reg->bfs);
315 data1_destroy (reg->dh);
317 xfree (reg->key_buf);
320 yaz_log (LOG_LOG, "zebra_register_close 2");
323 void zebra_stop(ZebraService zs)
327 yaz_log (LOG_LOG, "zebra_stop");
329 zebra_mutex_cond_lock (&zs->session_lock);
332 zebra_close (zs->sessions);
335 zebra_mutex_cond_unlock (&zs->session_lock);
337 zebra_mutex_cond_destroy (&zs->session_lock);
340 passwd_db_close (zs->passwd_db);
342 res_close (zs->global_res);
343 xfree (zs->configName);
344 xfree (zs->path_root);
348 void zebra_close (ZebraHandle zh)
351 struct zebra_session **sp;
357 yaz_log (LOG_LOG, "zebra_close zh=%p", zh);
360 resultSetDestroy (zh, -1, 0, 0);
364 zebra_register_close (zh->service, zh->reg);
365 zebra_close_res (zh);
367 xfree (zh->admin_databaseName);
368 zebra_mutex_cond_lock (&zs->session_lock);
369 zebra_lock_destroy (zh->lock_normal);
370 zebra_lock_destroy (zh->lock_shadow);
382 // if (!zs->sessions && zs->stop_flag)
383 // zebra_register_deactivate(zs);
384 zebra_mutex_cond_unlock (&zs->session_lock);
385 xfree (zh->reg_name);
387 yaz_log (LOG_LOG, "zebra_close zh=%p end", zh);}
389 struct map_baseinfo {
395 char **new_basenames;
399 static Res zebra_open_res (ZebraHandle zh)
403 if (*zh->reg_name == 0)
405 res = zh->service->global_res;
406 yaz_log (LOG_LOG, "local res = global res");
408 else if (zh->path_reg)
410 sprintf (fname, "%.200s/zebra.cfg", zh->path_reg);
411 yaz_log (LOG_LOG, "res_open(%s)", fname);
412 res = res_open (fname, zh->service->global_res);
417 return 0; /* no path for register - fail! */
421 static void zebra_close_res (ZebraHandle zh)
423 if (zh->res != zh->service->global_res)
428 static int zebra_select_register (ZebraHandle zh, const char *new_reg)
430 if (zh->res && strcmp (zh->reg_name, new_reg) == 0)
434 assert (zh->reg == 0);
435 assert (*zh->reg_name == 0);
441 resultSetInvalidate (zh);
442 zebra_register_close (zh->service, zh->reg);
447 xfree (zh->reg_name);
448 zh->reg_name = xstrdup (new_reg);
450 xfree (zh->path_reg);
452 if (zh->service->path_root)
454 zh->path_reg = xmalloc (strlen(zh->service->path_root) +
455 strlen(zh->reg_name) + 3);
456 strcpy (zh->path_reg, zh->service->path_root);
459 strcat (zh->path_reg, "/");
460 strcat (zh->path_reg, zh->reg_name);
463 zh->res = zebra_open_res (zh);
466 zebra_lock_destroy (zh->lock_normal);
470 zebra_lock_destroy (zh->lock_shadow);
476 const char *lock_area =res_get (zh->res, "lockDir");
478 if (!lock_area && zh->path_reg)
479 res_put (zh->res, "lockDir", zh->path_reg);
480 sprintf (fname, "norm.%s.LCK", zh->reg_name);
482 zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0);
484 sprintf (fname, "shadow.%s.LCK", zh->reg_name);
486 zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0);
492 void map_basenames_func (void *vp, const char *name, const char *value)
494 struct map_baseinfo *p = (struct map_baseinfo *) vp;
496 char fromdb[128], todb[8][128];
499 sscanf (value, "%127s %127s %127s %127s %127s %127s %127s %127s %127s",
500 fromdb, todb[0], todb[1], todb[2], todb[3], todb[4],
501 todb[5], todb[6], todb[7]);
505 for (i = 0; i<p->num_bases; i++)
506 if (p->basenames[i] && !strcmp (p->basenames[i], fromdb))
509 for (i = 0; i < no; i++)
511 if (p->new_num_bases == p->new_num_max)
513 p->new_basenames[(p->new_num_bases)++] =
514 nmem_strdup (p->mem, todb[i]);
520 void map_basenames (ZebraHandle zh, ODR stream,
521 int *num_bases, char ***basenames)
523 struct map_baseinfo info;
524 struct map_baseinfo *p = &info;
528 info.num_bases = *num_bases;
529 info.basenames = *basenames;
530 info.new_num_max = 128;
531 info.new_num_bases = 0;
532 info.new_basenames = (char **)
533 odr_malloc (stream, sizeof(*info.new_basenames) * info.new_num_max);
534 info.mem = stream->mem;
536 res_trav (zh->service->global_res, "mapdb", &info, map_basenames_func);
538 for (i = 0; i<p->num_bases; i++)
539 if (p->basenames[i] && p->new_num_bases < p->new_num_max)
541 p->new_basenames[(p->new_num_bases)++] =
542 nmem_strdup (p->mem, p->basenames[i]);
544 *num_bases = info.new_num_bases;
545 *basenames = info.new_basenames;
546 for (i = 0; i<*num_bases; i++)
547 logf (LOG_LOG, "base %s", (*basenames)[i]);
550 int zebra_select_database (ZebraHandle zh, const char *basename)
552 return zebra_select_databases (zh, 1, &basename);
555 int zebra_select_databases (ZebraHandle zh, int num_bases,
556 const char **basenames)
568 for (i = 0; i < zh->num_basenames; i++)
569 xfree (zh->basenames[i]);
570 xfree (zh->basenames);
572 zh->num_basenames = num_bases;
573 zh->basenames = xmalloc (zh->num_basenames * sizeof(*zh->basenames));
574 for (i = 0; i < zh->num_basenames; i++)
575 zh->basenames[i] = xstrdup (basenames[i]);
577 cp = strrchr(basenames[0], '/');
580 len = cp - basenames[0];
581 new_reg = xmalloc (len + 1);
582 memcpy (new_reg, basenames[0], len);
586 new_reg = xstrdup ("");
587 for (i = 1; i<num_bases; i++)
591 cp1 = strrchr (basenames[i], '/');
599 if (len != cp - basenames[i] ||
600 memcmp (basenames[i], new_reg, len))
615 zebra_select_register (zh, new_reg);
625 void zebra_search_rpn (ZebraHandle zh, ODR decode, ODR stream,
626 Z_RPNQuery *query, const char *setname, int *hits)
631 if (zebra_begin_read (zh))
633 resultSetAddRPN (zh, decode, stream, query,
634 zh->num_basenames, zh->basenames, setname);
638 logf(LOG_APP,"SEARCH:%d:",zh->hits);
642 void zebra_records_retrieve (ZebraHandle zh, ODR stream,
643 const char *setname, Z_RecordComposition *comp,
644 oid_value input_format, int num_recs,
645 ZebraRetrievalRecord *recs)
653 zh->errString = odr_strdup (stream, setname);
657 if (zebra_begin_read (zh))
660 pos_array = (int *) xmalloc (num_recs * sizeof(*pos_array));
661 for (i = 0; i<num_recs; i++)
662 pos_array[i] = recs[i].position;
663 poset = zebraPosSetCreate (zh, setname, num_recs, pos_array);
666 logf (LOG_DEBUG, "zebraPosSetCreate error");
668 zh->errString = nmem_strdup (stream->mem, setname);
672 for (i = 0; i<num_recs; i++)
677 recs[i].format = VAL_SUTRS;
678 recs[i].len = strlen(poset[i].term);
679 recs[i].buf = poset[i].term;
680 recs[i].base = poset[i].db;
682 else if (poset[i].sysno)
685 zebra_record_fetch (zh, poset[i].sysno, poset[i].score,
686 stream, input_format, comp,
687 &recs[i].format, &recs[i].buf,
690 recs[i].errString = NULL;
696 sprintf (num_str, "%d", pos_array[i]);
698 zh->errString = odr_strdup (stream, num_str);
702 zebraPosSetDestroy (zh, poset, num_recs);
708 void zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
709 oid_value attributeset,
710 int *position, int *num_entries, ZebraScanEntry **entries,
713 if (zebra_begin_read (zh))
719 rpn_scan (zh, stream, zapt, attributeset,
720 zh->num_basenames, zh->basenames, position,
721 num_entries, entries, is_partial);
725 void zebra_sort (ZebraHandle zh, ODR stream,
726 int num_input_setnames, const char **input_setnames,
727 const char *output_setname, Z_SortKeySpecList *sort_sequence,
730 if (zebra_begin_read (zh))
732 resultSetSort (zh, stream->mem, num_input_setnames, input_setnames,
733 output_setname, sort_sequence, sort_status);
737 int zebra_deleleResultSet(ZebraHandle zh, int function,
738 int num_setnames, char **setnames,
742 if (zebra_begin_read(zh))
743 return Z_DeleteStatus_systemProblemAtTarget;
746 case Z_DeleteRequest_list:
747 resultSetDestroy (zh, num_setnames, setnames, statuses);
749 case Z_DeleteRequest_all:
750 resultSetDestroy (zh, -1, 0, statuses);
754 status = Z_DeleteStatus_success;
755 for (i = 0; i<num_setnames; i++)
756 if (statuses[i] == Z_DeleteStatus_resultSetDidNotExist)
757 status = statuses[i];
761 int zebra_errCode (ZebraHandle zh)
766 const char *zebra_errString (ZebraHandle zh)
768 return diagbib1_str (zh->errCode);
771 char *zebra_errAdd (ZebraHandle zh)
773 return zh->errString;
776 int zebra_auth (ZebraHandle zh, const char *user, const char *pass)
778 ZebraService zs = zh->service;
779 if (!zs->passwd_db || !passwd_db_auth (zs->passwd_db, user, pass))
781 logf(LOG_APP,"AUTHOK:%s", user?user:"ANONYMOUS");
785 logf(LOG_APP,"AUTHFAIL:%s", user?user:"ANONYMOUS");
789 void zebra_admin_import_begin (ZebraHandle zh, const char *database)
791 zebra_begin_trans (zh);
792 xfree (zh->admin_databaseName);
793 zh->admin_databaseName = xstrdup(database);
796 void zebra_admin_import_end (ZebraHandle zh)
798 zebra_end_trans (zh);
801 void zebra_admin_import_segment (ZebraHandle zh, Z_Segment *segment)
805 for (i = 0; i<segment->num_segmentRecords; i++)
807 Z_NamePlusRecord *npr = segment->segmentRecords[i];
808 const char *databaseName = npr->databaseName;
811 databaseName = zh->admin_databaseName;
812 printf ("--------------%d--------------------\n", i);
813 if (npr->which == Z_NamePlusRecord_intermediateFragment)
815 Z_FragmentSyntax *fragment = npr->u.intermediateFragment;
816 if (fragment->which == Z_FragmentSyntax_notExternallyTagged)
818 Odr_oct *oct = fragment->u.notExternallyTagged;
819 printf ("%.*s", (oct->len > 100 ? 100 : oct->len) ,
823 extract_rec_in_mem (zh, "grs.sgml",
831 0 /* match criteria */);
837 void zebra_admin_create (ZebraHandle zh, const char *database)
841 zebra_begin_trans (zh);
844 /* announce database */
845 if (zebraExplain_newDatabase (zh->reg->zei, database, 0
846 /* explainDatabase */))
849 zh->errString = "Database already exist";
851 zebra_end_trans (zh);
854 int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
855 const char *input_str, int input_len,
856 char *output_str, int output_len)
859 if (!zh->reg->zebra_maps)
861 wrbuf = zebra_replace(zh->reg->zebra_maps, reg_id, "",
862 input_str, input_len);
865 if (wrbuf_len(wrbuf) >= output_len)
867 if (wrbuf_len(wrbuf))
868 memcpy (output_str, wrbuf_buf(wrbuf), wrbuf_len(wrbuf));
869 output_str[wrbuf_len(wrbuf)] = '\0';
870 return wrbuf_len(wrbuf);
874 void zebra_set_state (ZebraHandle zh, int val, int seqno)
876 char state_fname[256];
881 sprintf (state_fname, "state.%s.LCK", zh->reg_name);
882 fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
883 f = fopen (fname, "w");
885 yaz_log (LOG_LOG, "%c %d %ld", val, seqno, p);
886 fprintf (f, "%c %d %ld\n", val, seqno, p);
891 void zebra_get_state (ZebraHandle zh, char *val, int *seqno)
893 char state_fname[256];
897 sprintf (state_fname, "state.%s.LCK", zh->reg_name);
898 fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
899 f = fopen (fname, "r");
905 fscanf (f, "%c %d", val, seqno);
911 static int zebra_begin_read (ZebraHandle zh)
921 if (zh->trans_no != 1)
923 zebra_flush_reg (zh);
932 zebra_get_state (zh, &val, &seqno);
938 else if (seqno != zh->reg->seqno)
940 yaz_log (LOG_LOG, "reopen seqno cur/old %d/%d",
941 seqno, zh->reg->seqno);
944 else if (zh->reg->last_val != val)
946 yaz_log (LOG_LOG, "reopen last cur/old %d/%d",
947 val, zh->reg->last_val);
954 zebra_lock_r (zh->lock_shadow);
956 zebra_lock_r (zh->lock_normal);
959 zebra_register_close (zh->service, zh->reg);
960 zh->reg = zebra_register_open (zh->service, zh->reg_name,
961 0, val == 'c' ? 1 : 0,
962 zh->res, zh->path_reg);
968 zh->reg->last_val = val;
969 zh->reg->seqno = seqno;
974 static void zebra_end_read (ZebraHandle zh)
978 if (zh->trans_no != 0)
981 zebra_unlock (zh->lock_normal);
982 zebra_unlock (zh->lock_shadow);
985 void zebra_begin_trans (ZebraHandle zh)
995 if (zh->trans_no != 1)
1000 yaz_log (LOG_LOG, "zebra_begin_trans");
1001 #if HAVE_SYS_TIMES_H
1006 rval = res_get (zh->res, "shadow");
1008 for (pass = 0; pass < 2; pass++)
1012 zebra_lock_r (zh->lock_normal);
1013 zebra_lock_w (zh->lock_shadow);
1017 zebra_lock_w (zh->lock_normal);
1018 zebra_lock_w (zh->lock_shadow);
1021 zebra_get_state (zh, &val, &seqno);
1024 yaz_log (LOG_LOG, "previous transaction didn't finish commit");
1025 zebra_unlock (zh->lock_shadow);
1026 zebra_unlock (zh->lock_normal);
1030 else if (val == 'd')
1034 BFiles bfs = bfs_create (res_get (zh->res, "shadow"),
1036 yaz_log (LOG_LOG, "previous transaction didn't reach commit");
1037 bf_commitClean (bfs, rval);
1042 yaz_log (LOG_WARN, "your previous transaction didn't finish");
1049 yaz_log (LOG_FATAL, "zebra_begin_trans couldn't finish commit");
1053 zebra_set_state (zh, 'd', seqno);
1055 zh->reg = zebra_register_open (zh->service, zh->reg_name,
1056 1, rval ? 1 : 0, zh->res,
1059 zh->reg->seqno = seqno;
1062 void zebra_end_trans (ZebraHandle zh)
1069 if (zh->trans_no != 0)
1072 yaz_log (LOG_LOG, "zebra_end_trans");
1073 rval = res_get (zh->res, "shadow");
1075 zebra_flush_reg (zh);
1077 zebra_register_close (zh->service, zh->reg);
1080 zebra_get_state (zh, &val, &seqno);
1083 BFiles bfs = bfs_create (rval, zh->path_reg);
1084 yaz_log (LOG_LOG, "deleting shadow stuff val=%c", val);
1085 bf_commitClean (bfs, rval);
1090 zebra_set_state (zh, 'o', seqno);
1092 zebra_unlock (zh->lock_shadow);
1093 zebra_unlock (zh->lock_normal);
1095 #if HAVE_SYS_TIMES_H
1097 logf (LOG_LOG, "user/system: %ld/%ld",
1098 (long) (zh->tms2.tms_utime - zh->tms1.tms_utime),
1099 (long) (zh->tms2.tms_stime - zh->tms1.tms_stime));
1104 void zebra_repository_update (ZebraHandle zh)
1106 zebra_begin_trans (zh);
1107 logf (LOG_LOG, "updating %s", zh->rGroup.path);
1108 repositoryUpdate (zh);
1109 zebra_end_trans (zh);
1112 void zebra_repository_delete (ZebraHandle zh)
1114 logf (LOG_LOG, "deleting %s", zh->rGroup.path);
1115 repositoryDelete (zh);
1118 void zebra_repository_show (ZebraHandle zh)
1120 repositoryShow (zh);
1123 int zebra_commit (ZebraHandle zh)
1135 rval = res_get (zh->res, "shadow");
1138 logf (LOG_WARN, "Cannot perform commit");
1139 logf (LOG_WARN, "No shadow area defined");
1143 zebra_lock_w (zh->lock_normal);
1144 zebra_lock_r (zh->lock_shadow);
1146 bfs = bfs_create (res_get (zh->res, "register"), zh->path_reg);
1148 zebra_get_state (zh, &val, &seqno);
1151 bf_cache (bfs, rval);
1152 if (bf_commitExists (bfs))
1154 zebra_set_state (zh, 'c', seqno);
1156 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;