📄 main.c
字号:
/***************************************************************
* *
* Copyright (c) 2001-2007 McObject LLC. All Right Reserved. *
* *
***************************************************************/
/* This samples demonstartes eXtremeDB patricia tree *match functions behaviour. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "simple.h"
#include "objfunc.h"
#ifdef _WIN32_WCE
/* Only one define an be active */
#define _STR_OBJECT_TEST_
#define _BOOL_OBJECT_TEST_
#ifdef _STR_OBJECT_TEST_
#include "strobj.c"
#else
#include "boolobj.c"
#endif
#endif
static const char* dbname = "SimpleDb";
static const int FIRST_SEGSZ = 1024 * 8000UL;
#ifndef MCO_PLATFORM_X64
static const int PAGESIZE = 96;
#else
static const int PAGESIZE = 192;
#endif
const int MAP_ADDRESS = 0x20000000;
void _SH_(void)
{
char text[] =
{
"\nThis samples demonstartes eXtremeDB patricia tree *match functions behaviour.\n"
};
char text1[] =
{
"Copyright (c) 2001-2007 McObject LLC. All Right Reserved.\n\n"
};
printf("%s\neXtremeDB runtime version %d.%d, build %d\n%s\n\nPress Enter to start", text, MCO_COMP_VER_MAJOR,
MCO_COMP_VER_MINOR, MCO_COMP_BUILD_NUM, text1);
getchar();
}
/* fatal error handler */
static void errhandler(int n)
{
printf("\neXtremeDB runtime fatal error: %d", n);
getchar();
exit( - 1);
}
int main(void)
{
MCO_RET rc;
mco_db_h db = 0;
char* start_mem;
mco_runtime_info_t info;
_SH_();
mco_get_runtime_info(&info);
if (info.mco_shm_supported)
{
start_mem = (char*)MAP_ADDRESS;
}
else
{
start_mem = (char*)malloc(FIRST_SEGSZ);
if (!start_mem)
{
printf("Couldn't allocated memory\n");
exit(1);
}
};
/* set fatal error handler */
mco_error_set_handler(&errhandler);
mco_runtime_start();
/* Create a database - allocate 2M starting from mem. */
rc = mco_db_open(dbname, simple_get_dictionary(), start_mem, FIRST_SEGSZ, (uint2)PAGESIZE);
if (rc)
{
printf("\nerror creating database");
if (!info.mco_shm_supported)
{
free(start_mem);
}
exit(1);
}
/* connect to the database, obtain a database handle */
mco_db_connect(dbname, &db);
printf("\ndb handle = %d\n", db);
createDatabase(db);
doListing(db);
doGoogle(db);
/* disconnect from the database, db is no longer valid */
mco_db_disconnect(db);
/* destroy the db */
mco_db_close(dbname);
mco_runtime_stop();
if (!info.mco_shm_supported)
{
free(start_mem);
}
printf("Press Enter key to exit");
getchar();
exit(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -