2 * Copyright (C) 1994-1996, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.60 1996-06-04 10:18:12 adam
8 * Search/scan uses character mapping module.
10 * Revision 1.59 1996/05/14 15:47:07 adam
11 * Cleanup of various buffer size entities.
13 * Revision 1.58 1996/05/14 06:16:38 adam
14 * Compact use/set bytes used in search service.
16 * Revision 1.57 1996/05/13 14:23:04 adam
17 * Work on compaction of set/use bytes in dictionary.
19 * Revision 1.56 1996/05/09 09:54:42 adam
20 * Server supports maps from one logical attributes to a list of physical
22 * The extraction process doesn't make space consuming 'any' keys.
24 * Revision 1.55 1996/05/09 07:28:55 quinn
25 * Work towards phrases and multiple registers
27 * Revision 1.54 1996/05/01 13:46:35 adam
28 * First work on multiple records in one file.
29 * New option, -offset, to the "unread" command in the filter module.
31 * Revision 1.53 1996/04/26 12:09:43 adam
32 * Added a few comments.
34 * Revision 1.52 1996/04/25 13:27:57 adam
35 * Function recordExtract modified so that files with no keys (possibly empty)
38 * Revision 1.51 1996/03/19 11:08:42 adam
39 * Bug fix: Log preamble wasn't always turned off after recordExtract.
41 * Revision 1.50 1996/02/12 18:45:36 adam
42 * New fileVerboseFlag in record group control.
44 * Revision 1.49 1996/02/05 12:29:57 adam
45 * Logging reduced a bit.
46 * The remaining running time is estimated during register merge.
48 * Revision 1.48 1996/02/01 20:53:26 adam
49 * The temporary per-record keys are compacted a little, and duplication
50 * of the per-records keys are avoided when they are saved in the record
53 * Revision 1.47 1996/01/17 14:57:48 adam
54 * Prototype changed for reader functions in extract/retrieve. File
55 * is identified by 'void *' instead of 'int.
57 * Revision 1.46 1995/12/15 14:57:16 adam
60 * Revision 1.45 1995/12/15 12:37:41 adam
61 * In addRecordKeyAny: Writes key only when attrSet != -1.
63 * Revision 1.44 1995/12/12 16:00:54 adam
64 * System call sync(2) used after update/commit.
65 * Locking (based on fcntl) uses F_EXLCK and F_SHLCK instead of F_WRLCK
68 * Revision 1.43 1995/12/11 09:12:46 adam
69 * The rec_get function returns NULL if record doesn't exist - will
70 * happen in the server if the result set records have been deleted since
71 * the creation of the set (i.e. the search).
72 * The server saves a result temporarily if it is 'volatile', i.e. the
73 * set is register dependent.
75 * Revision 1.42 1995/12/07 17:38:46 adam
76 * Work locking mechanisms for concurrent updates/commit.
78 * Revision 1.41 1995/12/06 16:06:42 adam
79 * Better diagnostics. Work on 'real' dictionary deletion.
81 * Revision 1.40 1995/12/05 16:57:40 adam
82 * More work on regular patterns.
84 * Revision 1.39 1995/12/05 13:20:18 adam
85 * Bug fix: file_read sometimes returned early EOF.
87 * Revision 1.38 1995/12/04 17:59:21 adam
88 * More work on regular expression conversion.
90 * Revision 1.37 1995/12/04 14:22:27 adam
91 * Extra arg to recType_byName.
92 * Started work on new regular expression parsed input to
95 * Revision 1.36 1995/11/30 08:34:29 adam
96 * Started work on commit facility.
97 * Changed a few malloc/free to xmalloc/xfree.
99 * Revision 1.35 1995/11/28 14:26:21 adam
100 * Bug fix: recordId with constant wasn't right.
101 * Bug fix: recordId dictionary entry wasn't deleted when needed.
103 * Revision 1.34 1995/11/28 09:09:38 adam
104 * Zebra config renamed.
105 * Use setting 'recordId' to identify record now.
106 * Bug fix in recindex.c: rec_release_blocks was invokeded even
107 * though the blocks were already released.
108 * File traversal properly deletes records when needed.
110 * Revision 1.33 1995/11/27 09:56:20 adam
111 * Record info elements better enumerated. Internal store of records.
113 * Revision 1.32 1995/11/25 10:24:05 adam
114 * More record fields - they are enumerated now.
115 * New options: flagStoreData flagStoreKey.
117 * Revision 1.31 1995/11/24 11:31:35 adam
118 * Commands add & del read filenames from stdin if source directory is
120 * Match criteria supports 'constant' strings.
122 * Revision 1.30 1995/11/22 17:19:16 adam
123 * Record management uses the bfile system.
125 * Revision 1.29 1995/11/21 15:01:14 adam
126 * New general match criteria implemented.
127 * New feature: document groups.
129 * Revision 1.28 1995/11/21 09:20:30 adam
130 * Yet more work on record match.
132 * Revision 1.27 1995/11/20 16:59:45 adam
133 * New update method: the 'old' keys are saved for each records.
135 * Revision 1.26 1995/11/20 11:56:24 adam
136 * Work on new traversal.
138 * Revision 1.25 1995/11/16 15:34:54 adam
139 * Uses new record management system in both indexer and server.
141 * Revision 1.24 1995/11/15 19:13:08 adam
142 * Work on record management.
144 * Revision 1.23 1995/10/27 14:00:10 adam
145 * Implemented detection of database availability.
147 * Revision 1.22 1995/10/17 18:02:07 adam
148 * New feature: databases. Implemented as prefix to words in dictionary.
150 * Revision 1.21 1995/10/10 12:24:38 adam
151 * Temporary sort files are compressed.
153 * Revision 1.20 1995/10/06 13:52:05 adam
154 * Bug fixes. Handler may abort further scanning.
156 * Revision 1.19 1995/10/04 12:55:16 adam
157 * Bug fix in ranked search. Use=Any keys inserted.
159 * Revision 1.18 1995/10/04 09:37:08 quinn
162 * Revision 1.17 1995/10/03 14:28:57 adam
163 * Buffered read in extract works.
165 * Revision 1.16 1995/10/03 14:28:45 adam
166 * Work on more effecient read handler in extract.
168 * Revision 1.15 1995/10/02 15:42:53 adam
169 * Extract uses file descriptors instead of FILE pointers.
171 * Revision 1.14 1995/10/02 15:29:13 adam
172 * More logging in file_extract.
174 * Revision 1.13 1995/09/29 14:01:39 adam
177 * Revision 1.12 1995/09/28 14:22:56 adam
178 * Sort uses smaller temporary files.
180 * Revision 1.11 1995/09/28 12:10:31 adam
181 * Bug fixes. Field prefix used in queries.
183 * Revision 1.10 1995/09/28 09:19:41 adam
184 * xfree/xmalloc used everywhere.
185 * Extract/retrieve method seems to work for text records.
187 * Revision 1.9 1995/09/27 12:22:28 adam
188 * More work on extract in record control.
189 * Field name is not in isam keys but in prefix in dictionary words.
191 * Revision 1.8 1995/09/14 07:48:22 adam
192 * Record control management.
194 * Revision 1.7 1995/09/11 13:09:32 adam
195 * More work on relevance feedback.
197 * Revision 1.6 1995/09/08 14:52:27 adam
198 * Minor changes. Dictionary is lower case now.
200 * Revision 1.5 1995/09/06 16:11:16 adam
201 * Option: only one word key per file.
203 * Revision 1.4 1995/09/05 15:28:39 adam
204 * More work on search engine.
206 * Revision 1.3 1995/09/04 12:33:41 adam
207 * Various cleanup. YAZ util used instead.
209 * Revision 1.2 1995/09/04 09:10:34 adam
210 * More work on index add/del/update.
211 * Merge sort implemented.
212 * Initial work on z39 server.
214 * Revision 1.1 1995/09/01 14:06:35 adam
215 * Split of work into more files.
223 #include <alexutil.h>
229 static Dict matchDict;
231 static Records records = NULL;
233 static char **key_buf;
234 static size_t ptr_top;
236 static size_t key_buf_used;
237 static int key_file_no;
239 static int records_inserted = 0;
240 static int records_updated = 0;
241 static int records_deleted = 0;
242 static int records_processed = 0;
244 static ZebTargetInfo *zti = NULL;
246 static void logRecord (int showFlag)
250 if (showFlag || !(records_processed % 1000))
252 logf (LOG_LOG, "Records: %7d i/u/d %d/%d/%d",
253 records_processed, records_inserted, records_updated,
258 void key_open (int mem)
262 key_buf = xmalloc (mem);
263 ptr_top = mem/sizeof(char*);
269 if (!(matchDict = dict_open (GMATCH_DICT, 50, 1)))
271 logf (LOG_FATAL, "dict_open fail of %s", GMATCH_DICT);
275 records = rec_open (1);
277 zti = zebTargetInfo_open (records, 1);
287 void encode_key_init (struct encode_info *i)
293 char *encode_key_int (int d, char *bp)
302 else if (d <= 4194303)
304 *bp++ = 128 + (d>>16);
305 *bp++ = (d>>8) & 255;
310 *bp++ = 192 + (d>>24);
311 *bp++ = (d>>16) & 255;
312 *bp++ = (d>>8) & 255;
318 void encode_key_write (char *k, struct encode_info *i, FILE *outf)
323 while ((*bp++ = *k++))
325 memcpy (&key, k+1, sizeof(struct it_key));
326 bp = encode_key_int ( (key.sysno - i->sysno) * 2 + *k, bp);
327 if (i->sysno != key.sysno)
329 i->sysno = key.sysno;
332 bp = encode_key_int (key.seqno - i->seqno, bp);
333 i->seqno = key.seqno;
334 if (fwrite (i->buf, bp - i->buf, 1, outf) != 1)
336 logf (LOG_FATAL|LOG_ERRNO, "fwrite");
341 void key_flush (void)
346 struct encode_info encode_info;
352 logf (LOG_LOG, "sorting section %d", key_file_no);
353 qsort (key_buf + ptr_top-ptr_i, ptr_i, sizeof(char*), key_qsort_compare);
354 sprintf (out_fname, TEMP_FNAME, key_file_no);
356 if (!(outf = fopen (out_fname, "w")))
358 logf (LOG_FATAL|LOG_ERRNO, "fopen (4) %s", out_fname);
361 logf (LOG_LOG, "writing section %d", key_file_no);
362 prevcp = cp = key_buf[ptr_top-ptr_i];
364 encode_key_init (&encode_info);
365 encode_key_write (cp, &encode_info, outf);
368 cp = key_buf[ptr_top-ptr_i];
369 if (strcmp (cp, prevcp))
371 encode_key_init (&encode_info);
372 encode_key_write (cp, &encode_info, outf);
376 encode_key_write (cp + strlen(cp), &encode_info, outf);
380 logf (LOG_FATAL|LOG_ERRNO, "fclose %s", out_fname);
383 logf (LOG_LOG, "finished section %d", key_file_no);
393 zebTargetInfo_close (zti, 1);
395 rec_close (&records);
396 dict_close (matchDict);
402 static void wordInit (RecWord *p)
406 p->which = Word_String;
417 static void addRecordKey (const RecWord *p)
425 if (reckeys.buf_used+1024 > reckeys.buf_max)
429 b = xmalloc (reckeys.buf_max += 128000);
430 if (reckeys.buf_used > 0)
431 memcpy (b, reckeys.buf, reckeys.buf_used);
435 dst = reckeys.buf + reckeys.buf_used;
437 attrSet = p->attrSet;
438 if (reckeys.buf_used > 0 && reckeys.prevAttrSet == attrSet)
441 reckeys.prevAttrSet = attrSet;
442 attrUse = p->attrUse;
443 if (reckeys.buf_used > 0 && reckeys.prevAttrUse == attrUse)
446 reckeys.prevAttrUse = attrUse;
452 memcpy (dst, &attrSet, sizeof(attrSet));
453 dst += sizeof(attrSet);
457 memcpy (dst, &attrUse, sizeof(attrUse));
458 dst += sizeof(attrUse);
471 for (i = 0; p->u.string[i]; i++)
472 *dst++ = p->u.string[i];
475 memcpy (dst, &p->seqno, sizeof(p->seqno));
476 dst += sizeof(p->seqno);
477 reckeys.buf_used = dst - reckeys.buf;
480 static void flushRecordKeys (SYSNO sysno, int cmd, struct recKeys *reckeys,
481 const char *databaseName)
487 if (zebTargetInfo_curDatabase (zti, databaseName))
489 if (zebTargetInfo_newDatabase (zti, databaseName))
492 while (off < reckeys->buf_used)
494 const char *src = reckeys->buf + off;
502 memcpy (&attrSet, src, sizeof(attrSet));
503 src += sizeof(attrSet);
507 memcpy (&attrUse, src, sizeof(attrUse));
508 src += sizeof(attrUse);
510 if (key_buf_used + 1024 > (ptr_top-ptr_i)*sizeof(char*))
513 key_buf[ptr_top-ptr_i] = (char*)key_buf + key_buf_used;
515 lead = zebTargetInfo_lookupSU (zti, attrSet, attrUse);
517 lead = zebTargetInfo_addSU (zti, attrSet, attrUse);
519 ((char*) key_buf) [key_buf_used++] = lead;
521 ((char*)key_buf) [key_buf_used++] = *src++;
523 ((char*)key_buf) [key_buf_used++] = '\0';
525 ((char*) key_buf)[key_buf_used++] = cmd;
527 memcpy (&key.seqno, src, sizeof(key.seqno));
528 src += sizeof(key.seqno);
530 memcpy ((char*)key_buf + key_buf_used, &key, sizeof(key));
531 key_buf_used += sizeof(key);
532 off = src - reckeys->buf;
534 assert (off == reckeys->buf_used);
537 static const char **searchRecordKey (struct recKeys *reckeys,
538 int attrSetS, int attrUseS)
540 static const char *ws[32];
545 for (i = 0; i<32; i++)
548 while (off < reckeys->buf_used)
550 const char *src = reckeys->buf + off;
556 memcpy (&attrSet, src, sizeof(attrSet));
557 src += sizeof(attrSet);
559 memcpy (&attrUse, src, sizeof(attrUse));
560 src += sizeof(attrUse);
566 memcpy (&seqno, src, sizeof(seqno));
567 src += sizeof(seqno);
570 logf (LOG_LOG, "(%d,%d) %d %s", attrSet, attrUse, seqno, wstart);
572 if (attrUseS == attrUse && attrSetS == attrSet)
579 woff = seqno - startSeq;
580 if (woff >= 0 && woff < 31)
584 off = src - reckeys->buf;
586 assert (off == reckeys->buf_used);
590 struct file_read_info {
598 static struct file_read_info *file_read_start (int fd)
600 struct file_read_info *fi = xmalloc (sizeof(*fi));
604 fi->file_moffset = 0;
608 static void file_read_stop (struct file_read_info *fi)
614 static off_t file_seek (void *handle, off_t offset)
616 struct file_read_info *p = handle;
617 p->file_offset = offset;
618 return lseek (p->fd, offset, SEEK_SET);
621 static int file_read (void *handle, char *buf, size_t count)
623 struct file_read_info *p = handle;
626 r = read (fd, buf, count);
630 if (p->file_offset > p->file_max)
631 p->file_max = p->file_offset;
636 static void file_begin (void *handle)
638 struct file_read_info *p = handle;
640 p->file_offset = p->file_moffset;
642 lseek (p->fd, p->file_moffset, SEEK_SET);
646 static void file_end (void *handle, off_t offset)
648 struct file_read_info *p = handle;
650 assert (p->file_more == 0);
652 p->file_moffset = offset;
655 static int atois (const char **s)
658 while ( (c=**s) >= '0' && c <= '9')
660 val = val*10 + c - '0';
666 static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup,
670 static char dstBuf[2048];
672 const char *s = spec;
673 static const char **w;
678 while (*s == ' ' || *s == '\t')
685 int attrSet, attrUse;
689 attrSet = atois (&s);
692 logf (LOG_WARN, "Missing , in match criteria %s in group %s",
693 spec, rGroup->groupName ? rGroup->groupName : "none");
697 attrUse = atois (&s);
698 w = searchRecordKey (reckeys, attrSet, attrUse);
703 for (i = 0; i<32; i++)
708 logf (LOG_WARN, "Missing ) in match criteria %s in group %s",
709 spec, rGroup->groupName ? rGroup->groupName : "none");
714 for (i = 0; i<32; i++)
715 if (matchFlag[i] && w[i])
727 logf (LOG_WARN, "Record didn't contain match"
728 " fields in (%d,%d)", attrSet, attrUse);
736 const char *spec_src = NULL;
737 const char *s1 = ++s;
738 while (*s1 && *s1 != ' ' && *s1 != '\t')
744 memcpy (special, s, spec_len);
745 special[spec_len] = '\0';
748 if (!strcmp (special, "group"))
749 spec_src = rGroup->groupName;
750 else if (!strcmp (special, "database"))
751 spec_src = rGroup->databaseName;
752 else if (!strcmp (special, "filename"))
754 else if (!strcmp (special, "type"))
755 spec_src = rGroup->recordType;
760 strcpy (dst, spec_src);
761 dst += strlen (spec_src);
764 else if (*s == '\"' || *s == '\'')
766 int stopMarker = *s++;
770 while (*s && *s != stopMarker)
773 tmpString[i++] = *s++;
778 strcpy (dst, tmpString);
779 dst += strlen (tmpString);
783 logf (LOG_WARN, "Syntax error in match criteria %s in group %s",
784 spec, rGroup->groupName ? rGroup->groupName : "none");
791 logf (LOG_WARN, "No match criteria for record %s in group %s",
792 fname, rGroup->groupName ? rGroup->groupName : "none");
798 struct recordLogInfo {
801 struct recordGroup *rGroup;
804 static void recordLogPreamble (int level, const char *msg, void *info)
806 struct recordLogInfo *p = info;
807 FILE *outf = log_file ();
812 fprintf (outf, "%s of ", p->op);
813 fprintf (outf, "%s type %s\n", p->rGroup->recordType, p->fname);
814 log_event_start (NULL, NULL);
817 static int recordExtract (SYSNO *sysno, const char *fname,
818 struct recordGroup *rGroup, int deleteFlag,
819 struct file_read_info *fi, RecType recType,
822 struct recExtractCtrl extractCtrl;
826 off_t recordOffset = 0;
828 struct recordLogInfo logInfo;
830 logInfo.fname = fname;
832 logInfo.rGroup = rGroup;
833 log_event_start (recordLogPreamble, &logInfo);
837 /* we are going to read from a file, so prepare the extraction */
839 extractCtrl.subType = subType;
840 extractCtrl.init = wordInit;
841 extractCtrl.add = addRecordKey;
843 reckeys.buf_used = 0;
844 reckeys.prevAttrUse = -1;
845 reckeys.prevAttrSet = -1;
847 recordOffset = fi->file_moffset;
848 extractCtrl.offset = recordOffset;
849 extractCtrl.readf = file_read;
850 extractCtrl.seekf = file_seek;
851 extractCtrl.endf = file_end;
852 r = (*recType->extract)(&extractCtrl);
856 /* error occured during extraction ... */
857 logf (LOG_WARN, "Couldn't extract file %s, code %d", fname, r);
860 if (reckeys.buf_used == 0)
862 /* the extraction process returned no information - the record
864 logf (LOG_WARN, "Empty file %s", fname);
869 /* perform match if sysno not known and if match criteria is specified */
876 if (rGroup->recordId && *rGroup->recordId)
880 matchStr = fileMatchStr (&reckeys, rGroup, fname,
884 rinfo = dict_lookup (matchDict, matchStr);
886 memcpy (sysno, rinfo+1, sizeof(*sysno));
890 logf (LOG_WARN, "Bad match criteria");
901 logf (LOG_LOG, "Cannot delete new record");
905 if (rGroup->fileVerboseFlag)
906 logf (LOG_LOG, "add %s %s+%ld", rGroup->recordType,
907 fname, (long) recordOffset);
908 rec = rec_new (records);
913 dict_insert (matchDict, matchStr, sizeof(*sysno), sysno);
915 flushRecordKeys (*sysno, 1, &reckeys, rGroup->databaseName);
921 /* record already exists */
922 struct recKeys delkeys;
924 rec = rec_get (records, *sysno);
926 delkeys.buf_used = rec->size[recInfo_delKeys];
927 delkeys.buf = rec->info[recInfo_delKeys];
928 flushRecordKeys (*sysno, 0, &delkeys, rec->info[recInfo_databaseName]);
931 /* record going to be deleted */
932 logInfo.op = "delete";
933 if (!delkeys.buf_used)
935 logf (LOG_WARN, "cannot delete; storeKeys false");
939 if (rGroup->fileVerboseFlag)
940 logf (LOG_LOG, "delete %s %s %ld", rGroup->recordType,
941 fname, (long) recordOffset);
944 dict_delete (matchDict, matchStr);
945 rec_del (records, &rec);
952 /* record going to be updated */
953 logInfo.op = "update";
954 if (!delkeys.buf_used)
956 logf (LOG_WARN, "cannot update; storeKeys false");
960 if (rGroup->fileVerboseFlag)
961 logf (LOG_LOG, "update %s %s %ld", rGroup->recordType,
962 fname, (long) recordOffset);
963 flushRecordKeys (*sysno, 1, &reckeys, rGroup->databaseName);
968 /* update file type */
969 xfree (rec->info[recInfo_fileType]);
970 rec->info[recInfo_fileType] =
971 rec_strdup (rGroup->recordType, &rec->size[recInfo_fileType]);
973 /* update filename */
974 xfree (rec->info[recInfo_filename]);
975 rec->info[recInfo_filename] =
976 rec_strdup (fname, &rec->size[recInfo_filename]);
978 /* update delete keys */
979 xfree (rec->info[recInfo_delKeys]);
980 if (reckeys.buf_used > 0 && rGroup->flagStoreKeys == 1)
983 rec->size[recInfo_delKeys] = reckeys.buf_used;
984 rec->info[recInfo_delKeys] = reckeys.buf;
988 rec->info[recInfo_delKeys] = xmalloc (reckeys.buf_used);
989 rec->size[recInfo_delKeys] = reckeys.buf_used;
990 memcpy (rec->info[recInfo_delKeys], reckeys.buf,
991 rec->size[recInfo_delKeys]);
996 rec->info[recInfo_delKeys] = NULL;
997 rec->size[recInfo_delKeys] = 0;
1000 /* update store data */
1001 xfree (rec->info[recInfo_storeData]);
1002 if (rGroup->flagStoreData == 1)
1004 rec->size[recInfo_storeData] = fi->file_max;
1005 rec->info[recInfo_storeData] = xmalloc (fi->file_max);
1006 if (lseek (fi->fd, recordOffset, SEEK_SET) < 0)
1008 logf (LOG_ERRNO|LOG_FATAL, "seek to %ld in %s", fname,
1009 (long) recordOffset);
1012 if (read (fi->fd, rec->info[recInfo_storeData], fi->file_max)
1015 logf (LOG_ERRNO|LOG_FATAL, "read %d bytes of %s",
1016 fi->file_max, fname);
1022 rec->info[recInfo_storeData] = NULL;
1023 rec->size[recInfo_storeData] = 0;
1025 /* update database name */
1026 xfree (rec->info[recInfo_databaseName]);
1027 rec->info[recInfo_databaseName] =
1028 rec_strdup (rGroup->databaseName, &rec->size[recInfo_databaseName]);
1031 xfree (rec->info[recInfo_offset]);
1033 rec->size[recInfo_offset] = sizeof(recordOffset);
1034 rec->info[recInfo_offset] = xmalloc (sizeof(recordOffset));
1035 memcpy (rec->info[recInfo_offset], &recordOffset, sizeof(recordOffset));
1037 /* commit this record */
1038 rec_put (records, &rec);
1043 int fileExtract (SYSNO *sysno, const char *fname,
1044 const struct recordGroup *rGroupP, int deleteFlag)
1052 struct recordGroup rGroupM;
1053 struct recordGroup *rGroup = &rGroupM;
1054 struct file_read_info *fi;
1056 memcpy (rGroup, rGroupP, sizeof(*rGroupP));
1058 if (!rGroup->groupName || !*rGroup->groupName)
1061 sprintf (gprefix, "%s.", rGroup->groupName);
1063 logf (LOG_DEBUG, "fileExtract %s", fname);
1065 /* determine file extension */
1066 for (i = strlen(fname); --i >= 0; )
1067 if (fname[i] == '/')
1072 else if (fname[i] == '.')
1074 strcpy (ext, fname+i+1);
1077 /* determine file type - depending on extension */
1078 if (!rGroup->recordType)
1080 sprintf (ext_res, "%srecordType.%s", gprefix, ext);
1081 if (!(rGroup->recordType = res_get (common_resource, ext_res)))
1083 sprintf (ext_res, "%srecordType", gprefix);
1084 if (!(rGroup->recordType = res_get (common_resource, ext_res)))
1086 if (rGroup->fileVerboseFlag)
1087 logf (LOG_LOG, "? %s", fname);
1092 if (!rGroup->recordType)
1094 if (rGroup->fileVerboseFlag)
1095 logf (LOG_LOG, "? record %s", fname);
1098 if (!(recType = recType_byName (rGroup->recordType, subType)))
1100 logf (LOG_WARN, "No such record type: %s", rGroup->recordType);
1104 /* determine match criteria */
1105 if (!rGroup->recordId)
1107 sprintf (ext_res, "%srecordId.%s", gprefix, ext);
1108 rGroup->recordId = res_get (common_resource, ext_res);
1111 /* determine database name */
1112 if (!rGroup->databaseName)
1114 sprintf (ext_res, "%sdatabase.%s", gprefix, ext);
1115 if (!(rGroup->databaseName = res_get (common_resource, ext_res)))
1117 sprintf (ext_res, "%sdatabase", gprefix);
1118 rGroup->databaseName = res_get (common_resource, ext_res);
1121 if (!rGroup->databaseName)
1122 rGroup->databaseName = "Default";
1124 if (rGroup->flagStoreData == -1)
1127 sprintf (ext_res, "%sstoreData.%s", gprefix, ext);
1128 if (!(sval = res_get (common_resource, ext_res)))
1130 sprintf (ext_res, "%sstoreData", gprefix);
1131 sval = res_get (common_resource, ext_res);
1134 rGroup->flagStoreData = atoi (sval);
1136 if (rGroup->flagStoreData == -1)
1137 rGroup->flagStoreData = 0;
1139 if (rGroup->flagStoreKeys == -1)
1143 sprintf (ext_res, "%sstoreKeys.%s", gprefix, ext);
1144 if (!(sval = res_get (common_resource, ext_res)))
1146 sprintf (ext_res, "%sstoreKeys", gprefix);
1147 sval = res_get (common_resource, ext_res);
1150 rGroup->flagStoreKeys = atoi (sval);
1152 if (rGroup->flagStoreKeys == -1)
1153 rGroup->flagStoreKeys = 0;
1155 if (sysno && deleteFlag)
1159 if ((fd = open (fname, O_RDONLY)) == -1)
1161 logf (LOG_WARN|LOG_ERRNO, "open %s", fname);
1165 fi = file_read_start (fd);
1169 r = recordExtract (sysno, fname, rGroup, deleteFlag, fi,
1171 } while (r && !sysno && fi->file_more);
1172 log_event_start (NULL, NULL);
1173 file_read_stop (fi);