2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.55 1996-05-09 07:28:55 quinn
8 * Work towards phrases and multiple registers
10 * Revision 1.54 1996/05/01 13:46:35 adam
11 * First work on multiple records in one file.
12 * New option, -offset, to the "unread" command in the filter module.
14 * Revision 1.53 1996/04/26 12:09:43 adam
15 * Added a few comments.
17 * Revision 1.52 1996/04/25 13:27:57 adam
18 * Function recordExtract modified so that files with no keys (possibly empty)
21 * Revision 1.51 1996/03/19 11:08:42 adam
22 * Bug fix: Log preamble wasn't always turned off after recordExtract.
24 * Revision 1.50 1996/02/12 18:45:36 adam
25 * New fileVerboseFlag in record group control.
27 * Revision 1.49 1996/02/05 12:29:57 adam
28 * Logging reduced a bit.
29 * The remaining running time is estimated during register merge.
31 * Revision 1.48 1996/02/01 20:53:26 adam
32 * The temporary per-record keys are compacted a little, and duplication
33 * of the per-records keys are avoided when they are saved in the record
36 * Revision 1.47 1996/01/17 14:57:48 adam
37 * Prototype changed for reader functions in extract/retrieve. File
38 * is identified by 'void *' instead of 'int.
40 * Revision 1.46 1995/12/15 14:57:16 adam
43 * Revision 1.45 1995/12/15 12:37:41 adam
44 * In addRecordKeyAny: Writes key only when attrSet != -1.
46 * Revision 1.44 1995/12/12 16:00:54 adam
47 * System call sync(2) used after update/commit.
48 * Locking (based on fcntl) uses F_EXLCK and F_SHLCK instead of F_WRLCK
51 * Revision 1.43 1995/12/11 09:12:46 adam
52 * The rec_get function returns NULL if record doesn't exist - will
53 * happen in the server if the result set records have been deleted since
54 * the creation of the set (i.e. the search).
55 * The server saves a result temporarily if it is 'volatile', i.e. the
56 * set is register dependent.
58 * Revision 1.42 1995/12/07 17:38:46 adam
59 * Work locking mechanisms for concurrent updates/commit.
61 * Revision 1.41 1995/12/06 16:06:42 adam
62 * Better diagnostics. Work on 'real' dictionary deletion.
64 * Revision 1.40 1995/12/05 16:57:40 adam
65 * More work on regular patterns.
67 * Revision 1.39 1995/12/05 13:20:18 adam
68 * Bug fix: file_read sometimes returned early EOF.
70 * Revision 1.38 1995/12/04 17:59:21 adam
71 * More work on regular expression conversion.
73 * Revision 1.37 1995/12/04 14:22:27 adam
74 * Extra arg to recType_byName.
75 * Started work on new regular expression parsed input to
78 * Revision 1.36 1995/11/30 08:34:29 adam
79 * Started work on commit facility.
80 * Changed a few malloc/free to xmalloc/xfree.
82 * Revision 1.35 1995/11/28 14:26:21 adam
83 * Bug fix: recordId with constant wasn't right.
84 * Bug fix: recordId dictionary entry wasn't deleted when needed.
86 * Revision 1.34 1995/11/28 09:09:38 adam
87 * Zebra config renamed.
88 * Use setting 'recordId' to identify record now.
89 * Bug fix in recindex.c: rec_release_blocks was invokeded even
90 * though the blocks were already released.
91 * File traversal properly deletes records when needed.
93 * Revision 1.33 1995/11/27 09:56:20 adam
94 * Record info elements better enumerated. Internal store of records.
96 * Revision 1.32 1995/11/25 10:24:05 adam
97 * More record fields - they are enumerated now.
98 * New options: flagStoreData flagStoreKey.
100 * Revision 1.31 1995/11/24 11:31:35 adam
101 * Commands add & del read filenames from stdin if source directory is
103 * Match criteria supports 'constant' strings.
105 * Revision 1.30 1995/11/22 17:19:16 adam
106 * Record management uses the bfile system.
108 * Revision 1.29 1995/11/21 15:01:14 adam
109 * New general match criteria implemented.
110 * New feature: document groups.
112 * Revision 1.28 1995/11/21 09:20:30 adam
113 * Yet more work on record match.
115 * Revision 1.27 1995/11/20 16:59:45 adam
116 * New update method: the 'old' keys are saved for each records.
118 * Revision 1.26 1995/11/20 11:56:24 adam
119 * Work on new traversal.
121 * Revision 1.25 1995/11/16 15:34:54 adam
122 * Uses new record management system in both indexer and server.
124 * Revision 1.24 1995/11/15 19:13:08 adam
125 * Work on record management.
127 * Revision 1.23 1995/10/27 14:00:10 adam
128 * Implemented detection of database availability.
130 * Revision 1.22 1995/10/17 18:02:07 adam
131 * New feature: databases. Implemented as prefix to words in dictionary.
133 * Revision 1.21 1995/10/10 12:24:38 adam
134 * Temporary sort files are compressed.
136 * Revision 1.20 1995/10/06 13:52:05 adam
137 * Bug fixes. Handler may abort further scanning.
139 * Revision 1.19 1995/10/04 12:55:16 adam
140 * Bug fix in ranked search. Use=Any keys inserted.
142 * Revision 1.18 1995/10/04 09:37:08 quinn
145 * Revision 1.17 1995/10/03 14:28:57 adam
146 * Buffered read in extract works.
148 * Revision 1.16 1995/10/03 14:28:45 adam
149 * Work on more effecient read handler in extract.
151 * Revision 1.15 1995/10/02 15:42:53 adam
152 * Extract uses file descriptors instead of FILE pointers.
154 * Revision 1.14 1995/10/02 15:29:13 adam
155 * More logging in file_extract.
157 * Revision 1.13 1995/09/29 14:01:39 adam
160 * Revision 1.12 1995/09/28 14:22:56 adam
161 * Sort uses smaller temporary files.
163 * Revision 1.11 1995/09/28 12:10:31 adam
164 * Bug fixes. Field prefix used in queries.
166 * Revision 1.10 1995/09/28 09:19:41 adam
167 * xfree/xmalloc used everywhere.
168 * Extract/retrieve method seems to work for text records.
170 * Revision 1.9 1995/09/27 12:22:28 adam
171 * More work on extract in record control.
172 * Field name is not in isam keys but in prefix in dictionary words.
174 * Revision 1.8 1995/09/14 07:48:22 adam
175 * Record control management.
177 * Revision 1.7 1995/09/11 13:09:32 adam
178 * More work on relevance feedback.
180 * Revision 1.6 1995/09/08 14:52:27 adam
181 * Minor changes. Dictionary is lower case now.
183 * Revision 1.5 1995/09/06 16:11:16 adam
184 * Option: only one word key per file.
186 * Revision 1.4 1995/09/05 15:28:39 adam
187 * More work on search engine.
189 * Revision 1.3 1995/09/04 12:33:41 adam
190 * Various cleanup. YAZ util used instead.
192 * Revision 1.2 1995/09/04 09:10:34 adam
193 * More work on index add/del/update.
194 * Merge sort implemented.
195 * Initial work on z39 server.
197 * Revision 1.1 1995/09/01 14:06:35 adam
198 * Split of work into more files.
207 #include <alexutil.h>
211 #include "recindex.h"
213 static Dict matchDict;
215 static Records records = NULL;
217 static char **key_buf;
218 static size_t ptr_top;
220 static size_t key_buf_used;
221 static int key_file_no;
223 static int records_inserted = 0;
224 static int records_updated = 0;
225 static int records_deleted = 0;
226 static int records_processed = 0;
228 static void logRecord (int showFlag)
232 if (showFlag || !(records_processed % 1000))
234 logf (LOG_LOG, "Records: %7d i/u/d %d/%d/%d",
235 records_processed, records_inserted, records_updated,
240 void key_open (int mem)
244 key_buf = xmalloc (mem);
245 ptr_top = mem/sizeof(char*);
251 if (!(matchDict = dict_open (GMATCH_DICT, 50, 1)))
253 logf (LOG_FATAL, "dict_open fail of %s", GMATCH_DICT);
257 records = rec_open (1);
266 void encode_key_init (struct encode_info *i)
272 char *encode_key_int (int d, char *bp)
281 else if (d <= 4194303)
283 *bp++ = 128 + (d>>16);
284 *bp++ = (d>>8) & 255;
289 *bp++ = 192 + (d>>24);
290 *bp++ = (d>>16) & 255;
291 *bp++ = (d>>8) & 255;
297 void encode_key_write (char *k, struct encode_info *i, FILE *outf)
302 while ((*bp++ = *k++))
304 memcpy (&key, k+1, sizeof(struct it_key));
305 bp = encode_key_int ( (key.sysno - i->sysno) * 2 + *k, bp);
306 if (i->sysno != key.sysno)
308 i->sysno = key.sysno;
311 bp = encode_key_int (key.seqno - i->seqno, bp);
312 i->seqno = key.seqno;
313 if (fwrite (i->buf, bp - i->buf, 1, outf) != 1)
315 logf (LOG_FATAL|LOG_ERRNO, "fwrite");
320 void key_flush (void)
325 struct encode_info encode_info;
331 logf (LOG_LOG, "sorting section %d", key_file_no);
332 qsort (key_buf + ptr_top-ptr_i, ptr_i, sizeof(char*), key_qsort_compare);
333 sprintf (out_fname, TEMP_FNAME, key_file_no);
335 if (!(outf = fopen (out_fname, "w")))
337 logf (LOG_FATAL|LOG_ERRNO, "fopen (4) %s", out_fname);
340 logf (LOG_LOG, "writing section %d", key_file_no);
341 prevcp = cp = key_buf[ptr_top-ptr_i];
343 encode_key_init (&encode_info);
344 encode_key_write (cp, &encode_info, outf);
347 cp = key_buf[ptr_top-ptr_i];
348 if (strcmp (cp, prevcp))
350 encode_key_init (&encode_info);
351 encode_key_write (cp, &encode_info, outf);
355 encode_key_write (cp + strlen(cp), &encode_info, outf);
359 logf (LOG_FATAL|LOG_ERRNO, "fclose %s", out_fname);
362 logf (LOG_LOG, "finished section %d", key_file_no);
371 rec_close (&records);
372 dict_close (matchDict);
378 static void wordInit (RecWord *p)
382 p->which = Word_String;
393 static void addRecordKey (const RecWord *p)
401 if (reckeys.buf_used+1024 > reckeys.buf_max)
405 b = xmalloc (reckeys.buf_max += 128000);
406 if (reckeys.buf_used > 0)
407 memcpy (b, reckeys.buf, reckeys.buf_used);
411 dst = reckeys.buf + reckeys.buf_used;
413 attrSet = p->attrSet;
414 if (reckeys.buf_used > 0 && reckeys.prevAttrSet == attrSet)
417 reckeys.prevAttrSet = attrSet;
418 attrUse = p->attrUse;
419 if (reckeys.buf_used > 0 && reckeys.prevAttrUse == attrUse)
422 reckeys.prevAttrUse = attrUse;
426 case Word_String: case Word_Phrase:
431 memcpy (dst, &attrSet, sizeof(attrSet));
432 dst += sizeof(attrSet);
436 memcpy (dst, &attrUse, sizeof(attrUse));
437 dst += sizeof(attrUse);
439 for (i = 0; p->u.string[i]; i++)
440 *dst++ = p->u.string[i];
443 memcpy (dst, &p->seqno, sizeof(p->seqno));
444 dst += sizeof(p->seqno);
450 reckeys.buf_used = dst - reckeys.buf;
453 static void flushRecordKeys (SYSNO sysno, int cmd, struct recKeys *reckeys,
454 const char *databaseName)
459 while (off < reckeys->buf_used)
461 const char *src = reckeys->buf + off;
469 memcpy (&attrSet, src, sizeof(attrSet));
470 src += sizeof(attrSet);
474 memcpy (&attrUse, src, sizeof(attrUse));
475 src += sizeof(attrUse);
477 if (key_buf_used + 1024 > (ptr_top-ptr_i)*sizeof(char*))
480 key_buf[ptr_top-ptr_i] = (char*)key_buf + key_buf_used;
481 key_buf_used += index_word_prefix ((char*)key_buf + key_buf_used,
482 attrSet, attrUse, databaseName);
484 ((char*)key_buf) [key_buf_used++] = index_char_cvt (*src++);
486 ((char*)key_buf) [key_buf_used++] = '\0';
488 ((char*) key_buf)[key_buf_used++] = cmd;
490 memcpy (&key.seqno, src, sizeof(key.seqno));
491 src += sizeof(key.seqno);
493 memcpy ((char*)key_buf + key_buf_used, &key, sizeof(key));
494 key_buf_used += sizeof(key);
495 off = src - reckeys->buf;
497 assert (off == reckeys->buf_used);
500 static const char **searchRecordKey (struct recKeys *reckeys,
501 int attrSetS, int attrUseS)
503 static const char *ws[32];
508 for (i = 0; i<32; i++)
511 while (off < reckeys->buf_used)
513 const char *src = reckeys->buf + off;
519 memcpy (&attrSet, src, sizeof(attrSet));
520 src += sizeof(attrSet);
522 memcpy (&attrUse, src, sizeof(attrUse));
523 src += sizeof(attrUse);
529 memcpy (&seqno, src, sizeof(seqno));
530 src += sizeof(seqno);
533 logf (LOG_LOG, "(%d,%d) %d %s", attrSet, attrUse, seqno, wstart);
535 if (attrUseS == attrUse && attrSetS == attrSet)
542 woff = seqno - startSeq;
543 if (woff >= 0 && woff < 31)
547 off = src - reckeys->buf;
549 assert (off == reckeys->buf_used);
553 static void addRecordKeyAny (const RecWord *p)
555 if (p->attrSet != 1 || p->attrUse != 1016)
559 memcpy (&w, p, sizeof(w));
564 if (p->attrSet != -1)
568 struct file_read_info {
576 static struct file_read_info *file_read_start (int fd)
578 struct file_read_info *fi = xmalloc (sizeof(*fi));
582 fi->file_moffset = 0;
586 static void file_read_stop (struct file_read_info *fi)
592 static off_t file_seek (void *handle, off_t offset)
594 struct file_read_info *p = handle;
595 p->file_offset = offset;
596 return lseek (p->fd, offset, SEEK_SET);
599 static int file_read (void *handle, char *buf, size_t count)
601 struct file_read_info *p = handle;
604 r = read (fd, buf, count);
608 if (p->file_offset > p->file_max)
609 p->file_max = p->file_offset;
614 static void file_begin (void *handle)
616 struct file_read_info *p = handle;
618 p->file_offset = p->file_moffset;
620 lseek (p->fd, p->file_moffset, SEEK_SET);
624 static void file_end (void *handle, off_t offset)
626 struct file_read_info *p = handle;
628 assert (p->file_more == 0);
630 p->file_moffset = offset;
633 static int atois (const char **s)
636 while ( (c=**s) >= '0' && c <= '9')
638 val = val*10 + c - '0';
644 static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup,
648 static char dstBuf[2048];
650 const char *s = spec;
651 static const char **w;
656 while (*s == ' ' || *s == '\t')
663 int attrSet, attrUse;
667 attrSet = atois (&s);
670 logf (LOG_WARN, "Missing , in match criteria %s in group %s",
671 spec, rGroup->groupName ? rGroup->groupName : "none");
675 attrUse = atois (&s);
676 w = searchRecordKey (reckeys, attrSet, attrUse);
681 for (i = 0; i<32; i++)
686 logf (LOG_WARN, "Missing ) in match criteria %s in group %s",
687 spec, rGroup->groupName ? rGroup->groupName : "none");
692 for (i = 0; i<32; i++)
693 if (matchFlag[i] && w[i])
705 logf (LOG_WARN, "Record didn't contain match"
706 " fields in (%d,%d)", attrSet, attrUse);
714 const char *spec_src = NULL;
715 const char *s1 = ++s;
716 while (*s1 && *s1 != ' ' && *s1 != '\t')
722 memcpy (special, s, spec_len);
723 special[spec_len] = '\0';
726 if (!strcmp (special, "group"))
727 spec_src = rGroup->groupName;
728 else if (!strcmp (special, "database"))
729 spec_src = rGroup->databaseName;
730 else if (!strcmp (special, "filename"))
732 else if (!strcmp (special, "type"))
733 spec_src = rGroup->recordType;
738 strcpy (dst, spec_src);
739 dst += strlen (spec_src);
742 else if (*s == '\"' || *s == '\'')
744 int stopMarker = *s++;
748 while (*s && *s != stopMarker)
751 tmpString[i++] = *s++;
756 strcpy (dst, tmpString);
757 dst += strlen (tmpString);
761 logf (LOG_WARN, "Syntax error in match criteria %s in group %s",
762 spec, rGroup->groupName ? rGroup->groupName : "none");
769 logf (LOG_WARN, "No match criteria for record %s in group %s",
770 fname, rGroup->groupName ? rGroup->groupName : "none");
776 struct recordLogInfo {
779 struct recordGroup *rGroup;
782 static void recordLogPreamble (int level, const char *msg, void *info)
784 struct recordLogInfo *p = info;
785 FILE *outf = log_file ();
790 fprintf (outf, "%s of ", p->op);
791 fprintf (outf, "%s type %s\n", p->rGroup->recordType, p->fname);
792 log_event_start (NULL, NULL);
795 static int recordExtract (SYSNO *sysno, const char *fname,
796 struct recordGroup *rGroup, int deleteFlag,
797 struct file_read_info *fi, RecType recType,
800 struct recExtractCtrl extractCtrl;
804 off_t recordOffset = 0;
806 struct recordLogInfo logInfo;
808 logInfo.fname = fname;
810 logInfo.rGroup = rGroup;
811 log_event_start (recordLogPreamble, &logInfo);
815 /* we are going to read from a file, so prepare the extraction */
817 extractCtrl.subType = subType;
818 extractCtrl.init = wordInit;
819 extractCtrl.add = addRecordKeyAny;
821 reckeys.buf_used = 0;
822 reckeys.prevAttrUse = -1;
823 reckeys.prevAttrSet = -1;
825 recordOffset = fi->file_moffset;
826 extractCtrl.offset = recordOffset;
827 extractCtrl.readf = file_read;
828 extractCtrl.seekf = file_seek;
829 extractCtrl.endf = file_end;
830 r = (*recType->extract)(&extractCtrl);
834 /* error occured during extraction ... */
835 logf (LOG_WARN, "Couldn't extract file %s, code %d", fname, r);
838 if (reckeys.buf_used == 0)
840 /* the extraction process returned no information - the record
842 logf (LOG_WARN, "Empty file %s", fname);
847 /* perform match if sysno not known and if match criteria is specified */
854 if (rGroup->recordId && *rGroup->recordId)
858 matchStr = fileMatchStr (&reckeys, rGroup, fname,
862 rinfo = dict_lookup (matchDict, matchStr);
864 memcpy (sysno, rinfo+1, sizeof(*sysno));
868 logf (LOG_WARN, "Bad match criteria");
879 logf (LOG_LOG, "Cannot delete new record");
883 if (rGroup->fileVerboseFlag)
884 logf (LOG_LOG, "add %s %s+%ld", rGroup->recordType,
885 fname, (long) recordOffset);
886 rec = rec_new (records);
891 dict_insert (matchDict, matchStr, sizeof(*sysno), sysno);
893 flushRecordKeys (*sysno, 1, &reckeys, rGroup->databaseName);
899 /* record already exists */
900 struct recKeys delkeys;
902 rec = rec_get (records, *sysno);
904 delkeys.buf_used = rec->size[recInfo_delKeys];
905 delkeys.buf = rec->info[recInfo_delKeys];
906 flushRecordKeys (*sysno, 0, &delkeys, rec->info[recInfo_databaseName]);
909 /* record going to be deleted */
910 logInfo.op = "delete";
911 if (!delkeys.buf_used)
913 logf (LOG_WARN, "cannot delete; storeKeys false");
917 if (rGroup->fileVerboseFlag)
918 logf (LOG_LOG, "delete %s %s %ld", rGroup->recordType,
919 fname, (long) recordOffset);
922 dict_delete (matchDict, matchStr);
923 rec_del (records, &rec);
930 /* record going to be updated */
931 logInfo.op = "update";
932 if (!delkeys.buf_used)
934 logf (LOG_WARN, "cannot update; storeKeys false");
938 if (rGroup->fileVerboseFlag)
939 logf (LOG_LOG, "update %s %s %ld", rGroup->recordType,
940 fname, (long) recordOffset);
941 flushRecordKeys (*sysno, 1, &reckeys, rGroup->databaseName);
946 /* update file type */
947 xfree (rec->info[recInfo_fileType]);
948 rec->info[recInfo_fileType] =
949 rec_strdup (rGroup->recordType, &rec->size[recInfo_fileType]);
951 /* update filename */
952 xfree (rec->info[recInfo_filename]);
953 rec->info[recInfo_filename] =
954 rec_strdup (fname, &rec->size[recInfo_filename]);
956 /* update delete keys */
957 xfree (rec->info[recInfo_delKeys]);
958 if (reckeys.buf_used > 0 && rGroup->flagStoreKeys == 1)
961 rec->size[recInfo_delKeys] = reckeys.buf_used;
962 rec->info[recInfo_delKeys] = reckeys.buf;
966 rec->info[recInfo_delKeys] = xmalloc (reckeys.buf_used);
967 rec->size[recInfo_delKeys] = reckeys.buf_used;
968 memcpy (rec->info[recInfo_delKeys], reckeys.buf,
969 rec->size[recInfo_delKeys]);
974 rec->info[recInfo_delKeys] = NULL;
975 rec->size[recInfo_delKeys] = 0;
978 /* update store data */
979 xfree (rec->info[recInfo_storeData]);
980 if (rGroup->flagStoreData == 1)
982 rec->size[recInfo_storeData] = fi->file_max;
983 rec->info[recInfo_storeData] = xmalloc (fi->file_max);
984 if (lseek (fi->fd, recordOffset, SEEK_SET) < 0)
986 logf (LOG_ERRNO|LOG_FATAL, "seek to %ld in %s", fname,
987 (long) recordOffset);
990 if (read (fi->fd, rec->info[recInfo_storeData], fi->file_max)
993 logf (LOG_ERRNO|LOG_FATAL, "read %d bytes of %s",
994 fi->file_max, fname);
1000 rec->info[recInfo_storeData] = NULL;
1001 rec->size[recInfo_storeData] = 0;
1003 /* update database name */
1004 xfree (rec->info[recInfo_databaseName]);
1005 rec->info[recInfo_databaseName] =
1006 rec_strdup (rGroup->databaseName, &rec->size[recInfo_databaseName]);
1009 xfree (rec->info[recInfo_offset]);
1011 rec->size[recInfo_offset] = sizeof(recordOffset);
1012 rec->info[recInfo_offset] = xmalloc (sizeof(recordOffset));
1013 memcpy (rec->info[recInfo_offset], &recordOffset, sizeof(recordOffset));
1015 /* commit this record */
1016 rec_put (records, &rec);
1021 int fileExtract (SYSNO *sysno, const char *fname,
1022 const struct recordGroup *rGroupP, int deleteFlag)
1030 struct recordGroup rGroupM;
1031 struct recordGroup *rGroup = &rGroupM;
1032 struct file_read_info *fi;
1034 memcpy (rGroup, rGroupP, sizeof(*rGroupP));
1036 if (!rGroup->groupName || !*rGroup->groupName)
1039 sprintf (gprefix, "%s.", rGroup->groupName);
1041 logf (LOG_DEBUG, "fileExtract %s", fname);
1043 /* determine file extension */
1044 for (i = strlen(fname); --i >= 0; )
1045 if (fname[i] == '/')
1050 else if (fname[i] == '.')
1052 strcpy (ext, fname+i+1);
1055 /* determine file type - depending on extension */
1056 if (!rGroup->recordType)
1058 sprintf (ext_res, "%srecordType.%s", gprefix, ext);
1059 if (!(rGroup->recordType = res_get (common_resource, ext_res)))
1061 sprintf (ext_res, "%srecordType", gprefix);
1062 if (!(rGroup->recordType = res_get (common_resource, ext_res)))
1064 if (rGroup->fileVerboseFlag)
1065 logf (LOG_LOG, "? %s", fname);
1070 if (!rGroup->recordType)
1072 if (rGroup->fileVerboseFlag)
1073 logf (LOG_LOG, "? record %s", fname);
1076 if (!(recType = recType_byName (rGroup->recordType, subType)))
1078 logf (LOG_WARN, "No such record type: %s", rGroup->recordType);
1082 /* determine match criteria */
1083 if (!rGroup->recordId)
1085 sprintf (ext_res, "%srecordId.%s", gprefix, ext);
1086 rGroup->recordId = res_get (common_resource, ext_res);
1089 /* determine database name */
1090 if (!rGroup->databaseName)
1092 sprintf (ext_res, "%sdatabase.%s", gprefix, ext);
1093 if (!(rGroup->databaseName = res_get (common_resource, ext_res)))
1095 sprintf (ext_res, "%sdatabase", gprefix);
1096 rGroup->databaseName = res_get (common_resource, ext_res);
1099 if (!rGroup->databaseName)
1100 rGroup->databaseName = "Default";
1102 if (rGroup->flagStoreData == -1)
1105 sprintf (ext_res, "%sstoreData.%s", gprefix, ext);
1106 if (!(sval = res_get (common_resource, ext_res)))
1108 sprintf (ext_res, "%sstoreData", gprefix);
1109 sval = res_get (common_resource, ext_res);
1112 rGroup->flagStoreData = atoi (sval);
1114 if (rGroup->flagStoreData == -1)
1115 rGroup->flagStoreData = 0;
1117 if (rGroup->flagStoreKeys == -1)
1121 sprintf (ext_res, "%sstoreKeys.%s", gprefix, ext);
1122 if (!(sval = res_get (common_resource, ext_res)))
1124 sprintf (ext_res, "%sstoreKeys", gprefix);
1125 sval = res_get (common_resource, ext_res);
1128 rGroup->flagStoreKeys = atoi (sval);
1130 if (rGroup->flagStoreKeys == -1)
1131 rGroup->flagStoreKeys = 0;
1133 if (sysno && deleteFlag)
1137 if ((fd = open (fname, O_RDONLY)) == -1)
1139 logf (LOG_WARN|LOG_ERRNO, "open %s", fname);
1143 fi = file_read_start (fd);
1147 r = recordExtract (sysno, fname, rGroup, deleteFlag, fi,
1149 } while (r && !sysno && fi->file_more);
1150 log_event_start (NULL, NULL);
1151 file_read_stop (fi);