Wheefun I/O Library  0.0.5
Useful I/O Primitives.
Classes | Namespaces | Typedefs | Functions
peer.h File Reference

Generic wrapping around various stream types. More...

#include <wfio/type.h>
#include <wfio/device.h>

Go to the source code of this file.

Classes

struct  wfio_peer_t
 A generic stream encapsulation. More...
 
class  wfio::Peer
 

Namespaces

 wfio
 The root namespace for WFIO.
 

Typedefs

typedef WFIO_C_BEGIN struct wfio_peer_t wfio_peer_t
 A generic stream encapsulation. More...
 

Functions

WFIO_DLL int wfio_peer_fromDeviceEx (wfio_peer_t *peer, struct wfio_device_t *device, int ioshare, int *error)
 Initialize a peer using a device with the specified ioshare mode. More...
 
WFIO_ALWAYS_INLINE int wfio_peer_fromDevice (wfio_peer_t *peer, struct wfio_device_t *device, int *error)
 Initialize a peer using a device. More...
 
WFIO_DLL int wfio_peer_fromBinstreamEx (wfio_peer_t *peer, struct wfio_binstream_t *bin, int ioshare, int *error)
 Initialize a peer using a binstream with the specified ioshare mode. More...
 
WFIO_ALWAYS_INLINE int wfio_peer_fromBinstream (wfio_peer_t *peer, struct wfio_binstream_t *bin, int *error)
 Initialize a peer using a binstream. More...
 
WFIO_DLL_FASTCALL wfio_peer_t wfio_peer_ioshare (wfio_peer_t *peer, wfio_ioshare_t ioshare, int *error)
 Share this peer with the supplied ioshare mode. More...
 
WFIO_DLL int wfio_peer_acquire (wfio_peer_t *peer, int *error)
 Share this peer. More...
 
WFIO_DLL void wfio_peer_close (wfio_peer_t *peer)
 Release this peer. More...
 
WFIO_DLL size_t wfio_peer_read (wfio_peer_t *peer, void *buf, size_t sz, size_t elem, int *error)
 Read elements from this peer. More...
 
WFIO_ALWAYS_INLINE size_t wfio_peer_readbV (wfio_peer_t *peer, void *buf, size_t len, int *error)
 Read bytes from this peer. More...
 
WFIO_ALWAYS_INLINE int wfio_peer_readb (wfio_peer_t *peer, int *error)
 Read a single byte from this peer. More...
 
WFIO_DLL size_t wfio_peer_write (wfio_peer_t *peer, const void *buf, size_t sz, size_t elem, int *error)
 Write elements to this peer. More...
 
WFIO_ALWAYS_INLINE size_t wfio_peer_writebV (wfio_peer_t *peer, const void *buf, size_t len, int *error)
 Write bytes to this peer. More...
 
WFIO_ALWAYS_INLINE int wfio_peer_writeb (wfio_peer_t *peer, char c, int *error)
 Write a single byte to this peer. More...
 
WFIO_DLL int wfio_peer_vdcntl (wfio_peer_t *peer, wfio_dcntl_t cmd, int *error, va_list va)
 Perform device-independent I/O on this peer using a va_list. More...
 
WFIO_ALWAYS_INLINE int wfio_peer_dcntl (wfio_peer_t *peer, wfio_dcntl_t cmd, int *error,...)
 Perform device-independent I/O on this peer. More...
 
WFIO_DLL int wfio_peer_vioctl (wfio_peer_t *peer, int cmd, int *error, va_list va)
 Perform device-dependent I/O on this peer using a va_list. More...
 
WFIO_ALWAYS_INLINE int wfio_peer_ioctl (wfio_peer_t *peer, int *error, int cmd,...)
 Perform device-dependent I/O on this peer. More...
 
WFIO_DLL int wfio_peer_seek (wfio_peer_t *peer, wfio_off_t offset, wfio_whence_t whence, int *error)
 Seek to a position in the stream. More...
 
WFIO_DLL_FASTCALL int wfio_peer_canSeek (wfio_peer_t *peer)
 Determine whether or not this peer can seek. More...
 
WFIO_DLL_FASTCALL wfio_off_t wfio_peer_tell (wfio_peer_t *peer, int *error)
 Determine the current stream position of this peer. More...
 
WFIO_DLL_FASTCALL int wfio_peer_flush (wfio_peer_t *peer, int *error)
 Determine the current stream position of this peer. More...
 
WFIO_DLL_FASTCALL size_t wfio_peer_getbufsz (wfio_peer_t *peer, int *error)
 Obtain the buffer size. More...
 
WFIO_DLL size_t wfio_peer_setbufsz (wfio_peer_t *peer, size_t sz, int *error)
 Set the buffer size. More...
 

Detailed Description

Generic wrapping around various stream types.

Author
Phillip Kilgore
Since
0.0.1

Typedef Documentation

◆ wfio_peer_t

A generic stream encapsulation.

This type wraps around various stream types. This allows for it to be generically used in other types; for instance,

Function Documentation

◆ wfio_peer_acquire()

WFIO_DLL int wfio_peer_acquire ( wfio_peer_t peer,
int *  error 
)

Share this peer.

Parameters
peerThe peer to acquire.
errorAn optional error indicator.
Returns
Nonzero if the peer was successfully acquired; otherwize, zero.

◆ wfio_peer_canSeek()

WFIO_DLL_FASTCALL int wfio_peer_canSeek ( wfio_peer_t peer)

Determine whether or not this peer can seek.

Parameters
peerThe peer to interrogate.
Returns
Nonzero if this peer can seek; otherwise, zero.

◆ wfio_peer_close()

WFIO_DLL void wfio_peer_close ( wfio_peer_t peer)

Release this peer.

Parameters
peerThe peer to acquire.

◆ wfio_peer_dcntl()

WFIO_ALWAYS_INLINE int wfio_peer_dcntl ( wfio_peer_t peer,
wfio_dcntl_t  cmd,
int *  error,
  ... 
)

Perform device-independent I/O on this peer.

Parameters
peerThe peer to dcntl.
cmdThe command to send to the peer.
...Additional arguments to the dcntl.
See also
wfio_device_dcntl

◆ wfio_peer_flush()

WFIO_DLL_FASTCALL int wfio_peer_flush ( wfio_peer_t peer,
int *  error 
)

Determine the current stream position of this peer.

Parameters
peerThe peer to interrogate.
errorAn optional error indicator.
Returns
The current stream position of the peer on success; otherwise, WFIO_NPOS.
Note
This method may set ecode.

◆ wfio_peer_fromBinstream()

WFIO_ALWAYS_INLINE int wfio_peer_fromBinstream ( wfio_peer_t peer,
struct wfio_binstream_t bin,
int *  error 
)

Initialize a peer using a binstream.

Parameters
peerThe peer to initialize.
binThe binstream to initialize the peer.
errorAn optional error indicator.
Returns
Nonzero if initialization was successful; otherwise, zero.

◆ wfio_peer_fromBinstreamEx()

WFIO_DLL int wfio_peer_fromBinstreamEx ( wfio_peer_t peer,
struct wfio_binstream_t bin,
int  ioshare,
int *  error 
)

Initialize a peer using a binstream with the specified ioshare mode.

Parameters
peerThe peer to initialize.
binThe binstream to initialize the peer.
ioshareThe ioshare mode to initialize the peer with.
errorAn optional error indicator.
Returns
Nonzero if initialization was successful; otherwise, zero.

◆ wfio_peer_fromDevice()

WFIO_ALWAYS_INLINE int wfio_peer_fromDevice ( wfio_peer_t peer,
struct wfio_device_t device,
int *  error 
)

Initialize a peer using a device.

Parameters
peerThe peer to initialize.
deviceThe device to initialize the peer.
errorAn optional error indicator.
Returns
Nonzero if initialization was successful; otherwise, zero.

◆ wfio_peer_fromDeviceEx()

WFIO_DLL int wfio_peer_fromDeviceEx ( wfio_peer_t peer,
struct wfio_device_t device,
int  ioshare,
int *  error 
)

Initialize a peer using a device with the specified ioshare mode.

Parameters
peerThe peer to initialize.
deviceThe device to initialize the peer.
ioshareThe ioshare mode to initialize the peer with.
errorAn optional error indicator.
Returns
Nonzero if initialization was successful; otherwise, zero.

◆ wfio_peer_getbufsz()

WFIO_DLL_FASTCALL size_t wfio_peer_getbufsz ( wfio_peer_t peer,
int *  error 
)

Obtain the buffer size.

Parameters
peerThe peer to interrogate.
errorAn optional error indicator.
Returns
The size of the buffer associated with this peer on success; otherwise, WFIO_NPOS. A return value of zero shall indicate that the peer is unbuffered.

◆ wfio_peer_ioctl()

WFIO_ALWAYS_INLINE int wfio_peer_ioctl ( wfio_peer_t peer,
int *  error,
int  cmd,
  ... 
)

Perform device-dependent I/O on this peer.

Parameters
peerThe peer to ioctl.
cmdThe command to send to the peer.
...Additional arguments to the ioctl.
See also
wfio_device_ioctl

◆ wfio_peer_ioshare()

WFIO_DLL_FASTCALL wfio_peer_t wfio_peer_ioshare ( wfio_peer_t peer,
wfio_ioshare_t  ioshare,
int *  error 
)

Share this peer with the supplied ioshare mode.

Parameters
peerThe device to share.
ioshareThe ioshare mode.

This function allows for the peer to be shared in the specified manner.

Returns
The shared instance of this peer.
Warning
If WFIO_IOSHARE_O_ACQUIRE or WFIO_IOSHARE_DUP is specified, then the resulting peer must be matched with a corresponding call to wfio_device_close() or resources will leak.

◆ wfio_peer_read()

WFIO_DLL size_t wfio_peer_read ( wfio_peer_t peer,
void *  buf,
size_t  sz,
size_t  elem,
int *  error 
)

Read elements from this peer.

Parameters
peerThe peer to read from.
bufThe buffer to read into.
szThe size of each element.
elemThe number of elements to read.
errorAn optional error indicator.
Returns
The number of elements read on success; otherwise, WFIO_NPOS.

◆ wfio_peer_readb()

WFIO_ALWAYS_INLINE int wfio_peer_readb ( wfio_peer_t peer,
int *  error 
)

Read a single byte from this peer.

Parameters
peerThe peer to read from.
errorAn optional error indicator.
Returns
The byte read on success; otherwise, WFIO_NPOS.

◆ wfio_peer_readbV()

WFIO_ALWAYS_INLINE size_t wfio_peer_readbV ( wfio_peer_t peer,
void *  buf,
size_t  len,
int *  error 
)

Read bytes from this peer.

Parameters
peerThe peer to read from.
bufThe buffer to read into.
lenThe number of bytes to read.
errorAn optional error indicator.
Returns
The number of bytes read on success; otherwise, WFIO_NPOS.

◆ wfio_peer_seek()

WFIO_DLL int wfio_peer_seek ( wfio_peer_t peer,
wfio_off_t  offset,
wfio_whence_t  whence,
int *  error 
)

Seek to a position in the stream.

This method attempts to seek the peer to the specified position. This is only successful if the peer is open and seekable.

Parameters
peerThe peer to seek.
offsetThe offset relative to whence to seek to.
whenceThe origin added to whence to seek to.
errorAn optional error indicator.
Returns
Nonzero on success; otherwise, zero.

◆ wfio_peer_setbufsz()

WFIO_DLL size_t wfio_peer_setbufsz ( wfio_peer_t peer,
size_t  sz,
int *  error 
)

Set the buffer size.

This function sets the size of the underlying buffer belonging to peer if it supports this behavior. The peer itself is not required to change the size of the buffer to sz; if it changes it to a different size, If for some reason this operation fails or is unsupported, then it shall return WFIO_NPOS and the buffer size shall remain unchanged.

Parameters
peerThe peer to set the buffer size for.
szThe requested size to set.
errorAn optional error indicator.
Returns
The size of the buffer after this operation; otherwise, WFIO_NPOS. A return value of zero shall indicate that peer is unbuffered.
Note
When the buffer size is immutable or the device cannot be buffered, but is otherwise known, then the size of the buffer is returned.

◆ wfio_peer_tell()

WFIO_DLL_FASTCALL wfio_off_t wfio_peer_tell ( wfio_peer_t peer,
int *  error 
)

Determine the current stream position of this peer.

Parameters
peerThe peer to interrogate.
errorAn optional error indicator.
Returns
The current stream position of the peer on success; otherwise, WFIO_NPOS.

◆ wfio_peer_vdcntl()

WFIO_DLL int wfio_peer_vdcntl ( wfio_peer_t peer,
wfio_dcntl_t  cmd,
int *  error,
va_list  va 
)

Perform device-independent I/O on this peer using a va_list.

Parameters
peerThe peer to dcntl.
cmdThe command to send to the peer.
vaAdditional arguments to the dcntl.
See also
wfio_device_vdcntl

◆ wfio_peer_vioctl()

WFIO_DLL int wfio_peer_vioctl ( wfio_peer_t peer,
int  cmd,
int *  error,
va_list  va 
)

Perform device-dependent I/O on this peer using a va_list.

Parameters
peerThe peer to ioctl.
cmdThe command to send to the peer.
vaAdditional arguments to the ioctl.
See also
wfio_device_vioctl

◆ wfio_peer_write()

WFIO_DLL size_t wfio_peer_write ( wfio_peer_t peer,
const void *  buf,
size_t  sz,
size_t  elem,
int *  error 
)

Write elements to this peer.

Parameters
peerThe peer to write to.
bufThe buffer to write from.
szThe size of each element.
elemThe number of elements to write.
errorAn optional error indicator.
Returns
The number of elements written on success; otherwise, WFIO_NPOS.

◆ wfio_peer_writeb()

WFIO_ALWAYS_INLINE int wfio_peer_writeb ( wfio_peer_t peer,
char  c,
int *  error 
)

Write a single byte to this peer.

Parameters
peerThe peer to write to.
cThe byte to write.
errorAn optional error indicator.
Returns
Nonzero on success; otherwise, zero.

◆ wfio_peer_writebV()

WFIO_ALWAYS_INLINE size_t wfio_peer_writebV ( wfio_peer_t peer,
const void *  buf,
size_t  len,
int *  error 
)

Write bytes to this peer.

Parameters
peerThe peer to write to.
bufThe buffer to write from.
lenThe number of bytes to write.
errorAn optional error indicator.
Returns
The number of bytes written on success; otherwise, WFIO_NPOS.