2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.56 1996-05-09 09:54:42 adam
8 * Server supports maps from one logical attributes to a list of physical
10 * The extraction process doesn't make space consuming 'any' keys.
12 * Revision 1.55 1996/05/09 07:28:55 quinn
13 * Work towards phrases and multiple registers
15 * Revision 1.54 1996/05/01 13:46:35 adam
16 * First work on multiple records in one file.
17 * New option, -offset, to the "unread" command in the filter module.
19 * Revision 1.53 1996/04/26 12:09:43 adam
20 * Added a few comments.
22 * Revision 1.52 1996/04/25 13:27:57 adam
23 * Function recordExtract modified so that files with no keys (possibly empty)
26 * Revision 1.51 1996/03/19 11:08:42 adam
27 * Bug fix: Log preamble wasn't always turned off after recordExtract.
29 * Revision 1.50 1996/02/12 18:45:36 adam
30 * New fileVerboseFlag in record group control.
32 * Revision 1.49 1996/02/05 12:29:57 adam
33 * Logging reduced a bit.
34 * The remaining running time is estimated during register merge.
36 * Revision 1.48 1996/02/01 20:53:26 adam
37 * The temporary per-record keys are compacted a little, and duplication
38 * of the per-records keys are avoided when they are saved in the record
41 * Revision 1.47 1996/01/17 14:57:48 adam
42 * Prototype changed for reader functions in extract/retrieve. File
43 * is identified by 'void *' instead of 'int.
45 * Revision 1.46 1995/12/15 14:57:16 adam
48 * Revision 1.45 1995/12/15 12:37:41 adam
49 * In addRecordKeyAny: Writes key only when attrSet != -1.
51 * Revision 1.44 1995/12/12 16:00:54 adam
52 * System call sync(2) used after update/commit.
53 * Locking (based on fcntl) uses F_EXLCK and F_SHLCK instead of F_WRLCK
56 * Revision 1.43 1995/12/11 09:12:46 adam
57 * The rec_get function returns NULL if record doesn't exist - will
58 * happen in the server if the result set records have been deleted since
59 * the creation of the set (i.e. the search).
60 * The server saves a result temporarily if it is 'volatile', i.e. the
61 * set is register dependent.
63 * Revision 1.42 1995/12/07 17:38:46 adam
64 * Work locking mechanisms for concurrent updates/commit.
66 * Revision 1.41 1995/12/06 16:06:42 adam
67 * Better diagnostics. Work on 'real' dictionary deletion.
69 * Revision 1.40 1995/12/05 16:57:40 adam
70 * More work on regular patterns.
72 * Revision 1.39 1995/12/05 13:20:18 adam
73 * Bug fix: file_read sometimes returned early EOF.
75 * Revision 1.38 1995/12/04 17:59:21 adam
76 * More work on regular expression conversion.
78 * Revision 1.37 1995/12/04 14:22:27 adam
79 * Extra arg to recType_byName.
80 * Started work on new regular expression parsed input to
83 * Revision 1.36 1995/11/30 08:34:29 adam
84 * Started work on commit facility.
85 * Changed a few malloc/free to xmalloc/xfree.
87 * Revision 1.35 1995/11/28 14:26:21 adam
88 * Bug fix: recordId with constant wasn't right.
89 * Bug fix: recordId dictionary entry wasn't deleted when needed.
91 * Revision 1.34 1995/11/28 09:09:38 adam
92 * Zebra config renamed.
93 * Use setting 'recordId' to identify record now.
94 * Bug fix in recindex.c: rec_release_blocks was invokeded even
95 * though the blocks were already released.
96 * File traversal properly deletes records when needed.
98 * Revision 1.33 1995/11/27 09:56:20 adam
99 * Record info elements better enumerated. Internal store of records.
101 * Revision 1.32 1995/11/25 10:24:05 adam
102 * More record fields - they are enumerated now.
103 * New options: flagStoreData flagStoreKey.
105 * Revision 1.31 1995/11/24 11:31:35 adam
106 * Commands add & del read filenames from stdin if source directory is
108 * Match criteria supports 'constant' strings.
110 * Revision 1.30 1995/11/22 17:19:16 adam
111 * Record management uses the bfile system.
113 * Revision 1.29 1995/11/21 15:01:14 adam
114 * New general match criteria implemented.
115 * New feature: document groups.
117 * Revision 1.28 1995/11/21 09:20:30 adam
118 * Yet more work on record match.
120 * Revision 1.27 1995/11/20 16:59:45 adam
121 * New update method: the 'old' keys are saved for each records.
123 * Revision 1.26 1995/11/20 11:56:24 adam
124 * Work on new traversal.
126 * Revision 1.25 1995/11/16 15:34:54 adam
127 * Uses new record management system in both indexer and server.
129 * Revision 1.24 1995/11/15 19:13:08 adam
130 * Work on record management.
132 * Revision 1.23 1995/10/27 14:00:10 adam
133 * Implemented detection of database availability.
135 * Revision 1.22 1995/10/17 18:02:07 adam
136 * New feature: databases. Implemented as prefix to words in dictionary.
138 * Revision 1.21 1995/10/10 12:24:38 adam
139 * Temporary sort files are compressed.
141 * Revision 1.20 1995/10/06 13:52:05 adam
142 * Bug fixes. Handler may abort further scanning.
144 * Revision 1.19 1995/10/04 12:55:16 adam
145 * Bug fix in ranked search. Use=Any keys inserted.
147 * Revision 1.18 1995/10/04 09:37:08 quinn
150 * Revision 1.17 1995/10/03 14:28:57 adam
151 * Buffered read in extract works.
153 * Revision 1.16 1995/10/03 14:28:45 adam
154 * Work on more effecient read handler in extract.
156 * Revision 1.15 1995/10/02 15:42:53 adam
157 * Extract uses file descriptors instead of FILE pointers.
159 * Revision 1.14 1995/10/02 15:29:13 adam
160 * More logging in file_extract.
162 * Revision 1.13 1995/09/29 14:01:39 adam
165 * Revision 1.12 1995/09/28 14:22:56 adam
166 * Sort uses smaller temporary files.
168 * Revision 1.11 1995/09/28 12:10:31 adam
169 * Bug fixes. Field prefix used in queries.
171 * Revision 1.10 1995/09/28 09:19:41 adam
172 * xfree/xmalloc used everywhere.
173 * Extract/retrieve method seems to work for text records.
175 * Revision 1.9 1995/09/27 12:22:28 adam
176 * More work on extract in record control.
177 * Field name is not in isam keys but in prefix in dictionary words.
179 * Revision 1.8 1995/09/14 07:48:22 adam
180 * Record control management.
182 * Revision 1.7 1995/09/11 13:09:32 adam
183 * More work on relevance feedback.
185 * Revision 1.6 1995/09/08 14:52:27 adam
186 * Minor changes. Dictionary is lower case now.
188 * Revision 1.5 1995/09/06 16:11:16 adam
189 * Option: only one word key per file.
191 * Revision 1.4 1995/09/05 15:28:39 adam
192 * More work on search engine.
194 * Revision 1.3 1995/09/04 12:33:41 adam
195 * Various cleanup. YAZ util used instead.
197 * Revision 1.2 1995/09/04 09:10:34 adam
198 * More work on index add/del/update.
199 * Merge sort implemented.
200 * Initial work on z39 server.
202 * Revision 1.1 1995/09/01 14:06:35 adam
203 * Split of work into more files.
212 #include <alexutil.h>
216 #include "recindex.h"
218 static Dict matchDict;
220 static Records records = NULL;
222 static char **key_buf;
223 static size_t ptr_top;
225 static size_t key_buf_used;
226 static int key_file_no;
228 static int records_inserted = 0;
229 static int records_updated = 0;
230 static int records_deleted = 0;
231 static int records_processed = 0;
233 static void logRecord (int showFlag)
237 if (showFlag || !(records_processed % 1000))
239 logf (LOG_LOG, "Records: %7d i/u/d %d/%d/%d",
240 records_processed, records_inserted, records_updated,
245 void key_open (int mem)
249 key_buf = xmalloc (mem);
250 ptr_top = mem/sizeof(char*);
256 if (!(matchDict = dict_open (GMATCH_DICT, 50, 1)))
258 logf (LOG_FATAL, "dict_open fail of %s", GMATCH_DICT);
262 records = rec_open (1);
271 void encode_key_init (struct encode_info *i)
277 char *encode_key_int (int d, char *bp)
286 else if (d <= 4194303)
288 *bp++ = 128 + (d>>16);
289 *bp++ = (d>>8) & 255;
294 *bp++ = 192 + (d>>24);
295 *bp++ = (d>>16) & 255;
296 *bp++ = (d>>8) & 255;
302 void encode_key_write (char *k, struct encode_info *i, FILE *outf)
307 while ((*bp++ = *k++))
309 memcpy (&key, k+1, sizeof(struct it_key));
310 bp = encode_key_int ( (key.sysno - i->sysno) * 2 + *k, bp);
311 if (i->sysno != key.sysno)
313 i->sysno = key.sysno;
316 bp = encode_key_int (key.seqno - i->seqno, bp);
317 i->seqno = key.seqno;
318 if (fwrite (i->buf, bp - i->buf, 1, outf) != 1)
320 logf (LOG_FATAL|LOG_ERRNO, "fwrite");
325 void key_flush (void)
330 struct encode_info encode_info;
336 logf (LOG_LOG, "sorting section %d", key_file_no);
337 qsort (key_buf + ptr_top-ptr_i, ptr_i, sizeof(char*), key_qsort_compare);
338 sprintf (out_fname, TEMP_FNAME, key_file_no);
340 if (!(outf = fopen (out_fname, "w")))
342 logf (LOG_FATAL|LOG_ERRNO, "fopen (4) %s", out_fname);
345 logf (LOG_LOG, "writing section %d", key_file_no);
346 prevcp = cp = key_buf[ptr_top-ptr_i];
348 encode_key_init (&encode_info);
349 encode_key_write (cp, &encode_info, outf);
352 cp = key_buf[ptr_top-ptr_i];
353 if (strcmp (cp, prevcp))
355 encode_key_init (&encode_info);
356 encode_key_write (cp, &encode_info, outf);
360 encode_key_write (cp + strlen(cp), &encode_info, outf);
364 logf (LOG_FATAL|LOG_ERRNO, "fclose %s", out_fname);
367 logf (LOG_LOG, "finished section %d", key_file_no);
376 rec_close (&records);
377 dict_close (matchDict);
383 static void wordInit (RecWord *p)
387 p->which = Word_String;
398 static void addRecordKey (const RecWord *p)
406 if (reckeys.buf_used+1024 > reckeys.buf_max)
410 b = xmalloc (reckeys.buf_max += 128000);
411 if (reckeys.buf_used > 0)
412 memcpy (b, reckeys.buf, reckeys.buf_used);
416 dst = reckeys.buf + reckeys.buf_used;
418 attrSet = p->attrSet;
419 if (reckeys.buf_used > 0 && reckeys.prevAttrSet == attrSet)
422 reckeys.prevAttrSet = attrSet;
423 attrUse = p->attrUse;
424 if (reckeys.buf_used > 0 && reckeys.prevAttrUse == attrUse)
427 reckeys.prevAttrUse = attrUse;
431 case Word_String: case Word_Phrase:
436 memcpy (dst, &attrSet, sizeof(attrSet));
437 dst += sizeof(attrSet);
441 memcpy (dst, &attrUse, sizeof(attrUse));
442 dst += sizeof(attrUse);
444 for (i = 0; p->u.string[i]; i++)
445 *dst++ = p->u.string[i];
448 memcpy (dst, &p->seqno, sizeof(p->seqno));
449 dst += sizeof(p->seqno);
455 reckeys.buf_used = dst - reckeys.buf;
458 static void flushRecordKeys (SYSNO sysno, int cmd, struct recKeys *reckeys,
459 const char *databaseName)
464 while (off < reckeys->buf_used)
466 const char *src = reckeys->buf + off;
474 memcpy (&attrSet, src, sizeof(attrSet));
475 src += sizeof(attrSet);
479 memcpy (&attrUse, src, sizeof(attrUse));
480 src += sizeof(attrUse);
482 if (key_buf_used + 1024 > (ptr_top-ptr_i)*sizeof(char*))
485 key_buf[ptr_top-ptr_i] = (char*)key_buf + key_buf_used;
486 key_buf_used += index_word_prefix ((char*)key_buf + key_buf_used,
487 attrSet, attrUse, databaseName);
489 ((char*)key_buf) [key_buf_used++] = index_char_cvt (*src++);
491 ((char*)key_buf) [key_buf_used++] = '\0';
493 ((char*) key_buf)[key_buf_used++] = cmd;
495 memcpy (&key.seqno, src, sizeof(key.seqno));
496 src += sizeof(key.seqno);
498 memcpy ((char*)key_buf + key_buf_used, &key, sizeof(key));
499 key_buf_used += sizeof(key);
500 off = src - reckeys->buf;
502 assert (off == reckeys->buf_used);
505 static const char **searchRecordKey (struct recKeys *reckeys,
506 int attrSetS, int attrUseS)
508 static const char *ws[32];
513 for (i = 0; i<32; i++)
516 while (off < reckeys->buf_used)
518 const char *src = reckeys->buf + off;
524 memcpy (&attrSet, src, sizeof(attrSet));
525 src += sizeof(attrSet);
527 memcpy (&attrUse, src, sizeof(attrUse));
528 src += sizeof(attrUse);
534 memcpy (&seqno, src, sizeof(seqno));
535 src += sizeof(seqno);
538 logf (LOG_LOG, "(%d,%d) %d %s", attrSet, attrUse, seqno, wstart);
540 if (attrUseS == attrUse && attrSetS == attrSet)
547 woff = seqno - startSeq;
548 if (woff >= 0 && woff < 31)
552 off = src - reckeys->buf;
554 assert (off == reckeys->buf_used);
558 struct file_read_info {
566 static struct file_read_info *file_read_start (int fd)
568 struct file_read_info *fi = xmalloc (sizeof(*fi));
572 fi->file_moffset = 0;
576 static void file_read_stop (struct file_read_info *fi)
582 static off_t file_seek (void *handle, off_t offset)
584 struct file_read_info *p = handle;
585 p->file_offset = offset;
586 return lseek (p->fd, offset, SEEK_SET);
589 static int file_read (void *handle, char *buf, size_t count)
591 struct file_read_info *p = handle;
594 r = read (fd, buf, count);
598 if (p->file_offset > p->file_max)
599 p->file_max = p->file_offset;
604 static void file_begin (void *handle)
606 struct file_read_info *p = handle;
608 p->file_offset = p->file_moffset;
610 lseek (p->fd, p->file_moffset, SEEK_SET);
614 static void file_end (void *handle, off_t offset)
616 struct file_read_info *p = handle;
618 assert (p->file_more == 0);
620 p->file_moffset = offset;
623 static int atois (const char **s)
626 while ( (c=**s) >= '0' && c <= '9')
628 val = val*10 + c - '0';
634 static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup,
638 static char dstBuf[2048];
640 const char *s = spec;
641 static const char **w;
646 while (*s == ' ' || *s == '\t')
653 int attrSet, attrUse;
657 attrSet = atois (&s);
660 logf (LOG_WARN, "Missing , in match criteria %s in group %s",
661 spec, rGroup->groupName ? rGroup->groupName : "none");
665 attrUse = atois (&s);
666 w = searchRecordKey (reckeys, attrSet, attrUse);
671 for (i = 0; i<32; i++)
676 logf (LOG_WARN, "Missing ) in match criteria %s in group %s",
677 spec, rGroup->groupName ? rGroup->groupName : "none");
682 for (i = 0; i<32; i++)
683 if (matchFlag[i] && w[i])
695 logf (LOG_WARN, "Record didn't contain match"
696 " fields in (%d,%d)", attrSet, attrUse);
704 const char *spec_src = NULL;
705 const char *s1 = ++s;
706 while (*s1 && *s1 != ' ' && *s1 != '\t')
712 memcpy (special, s, spec_len);
713 special[spec_len] = '\0';
716 if (!strcmp (special, "group"))
717 spec_src = rGroup->groupName;
718 else if (!strcmp (special, "database"))
719 spec_src = rGroup->databaseName;
720 else if (!strcmp (special, "filename"))
722 else if (!strcmp (special, "type"))
723 spec_src = rGroup->recordType;
728 strcpy (dst, spec_src);
729 dst += strlen (spec_src);
732 else if (*s == '\"' || *s == '\'')
734 int stopMarker = *s++;
738 while (*s && *s != stopMarker)
741 tmpString[i++] = *s++;
746 strcpy (dst, tmpString);
747 dst += strlen (tmpString);
751 logf (LOG_WARN, "Syntax error in match criteria %s in group %s",
752 spec, rGroup->groupName ? rGroup->groupName : "none");
759 logf (LOG_WARN, "No match criteria for record %s in group %s",
760 fname, rGroup->groupName ? rGroup->groupName : "none");
766 struct recordLogInfo {
769 struct recordGroup *rGroup;
772 static void recordLogPreamble (int level, const char *msg, void *info)
774 struct recordLogInfo *p = info;
775 FILE *outf = log_file ();
780 fprintf (outf, "%s of ", p->op);
781 fprintf (outf, "%s type %s\n", p->rGroup->recordType, p->fname);
782 log_event_start (NULL, NULL);
785 static int recordExtract (SYSNO *sysno, const char *fname,
786 struct recordGroup *rGroup, int deleteFlag,
787 struct file_read_info *fi, RecType recType,
790 struct recExtractCtrl extractCtrl;
794 off_t recordOffset = 0;
796 struct recordLogInfo logInfo;
798 logInfo.fname = fname;
800 logInfo.rGroup = rGroup;
801 log_event_start (recordLogPreamble, &logInfo);
805 /* we are going to read from a file, so prepare the extraction */
807 extractCtrl.subType = subType;
808 extractCtrl.init = wordInit;
809 extractCtrl.add = addRecordKey;
811 reckeys.buf_used = 0;
812 reckeys.prevAttrUse = -1;
813 reckeys.prevAttrSet = -1;
815 recordOffset = fi->file_moffset;
816 extractCtrl.offset = recordOffset;
817 extractCtrl.readf = file_read;
818 extractCtrl.seekf = file_seek;
819 extractCtrl.endf = file_end;
820 r = (*recType->extract)(&extractCtrl);
824 /* error occured during extraction ... */
825 logf (LOG_WARN, "Couldn't extract file %s, code %d", fname, r);
828 if (reckeys.buf_used == 0)
830 /* the extraction process returned no information - the record
832 logf (LOG_WARN, "Empty file %s", fname);
837 /* perform match if sysno not known and if match criteria is specified */
844 if (rGroup->recordId && *rGroup->recordId)
848 matchStr = fileMatchStr (&reckeys, rGroup, fname,
852 rinfo = dict_lookup (matchDict, matchStr);
854 memcpy (sysno, rinfo+1, sizeof(*sysno));
858 logf (LOG_WARN, "Bad match criteria");
869 logf (LOG_LOG, "Cannot delete new record");
873 if (rGroup->fileVerboseFlag)
874 logf (LOG_LOG, "add %s %s+%ld", rGroup->recordType,
875 fname, (long) recordOffset);
876 rec = rec_new (records);
881 dict_insert (matchDict, matchStr, sizeof(*sysno), sysno);
883 flushRecordKeys (*sysno, 1, &reckeys, rGroup->databaseName);
889 /* record already exists */
890 struct recKeys delkeys;
892 rec = rec_get (records, *sysno);
894 delkeys.buf_used = rec->size[recInfo_delKeys];
895 delkeys.buf = rec->info[recInfo_delKeys];
896 flushRecordKeys (*sysno, 0, &delkeys, rec->info[recInfo_databaseName]);
899 /* record going to be deleted */
900 logInfo.op = "delete";
901 if (!delkeys.buf_used)
903 logf (LOG_WARN, "cannot delete; storeKeys false");
907 if (rGroup->fileVerboseFlag)
908 logf (LOG_LOG, "delete %s %s %ld", rGroup->recordType,
909 fname, (long) recordOffset);
912 dict_delete (matchDict, matchStr);
913 rec_del (records, &rec);
920 /* record going to be updated */
921 logInfo.op = "update";
922 if (!delkeys.buf_used)
924 logf (LOG_WARN, "cannot update; storeKeys false");
928 if (rGroup->fileVerboseFlag)
929 logf (LOG_LOG, "update %s %s %ld", rGroup->recordType,
930 fname, (long) recordOffset);
931 flushRecordKeys (*sysno, 1, &reckeys, rGroup->databaseName);
936 /* update file type */
937 xfree (rec->info[recInfo_fileType]);
938 rec->info[recInfo_fileType] =
939 rec_strdup (rGroup->recordType, &rec->size[recInfo_fileType]);
941 /* update filename */
942 xfree (rec->info[recInfo_filename]);
943 rec->info[recInfo_filename] =
944 rec_strdup (fname, &rec->size[recInfo_filename]);
946 /* update delete keys */
947 xfree (rec->info[recInfo_delKeys]);
948 if (reckeys.buf_used > 0 && rGroup->flagStoreKeys == 1)
951 rec->size[recInfo_delKeys] = reckeys.buf_used;
952 rec->info[recInfo_delKeys] = reckeys.buf;
956 rec->info[recInfo_delKeys] = xmalloc (reckeys.buf_used);
957 rec->size[recInfo_delKeys] = reckeys.buf_used;
958 memcpy (rec->info[recInfo_delKeys], reckeys.buf,
959 rec->size[recInfo_delKeys]);
964 rec->info[recInfo_delKeys] = NULL;
965 rec->size[recInfo_delKeys] = 0;
968 /* update store data */
969 xfree (rec->info[recInfo_storeData]);
970 if (rGroup->flagStoreData == 1)
972 rec->size[recInfo_storeData] = fi->file_max;
973 rec->info[recInfo_storeData] = xmalloc (fi->file_max);
974 if (lseek (fi->fd, recordOffset, SEEK_SET) < 0)
976 logf (LOG_ERRNO|LOG_FATAL, "seek to %ld in %s", fname,
977 (long) recordOffset);
980 if (read (fi->fd, rec->info[recInfo_storeData], fi->file_max)
983 logf (LOG_ERRNO|LOG_FATAL, "read %d bytes of %s",
984 fi->file_max, fname);
990 rec->info[recInfo_storeData] = NULL;
991 rec->size[recInfo_storeData] = 0;
993 /* update database name */
994 xfree (rec->info[recInfo_databaseName]);
995 rec->info[recInfo_databaseName] =
996 rec_strdup (rGroup->databaseName, &rec->size[recInfo_databaseName]);
999 xfree (rec->info[recInfo_offset]);
1001 rec->size[recInfo_offset] = sizeof(recordOffset);
1002 rec->info[recInfo_offset] = xmalloc (sizeof(recordOffset));
1003 memcpy (rec->info[recInfo_offset], &recordOffset, sizeof(recordOffset));
1005 /* commit this record */
1006 rec_put (records, &rec);
1011 int fileExtract (SYSNO *sysno, const char *fname,
1012 const struct recordGroup *rGroupP, int deleteFlag)
1020 struct recordGroup rGroupM;
1021 struct recordGroup *rGroup = &rGroupM;
1022 struct file_read_info *fi;
1024 memcpy (rGroup, rGroupP, sizeof(*rGroupP));
1026 if (!rGroup->groupName || !*rGroup->groupName)
1029 sprintf (gprefix, "%s.", rGroup->groupName);
1031 logf (LOG_DEBUG, "fileExtract %s", fname);
1033 /* determine file extension */
1034 for (i = strlen(fname); --i >= 0; )
1035 if (fname[i] == '/')
1040 else if (fname[i] == '.')
1042 strcpy (ext, fname+i+1);
1045 /* determine file type - depending on extension */
1046 if (!rGroup->recordType)
1048 sprintf (ext_res, "%srecordType.%s", gprefix, ext);
1049 if (!(rGroup->recordType = res_get (common_resource, ext_res)))
1051 sprintf (ext_res, "%srecordType", gprefix);
1052 if (!(rGroup->recordType = res_get (common_resource, ext_res)))
1054 if (rGroup->fileVerboseFlag)
1055 logf (LOG_LOG, "? %s", fname);
1060 if (!rGroup->recordType)
1062 if (rGroup->fileVerboseFlag)
1063 logf (LOG_LOG, "? record %s", fname);
1066 if (!(recType = recType_byName (rGroup->recordType, subType)))
1068 logf (LOG_WARN, "No such record type: %s", rGroup->recordType);
1072 /* determine match criteria */
1073 if (!rGroup->recordId)
1075 sprintf (ext_res, "%srecordId.%s", gprefix, ext);
1076 rGroup->recordId = res_get (common_resource, ext_res);
1079 /* determine database name */
1080 if (!rGroup->databaseName)
1082 sprintf (ext_res, "%sdatabase.%s", gprefix, ext);
1083 if (!(rGroup->databaseName = res_get (common_resource, ext_res)))
1085 sprintf (ext_res, "%sdatabase", gprefix);
1086 rGroup->databaseName = res_get (common_resource, ext_res);
1089 if (!rGroup->databaseName)
1090 rGroup->databaseName = "Default";
1092 if (rGroup->flagStoreData == -1)
1095 sprintf (ext_res, "%sstoreData.%s", gprefix, ext);
1096 if (!(sval = res_get (common_resource, ext_res)))
1098 sprintf (ext_res, "%sstoreData", gprefix);
1099 sval = res_get (common_resource, ext_res);
1102 rGroup->flagStoreData = atoi (sval);
1104 if (rGroup->flagStoreData == -1)
1105 rGroup->flagStoreData = 0;
1107 if (rGroup->flagStoreKeys == -1)
1111 sprintf (ext_res, "%sstoreKeys.%s", gprefix, ext);
1112 if (!(sval = res_get (common_resource, ext_res)))
1114 sprintf (ext_res, "%sstoreKeys", gprefix);
1115 sval = res_get (common_resource, ext_res);
1118 rGroup->flagStoreKeys = atoi (sval);
1120 if (rGroup->flagStoreKeys == -1)
1121 rGroup->flagStoreKeys = 0;
1123 if (sysno && deleteFlag)
1127 if ((fd = open (fname, O_RDONLY)) == -1)
1129 logf (LOG_WARN|LOG_ERRNO, "open %s", fname);
1133 fi = file_read_start (fd);
1137 r = recordExtract (sysno, fname, rGroup, deleteFlag, fi,
1139 } while (r && !sysno && fi->file_more);
1140 log_event_start (NULL, NULL);
1141 file_read_stop (fi);