Option: only one word key per file.
[idzebra-moved-to-github.git] / index / kcompare.c
1 /*
2  * Copyright (C) 1994-1995, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: kcompare.c,v $
7  * Revision 1.2  1995-09-06 16:11:17  adam
8  * Option: only one word key per file.
9  *
10  * Revision 1.1  1995/09/04  09:10:36  adam
11  * More work on index add/del/update.
12  * Merge sort implemented.
13  * Initial work on z39 server.
14  *
15  */
16
17 #include <stdlib.h>
18 #include <string.h>
19 #include <stdio.h>
20 #include <assert.h>
21
22 #include "index.h"
23
24 int key_compare (const void *p1, const void *p2)
25 {
26     struct it_key i1, i2;
27     memcpy (&i1, p1, sizeof(i1));
28     memcpy (&i2, p2, sizeof(i2));
29     if ( i1.sysno != i2.sysno)
30         return i1.sysno - i2.sysno;
31 #if IT_KEY_HAVE_FIELD
32     if ( i1.seqno != i2.seqno)
33         return i1.seqno - i2.seqno;
34     return i1.field - i2.field;
35 #else
36     return i1.seqno - i2.seqno;
37 #endif
38 }
39
40 int key_compare_x (const struct it_key *i1, const struct it_key *i2)
41 {
42     if ( i1->sysno != i2->sysno)
43         return i1->sysno - i2->sysno;
44 #if IT_KEY_HAVE_FIELD
45     if ( i1->seqno != i2->seqno)
46         return i1->seqno - i2->seqno;
47     return i1->field - i2->field;
48 #else
49     return i1->seqno - i2->seqno;
50 #endif
51 }
52