2 * Copyright (C) 1995-2002, Index Data
5 * $Id: zebraapi.c,v 1.52 2002-04-04 20:50:37 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;
193 zebraRankInstall (reg, rank1_class);
195 recordCompression = res_get_def (res, "recordCompression", "none");
196 if (!strcmp (recordCompression, "none"))
197 record_compression = REC_COMPRESS_NONE;
198 if (!strcmp (recordCompression, "bzip2"))
199 record_compression = REC_COMPRESS_BZIP2;
201 if (!(reg->records = rec_open (reg->bfs, rw, record_compression)))
203 logf (LOG_WARN, "rec_open");
208 reg->matchDict = dict_open (reg->bfs, GMATCH_DICT, 20, 1, 0);
210 if (!(reg->dict = dict_open (reg->bfs, FNAME_DICT, 40, rw, 0)))
212 logf (LOG_WARN, "dict_open");
215 if (!(reg->sortIdx = sortIdx_open (reg->bfs, rw)))
217 logf (LOG_WARN, "sortIdx_open");
220 if (res_get_match (res, "isam", "s", ISAM_DEFAULT))
222 struct ISAMS_M_s isams_m;
223 if (!(reg->isams = isams_open (reg->bfs, FNAME_ISAMS, rw,
224 key_isams_m(res, &isams_m))))
226 logf (LOG_WARN, "isams_open");
231 else if (res_get_match (res, "isam", "i", ISAM_DEFAULT))
233 if (!(reg->isam = is_open (reg->bfs, FNAME_ISAM, key_compare, rw,
234 sizeof (struct it_key), res)))
236 logf (LOG_WARN, "is_open");
240 else if (res_get_match (res, "isam", "c", ISAM_DEFAULT))
242 struct ISAMC_M_s isamc_m;
243 if (!(reg->isamc = isc_open (reg->bfs, FNAME_ISAMC,
244 rw, key_isamc_m(res, &isamc_m))))
246 logf (LOG_WARN, "isc_open");
250 else if (res_get_match (res, "isam", "d", ISAM_DEFAULT))
252 struct ISAMD_M_s isamd_m;
254 if (!(reg->isamd = isamd_open (reg->bfs, FNAME_ISAMD,
255 rw, key_isamd_m(res, &isamd_m))))
257 logf (LOG_WARN, "isamd_open");
262 reg->zei = zebraExplain_open (reg->records, reg->dh,
267 logf (LOG_WARN, "Cannot obtain EXPLAIN information");
271 yaz_log (LOG_LOG, "zebra_register_open ok p=%p", reg);
275 void zebra_admin_shutdown (ZebraHandle zh)
277 zebra_mutex_cond_lock (&zh->service->session_lock);
278 zh->service->stop_flag = 1;
279 zebra_mutex_cond_unlock (&zh->service->session_lock);
282 void zebra_admin_start (ZebraHandle zh)
284 ZebraService zs = zh->service;
286 zebra_mutex_cond_lock (&zs->session_lock);
287 zebra_mutex_cond_unlock (&zs->session_lock);
290 static void zebra_register_close (ZebraService zs, struct zebra_register *reg)
292 yaz_log(LOG_LOG, "zebra_register_close p=%p", reg);
297 zebraExplain_close (reg->zei, 0);
298 dict_close (reg->dict);
300 dict_close (reg->matchDict);
301 sortIdx_close (reg->sortIdx);
303 isams_close (reg->isams);
306 is_close (reg->isam);
308 isc_close (reg->isamc);
310 isamd_close (reg->isamd);
312 rec_close (®->records);
315 recTypes_destroy (reg->recTypes);
316 zebra_maps_close (reg->zebra_maps);
317 zebraRankDestroy (reg);
318 bfs_destroy (reg->bfs);
319 data1_destroy (reg->dh);
321 xfree (reg->key_buf);
324 yaz_log (LOG_LOG, "zebra_register_close 2");
327 void zebra_stop(ZebraService zs)
331 yaz_log (LOG_LOG, "zebra_stop");
333 zebra_mutex_cond_lock (&zs->session_lock);
336 zebra_close (zs->sessions);
339 zebra_mutex_cond_unlock (&zs->session_lock);
341 zebra_mutex_cond_destroy (&zs->session_lock);
344 passwd_db_close (zs->passwd_db);
346 res_close (zs->global_res);
347 xfree (zs->configName);
348 xfree (zs->path_root);
352 void zebra_close (ZebraHandle zh)
355 struct zebra_session **sp;
361 yaz_log (LOG_LOG, "zebra_close zh=%p", zh);
364 resultSetDestroy (zh, -1, 0, 0);
368 zebra_register_close (zh->service, zh->reg);
369 zebra_close_res (zh);
371 xfree (zh->admin_databaseName);
372 zebra_mutex_cond_lock (&zs->session_lock);
373 zebra_lock_destroy (zh->lock_normal);
374 zebra_lock_destroy (zh->lock_shadow);
386 // if (!zs->sessions && zs->stop_flag)
387 // zebra_register_deactivate(zs);
388 zebra_mutex_cond_unlock (&zs->session_lock);
389 xfree (zh->reg_name);
391 yaz_log (LOG_LOG, "zebra_close zh=%p end", zh);}
393 struct map_baseinfo {
399 char **new_basenames;
403 static Res zebra_open_res (ZebraHandle zh)
409 sprintf (fname, "%.200s/zebra.cfg", zh->path_reg);
410 res = res_open (fname, zh->service->global_res);
412 res = zh->service->global_res;
414 else if (*zh->reg_name == 0)
416 res = zh->service->global_res;
420 yaz_log (LOG_WARN, "no register root specified");
421 return 0; /* no path for register - fail! */
426 static void zebra_close_res (ZebraHandle zh)
428 if (zh->res != zh->service->global_res)
433 static int zebra_select_register (ZebraHandle zh, const char *new_reg)
435 if (zh->res && strcmp (zh->reg_name, new_reg) == 0)
439 assert (zh->reg == 0);
440 assert (*zh->reg_name == 0);
446 resultSetInvalidate (zh);
447 zebra_register_close (zh->service, zh->reg);
452 xfree (zh->reg_name);
453 zh->reg_name = xstrdup (new_reg);
455 xfree (zh->path_reg);
457 if (zh->service->path_root)
459 zh->path_reg = xmalloc (strlen(zh->service->path_root) +
460 strlen(zh->reg_name) + 3);
461 strcpy (zh->path_reg, zh->service->path_root);
464 strcat (zh->path_reg, "/");
465 strcat (zh->path_reg, zh->reg_name);
468 zh->res = zebra_open_res (zh);
471 zebra_lock_destroy (zh->lock_normal);
475 zebra_lock_destroy (zh->lock_shadow);
481 const char *lock_area =res_get (zh->res, "lockDir");
483 if (!lock_area && zh->path_reg)
484 res_put (zh->res, "lockDir", zh->path_reg);
485 sprintf (fname, "norm.%s.LCK", zh->reg_name);
487 zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0);
489 sprintf (fname, "shadow.%s.LCK", zh->reg_name);
491 zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0);
497 void map_basenames_func (void *vp, const char *name, const char *value)
499 struct map_baseinfo *p = (struct map_baseinfo *) vp;
501 char fromdb[128], todb[8][128];
504 sscanf (value, "%127s %127s %127s %127s %127s %127s %127s %127s %127s",
505 fromdb, todb[0], todb[1], todb[2], todb[3], todb[4],
506 todb[5], todb[6], todb[7]);
510 for (i = 0; i<p->num_bases; i++)
511 if (p->basenames[i] && !strcmp (p->basenames[i], fromdb))
514 for (i = 0; i < no; i++)
516 if (p->new_num_bases == p->new_num_max)
518 p->new_basenames[(p->new_num_bases)++] =
519 nmem_strdup (p->mem, todb[i]);
525 void map_basenames (ZebraHandle zh, ODR stream,
526 int *num_bases, char ***basenames)
528 struct map_baseinfo info;
529 struct map_baseinfo *p = &info;
533 info.num_bases = *num_bases;
534 info.basenames = *basenames;
535 info.new_num_max = 128;
536 info.new_num_bases = 0;
537 info.new_basenames = (char **)
538 odr_malloc (stream, sizeof(*info.new_basenames) * info.new_num_max);
539 info.mem = stream->mem;
541 res_trav (zh->service->global_res, "mapdb", &info, map_basenames_func);
543 for (i = 0; i<p->num_bases; i++)
544 if (p->basenames[i] && p->new_num_bases < p->new_num_max)
546 p->new_basenames[(p->new_num_bases)++] =
547 nmem_strdup (p->mem, p->basenames[i]);
549 *num_bases = info.new_num_bases;
550 *basenames = info.new_basenames;
551 for (i = 0; i<*num_bases; i++)
552 logf (LOG_LOG, "base %s", (*basenames)[i]);
555 int zebra_select_database (ZebraHandle zh, const char *basename)
557 return zebra_select_databases (zh, 1, &basename);
560 int zebra_select_databases (ZebraHandle zh, int num_bases,
561 const char **basenames)
573 for (i = 0; i < zh->num_basenames; i++)
574 xfree (zh->basenames[i]);
575 xfree (zh->basenames);
577 zh->num_basenames = num_bases;
578 zh->basenames = xmalloc (zh->num_basenames * sizeof(*zh->basenames));
579 for (i = 0; i < zh->num_basenames; i++)
580 zh->basenames[i] = xstrdup (basenames[i]);
582 cp = strrchr(basenames[0], '/');
585 len = cp - basenames[0];
586 new_reg = xmalloc (len + 1);
587 memcpy (new_reg, basenames[0], len);
591 new_reg = xstrdup ("");
592 for (i = 1; i<num_bases; i++)
596 cp1 = strrchr (basenames[i], '/');
604 if (len != cp - basenames[i] ||
605 memcmp (basenames[i], new_reg, len))
620 zebra_select_register (zh, new_reg);
630 void zebra_search_rpn (ZebraHandle zh, ODR decode, ODR stream,
631 Z_RPNQuery *query, const char *setname, int *hits)
636 if (zebra_begin_read (zh))
638 resultSetAddRPN (zh, decode, stream, query,
639 zh->num_basenames, zh->basenames, setname);
646 void zebra_records_retrieve (ZebraHandle zh, ODR stream,
647 const char *setname, Z_RecordComposition *comp,
648 oid_value input_format, int num_recs,
649 ZebraRetrievalRecord *recs)
657 zh->errString = odr_strdup (stream, setname);
661 if (zebra_begin_read (zh))
664 pos_array = (int *) xmalloc (num_recs * sizeof(*pos_array));
665 for (i = 0; i<num_recs; i++)
666 pos_array[i] = recs[i].position;
667 poset = zebraPosSetCreate (zh, setname, num_recs, pos_array);
670 logf (LOG_DEBUG, "zebraPosSetCreate error");
672 zh->errString = nmem_strdup (stream->mem, setname);
676 for (i = 0; i<num_recs; i++)
681 recs[i].format = VAL_SUTRS;
682 recs[i].len = strlen(poset[i].term);
683 recs[i].buf = poset[i].term;
684 recs[i].base = poset[i].db;
686 else if (poset[i].sysno)
689 zebra_record_fetch (zh, poset[i].sysno, poset[i].score,
690 stream, input_format, comp,
691 &recs[i].format, &recs[i].buf,
694 recs[i].errString = NULL;
700 sprintf (num_str, "%d", pos_array[i]);
702 zh->errString = odr_strdup (stream, num_str);
706 zebraPosSetDestroy (zh, poset, num_recs);
712 void zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
713 oid_value attributeset,
714 int *position, int *num_entries, ZebraScanEntry **entries,
717 if (zebra_begin_read (zh))
723 rpn_scan (zh, stream, zapt, attributeset,
724 zh->num_basenames, zh->basenames, position,
725 num_entries, entries, is_partial);
729 void zebra_sort (ZebraHandle zh, ODR stream,
730 int num_input_setnames, const char **input_setnames,
731 const char *output_setname, Z_SortKeySpecList *sort_sequence,
734 if (zebra_begin_read (zh))
736 resultSetSort (zh, stream->mem, num_input_setnames, input_setnames,
737 output_setname, sort_sequence, sort_status);
741 int zebra_deleleResultSet(ZebraHandle zh, int function,
742 int num_setnames, char **setnames,
746 if (zebra_begin_read(zh))
747 return Z_DeleteStatus_systemProblemAtTarget;
750 case Z_DeleteRequest_list:
751 resultSetDestroy (zh, num_setnames, setnames, statuses);
753 case Z_DeleteRequest_all:
754 resultSetDestroy (zh, -1, 0, statuses);
758 status = Z_DeleteStatus_success;
759 for (i = 0; i<num_setnames; i++)
760 if (statuses[i] == Z_DeleteStatus_resultSetDidNotExist)
761 status = statuses[i];
765 int zebra_errCode (ZebraHandle zh)
770 const char *zebra_errString (ZebraHandle zh)
772 return diagbib1_str (zh->errCode);
775 char *zebra_errAdd (ZebraHandle zh)
777 return zh->errString;
780 int zebra_auth (ZebraHandle zh, const char *user, const char *pass)
782 ZebraService zs = zh->service;
783 if (!zs->passwd_db || !passwd_db_auth (zs->passwd_db, user, pass))
785 logf(LOG_APP,"AUTHOK:%s", user?user:"ANONYMOUS");
789 logf(LOG_APP,"AUTHFAIL:%s", user?user:"ANONYMOUS");
793 void zebra_admin_import_begin (ZebraHandle zh, const char *database)
795 zebra_begin_trans (zh);
796 xfree (zh->admin_databaseName);
797 zh->admin_databaseName = xstrdup(database);
800 void zebra_admin_import_end (ZebraHandle zh)
802 zebra_end_trans (zh);
805 void zebra_admin_import_segment (ZebraHandle zh, Z_Segment *segment)
809 for (i = 0; i<segment->num_segmentRecords; i++)
811 Z_NamePlusRecord *npr = segment->segmentRecords[i];
812 const char *databaseName = npr->databaseName;
815 databaseName = zh->admin_databaseName;
816 printf ("--------------%d--------------------\n", i);
817 if (npr->which == Z_NamePlusRecord_intermediateFragment)
819 Z_FragmentSyntax *fragment = npr->u.intermediateFragment;
820 if (fragment->which == Z_FragmentSyntax_notExternallyTagged)
822 Odr_oct *oct = fragment->u.notExternallyTagged;
823 printf ("%.*s", (oct->len > 100 ? 100 : oct->len) ,
827 extract_rec_in_mem (zh, "grs.sgml",
835 0 /* match criteria */);
841 void zebra_admin_create (ZebraHandle zh, const char *database)
845 zebra_begin_trans (zh);
848 /* announce database */
849 if (zebraExplain_newDatabase (zh->reg->zei, database, 0
850 /* explainDatabase */))
853 zh->errString = "Database already exist";
855 zebra_end_trans (zh);
858 int zebra_string_norm (ZebraHandle zh, unsigned reg_id,
859 const char *input_str, int input_len,
860 char *output_str, int output_len)
863 if (!zh->reg->zebra_maps)
865 wrbuf = zebra_replace(zh->reg->zebra_maps, reg_id, "",
866 input_str, input_len);
869 if (wrbuf_len(wrbuf) >= output_len)
871 if (wrbuf_len(wrbuf))
872 memcpy (output_str, wrbuf_buf(wrbuf), wrbuf_len(wrbuf));
873 output_str[wrbuf_len(wrbuf)] = '\0';
874 return wrbuf_len(wrbuf);
878 void zebra_set_state (ZebraHandle zh, int val, int seqno)
880 char state_fname[256];
885 sprintf (state_fname, "state.%s.LCK", zh->reg_name);
886 fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
887 f = fopen (fname, "w");
889 yaz_log (LOG_LOG, "%c %d %ld", val, seqno, p);
890 fprintf (f, "%c %d %ld\n", val, seqno, p);
895 void zebra_get_state (ZebraHandle zh, char *val, int *seqno)
897 char state_fname[256];
901 sprintf (state_fname, "state.%s.LCK", zh->reg_name);
902 fname = zebra_mk_fname (res_get(zh->res, "lockDir"), state_fname);
903 f = fopen (fname, "r");
909 fscanf (f, "%c %d", val, seqno);
915 static int zebra_begin_read (ZebraHandle zh)
925 if (zh->trans_no != 1)
927 zebra_flush_reg (zh);
936 zebra_get_state (zh, &val, &seqno);
942 else if (seqno != zh->reg->seqno)
944 yaz_log (LOG_LOG, "reopen seqno cur/old %d/%d",
945 seqno, zh->reg->seqno);
948 else if (zh->reg->last_val != val)
950 yaz_log (LOG_LOG, "reopen last cur/old %d/%d",
951 val, zh->reg->last_val);
958 zebra_lock_r (zh->lock_shadow);
960 zebra_lock_r (zh->lock_normal);
963 zebra_register_close (zh->service, zh->reg);
964 zh->reg = zebra_register_open (zh->service, zh->reg_name,
965 0, val == 'c' ? 1 : 0,
966 zh->res, zh->path_reg);
972 zh->reg->last_val = val;
973 zh->reg->seqno = seqno;
978 static void zebra_end_read (ZebraHandle zh)
982 if (zh->trans_no != 0)
985 zebra_unlock (zh->lock_normal);
986 zebra_unlock (zh->lock_shadow);
989 void zebra_begin_trans (ZebraHandle zh)
999 if (zh->trans_no != 1)
1004 yaz_log (LOG_LOG, "zebra_begin_trans");
1005 #if HAVE_SYS_TIMES_H
1010 rval = res_get (zh->res, "shadow");
1012 for (pass = 0; pass < 2; pass++)
1016 zebra_lock_r (zh->lock_normal);
1017 zebra_lock_w (zh->lock_shadow);
1021 zebra_lock_w (zh->lock_normal);
1022 zebra_lock_w (zh->lock_shadow);
1025 zebra_get_state (zh, &val, &seqno);
1028 yaz_log (LOG_LOG, "previous transaction didn't finish commit");
1029 zebra_unlock (zh->lock_shadow);
1030 zebra_unlock (zh->lock_normal);
1034 else if (val == 'd')
1038 BFiles bfs = bfs_create (res_get (zh->res, "shadow"),
1040 yaz_log (LOG_LOG, "previous transaction didn't reach commit");
1041 bf_commitClean (bfs, rval);
1046 yaz_log (LOG_WARN, "your previous transaction didn't finish");
1053 yaz_log (LOG_FATAL, "zebra_begin_trans couldn't finish commit");
1057 zebra_set_state (zh, 'd', seqno);
1059 zh->reg = zebra_register_open (zh->service, zh->reg_name,
1060 1, rval ? 1 : 0, zh->res,
1063 zh->reg->seqno = seqno;
1066 void zebra_end_trans (ZebraHandle zh)
1073 if (zh->trans_no != 0)
1076 yaz_log (LOG_LOG, "zebra_end_trans");
1077 rval = res_get (zh->res, "shadow");
1079 zebra_flush_reg (zh);
1081 zebra_register_close (zh->service, zh->reg);
1084 zebra_get_state (zh, &val, &seqno);
1087 BFiles bfs = bfs_create (rval, zh->path_reg);
1088 yaz_log (LOG_LOG, "deleting shadow stuff val=%c", val);
1089 bf_commitClean (bfs, rval);
1094 zebra_set_state (zh, 'o', seqno);
1096 zebra_unlock (zh->lock_shadow);
1097 zebra_unlock (zh->lock_normal);
1099 #if HAVE_SYS_TIMES_H
1101 logf (LOG_LOG, "user/system: %ld/%ld",
1102 (long) (zh->tms2.tms_utime - zh->tms1.tms_utime),
1103 (long) (zh->tms2.tms_stime - zh->tms1.tms_stime));
1108 void zebra_repository_update (ZebraHandle zh)
1110 zebra_begin_trans (zh);
1111 logf (LOG_LOG, "updating %s", zh->rGroup.path);
1112 repositoryUpdate (zh);
1113 zebra_end_trans (zh);
1116 void zebra_repository_delete (ZebraHandle zh)
1118 logf (LOG_LOG, "deleting %s", zh->rGroup.path);
1119 repositoryDelete (zh);
1122 void zebra_repository_show (ZebraHandle zh)
1124 repositoryShow (zh);
1127 int zebra_commit (ZebraHandle zh)
1139 rval = res_get (zh->res, "shadow");
1142 logf (LOG_WARN, "Cannot perform commit");
1143 logf (LOG_WARN, "No shadow area defined");
1147 zebra_lock_w (zh->lock_normal);
1148 zebra_lock_r (zh->lock_shadow);
1150 bfs = bfs_create (res_get (zh->res, "register"), zh->path_reg);
1152 zebra_get_state (zh, &val, &seqno);
1155 bf_cache (bfs, rval);
1156 if (bf_commitExists (bfs))
1158 zebra_set_state (zh, 'c', seqno);
1160 logf (LOG_LOG, "commit start");
1162 bf_commitExec (bfs);
1166 logf (LOG_LOG, "commit clean");
1167 bf_commitClean (bfs, rval);
1169 zebra_set_state (zh, 'o', seqno);
1173 logf (LOG_LOG, "nothing to commit");
1177 zebra_unlock (zh->lock_shadow);
1178 zebra_unlock (zh->lock_normal);
1182 int zebra_init (ZebraHandle zh)
1192 rval = res_get (zh->res, "shadow");
1194 bfs = bfs_create (res_get (zh->service->global_res, "register"),
1197 bf_cache (bfs, rval);
1201 zebra_set_state (zh, 'o', 0);
1205 int zebra_compact (ZebraHandle zh)
1213 bfs = bfs_create (res_get (zh->res, "register"), zh->path_reg);
1219 int zebra_record_insert (ZebraHandle zh, const char *buf, int len)
1222 zebra_begin_trans (zh);
1223 extract_rec_in_mem (zh, "grs.sgml",
1225 "Default", /* database */
1226 0 /* delete_flag */,
1231 0 /* match criteria */);
1232 zebra_end_trans (zh);
1236 void zebra_set_group (ZebraHandle zh, struct recordGroup *rg)
1238 memcpy (&zh->rGroup, rg, sizeof(*rg));
1241 void zebra_result (ZebraHandle zh, int *code, char **addinfo)
1243 *code = zh->errCode;
1244 *addinfo = zh->errString;