xref: /original-bsd/contrib/sort/fsort.h (revision c3e32dec)
1 /*-
2  * Copyright (c) 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Peter McIlroy.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)fsort.h	8.1 (Berkeley) 06/06/93
11  */
12 
13 #define POW 20			/* exponent for buffer size */
14 #define BUFSIZE (1 << POW)
15 #define MAXNUM (BUFSIZE/10)	/* lowish guess at average record size */
16 #define BUFFEND (EOF-2)
17 #define MAXFCT 1000
18 #define MAXLLEN ((1 << min(POW-4, 16)) - 14)
19 
20 extern u_char **keylist, **l2buf, *buffer, *linebuf;
21 
22 /* temp files in the stack have a file descriptor, a largest bin (maxb)
23  * which becomes the last non-empty bin (lastb) when the actual largest
24  * bin is smaller than max(half the total file, BUFSIZE)
25  * Max_o is the offset of maxb so it can be sought after the other bins
26  * are sorted.
27 */
28 struct tempfile {
29 	FILE *fd;
30 	u_char maxb;
31 	u_char lastb;
32 	long max_o;
33 };
34 extern struct tempfile fstack[MAXFCT];
35