libuproc  1.2.0
io.h
Go to the documentation of this file.
1 /* Copyright 2014 Peter Meinicke, Robin Martinjak
2  *
3  * This file is part of libuproc.
4  *
5  * libuproc is free software: you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License as published by the Free
7  * Software Foundation, either version 3 of the License, or (at your option)
8  * any later version.
9  *
10  * libuproc is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libuproc. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
33 #ifndef UPROC_IO_H
34 #define UPROC_IO_H
35 
36 #include <stdio.h>
37 #include <stdarg.h>
38 
56 typedef struct uproc_io_stream uproc_io_stream;
57 
64 };
65 
74 
77 };
78 
91 uproc_io_stream *uproc_io_open(const char *mode, enum uproc_io_type type,
92  const char *pathfmt, ...);
93 
99 uproc_io_stream *uproc_io_openv(const char *mode, enum uproc_io_type type,
100  const char *pathfmt, va_list ap);
101 
103 int uproc_io_close(uproc_io_stream *stream);
104 
106 int uproc_io_printf(uproc_io_stream *stream, const char *fmt, ...);
107 
109 size_t uproc_io_read(void *ptr, size_t size, size_t nmemb,
110  uproc_io_stream *stream);
111 
113 size_t uproc_io_write(const void *ptr, size_t size, size_t nmemb,
114  uproc_io_stream *stream);
115 
120 char *uproc_io_gets(char *s, int size, uproc_io_stream *stream);
121 
127 long uproc_io_getline(char **lineptr, size_t *n, uproc_io_stream *stream);
128 
130 int uproc_io_putc(int c, uproc_io_stream *stream);
131 
133 int uproc_io_puts(const char *s, uproc_io_stream *stream);
134 
136 int uproc_io_seek(uproc_io_stream *stream, long offset,
137  enum uproc_io_seek_whence whence);
138 
140 long uproc_io_tell(uproc_io_stream *stream);
141 
143 int uproc_io_eof(uproc_io_stream *stream);
154 uproc_io_stream *uproc_io_stdstream(FILE *stream);
155 
159 #define uproc_stdin uproc_io_stdstream_gz(stdin)
160 
162 #define uproc_stdout uproc_io_stdstream(stdout)
163 
165 #define uproc_stderr uproc_io_stdstream(stderr)
166 
186 
188 #define uproc_stdout_gz uproc_io_stdstream_gz(stdout)
189 
191 #define uproc_stderr_gz uproc_io_stdstream_gz(stderr)
192 
198 #endif
uproc_io_stream * uproc_io_stdstream_gz(FILE *stream)
Wraps gz input streams.
int uproc_io_eof(uproc_io_stream *stream)
Test end-of-file indicator.
standard C's FILE pointer
Definition: io.h:61
size_t uproc_io_read(void *ptr, size_t size, size_t nmemb, uproc_io_stream *stream)
Read binary data.
int uproc_io_putc(int c, uproc_io_stream *stream)
Write a character.
long uproc_io_tell(uproc_io_stream *stream)
Obtain current file position.
int uproc_io_seek(uproc_io_stream *stream, long offset, enum uproc_io_seek_whence whence)
Set the file position.
uproc_io_stream * uproc_io_openv(const char *mode, enum uproc_io_type type, const char *pathfmt, va_list ap)
Open a file using a va_list.
size_t uproc_io_write(const void *ptr, size_t size, size_t nmemb, uproc_io_stream *stream)
Write binary data.
long uproc_io_getline(char **lineptr, size_t *n, uproc_io_stream *stream)
Read an entire line.
int uproc_io_close(uproc_io_stream *stream)
Close a file stream.
int uproc_io_puts(const char *s, uproc_io_stream *stream)
Write a string and a trailing newline.
int uproc_io_printf(uproc_io_stream *stream, const char *fmt,...)
Formatted output.
uproc_io_seek_whence
Third argument to uproc_io_seek()
Definition: io.h:71
Set the new position relative to the current one.
Definition: io.h:76
uproc_io_stream * uproc_io_open(const char *mode, enum uproc_io_type type, const char *pathfmt,...)
Open a file.
char * uproc_io_gets(char *s, int size, uproc_io_stream *stream)
(Partially) read a line
Optionally compressed I/O stream.
uproc_io_stream * uproc_io_stdstream(FILE *stream)
Wrap standard input streams.
transparent gzip stream using zlib
Definition: io.h:63
Set the cursor to an absolute position.
Definition: io.h:73
uproc_io_type
Underlying stream type.
Definition: io.h:59