xref: /illumos-gate/usr/src/cmd/sort/streams.h (revision 101e15b5f8a77d9433805e541996abaabc9ca8c1)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1998-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SORT_STREAMS_H
28 #define	_SORT_STREAMS_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/mman.h>
35 #include <sys/param.h>
36 #include <sys/types.h>
37 #include <sys/stat.h>
38 
39 #include <fcntl.h>
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43 #include <unistd.h>
44 
45 #include "fields.h"
46 #include "types.h"
47 #include "streams_array.h"
48 #include "streams_common.h"
49 #include "streams_mmap.h"
50 #include "streams_stdio.h"
51 #include "streams_wide.h"
52 #include "utility.h"
53 
54 #define	ST_MEM_FILLED	0x0	/* no memory left; proceed to internal sort */
55 #define	ST_MEM_AVAIL	0x1	/* memory left for sort; take add'l input */
56 
57 #define	ST_NOCACHE	0x0	/* write sorted array to temporary file */
58 #define	ST_CACHE	0x1	/* keep sorted array in memory */
59 #define	ST_OPEN		0x2	/* create open temporary file */
60 #define	ST_WIDE		0x4	/* write multibyte chars to temporary file */
61 
62 extern void stream_add_file_to_chain(stream_t **, char *);
63 extern void stream_clear(stream_t *);
64 extern void stream_close_all_previous(stream_t *);
65 extern uint_t stream_count_chain(stream_t *);
66 extern int stream_insert(sort_t *, stream_t *, stream_t *);
67 extern stream_t *stream_new(int);
68 extern int stream_open_for_read(sort_t *, stream_t *);
69 extern void stream_push_to_chain(stream_t **, stream_t *);
70 extern stream_t *stream_push_to_temporary(stream_t **, stream_t *, int);
71 extern void stream_set_size(stream_t *, size_t);
72 extern void stream_stat_chain(stream_t *);
73 extern void stream_swap_buffer(stream_t *, char **, size_t *);
74 extern void stream_unlink_temporary(stream_t *streamp);
75 
76 #ifdef	__cplusplus
77 }
78 #endif
79 
80 #endif	/* _SORT_STREAMS_H */
81