/*******************************************************************
 *                                                                 *
 *  sqlinf.cpp                                                     *
 *                                                                 *
 *  This file is a part of the eXtremeDB source code               *
 *  Copyright (c) 2001-2010 McObject LLC                           *
 *  All Rights Reserved                                            *
 *                                                                 *
 *******************************************************************/
#include

#include "mcosql.h"
#include "sqlcln.h"
#include "sqlsrv.h"

const int SERVER_PORT = 5501;
#include "sqlintf.h"
//#include "ph2db.h"

#ifdef DISK_DATABASE
#ifndef _WIN32
#include
#endif
#endif

using namespace McoSql;
#ifdef __cplusplus
extern "C" {
#endif
/* redefine default stack size if needed */
#undef DEFAULT_STACK_SIZE
#define DEFAULT_STACK_SIZE 64*1024

/*#ifndef MCO_PLATFORM_X64
    size_t const PAGE_SIZE = 128; // define eXtremeDB page size
#else
    size_t const PAGE_SIZE = 256;
#endif*/

McoMultithreadedSqlEngine engine;
McoSql::SqlServer * server=NULL;
char db_sname[100];


int start_sql(const char * dbname,int iCmd)
{
    McoSqlOpenParameters params;
 sprintf(db_sname,"%s",dbname);
    params.databaseName = db_sname;
    printf("sql dbname = %s\n", params.databaseName);
 params.flags = McoSqlOpenParameters::SET_SQL_ALLOCATOR;

 engine.open(params);
 if (iCmd)
 {
  engine.main("SQL>",stdin, stdout, stderr);
 }

    printf("start sql engine successful!\n");
   
    return 0;
}

int start_sqlsvr(int isMst)
{
 int iPort = SERVER_PORT + (isMst?0:1000);
 
 server = new SqlServer(&engine, iPort);

 server->start();
 return 0;
}

int stop_sql()
{
    engine.close();
    return 0;
};

int stop_sqlsvr()
{
 if (server)
 {
  server->stop();  
  delete server;
 }
 return 0;
};
#ifdef __cplusplus
}
#endif

09-07 16:18