2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.54 1996-05-01 13:46:35 adam
8 * First work on multiple records in one file.
9 * New option, -offset, to the "unread" command in the filter module.
11 * Revision 1.53 1996/04/26 12:09:43 adam
12 * Added a few comments.
14 * Revision 1.52 1996/04/25 13:27:57 adam
15 * Function recordExtract modified so that files with no keys (possibly empty)
18 * Revision 1.51 1996/03/19 11:08:42 adam
19 * Bug fix: Log preamble wasn't always turned off after recordExtract.
21 * Revision 1.50 1996/02/12 18:45:36 adam
22 * New fileVerboseFlag in record group control.
24 * Revision 1.49 1996/02/05 12:29:57 adam
25 * Logging reduced a bit.
26 * The remaining running time is estimated during register merge.
28 * Revision 1.48 1996/02/01 20:53:26 adam
29 * The temporary per-record keys are compacted a little, and duplication
30 * of the per-records keys are avoided when they are saved in the record
33 * Revision 1.47 1996/01/17 14:57:48 adam
34 * Prototype changed for reader functions in extract/retrieve. File
35 * is identified by 'void *' instead of 'int.
37 * Revision 1.46 1995/12/15 14:57:16 adam
40 * Revision 1.45 1995/12/15 12:37:41 adam
41 * In addRecordKeyAny: Writes key only when attrSet != -1.
43 * Revision 1.44 1995/12/12 16:00:54 adam
44 * System call sync(2) used after update/commit.
45 * Locking (based on fcntl) uses F_EXLCK and F_SHLCK instead of F_WRLCK
48 * Revision 1.43 1995/12/11 09:12:46 adam
49 * The rec_get function returns NULL if record doesn't exist - will
50 * happen in the server if the result set records have been deleted since
51 * the creation of the set (i.e. the search).
52 * The server saves a result temporarily if it is 'volatile', i.e. the
53 * set is register dependent.
55 * Revision 1.42 1995/12/07 17:38:46 adam
56 * Work locking mechanisms for concurrent updates/commit.
58 * Revision 1.41 1995/12/06 16:06:42 adam
59 * Better diagnostics. Work on 'real' dictionary deletion.
61 * Revision 1.40 1995/12/05 16:57:40 adam
62 * More work on regular patterns.
64 * Revision 1.39 1995/12/05 13:20:18 adam
65 * Bug fix: file_read sometimes returned early EOF.
67 * Revision 1.38 1995/12/04 17:59:21 adam
68 * More work on regular expression conversion.
70 * Revision 1.37 1995/12/04 14:22:27 adam
71 * Extra arg to recType_byName.
72 * Started work on new regular expression parsed input to
75 * Revision 1.36 1995/11/30 08:34:29 adam
76 * Started work on commit facility.
77 * Changed a few malloc/free to xmalloc/xfree.
79 * Revision 1.35 1995/11/28 14:26:21 adam
80 * Bug fix: recordId with constant wasn't right.
81 * Bug fix: recordId dictionary entry wasn't deleted when needed.
83 * Revision 1.34 1995/11/28 09:09:38 adam
84 * Zebra config renamed.
85 * Use setting 'recordId' to identify record now.
86 * Bug fix in recindex.c: rec_release_blocks was invokeded even
87 * though the blocks were already released.
88 * File traversal properly deletes records when needed.
90 * Revision 1.33 1995/11/27 09:56:20 adam
91 * Record info elements better enumerated. Internal store of records.
93 * Revision 1.32 1995/11/25 10:24:05 adam
94 * More record fields - they are enumerated now.
95 * New options: flagStoreData flagStoreKey.
97 * Revision 1.31 1995/11/24 11:31:35 adam
98 * Commands add & del read filenames from stdin if source directory is
100 * Match criteria supports 'constant' strings.
102 * Revision 1.30 1995/11/22 17:19:16 adam
103 * Record management uses the bfile system.
105 * Revision 1.29 1995/11/21 15:01:14 adam
106 * New general match criteria implemented.
107 * New feature: document groups.
109 * Revision 1.28 1995/11/21 09:20:30 adam
110 * Yet more work on record match.
112 * Revision 1.27 1995/11/20 16:59:45 adam
113 * New update method: the 'old' keys are saved for each records.
115 * Revision 1.26 1995/11/20 11:56:24 adam
116 * Work on new traversal.
118 * Revision 1.25 1995/11/16 15:34:54 adam
119 * Uses new record management system in both indexer and server.
121 * Revision 1.24 1995/11/15 19:13:08 adam
122 * Work on record management.
124 * Revision 1.23 1995/10/27 14:00:10 adam
125 * Implemented detection of database availability.
127 * Revision 1.22 1995/10/17 18:02:07 adam
128 * New feature: databases. Implemented as prefix to words in dictionary.
130 * Revision 1.21 1995/10/10 12:24:38 adam
131 * Temporary sort files are compressed.
133 * Revision 1.20 1995/10/06 13:52:05 adam
134 * Bug fixes. Handler may abort further scanning.
136 * Revision 1.19 1995/10/04 12:55:16 adam
137 * Bug fix in ranked search. Use=Any keys inserted.
139 * Revision 1.18 1995/10/04 09:37:08 quinn
142 * Revision 1.17 1995/10/03 14:28:57 adam
143 * Buffered read in extract works.
145 * Revision 1.16 1995/10/03 14:28:45 adam
146 * Work on more effecient read handler in extract.
148 * Revision 1.15 1995/10/02 15:42:53 adam
149 * Extract uses file descriptors instead of FILE pointers.
151 * Revision 1.14 1995/10/02 15:29:13 adam
152 * More logging in file_extract.
154 * Revision 1.13 1995/09/29 14:01:39 adam
157 * Revision 1.12 1995/09/28 14:22:56 adam
158 * Sort uses smaller temporary files.
160 * Revision 1.11 1995/09/28 12:10:31 adam
161 * Bug fixes. Field prefix used in queries.
163 * Revision 1.10 1995/09/28 09:19:41 adam
164 * xfree/xmalloc used everywhere.
165 * Extract/retrieve method seems to work for text records.
167 * Revision 1.9 1995/09/27 12:22:28 adam
168 * More work on extract in record control.
169 * Field name is not in isam keys but in prefix in dictionary words.
171 * Revision 1.8 1995/09/14 07:48:22 adam
172 * Record control management.
174 * Revision 1.7 1995/09/11 13:09:32 adam
175 * More work on relevance feedback.
177 * Revision 1.6 1995/09/08 14:52:27 adam
178 * Minor changes. Dictionary is lower case now.
180 * Revision 1.5 1995/09/06 16:11:16 adam
181 * Option: only one word key per file.
183 * Revision 1.4 1995/09/05 15:28:39 adam
184 * More work on search engine.
186 * Revision 1.3 1995/09/04 12:33:41 adam
187 * Various cleanup. YAZ util used instead.
189 * Revision 1.2 1995/09/04 09:10:34 adam
190 * More work on index add/del/update.
191 * Merge sort implemented.
192 * Initial work on z39 server.
194 * Revision 1.1 1995/09/01 14:06:35 adam
195 * Split of work into more files.
204 #include <alexutil.h>
208 #include "recindex.h"
210 static Dict matchDict;
212 static Records records = NULL;
214 static char **key_buf;
215 static size_t ptr_top;
217 static size_t key_buf_used;
218 static int key_file_no;
220 static int records_inserted = 0;
221 static int records_updated = 0;
222 static int records_deleted = 0;
223 static int records_processed = 0;
225 static void logRecord (int showFlag)
229 if (showFlag || !(records_processed % 1000))
231 logf (LOG_LOG, "Records: %7d i/u/d %d/%d/%d",
232 records_processed, records_inserted, records_updated,
237 void key_open (int mem)
241 key_buf = xmalloc (mem);
242 ptr_top = mem/sizeof(char*);
248 if (!(matchDict = dict_open (GMATCH_DICT, 50, 1)))
250 logf (LOG_FATAL, "dict_open fail of %s", GMATCH_DICT);
254 records = rec_open (1);
263 void encode_key_init (struct encode_info *i)
269 char *encode_key_int (int d, char *bp)
278 else if (d <= 4194303)
280 *bp++ = 128 + (d>>16);
281 *bp++ = (d>>8) & 255;
286 *bp++ = 192 + (d>>24);
287 *bp++ = (d>>16) & 255;
288 *bp++ = (d>>8) & 255;
294 void encode_key_write (char *k, struct encode_info *i, FILE *outf)
299 while ((*bp++ = *k++))
301 memcpy (&key, k+1, sizeof(struct it_key));
302 bp = encode_key_int ( (key.sysno - i->sysno) * 2 + *k, bp);
303 if (i->sysno != key.sysno)
305 i->sysno = key.sysno;
308 bp = encode_key_int (key.seqno - i->seqno, bp);
309 i->seqno = key.seqno;
310 if (fwrite (i->buf, bp - i->buf, 1, outf) != 1)
312 logf (LOG_FATAL|LOG_ERRNO, "fwrite");
317 void key_flush (void)
322 struct encode_info encode_info;
328 logf (LOG_LOG, "sorting section %d", key_file_no);
329 qsort (key_buf + ptr_top-ptr_i, ptr_i, sizeof(char*), key_qsort_compare);
330 sprintf (out_fname, TEMP_FNAME, key_file_no);
332 if (!(outf = fopen (out_fname, "w")))
334 logf (LOG_FATAL|LOG_ERRNO, "fopen (4) %s", out_fname);
337 logf (LOG_LOG, "writing section %d", key_file_no);
338 prevcp = cp = key_buf[ptr_top-ptr_i];
340 encode_key_init (&encode_info);
341 encode_key_write (cp, &encode_info, outf);
344 cp = key_buf[ptr_top-ptr_i];
345 if (strcmp (cp, prevcp))
347 encode_key_init (&encode_info);
348 encode_key_write (cp, &encode_info, outf);
352 encode_key_write (cp + strlen(cp), &encode_info, outf);
356 logf (LOG_FATAL|LOG_ERRNO, "fclose %s", out_fname);
359 logf (LOG_LOG, "finished section %d", key_file_no);
368 rec_close (&records);
369 dict_close (matchDict);
375 static void wordInit (RecWord *p)
379 p->which = Word_String;
390 static void addRecordKey (const RecWord *p)
398 if (reckeys.buf_used+1024 > reckeys.buf_max)
402 b = xmalloc (reckeys.buf_max += 128000);
403 if (reckeys.buf_used > 0)
404 memcpy (b, reckeys.buf, reckeys.buf_used);
408 dst = reckeys.buf + reckeys.buf_used;
410 attrSet = p->attrSet;
411 if (reckeys.buf_used > 0 && reckeys.prevAttrSet == attrSet)
414 reckeys.prevAttrSet = attrSet;
415 attrUse = p->attrUse;
416 if (reckeys.buf_used > 0 && reckeys.prevAttrUse == attrUse)
419 reckeys.prevAttrUse = attrUse;
428 memcpy (dst, &attrSet, sizeof(attrSet));
429 dst += sizeof(attrSet);
433 memcpy (dst, &attrUse, sizeof(attrUse));
434 dst += sizeof(attrUse);
436 for (i = 0; p->u.string[i]; i++)
437 *dst++ = p->u.string[i];
440 memcpy (dst, &p->seqno, sizeof(p->seqno));
441 dst += sizeof(p->seqno);
447 reckeys.buf_used = dst - reckeys.buf;
450 static void flushRecordKeys (SYSNO sysno, int cmd, struct recKeys *reckeys,
451 const char *databaseName)
456 while (off < reckeys->buf_used)
458 const char *src = reckeys->buf + off;
466 memcpy (&attrSet, src, sizeof(attrSet));
467 src += sizeof(attrSet);
471 memcpy (&attrUse, src, sizeof(attrUse));
472 src += sizeof(attrUse);
474 if (key_buf_used + 1024 > (ptr_top-ptr_i)*sizeof(char*))
477 key_buf[ptr_top-ptr_i] = (char*)key_buf + key_buf_used;
478 key_buf_used += index_word_prefix ((char*)key_buf + key_buf_used,
479 attrSet, attrUse, databaseName);
481 ((char*)key_buf) [key_buf_used++] = index_char_cvt (*src++);
483 ((char*)key_buf) [key_buf_used++] = '\0';
485 ((char*) key_buf)[key_buf_used++] = cmd;
487 memcpy (&key.seqno, src, sizeof(key.seqno));
488 src += sizeof(key.seqno);
490 memcpy ((char*)key_buf + key_buf_used, &key, sizeof(key));
491 key_buf_used += sizeof(key);
492 off = src - reckeys->buf;
494 assert (off == reckeys->buf_used);
497 static const char **searchRecordKey (struct recKeys *reckeys,
498 int attrSetS, int attrUseS)
500 static const char *ws[32];
505 for (i = 0; i<32; i++)
508 while (off < reckeys->buf_used)
510 const char *src = reckeys->buf + off;
516 memcpy (&attrSet, src, sizeof(attrSet));
517 src += sizeof(attrSet);
519 memcpy (&attrUse, src, sizeof(attrUse));
520 src += sizeof(attrUse);
526 memcpy (&seqno, src, sizeof(seqno));
527 src += sizeof(seqno);
530 logf (LOG_LOG, "(%d,%d) %d %s", attrSet, attrUse, seqno, wstart);
532 if (attrUseS == attrUse && attrSetS == attrSet)
539 woff = seqno - startSeq;
540 if (woff >= 0 && woff < 31)
544 off = src - reckeys->buf;
546 assert (off == reckeys->buf_used);
550 static void addRecordKeyAny (const RecWord *p)
552 if (p->attrSet != 1 || p->attrUse != 1016)
556 memcpy (&w, p, sizeof(w));
561 if (p->attrSet != -1)
565 struct file_read_info {
573 static struct file_read_info *file_read_start (int fd)
575 struct file_read_info *fi = xmalloc (sizeof(*fi));
579 fi->file_moffset = 0;
583 static void file_read_stop (struct file_read_info *fi)
589 static off_t file_seek (void *handle, off_t offset)
591 struct file_read_info *p = handle;
592 p->file_offset = offset;
593 return lseek (p->fd, offset, SEEK_SET);
596 static int file_read (void *handle, char *buf, size_t count)
598 struct file_read_info *p = handle;
601 r = read (fd, buf, count);
605 if (p->file_offset > p->file_max)
606 p->file_max = p->file_offset;
611 static void file_begin (void *handle)
613 struct file_read_info *p = handle;
615 p->file_offset = p->file_moffset;
617 lseek (p->fd, p->file_moffset, SEEK_SET);
621 static void file_end (void *handle, off_t offset)
623 struct file_read_info *p = handle;
625 assert (p->file_more == 0);
627 p->file_moffset = offset;
630 static int atois (const char **s)
633 while ( (c=**s) >= '0' && c <= '9')
635 val = val*10 + c - '0';
641 static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup,
645 static char dstBuf[2048];
647 const char *s = spec;
648 static const char **w;
653 while (*s == ' ' || *s == '\t')
660 int attrSet, attrUse;
664 attrSet = atois (&s);
667 logf (LOG_WARN, "Missing , in match criteria %s in group %s",
668 spec, rGroup->groupName ? rGroup->groupName : "none");
672 attrUse = atois (&s);
673 w = searchRecordKey (reckeys, attrSet, attrUse);
678 for (i = 0; i<32; i++)
683 logf (LOG_WARN, "Missing ) in match criteria %s in group %s",
684 spec, rGroup->groupName ? rGroup->groupName : "none");
689 for (i = 0; i<32; i++)
690 if (matchFlag[i] && w[i])
702 logf (LOG_WARN, "Record didn't contain match"
703 " fields in (%d,%d)", attrSet, attrUse);
711 const char *spec_src = NULL;
712 const char *s1 = ++s;
713 while (*s1 && *s1 != ' ' && *s1 != '\t')
719 memcpy (special, s, spec_len);
720 special[spec_len] = '\0';
723 if (!strcmp (special, "group"))
724 spec_src = rGroup->groupName;
725 else if (!strcmp (special, "database"))
726 spec_src = rGroup->databaseName;
727 else if (!strcmp (special, "filename"))
729 else if (!strcmp (special, "type"))
730 spec_src = rGroup->recordType;
735 strcpy (dst, spec_src);
736 dst += strlen (spec_src);
739 else if (*s == '\"' || *s == '\'')
741 int stopMarker = *s++;
745 while (*s && *s != stopMarker)
748 tmpString[i++] = *s++;
753 strcpy (dst, tmpString);
754 dst += strlen (tmpString);
758 logf (LOG_WARN, "Syntax error in match criteria %s in group %s",
759 spec, rGroup->groupName ? rGroup->groupName : "none");
766 logf (LOG_WARN, "No match criteria for record %s in group %s",
767 fname, rGroup->groupName ? rGroup->groupName : "none");
773 struct recordLogInfo {
776 struct recordGroup *rGroup;
779 static void recordLogPreamble (int level, const char *msg, void *info)
781 struct recordLogInfo *p = info;
782 FILE *outf = log_file ();
787 fprintf (outf, "%s of ", p->op);
788 fprintf (outf, "%s type %s\n", p->rGroup->recordType, p->fname);
789 log_event_start (NULL, NULL);
792 static int recordExtract (SYSNO *sysno, const char *fname,
793 struct recordGroup *rGroup, int deleteFlag,
794 struct file_read_info *fi, RecType recType,
797 struct recExtractCtrl extractCtrl;
801 off_t recordOffset = 0;
803 struct recordLogInfo logInfo;
805 logInfo.fname = fname;
807 logInfo.rGroup = rGroup;
808 log_event_start (recordLogPreamble, &logInfo);
812 /* we are going to read from a file, so prepare the extraction */
814 extractCtrl.subType = subType;
815 extractCtrl.init = wordInit;
816 extractCtrl.add = addRecordKeyAny;
818 reckeys.buf_used = 0;
819 reckeys.prevAttrUse = -1;
820 reckeys.prevAttrSet = -1;
822 recordOffset = fi->file_moffset;
823 extractCtrl.offset = recordOffset;
824 extractCtrl.readf = file_read;
825 extractCtrl.seekf = file_seek;
826 extractCtrl.endf = file_end;
827 r = (*recType->extract)(&extractCtrl);
831 /* error occured during extraction ... */
832 logf (LOG_WARN, "Couldn't extract file %s, code %d", fname, r);
835 if (reckeys.buf_used == 0)
837 /* the extraction process returned no information - the record
839 logf (LOG_WARN, "Empty file %s", fname);
844 /* perform match if sysno not known and if match criteria is specified */
851 if (rGroup->recordId && *rGroup->recordId)
855 matchStr = fileMatchStr (&reckeys, rGroup, fname,
859 rinfo = dict_lookup (matchDict, matchStr);
861 memcpy (sysno, rinfo+1, sizeof(*sysno));
865 logf (LOG_WARN, "Bad match criteria");
876 logf (LOG_LOG, "Cannot delete new record");
880 if (rGroup->fileVerboseFlag)
881 logf (LOG_LOG, "add %s %s %ld", rGroup->recordType,
882 fname, (long) recordOffset);
883 rec = rec_new (records);
888 dict_insert (matchDict, matchStr, sizeof(*sysno), sysno);
890 flushRecordKeys (*sysno, 1, &reckeys, rGroup->databaseName);
896 /* record already exists */
897 struct recKeys delkeys;
899 rec = rec_get (records, *sysno);
901 delkeys.buf_used = rec->size[recInfo_delKeys];
902 delkeys.buf = rec->info[recInfo_delKeys];
903 flushRecordKeys (*sysno, 0, &delkeys, rec->info[recInfo_databaseName]);
906 /* record going to be deleted */
907 logInfo.op = "delete";
908 if (!delkeys.buf_used)
910 logf (LOG_WARN, "cannot delete; storeKeys false");
914 if (rGroup->fileVerboseFlag)
915 logf (LOG_LOG, "delete %s %s %ld", rGroup->recordType,
916 fname, (long) recordOffset);
919 dict_delete (matchDict, matchStr);
920 rec_del (records, &rec);
927 /* record going to be updated */
928 logInfo.op = "update";
929 if (!delkeys.buf_used)
931 logf (LOG_WARN, "cannot update; storeKeys false");
935 if (rGroup->fileVerboseFlag)
936 logf (LOG_LOG, "update %s %s %ld", rGroup->recordType,
937 fname, (long) recordOffset);
938 flushRecordKeys (*sysno, 1, &reckeys, rGroup->databaseName);
943 /* update file type */
944 xfree (rec->info[recInfo_fileType]);
945 rec->info[recInfo_fileType] =
946 rec_strdup (rGroup->recordType, &rec->size[recInfo_fileType]);
948 /* update filename */
949 xfree (rec->info[recInfo_filename]);
950 rec->info[recInfo_filename] =
951 rec_strdup (fname, &rec->size[recInfo_filename]);
953 /* update delete keys */
954 xfree (rec->info[recInfo_delKeys]);
955 if (reckeys.buf_used > 0 && rGroup->flagStoreKeys == 1)
958 rec->size[recInfo_delKeys] = reckeys.buf_used;
959 rec->info[recInfo_delKeys] = reckeys.buf;
963 rec->info[recInfo_delKeys] = xmalloc (reckeys.buf_used);
964 rec->size[recInfo_delKeys] = reckeys.buf_used;
965 memcpy (rec->info[recInfo_delKeys], reckeys.buf,
966 rec->size[recInfo_delKeys]);
971 rec->info[recInfo_delKeys] = NULL;
972 rec->size[recInfo_delKeys] = 0;
975 /* update store data */
976 xfree (rec->info[recInfo_storeData]);
977 if (rGroup->flagStoreData == 1)
979 rec->size[recInfo_storeData] = fi->file_max;
980 rec->info[recInfo_storeData] = xmalloc (fi->file_max);
981 if (lseek (fi->fd, recordOffset, SEEK_SET) < 0)
983 logf (LOG_ERRNO|LOG_FATAL, "seek to %ld in %s", fname,
984 (long) recordOffset);
987 if (read (fi->fd, rec->info[recInfo_storeData], fi->file_max)
990 logf (LOG_ERRNO|LOG_FATAL, "read %d bytes of %s",
991 fi->file_max, fname);
997 rec->info[recInfo_storeData] = NULL;
998 rec->size[recInfo_storeData] = 0;
1000 /* update database name */
1001 xfree (rec->info[recInfo_databaseName]);
1002 rec->info[recInfo_databaseName] =
1003 rec_strdup (rGroup->databaseName, &rec->size[recInfo_databaseName]);
1006 xfree (rec->info[recInfo_offset]);
1008 rec->size[recInfo_offset] = sizeof(recordOffset);
1009 rec->info[recInfo_offset] = xmalloc (sizeof(recordOffset));
1010 memcpy (rec->info[recInfo_offset], &recordOffset, sizeof(recordOffset));
1012 /* commit this record */
1013 rec_put (records, &rec);
1018 int fileExtract (SYSNO *sysno, const char *fname,
1019 const struct recordGroup *rGroupP, int deleteFlag)
1027 struct recordGroup rGroupM;
1028 struct recordGroup *rGroup = &rGroupM;
1029 struct file_read_info *fi;
1031 memcpy (rGroup, rGroupP, sizeof(*rGroupP));
1033 if (!rGroup->groupName || !*rGroup->groupName)
1036 sprintf (gprefix, "%s.", rGroup->groupName);
1038 logf (LOG_DEBUG, "fileExtract %s", fname);
1040 /* determine file extension */
1041 for (i = strlen(fname); --i >= 0; )
1042 if (fname[i] == '/')
1047 else if (fname[i] == '.')
1049 strcpy (ext, fname+i+1);
1052 /* determine file type - depending on extension */
1053 if (!rGroup->recordType)
1055 sprintf (ext_res, "%srecordType.%s", gprefix, ext);
1056 if (!(rGroup->recordType = res_get (common_resource, ext_res)))
1058 sprintf (ext_res, "%srecordType", gprefix);
1059 if (!(rGroup->recordType = res_get (common_resource, ext_res)))
1061 if (rGroup->fileVerboseFlag)
1062 logf (LOG_LOG, "? %s", fname);
1067 if (!rGroup->recordType)
1069 if (rGroup->fileVerboseFlag)
1070 logf (LOG_LOG, "? record %s", fname);
1073 if (!(recType = recType_byName (rGroup->recordType, subType)))
1075 logf (LOG_WARN, "No such record type: %s", rGroup->recordType);
1079 /* determine match criteria */
1080 if (!rGroup->recordId)
1082 sprintf (ext_res, "%srecordId.%s", gprefix, ext);
1083 rGroup->recordId = res_get (common_resource, ext_res);
1086 /* determine database name */
1087 if (!rGroup->databaseName)
1089 sprintf (ext_res, "%sdatabase.%s", gprefix, ext);
1090 if (!(rGroup->databaseName = res_get (common_resource, ext_res)))
1092 sprintf (ext_res, "%sdatabase", gprefix);
1093 rGroup->databaseName = res_get (common_resource, ext_res);
1096 if (!rGroup->databaseName)
1097 rGroup->databaseName = "Default";
1099 if (rGroup->flagStoreData == -1)
1102 sprintf (ext_res, "%sstoreData.%s", gprefix, ext);
1103 if (!(sval = res_get (common_resource, ext_res)))
1105 sprintf (ext_res, "%sstoreData", gprefix);
1106 sval = res_get (common_resource, ext_res);
1109 rGroup->flagStoreData = atoi (sval);
1111 if (rGroup->flagStoreData == -1)
1112 rGroup->flagStoreData = 0;
1114 if (rGroup->flagStoreKeys == -1)
1118 sprintf (ext_res, "%sstoreKeys.%s", gprefix, ext);
1119 if (!(sval = res_get (common_resource, ext_res)))
1121 sprintf (ext_res, "%sstoreKeys", gprefix);
1122 sval = res_get (common_resource, ext_res);
1125 rGroup->flagStoreKeys = atoi (sval);
1127 if (rGroup->flagStoreKeys == -1)
1128 rGroup->flagStoreKeys = 0;
1130 if (sysno && deleteFlag)
1134 if ((fd = open (fname, O_RDONLY)) == -1)
1136 logf (LOG_WARN|LOG_ERRNO, "open %s", fname);
1140 fi = file_read_start (fd);
1144 r = recordExtract (sysno, fname, rGroup, deleteFlag, fi,
1146 } while (r && !sysno && fi->file_more);
1147 log_event_start (NULL, NULL);
1148 file_read_stop (fi);