This article is deprecated. Please see the following article instead.
As explained in the Database Browser page, the eXtremeDB SDK includes an HTML-based database browser / editor (HTTP Viewer) that can be used to examine any eXtremeDB database.
The browser is implemented via a special library
mcohv, which is a layer between the UDA API and the generic C APIs of the eXtremeDB database, and the HTTP server librarymcoews. Simply linking with these libraries enables HTML browser access to examine or change the database contents. Librarymcohvhas an extended versionmcohv_sqlwhich allows executing SQL queries to browse the database. (The additional librarymcosqlmust be linked for SQL access). Conversely, not linking the application with themcohvandmcoewslibraries effectively disables http access to the eXtremeDB database.Database Browser Functions
The following structure allows changing the default HTTP server bindings from
http://localhost:8082/to a user defined address and port when starting the HTTP server:typedef struct tag_mcohv_interface_def { char* interface_addr; unsigned short port; } mcohv_interface_def_t;The database browser can simultaneously serve up to five custom interfaces specified by argument
n_intfof function mcohv_start().The application will define the following data structure pointer (as a void pointer) to hold
mcohvlibrary internal information between the starting and stopping of the Database Browser HTTP Server:
typedef void* mcohv_p;Database Browser Initialize/Shutdown Functions
To initialize the
mcohvlibrary before starting the Database Browser Server and to shut it down gracefully, call the following functions:int mcohv_initialize(); int mcohv_shutdown();The HTTP server library
mcoewsneeds no additional initialization. All of the necessary functionality performed by this library are encapsulated in themcohvlibrary.Database Browser Start/Stop Server Functions
Then
mcohvlibrary is initialized and the database or databases opened as usual by the application using generic API functionsmco_db_open_dev()ormco_db_load()or by using the UDA functionmco_uda_db_open(). The application starts the Database Browser server. Note that, due to the fact that UDA functions are used by themcohvlibrary, to gather database information, the UDA metadictionary must first be created and initialized.int mcohv_start(mcohv_p* hv, mco_metadict_header_t *db, mcohv_interface_def_t* intf, unsigned int n_intf); int mcohv_stop(mcohv_p hv);The following code snippets (from samples "samples/core/02-open/convhv" and "samples/core/22-httpview") show some of the details and steps for using the HttpViewer in an application:
#define DATABASE_SEGMENT_SIZE 10*1024*1024 mco_device_t dev; mco_metadict_header_t *metadict; mcohv_p hv; unsigned int size; char *db_name = "my_db" mco_runtime_start(); mco_metadict_size(1, &size); metadict = (mco_metadict_header_t *) (malloc(size)); mco_metadict_register(metadict, db_name, my_db get_dictionary(), NULL); mco_db_params_init ( &db_params ); dev.type = MCO_MEMORY_CONV; dev.assignment = MCO_MEMORY_ASSIGN_DATABASE; dev.size = DATABASE_SEGMENT_SIZE; dev.dev.conv.ptr = (void*)malloc( DATABASE_SEGMENT_SIZE ); mco_db_open_dev(db_name, my_db_get_dictionary(), &dev, 1, &db_params ); mcohv_start(&hv, metadict, 0, 0); /* Wait until some event to stop http server */ mcohv_stop(hv); mco_db_close(db_name); mco_runtime_stop(); free(dev.dev.conv.ptr);