2 * Copyright (C) 1995-2002, Index Data
5 * $Id: zebraapi.c,v 1.55 2002-04-15 13:48:11 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 zh->shadow_enable = 1;
88 zebra_mutex_cond_lock (&zs->session_lock);
90 zh->next = zs->sessions;
93 zebra_mutex_cond_unlock (&zs->session_lock);
98 ZebraService zebra_start (const char *configName)
102 yaz_log (LOG_LOG, "zebra_start %s", configName);
104 if (!(res = res_open (configName, 0)))
105 yaz_log (LOG_WARN, "Cannot read resources `%s'", configName);
108 ZebraService zh = xmalloc (sizeof(*zh));
110 yaz_log (LOG_LOG, "Read resources `%s'", configName);
112 zh->global_res = res;
113 zh->configName = xstrdup(configName);
118 zebra_mutex_cond_init (&zh->session_lock);
119 if (!res_get (zh->global_res, "passwd"))
120 zh->passwd_db = NULL;
123 zh->passwd_db = passwd_db_open ();
125 logf (LOG_WARN|LOG_ERRNO, "passwd_db_open failed");
127 passwd_db_file (zh->passwd_db,
128 res_get (zh->global_res, "passwd"));
130 zh->path_root = res_get (zh->global_res, "root");
137 struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
138 int rw, int useshadow, Res res,
139 const char *reg_path)
141 struct zebra_register *reg;
142 int record_compression = REC_COMPRESS_NONE;
143 char *recordCompression = 0;
145 reg = xmalloc (sizeof(*reg));
148 reg->name = xstrdup (name);
155 yaz_log (LOG_LOG, "zebra_register_open rw = %d useshadow=%d p=%p",
158 reg->dh = data1_create ();
161 reg->bfs = bfs_create (res_get (res, "register"), reg_path);
164 data1_destroy(reg->dh);
168 bf_cache (reg->bfs, res_get (res, "shadow"));
169 data1_set_tabpath (reg->dh, res_get(res, "profilePath"));
170 data1_set_tabroot (reg->dh, reg_path);
171 reg->recTypes = recTypes_init (reg->dh);
172 recTypes_default_handlers (reg->recTypes);
174 reg->zebra_maps = zebra_maps_open (res, reg_path);
175 reg->rank_classes = NULL;
179 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");
230 else if (res_get_match (res, "isam", "i", ISAM_DEFAULT))
232 if (!(reg->isam = is_open (reg->bfs, FNAME_ISAM, key_compare, rw,
233 sizeof (struct it_key), res)))
235 logf (LOG_WARN, "is_open");
239 else if (res_get_match (res, "isam", "c", ISAM_DEFAULT))
241 struct ISAMC_M_s isamc_m;
242 if (!(reg->isamc = isc_open (reg->bfs, FNAME_ISAMC,
243 rw, key_isamc_m(res, &isamc_m))))
245 logf (LOG_WARN, "isc_open");
249 else if (res_get_match (res, "isam", "d", ISAM_DEFAULT))
251 struct ISAMD_M_s isamd_m;
253 if (!(reg->isamd = isamd_open (reg->bfs, FNAME_ISAMD,
254 rw, key_isamd_m(res, &isamd_m))))
256 logf (LOG_WARN, "isamd_open");
260 reg->zei = zebraExplain_open (reg->records, reg->dh,
265 logf (LOG_WARN, "Cannot obtain EXPLAIN information");
269 yaz_log (LOG_LOG, "zebra_register_open ok p=%p", reg);
273 void zebra_admin_shutdown (ZebraHandle zh)
275 zebra_mutex_cond_lock (&zh->service->session_lock);
276 zh->service->stop_flag = 1;
277 zebra_mutex_cond_unlock (&zh->service->session_lock);
280 void zebra_admin_start (ZebraHandle zh)
282 ZebraService zs = zh->service;
284 zebra_mutex_cond_lock (&zs->session_lock);
285 zebra_mutex_cond_unlock (&zs->session_lock);
288 static void zebra_register_close (ZebraService zs, struct zebra_register *reg)
290 yaz_log(LOG_LOG, "zebra_register_close p=%p", reg);
295 zebraExplain_close (reg->zei, 0);
296 dict_close (reg->dict);
298 dict_close (reg->matchDict);
299 sortIdx_close (reg->sortIdx);
301 isams_close (reg->isams);
303 is_close (reg->isam);
305 isc_close (reg->isamc);
307 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)
405 sprintf (fname, "%.200s/zebra.cfg", zh->path_reg);
406 res = res_open (fname, zh->service->global_res);
408 res = zh->service->global_res;
410 else if (*zh->reg_name == 0)
412 res = zh->service->global_res;
416 yaz_log (LOG_WARN, "no register root specified");
417 return 0; /* no path for register - fail! */
422 static void zebra_close_res (ZebraHandle zh)
424 if (zh->res != zh->service->global_res)
429 static int zebra_select_register (ZebraHandle zh, const char *new_reg)
431 if (zh->res && strcmp (zh->reg_name, new_reg) == 0)
435 assert (zh->reg == 0);
436 assert (*zh->reg_name == 0);
442 resultSetInvalidate (zh);
443 zebra_register_close (zh->service, zh->reg);
448 xfree (zh->reg_name);
449 zh->reg_name = xstrdup (new_reg);
451 xfree (zh->path_reg);
453 if (zh->service->path_root)
455 zh->path_reg = xmalloc (strlen(zh->service->path_root) +
456 strlen(zh->reg_name) + 3);
457 strcpy (zh->path_reg, zh->service->path_root);
460 strcat (zh->path_reg, "/");
461 strcat (zh->path_reg, zh->reg_name);
464 zh->res = zebra_open_res (zh);
467 zebra_lock_destroy (zh->lock_normal);
471 zebra_lock_destroy (zh->lock_shadow);
477 const char *lock_area =res_get (zh->res, "lockDir");
479 if (!lock_area && zh->path_reg)
480 res_put (zh->res, "lockDir", zh->path_reg);
481 sprintf (fname, "norm.%s.LCK", zh->reg_name);
483 zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0);
485 sprintf (fname, "shadow.%s.LCK", zh->reg_name);
487 zebra_lock_create (res_get(zh->res, "lockDir"), fname, 0);
493 void map_basenames_func (void *vp, const char *name, const char *value)
495 struct map_baseinfo *p = (struct map_baseinfo *) vp;
497 char fromdb[128], todb[8][128];
500 sscanf (value, "%127s %127s %127s %127s %127s %127s %127s %127s %127s",
501 fromdb, todb[0], todb[1], todb[2], todb[3], todb[4],
502 todb[5], todb[6], todb[7]);
506 for (i = 0; i<p->num_bases; i++)
507 if (p->basenames[i] && !strcmp (p->basenames[i], fromdb))
510 for (i = 0; i < no; i++)
512 if (p->new_num_bases == p->new_num_max)
514 p->new_basenames[(p->new_num_bases)++] =
515 nmem_strdup (p->mem, todb[i]);
521 void map_basenames (ZebraHandle zh, ODR stream,
522 int *num_bases, char ***basenames)
524 struct map_baseinfo info;
525 struct map_baseinfo *p = &info;
529 info.num_bases = *num_bases;
530 info.basenames = *basenames;
531 info.new_num_max = 128;
532 info.new_num_bases = 0;
533 info.new_basenames = (char **)
534 odr_malloc (stream, sizeof(*info.new_basenames) * info.new_num_max);
535 info.mem = stream->mem;
537 res_trav (zh->service->global_res, "mapdb", &info, map_basenames_func);
539 for (i = 0; i<p->num_bases; i++)
540 if (p->basenames[i] && p->new_num_bases < p->new_num_max)
542 p->new_basenames[(p->new_num_bases)++] =
543 nmem_strdup (p->mem, p->basenames[i]);
545 *num_bases = info.new_num_bases;
546 *basenames = info.new_basenames;
547 for (i = 0; i<*num_bases; i++)
548 logf (LOG_LOG, "base %s", (*basenames)[i]);
551 int zebra_select_database (ZebraHandle zh, const char *basename)
553 return zebra_select_databases (zh, 1, &basename);
556 int zebra_select_databases (ZebraHandle zh, int num_bases,
557 const char **basenames)
569 for (i = 0; i < zh->num_basenames; i++)
570 xfree (zh->basenames[i]);
571 xfree (zh->basenames);
573 zh->num_basenames = num_bases;
574 zh->basenames = xmalloc (zh->num_basenames * sizeof(*zh->basenames));
575 for (i = 0; i < zh->num_basenames; i++)
576 zh->basenames[i] = xstrdup (basenames[i]);
578 cp = strrchr(basenames[0], '/');
581 len = cp - basenames[0];
582 new_reg = xmalloc (len + 1);
583 memcpy (new_reg, basenames[0], len);
587 new_reg = xstrdup ("");
588 for (i = 1; i<num_bases; i++)
592 cp1 = strrchr (basenames[i], '/');
600 if (len != cp1 - basenames[i] ||
601 memcmp (basenames[i], new_reg, len))
616 zebra_select_register (zh, new_reg);
626 void zebra_search_rpn (ZebraHandle zh, ODR decode, ODR stream,
627 Z_RPNQuery *query, const char *setname, int *hits)
632 if (zebra_begin_read (zh))
634 resultSetAddRPN (zh, decode, stream, query,
635 zh->num_basenames, zh->basenames, setname);
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)
990 const char *rval = 0;
995 if (zh->trans_no != 1)
1000 yaz_log (LOG_LOG, "zebra_begin_trans");
1001 #if HAVE_SYS_TIMES_H
1006 if (zh->shadow_enable)
1007 rval = res_get (zh->res, "shadow");
1009 for (pass = 0; pass < 2; pass++)
1013 zebra_lock_r (zh->lock_normal);
1014 zebra_lock_w (zh->lock_shadow);
1018 zebra_lock_w (zh->lock_normal);
1019 zebra_lock_w (zh->lock_shadow);
1022 zebra_get_state (zh, &val, &seqno);
1025 yaz_log (LOG_LOG, "previous transaction didn't finish commit");
1026 zebra_unlock (zh->lock_shadow);
1027 zebra_unlock (zh->lock_normal);
1031 else if (val == 'd')
1035 BFiles bfs = bfs_create (res_get (zh->res, "shadow"),
1037 yaz_log (LOG_LOG, "previous transaction didn't reach commit");
1038 bf_commitClean (bfs, rval);
1043 yaz_log (LOG_WARN, "your previous transaction didn't finish");
1050 yaz_log (LOG_FATAL, "zebra_begin_trans couldn't finish commit");
1054 zebra_set_state (zh, 'd', seqno);
1056 zh->reg = zebra_register_open (zh->service, zh->reg_name,
1057 1, rval ? 1 : 0, zh->res,
1060 zh->reg->seqno = seqno;
1063 void zebra_end_trans (ZebraHandle zh)
1070 if (zh->trans_no != 0)
1073 yaz_log (LOG_LOG, "zebra_end_trans");
1074 rval = res_get (zh->res, "shadow");
1076 zebra_flush_reg (zh);
1078 zebra_register_close (zh->service, zh->reg);
1081 zebra_get_state (zh, &val, &seqno);
1084 BFiles bfs = bfs_create (rval, zh->path_reg);
1085 yaz_log (LOG_LOG, "deleting shadow stuff val=%c", val);
1086 bf_commitClean (bfs, rval);
1091 zebra_set_state (zh, 'o', seqno);
1093 zebra_unlock (zh->lock_shadow);
1094 zebra_unlock (zh->lock_normal);
1096 #if HAVE_SYS_TIMES_H
1098 logf (LOG_LOG, "user/system: %ld/%ld",
1099 (long) (zh->tms2.tms_utime - zh->tms1.tms_utime),
1100 (long) (zh->tms2.tms_stime - zh->tms1.tms_stime));
1105 void zebra_repository_update (ZebraHandle zh)
1107 zebra_begin_trans (zh);
1108 logf (LOG_LOG, "updating %s", zh->rGroup.path);
1109 repositoryUpdate (zh);
1110 zebra_end_trans (zh);
1113 void zebra_repository_delete (ZebraHandle zh)
1115 logf (LOG_LOG, "deleting %s", zh->rGroup.path);
1116 repositoryDelete (zh);
1119 void zebra_repository_show (ZebraHandle zh)
1121 repositoryShow (zh);
1124 int zebra_commit (ZebraHandle zh)
1136 rval = res_get (zh->res, "shadow");
1139 logf (LOG_WARN, "Cannot perform commit");
1140 logf (LOG_WARN, "No shadow area defined");
1144 zebra_lock_w (zh->lock_normal);
1145 zebra_lock_r (zh->lock_shadow);
1147 bfs = bfs_create (res_get (zh->res, "register"), zh->path_reg);
1149 zebra_get_state (zh, &val, &seqno);
1152 bf_cache (bfs, rval);
1153 if (bf_commitExists (bfs))
1155 zebra_set_state (zh, 'c', seqno);
1157 logf (LOG_LOG, "commit start");
1161 bf_commitExec (bfs);
1165 logf (LOG_LOG, "commit clean");
1166 bf_commitClean (bfs, rval);
1168 zebra_set_state (zh, 'o', seqno);
1172 logf (LOG_LOG, "nothing to commit");
1176 zebra_unlock (zh->lock_shadow);
1177 zebra_unlock (zh->lock_normal);
1181 int zebra_init (ZebraHandle zh)
1191 rval = res_get (zh->res, "shadow");
1193 bfs = bfs_create (res_get (zh->service->global_res, "register"),
1196 bf_cache (bfs, rval);
1200 zebra_set_state (zh, 'o', 0);
1204 int zebra_compact (ZebraHandle zh)
1212 bfs = bfs_create (res_get (zh->res, "register"), zh->path_reg);
1218 int zebra_record_insert (ZebraHandle zh, const char *buf, int len)
1221 zebra_begin_trans (zh);
1222 extract_rec_in_mem (zh, "grs.sgml",
1224 "Default", /* database */
1225 0 /* delete_flag */,
1230 0 /* match criteria */);
1231 zebra_end_trans (zh);
1235 void zebra_set_group (ZebraHandle zh, struct recordGroup *rg)
1237 memcpy (&zh->rGroup, rg, sizeof(*rg));
1240 void zebra_result (ZebraHandle zh, int *code, char **addinfo)
1242 *code = zh->errCode;
1243 *addinfo = zh->errString;
1246 void zebra_shadow_enable (ZebraHandle zh, int value)
1248 zh->shadow_enable = value;