mco_disk_load DEPRECATED

Load persistent classes from an external file. This function has been deprecated in version 7.1. See mco_db_load().

Prototype

 
    MCO_RET	mco_disk_load(	/*IN*/ void *stream_handle,
                 /*IN*/ mco_stream_read input_stream_reader,
                 /*IN*/ const char * dbname,
                 /*IN*/ mco_dictionary_h dict,
                 /*IN*/ mco_device_t *devices,
                 /*IN*/ uint2 n_devices,
                 /*IN*/ mco_db_params_t * db_params );
 

Arguments

stream_handle Handle to the input stream
input_stream_reader Handler function called by the runtime to read the input
dbname Database name passed to mco_db_open_dev()

dict

Database dictionary handle passed to mco_db_open_dev().

devices

Device structure array passed to mco_db_open_dev()

n_devices

The number of device structures passed to mco_db_open_dev()

db_params

The database parameters passed to mco_db_open_dev()

Description

While mco_db_load() loads all database objects (both persistent and transient), this function reads the content of only the persistent classes. After loading the persistent classes this function opens the database by calling mco_db_open_dev() with the passed parameters.

The calling application must provide a stream pointer (a pointer to a file, socket, pipe, etc.) and the address of a function that will perform the reading of the stream of bytes representing the database image. The eXtremeDB runtime will call the given function, passing it the stream pointer, a buffer and the size of the buffer to be read. See the control structure stream_reader for further details. (Also see mco_disk_save()).

Return Codes

MCO_S_OK The database was closed successfully
MCO_E_NOINSTANCE The specified database is not opened

Example

 
    Application snippet:
        
     
    const char * db_name = "backupdb";
     
    mco_size_sig_t file_reader( void *stream_handle /* FILE *  */,  /* OUT */void *to, mco_size_t max_nbytes )
    {
        FILE *f = (FILE *)stream_handle;
        mco_size_sig_t nbs;
        nbs = fread( to, 1, max_nbytes, f );
        return nbs;
    }
     
    int  main(int argc, char** argv)
    {
        MCO_RET             rc;
        sample_memory_t     dbmem;
        mco_db_h            db;
        mco_db_params_t     db_params;
        …
        FILE * fbak;
        …
        rc = mco_disk_load( (void *)fbak, file_reader, dbname, backupdb_get_dictionary(), 
        
                    dbmem.dev, dbmem.n_dev, &db_params );
        
        fclose( fbak );
        sample_rc_check( "\t Load database", rc );
        if ( MCO_S_OK == rc )
        {
            /* Connect to database */
            rc = mco_db_connect( dbname, &db );
            sample_rc_check( "\t Connect to database", rc );
        }
    }