RSA Security logo

RSA BSAFE Cert-C
API Reference

IO_FUNCS Reference

Stores pointers to the stream service provider functions in Cert C.

In this case, there is one implementation, the Cert-C Stream service provider. Use S_InitializeFileIO() to initialize funcs io function pointer to the Cert-C Stream service provider implementation of IO_FUNCS.

#include <iospi.h>

00033 typedef struct io_funcs {
00046   void (*Finalize) (
00047     CERTC_CTX       ctx,                /* Cert-C context */
00048     POINTER         handle);            /* provider handle */
00049 
00124   int (*Open) (
00125     CERTC_CTX       ctx,                /* Cert-C context */
00126     POINTER         handle,             /* provider handle */
00127     POINTER         name,               /* name of stream */
00128     unsigned int    flags,              /* stream flags */
00129     POINTER         *streamID);         /* (out) stream identifier */
00130 
00152   int (*Close) (
00153     CERTC_CTX       ctx,                /* Cert-C context */
00154     POINTER         handle,             /* provider handle */
00155     POINTER         streamID);          /* stream identifier */
00156 
00198   int (*GetLine) (
00199     CERTC_CTX       ctx,                /* Cert-C context */
00200     POINTER         handle,             /* provider handle */
00201     POINTER         streamID,           /* stream identifier */
00202     char            *str,               /* storage for string */
00203     unsigned int    maxLen);            /* max # of characters to read */
00204 
00232   int (*PutLine) (
00233     CERTC_CTX       ctx,                /* Cert-C context */
00234     POINTER         handle,             /* provider handle */
00235     POINTER         streamID,           /* stream identifier */
00236     char            *str);              /* output string */
00237 
00278   int (*Read) (
00279     CERTC_CTX       ctx,                /* Cert-C context */
00280     POINTER         handle,             /* provider handle */
00281     POINTER         streamID,           /* stream identifier */
00282     unsigned char   *buf,               /* storage for data */
00283     unsigned int    len,                /* # of bytes to read */
00284     unsigned int    *actualLen);        /* (out) # of bytes actually read */
00285 
00314   int (*Write) (
00315     CERTC_CTX       ctx,                /* Cert-C context */
00316     POINTER         handle,             /* provider handle */
00317     POINTER         streamID,           /* stream identifier */
00318     unsigned char   *buf,               /* output buffer */
00319     unsigned int    len);               /* # of bytes to write */
00320 
00343   int (*Rewind) (
00344     CERTC_CTX       ctx,                /* Cert-C context */
00345     POINTER         handle,             /* provider handle */
00346     POINTER         streamID);          /* stream identifier */
00347 } IO_FUNCS;

Data Fields

void(* Finalize )(CERTC_CTX ctx, POINTER handle)
 Frees resources associated with the specified service provider handle, including freeing memory allocated during service provider initialization. More...

int(* Open )(CERTC_CTX ctx, POINTER handle, POINTER name, unsigned int flags, POINTER *streamID)
 Opens a file stream managed by the Cert-C Stream service provider. More...

int(* Close )(CERTC_CTX ctx, POINTER handle, POINTER streamID)
 Closes a previously opened input or output stream. More...

int(* GetLine )(CERTC_CTX ctx, POINTER handle, POINTER streamID, char *str, unsigned int maxLen)
 Reads one line of characters, terminated by a newline character ('\n'). More...

int(* PutLine )(CERTC_CTX ctx, POINTER handle, POINTER streamID, char *str)
 Writes a NUL-terminated string to the specified stream, followed by a newline character ('\n'). More...

int(* Read )(CERTC_CTX ctx, POINTER handle, POINTER streamID, unsigned char *buf, unsigned int len, unsigned int *actualLen)
 Reads the indicated number of bytes from the specified stream. More...

int(* Write )(CERTC_CTX ctx, POINTER handle, POINTER streamID, unsigned char *buf, unsigned int len)
 Writes the indicated number of bytes to the specified stream. More...

int(* Rewind )(CERTC_CTX ctx, POINTER handle, POINTER streamID)
 Repositions the point in the stream where subsequent inputs or outputs can occur to the beginning of that stream. More...


Field Documentation (alphabetical)

int(* io_funcs::Close)( CERTC_CTX ctx, POINTER handle, POINTER streamID)
 

Closes a previously opened input or output stream. This function is implemented by the Cert-C Stream service provider.

Parameters:
ctx This input parameter points to an initialized Cert-C context handle.
handle This input parameter points to a copy of the Cert-C Stream service provider handle.
streamID This input parameter points to the stream ID returned by a previous call to the service provider's Open function.
Returns:
If successful, returns 0. If not, returns a Cert-C error code.

void(* io_funcs::Finalize)( CERTC_CTX ctx, POINTER handle)
 

Frees resources associated with the specified service provider handle, including freeing memory allocated during service provider initialization. Cert-C calls Finalize when a service provider's instance is unregistered.

This function is implemented by the Cert-C Stream service provider.

int(* io_funcs::GetLine)( CERTC_CTX ctx, POINTER handle, POINTER streamID, char *str, unsigned int maxLen)
 

Reads one line of characters, terminated by a newline character ('\n'). GetLine reads characters from the current position in the stream up to and including the next newline character. It copies the characters read, except the newline, into the indicated string buffer, and then appends a NUL character to the end of the string. If maxLen -1 characters are read without a newline, GetLine copies the characters read to the string buffer and terminates the buffer with a NUL.

This function is implemented by the Cert-C Stream service provider.

Parameters:
ctx This input parameter points to an initialized Cert-C context handle.
handle This input parameter points to a copy of the Cert-C Stream service provider handle.
streamID This input parameter points to the stream ID returned by a previous call to the service provider's Open function.
str This is both an input and output parameter. As an input paramiter, it points to an empty buffer. As an output parameter, it points to a buffer where a NUL-terminated string of characters is returned.
maxLen This input parameter determines the maximum number of characters that may be read by GetLine.
Returns:
If successful, returns 0. If not, returns a Cert-C error code.

int(* io_funcs::Open)( CERTC_CTX ctx, POINTER handle, POINTER name, unsigned int flags, POINTER *streamID)
 

Opens a file stream managed by the Cert-C Stream service provider. This function allows a file to be opened in either binary or text mode. The Open function's action depends on the IO_* flag constant or the flag constant combination passed to the function. You can open the file stream for reading or writing, or for a combination of both. This function also allows a file to be created if it does not exist, or to be truncated if it does exist.

This function is implemented by the Cert-C Stream service provider.

Parameters:
ctx This input parameter points to an initialized Cert-C context handle.
handle This input parameter points to a copy of the Cert-C Stream service provider handle.
name This input parameter points to the NUL-terminated file name to be opened.
flags This input parameter contains flags that can modify the behavior of the service provider for this stream. The flags should be one or more of the IO_* constants combined by the bitwise- OR operator, as listed in the following table.
IO_* Constants

The following table describes the Cert-C Stream service provider supported IO_* flag combinations and their correspondence to standard file open modes:

Flag Combination ModeComments
IO_RDONLYr The stream is opened for input only.
IO_WRONLYr+ The stream is opened for reading and writing. Write-only mode by itself is not supported and is converted to read-write.
IO_RDWRr+ The stream is opened for reading and writing.
IO_WRONLY|IO_CREAT|IO_TRUNC w The stream is opened for writing. If it does not exist, it is created. If it already exists, it is truncated.
IO_RDWR|IO_CREAT|IO_TRUNCw+ The stream is opened for reading and writing. If it does not exist, it is created. If it already exists, it is truncated.
IO_BINARYb This flag may be combined with any of the previous flag combinations listed here. If present, the stream is opened in binary mode. Otherwise, the stream is opened in text mode.

Parameters:
streamID This output parameter points to the location where the opened stream identifier of the service provider is stored.
Returns:
If successful, returns 0. If not, returns a Cert-C error code.

int(* io_funcs::PutLine)( CERTC_CTX ctx, POINTER handle, POINTER streamID, char *str)
 

Writes a NUL-terminated string to the specified stream, followed by a newline character ('\n'). This function is implemented by the Cert-C Stream service provider.

Parameters:
ctx This input parameter points to an initialized Cert-C context handle.
handle This input parameter points to a copy of the Cert-C Stream service provider handle.
streamID This input parameter points to the stream ID returned by a previous call to the service provider's Open function.
str This input parameter points to a NUL-terminated string of characters that is to be written to the specified stream.
Returns:
If successful, returns 0. If not, returns a Cert-C error code.

int(* io_funcs::Read)( CERTC_CTX ctx, POINTER handle, POINTER streamID, unsigned char *buf, unsigned int len, unsigned int *actualLen)
 

Reads the indicated number of bytes from the specified stream. If the end of the stream is reached before the requested number of bytes is read, the actual number of bytes read is returned in the actualLen parameter.

This function is implemented by the Cert-C Stream service provider.

Parameters:
ctx This input parameter points to an initialized Cert-C context handle.
handle This input parameter points to a copy of the Cert-C Stream service provider handle.
streamID This input parameter points to the stream ID returned by a previous call to the service provider's Open function.
buf This is both an input and output parameter. As an input parameter, it points to an empty buffer. As an output parameter, it points to a buffer where bytes are copied to after being read.
len This input parameter indicates the number of bytes to read from the stream.
actualLen This output parameter points to the location where the actual number of bytes read is returned. The actual number of bytes read may be less than or equal to the number of bytes requested.
Returns:
If successful, returns 0. If not, returns a Cert-C error code. The Cert-C status code E_EOS is returned only when the end-of-stream is reached.

int(* io_funcs::Rewind)( CERTC_CTX ctx, POINTER handle, POINTER streamID)
 

Repositions the point in the stream where subsequent inputs or outputs can occur to the beginning of that stream. This call may do nothing if the stream is an interactive communications channel.

This function is implemented by the Cert-C Stream service provider.

Parameters:
ctx This input parameter points to an initialized Cert-C context handle.
handle This input parameter points to a copy of the Cert-C Stream service provider's handle.
streamID This input parameter points to the stream ID returned by a previous call to the service provider's Open function.
Returns:
This function always returns 0 (zero).

int(* io_funcs::Write)( CERTC_CTX ctx, POINTER handle, POINTER streamID, unsigned char *buf, unsigned int len)
 

Writes the indicated number of bytes to the specified stream. This function is implemented by the Cert-C Stream service provider.

Parameters:
ctx This input parameter points to an initialized Cert-C context handle.
handle This input parameter points to a copy of the Cert-C Stream service provider handle.
streamID This input parameter points to the stream ID returned by a previous call to the service provider's Open function.
buf This input parameter points to the array of bytes that are to be written to the stream.
len This input parameter indicates the number of bytes to write to the stream.
Returns:
If successful, returns 0. If not, returns a Cert-C error code.


The documentation for this struct was generated from the following file:


RSA BSAFE® Cert-C 2.7 API Reference