2 * Copyright (C) 1994-1996, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.61 1996-06-06 12:08:37 quinn
8 * Added showRecord function
10 * Revision 1.60 1996/06/04 10:18:12 adam
11 * Search/scan uses character mapping module.
13 * Revision 1.59 1996/05/14 15:47:07 adam
14 * Cleanup of various buffer size entities.
16 * Revision 1.58 1996/05/14 06:16:38 adam
17 * Compact use/set bytes used in search service.
19 * Revision 1.57 1996/05/13 14:23:04 adam
20 * Work on compaction of set/use bytes in dictionary.
22 * Revision 1.56 1996/05/09 09:54:42 adam
23 * Server supports maps from one logical attributes to a list of physical
25 * The extraction process doesn't make space consuming 'any' keys.
27 * Revision 1.55 1996/05/09 07:28:55 quinn
28 * Work towards phrases and multiple registers
30 * Revision 1.54 1996/05/01 13:46:35 adam
31 * First work on multiple records in one file.
32 * New option, -offset, to the "unread" command in the filter module.
34 * Revision 1.53 1996/04/26 12:09:43 adam
35 * Added a few comments.
37 * Revision 1.52 1996/04/25 13:27:57 adam
38 * Function recordExtract modified so that files with no keys (possibly empty)
41 * Revision 1.51 1996/03/19 11:08:42 adam
42 * Bug fix: Log preamble wasn't always turned off after recordExtract.
44 * Revision 1.50 1996/02/12 18:45:36 adam
45 * New fileVerboseFlag in record group control.
47 * Revision 1.49 1996/02/05 12:29:57 adam
48 * Logging reduced a bit.
49 * The remaining running time is estimated during register merge.
51 * Revision 1.48 1996/02/01 20:53:26 adam
52 * The temporary per-record keys are compacted a little, and duplication
53 * of the per-records keys are avoided when they are saved in the record
56 * Revision 1.47 1996/01/17 14:57:48 adam
57 * Prototype changed for reader functions in extract/retrieve. File
58 * is identified by 'void *' instead of 'int.
60 * Revision 1.46 1995/12/15 14:57:16 adam
63 * Revision 1.45 1995/12/15 12:37:41 adam
64 * In addRecordKeyAny: Writes key only when attrSet != -1.
66 * Revision 1.44 1995/12/12 16:00:54 adam
67 * System call sync(2) used after update/commit.
68 * Locking (based on fcntl) uses F_EXLCK and F_SHLCK instead of F_WRLCK
71 * Revision 1.43 1995/12/11 09:12:46 adam
72 * The rec_get function returns NULL if record doesn't exist - will
73 * happen in the server if the result set records have been deleted since
74 * the creation of the set (i.e. the search).
75 * The server saves a result temporarily if it is 'volatile', i.e. the
76 * set is register dependent.
78 * Revision 1.42 1995/12/07 17:38:46 adam
79 * Work locking mechanisms for concurrent updates/commit.
81 * Revision 1.41 1995/12/06 16:06:42 adam
82 * Better diagnostics. Work on 'real' dictionary deletion.
84 * Revision 1.40 1995/12/05 16:57:40 adam
85 * More work on regular patterns.
87 * Revision 1.39 1995/12/05 13:20:18 adam
88 * Bug fix: file_read sometimes returned early EOF.
90 * Revision 1.38 1995/12/04 17:59:21 adam
91 * More work on regular expression conversion.
93 * Revision 1.37 1995/12/04 14:22:27 adam
94 * Extra arg to recType_byName.
95 * Started work on new regular expression parsed input to
98 * Revision 1.36 1995/11/30 08:34:29 adam
99 * Started work on commit facility.
100 * Changed a few malloc/free to xmalloc/xfree.
102 * Revision 1.35 1995/11/28 14:26:21 adam
103 * Bug fix: recordId with constant wasn't right.
104 * Bug fix: recordId dictionary entry wasn't deleted when needed.
106 * Revision 1.34 1995/11/28 09:09:38 adam
107 * Zebra config renamed.
108 * Use setting 'recordId' to identify record now.
109 * Bug fix in recindex.c: rec_release_blocks was invokeded even
110 * though the blocks were already released.
111 * File traversal properly deletes records when needed.
113 * Revision 1.33 1995/11/27 09:56:20 adam
114 * Record info elements better enumerated. Internal store of records.
116 * Revision 1.32 1995/11/25 10:24:05 adam
117 * More record fields - they are enumerated now.
118 * New options: flagStoreData flagStoreKey.
120 * Revision 1.31 1995/11/24 11:31:35 adam
121 * Commands add & del read filenames from stdin if source directory is
123 * Match criteria supports 'constant' strings.
125 * Revision 1.30 1995/11/22 17:19:16 adam
126 * Record management uses the bfile system.
128 * Revision 1.29 1995/11/21 15:01:14 adam
129 * New general match criteria implemented.
130 * New feature: document groups.
132 * Revision 1.28 1995/11/21 09:20:30 adam
133 * Yet more work on record match.
135 * Revision 1.27 1995/11/20 16:59:45 adam
136 * New update method: the 'old' keys are saved for each records.
138 * Revision 1.26 1995/11/20 11:56:24 adam
139 * Work on new traversal.
141 * Revision 1.25 1995/11/16 15:34:54 adam
142 * Uses new record management system in both indexer and server.
144 * Revision 1.24 1995/11/15 19:13:08 adam
145 * Work on record management.
147 * Revision 1.23 1995/10/27 14:00:10 adam
148 * Implemented detection of database availability.
150 * Revision 1.22 1995/10/17 18:02:07 adam
151 * New feature: databases. Implemented as prefix to words in dictionary.
153 * Revision 1.21 1995/10/10 12:24:38 adam
154 * Temporary sort files are compressed.
156 * Revision 1.20 1995/10/06 13:52:05 adam
157 * Bug fixes. Handler may abort further scanning.
159 * Revision 1.19 1995/10/04 12:55:16 adam
160 * Bug fix in ranked search. Use=Any keys inserted.
162 * Revision 1.18 1995/10/04 09:37:08 quinn
165 * Revision 1.17 1995/10/03 14:28:57 adam
166 * Buffered read in extract works.
168 * Revision 1.16 1995/10/03 14:28:45 adam
169 * Work on more effecient read handler in extract.
171 * Revision 1.15 1995/10/02 15:42:53 adam
172 * Extract uses file descriptors instead of FILE pointers.
174 * Revision 1.14 1995/10/02 15:29:13 adam
175 * More logging in file_extract.
177 * Revision 1.13 1995/09/29 14:01:39 adam
180 * Revision 1.12 1995/09/28 14:22:56 adam
181 * Sort uses smaller temporary files.
183 * Revision 1.11 1995/09/28 12:10:31 adam
184 * Bug fixes. Field prefix used in queries.
186 * Revision 1.10 1995/09/28 09:19:41 adam
187 * xfree/xmalloc used everywhere.
188 * Extract/retrieve method seems to work for text records.
190 * Revision 1.9 1995/09/27 12:22:28 adam
191 * More work on extract in record control.
192 * Field name is not in isam keys but in prefix in dictionary words.
194 * Revision 1.8 1995/09/14 07:48:22 adam
195 * Record control management.
197 * Revision 1.7 1995/09/11 13:09:32 adam
198 * More work on relevance feedback.
200 * Revision 1.6 1995/09/08 14:52:27 adam
201 * Minor changes. Dictionary is lower case now.
203 * Revision 1.5 1995/09/06 16:11:16 adam
204 * Option: only one word key per file.
206 * Revision 1.4 1995/09/05 15:28:39 adam
207 * More work on search engine.
209 * Revision 1.3 1995/09/04 12:33:41 adam
210 * Various cleanup. YAZ util used instead.
212 * Revision 1.2 1995/09/04 09:10:34 adam
213 * More work on index add/del/update.
214 * Merge sort implemented.
215 * Initial work on z39 server.
217 * Revision 1.1 1995/09/01 14:06:35 adam
218 * Split of work into more files.
226 #include <alexutil.h>
232 static Dict matchDict;
234 static Records records = NULL;
236 static char **key_buf;
237 static size_t ptr_top;
239 static size_t key_buf_used;
240 static int key_file_no;
242 static int records_inserted = 0;
243 static int records_updated = 0;
244 static int records_deleted = 0;
245 static int records_processed = 0;
247 static ZebTargetInfo *zti = NULL;
249 static void logRecord (int showFlag)
253 if (showFlag || !(records_processed % 1000))
255 logf (LOG_LOG, "Records: %7d i/u/d %d/%d/%d",
256 records_processed, records_inserted, records_updated,
261 void key_open (int mem)
265 key_buf = xmalloc (mem);
266 ptr_top = mem/sizeof(char*);
272 if (!(matchDict = dict_open (GMATCH_DICT, 50, 1)))
274 logf (LOG_FATAL, "dict_open fail of %s", GMATCH_DICT);
278 records = rec_open (1);
280 zti = zebTargetInfo_open (records, 1);
290 void encode_key_init (struct encode_info *i)
296 char *encode_key_int (int d, char *bp)
305 else if (d <= 4194303)
307 *bp++ = 128 + (d>>16);
308 *bp++ = (d>>8) & 255;
313 *bp++ = 192 + (d>>24);
314 *bp++ = (d>>16) & 255;
315 *bp++ = (d>>8) & 255;
321 void encode_key_write (char *k, struct encode_info *i, FILE *outf)
326 while ((*bp++ = *k++))
328 memcpy (&key, k+1, sizeof(struct it_key));
329 bp = encode_key_int ( (key.sysno - i->sysno) * 2 + *k, bp);
330 if (i->sysno != key.sysno)
332 i->sysno = key.sysno;
335 bp = encode_key_int (key.seqno - i->seqno, bp);
336 i->seqno = key.seqno;
337 if (fwrite (i->buf, bp - i->buf, 1, outf) != 1)
339 logf (LOG_FATAL|LOG_ERRNO, "fwrite");
344 void key_flush (void)
349 struct encode_info encode_info;
355 logf (LOG_LOG, "sorting section %d", key_file_no);
356 qsort (key_buf + ptr_top-ptr_i, ptr_i, sizeof(char*), key_qsort_compare);
357 sprintf (out_fname, TEMP_FNAME, key_file_no);
359 if (!(outf = fopen (out_fname, "w")))
361 logf (LOG_FATAL|LOG_ERRNO, "fopen (4) %s", out_fname);
364 logf (LOG_LOG, "writing section %d", key_file_no);
365 prevcp = cp = key_buf[ptr_top-ptr_i];
367 encode_key_init (&encode_info);
368 encode_key_write (cp, &encode_info, outf);
371 cp = key_buf[ptr_top-ptr_i];
372 if (strcmp (cp, prevcp))
374 encode_key_init (&encode_info);
375 encode_key_write (cp, &encode_info, outf);
379 encode_key_write (cp + strlen(cp), &encode_info, outf);
383 logf (LOG_FATAL|LOG_ERRNO, "fclose %s", out_fname);
386 logf (LOG_LOG, "finished section %d", key_file_no);
396 zebTargetInfo_close (zti, 1);
398 rec_close (&records);
399 dict_close (matchDict);
405 static void wordInit (RecWord *p)
409 p->which = Word_String;
420 static void addRecordKey (const RecWord *p)
428 if (reckeys.buf_used+1024 > reckeys.buf_max)
432 b = xmalloc (reckeys.buf_max += 128000);
433 if (reckeys.buf_used > 0)
434 memcpy (b, reckeys.buf, reckeys.buf_used);
438 dst = reckeys.buf + reckeys.buf_used;
440 attrSet = p->attrSet;
441 if (reckeys.buf_used > 0 && reckeys.prevAttrSet == attrSet)
444 reckeys.prevAttrSet = attrSet;
445 attrUse = p->attrUse;
446 if (reckeys.buf_used > 0 && reckeys.prevAttrUse == attrUse)
449 reckeys.prevAttrUse = attrUse;
455 memcpy (dst, &attrSet, sizeof(attrSet));
456 dst += sizeof(attrSet);
460 memcpy (dst, &attrUse, sizeof(attrUse));
461 dst += sizeof(attrUse);
474 for (i = 0; p->u.string[i]; i++)
475 *dst++ = p->u.string[i];
478 memcpy (dst, &p->seqno, sizeof(p->seqno));
479 dst += sizeof(p->seqno);
480 reckeys.buf_used = dst - reckeys.buf;
483 static void flushRecordKeys (SYSNO sysno, int cmd, struct recKeys *reckeys,
484 const char *databaseName)
490 if (zebTargetInfo_curDatabase (zti, databaseName))
492 if (zebTargetInfo_newDatabase (zti, databaseName))
495 while (off < reckeys->buf_used)
497 const char *src = reckeys->buf + off;
505 memcpy (&attrSet, src, sizeof(attrSet));
506 src += sizeof(attrSet);
510 memcpy (&attrUse, src, sizeof(attrUse));
511 src += sizeof(attrUse);
513 if (key_buf_used + 1024 > (ptr_top-ptr_i)*sizeof(char*))
516 key_buf[ptr_top-ptr_i] = (char*)key_buf + key_buf_used;
518 lead = zebTargetInfo_lookupSU (zti, attrSet, attrUse);
520 lead = zebTargetInfo_addSU (zti, attrSet, attrUse);
522 ((char*) key_buf) [key_buf_used++] = lead;
524 ((char*)key_buf) [key_buf_used++] = *src++;
526 ((char*)key_buf) [key_buf_used++] = '\0';
528 ((char*) key_buf)[key_buf_used++] = cmd;
530 memcpy (&key.seqno, src, sizeof(key.seqno));
531 src += sizeof(key.seqno);
533 memcpy ((char*)key_buf + key_buf_used, &key, sizeof(key));
534 key_buf_used += sizeof(key);
535 off = src - reckeys->buf;
537 assert (off == reckeys->buf_used);
540 static const char **searchRecordKey (struct recKeys *reckeys,
541 int attrSetS, int attrUseS)
543 static const char *ws[32];
548 for (i = 0; i<32; i++)
551 while (off < reckeys->buf_used)
553 const char *src = reckeys->buf + off;
559 memcpy (&attrSet, src, sizeof(attrSet));
560 src += sizeof(attrSet);
562 memcpy (&attrUse, src, sizeof(attrUse));
563 src += sizeof(attrUse);
569 memcpy (&seqno, src, sizeof(seqno));
570 src += sizeof(seqno);
573 logf (LOG_LOG, "(%d,%d) %d %s", attrSet, attrUse, seqno, wstart);
575 if (attrUseS == attrUse && attrSetS == attrSet)
582 woff = seqno - startSeq;
583 if (woff >= 0 && woff < 31)
587 off = src - reckeys->buf;
589 assert (off == reckeys->buf_used);
593 struct file_read_info {
601 static struct file_read_info *file_read_start (int fd)
603 struct file_read_info *fi = xmalloc (sizeof(*fi));
607 fi->file_moffset = 0;
611 static void file_read_stop (struct file_read_info *fi)
617 static off_t file_seek (void *handle, off_t offset)
619 struct file_read_info *p = handle;
620 p->file_offset = offset;
621 return lseek (p->fd, offset, SEEK_SET);
624 static int file_read (void *handle, char *buf, size_t count)
626 struct file_read_info *p = handle;
629 r = read (fd, buf, count);
633 if (p->file_offset > p->file_max)
634 p->file_max = p->file_offset;
639 static void file_begin (void *handle)
641 struct file_read_info *p = handle;
643 p->file_offset = p->file_moffset;
645 lseek (p->fd, p->file_moffset, SEEK_SET);
649 static void file_end (void *handle, off_t offset)
651 struct file_read_info *p = handle;
653 assert (p->file_more == 0);
655 p->file_moffset = offset;
658 static int atois (const char **s)
661 while ( (c=**s) >= '0' && c <= '9')
663 val = val*10 + c - '0';
669 static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup,
673 static char dstBuf[2048];
675 const char *s = spec;
676 static const char **w;
681 while (*s == ' ' || *s == '\t')
688 int attrSet, attrUse;
692 attrSet = atois (&s);
695 logf (LOG_WARN, "Missing , in match criteria %s in group %s",
696 spec, rGroup->groupName ? rGroup->groupName : "none");
700 attrUse = atois (&s);
701 w = searchRecordKey (reckeys, attrSet, attrUse);
706 for (i = 0; i<32; i++)
711 logf (LOG_WARN, "Missing ) in match criteria %s in group %s",
712 spec, rGroup->groupName ? rGroup->groupName : "none");
717 for (i = 0; i<32; i++)
718 if (matchFlag[i] && w[i])
730 logf (LOG_WARN, "Record didn't contain match"
731 " fields in (%d,%d)", attrSet, attrUse);
739 const char *spec_src = NULL;
740 const char *s1 = ++s;
741 while (*s1 && *s1 != ' ' && *s1 != '\t')
747 memcpy (special, s, spec_len);
748 special[spec_len] = '\0';
751 if (!strcmp (special, "group"))
752 spec_src = rGroup->groupName;
753 else if (!strcmp (special, "database"))
754 spec_src = rGroup->databaseName;
755 else if (!strcmp (special, "filename"))
757 else if (!strcmp (special, "type"))
758 spec_src = rGroup->recordType;
763 strcpy (dst, spec_src);
764 dst += strlen (spec_src);
767 else if (*s == '\"' || *s == '\'')
769 int stopMarker = *s++;
773 while (*s && *s != stopMarker)
776 tmpString[i++] = *s++;
781 strcpy (dst, tmpString);
782 dst += strlen (tmpString);
786 logf (LOG_WARN, "Syntax error in match criteria %s in group %s",
787 spec, rGroup->groupName ? rGroup->groupName : "none");
794 logf (LOG_WARN, "No match criteria for record %s in group %s",
795 fname, rGroup->groupName ? rGroup->groupName : "none");
801 struct recordLogInfo {
804 struct recordGroup *rGroup;
807 static void recordLogPreamble (int level, const char *msg, void *info)
809 struct recordLogInfo *p = info;
810 FILE *outf = log_file ();
815 fprintf (outf, "%s of ", p->op);
816 fprintf (outf, "%s type %s\n", p->rGroup->recordType, p->fname);
817 log_event_start (NULL, NULL);
820 static int recordExtract (SYSNO *sysno, const char *fname,
821 struct recordGroup *rGroup, int deleteFlag,
822 struct file_read_info *fi, RecType recType,
825 struct recExtractCtrl extractCtrl;
829 off_t recordOffset = 0;
831 struct recordLogInfo logInfo;
833 logInfo.fname = fname;
835 logInfo.rGroup = rGroup;
836 log_event_start (recordLogPreamble, &logInfo);
840 /* we are going to read from a file, so prepare the extraction */
842 extractCtrl.subType = subType;
843 extractCtrl.init = wordInit;
844 extractCtrl.add = addRecordKey;
846 reckeys.buf_used = 0;
847 reckeys.prevAttrUse = -1;
848 reckeys.prevAttrSet = -1;
850 recordOffset = fi->file_moffset;
851 extractCtrl.offset = recordOffset;
852 extractCtrl.readf = file_read;
853 extractCtrl.seekf = file_seek;
854 extractCtrl.endf = file_end;
855 extractCtrl.group = rGroup;
856 r = (*recType->extract)(&extractCtrl);
860 /* error occured during extraction ... */
861 logf (LOG_WARN, "Couldn't extract file %s, code %d", fname, r);
864 if (reckeys.buf_used == 0)
866 /* the extraction process returned no information - the record
868 logf (LOG_WARN, "Empty file %s", fname);
873 /* perform match if sysno not known and if match criteria is specified */
880 if (rGroup->recordId && *rGroup->recordId)
884 matchStr = fileMatchStr (&reckeys, rGroup, fname,
888 rinfo = dict_lookup (matchDict, matchStr);
890 memcpy (sysno, rinfo+1, sizeof(*sysno));
894 logf (LOG_WARN, "Bad match criteria");
905 logf (LOG_LOG, "Cannot delete new record");
909 if (rGroup->fileVerboseFlag)
910 logf (LOG_LOG, "add %s %s+%ld", rGroup->recordType,
911 fname, (long) recordOffset);
912 rec = rec_new (records);
917 dict_insert (matchDict, matchStr, sizeof(*sysno), sysno);
919 flushRecordKeys (*sysno, 1, &reckeys, rGroup->databaseName);
925 /* record already exists */
926 struct recKeys delkeys;
928 rec = rec_get (records, *sysno);
930 delkeys.buf_used = rec->size[recInfo_delKeys];
931 delkeys.buf = rec->info[recInfo_delKeys];
932 flushRecordKeys (*sysno, 0, &delkeys, rec->info[recInfo_databaseName]);
935 /* record going to be deleted */
936 logInfo.op = "delete";
937 if (!delkeys.buf_used)
939 logf (LOG_WARN, "cannot delete; storeKeys false");
943 if (rGroup->fileVerboseFlag)
944 logf (LOG_LOG, "delete %s %s %ld", rGroup->recordType,
945 fname, (long) recordOffset);
948 dict_delete (matchDict, matchStr);
949 rec_del (records, &rec);
956 /* record going to be updated */
957 logInfo.op = "update";
958 if (!delkeys.buf_used)
960 logf (LOG_WARN, "cannot update; storeKeys false");
964 if (rGroup->fileVerboseFlag)
965 logf (LOG_LOG, "update %s %s %ld", rGroup->recordType,
966 fname, (long) recordOffset);
967 flushRecordKeys (*sysno, 1, &reckeys, rGroup->databaseName);
972 /* update file type */
973 xfree (rec->info[recInfo_fileType]);
974 rec->info[recInfo_fileType] =
975 rec_strdup (rGroup->recordType, &rec->size[recInfo_fileType]);
977 /* update filename */
978 xfree (rec->info[recInfo_filename]);
979 rec->info[recInfo_filename] =
980 rec_strdup (fname, &rec->size[recInfo_filename]);
982 /* update delete keys */
983 xfree (rec->info[recInfo_delKeys]);
984 if (reckeys.buf_used > 0 && rGroup->flagStoreKeys == 1)
987 rec->size[recInfo_delKeys] = reckeys.buf_used;
988 rec->info[recInfo_delKeys] = reckeys.buf;
992 rec->info[recInfo_delKeys] = xmalloc (reckeys.buf_used);
993 rec->size[recInfo_delKeys] = reckeys.buf_used;
994 memcpy (rec->info[recInfo_delKeys], reckeys.buf,
995 rec->size[recInfo_delKeys]);
1000 rec->info[recInfo_delKeys] = NULL;
1001 rec->size[recInfo_delKeys] = 0;
1004 /* update store data */
1005 xfree (rec->info[recInfo_storeData]);
1006 if (rGroup->flagStoreData == 1)
1008 rec->size[recInfo_storeData] = fi->file_max;
1009 rec->info[recInfo_storeData] = xmalloc (fi->file_max);
1010 if (lseek (fi->fd, recordOffset, SEEK_SET) < 0)
1012 logf (LOG_ERRNO|LOG_FATAL, "seek to %ld in %s", fname,
1013 (long) recordOffset);
1016 if (read (fi->fd, rec->info[recInfo_storeData], fi->file_max)
1019 logf (LOG_ERRNO|LOG_FATAL, "read %d bytes of %s",
1020 fi->file_max, fname);
1026 rec->info[recInfo_storeData] = NULL;
1027 rec->size[recInfo_storeData] = 0;
1029 /* update database name */
1030 xfree (rec->info[recInfo_databaseName]);
1031 rec->info[recInfo_databaseName] =
1032 rec_strdup (rGroup->databaseName, &rec->size[recInfo_databaseName]);
1035 xfree (rec->info[recInfo_offset]);
1037 rec->size[recInfo_offset] = sizeof(recordOffset);
1038 rec->info[recInfo_offset] = xmalloc (sizeof(recordOffset));
1039 memcpy (rec->info[recInfo_offset], &recordOffset, sizeof(recordOffset));
1041 /* commit this record */
1042 rec_put (records, &rec);
1047 int fileExtract (SYSNO *sysno, const char *fname,
1048 const struct recordGroup *rGroupP, int deleteFlag)
1056 struct recordGroup rGroupM;
1057 struct recordGroup *rGroup = &rGroupM;
1058 struct file_read_info *fi;
1060 memcpy (rGroup, rGroupP, sizeof(*rGroupP));
1062 if (!rGroup->groupName || !*rGroup->groupName)
1065 sprintf (gprefix, "%s.", rGroup->groupName);
1067 logf (LOG_DEBUG, "fileExtract %s", fname);
1069 /* determine file extension */
1070 for (i = strlen(fname); --i >= 0; )
1071 if (fname[i] == '/')
1076 else if (fname[i] == '.')
1078 strcpy (ext, fname+i+1);
1081 /* determine file type - depending on extension */
1082 if (!rGroup->recordType)
1084 sprintf (ext_res, "%srecordType.%s", gprefix, ext);
1085 if (!(rGroup->recordType = res_get (common_resource, ext_res)))
1087 sprintf (ext_res, "%srecordType", gprefix);
1088 if (!(rGroup->recordType = res_get (common_resource, ext_res)))
1090 if (rGroup->fileVerboseFlag)
1091 logf (LOG_LOG, "? %s", fname);
1096 if (!rGroup->recordType)
1098 if (rGroup->fileVerboseFlag)
1099 logf (LOG_LOG, "? record %s", fname);
1102 if (!(recType = recType_byName (rGroup->recordType, subType)))
1104 logf (LOG_WARN, "No such record type: %s", rGroup->recordType);
1108 /* determine match criteria */
1109 if (!rGroup->recordId)
1111 sprintf (ext_res, "%srecordId.%s", gprefix, ext);
1112 rGroup->recordId = res_get (common_resource, ext_res);
1115 /* determine database name */
1116 if (!rGroup->databaseName)
1118 sprintf (ext_res, "%sdatabase.%s", gprefix, ext);
1119 if (!(rGroup->databaseName = res_get (common_resource, ext_res)))
1121 sprintf (ext_res, "%sdatabase", gprefix);
1122 rGroup->databaseName = res_get (common_resource, ext_res);
1125 if (!rGroup->databaseName)
1126 rGroup->databaseName = "Default";
1128 if (rGroup->flagStoreData == -1)
1131 sprintf (ext_res, "%sstoreData.%s", gprefix, ext);
1132 if (!(sval = res_get (common_resource, ext_res)))
1134 sprintf (ext_res, "%sstoreData", gprefix);
1135 sval = res_get (common_resource, ext_res);
1138 rGroup->flagStoreData = atoi (sval);
1140 if (rGroup->flagStoreData == -1)
1141 rGroup->flagStoreData = 0;
1143 if (rGroup->flagStoreKeys == -1)
1147 sprintf (ext_res, "%sstoreKeys.%s", gprefix, ext);
1148 if (!(sval = res_get (common_resource, ext_res)))
1150 sprintf (ext_res, "%sstoreKeys", gprefix);
1151 sval = res_get (common_resource, ext_res);
1154 rGroup->flagStoreKeys = atoi (sval);
1156 if (rGroup->flagStoreKeys == -1)
1157 rGroup->flagStoreKeys = 0;
1159 if (sysno && deleteFlag)
1163 if ((fd = open (fname, O_RDONLY)) == -1)
1165 logf (LOG_WARN|LOG_ERRNO, "open %s", fname);
1169 fi = file_read_start (fd);
1173 r = recordExtract (sysno, fname, rGroup, deleteFlag, fi,
1175 } while (r && !sysno && fi->file_more);
1176 log_event_start (NULL, NULL);
1177 file_read_stop (fi);