2 * Copyright (C) 1994-1996, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.59 1996-05-14 15:47:07 adam
8 * Cleanup of various buffer size entities.
10 * Revision 1.58 1996/05/14 06:16:38 adam
11 * Compact use/set bytes used in search service.
13 * Revision 1.57 1996/05/13 14:23:04 adam
14 * Work on compaction of set/use bytes in dictionary.
16 * Revision 1.56 1996/05/09 09:54:42 adam
17 * Server supports maps from one logical attributes to a list of physical
19 * The extraction process doesn't make space consuming 'any' keys.
21 * Revision 1.55 1996/05/09 07:28:55 quinn
22 * Work towards phrases and multiple registers
24 * Revision 1.54 1996/05/01 13:46:35 adam
25 * First work on multiple records in one file.
26 * New option, -offset, to the "unread" command in the filter module.
28 * Revision 1.53 1996/04/26 12:09:43 adam
29 * Added a few comments.
31 * Revision 1.52 1996/04/25 13:27:57 adam
32 * Function recordExtract modified so that files with no keys (possibly empty)
35 * Revision 1.51 1996/03/19 11:08:42 adam
36 * Bug fix: Log preamble wasn't always turned off after recordExtract.
38 * Revision 1.50 1996/02/12 18:45:36 adam
39 * New fileVerboseFlag in record group control.
41 * Revision 1.49 1996/02/05 12:29:57 adam
42 * Logging reduced a bit.
43 * The remaining running time is estimated during register merge.
45 * Revision 1.48 1996/02/01 20:53:26 adam
46 * The temporary per-record keys are compacted a little, and duplication
47 * of the per-records keys are avoided when they are saved in the record
50 * Revision 1.47 1996/01/17 14:57:48 adam
51 * Prototype changed for reader functions in extract/retrieve. File
52 * is identified by 'void *' instead of 'int.
54 * Revision 1.46 1995/12/15 14:57:16 adam
57 * Revision 1.45 1995/12/15 12:37:41 adam
58 * In addRecordKeyAny: Writes key only when attrSet != -1.
60 * Revision 1.44 1995/12/12 16:00:54 adam
61 * System call sync(2) used after update/commit.
62 * Locking (based on fcntl) uses F_EXLCK and F_SHLCK instead of F_WRLCK
65 * Revision 1.43 1995/12/11 09:12:46 adam
66 * The rec_get function returns NULL if record doesn't exist - will
67 * happen in the server if the result set records have been deleted since
68 * the creation of the set (i.e. the search).
69 * The server saves a result temporarily if it is 'volatile', i.e. the
70 * set is register dependent.
72 * Revision 1.42 1995/12/07 17:38:46 adam
73 * Work locking mechanisms for concurrent updates/commit.
75 * Revision 1.41 1995/12/06 16:06:42 adam
76 * Better diagnostics. Work on 'real' dictionary deletion.
78 * Revision 1.40 1995/12/05 16:57:40 adam
79 * More work on regular patterns.
81 * Revision 1.39 1995/12/05 13:20:18 adam
82 * Bug fix: file_read sometimes returned early EOF.
84 * Revision 1.38 1995/12/04 17:59:21 adam
85 * More work on regular expression conversion.
87 * Revision 1.37 1995/12/04 14:22:27 adam
88 * Extra arg to recType_byName.
89 * Started work on new regular expression parsed input to
92 * Revision 1.36 1995/11/30 08:34:29 adam
93 * Started work on commit facility.
94 * Changed a few malloc/free to xmalloc/xfree.
96 * Revision 1.35 1995/11/28 14:26:21 adam
97 * Bug fix: recordId with constant wasn't right.
98 * Bug fix: recordId dictionary entry wasn't deleted when needed.
100 * Revision 1.34 1995/11/28 09:09:38 adam
101 * Zebra config renamed.
102 * Use setting 'recordId' to identify record now.
103 * Bug fix in recindex.c: rec_release_blocks was invokeded even
104 * though the blocks were already released.
105 * File traversal properly deletes records when needed.
107 * Revision 1.33 1995/11/27 09:56:20 adam
108 * Record info elements better enumerated. Internal store of records.
110 * Revision 1.32 1995/11/25 10:24:05 adam
111 * More record fields - they are enumerated now.
112 * New options: flagStoreData flagStoreKey.
114 * Revision 1.31 1995/11/24 11:31:35 adam
115 * Commands add & del read filenames from stdin if source directory is
117 * Match criteria supports 'constant' strings.
119 * Revision 1.30 1995/11/22 17:19:16 adam
120 * Record management uses the bfile system.
122 * Revision 1.29 1995/11/21 15:01:14 adam
123 * New general match criteria implemented.
124 * New feature: document groups.
126 * Revision 1.28 1995/11/21 09:20:30 adam
127 * Yet more work on record match.
129 * Revision 1.27 1995/11/20 16:59:45 adam
130 * New update method: the 'old' keys are saved for each records.
132 * Revision 1.26 1995/11/20 11:56:24 adam
133 * Work on new traversal.
135 * Revision 1.25 1995/11/16 15:34:54 adam
136 * Uses new record management system in both indexer and server.
138 * Revision 1.24 1995/11/15 19:13:08 adam
139 * Work on record management.
141 * Revision 1.23 1995/10/27 14:00:10 adam
142 * Implemented detection of database availability.
144 * Revision 1.22 1995/10/17 18:02:07 adam
145 * New feature: databases. Implemented as prefix to words in dictionary.
147 * Revision 1.21 1995/10/10 12:24:38 adam
148 * Temporary sort files are compressed.
150 * Revision 1.20 1995/10/06 13:52:05 adam
151 * Bug fixes. Handler may abort further scanning.
153 * Revision 1.19 1995/10/04 12:55:16 adam
154 * Bug fix in ranked search. Use=Any keys inserted.
156 * Revision 1.18 1995/10/04 09:37:08 quinn
159 * Revision 1.17 1995/10/03 14:28:57 adam
160 * Buffered read in extract works.
162 * Revision 1.16 1995/10/03 14:28:45 adam
163 * Work on more effecient read handler in extract.
165 * Revision 1.15 1995/10/02 15:42:53 adam
166 * Extract uses file descriptors instead of FILE pointers.
168 * Revision 1.14 1995/10/02 15:29:13 adam
169 * More logging in file_extract.
171 * Revision 1.13 1995/09/29 14:01:39 adam
174 * Revision 1.12 1995/09/28 14:22:56 adam
175 * Sort uses smaller temporary files.
177 * Revision 1.11 1995/09/28 12:10:31 adam
178 * Bug fixes. Field prefix used in queries.
180 * Revision 1.10 1995/09/28 09:19:41 adam
181 * xfree/xmalloc used everywhere.
182 * Extract/retrieve method seems to work for text records.
184 * Revision 1.9 1995/09/27 12:22:28 adam
185 * More work on extract in record control.
186 * Field name is not in isam keys but in prefix in dictionary words.
188 * Revision 1.8 1995/09/14 07:48:22 adam
189 * Record control management.
191 * Revision 1.7 1995/09/11 13:09:32 adam
192 * More work on relevance feedback.
194 * Revision 1.6 1995/09/08 14:52:27 adam
195 * Minor changes. Dictionary is lower case now.
197 * Revision 1.5 1995/09/06 16:11:16 adam
198 * Option: only one word key per file.
200 * Revision 1.4 1995/09/05 15:28:39 adam
201 * More work on search engine.
203 * Revision 1.3 1995/09/04 12:33:41 adam
204 * Various cleanup. YAZ util used instead.
206 * Revision 1.2 1995/09/04 09:10:34 adam
207 * More work on index add/del/update.
208 * Merge sort implemented.
209 * Initial work on z39 server.
211 * Revision 1.1 1995/09/01 14:06:35 adam
212 * Split of work into more files.
221 #include <alexutil.h>
227 static Dict matchDict;
229 static Records records = NULL;
231 static char **key_buf;
232 static size_t ptr_top;
234 static size_t key_buf_used;
235 static int key_file_no;
237 static int records_inserted = 0;
238 static int records_updated = 0;
239 static int records_deleted = 0;
240 static int records_processed = 0;
242 static ZebTargetInfo *zti = NULL;
244 static void logRecord (int showFlag)
248 if (showFlag || !(records_processed % 1000))
250 logf (LOG_LOG, "Records: %7d i/u/d %d/%d/%d",
251 records_processed, records_inserted, records_updated,
256 void key_open (int mem)
260 key_buf = xmalloc (mem);
261 ptr_top = mem/sizeof(char*);
267 if (!(matchDict = dict_open (GMATCH_DICT, 50, 1)))
269 logf (LOG_FATAL, "dict_open fail of %s", GMATCH_DICT);
273 records = rec_open (1);
275 zti = zebTargetInfo_open (records, 1);
285 void encode_key_init (struct encode_info *i)
291 char *encode_key_int (int d, char *bp)
300 else if (d <= 4194303)
302 *bp++ = 128 + (d>>16);
303 *bp++ = (d>>8) & 255;
308 *bp++ = 192 + (d>>24);
309 *bp++ = (d>>16) & 255;
310 *bp++ = (d>>8) & 255;
316 void encode_key_write (char *k, struct encode_info *i, FILE *outf)
321 while ((*bp++ = *k++))
323 memcpy (&key, k+1, sizeof(struct it_key));
324 bp = encode_key_int ( (key.sysno - i->sysno) * 2 + *k, bp);
325 if (i->sysno != key.sysno)
327 i->sysno = key.sysno;
330 bp = encode_key_int (key.seqno - i->seqno, bp);
331 i->seqno = key.seqno;
332 if (fwrite (i->buf, bp - i->buf, 1, outf) != 1)
334 logf (LOG_FATAL|LOG_ERRNO, "fwrite");
339 void key_flush (void)
344 struct encode_info encode_info;
350 logf (LOG_LOG, "sorting section %d", key_file_no);
351 qsort (key_buf + ptr_top-ptr_i, ptr_i, sizeof(char*), key_qsort_compare);
352 sprintf (out_fname, TEMP_FNAME, key_file_no);
354 if (!(outf = fopen (out_fname, "w")))
356 logf (LOG_FATAL|LOG_ERRNO, "fopen (4) %s", out_fname);
359 logf (LOG_LOG, "writing section %d", key_file_no);
360 prevcp = cp = key_buf[ptr_top-ptr_i];
362 encode_key_init (&encode_info);
363 encode_key_write (cp, &encode_info, outf);
366 cp = key_buf[ptr_top-ptr_i];
367 if (strcmp (cp, prevcp))
369 encode_key_init (&encode_info);
370 encode_key_write (cp, &encode_info, outf);
374 encode_key_write (cp + strlen(cp), &encode_info, outf);
378 logf (LOG_FATAL|LOG_ERRNO, "fclose %s", out_fname);
381 logf (LOG_LOG, "finished section %d", key_file_no);
391 zebTargetInfo_close (zti, 1);
393 rec_close (&records);
394 dict_close (matchDict);
400 static void wordInit (RecWord *p)
404 p->which = Word_String;
415 static void addRecordKey (const RecWord *p)
423 if (reckeys.buf_used+1024 > reckeys.buf_max)
427 b = xmalloc (reckeys.buf_max += 128000);
428 if (reckeys.buf_used > 0)
429 memcpy (b, reckeys.buf, reckeys.buf_used);
433 dst = reckeys.buf + reckeys.buf_used;
435 attrSet = p->attrSet;
436 if (reckeys.buf_used > 0 && reckeys.prevAttrSet == attrSet)
439 reckeys.prevAttrSet = attrSet;
440 attrUse = p->attrUse;
441 if (reckeys.buf_used > 0 && reckeys.prevAttrUse == attrUse)
444 reckeys.prevAttrUse = attrUse;
450 memcpy (dst, &attrSet, sizeof(attrSet));
451 dst += sizeof(attrSet);
455 memcpy (dst, &attrUse, sizeof(attrUse));
456 dst += sizeof(attrUse);
469 for (i = 0; p->u.string[i]; i++)
470 *dst++ = p->u.string[i];
473 memcpy (dst, &p->seqno, sizeof(p->seqno));
474 dst += sizeof(p->seqno);
475 reckeys.buf_used = dst - reckeys.buf;
478 static void flushRecordKeys (SYSNO sysno, int cmd, struct recKeys *reckeys,
479 const char *databaseName)
486 if (zebTargetInfo_curDatabase (zti, databaseName))
488 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 key_buf_used += index_word_prefix ((char*)key_buf + key_buf_used,
522 attrSet, attrUse, databaseName);
525 ((char*)key_buf) [key_buf_used++] = index_char_cvt (*src++);
527 ((char*)key_buf) [key_buf_used++] = '\0';
529 ((char*) key_buf)[key_buf_used++] = cmd;
531 memcpy (&key.seqno, src, sizeof(key.seqno));
532 src += sizeof(key.seqno);
534 memcpy ((char*)key_buf + key_buf_used, &key, sizeof(key));
535 key_buf_used += sizeof(key);
536 off = src - reckeys->buf;
538 assert (off == reckeys->buf_used);
541 static const char **searchRecordKey (struct recKeys *reckeys,
542 int attrSetS, int attrUseS)
544 static const char *ws[32];
549 for (i = 0; i<32; i++)
552 while (off < reckeys->buf_used)
554 const char *src = reckeys->buf + off;
560 memcpy (&attrSet, src, sizeof(attrSet));
561 src += sizeof(attrSet);
563 memcpy (&attrUse, src, sizeof(attrUse));
564 src += sizeof(attrUse);
570 memcpy (&seqno, src, sizeof(seqno));
571 src += sizeof(seqno);
574 logf (LOG_LOG, "(%d,%d) %d %s", attrSet, attrUse, seqno, wstart);
576 if (attrUseS == attrUse && attrSetS == attrSet)
583 woff = seqno - startSeq;
584 if (woff >= 0 && woff < 31)
588 off = src - reckeys->buf;
590 assert (off == reckeys->buf_used);
594 struct file_read_info {
602 static struct file_read_info *file_read_start (int fd)
604 struct file_read_info *fi = xmalloc (sizeof(*fi));
608 fi->file_moffset = 0;
612 static void file_read_stop (struct file_read_info *fi)
618 static off_t file_seek (void *handle, off_t offset)
620 struct file_read_info *p = handle;
621 p->file_offset = offset;
622 return lseek (p->fd, offset, SEEK_SET);
625 static int file_read (void *handle, char *buf, size_t count)
627 struct file_read_info *p = handle;
630 r = read (fd, buf, count);
634 if (p->file_offset > p->file_max)
635 p->file_max = p->file_offset;
640 static void file_begin (void *handle)
642 struct file_read_info *p = handle;
644 p->file_offset = p->file_moffset;
646 lseek (p->fd, p->file_moffset, SEEK_SET);
650 static void file_end (void *handle, off_t offset)
652 struct file_read_info *p = handle;
654 assert (p->file_more == 0);
656 p->file_moffset = offset;
659 static int atois (const char **s)
662 while ( (c=**s) >= '0' && c <= '9')
664 val = val*10 + c - '0';
670 static char *fileMatchStr (struct recKeys *reckeys, struct recordGroup *rGroup,
674 static char dstBuf[2048];
676 const char *s = spec;
677 static const char **w;
682 while (*s == ' ' || *s == '\t')
689 int attrSet, attrUse;
693 attrSet = atois (&s);
696 logf (LOG_WARN, "Missing , in match criteria %s in group %s",
697 spec, rGroup->groupName ? rGroup->groupName : "none");
701 attrUse = atois (&s);
702 w = searchRecordKey (reckeys, attrSet, attrUse);
707 for (i = 0; i<32; i++)
712 logf (LOG_WARN, "Missing ) in match criteria %s in group %s",
713 spec, rGroup->groupName ? rGroup->groupName : "none");
718 for (i = 0; i<32; i++)
719 if (matchFlag[i] && w[i])
731 logf (LOG_WARN, "Record didn't contain match"
732 " fields in (%d,%d)", attrSet, attrUse);
740 const char *spec_src = NULL;
741 const char *s1 = ++s;
742 while (*s1 && *s1 != ' ' && *s1 != '\t')
748 memcpy (special, s, spec_len);
749 special[spec_len] = '\0';
752 if (!strcmp (special, "group"))
753 spec_src = rGroup->groupName;
754 else if (!strcmp (special, "database"))
755 spec_src = rGroup->databaseName;
756 else if (!strcmp (special, "filename"))
758 else if (!strcmp (special, "type"))
759 spec_src = rGroup->recordType;
764 strcpy (dst, spec_src);
765 dst += strlen (spec_src);
768 else if (*s == '\"' || *s == '\'')
770 int stopMarker = *s++;
774 while (*s && *s != stopMarker)
777 tmpString[i++] = *s++;
782 strcpy (dst, tmpString);
783 dst += strlen (tmpString);
787 logf (LOG_WARN, "Syntax error in match criteria %s in group %s",
788 spec, rGroup->groupName ? rGroup->groupName : "none");
795 logf (LOG_WARN, "No match criteria for record %s in group %s",
796 fname, rGroup->groupName ? rGroup->groupName : "none");
802 struct recordLogInfo {
805 struct recordGroup *rGroup;
808 static void recordLogPreamble (int level, const char *msg, void *info)
810 struct recordLogInfo *p = info;
811 FILE *outf = log_file ();
816 fprintf (outf, "%s of ", p->op);
817 fprintf (outf, "%s type %s\n", p->rGroup->recordType, p->fname);
818 log_event_start (NULL, NULL);
821 static int recordExtract (SYSNO *sysno, const char *fname,
822 struct recordGroup *rGroup, int deleteFlag,
823 struct file_read_info *fi, RecType recType,
826 struct recExtractCtrl extractCtrl;
830 off_t recordOffset = 0;
832 struct recordLogInfo logInfo;
834 logInfo.fname = fname;
836 logInfo.rGroup = rGroup;
837 log_event_start (recordLogPreamble, &logInfo);
841 /* we are going to read from a file, so prepare the extraction */
843 extractCtrl.subType = subType;
844 extractCtrl.init = wordInit;
845 extractCtrl.add = addRecordKey;
847 reckeys.buf_used = 0;
848 reckeys.prevAttrUse = -1;
849 reckeys.prevAttrSet = -1;
851 recordOffset = fi->file_moffset;
852 extractCtrl.offset = recordOffset;
853 extractCtrl.readf = file_read;
854 extractCtrl.seekf = file_seek;
855 extractCtrl.endf = file_end;
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);