DSI APIs:

The DSI APIs are modeled after the UNIX file manipulation commands (open, close etc.) with a few extra parameters that are specific to the concepts of DSI. This section provides the syntax and semantics of the different DSI APIs available to the NetSolve user.

DSI_FILE* ns_dsi_open(char* host_name, int flag, int permissions, int size, dsi_type storage_system);

host_name

Name of the host where the IBP server resides.

flag

This flag has the same meaning as the flag in open() calls in C. Specifically O_CREAT is used for creating a dsi file and so on.

permissions

While creating the file with O_CREAT flag, the user can specify the permissions for himself and others. The permissions are similar to the ones used in UNIX. Hence if the user wants to set read, write, execute permissions for himself and read and write permissions for others, he would call ns_dsi_open with 74 as the value for the permissions.

size

Represents the maximum length of the DSI file. Write or read operations over this size limit will return an error.

storage_system

At present, IBP.

ns_dsi_open() is used for allocating a chunk of storage in the IBP storage. On success, ns_dsi_open returns a pinter to the DSI file. On failure, returns NULL. Following are the various error values set in case of failure.

NetSolveUnknownDsiFile

If the file does not exist and if the file is opened without O_CREAT.

NetSolveIBPAllocateError

Error while allocating IBP storage.

NetSolveDsiDisabled

If DSI is not enabled in the NetSolve configuration.

int ns_dsi_close(DSI_FILE* dsi_file);

dsi_file

Pointer to the DSI file.

ns_dsi_close() is used for closing a DSI file.

On success returns 1. On failure, returns -1. Following are the various error values set in case of failure.

NetSolveIBPManageError

Error in IBP internals while closing.

NetSolveDsiDisabled

If DSI is not enabled in the NetSolve configuration.

DSI_OBJECT* ns_dsi_write_vector(DSI_FILE* dsi_file, void* data, int count, int data_type);

dsi_file

The name of the DSI file where the vector will be written.

data

Vector to write to the DSI storage.

count

Number of elements in the vector.

data_type

One of netsolve data types.

ns_dsi_write_vector() is used for writing a vector of a particular datatype to a DSI file.

On success, ns_dsi_write_vector() returns a pointer to the DSI object created for the vector. On failure, returns NULL. Following are the various error values set in case of failure.

NetSolveIBPStoreError

Error while storing the vector in IBP.

NetSolveDsiEACCESS

Not enough permissions for writing to the DSI file.

NetSolveDsiDisabled

If DSI is not enabled in the NetSolve configuration.

DSI_OBJECT* ns_dsi_write_matrix(DSI_FILE* dsi_file, void* data, int rows, int cols, int data_type);

Same functionality and return values as ns_dsi_write_vector() except ns_dsi_write_matrix() is used to write matrix of rows rows and cols columns.

int ns_dsi_read_vector(DSI_OBJECT* dsi_obj, void* data, int count, int data_type);

dsi_obj

Pointer to the DSI object that contains the data to read.

data

Actual vector to read.

count

Number of elements of the vector to read.

data_type

One of NetSolve data types.

On success, returns the number of elements read. On failure, returns -1. Following are the various error values set in case of failure.

NetSolveIBPLoadError

Error while loading the vector from IBP.

NetSolveDsiEACCESS

Not enough permissions for reading from the DSI file.

NetSolveDsiDisabled

If DSI is not enabled in the NetSolve configuration.

int ns_dsi_read_matrix(DSI_OBJECT* dsi_obj, void* data, int rows, int cols, int data_type);

Same functionality and return values as ns_dsi_read_vector() except ns_dsi_read_matrix() is used to read matrix of rows rows and cols columns.