Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / libparanoia / isort.h
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
4  * The behaviour and appearence of the program code below can differ to a major
5  * extent from the version distributed by the original author(s).
6  *
7  * For details, see Changelog file distributed with the cdrkit package. If you
8  * received this file from another source then ask the distributing person for
9  * a log of modifications.
10  *
11  */
12
13 /* @(#)isort.h  1.10 04/02/18 J. Schilling from cdparanoia-III-alpha9.8 */
14 /*
15  *      Modifications to make the code portable Copyright (c) 2002 J. Schilling
16  */
17 /*
18  * CopyPolicy: GNU Public License 2 applies
19  * Copyright (C) by Monty (xiphmont@mit.edu)
20  */
21
22 #ifndef _ISORT_H_
23 #define _ISORT_H_
24
25 typedef struct sort_link {
26         struct sort_link *next;
27 } sort_link;
28
29 typedef struct sort_info {
30         Int16_t         *vector;        /* vector */
31                                         /* vec storage doesn't belong to us */
32
33         long            *abspos;        /* pointer for side effects */
34         long            size;           /* vector size */
35
36         long            maxsize;        /* maximum vector size */
37
38         long            sortbegin;      /* range of contiguous sorted area */
39         long            lo;
40         long            hi;             /* current post, overlap range */
41         int             val;            /* ...and val */
42
43         /*
44          * sort structs
45          */
46         sort_link       **head;         /* sort buckets (65536) */
47
48         long            *bucketusage;   /* of used buckets (65536) */
49         long            lastbucket;
50         sort_link       *revindex;
51
52 } sort_info;
53
54 extern sort_info        *sort_alloc(long size);
55 extern void             sort_unsortall(sort_info * i);
56 extern void             sort_setup(sort_info * i, Int16_t * vector, long *abspos, 
57                                                                   long size, long sortlo, long sorthi);
58 extern void             sort_free(sort_info * i);
59 extern sort_link        *sort_getmatch(sort_info * i, long post, long overlap, 
60                                                                                         int value);
61 extern sort_link        *sort_nextmatch(sort_info * i, sort_link * prev);
62
63 #define is(i)           ((i)->size)
64 #define ib(i)           (*(i)->abspos)
65 #define ie(i)           ((i)->size + *(i)->abspos)
66 #define iv(i)           ((i)->vector)
67 #define ipos(i, l)      ((l) - (i)->revindex)
68
69 #endif