- memcpy (&key, k+1, sizeof(struct it_key));
- if (0==i->prevsys) /* no previous filter, fill up */
- {
- i->prevsys=key.sysno;
- i->prevseq=key.seqno;
- i->prevcmd=*k;
- }
- else if ( (i->prevsys==key.sysno) &&
- (i->prevseq==key.seqno) &&
- (i->prevcmd!=*k) )
- { /* same numbers, diff cmd, they cancel out */
- i->prevsys=0;
- }
- else
- { /* different stuff, write previous, move buf */
- bp = encode_key_int ( (i->prevsys - i->sysno) * 2 + i->prevcmd, bp);
- if (i->sysno != i->prevsys)
- {
- i->sysno = i->prevsys;
- i->seqno = 0;
- }
- else if (!i->seqno && !i->prevseq && i->cmd == i->prevcmd)
- {
- return; /* ??? Filters some sort of duplicates away */
- /* ??? Can this ever happen -H 15oct02 */
- }
- bp = encode_key_int (i->prevseq - i->seqno, bp);
- i->seqno = i->prevseq;
- i->cmd = i->prevcmd;
- if (fwrite (i->buf, bp - i->buf, 1, outf) != 1)
- {
- yaz_log (YLOG_FATAL|YLOG_ERRNO, "fwrite");
- exit (1);
- }
- i->keylen=0; /* ok, it's written, forget it */
- i->prevsys=key.sysno;
- i->prevseq=key.seqno;
- i->prevcmd=*k;