INGOR
ytStdioBuff.h
1/*
2 io/ytStdioBuff.{h,c} : Standard input/output buffer
3 Copyright (C) 2022, Yoshinori Tamada <tamada A T ytlab.jp>
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12
13 * Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in
15 the documentation and/or other materials provided with the
16 distribution.
17
18 * Neither the name of Hirosaki University, Kyoto University, The
19 University of Tokyo, nor the names of its contributors may be
20 used to endorse or promote products derived from this software
21 without specific prior written permission.
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35*/
36#ifndef __YTLIB_STDIO_BUFF_H
37#define __YTLIB_STDIO_BUFF_H
38
39#include "util/ytStrBuff.h"
40#include "util/ytArray.h"
41
42typedef struct ytStdioBuff_t {
43 ytStrBuff * buff;
44 ytArray * pos;
45 ytArray * size;
46
47 ytArray * writeBuff;
48 ytArray * writeSize;
49#ifdef _WIN32
50 ytArray * writeTid;
51#endif
53
54extern ytStdioBuff * ytFileBuff_global;
55
57size_t ytStdioBuff_size();
58FILE * ytStdioBuff_getRead(size_t index);
61FILE * ytStdioBuff_getWrite(size_t index);
63int ytStdioBuff_checkOutFile(const char * filename);
64#endif /* __YTLIB_STDIO_BUFF_H */
Expandable array.
Standard input buffer.
int ytStdioBuff_checkOutFile(const char *filename)
Return the standard output index if the file name has the form and the standard output buffer is enab...
Definition: ytStdioBuff.c:297
FILE * ytStdioBuff_getRead(size_t index)
Returns the file stream corresponding to the read data.
Definition: ytStdioBuff.c:155
FILE * ytStdioBuff_getWrite(size_t index)
Returns the file stream corresponding to the indexed buffer to write.
Definition: ytStdioBuff.c:214
void ytStdioBuff_flush()
Flushes the writing buffer to the standard output.
Definition: ytStdioBuff.c:265
void ytStdioBuff_prepare()
Prepares the buffer to write.
Definition: ytStdioBuff.c:179
int ytStdioBuff_ready()
Returns non-zero if the buffer is ready to write.
Definition: ytStdioBuff.c:202
int ytStdioBuff_read()
Reads multiple data from the standard input and buffers them.
Definition: ytStdioBuff.c:82
Expandable String Buffer.
Definition: ytStdioBuff.h:42