Vio class

This class provides an I/O layer for files/bufferes/pipes/sockets. More...

## Files

file | vio.h
| Class Vio: virtual <SDIO/FILE/BUFF/UNIX/INET> I/O layer.

## Classes

struct | sVio
| Contains public data members for Vio class. More...

## Typedefs

typedef enum VIOtype | VIOtype
| Parameter for I/O type (sdio,buff,file,unix,inet) More...
typedef enum VIOfrmt | VIOfrmt
| Parameter for compression type (XDR,ASC) More...
typedef enum VIOrwkey | VIOrwkey
| Parameter for rw type (R,RW) More...
typedef struct sVio | Vio
| Declaration of the Vio class as the Vio structure. More...

## Enumerations

enum | VIOtype { VIO_NO_TYPE , VIO_SDIO , VIO_BUFF , VIO_FILE , VIO_UNIX , VIO_INET }
| Parameter for I/O type (sdio,buff,file,unix,inet) More...
enum | VIOfrmt { VIO_NO_FRMT , VIO_XDR , VIO_ASC }
| Parameter for compression type (XDR,ASC) More...
enum | VIOrwkey { VIO_NO_RW , VIO_R , VIO_W }
| Parameter for rw type (R,RW) More...

## Functions

void | Vio_start (void)
| Start Vio communication layer (init internal variables/buffers) More...
void | Vio_stop (void)
| Shutdown Vio communication layer. More...
Vio * | Vio_ctor (const char *socktype, const char *datafrmt, const char *hostname, const char *filename, const char *rwkey)
| Construct the Vio object. More...
int | Vio_ctor2 (Vio *thee, const char *socktype, const char *datafrmt, const char *hostname, const char *filename, const char *rwkey)
| Work routine that Vio_ctor calls to do most of the construction. More...
void | Vio_dtor (Vio **thee)
| Destruct the Vio object. More...
void | Vio_dtor2 (Vio *thee)
| Work routine that Vio_dtor calls to do most of the destruction. More...
void | Vio_setWhiteChars (Vio *thee, char *whiteChars)
| Set the white character set for I/O stream. More...
void | Vio_setCommChars (Vio *thee, char *commChars)
| Set the comment character set for I/O stream. More...
int | Vio_accept (Vio *thee, int nonblock)
| Accept any waiting connect attempt to our socket on our machine. More...
void | Vio_acceptFree (Vio *thee)
| Free the socket child that was used for the last accept. More...
int | Vio_connect (Vio *thee, int nonblock)
| Connect to some socket on a remote machine (or on our machine) More...
void | Vio_connectFree (Vio *thee)
| Purge any output buffers (for <UNIX/INET>, else a no-op) More...
int | Vio_scanf (Vio *thee, char *parms,...)
| Mimic "scanf" from an arbitrary Vio device. More...
int | Vio_printf (Vio *thee, char *parms,...)
| Mimic "printf" from an arbitrary Vio device. More...
int | Vio_read (Vio *thee, char *buf, int bufsize)
| Read (up to) bufsize characters into buf from input device. More...
int | Vio_write (Vio *thee, char *buf, int bufsize)
| Write bufsize characters from buf to output device. More...
void | Vio_bufTake (Vio *thee, char *buf, int bufsize)
| Set the pointer to the internal buffer. More...
char * | Vio_bufGive (Vio *thee)
| Return the pointer to the internal buffer. More...
int | Vio_bufSize (Vio *thee)
| Return the length to the internal buffer. More...
Vio * | Vio_socketOpen (char *key, const char *iodev, const char *iofmt, const char *iohost, const char *iofile)
| Socket open for read or write. More...
void | Vio_socketClose (Vio **sock)
| Socket close from read or write. More...

## Detailed Description

This class provides an I/O layer for files/bufferes/pipes/sockets.

This class provides an abstraction of I/O to give acess to files, buffers, pipes, UNIX sockets, and INET sockets.

## Typedef Documentation

## Vio

typedef struct sVio Vio

Declaration of the Vio class as the Vio structure.

Author
  Michael Holst

## VIOfrmt

typedef enum VIOfrmt VIOfrmt

Parameter for compression type (XDR,ASC)

Author
  Michael Holst

## VIOrwkey

typedef enum VIOrwkey VIOrwkey

Parameter for rw type (R,RW)

Author
  Michael Holst

## VIOtype

typedef enum VIOtype VIOtype

Parameter for I/O type (sdio,buff,file,unix,inet)

Author
  Michael Holst

## Enumeration Type Documentation

## VIOfrmt

enum VIOfrmt

Parameter for compression type (XDR,ASC)

Author
  Michael Holst

Enumerator
VIO_NO_FRMT |
VIO_XDR |
VIO_ASC |

{
VIO_NO_FRMT,
VIO_XDR,
VIO_ASC
} VIOfrmt;
VIOfrmt
VIOfrmt
Parameter for compression type (XDR,ASC)
Definition: vio.h:76
VIO_XDR
@ VIO_XDR
Definition: vio.h:78
VIO_NO_FRMT
@ VIO_NO_FRMT
Definition: vio.h:77
VIO_ASC
@ VIO_ASC
Definition: vio.h:79

## VIOrwkey

enum VIOrwkey

Parameter for rw type (R,RW)

Author
  Michael Holst

Enumerator
VIO_NO_RW |
VIO_R |
VIO_W |

## VIOtype

enum VIOtype

Parameter for I/O type (sdio,buff,file,unix,inet)

Author
  Michael Holst

Enumerator
VIO_NO_TYPE |
VIO_SDIO |
VIO_BUFF |
VIO_FILE |
VIO_UNIX |
VIO_INET |

## Function Documentation

## Vio_accept()

int Vio_accept | ( | Vio * | thee,
|  | int | nonblock
| ) |  |

Accept any waiting connect attempt to our socket on our machine.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  1 on success, -1 on failure

Parameters

  thee | Pointer to the Vio object
  nonblock | index for a non-blocking socket Only for <UNIX/INET>; othewise it is ignored. nonblock==0 ==> block until a connect is attempted nonblock==1 ==> DO NOT block at all

## Vio_acceptFree()

void Vio_acceptFree | ( | Vio * | thee | ) |

Free the socket child that was used for the last accept.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  None

Parameters

  thee | Pointer to the Vio object

## Vio_bufGive()

char * Vio_bufGive | ( | Vio * | thee | ) |

Return the pointer to the internal buffer.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  Poitner to the internal buffer

Parameters

  thee | Pointer to the Vio object

## Vio_bufSize()

int Vio_bufSize | ( | Vio * | thee | ) |

Return the length to the internal buffer.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  Length of the internal buffer

Parameters

  thee | Pointer to the Vio object

## Vio_bufTake()

void Vio_bufTake | ( | Vio * | thee,
|  | char * | buf,
|  | int | bufsize
| ) |  |

Set the pointer to the internal buffer.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  None

Parameters

  thee | Pointer to the Vio object
  buf | buffer containing message
  bufsize | number of items (of declared type) in buffer

## Vio_connect()

int Vio_connect | ( | Vio * | thee,
|  | int | nonblock
| ) |  |

Connect to some socket on a remote machine (or on our machine)

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  1 on success, -1 on failure

Parameters

  thee | Pointer to the Vio object
  nonblock | index for a non-blocking socket Only for <UNIX/INET>; othewise it is ignored. nonblock==0 ==> block until a connect is attempted nonblock==1 ==> DO NOT block at all

## Vio_connectFree()

void Vio_connectFree | ( | Vio * | thee | ) |

Purge any output buffers (for <UNIX/INET>, else a no-op)

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  None

Parameters

  thee | Pointer to the Vio object

## Vio_ctor()

Vio * Vio_ctor | ( | const char * | socktype,
|  | const char * | datafrmt,
|  | const char * | hostname,
|  | const char * | filename,
|  | const char * | rwkey
| ) |  |

Construct the Vio object.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  Pointer to newly constructed Vio object

Parameters

  socktype | Pointer to the socket type
  datafrmt | Pointer to the data format
  hostname | Pointer to network address of port
  filename | Pointer to the i/o file name
  rwkey | Pointer to the read/write options

## Vio_ctor2()

int Vio_ctor2 | ( | Vio * | thee,
|  | const char * | socktype,
|  | const char * | datafrmt,
|  | const char * | hostname,
|  | const char * | filename,
|  | const char * | rwkey
| ) |  |

Work routine that Vio_ctor calls to do most of the construction.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  1 on success, 0 on failure

Parameters

  thee | Pointer to the Vio object
  socktype | Pointer to the socket type
  datafrmt | Pointer to the data format
  hostname | Pointer to network address of port
  filename | Pointer to the i/o file name
  rwkey | Pointer to the read/write options

## Vio_dtor()

void Vio_dtor | ( | Vio ** | thee | ) |

Destruct the Vio object.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  None

Parameters

  thee | Pointer to the Vio object

## Vio_dtor2()

void Vio_dtor2 | ( | Vio * | thee | ) |

Work routine that Vio_dtor calls to do most of the destruction.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  None

Parameters

  thee | Pointer to the Vio object

## Vio_printf()

int Vio_printf | ( | Vio * | thee,
|  | char * | parms,
|  |  | ...
| ) |  |

Mimic "printf" from an arbitrary Vio device.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  Number of tokens printed

Parameters

  thee | Pointer to the Vio object
  parms | Pointer to output parameters

## Vio_read()

int Vio_read | ( | Vio * | thee,
|  | char * | buf,
|  | int | bufsize
| ) |  |

Read (up to) bufsize characters into buf from input device.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  Number of bytes read

Parameters

  thee | Pointer to the Vio object
  buf | buffer containing message
  bufsize | number of items (of declared type) in buffer

## Vio_scanf()

int Vio_scanf | ( | Vio * | thee,
|  | char * | parms,
|  |  | ...
| ) |  |

Mimic "scanf" from an arbitrary Vio device.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  Number of tokens read

Parameters

  thee | Pointer to the Vio object
  parms | Pointer to input parameters

## Vio_setCommChars()

void Vio_setCommChars | ( | Vio * | thee,
|  | char * | commChars
| ) |  |

Set the comment character set for I/O stream.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  None

Parameters

  thee | Pointer to the Vio object
  commChars | comment character set

## Vio_setWhiteChars()

void Vio_setWhiteChars | ( | Vio * | thee,
|  | char * | whiteChars
| ) |  |

Set the white character set for I/O stream.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  None

Parameters

  thee | Pointer to the Vio object
  whiteChars | white space character set

## Vio_socketClose()

void Vio_socketClose | ( | Vio ** | sock | ) |

Socket close from read or write.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  None

Parameters

  sock | Socket for reading/writing the external data

## Vio_socketOpen()

Vio * Vio_socketOpen | ( | char * | key,
|  | const char * | iodev,
|  | const char * | iofmt,
|  | const char * | iohost,
|  | const char * | iofile
| ) |  |

Socket open for read or write.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  Socket for reading/writing the external data

Parameters

  key | Pointer to the read/write option
  iodev | Pointer to open device for read/write
  iofmt | Pointer to i/o data format
  iohost | Pointer to i/o address of port
  iofile | Pointer to the i/o file name

## Vio_start()

void Vio_start | ( | void |  | ) |

Start Vio communication layer (init internal variables/buffers)

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  None

## Vio_stop()

void Vio_stop | ( | void |  | ) |

Shutdown Vio communication layer.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  None

## Vio_write()

int Vio_write | ( | Vio * | thee,
|  | char * | buf,
|  | int | bufsize
| ) |  |

Write bufsize characters from buf to output device.

Author
  Michael Holst

Note
  Class Vio: Non-Inlineable methods (vio.c)

Returns
  Number of bytes writen

Parameters

  thee | Pointer to the Vio object
  buf | buffer containing message
  bufsize | number of items (of declared type) in buffer