OC Updated for version 2.0
Defines | Functions
oc.c File Reference
#include "config.h"
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "ocinternal.h"
#include "ocdebug.h"
#include "ocdump.h"
#include "oclog.h"
#include "occlientparams.h"

Go to the source code of this file.

Defines

#define ocverify(o)   ((o) != NULL && (((OCheader*)(o))->magic == OCMAGIC)?1:0)
#define ocverifyclass(o, cl)   ((o) != NULL && (((OCheader*)(o))->occlass == cl)?1:0)
#define OCVERIFYX(k, x, r)   if(!ocverify(x)||!ocverifyclass(x,k)) {return (r);}
#define OCVERIFY(k, x)   OCVERIFYX(k,x,OCTHROW(OC_EINVAL))
#define OCDEREF(T, s, x)   (s)=(T)(x)

Functions

OCerror oc_open (const char *url, OCobject *linkp)
OCerror oc_close (OCobject link)
OCerror oc_fetch (OCobject link, const char *constraint, OCdxd dxdkind, OCflags flags, OCobject *rootp)
OCerror oc_root_free (OCobject link, OCobject ddsroot)
const char * oc_tree_text (OCobject link, OCobject ddsroot)
OCerror oc_dds_properties (OCobject link, OCobject ddsnode, char **namep, OCtype *octypep, OCtype *atomtypep, OCobject *containerp, size_t *rankp, size_t *nsubnodesp, size_t *nattrp)
OCerror oc_dds_name (OCobject link, OCobject ddsnode, char **namep)
OCerror oc_dds_nsubnodes (OCobject link, OCobject ddsnode, size_t *nsubnodesp)
OCerror oc_dds_atomictype (OCobject link, OCobject ddsnode, OCtype *typep)
OCerror oc_dds_class (OCobject link, OCobject ddsnode, OCtype *typep)
OCerror oc_dds_rank (OCobject link, OCobject ddsnode, size_t *rankp)
OCerror oc_dds_attr_count (OCobject link, OCobject ddsnode, size_t *nattrp)
OCerror oc_dds_root (OCobject link, OCobject ddsnode, OCobject *rootp)
OCerror oc_dds_container (OCobject link, OCobject ddsnode, OCobject *containerp)
OCerror oc_dds_ithfield (OCobject link, OCobject ddsnode, size_t index, OCobject *fieldnodep)
OCerror oc_dds_gridarray (OCobject link, OCobject grid, OCobject *arraynodep)
OCerror oc_dds_gridmap (OCobject link, OCobject grid, size_t index, OCobject *mapnodep)
OCerror oc_dds_dimensions (OCobject link, OCobject ddsnode, OCobject *dims)
OCerror oc_dds_ithdimension (OCobject link, OCobject ddsnode, size_t index, OCobject *dimidp)
OCerror oc_dimension_properties (OCobject link, OCobject ddsnode, size_t *sizep, char **namep)
OCerror oc_dds_dimensionsizes (OCobject link, OCobject ddsnode, size_t *dimsizes)
OCerror oc_dds_attr (OCobject link, OCobject ddsnode, size_t index, char **namep, OCtype *octypep, size_t *nvaluesp, char **strings)
void oc_reclaim_strings (size_t n, char **svec)
OCerror oc_das_attr_count (OCobject link, OCobject dasnode, size_t *nvaluesp)
OCerror oc_das_attr (OCobject link, OCobject dasnode, size_t index, OCtype *etypep, char **valuep)
size_t oc_typesize (OCtype etype)
const char * oc_typetostring (OCtype octype)
OCerror oc_typeprint (OCtype etype, void *value, size_t bufsize, char *buffer)
const char * oc_errstring (OCerror err)
const char * oc_clientparam_get (OCobject link, const char *param)
OCerror oc_svcerrordata (OCobject link, char **codep, char **msgp, long *httpp)
OCerror oc_raw_xdrsize (OCobject link, OCobject ddsroot, size_t *sizep)
OCerror oc_update_lastmodified_data (OCobject link)
long oc_get_lastmodified_data (OCobject link)
int oc_dumpnode (OCobject link, OCobject ddsroot)
OCerror oc_dds_dd (OCobject link, OCobject ddsroot, int level)
OCerror oc_dds_ddnode (OCobject link, OCobject ddsroot)
OCerror oc_data_ddpath (OCobject link, OCobject datanode, char **resultp)
OCerror oc_data_ddtree (OCobject link, OCobject ddsroot)
OCDT oc_data_mode (OCobject link, OCobject datanode)
OCerror oc_data_free (OCobject link, OCobject datanode)
OCerror oc_dds_free (OCobject link, OCobject dds0)
OCerror oc_merge_das (OCobject link, OCobject dasroot, OCobject ddsroot)
OCerror oc_data_getroot (OCobject link, OCobject ddsroot, OCobject *datarootp)
OCerror oc_data_ithfield (OCobject link, OCobject datanode, size_t index, OCobject *fieldp)
OCerror oc_data_gridarray (OCobject link, OCobject grid, OCobject *arraydatap)
OCerror oc_data_gridmap (OCobject link, OCobject grid, size_t index, OCobject *mapdatap)
OCerror oc_data_container (OCobject link, OCobject datanode, OCobject *containerp)
OCerror oc_data_root (OCobject link, OCobject datanode, OCobject *rootp)
OCerror oc_data_ithelement (OCobject link, OCobject datanode, size_t *indices, OCobject *elementp)
OCerror oc_data_ithrecord (OCobject link, OCobject datanode, size_t index, OCobject *recordp)
OCerror oc_data_position (OCobject link, OCobject datanode, size_t *indices)
OCerror oc_data_recordcount (OCobject link, OCobject datanode, size_t *countp)
OCerror oc_data_ddsnode (OCobject link, OCobject datanode, OCobject *nodep)
OCerror oc_data_octype (OCobject link, OCobject datanode, OCtype *typep)
int oc_data_indexable (OCobject link, OCobject datanode)
int oc_data_indexed (OCobject link, OCobject datanode)
OCerror oc_data_read (OCobject link, OCobject datanode, size_t *start, size_t *edges, size_t memsize, void *memory)

Detailed Description

Definition in file oc.c.


Define Documentation

#define OCDEREF (   T,
  s,
 
)    (s)=(T)(x)
#define OCVERIFY (   k,
 
)    OCVERIFYX(k,x,OCTHROW(OC_EINVAL))
#define ocverify (   o)    ((o) != NULL && (((OCheader*)(o))->magic == OCMAGIC)?1:0)

Definition at line 24 of file oc.c.

#define ocverifyclass (   o,
  cl 
)    ((o) != NULL && (((OCheader*)(o))->occlass == cl)?1:0)

Definition at line 26 of file oc.c.

#define OCVERIFYX (   k,
  x,
 
)    if(!ocverify(x)||!ocverifyclass(x,k)) {return (r);}

Definition at line 28 of file oc.c.

Referenced by oc_clientparam_get(), and oc_tree_text().


Function Documentation

OCerror oc_data_container ( OCobject  link,
OCobject  datanode,
OCobject containerp 
)

Obtain the data instance corresponding to the container of a specied instance object.

Parameters:
[in]linkThe link through which the server is accessed.
[in]datanodeThe data instance of interest
[out]containerpA pointer into which the container instance is stored.
Return values:
OC_NOERRThe procedure executed normally.
OC_EINVALThe data object has no container (=> it is a Dataset instance).
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 929 of file oc.c.

References OC_EINVAL, OC_NOERR, OCDEREF, and OCVERIFY.

OCerror oc_data_ddpath ( OCobject  link,
OCobject  datanode,
char **  resultp 
)

Definition at line 1586 of file oc.c.

References OC_NOERR, OCDEREF, and OCVERIFY.

OCerror oc_data_ddsnode ( OCobject  link,
OCobject  datanode,
OCobject nodep 
)

Return the dds node that is the "template" for this data instance.

Parameters:
[in]linkThe link through which the server is accessed.
[in]datanodeThe data node instance of interest.
[out]nodepA pointer into which the ddsnode is stored.
Return values:
OC_NOERRThe procedure executed normally.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 1123 of file oc.c.

References OC_EINVAL, OC_NOERR, OCDEREF, and OCVERIFY.

OCerror oc_data_ddtree ( OCobject  link,
OCobject  ddsroot 
)

Definition at line 1605 of file oc.c.

References OC_NOERR, OCDEREF, and OCVERIFY.

OCerror oc_data_free ( OCobject  link,
OCobject  datanode 
)

Definition at line 1636 of file oc.c.

References OC_NOERR.

OCerror oc_data_getroot ( OCobject  link,
OCobject  ddsroot,
OCobject datarootp 
)

Data Management

Obtain the datanode root associated with a DataDDS tree.

Parameters:
[in]linkThe link through which the server is accessed.
[in]ddsrootThe DataDDS tree root.
[out]datarootpA pointer into which the datanode root is stored.
Return values:
OC_NOERRThe procedure executed normally.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 822 of file oc.c.

References OC_EINVAL, OC_NOERR, OCDEREF, and OCVERIFY.

OCerror oc_data_gridarray ( OCobject  link,
OCobject  grid,
OCobject arraydatap 
)

Obtain the data instance corresponding to the array field of a Grid container instance. Equivalent to oc_data_ithfield(link,grid,0,arraydata).

Parameters:
[in]linkThe link through which the server is accessed.
[in]gridThe grid container instance of interest.
[out]arraydatapA pointer into which the grid array instance is stored.
Return values:
OC_NOERRThe procedure executed normally.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 888 of file oc.c.

References oc_data_ithfield().

OCerror oc_data_gridmap ( OCobject  link,
OCobject  grid,
size_t  index,
OCobject mapdatap 
)

Obtain the data instance corresponding to the ith map field of a Grid container instance. Equivalent to oc_data_ithfield(link,grid-container,index+1,mapdata). Note that Map indices start at zero.

Parameters:
[in]linkThe link through which the server is accessed.
[in]gridThe grid container instance of interest.
[in]indexThe map index of the map to return.
[out]mapdatapA pointer into which the grid map instance is stored.
Return values:
OC_NOERRThe procedure executed normally.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 909 of file oc.c.

References oc_data_ithfield().

int oc_data_indexable ( OCobject  link,
OCobject  datanode 
)

Return the value one (1) if the specified data instance is indexable. Indexable means that the data instance is a dimensioned Structure or it is a Sequence (but not a record in a Sequence).

Parameters:
[in]linkThe link through which the server is accessed.
[in]datanodeThe data node instance of interest.
Return values:
one(1)if the specified data instance is indexable.
zero(0)otherwise.

Definition at line 1178 of file oc.c.

References OCDEREF, and OCVERIFY.

int oc_data_indexed ( OCobject  link,
OCobject  datanode 
)

Return the value one (1) if the specified data instance was obtained by applying either the procedure oc_data_ithelement or oc_data_ithrecord. This means that the operation oc_data_position() will succeed when applied to this data instance.

Parameters:
[in]linkThe link through which the server is accessed.
[in]datanodeThe data node instance of interest.
Return values:
one(1)if the specified data instance has an index.
zero(0)otherwise.

Definition at line 1202 of file oc.c.

References OCDEREF, and OCVERIFY.

OCerror oc_data_ithelement ( OCobject  link,
OCobject  datanode,
size_t *  indices,
OCobject elementp 
)

Return the data of a dimensioned Structure corresponding to the element instance specified by the indices argument.

Parameters:
[in]linkThe link through which the server is accessed.
[in]datanodeThe data node instance of interest.
[in]indicesA vector of indices specifying the element instance to return. This vector must be allocated and free'd by the caller.
[out]elementpA pointer into which the element instance is stored.
Return values:
OC_NOERRThe procedure executed normally.
OC_EBADTYPEThe data instance was not of type OC_Structure or was a scalar.
OC_EINDEXThe indices specified an illegal element.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 996 of file oc.c.

References OC_EINVAL, OC_NOERR, OCDEREF, and OCVERIFY.

OCerror oc_data_ithfield ( OCobject  link,
OCobject  datanode,
size_t  index,
OCobject fieldp 
)

Obtain the data instance corresponding to the i'th field of a data node instance that itself is a container instance.

Parameters:
[in]linkThe link through which the server is accessed.
[in]datanodeThe container data node instance of interest.
[in]indexThe index (starting at zero) of the field instance to return.
[out]fieldpA pointer into which the i'th field instance is stored.
Return values:
OC_NOERRThe procedure executed normally.
OC_EINDEXThe index was greater than the number of fields.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 856 of file oc.c.

References OC_EINVAL, OC_NOERR, OCDEREF, and OCVERIFY.

Referenced by oc_data_gridarray(), and oc_data_gridmap().

OCerror oc_data_ithrecord ( OCobject  link,
OCobject  datanode,
size_t  index,
OCobject recordp 
)

Return the i'th record instance of a Sequence data instance.

Parameters:
[in]linkThe link through which the server is accessed.
[in]datanodeThe data node instance of interest.
[in]indexThe record instance to return.
[out]recordpA pointer into which the record instance is stored.
Return values:
OC_NOERRThe procedure executed normally.
OC_EBADTYPEThe data instance was not of type OC_Sequence
OC_EINDEXThe indices is larger than the number of records of the Sequence.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 1030 of file oc.c.

References OC_EINVAL, OC_NOERR, OCDEREF, and OCVERIFY.

OCDT oc_data_mode ( OCobject  link,
OCobject  datanode 
)

Definition at line 1623 of file oc.c.

References OCDEREF, and OCVERIFY.

OCerror oc_data_octype ( OCobject  link,
OCobject  datanode,
OCtype typep 
)

Return the OCtype of the ddsnode that is the "template" for this data instance. This is a convenience function since it can be obtained using a combination of other API procedures.

Parameters:
[in]linkThe link through which the server is accessed.
[in]datanodeThe data node instance of interest.
[out]typepA pointer into which the OCtype value is stored.
Return values:
OC_NOERRThe procedure executed normally.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 1151 of file oc.c.

References OC_EINVAL, OC_NOERR, OCDEREF, and OCVERIFY.

OCerror oc_data_position ( OCobject  link,
OCobject  datanode,
size_t *  indices 
)

Return the i'th record instance of a Sequence data instance. Return the indices for this data instance; Assumes the data was obtained using oc_data_ithelement or oc_data_ithrecord.

Parameters:
[in]linkThe link through which the server is accessed.
[in]datanodeThe data node instance of interest.
[out]indicesA vector into which the indices of the data instance are stored. If the data instance is a record, then only indices[0] is used.
Return values:
OC_NOERRThe procedure executed normally.
OC_EBADTYPEThe data instance was not of type OC_Sequence or it was not a dimensioned instance of OC_Structure.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 1067 of file oc.c.

References OC_EINVAL, OCDEREF, and OCVERIFY.

OCerror oc_data_read ( OCobject  link,
OCobject  datanode,
size_t *  start,
size_t *  edges,
size_t  memsize,
void *  memory 
)

This procedure does the work of actually extracting data from a leaf instance of a data tree and storing it into memory for use by the calling code. The data instance must be referencing either a scalar primitive value or an array of primitive values. That is, its oc_data_octype() value must be OCatomic. If the variable is a scalar, then the index and count vectors will be ignored.

Parameters:
[in]linkThe link through which the server is accessed.
[in]datanodeThe data node instance of interest.
[in]startA vector of indices specifying the starting element to return.
[in]edgesA vector of indices specifying the count in each dimension of the number of elements to return.
[in]memsizeThe size (in bytes) of the memory argument.
[out]memoryUser allocated memory into which the extracted data is to be stored. The caller is responsible for allocating and free'ing this argument.
Return values:
OC_NOERRThe procedure executed normally.
OC_EINVALThe memsize argument is too small to hold the specified data.
OC_EINVALCOORDSThe start and/or edges argument is outside the range of legal indices.
OC_EDATADDSThe data retrieved from the server was malformed and the read request cannot be completed.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 1246 of file oc.c.

References OC_EDATADDS, OC_EINVAL, OC_EINVALCOORDS, OC_NOERR, OCDEREF, and OCVERIFY.

OCerror oc_data_recordcount ( OCobject  link,
OCobject  datanode,
size_t *  countp 
)

Return the number of records associated with a Sequence data object. Be warned that applying this procedure to a record data instance (as opposed to an instance representing a whole Sequence) will return an error. More succinctly, the data object's OCtype must be of type OC_Sequence and oc_data_indexable() must be true.

Parameters:
[in]linkThe link through which the server is accessed.
[in]datanodeThe data node instance of interest.
[out]countpA pointer into which the record count is stored.
Return values:
OC_NOERRThe procedure executed normally.
OC_EBADTYPEThe data instance was not of type OC_Sequence or it was a record data instance.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 1098 of file oc.c.

References OC_EINVAL, OCDEREF, and OCVERIFY.

OCerror oc_data_root ( OCobject  link,
OCobject  datanode,
OCobject rootp 
)

Obtain the data instance corresponding to the root of the tree of which the specified instance object is a part.

Parameters:
[in]linkThe link through which the server is accessed.
[in]datanodeThe data instance of interest
[out]rootpA pointer into which the root instance is stored.
Return values:
OC_NOERRThe procedure executed normally.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 960 of file oc.c.

References OC_EINVAL, OC_NOERR, OCDEREF, and OCVERIFY.

OCerror oc_dds_dd ( OCobject  link,
OCobject  ddsroot,
int  level 
)

Definition at line 1561 of file oc.c.

References OC_NOERR, OCDEREF, and OCVERIFY.

OCerror oc_dds_ddnode ( OCobject  link,
OCobject  ddsroot 
)

Definition at line 1575 of file oc.c.

References OC_NOERR, OCDEREF, and OCVERIFY.

OCerror oc_dds_free ( OCobject  link,
OCobject  dds0 
)

Definition at line 1645 of file oc.c.

References OC_NOERR.

int oc_dumpnode ( OCobject  link,
OCobject  ddsroot 
)

Definition at line 1543 of file oc.c.

References OC_NOERR, OCDEREF, and OCVERIFY.

long oc_get_lastmodified_data ( OCobject  link)

Definition at line 1534 of file oc.c.

References OCDEREF, and OCVERIFY.

OCerror oc_merge_das ( OCobject  link,
OCobject  dasroot,
OCobject  ddsroot 
)

Node Interconnection Management

As a rule, the attributes of an object are accessed using the oc_dds_attr procedure rather than by traversing a DAS. In order to support this, the oc_merge_das procedure annotates a DDS node with attribute values taken from a specified DAS node.

Parameters:
[in]linkThe link through which the server is accessed.
[in]dasrootThe root object of a DAS tree.
[in]ddsrootThe root object of a DDS (or DataDDS) tree.
Return values:
OC_NOERRThe procedure executed normally.
OtherErrorOne of the arguments (link, etc.) was invalid.

Definition at line 788 of file oc.c.

References OCDEREF, and OCVERIFY.

OCerror oc_raw_xdrsize ( OCobject  link,
OCobject  ddsroot,
size_t *  sizep 
)

Definition at line 1507 of file oc.c.

References OC_EINVAL, OC_NOERR, OCDATADDS, OCDEREF, and OCVERIFY.

OCerror oc_update_lastmodified_data ( OCobject  link)

Definition at line 1525 of file oc.c.

References OCDEREF, and OCVERIFY.