📄 hvdemo.c
字号:
/**************************************************************** * * * Copyright (c) 2001-2007 McObject LLC. All Right Reserved. * * * ****************************************************************/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <platform.h>#include "hvddb.h"#include <mcohv.h>#include <mco.h>#define DB_MEMORY_SIZE 4 * 1024 * 1024#ifndef MCO_PLATFORM_X64#define PAGESIZE 96#else#define PAGESIZE 192#endifconst int MAP_ADDRESS = 0x20000000;mco_db_h db;static void errhandler( int n ) { printf( "\neXtremeDB fatal error: %d", n ); getchar(); exit( -1 );}int LoadData(mco_db_h db);int mcohv_int_fill_trans_obj( uint2 class_no, char * ckey, mco_trans_h t, MCO_Hf * ph );int main( void ) { char * start_mem = 0; mco_runtime_info_t info; char * dbName = "hvddb"; mcohv_p hv = 0; mco_get_runtime_info( &info); if ( info.mco_shm_supported ) { start_mem = (char*)MAP_ADDRESS; } else { start_mem = (char*)malloc(DB_MEMORY_SIZE); if (!start_mem) { printf("Couldn't allocated memory\n"); exit (1); } }; /* set fatal error handler */ mco_error_set_handler( &errhandler ); /* start db engine */ if ( mco_runtime_start() != MCO_S_OK) { printf( "\nUnable to start database engine\n" ); if ( !info.mco_shm_supported ) free( start_mem ); exit(-1); }; /* initialize MCOHV */ mcohv_initialize (); /* create and connect the database */ mco_db_open( dbName, hvddb_get_dictionary(), start_mem, DB_MEMORY_SIZE, (uint2) PAGESIZE ); mco_db_connect( dbName, &db ); /* load data to the database */ LoadData( db ); /* start the HTTP server */ printf( "mcohv_start(...)==%d\n", mcohv_start ( &hv, db, 0, 0 ) ) ; /* simulate the progrm's event- or data-loop */ printf("Hit ENTER to continue..."); fflush( stdout ); { char buf[100]; while (!fgets( buf, sizeof(buf), stdin )) {Sleep(100);} }; /* stop the server */ printf( "mcohv_stop(...)=="); fflush(stdout); printf( "%d\n", mcohv_stop ( hv ) ); /* disconnect from the database, db is no longer valid */ if ( mco_db_disconnect( db ) != MCO_S_OK ) { printf( "mco_db_disconnect(...) failed\n" ); }; /* destroys the memory manager */ if ( mco_db_close( dbName ) != MCO_S_OK ) { printf( "mco_db_close(...) failed\n" ); }; /* free the memory */ if ( !info.mco_shm_supported ) free( start_mem ); /* final cleanup */ printf( "mcohv_shutdown(...)=="); fflush(stdout); printf( "%d\n", mcohv_shutdown () ); /* shutdown database engine */ mco_runtime_stop(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -