Save the database dictionary to an external file.
MCO_RET mco_db_save_dictionary( /*IN*/ void * stream_handle, /*IN*/ mco_stream_write output_stream_writer, /*IN*/ mco_db_h db);
stream_handle | Handle to the output stream |
output_stream_writer |
|
db |
The database handle |
This function is used to stream the database schema (in eXtremeDB DDL format) to permanent storage.
MCO_S_OK | The database was closed successfully |
MCO_E_NOINSTANCE | The specified database is not opened |
MCO_E_WRITE_STREAM | Error writing to output stream |
Application snippet: const char * dbname = "SimpleDb"; /* Stream writer with prototype mco_stream_write */ mco_size_sig_t file_writer( void *stream_handle /* FILE * */, const void *from, mco_size_t nbytes ) { FILE *f = (FILE *)stream_handle; mco_size_sig_t nbs; nbs = fwrite( from, 1, nbytes, f ); return nbs; } int main(int argc, char* argv[]) { mco_db_h db; MCO_RET rc; mco_db_params_t db_params; FILE * fbak; mco_device_t dev; ... if( (rc = mco_runtime_start()) != MCO_S_OK) exit(-1); rc = mco_db_open_dev( dbname, simpledb_get_dictionary(), &dev, 1, &db_params ); if ( MCO_S_OK != rc ) { rc = mco_db_connect(dbname, &db); ... /* Backup dictionary */ fbak = fopen( "dictionary.bak", "wb" ); if ( fbak == 0 ) { printf( "\n\t Can't open output file for streaming\n"); } else { rc = mco_db_save_dictionary( (void *)fbak, file_writer, db ); fclose( fbak ); sample_rc_check( "\t Save dictionary", rc ); } ... } }