Wheefun I/O Library  0.0.5
Useful I/O Primitives.
stdio.h
Go to the documentation of this file.
1 /* WFIO - the Wheefun IO Library
2  Copyright (C) 2018 Phillip Kilgore
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <https://www.gnu.org/licenses/>.
16 
17  Additionally, you should have recieved a copy of the GNU Classpath
18  exception, which amends the license to generally permit linking against
19  the software provided herein.
20 */
21 
22 #ifndef WFIO_STDIO_H
23 #define WFIO_STDIO_H
24 
25 #include <wfio/type.h>
26 #include <stdio.h>
27 
39 
57 WFIO_DLL struct wfio_device_t* wfio_device_from_stdio(FILE* handle,
58  int* error);
59 
68 WFIO_DLL_FASTCALL size_t wfio_stdio_getbufsz(FILE* handle, int* error);
69 
79 WFIO_DLL_FASTCALL wfio_fd_t wfio_stdio_to_fd(FILE* handle, int* error);
80 
82 
83 #ifdef __cplusplus
84 
85 namespace wfio {
93  class StdioDevice : public Device {
94  public:
95 
102  inline StdioDevice(FILE* file, int* error = NULL) : Device(
103  ::wfio_device_from_stdio(file, error), false) {}
104  };
105 }
106 #endif
107 
108 #endif
The root namespace for WFIO.
Definition: bin.h:879
#define WFIO_DLL
Mark the symbol as an element of the library.
Definition: host.h:397
#define WFIO_C_BEGIN
Definition: host.h:477
#define WFIO_DLL_FASTCALL
Shorthand for WFIO_DLL WFIO_FASTCALL.
Definition: host.h:425
WFIO_DLL_FASTCALL wfio_fd_t wfio_stdio_to_fd(FILE *handle, int *error)
Attempt to convert handle to a file descriptor.
WFIO_C_BEGIN WFIO_DLL struct wfio_device_t * wfio_device_from_stdio(FILE *handle, int *error)
Wrap the device with the given filehandle handle.
int wfio_fd_t
The type corresponding a file descriptor.
Definition: iotype.h:108
A Device wrapping a standard IO device.
Definition: stdio.h:93
A C++ wrapper for a wfio_device_t.
Definition: device.h:783
StdioDevice(FILE *file, int *error=NULL)
Construct a new StdioDevice from a FILE*.
Definition: stdio.h:102
#define WFIO_C_END
Definition: host.h:485
A simple, byte-oriented channel.
Definition: device.h:164
STDIO interaction.
WFIO_DLL_FASTCALL size_t wfio_stdio_getbufsz(FILE *handle, int *error)
Obtain the buffer size associated with this handle.
Shared type definitions.