Obtain status information

After you have a valid LO-status structure, you can use the accessor functions to obtain the status information from this structure.

The following table shows the status information that an LO-status structure contains and the corresponding LO-status accessor functions.
Table 1. Status information in the LO-status structure
Status information LO-status accessor function
Last-access time

This value is available only if the last-access time attribute (MI_LO_ATTR_KEEP_LASTACCESS_TIME) is set for this smart large object.

mi_lo_stat_atime()
Storage characteristics

These characteristics are stored in an LO-specification structure. Use the LO-specification accessor functions (see Define user-specified storage characteristics) to obtain information from this structure.

mi_lo_stat_cspec()
Last-change time mi_lo_stat_ctime()
Last-modification time mi_lo_stat_mtime_sec(), mi_lo_stat_mtime_usec()
Reference count mi_lo_stat_refcnt()
Size mi_lo_stat_size()
Important: The LO-status structure, MI_LO_STAT, is an opaque structure to DataBlade® API modules. Do not access its internal structure directly. The internal structure of MI_LO_STAT might change in future releases. Therefore, to create portable code, always use the LO-status accessor functions for this structure.
The following code fragment obtains the reference count from an LO-status structure that the LO_stat variable references:
MI_CONNECTION *conn;
MI_LO_HANDLE *LO_hdl;
MI_LO_FD LO_fd;
MI_LO_STAT *LO_stat = NULL; /* DataBlade API allocates */
mi_integer ref_count, err;
...
/* Open the selected large object */
LO_fd = mi_lo_open(conn, LO_hdl, MI_LO_RDONLY);
if ( LO_fd == MI_ERROR )
   /* handle error */

/* Allocate LO-specification structure and get status
 * information for the opened smart large object
 */
if ( mi_lo_stat(conn, LO_fd, &LO_stat) != MI_OK )
   /* handle error */
else
   {
   /* get reference count for this smart large object */
   ref_count = mi_lo_stat_refcnt(LO_stat);

   /* free the LO-status structure */
   err = mi_lo_stat_free(LO_stat);
   }
The mi_lo_open() function opens the smart large object that the LO handle, LO_hdl, identifies. The mi_lo_stat() function then obtains the status information for this open smart large object. The mi_lo_stat() function performs the following tasks:
  1. Allocates a new LO-status structure because the value of *LO_stat is NULL

    The mi_lo_stat() function assigns a pointer to this new LO-status structure to the LO_stat variable.

  2. Initializes the LO_stat structure with the status information for the open smart large object that the LO file descriptor, LO_fd, identifies

After the LO-status structure contains the status information, the mi_lo_stat_refcnt() accessor function obtains the reference count from the LO-status structure and returns it into the ref_count variable. When the code no longer needs the LO-status structure, it frees this structure with the mi_lo_stat_free() function.