+void index_marc_line_records(ISAMB isb,
+ Dict dict,
+ zint *docid_seq,
+ FILE *inf,
+ int memory)
+{
+ WRBUF wrbuf = wrbuf_alloc();
+ int no_docs = 0;
+ int new_rec = 1;
+ char line[4096];
+ struct index_block *b = index_block_new(memory);
+ while(fgets(line, sizeof(line)-1, inf))
+ {
+ if (line[0] == '$')
+ {
+ if (!new_rec)
+ new_rec = 1;
+ else
+ new_rec = 0;
+ continue;
+ }
+ if (new_rec)
+ {
+ (*docid_seq)++;
+ no_docs++;
+ index_block_check_flush(b, isb, dict, no_docs);
+ new_rec = 0;
+ }
+
+ if (line[0] == ' ')
+ {
+ /* continuation */
+ wrbuf_puts(wrbuf, line);
+ continue;
+ }
+ else
+ {
+ /* index existing buffer (if any) */
+ if (wrbuf_len(wrbuf))
+ {
+ index_wrbuf(b, wrbuf, *docid_seq, '*');
+ wrbuf_rewind(wrbuf);
+ }
+ if (line[0] != ' ' && line[1] != ' ' && line[2] != ' ' &&
+ line[3] == ' ')
+ {
+ /* normal field+indicator line */
+ wrbuf_puts(wrbuf, line);
+ }
+ }
+ }
+ if (wrbuf_len(wrbuf))
+ {
+ index_wrbuf(b, wrbuf, *docid_seq, '*');
+ wrbuf_rewind(wrbuf);
+ }
+ (*docid_seq)++;
+ no_docs++;
+ index_block_check_flush(b, isb, dict, no_docs);
+ index_block_destroy(&b);
+}
+