#ifndef fsubagentArray_H #define fsubagentArray_H #include "fsubagentRow.h" #include #ifdef __cplusplus extern "C" { #endif /* First two bytes (in big endian order) written by fsubagentArray_toBuf() */ #define fsubagentArray_MAGIC 0x5341 /* SA */ /**---------------------------------------------------------------------- An array of fsubagentRows; holds a rectangular array of SNMP variables. Each row has the same number of columns. The entries of each row have type as indicated by the corresponding entry in the array's constraints object. In the SNMP variables fooTable.fooEntry.fooMember.index barTable.barEntry.barMember.index1.index2 the final index is you pass to fsubagentArray_getRow() to locate the proper row. The only methods for use by the app programmer are getMax{Row,Column}(), getRow(), and createRow(). The rest of its methods are not meant to be called directly by the programmer; see fsubagent.h. The module is implemented in C using an object-oriented idiom which provides good encapsualation. Since all data members of fsubagentArray are private, the structure is only named here; the full definition is private to fsubagentArray.c. -----------------------------------------------------------------------*/ typedef struct fsubagentArray_s fsubagentArray; /* class fsubagentArray { */ /**---------------------------------------------------------------------- Create a fsubagentArray. @param constraints = stable pointer to constraints on all rows @return initialized fsubagentArray * on success, NULL on failure -----------------------------------------------------------------------*/ fsubagentArray *fsubagentArray_new(const fsubagentRowConstraints *c); /**---------------------------------------------------------------------- Delete a fsubagentArray and release any resources it has allocated. -----------------------------------------------------------------------*/ void fsubagentArray_delete(fsubagentArray *); /**---------------------------------------------------------------------- Retrieve index of highest row currently in this array. -----------------------------------------------------------------------*/ int fsubagentArray_getMaxRow(fsubagentArray *); /**---------------------------------------------------------------------- Retrieve index of highest column in this array. -----------------------------------------------------------------------*/ int fsubagentArray_getMaxColumn(fsubagentArray *); /**---------------------------------------------------------------------- Retrieve pointer to a row from a 2d array @param index = positive index (>= 1) to row of 2d array @return persistant row pointer on success, NULL on failure -----------------------------------------------------------------------*/ fsubagentRow *fsubagentArray_getRow(fsubagentArray *, int index); /**---------------------------------------------------------------------- Retrieve pointer to the row containing a given identifier, if any. For instance, to persist the array partition.pname.1 = "/var" partition.psize.1 = 1000 partition.pname.2 = "/usr" partition.psize.2 = 1000 properly, you'd call usr_row = fsubagentArray_getRowByStr(array, DIMIB_pname, "/usr", 0); where DIMIB_pname is the OID component for 'pname' (provided by the mib2h.pl mib compiler) to get a pointer for the row corresponding to "/usr". @param colindex which element of the row to compare with val @param val the nul-terminated string to compare with @param prowindex where to store index of this row in the array (or NULL) @return persistant row pointer on success, NULL on failure -----------------------------------------------------------------------*/ fsubagentRow *fsubagentArray_getRowByStr(fsubagentArray *, int colindex, const char *val, int *prowindex); /**---------------------------------------------------------------------- Create a new row in this Array. @parameter pIndex - the index of the new row is stored in *pIndex @return persistant row pointer on success, NULL on failure -----------------------------------------------------------------------*/ fsubagentRow *fsubagentArray_createRow(fsubagentArray *, int *pIndex); /**---------------------------------------------------------------------- Load new current array contents from buffer. Must obey constraints this array was created with. @param buf Buffer to load from. @param buflen Number of bytes of data in buffer. @return 0 on success, Unix error code on failure -----------------------------------------------------------------------*/ int fsubagentArray_fromBuf(fsubagentArray *, const char *buf, int buflen); /**---------------------------------------------------------------------- Save new current array contents to buffer. @param buf Buffer to save to. @param bufsize Size of buffer in bytes. @param bufused Pointer to where to store number of buffer bytes used. @return 0 on success, Unix error code on failure -----------------------------------------------------------------------*/ int fsubagentArray_toBuf(fsubagentArray *, char *buf, int bufsize, int *bufused); /* } */ #ifdef __cplusplus } #endif #endif