streams.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1998-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "streams.h"
static const stream_ops_t invalid_ops = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};
stream_t *
stream_new(int src)
{
return (str);
}
void
{
if (flags & STREAM_SOURCE_MASK) {
switch (flags & STREAM_SOURCE_MASK) {
case STREAM_NO_SOURCE:
str->s_element_size = 0;
return;
case STREAM_ARRAY:
/*
* Array streams inherit element size.
*/
break;
case STREAM_MMAP:
str->s_element_size = sizeof (char);
break;
case STREAM_SINGLE:
str->s_element_size = sizeof (char);
break;
case STREAM_WIDE:
break;
default:
}
}
case STREAM_SINGLE :
break;
case STREAM_WIDE :
break;
default :
break;
}
case STREAM_SINGLE :
break;
case STREAM_WIDE :
break;
default :
break;
}
}
void
{
}
int
{
}
void
{
}
static void
{
}
void
{
continue;
}
}
}
{
uint_t n = 0;
n++;
}
return (n);
}
int
{
int fd;
/*
* STREAM_ARRAY streams are open by definition.
*/
return (1);
}
/*
* Set data type according to locale for input from stdin.
*/
STREAM_SINGLE : STREAM_WIDE));
return (1);
}
#ifndef DEBUG_DISALLOW_MMAP
if (S->m_single_byte_locale &&
str->s_filesize > 0 &&
/*
* make mmap() attempt; set s_status and return if successful
*/
if (fd < 0) {
return (-1);
else
}
MAP_SHARED, fd, 0);
return (1);
}
/*
* Otherwise the mmap() failed due to address space exhaustion;
* since we have already opened the file, we close it and drop
* into the normal (STDIO) case.
*/
}
#endif /* DEBUG_DISALLOW_MMAP */
return (-1);
else
}
STDIO_VBUF_SIZE) != 0) {
}
STREAM_WIDE));
return (1);
}
void
{
/*
* p_new_size is new_size rounded upwards to nearest multiple of
* PAGESIZE, since mmap() is going to reserve it in any case. This
* ensures that the far end of the buffer is also aligned, such that we
* obtain aligned pointers if we choose to subtract from it.
*/
return;
if (new_size == 0) {
str->s_buffer_size = 0;
return;
}
MAP_PRIVATE, 0);
}
void
{
}
void
{
if (cur_streamp == NULL) {
return;
}
}
static void
{
}
}
/*
* stream_push_to_temporary() with flags set to ST_CACHE merely copies the
* stream_t pointer onto the chain. With flags set to ST_NOCACHE, the stream is
* written out to a file. Stream pointers passed to stream_push_to_temporary()
* must refer to allocated objects, and not to objects created on function
* stacks. Finally, if strp == NULL, stream_push_to_temporary() creates and
* pushes the new stream; the output stream is left open if ST_OPEN is set.
*/
stream_t *
{
return (streamp);
}
out_streamp->s_buffer_size = 0;
} else {
}
(void) bump_file_template();
return (NULL);
/*
* We reset the input stream to the beginning, and copy it in
* sequence to the output stream, freeing the raw_collate field
* as we go.
*/
}
(void) SOP_CLOSE(out_streamp);
}
/*
* Now that we've written this stream to disk, we needn't protect any
* in-memory consumer.
*/
return (out_streamp);
}
void
{
while (cur_streamp != NULL) {
(void) SOP_FREE(cur_streamp);
if (SOP_IS_CLOSABLE(cur_streamp))
(void) SOP_CLOSE(cur_streamp);
}
}
void
{
(void) SOP_UNLINK(streamp);
}
}
/*
* stream_insert() takes input from src stream, converts to each line to
* collatable form, and places a line_rec_t in dest stream, which is of type
* STREAM_ARRAY.
*/
int
{
int return_val = ST_MEM_AVAIL;
int fetch_result = NEXT_LINE_COMPLETE;
/*
* Scan through until total bytes allowed accumulated, and return.
* Use SOP_FETCH(src) so that this works for all stream types,
* and so that we can repeat until eos.
*
* For each new line, we move back sizeof (line_rec_t) from the end of
* the array buffer, and copy into the start of the array buffer. When
* the pointers meet, or when we exhaust the current stream, we return.
* If we have not filled the current memory allocation, we return
* ST_MEM_AVAIL, else we return ST_MEM_FILLED.
*/
/*LINTED ALIGNMENT*/
/*
* current line has been set prior to entry
*/
return (ST_MEM_FILLED);
S->m_field_separator)) >= 0) {
l_series--;
l_series++;
break;
}
/*
* There's no collision with the lower part of the buffer, so we
* can safely begin processing the line. In the debug case, we
* test for uninitialized data by copying a non-zero pattern.
*/
#ifdef DEBUG
#endif
i++;
break;
}
if (fetch_result == NEXT_LINE_INCOMPLETE) {
}
if (fetch_result != NEXT_LINE_INCOMPLETE &&
i == 0)
/*
* There's no room for conversion of our only line; need to
* execute with larger memory.
*/
/*
* Set up pointer array to line records.
*/
sizeof (line_rec_t *) * i);
i = 0;
l_series++;
i++;
}
/*
* LINES_ARRAY streams are always open.
*/
return (return_val);
}
/*
* stream_swap_buffer() exchanges the stream's buffer with the proffered one;
* s_current is not adjusted so this is safe only for STREAM_INSTANT.
*/
void
{
}