2 * Copyright (C) 1994-1995, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.58 1996-05-14 06:16:38 adam
8 * Compact use/set bytes used in search service.
10 * Revision 1.57 1996/05/13 14:23:04 adam
11 * Work on compaction of set/use bytes in dictionary.
13 * Revision 1.56 1996/05/09 09:54:42 adam
14 * Server supports maps from one logical attributes to a list of physical
16 * The extraction process doesn't make space consuming 'any' keys.
18 * Revision 1.55 1996/05/09 07:28:55 quinn
19 * Work towards phrases and multiple registers
21 * Revision 1.54 1996/05/01 13:46:35 adam
22 * First work on multiple records in one file.
23 * New option, -offset, to the "unread" command in the filter module.
25 * Revision 1.53 1996/04/26 12:09:43 adam
26 * Added a few comments.
28 * Revision 1.52 1996/04/25 13:27:57 adam
29 * Function recordExtract modified so that files with no keys (possibly empty)
32 * Revision 1.51 1996/03/19 11:08:42 adam
33 * Bug fix: Log preamble wasn't always turned off after recordExtract.
35 * Revision 1.50 1996/02/12 18:45:36 adam
36 * New fileVerboseFlag in record group control.
38 * Revision 1.49 1996/02/05 12:29:57 adam
39 * Logging reduced a bit.
40 * The remaining running time is estimated during register merge.
42 * Revision 1.48 1996/02/01 20:53:26 adam
43 * The temporary per-record keys are compacted a little, and duplication
44 * of the per-records keys are avoided when they are saved in the record
47 * Revision 1.47 1996/01/17 14:57:48 adam
48 * Prototype changed for reader functions in extract/retrieve. File
49 * is identified by 'void *' instead of 'int.
51 * Revision 1.46 1995/12/15 14:57:16 adam
54 * Revision 1.45 1995/12/15 12:37:41 adam
55 * In addRecordKeyAny: Writes key only when attrSet != -1.
57 * Revision 1.44 1995/12/12 16:00:54 adam
58 * System call sync(2) used after update/commit.
59 * Locking (based on fcntl) uses F_EXLCK and F_SHLCK instead of F_WRLCK
62 * Revision 1.43 1995/12/11 09:12:46 adam
63 * The rec_get function returns NULL if record doesn't exist - will
64 * happen in the server if the result set records have been deleted since
65 * the creation of the set (i.e. the search).
66 * The server saves a result temporarily if it is 'volatile', i.e. the
67 * set is register dependent.
69 * Revision 1.42 1995/12/07 17:38:46 adam
70 * Work locking mechanisms for concurrent updates/commit.
72 * Revision 1.41 1995/12/06 16:06:42 adam
73 * Better diagnostics. Work on 'real' dictionary deletion.
75 * Revision 1.40 1995/12/05 16:57:40 adam
76 * More work on regular patterns.
78 * Revision 1.39 1995/12/05 13:20:18 adam
79 * Bug fix: file_read sometimes returned early EOF.
81 * Revision 1.38 1995/12/04 17:59:21 adam
82 * More work on regular expression conversion.
84 * Revision 1.37 1995/12/04 14:22:27 adam
85 * Extra arg to recType_byName.
86 * Started work on new regular expression parsed input to
89 * Revision 1.36 1995/11/30 08:34:29 adam
90 * Started work on commit facility.
91 * Changed a few malloc/free to xmalloc/xfree.
93 * Revision 1.35 1995/11/28 14:26:21 adam
94 * Bug fix: recordId with constant wasn't right.
95 * Bug fix: recordId dictionary entry wasn't deleted when needed.
97 * Revision 1.34 1995/11/28 09:09:38 adam
98 * Zebra config renamed.
99 * Use setting 'recordId' to identify record now.
100 * Bug fix in recindex.c: rec_release_blocks was invokeded even
101 * though the blocks were already released.
102 * File traversal properly deletes records when needed.
104 * Revision 1.33 1995/11/27 09:56:20 adam
105 * Record info elements better enumerated. Internal store of records.
107 * Revision 1.32 1995/11/25 10:24:05 adam
108 * More record fields - they are enumerated now.
109 * New options: flagStoreData flagStoreKey.
111 * Revision 1.31 1995/11/24 11:31:35 adam
112 * Commands add & del read filenames from stdin if source directory is
114 * Match criteria supports 'constant' strings.
116 * Revision 1.30 1995/11/22 17:19:16 adam
117 * Record management uses the bfile system.
119 * Revision 1.29 1995/11/21 15:01:14 adam
120 * New general match criteria implemented.
121 * New feature: document groups.
123 * Revision 1.28 1995/11/21 09:20:30 adam
124 * Yet more work on record match.
126 * Revision 1.27 1995/11/20 16:59:45 adam
127 * New update method: the 'old' keys are saved for each records.
129 * Revision 1.26 1995/11/20 11:56:24 adam
130 * Work on new traversal.
132 * Revision 1.25 1995/11/16 15:34:54 adam
133 * Uses new record management system in both indexer and server.
135 * Revision 1.24 1995/11/15 19:13:08 adam
136 * Work on record management.
138 * Revision 1.23 1995/10/27 14:00:10 adam
139 * Implemented detection of database availability.
141 * Revision 1.22 1995/10/17 18:02:07 adam
142 * New feature: databases. Implemented as prefix to words in dictionary.
144 * Revision 1.21 1995/10/10 12:24:38 adam
145 * Temporary sort files are compressed.
147 * Revision 1.20 1995/10/06 13:52:05 adam
148 * Bug fixes. Handler may abort further scanning.
150 * Revision 1.19 1995/10/04 12:55:16 adam
151 * Bug fix in ranked search. Use=Any keys inserted.
153 * Revision 1.18 1995/10/04 09:37:08 quinn
156 * Revision 1.17 1995/10/03 14:28:57 adam
157 * Buffered read in extract works.
159 * Revision 1.16 1995/10/03 14:28:45 adam
160 * Work on more effecient read handler in extract.
162 * Revision 1.15 1995/10/02 15:42:53 adam
163 * Extract uses file descriptors instead of FILE pointers.
165 * Revision 1.14 1995/10/02 15:29:13 adam
166 * More logging in file_extract.
168 * Revision 1.13 1995/09/29 14:01:39 adam
171 * Revision 1.12 1995/09/28 14:22:56 adam
172 * Sort uses smaller temporary files.
174 * Revision 1.11 1995/09/28 12:10:31 adam
175 * Bug fixes. Field prefix used in queries.
177 * Revision 1.10 1995/09/28 09:19:41 adam
178 * xfree/xmalloc used everywhere.
179 * Extract/retrieve method seems to work for text records.
181 * Revision 1.9 1995/09/27 12:22:28 adam
182 * More work on extract in record control.
183 * Field name is not in isam keys but in prefix in dictionary words.
185 * Revision 1.8 1995/09/14 07:48:22 adam
186 * Record control management.
188 * Revision 1.7 1995/09/11 13:09:32 adam
189 * More work on relevance feedback.
191 * Revision 1.6 1995/09/08 14:52:27 adam
192 * Minor changes. Dictionary is lower case now.
194 * Revision 1.5 1995/09/06 16:11:16 adam
195 * Option: only one word key per file.
197 * Revision 1.4 1995/09/05 15:28:39 adam
198 * More work on search engine.
200 * Revision 1.3 1995/09/04 12:33:41 adam
201 * Various cleanup. YAZ util used instead.
203 * Revision 1.2 1995/09/04 09:10:34 adam
204 * More work on index add/del/update.
205 * Merge sort implemented.
206 * Initial work on z39 server.
208 * Revision 1.1 1995/09/01 14:06:35 adam
209 * Split of work into more files.
218 #include <alexutil.h>
224 static Dict matchDict;
226 static Records records = NULL;
228 static char **key_buf;
229 static size_t ptr_top;
231 static size_t key_buf_used;
232 static int key_file_no;
234 static int records_inserted = 0;
235 static int records_updated = 0;
236 static int records_deleted = 0;
237 static int records_processed = 0;
239 static ZebTargetInfo *zti = NULL;
241 static void logRecord (int showFlag)
245 if (showFlag || !(records_processed % 1000))
247 logf (LOG_LOG, "Records: %7d i/u/d %d/%d/%d",
248 records_processed, records_inserted, records_updated,
253 void key_open (int mem)
257 key_buf = xmalloc (mem);
258 ptr_top = mem/sizeof(char*);
264 if (!(matchDict = dict_open (GMATCH_DICT, 50, 1)))
266 logf (LOG_FATAL, "dict_open fail of %s", GMATCH_DICT);
270 records = rec_open (1);
272 zti = zebTargetInfo_open (records, 1);
282 void encode_key_init (struct encode_info *i)
288 char *encode_key_int (int d, char *bp)
297 else if (d <= 4194303)
299 *bp++ = 128 + (d>>16);
300 *bp++ = (d>>8) & 255;
305 *bp++ = 192 + (d>>24);
306 *bp++ = (d>>16) & 255;
307 *bp++ = (d>>8) & 255;
313 void encode_key_write (char *k, struct encode_info *i, FILE *outf)
318 while ((*bp++ = *k++))
320 memcpy (&key, k+1, sizeof(struct it_key));
321 bp = encode_key_int ( (key.sysno - i->sysno) * 2 + *k, bp);
322 if (i->sysno != key.sysno)
324 i->sysno = key.sysno;
327 bp = encode_key_int (key.seqno - i->seqno, bp);
328 i->seqno = key.seqno;
329 if (fwrite (i->buf, bp - i->buf, 1, outf) != 1)
331 logf (LOG_FATAL|LOG_ERRNO, "fwrite");
336 void key_flush (void)
341 struct encode_info encode_info;
347 logf (LOG_LOG, "sorting section %d", key_file_no);
348 qsort (key_buf + ptr_top-ptr_i, ptr_i, sizeof(char*), key_qsort_compare);
349 sprintf (out_fname, TEMP_FNAME, key_file_no);
351 if (!(outf = fopen (out_fname, "w")))
353 logf (LOG_FATAL|LOG_ERRNO, "fopen (4) %s", out_fname);
356 logf (LOG_LOG, "writing section %d", key_file_no);
357 prevcp = cp = key_buf[ptr_top-ptr_i];
359 encode_key_init (&encode_info);
360 encode_key_write (cp, &encode_info, outf);
363 cp = key_buf[ptr_top-ptr_i];
364 if (strcmp (cp, prevcp))
366 encode_key_init (&encode_info);
367 encode_key_write (cp, &encode_info, outf);
371 encode_key_write (cp + strlen(cp), &encode_info, outf);
375 logf (LOG_FATAL|LOG_ERRNO, "fclose %s", out_fname);
378 logf (LOG_LOG, "finished section %d", key_file_no);
388 zebTargetInfo_close (zti, 1);
390 rec_close (&records);
391 dict_close (matchDict);
397 static void wordInit (RecWord *p)
401 p->which = Word_String;
412 static void addRecordKey (const RecWord *p)
420 if (reckeys.buf_used+1024 > reckeys.buf_max)
424 b = xmalloc (reckeys.buf_max += 128000);
425 if (reckeys.buf_used > 0)
426 memcpy (b, reckeys.buf, reckeys.buf_used);
430 dst = reckeys.buf + reckeys.buf_used;
432 attrSet = p->attrSet;
433 if (reckeys.buf_used > 0 && reckeys.prevAttrSet == attrSet)
436 reckeys.prevAttrSet = attrSet;
437 attrUse = p->attrUse;
438 if (reckeys.buf_used > 0 && reckeys.prevAttrUse == attrUse)
441 reckeys.prevAttrUse = attrUse;
447 memcpy (dst, &attrSet, sizeof(attrSet));
448 dst += sizeof(attrSet);
452 memcpy (dst, &attrUse, sizeof(attrUse));
453 dst += sizeof(attrUse);
466 for (i = 0; p->u.string[i]; i++)
467 *dst++ = p->u.string[i];
470 memcpy (dst, &p->seqno, sizeof(p->seqno));
471 dst += sizeof(p->seqno);
472 reckeys.buf_used = dst - reckeys.buf;
475 static void flushRecordKeys (SYSNO sysno, int cmd, struct recKeys *reckeys,
476 const char *databaseName)
483 if (zebTargetInfo_curDatabase (zti, databaseName))
485 if (zebTargetInfo_newDatabase (zti, databaseName))
489 while (off < reckeys->buf_used)
491 const char *src = reckeys->buf + off;
499 memcpy (&attrSet, src, sizeof(attrSet));
500 src += sizeof(attrSet);
504 memcpy (&attrUse, src, sizeof(attrUse));
505 src += sizeof(attrUse);
507 if (key_buf_used + 1024 > (ptr_top-ptr_i)*sizeof(char*))
510 key_buf[ptr_top-ptr_i] = (char*)key_buf + key_buf_used;
512 lead = zebTargetInfo_lookupSU (zti, attrSet, attrUse);
514 lead = zebTargetInfo_addSU (zti, attrSet, attrUse);
516 ((char*) key_buf) [key_buf_used++] = lead;
518 key_buf_used += index_word_prefix ((char*)key_buf + key_buf_used,
519 attrSet, attrUse, databaseName);
522 ((char*)key_buf) [key_buf_used++] = index_char_cvt (*src++);
524 ((char*)key_buf) [key_buf_used++] = '\0';
526 ((char*) key_buf)[key_buf_used++] = cmd;
528 memcpy (&key.seqno, src, sizeof(key.seqno));
529 src += sizeof(key.seqno);
531 memcpy ((char*)key_buf + key_buf_used, &key, sizeof(key));
532 key_buf_used += sizeof(key);
533 off = src - reckeys->buf;
535 assert (off == reckeys->buf_used);
538 static const char **searchRecordKey (struct recKeys *reckeys,
539 int attrSetS, int attrUseS)
541 static const char *ws[32];
546 for (i = 0; i<32; i++)
549 while (off < reckeys->buf_used)
551 const char *src = reckeys->buf + off;
557 memcpy (&attrSet, src, sizeof(attrSet));
558 src += sizeof(attrSet);
560 memcpy (&attrUse, src, sizeof(attrUse));
561 src += sizeof(attrUse);
567 memcpy (&seqno, src, sizeof(seqno));
568 src += sizeof(seqno);
571 logf (LOG_LOG, "(%d,%d) %d %s", attrSet, attrUse, seqno, wstart);
573 if (attrUseS == attrUse && attrSetS == attrSet)
580 woff = seqno - startSeq;
581 if (woff >= 0 && woff < 31)
585 off = src - reckeys->buf;
587 assert (off == reckeys->buf_used);
591 struct file_read_info {
599 static struct file_read_info *file_read_start (int fd)
601 struct file_read_info *fi = xmalloc (sizeof(*fi));
605 fi->file_moffset = 0;
609 static void file_read_stop (struct file_read_info *fi)
615 static off_t file_seek (void *handle, off_t offset)
617 struct file_read_info *p = handle;
618 p->file_offset = offset;
619 return lseek (p->fd, offset, SEEK_SET);
622 static int file_read (void *handle, char *buf, size_t count)
624 struct file_read_info *p = handle;
627 r = read (fd, buf, count);
631 if (p->file_offset > p->file_max)
632 p->file_max = p->file_offset;
637 static void file_begin (void *handle)
639 struct file_read_info *p = handle;
641 p->file_offset = p->file_moffset;
643 lseek (p->fd, p->file_moffset, SEEK_SET);
647 static void file_end (void *handle, off_t offset)
649 struct file_read_info *p = handle;
651 assert (p->file_more == 0);
653 p->file_moffset = offset;
656 static int atois (const char **s)
659 while ( (c=**s) >= '0' && c <= '9')
661 val = val*10 + c - '0';
667 static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup,
671 static char dstBuf[2048];
673 const char *s = spec;
674 static const char **w;
679 while (*s == ' ' || *s == '\t')
686 int attrSet, attrUse;
690 attrSet = atois (&s);
693 logf (LOG_WARN, "Missing , in match criteria %s in group %s",
694 spec, rGroup->groupName ? rGroup->groupName : "none");
698 attrUse = atois (&s);
699 w = searchRecordKey (reckeys, attrSet, attrUse);
704 for (i = 0; i<32; i++)
709 logf (LOG_WARN, "Missing ) in match criteria %s in group %s",
710 spec, rGroup->groupName ? rGroup->groupName : "none");
715 for (i = 0; i<32; i++)
716 if (matchFlag[i] && w[i])
728 logf (LOG_WARN, "Record didn't contain match"
729 " fields in (%d,%d)", attrSet, attrUse);
737 const char *spec_src = NULL;
738 const char *s1 = ++s;
739 while (*s1 && *s1 != ' ' && *s1 != '\t')
745 memcpy (special, s, spec_len);
746 special[spec_len] = '\0';
749 if (!strcmp (special, "group"))
750 spec_src = rGroup->groupName;
751 else if (!strcmp (special, "database"))
752 spec_src = rGroup->databaseName;
753 else if (!strcmp (special, "filename"))
755 else if (!strcmp (special, "type"))
756 spec_src = rGroup->recordType;
761 strcpy (dst, spec_src);
762 dst += strlen (spec_src);
765 else if (*s == '\"' || *s == '\'')
767 int stopMarker = *s++;
771 while (*s && *s != stopMarker)
774 tmpString[i++] = *s++;
779 strcpy (dst, tmpString);
780 dst += strlen (tmpString);
784 logf (LOG_WARN, "Syntax error in match criteria %s in group %s",
785 spec, rGroup->groupName ? rGroup->groupName : "none");
792 logf (LOG_WARN, "No match criteria for record %s in group %s",
793 fname, rGroup->groupName ? rGroup->groupName : "none");
799 struct recordLogInfo {
802 struct recordGroup *rGroup;
805 static void recordLogPreamble (int level, const char *msg, void *info)
807 struct recordLogInfo *p = info;
808 FILE *outf = log_file ();
813 fprintf (outf, "%s of ", p->op);
814 fprintf (outf, "%s type %s\n", p->rGroup->recordType, p->fname);
815 log_event_start (NULL, NULL);
818 static int recordExtract (SYSNO *sysno, const char *fname,
819 struct recordGroup *rGroup, int deleteFlag,
820 struct file_read_info *fi, RecType recType,
823 struct recExtractCtrl extractCtrl;
827 off_t recordOffset = 0;
829 struct recordLogInfo logInfo;
831 logInfo.fname = fname;
833 logInfo.rGroup = rGroup;
834 log_event_start (recordLogPreamble, &logInfo);
838 /* we are going to read from a file, so prepare the extraction */
840 extractCtrl.subType = subType;
841 extractCtrl.init = wordInit;
842 extractCtrl.add = addRecordKey;
844 reckeys.buf_used = 0;
845 reckeys.prevAttrUse = -1;
846 reckeys.prevAttrSet = -1;
848 recordOffset = fi->file_moffset;
849 extractCtrl.offset = recordOffset;
850 extractCtrl.readf = file_read;
851 extractCtrl.seekf = file_seek;
852 extractCtrl.endf = file_end;
853 r = (*recType->extract)(&extractCtrl);
857 /* error occured during extraction ... */
858 logf (LOG_WARN, "Couldn't extract file %s, code %d", fname, r);
861 if (reckeys.buf_used == 0)
863 /* the extraction process returned no information - the record
865 logf (LOG_WARN, "Empty file %s", fname);
870 /* perform match if sysno not known and if match criteria is specified */
877 if (rGroup->recordId && *rGroup->recordId)
881 matchStr = fileMatchStr (&reckeys, rGroup, fname,
885 rinfo = dict_lookup (matchDict, matchStr);
887 memcpy (sysno, rinfo+1, sizeof(*sysno));
891 logf (LOG_WARN, "Bad match criteria");
902 logf (LOG_LOG, "Cannot delete new record");
906 if (rGroup->fileVerboseFlag)
907 logf (LOG_LOG, "add %s %s+%ld", rGroup->recordType,
908 fname, (long) recordOffset);
909 rec = rec_new (records);
914 dict_insert (matchDict, matchStr, sizeof(*sysno), sysno);
916 flushRecordKeys (*sysno, 1, &reckeys, rGroup->databaseName);
922 /* record already exists */
923 struct recKeys delkeys;
925 rec = rec_get (records, *sysno);
927 delkeys.buf_used = rec->size[recInfo_delKeys];
928 delkeys.buf = rec->info[recInfo_delKeys];
929 flushRecordKeys (*sysno, 0, &delkeys, rec->info[recInfo_databaseName]);
932 /* record going to be deleted */
933 logInfo.op = "delete";
934 if (!delkeys.buf_used)
936 logf (LOG_WARN, "cannot delete; storeKeys false");
940 if (rGroup->fileVerboseFlag)
941 logf (LOG_LOG, "delete %s %s %ld", rGroup->recordType,
942 fname, (long) recordOffset);
945 dict_delete (matchDict, matchStr);
946 rec_del (records, &rec);
953 /* record going to be updated */
954 logInfo.op = "update";
955 if (!delkeys.buf_used)
957 logf (LOG_WARN, "cannot update; storeKeys false");
961 if (rGroup->fileVerboseFlag)
962 logf (LOG_LOG, "update %s %s %ld", rGroup->recordType,
963 fname, (long) recordOffset);
964 flushRecordKeys (*sysno, 1, &reckeys, rGroup->databaseName);
969 /* update file type */
970 xfree (rec->info[recInfo_fileType]);
971 rec->info[recInfo_fileType] =
972 rec_strdup (rGroup->recordType, &rec->size[recInfo_fileType]);
974 /* update filename */
975 xfree (rec->info[recInfo_filename]);
976 rec->info[recInfo_filename] =
977 rec_strdup (fname, &rec->size[recInfo_filename]);
979 /* update delete keys */
980 xfree (rec->info[recInfo_delKeys]);
981 if (reckeys.buf_used > 0 && rGroup->flagStoreKeys == 1)
984 rec->size[recInfo_delKeys] = reckeys.buf_used;
985 rec->info[recInfo_delKeys] = reckeys.buf;
989 rec->info[recInfo_delKeys] = xmalloc (reckeys.buf_used);
990 rec->size[recInfo_delKeys] = reckeys.buf_used;
991 memcpy (rec->info[recInfo_delKeys], reckeys.buf,
992 rec->size[recInfo_delKeys]);
997 rec->info[recInfo_delKeys] = NULL;
998 rec->size[recInfo_delKeys] = 0;
1001 /* update store data */
1002 xfree (rec->info[recInfo_storeData]);
1003 if (rGroup->flagStoreData == 1)
1005 rec->size[recInfo_storeData] = fi->file_max;
1006 rec->info[recInfo_storeData] = xmalloc (fi->file_max);
1007 if (lseek (fi->fd, recordOffset, SEEK_SET) < 0)
1009 logf (LOG_ERRNO|LOG_FATAL, "seek to %ld in %s", fname,
1010 (long) recordOffset);
1013 if (read (fi->fd, rec->info[recInfo_storeData], fi->file_max)
1016 logf (LOG_ERRNO|LOG_FATAL, "read %d bytes of %s",
1017 fi->file_max, fname);
1023 rec->info[recInfo_storeData] = NULL;
1024 rec->size[recInfo_storeData] = 0;
1026 /* update database name */
1027 xfree (rec->info[recInfo_databaseName]);
1028 rec->info[recInfo_databaseName] =
1029 rec_strdup (rGroup->databaseName, &rec->size[recInfo_databaseName]);
1032 xfree (rec->info[recInfo_offset]);
1034 rec->size[recInfo_offset] = sizeof(recordOffset);
1035 rec->info[recInfo_offset] = xmalloc (sizeof(recordOffset));
1036 memcpy (rec->info[recInfo_offset], &recordOffset, sizeof(recordOffset));
1038 /* commit this record */
1039 rec_put (records, &rec);
1044 int fileExtract (SYSNO *sysno, const char *fname,
1045 const struct recordGroup *rGroupP, int deleteFlag)
1053 struct recordGroup rGroupM;
1054 struct recordGroup *rGroup = &rGroupM;
1055 struct file_read_info *fi;
1057 memcpy (rGroup, rGroupP, sizeof(*rGroupP));
1059 if (!rGroup->groupName || !*rGroup->groupName)
1062 sprintf (gprefix, "%s.", rGroup->groupName);
1064 logf (LOG_DEBUG, "fileExtract %s", fname);
1066 /* determine file extension */
1067 for (i = strlen(fname); --i >= 0; )
1068 if (fname[i] == '/')
1073 else if (fname[i] == '.')
1075 strcpy (ext, fname+i+1);
1078 /* determine file type - depending on extension */
1079 if (!rGroup->recordType)
1081 sprintf (ext_res, "%srecordType.%s", gprefix, ext);
1082 if (!(rGroup->recordType = res_get (common_resource, ext_res)))
1084 sprintf (ext_res, "%srecordType", gprefix);
1085 if (!(rGroup->recordType = res_get (common_resource, ext_res)))
1087 if (rGroup->fileVerboseFlag)
1088 logf (LOG_LOG, "? %s", fname);
1093 if (!rGroup->recordType)
1095 if (rGroup->fileVerboseFlag)
1096 logf (LOG_LOG, "? record %s", fname);
1099 if (!(recType = recType_byName (rGroup->recordType, subType)))
1101 logf (LOG_WARN, "No such record type: %s", rGroup->recordType);
1105 /* determine match criteria */
1106 if (!rGroup->recordId)
1108 sprintf (ext_res, "%srecordId.%s", gprefix, ext);
1109 rGroup->recordId = res_get (common_resource, ext_res);
1112 /* determine database name */
1113 if (!rGroup->databaseName)
1115 sprintf (ext_res, "%sdatabase.%s", gprefix, ext);
1116 if (!(rGroup->databaseName = res_get (common_resource, ext_res)))
1118 sprintf (ext_res, "%sdatabase", gprefix);
1119 rGroup->databaseName = res_get (common_resource, ext_res);
1122 if (!rGroup->databaseName)
1123 rGroup->databaseName = "Default";
1125 if (rGroup->flagStoreData == -1)
1128 sprintf (ext_res, "%sstoreData.%s", gprefix, ext);
1129 if (!(sval = res_get (common_resource, ext_res)))
1131 sprintf (ext_res, "%sstoreData", gprefix);
1132 sval = res_get (common_resource, ext_res);
1135 rGroup->flagStoreData = atoi (sval);
1137 if (rGroup->flagStoreData == -1)
1138 rGroup->flagStoreData = 0;
1140 if (rGroup->flagStoreKeys == -1)
1144 sprintf (ext_res, "%sstoreKeys.%s", gprefix, ext);
1145 if (!(sval = res_get (common_resource, ext_res)))
1147 sprintf (ext_res, "%sstoreKeys", gprefix);
1148 sval = res_get (common_resource, ext_res);
1151 rGroup->flagStoreKeys = atoi (sval);
1153 if (rGroup->flagStoreKeys == -1)
1154 rGroup->flagStoreKeys = 0;
1156 if (sysno && deleteFlag)
1160 if ((fd = open (fname, O_RDONLY)) == -1)
1162 logf (LOG_WARN|LOG_ERRNO, "open %s", fname);
1166 fi = file_read_start (fd);
1170 r = recordExtract (sysno, fname, rGroup, deleteFlag, fi,
1172 } while (r && !sysno && fi->file_more);
1173 log_event_start (NULL, NULL);
1174 file_read_stop (fi);