MALOC 0.1
Classes | Files | Typedefs | Enumerations | Functions

Vio class

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

Classes

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

Files

file  vio.h
 

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


Typedefs

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

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

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

typedef struct sVio Vio

Declaration of the Vio class as the Vio structure.

Author:
Michael Holst
typedef enum VIOfrmt VIOfrmt

Parameter for compression type (XDR,ASC)

Author:
Michael Holst
typedef enum VIOrwkey VIOrwkey

Parameter for rw type (R,RW)

Author:
Michael Holst
typedef enum VIOtype VIOtype

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

Author:
Michael Holst

Enumeration Type Documentation

enum VIOfrmt

Parameter for compression type (XDR,ASC)

Author:
Michael Holst
Enumerator:
VIO_NO_FRMT 
VIO_XDR 
VIO_ASC 
enum VIOrwkey

Parameter for rw type (R,RW)

Author:
Michael Holst
Enumerator:
VIO_NO_RW 
VIO_R 
VIO_W 
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

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:
theePointer to the Vio object
nonblockindex 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
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:
theePointer to the Vio object
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:
theePointer to the Vio object
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:
theePointer to the Vio object
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:
theePointer to the Vio object
bufbuffer containing message
bufsizenumber of items (of declared type) in buffer
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:
theePointer to the Vio object
nonblockindex 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
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:
theePointer to the Vio object
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:
socktypePointer to the socket type
datafrmtPointer to the data format
hostnamePointer to network address of port
filenamePointer to the i/o file name
rwkeyPointer to the read/write options
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:
theePointer to the Vio object
socktypePointer to the socket type
datafrmtPointer to the data format
hostnamePointer to network address of port
filenamePointer to the i/o file name
rwkeyPointer to the read/write options
void Vio_dtor ( Vio **  thee)

Destruct the Vio object.

Author:
Michael Holst
Note:
Class Vio: Non-Inlineable methods (vio.c)
Returns:
None
Parameters:
theePointer to the Vio object
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:
theePointer to the Vio object
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:
theePointer to the Vio object
parmsPointer to output parameters
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:
theePointer to the Vio object
bufbuffer containing message
bufsizenumber of items (of declared type) in buffer
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:
theePointer to the Vio object
parmsPointer to input parameters
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:
theePointer to the Vio object
commCharscomment character set
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:
theePointer to the Vio object
whiteCharswhite space character set
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:
sockSocket for reading/writing the external data
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:
keyPointer to the read/write option
iodevPointer to open device for read/write
iofmtPointer to i/o data format
iohostPointer to i/o address of port
iofilePointer to the i/o file name
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
void Vio_stop ( void  )

Shutdown Vio communication layer.

Author:
Michael Holst
Note:
Class Vio: Non-Inlineable methods (vio.c)
Returns:
None
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:
theePointer to the Vio object
bufbuffer containing message
bufsizenumber of items (of declared type) in buffer