mirror of https://gitee.com/bigwinds/arangodb
various changes for windows
This commit is contained in:
parent
5faa701537
commit
aad73db128
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "Dispatcher/DispatcherThread.h"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class ActionDispatcherThread
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "RestActionHandler.h"
|
||||
|
||||
#include "Actions/ActionDispatcherThread.h"
|
||||
// #include "Actions/ActionDispatcherThread.h"
|
||||
#include "Actions/actions.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Rest/HttpRequest.h"
|
||||
|
|
|
@ -998,7 +998,7 @@ bool TRI_PushArrayAql (TRI_aql_context_t* const context,
|
|||
/// @brief get the boolean value of a node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline bool TRI_GetBooleanNodeValueAql (const TRI_aql_node_t* const node) {
|
||||
bool TRI_GetBooleanNodeValueAql (const TRI_aql_node_t* const node) {
|
||||
assert(node);
|
||||
assert(node->_type == TRI_AQL_NODE_VALUE);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "Ahuacatl/ahuacatl-collections.h"
|
||||
#include "Ahuacatl/ahuacatl-index.h"
|
||||
#include "Ahuacatl/ahuacatl-functions.h"
|
||||
#include "Ahuacatl/ahuacatl-node.h"
|
||||
#include "Ahuacatl/ahuacatl-scope.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -423,7 +424,7 @@ static TRI_aql_scope_e NextScopeType (TRI_aql_codegen_js_t* const generator,
|
|||
|
||||
static void StartScope (TRI_aql_codegen_js_t* const generator,
|
||||
TRI_string_buffer_t* const buffer,
|
||||
const TRI_aql_scope_e const type,
|
||||
const TRI_aql_scope_e type,
|
||||
const TRI_aql_codegen_register_t listRegister,
|
||||
const TRI_aql_codegen_register_t keyRegister,
|
||||
const TRI_aql_codegen_register_t ownRegister,
|
||||
|
@ -2102,7 +2103,7 @@ static void ProcessFilter (TRI_aql_codegen_js_t* const generator,
|
|||
/// this is a dispatcher function only
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void ProcessNode (TRI_aql_codegen_js_t* generator, const TRI_aql_node_t* const node) {
|
||||
static void ProcessNode (TRI_aql_codegen_js_t* const generator, const TRI_aql_node_t* const node) {
|
||||
if (node == NULL) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline bool TRI_IsTopLevelTypeAql (const TRI_aql_node_type_e type) {
|
||||
bool TRI_IsTopLevelTypeAql (const TRI_aql_node_type_e type) {
|
||||
if (type == TRI_AQL_NODE_SCOPE_START ||
|
||||
type == TRI_AQL_NODE_SCOPE_END ||
|
||||
type == TRI_AQL_NODE_SUBQUERY ||
|
||||
|
@ -193,7 +193,7 @@ const char* TRI_NodeNameAql (const TRI_aql_node_type_e type) {
|
|||
/// @brief return true if a node is a list node
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline bool TRI_IsListNodeAql (const TRI_aql_node_t* const node) {
|
||||
bool TRI_IsListNodeAql (const TRI_aql_node_t* const node) {
|
||||
return (node->_type == TRI_AQL_NODE_LIST);
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ bool TRI_IsConstantValueNodeAql (const TRI_aql_node_t* const node) {
|
|||
/// @brief checks if a node value is numeric
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline bool TRI_IsNumericValueNodeAql (const TRI_aql_node_t* const node) {
|
||||
bool TRI_IsNumericValueNodeAql (const TRI_aql_node_t* const node) {
|
||||
assert(node);
|
||||
|
||||
if (node->_type != TRI_AQL_NODE_VALUE) {
|
||||
|
@ -260,7 +260,7 @@ inline bool TRI_IsNumericValueNodeAql (const TRI_aql_node_t* const node) {
|
|||
/// @brief checks if a node value is boolean
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline bool TRI_IsBooleanValueNodeAql (const TRI_aql_node_t* const node) {
|
||||
bool TRI_IsBooleanValueNodeAql (const TRI_aql_node_t* const node) {
|
||||
assert(node);
|
||||
|
||||
return (node->_type == TRI_AQL_NODE_VALUE && node->_value._type == TRI_AQL_TYPE_BOOL);
|
||||
|
|
|
@ -514,6 +514,7 @@ static TRI_aql_node_t* OptimiseUnaryArithmeticOperation (TRI_aql_context_t* cons
|
|||
TRI_SetErrorContextAql(context, TRI_ERROR_QUERY_INVALID_ARITHMETIC_VALUE, NULL);
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
if (node->_type == TRI_AQL_NODE_OPERATOR_UNARY_PLUS) {
|
||||
// + number => number
|
||||
|
@ -725,7 +726,7 @@ static TRI_aql_node_t* OptimiseBinaryArithmeticOperation (TRI_aql_context_t* con
|
|||
|
||||
isEligibleLhs = TRI_IsConstantValueNodeAql(lhs);
|
||||
isEligibleRhs = TRI_IsConstantValueNodeAql(rhs);
|
||||
|
||||
|
||||
if (isEligibleLhs && !TRI_IsNumericValueNodeAql(lhs)) {
|
||||
// node is not a numeric value => error
|
||||
TRI_SetErrorContextAql(context, TRI_ERROR_QUERY_INVALID_ARITHMETIC_VALUE, NULL);
|
||||
|
@ -739,6 +740,7 @@ static TRI_aql_node_t* OptimiseBinaryArithmeticOperation (TRI_aql_context_t* con
|
|||
return node;
|
||||
}
|
||||
|
||||
|
||||
if (!isEligibleLhs || !isEligibleRhs) {
|
||||
return node;
|
||||
}
|
||||
|
|
|
@ -891,7 +891,9 @@ static bool isEqualJson(TRI_json_t* left, TRI_json_t* right) {
|
|||
default: {
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false; // shut the vc++ up
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -978,6 +978,7 @@ static int CompareShapeTypes (const TRI_shaped_json_t* left, const TRI_shaped_js
|
|||
|
||||
}
|
||||
assert(false);
|
||||
return 0; // shut the vc++ up
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include "Admin/RestHandlerCreator.h"
|
||||
#include "Basics/ProgramOptions.h"
|
||||
#include "Basics/ProgramOptionsDescription.h"
|
||||
#include "Basics/Random.h"
|
||||
#include "Basics/RandomGenerator.h"
|
||||
#include "Basics/Utf8Helper.h"
|
||||
#include "BasicsC/files.h"
|
||||
#include "BasicsC/init.h"
|
||||
|
@ -59,7 +59,7 @@
|
|||
#include "HttpServer/RedirectHandler.h"
|
||||
|
||||
#include "Logger/Logger.h"
|
||||
#include "Rest/Initialise.h"
|
||||
#include "Rest/InitialiseRest.h"
|
||||
#include "Rest/OperationMode.h"
|
||||
#include "RestHandler/ConnectionStatisticsHandler.h"
|
||||
#include "RestHandler/RequestStatisticsHandler.h"
|
||||
|
@ -68,7 +68,11 @@
|
|||
#include "RestHandler/RestEdgeHandler.h"
|
||||
#include "RestHandler/RestImportHandler.h"
|
||||
#include "Scheduler/ApplicationScheduler.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "V8/V8LineEditor.h"
|
||||
#endif
|
||||
|
||||
#include "V8/v8-conv.h"
|
||||
#include "V8/v8-utils.h"
|
||||
#include "V8Server/ApplicationV8.h"
|
||||
|
@ -245,7 +249,7 @@ void ArangoServer::buildApplicationServer () {
|
|||
|
||||
_applicationServer = new ApplicationServer("arangod", "[<options>] <database-directory>", TRIAGENS_VERSION);
|
||||
_applicationServer->setSystemConfigFile("arangod.conf");
|
||||
_applicationServer->setUserConfigFile(".arango/arangod.conf");
|
||||
_applicationServer->setUserConfigFile(string(".arango") + string(1,TRI_DIR_SEPARATOR_CHAR) + string("arangod.conf") );
|
||||
|
||||
// .............................................................................
|
||||
// multi-threading scheduler and dispatcher
|
||||
|
@ -792,6 +796,7 @@ int ArangoServer::executeConsole (OperationMode::server_operation_mode_e mode) {
|
|||
// .............................................................................
|
||||
|
||||
case OperationMode::MODE_CONSOLE: {
|
||||
#ifndef _WIN32
|
||||
context->_context->Global()->Set(v8::String::New("DATABASEPATH"), v8::String::New(_databasePath.c_str()), v8::ReadOnly);
|
||||
context->_context->Global()->Set(v8::String::New("VALGRIND"), _runningOnValgrind ? v8::True() : v8::False(), v8::ReadOnly);
|
||||
V8LineEditor* console = new V8LineEditor(context->_context, ".arango");
|
||||
|
@ -830,7 +835,7 @@ int ArangoServer::executeConsole (OperationMode::server_operation_mode_e mode) {
|
|||
console->close();
|
||||
|
||||
delete console;
|
||||
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "Basics/Common.h"
|
||||
|
||||
#include "RestServer/ArangoServer.h"
|
||||
#include "ResultGenerator/Initialise.h"
|
||||
#include "ResultGenerator/InitialiseGenerator.h"
|
||||
|
||||
using namespace triagens;
|
||||
using namespace triagens::rest;
|
||||
|
@ -48,6 +48,8 @@ using namespace triagens::arango;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int main (int argc, char* argv[]) {
|
||||
int res = 0;
|
||||
|
||||
TRIAGENS_RESULT_GENERATOR_INITIALISE(argc, argv);
|
||||
TRI_InitialiseVocBase();
|
||||
|
||||
|
@ -55,7 +57,7 @@ int main (int argc, char* argv[]) {
|
|||
ArangoServer server(argc, argv);
|
||||
|
||||
|
||||
int res = server.start();
|
||||
res = server.start();
|
||||
|
||||
|
||||
// shutdown
|
||||
|
|
|
@ -692,6 +692,8 @@ static int CompareShapeTypes (const TRI_shaped_json_t* left, const TRI_shaped_js
|
|||
} // end of switch (leftType)
|
||||
|
||||
assert(false);
|
||||
|
||||
return 0; //shut the vc++ up
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ using namespace triagens::basics;
|
|||
using namespace triagens::rest;
|
||||
using namespace triagens::arango;
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- forward declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
/// @author Copyright 2011, triagens GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "BasicsC/win-utils.h"
|
||||
#endif
|
||||
|
||||
#include "compactor.h"
|
||||
|
||||
#include "BasicsC/conversions.h"
|
||||
|
|
|
@ -3623,6 +3623,8 @@ static int GeoIndexFromJson (TRI_document_collection_t* sim,
|
|||
else {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
return 0; // shut the vc++ up
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -225,7 +225,7 @@ TRI_general_cursor_t* TRI_CreateGeneralCursor (TRI_general_cursor_result_t* resu
|
|||
/// @brief exclusively lock a general cursor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void TRI_LockGeneralCursor (TRI_general_cursor_t* const cursor) {
|
||||
void TRI_LockGeneralCursor (TRI_general_cursor_t* const cursor) {
|
||||
TRI_LockMutex(&cursor->_lock);
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ inline void TRI_LockGeneralCursor (TRI_general_cursor_t* const cursor) {
|
|||
/// @brief unlock a general cursor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void TRI_UnlockGeneralCursor (TRI_general_cursor_t* const cursor) {
|
||||
void TRI_UnlockGeneralCursor (TRI_general_cursor_t* const cursor) {
|
||||
assert(cursor);
|
||||
|
||||
TRI_UnlockMutex(&cursor->_lock);
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "ImportHelper.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "Rest/Endpoint.h"
|
||||
#include "Rest/Initialise.h"
|
||||
#include "Rest/InitialiseRest.h"
|
||||
#include "SimpleHttpClient/SimpleHttpClient.h"
|
||||
#include "SimpleHttpClient/SimpleHttpResult.h"
|
||||
#include "V8Client/V8ClientConnection.h"
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "BasicsC/init.h"
|
||||
#include "BasicsC/strings.h"
|
||||
#include "Rest/Endpoint.h"
|
||||
#include "Rest/Initialise.h"
|
||||
#include "Rest/InitialiseRest.h"
|
||||
#include "SimpleHttpClient/SimpleHttpClient.h"
|
||||
#include "SimpleHttpClient/SimpleHttpResult.h"
|
||||
#include "V8/JSLoader.h"
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include "ApplicationServer/ApplicationFeature.h"
|
||||
#include "Basics/FileUtils.h"
|
||||
#include "Basics/Random.h"
|
||||
#include "Basics/RandomGenerator.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/delete_object.h"
|
||||
#include "BasicsC/conversions.h"
|
||||
|
@ -106,6 +106,43 @@ string const ApplicationServer::OPTIONS_SERVER = "Server Options";
|
|||
/// @brief constructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _WIN32
|
||||
ApplicationServer::ApplicationServer (string const& name, string const& title, string const& version)
|
||||
: _options(),
|
||||
_description(),
|
||||
_descriptionFile(),
|
||||
_arguments(),
|
||||
_features(),
|
||||
_exitOnParentDeath(false),
|
||||
_watchParent(0),
|
||||
_stopping(0),
|
||||
_name(name),
|
||||
_title(title),
|
||||
_version(version),
|
||||
_configFile(),
|
||||
_userConfigFile(),
|
||||
_systemConfigFile(),
|
||||
_systemConfigPath(),
|
||||
_uid(),
|
||||
_realUid(0),
|
||||
_effectiveUid(0),
|
||||
_gid(),
|
||||
_realGid(0),
|
||||
_effectiveGid(0),
|
||||
_logApplicationName("triagens"),
|
||||
_logHostName("-"),
|
||||
_logFacility("-"),
|
||||
_logLevel("info"),
|
||||
_logFormat(),
|
||||
_logSeverity("human"),
|
||||
_logFile("+"),
|
||||
_logPrefix(),
|
||||
_logSyslog(),
|
||||
_logThreadId(false),
|
||||
_logLineNumber(false),
|
||||
_randomGenerator(5) {
|
||||
}
|
||||
#else
|
||||
ApplicationServer::ApplicationServer (string const& name, string const& title, string const& version)
|
||||
: _options(),
|
||||
_description(),
|
||||
|
@ -141,6 +178,7 @@ ApplicationServer::ApplicationServer (string const& name, string const& title, s
|
|||
_logLineNumber(false),
|
||||
_randomGenerator(3) {
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
|
@ -385,11 +423,29 @@ bool ApplicationServer::parse (int argc,
|
|||
|
||||
try {
|
||||
switch (_randomGenerator) {
|
||||
case 1: Random::selectVersion(Random::RAND_MERSENNE); break;
|
||||
case 2: Random::selectVersion(Random::RAND_RANDOM); break;
|
||||
case 3: Random::selectVersion(Random::RAND_URANDOM); break;
|
||||
case 4: Random::selectVersion(Random::RAND_COMBINED); break;
|
||||
default: break;
|
||||
case 1: {
|
||||
Random::selectVersion(Random::RAND_MERSENNE);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
Random::selectVersion(Random::RAND_RANDOM);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
Random::selectVersion(Random::RAND_URANDOM);
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
Random::selectVersion(Random::RAND_COMBINED);
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
Random::selectVersion(Random::RAND_WIN32);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -398,6 +454,7 @@ bool ApplicationServer::parse (int argc,
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
for (vector<ApplicationFeature*>::iterator i = _features.begin(); i != _features.end(); ++i) {
|
||||
ok = (*i)->parsePhase2(_options);
|
||||
|
||||
|
@ -845,12 +902,56 @@ bool ApplicationServer::readConfigurationFile () {
|
|||
// nothing has been specified on the command line regarding configuration file
|
||||
if (! _userConfigFile.empty()) {
|
||||
|
||||
// .........................................................................
|
||||
// first attempt to obtain a default configuration file from the users home directory
|
||||
string homeDir = string(getenv("HOME"));
|
||||
// .........................................................................
|
||||
|
||||
// .........................................................................
|
||||
// Under windows there is no 'HOME' directory as such so getenv("HOME")
|
||||
// may return NULL -- which it does under windows
|
||||
// A safer approach below
|
||||
// .........................................................................
|
||||
|
||||
string homeDir;
|
||||
string homeEnv;
|
||||
const char* envResult;
|
||||
|
||||
#ifdef _WIN32
|
||||
string homeDrive;
|
||||
string homePath;
|
||||
|
||||
homeEnv = string("%HOMEDRIVE% and/or %HOMEPATH%");
|
||||
|
||||
envResult = getenv("HOMEDRIVE");
|
||||
if (envResult != 0) {
|
||||
homeDrive = string(envResult);
|
||||
}
|
||||
|
||||
envResult = getenv("HOMEPATH");
|
||||
if (envResult != 0) {
|
||||
homePath = string(envResult);
|
||||
}
|
||||
|
||||
if (! homeDrive.empty() && ! homePath.empty()) {
|
||||
homeDir = homeDrive + homePath;
|
||||
}
|
||||
else {
|
||||
homeDir = string("");
|
||||
}
|
||||
#else
|
||||
homeEnv = string("$HOME");
|
||||
envResult = getenv("HOME");
|
||||
if (envResult != 0) {
|
||||
homeDir = string(envResult);
|
||||
}
|
||||
else {
|
||||
homeDir = string("");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! homeDir.empty()) {
|
||||
if (homeDir[homeDir.size() - 1] != '/') {
|
||||
homeDir += "/" + _userConfigFile;
|
||||
if (homeDir[homeDir.size() - 1] != TRI_DIR_SEPARATOR_CHAR) {
|
||||
homeDir += TRI_DIR_SEPARATOR_CHAR + _userConfigFile;
|
||||
}
|
||||
else {
|
||||
homeDir += _userConfigFile;
|
||||
|
@ -876,7 +977,7 @@ bool ApplicationServer::readConfigurationFile () {
|
|||
}
|
||||
}
|
||||
else {
|
||||
LOGGER_DEBUG << "no user init file, $HOME is empty";
|
||||
LOGGER_DEBUG << "no user init file, " << homeEnv << " is empty";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
/// @author Copyright 2009-2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Basics/Initialise.h"
|
||||
#include "Basics/InitialiseBasics.h"
|
||||
|
||||
#include "BasicsC/init.h"
|
||||
#include "BasicsC/error.h"
|
||||
|
@ -33,7 +33,7 @@
|
|||
#include "BasicsC/random.h"
|
||||
|
||||
#include "Logger/Logger.h"
|
||||
#include "Basics/Random.h"
|
||||
#include "Basics/RandomGenerator.h"
|
||||
|
||||
#ifdef TRI_BROKEN_CXA_GUARD
|
||||
#include <pthread.h>
|
|
@ -25,8 +25,8 @@
|
|||
/// @author Copyright 2009-2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_BASICS_INITIALISE_H
|
||||
#define TRIAGENS_BASICS_INITIALISE_H 1
|
||||
#ifndef TRIAGENS_BASICS_INITIALISE_BASICS_H
|
||||
#define TRIAGENS_BASICS_INITIALISE_BASICS_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
/// @author Copyright 2009-2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Random.h"
|
||||
#include "RandomGenerator.h"
|
||||
|
||||
#include "BasicsC/mersenne.h"
|
||||
#include "BasicsC/socket-utils.h"
|
||||
|
@ -235,11 +235,64 @@ namespace RandomHelper {
|
|||
uint32_t rseed;
|
||||
};
|
||||
|
||||
template<int N>
|
||||
class RandomDeviceWin32 : public RandomDevice {
|
||||
#ifndef _WIN32
|
||||
public:
|
||||
RandomDeviceWin32 () { assert(false); }
|
||||
~RandomDeviceWin32 () {}
|
||||
uint32_t random () { return 0;}
|
||||
#else
|
||||
public:
|
||||
RandomDeviceWin32 () : cryptoHandle(0), pos(0) {
|
||||
CryptAcquireContext(&cryptoHandle, NULL, NULL, PROV_RSA_FULL, 0);
|
||||
if (cryptoHandle == 0) {
|
||||
THROW_INTERNAL_ERROR("cannot create cryptographic windows handle");
|
||||
}
|
||||
fillBuffer();
|
||||
}
|
||||
|
||||
|
||||
~RandomDeviceWin32 () {
|
||||
if (cryptoHandle != 0) {
|
||||
CryptReleaseContext(cryptoHandle, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32_t random () {
|
||||
if (pos >= N) {
|
||||
fillBuffer();
|
||||
}
|
||||
|
||||
return buffer[pos++];
|
||||
}
|
||||
|
||||
private:
|
||||
void fillBuffer () {
|
||||
size_t n = sizeof(buffer);
|
||||
BYTE* ptr = reinterpret_cast<BYTE*>(&buffer);
|
||||
|
||||
// fill the buffer with random characters
|
||||
int result = CryptGenRandom(cryptoHandle, n, ptr);
|
||||
if (result == 0) {
|
||||
LOGGER_FATAL << "read on random device failed: nothing read";
|
||||
THROW_INTERNAL_ERROR("read on random device failed");
|
||||
}
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
HCRYPTPROV cryptoHandle;
|
||||
uint32_t buffer[N];
|
||||
size_t pos;
|
||||
#endif
|
||||
};
|
||||
|
||||
RandomDevice* randomDevice = 0;
|
||||
RandomDevice* urandomDevice = 0;
|
||||
RandomDevice* combinedDevice = 0;
|
||||
RandomDevice* win32Device = 0;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -391,6 +444,17 @@ namespace triagens {
|
|||
};
|
||||
|
||||
|
||||
// RANDOM DEVICE
|
||||
struct UniformIntegerWin32 : public UniformIntegerImpl, private RandomHelper::UniformGenerator {
|
||||
UniformIntegerWin32 (RandomHelper::RandomDevice* device) : RandomHelper::UniformGenerator(device) {
|
||||
}
|
||||
|
||||
int32_t random (int32_t left, int32_t right) {
|
||||
return RandomHelper::UniformGenerator::random(left, right);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// current implementation (see version at the top of the file)
|
||||
UniformIntegerImpl * uniformInteger = new UniformIntegerMersenne;
|
||||
|
@ -461,6 +525,7 @@ namespace triagens {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
random_e selectVersion (random_e newVersion) {
|
||||
|
||||
MUTEX_LOCKER(RandomLock);
|
||||
|
||||
random_e oldVersion = version;
|
||||
|
@ -471,12 +536,15 @@ namespace triagens {
|
|||
uniformInteger = 0;
|
||||
}
|
||||
|
||||
|
||||
switch (version) {
|
||||
case RAND_MERSENNE:
|
||||
|
||||
case RAND_MERSENNE: {
|
||||
uniformInteger = new UniformIntegerMersenne;
|
||||
break;
|
||||
}
|
||||
|
||||
case RAND_RANDOM:
|
||||
case RAND_RANDOM: {
|
||||
if (RandomHelper::randomDevice == 0) {
|
||||
RandomHelper::randomDevice = new RandomHelper::RandomDeviceDirect<1024>("/dev/random");
|
||||
}
|
||||
|
@ -484,8 +552,9 @@ namespace triagens {
|
|||
uniformInteger = new UniformIntegerRandom(RandomHelper::randomDevice);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case RAND_URANDOM:
|
||||
case RAND_URANDOM: {
|
||||
if (RandomHelper::urandomDevice == 0) {
|
||||
RandomHelper::urandomDevice = new RandomHelper::RandomDeviceDirect<1024>("/dev/urandom");
|
||||
}
|
||||
|
@ -493,8 +562,9 @@ namespace triagens {
|
|||
uniformInteger = new UniformIntegerRandom(RandomHelper::urandomDevice);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case RAND_COMBINED:
|
||||
case RAND_COMBINED: {
|
||||
if (RandomHelper::combinedDevice == 0) {
|
||||
RandomHelper::combinedDevice = new RandomHelper::RandomDeviceCombined<600>("/dev/random");
|
||||
}
|
||||
|
@ -502,9 +572,20 @@ namespace triagens {
|
|||
uniformInteger = new UniformIntegerRandom(RandomHelper::combinedDevice);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
case RAND_WIN32: {
|
||||
if (RandomHelper::win32Device == 0) {
|
||||
RandomHelper::win32Device = new RandomHelper::RandomDeviceWin32<1024>();
|
||||
}
|
||||
uniformInteger = new UniformIntegerWin32(RandomHelper::win32Device);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
THROW_INTERNAL_ERROR("unknown random generator");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return oldVersion;
|
|
@ -26,11 +26,15 @@
|
|||
/// @author Copyright 2009-2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_BASICS_RANDOM_H
|
||||
#define TRIAGENS_BASICS_RANDOM_H 1
|
||||
#ifndef TRIAGENS_BASICS_RANDOM_GENERATOR_H
|
||||
#define TRIAGENS_BASICS_RANDOM_GENERATOR_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Wincrypt.h>
|
||||
#endif
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
|
@ -48,7 +52,8 @@ namespace triagens {
|
|||
RAND_MERSENNE = 1,
|
||||
RAND_RANDOM = 2,
|
||||
RAND_URANDOM = 3,
|
||||
RAND_COMBINED = 4
|
||||
RAND_COMBINED = 4,
|
||||
RAND_WIN32 = 5 // uses the built in cryptographic services offered and recommended by microsoft (e.g. CryptGenKey(...) )
|
||||
};
|
||||
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Dr. Oreste Costa-Panaia
|
||||
/// @author Dr. O
|
||||
/// @author Copyright 2005-2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -323,7 +323,7 @@ char* TRI_Dirname (char const* path) {
|
|||
m = 0;
|
||||
|
||||
if (1 < n) {
|
||||
if (path[n - 1] == '/') {
|
||||
if (path[n - 1] == TRI_DIR_SEPARATOR_CHAR) {
|
||||
m = 1;
|
||||
}
|
||||
}
|
||||
|
@ -331,8 +331,8 @@ char* TRI_Dirname (char const* path) {
|
|||
if (n == 0) {
|
||||
return TRI_DuplicateString(".");
|
||||
}
|
||||
else if (n == 1 && *path == '/') {
|
||||
return TRI_DuplicateString("/");
|
||||
else if (n == 1 && *path == TRI_DIR_SEPARATOR_CHAR) {
|
||||
return TRI_DuplicateString(TRI_DIR_SEPARATOR_STR);
|
||||
}
|
||||
else if (n - m == 1 && *path == '.') {
|
||||
return TRI_DuplicateString(".");
|
||||
|
@ -342,14 +342,14 @@ char* TRI_Dirname (char const* path) {
|
|||
}
|
||||
|
||||
for (p = path + (n - m - 1); path < p; --p) {
|
||||
if (*p == '/') {
|
||||
if (*p == TRI_DIR_SEPARATOR_CHAR) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (path == p) {
|
||||
if (*p == '/') {
|
||||
return TRI_DuplicateString("/");
|
||||
if (*p == TRI_DIR_SEPARATOR_CHAR) {
|
||||
return TRI_DuplicateString(TRI_DIR_SEPARATOR_STR);
|
||||
}
|
||||
else {
|
||||
return TRI_DuplicateString(".");
|
||||
|
@ -374,7 +374,7 @@ char* TRI_Basename (char const* path) {
|
|||
m = 0;
|
||||
|
||||
if (1 < n) {
|
||||
if (path[n - 1] == '/') {
|
||||
if (path[n - 1] == TRI_DIR_SEPARATOR_CHAR) {
|
||||
m = 1;
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ char* TRI_Basename (char const* path) {
|
|||
if (n == 0) {
|
||||
return TRI_DuplicateString("");
|
||||
}
|
||||
else if (n == 1 && *path == '/') {
|
||||
else if (n == 1 && *path == TRI_DIR_SEPARATOR_CHAR) {
|
||||
return TRI_DuplicateString("");
|
||||
}
|
||||
else if (n - m == 1 && *path == '.') {
|
||||
|
@ -393,13 +393,13 @@ char* TRI_Basename (char const* path) {
|
|||
}
|
||||
|
||||
for (p = path + (n - m - 1); path < p; --p) {
|
||||
if (*p == '/') {
|
||||
if (*p == TRI_DIR_SEPARATOR_CHAR) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (path == p) {
|
||||
if (*p == '/') {
|
||||
if (*p == TRI_DIR_SEPARATOR_CHAR) {
|
||||
return TRI_DuplicateString2(path + 1, n - m);
|
||||
}
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ char* TRI_Basename (char const* path) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char* TRI_Concatenate2File (char const* path, char const* name) {
|
||||
return TRI_Concatenate3String(path, "/", name);
|
||||
return TRI_Concatenate3String(path, TRI_DIR_SEPARATOR_STR, name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -422,7 +422,7 @@ char* TRI_Concatenate2File (char const* path, char const* name) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char* TRI_Concatenate3File (char const* path1, char const* path2, char const* name) {
|
||||
return TRI_Concatenate5String(path1, "/", path2, "/", name);
|
||||
return TRI_Concatenate5String(path1, TRI_DIR_SEPARATOR_STR, path2, TRI_DIR_SEPARATOR_STR, name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1047,10 +1047,10 @@ char* TRI_LocateBinaryPath (char const* argv0) {
|
|||
char* binaryPath = NULL;
|
||||
size_t i;
|
||||
|
||||
// check if name contains a '/'
|
||||
// check if name contains a '/' ( or '\' for windows)
|
||||
p = argv0;
|
||||
|
||||
for (; *p && *p != '/'; ++p) {
|
||||
for (; *p && *p != TRI_DIR_SEPARATOR_CHAR; ++p) {
|
||||
}
|
||||
|
||||
// contains a path
|
||||
|
|
|
@ -300,6 +300,7 @@ void TRI_ReadLockReadWriteLock (TRI_read_write_lock_t* lock) {
|
|||
LeaveCriticalSection(&lock->_lockReaders);
|
||||
|
||||
if (WaitForSingleObject(lock->_writerEvent, 0) != WAIT_OBJECT_0) {
|
||||
exit(EXIT_FAILURE);
|
||||
EnterCriticalSection(&lock->_lockReaders);
|
||||
DecrementReaders(lock);
|
||||
LeaveCriticalSection(&lock->_lockReaders);
|
||||
|
@ -335,7 +336,7 @@ void TRI_ReadUnlockReadWriteLock (TRI_read_write_lock_t* lock) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&lock->_lockWriter);
|
||||
LeaveCriticalSection(&lock->_lockReaders);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -359,6 +360,7 @@ void TRI_WriteLockReadWriteLock (TRI_read_write_lock_t* lock) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_WriteUnlockReadWriteLock (TRI_read_write_lock_t* lock) {
|
||||
//printf("%s:%s:%s:%d:%s:%d\n","oreste",__FILE__,__FUNCTION__,__LINE__,"!!!!!!!!!!!!!!!!!",(uint64_t)(lock));
|
||||
EnterCriticalSection(&lock->_lockReaders);
|
||||
|
||||
// a write lock eists
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "win-utils.h"
|
||||
#endif
|
||||
|
||||
#include "logging.h"
|
||||
#include "BasicsC/logging.h"
|
||||
|
||||
#ifdef TRI_ENABLE_SYSLOG
|
||||
#define SYSLOG_NAMES
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_DIR_SEPARATOR_CHAR '/'
|
||||
#define TRI_HAVE_GETGRGID 1
|
||||
#define TRI_HAVE_GETPWNAM 1
|
||||
#define TRI_HAVE_GETPWUID 1
|
||||
|
@ -67,6 +66,9 @@
|
|||
|
||||
#ifdef __APPLE__
|
||||
|
||||
#define TRI_DIR_SEPARATOR_CHAR '/'
|
||||
#define TRI_DIR_SEPARATOR_STR "/"
|
||||
|
||||
#define TRI_HAVE_POSIX 1
|
||||
|
||||
#define TRI_HAVE_DLFCN_H 1
|
||||
|
@ -163,6 +165,9 @@
|
|||
|
||||
#ifdef __CYGWIN__
|
||||
|
||||
#define TRI_DIR_SEPARATOR_CHAR '/'
|
||||
#define TRI_DIR_SEPARATOR_STR "/"
|
||||
|
||||
#define TRI_HAVE_POSIX 1
|
||||
|
||||
#define TRI_HAVE_DLFCN_H 1
|
||||
|
@ -238,6 +243,9 @@
|
|||
|
||||
#ifdef __linux__
|
||||
|
||||
#define TRI_DIR_SEPARATOR_CHAR '/'
|
||||
#define TRI_DIR_SEPARATOR_STR "/"
|
||||
|
||||
#define TRI_HAVE_POSIX 1
|
||||
|
||||
#define TRI_HAVE_DLFCN_H 1
|
||||
|
@ -347,6 +355,9 @@
|
|||
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
|
||||
#define TRI_DIR_SEPARATOR_CHAR '\\'
|
||||
#define TRI_DIR_SEPARATOR_STR "\\"
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS 1
|
||||
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
|
||||
|
||||
|
@ -450,6 +461,13 @@ typedef unsigned int bool;
|
|||
// ...........................................................................
|
||||
#define inline _inline
|
||||
|
||||
// ...........................................................................
|
||||
// windows uses _alloca instead of alloca
|
||||
// ...........................................................................
|
||||
#define alloca _alloca
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -103,7 +103,7 @@ static unsigned long SeedRandom (void) {
|
|||
/// @brief generates a 16 bit random unsigned integer
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint16_t TRI_UInt16Random () {
|
||||
uint16_t TRI_UInt16Random (void) {
|
||||
#if RAND_MAX == 2147483647
|
||||
|
||||
return rand() & 0xFFFF;
|
||||
|
@ -125,7 +125,7 @@ uint16_t TRI_UInt16Random () {
|
|||
/// @brief generates a 32 bit random unsigned integer
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint32_t TRI_UInt32Random () {
|
||||
uint32_t TRI_UInt32Random (void) {
|
||||
#if RAND_MAX == 2147483647
|
||||
|
||||
uint32_t l1;
|
||||
|
@ -174,7 +174,7 @@ uint32_t TRI_UInt32Random () {
|
|||
/// @brief initialises the random components
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_InitialiseRandom () {
|
||||
void TRI_InitialiseRandom (void) {
|
||||
if (Initialised) {
|
||||
return;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ void TRI_InitialiseRandom () {
|
|||
/// @brief shut downs the logging components
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_ShutdownRandom () {
|
||||
void TRI_ShutdownRandom (void) {
|
||||
if (! Initialised) {
|
||||
return;
|
||||
}
|
||||
|
@ -196,6 +196,7 @@ void TRI_ShutdownRandom () {
|
|||
Initialised = false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -170,6 +170,25 @@ bool TRI_StartThread (TRI_thread_t* thread, const char* name, void (*starter)(v
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief attempts to stop/terminate a thread
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_StopThread(TRI_thread_t* thread) {
|
||||
TerminateThread(thread,0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief waits for a thread to finish
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_DetachThread(TRI_thread_t* thread) {
|
||||
// TODO: no native implementation
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief waits for a thread to finish
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -178,6 +197,37 @@ void TRI_JoinThread (TRI_thread_t* thread) {
|
|||
WaitForSingleObject(*thread, INFINITE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief sends a signal to a thread
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_SignalThread (TRI_thread_t* thread, int signum) {
|
||||
// TODO: NO NATIVE implementation of signals
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief checks if this thread is the thread passed as a parameter
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsSelfThread (TRI_thread_t* thread) {
|
||||
return ( GetCurrentThreadId() == GetThreadId(thread) );
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief allow cancellation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_AllowCancelation(void) {
|
||||
// TODO: No native implementation of this
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -26,13 +26,27 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#include "win-utils.h"
|
||||
|
||||
/*
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <share.h>
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup Windows_Utilties
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int ftruncate(int fd, long newSize) {
|
||||
int result = _chsize(fd, newSize);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int getpagesize(void) {
|
||||
static int pageSize = 0; // only define it once
|
||||
|
|
|
@ -55,6 +55,15 @@ extern "C" {
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// .............................................................................
|
||||
// windows equivalent of ftruncate (the truncation of an open file) is
|
||||
// _chsize
|
||||
// .............................................................................
|
||||
|
||||
int ftruncate (int, long);
|
||||
|
||||
|
||||
// .............................................................................
|
||||
// windows does not have a function called getpagesize -- create one here
|
||||
// .............................................................................
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "Basics/delete_object.h"
|
||||
#include "Basics/ssl-helper.h"
|
||||
#include "Basics/Random.h"
|
||||
#include "Basics/RandomGenerator.h"
|
||||
#include "Dispatcher/ApplicationDispatcher.h"
|
||||
#include "HttpServer/HttpHandlerFactory.h"
|
||||
#include "HttpServer/HttpServer.h"
|
||||
|
@ -262,7 +262,7 @@ bool ApplicationEndpointServer::parsePhase2 (ProgramOptions& options) {
|
|||
}
|
||||
|
||||
OperationMode::server_operation_mode_e mode = OperationMode::determineMode(options);
|
||||
if (0 == _endpoints.size() && mode == OperationMode::MODE_SERVER) {
|
||||
if (_endpoints.size() == 0 && mode == OperationMode::MODE_SERVER) {
|
||||
LOGGER_FATAL << "no endpoint has been specified, giving up";
|
||||
cerr << "no endpoint has been specified, giving up\n";
|
||||
LOGGER_INFO << "please use the '--server.endpoint' option";
|
||||
|
|
|
@ -13,13 +13,13 @@ lib_libarango_a_SOURCES = \
|
|||
lib/Basics/ConditionVariable.cpp \
|
||||
lib/Basics/Exceptions.cpp \
|
||||
lib/Basics/FileUtils.cpp \
|
||||
lib/Basics/Initialise.cpp \
|
||||
lib/Basics/InitialiseBasics.cpp \
|
||||
lib/Basics/LibraryLoader.cpp \
|
||||
lib/Basics/Mutex.cpp \
|
||||
lib/Basics/MutexLocker.cpp \
|
||||
lib/Basics/ProgramOptions.cpp \
|
||||
lib/Basics/ProgramOptionsDescription.cpp \
|
||||
lib/Basics/Random.cpp \
|
||||
lib/Basics/RandomGenerator.cpp \
|
||||
lib/Basics/ReadLocker.cpp \
|
||||
lib/Basics/ReadUnlocker.cpp \
|
||||
lib/Basics/ReadWriteLock.cpp \
|
||||
|
@ -73,7 +73,7 @@ lib_libarango_a_SOURCES = \
|
|||
lib/Rest/Handler.cpp \
|
||||
lib/Rest/HttpRequest.cpp \
|
||||
lib/Rest/HttpResponse.cpp \
|
||||
lib/Rest/Initialise.cpp \
|
||||
lib/Rest/InitialiseRest.cpp \
|
||||
lib/Rest/JsonContainer.cpp \
|
||||
lib/Rest/SslInterface.cpp \
|
||||
lib/Rest/Url.cpp \
|
||||
|
@ -141,7 +141,7 @@ lib_libarango_fe_a_SOURCES = \
|
|||
lib/HttpServer/RedirectHandler.cpp \
|
||||
lib/HttpServer/ServiceUnavailableHandler.cpp \
|
||||
lib/ResultGenerator/HtmlResultGenerator.cpp \
|
||||
lib/ResultGenerator/Initialise.cpp \
|
||||
lib/ResultGenerator/InitialiseGenerator.cpp \
|
||||
lib/ResultGenerator/JsonResultGenerator.cpp \
|
||||
lib/ResultGenerator/JsonXResultGenerator.cpp \
|
||||
lib/ResultGenerator/OutputGenerator.cpp \
|
||||
|
|
|
@ -156,23 +156,6 @@ typedef struct po_visit_functions_s {
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __TCHAR_DEFINED
|
||||
|
||||
struct option * InitOptionStructure (struct option * option,
|
||||
TCHAR const * name,
|
||||
int hasArg,
|
||||
int * flag,
|
||||
int val) {
|
||||
option->name = name;
|
||||
option->has_arg = hasArg;
|
||||
option->flag = flag;
|
||||
option->val = 256 + val;
|
||||
|
||||
return option;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct option * InitOptionStructure (struct option * option,
|
||||
char const * name,
|
||||
int hasArg,
|
||||
|
@ -186,8 +169,6 @@ struct option * InitOptionStructure (struct option * option,
|
|||
return option;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief frees a atomic option
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -229,13 +210,10 @@ static void CreateDoubleOption (po_double_t * desc, void const * input, void * o
|
|||
TRI_program_options_t * po;
|
||||
struct option doubleOpt;
|
||||
|
||||
po = output;
|
||||
po = (TRI_program_options_t*) (output);
|
||||
|
||||
#ifdef __TCHAR_DEFINED
|
||||
InitOptionStructure(&doubleOpt, desc->base._name, 1, 0, po->_longopts._length);
|
||||
#else
|
||||
InitOptionStructure(&doubleOpt, desc->base._name, 1, 0, po->_longopts._length);
|
||||
#endif
|
||||
|
||||
memset(&item, 0, sizeof(item));
|
||||
|
||||
item._desc = &desc->base;
|
||||
|
@ -254,7 +232,7 @@ static void ParseFlagArg (char const * userarg, void * value) {
|
|||
|
||||
assert(value != NULL);
|
||||
|
||||
flag = value;
|
||||
flag = (po_flag_t*) (value);
|
||||
|
||||
if (flag->_value != NULL) {
|
||||
if (userarg == NULL) {
|
||||
|
@ -290,7 +268,7 @@ static void CreateFlagOption (po_flag_t * desc, void const * input, void * outpu
|
|||
TRI_program_options_t * po;
|
||||
struct option flagOpt;
|
||||
|
||||
po = output;
|
||||
po = (TRI_program_options_t*) (output);
|
||||
|
||||
if (desc->_value == 0) {
|
||||
InitOptionStructure(&flagOpt, desc->base._name, 0, 0, po->_longopts._length);
|
||||
|
@ -318,7 +296,7 @@ static void ParseInt16Arg (char const * userarg, void * value) {
|
|||
|
||||
assert(value != NULL);
|
||||
|
||||
desc = value;
|
||||
desc = (po_int16_t*) (value);
|
||||
tmp = TRI_Int32String(userarg);
|
||||
|
||||
if (TRI_errno() == TRI_ERROR_NO_ERROR) {
|
||||
|
@ -340,7 +318,7 @@ void CreateInt16Option (po_int16_t * desc, void const * input, void * output) {
|
|||
TRI_program_options_t * po;
|
||||
struct option intOpt;
|
||||
|
||||
po = output;
|
||||
po = (TRI_program_options_t*) (output);
|
||||
|
||||
InitOptionStructure(&intOpt, desc->base._name, 1, 0, po->_longopts._length);
|
||||
|
||||
|
@ -363,7 +341,7 @@ static void ParseInt32Arg (char const * userarg, void * value) {
|
|||
|
||||
assert(value != NULL);
|
||||
|
||||
desc = value;
|
||||
desc = (po_int32_t*) (value);
|
||||
tmp = TRI_Int32String(userarg);
|
||||
|
||||
if (TRI_errno() == TRI_ERROR_NO_ERROR) {
|
||||
|
@ -380,7 +358,7 @@ void CreateInt32Option (po_int32_t * desc, void const * input, void * output) {
|
|||
TRI_program_options_t * po;
|
||||
struct option intOpt;
|
||||
|
||||
po = output;
|
||||
po = (TRI_program_options_t*) (output);
|
||||
|
||||
InitOptionStructure(&intOpt, desc->base._name, 1, 0, po->_longopts._length);
|
||||
|
||||
|
@ -403,7 +381,7 @@ static void ParseInt64Arg (char const * userarg, void * value) {
|
|||
|
||||
assert(value != NULL);
|
||||
|
||||
desc = value;
|
||||
desc = (po_int64_t*) (value);
|
||||
tmp = TRI_Int64String(userarg);
|
||||
|
||||
if (TRI_errno() == TRI_ERROR_NO_ERROR) {
|
||||
|
@ -420,7 +398,7 @@ static void CreateInt64Option (po_int64_t * desc, void const * input, void * out
|
|||
TRI_program_options_t * po;
|
||||
struct option intOpt;
|
||||
|
||||
po = output;
|
||||
po = (TRI_program_options_t*) (output);
|
||||
|
||||
InitOptionStructure(&intOpt, desc->base._name, 1, 0, po->_longopts._length);
|
||||
|
||||
|
@ -522,7 +500,7 @@ static void CreateUInt16Option (po_uint16_t * desc, void const * input, void * o
|
|||
TRI_program_options_t * po;
|
||||
struct option intOpt;
|
||||
|
||||
po = output;
|
||||
po = (TRI_program_options_t*) (output);
|
||||
|
||||
InitOptionStructure(&intOpt, desc->base._name, 1, 0, po->_longopts._length);
|
||||
|
||||
|
@ -562,7 +540,7 @@ static void CreateUInt32Option (po_uint32_t * desc, void const * input, void * o
|
|||
TRI_program_options_t * po;
|
||||
struct option intOpt;
|
||||
|
||||
po = output;
|
||||
po = (TRI_program_options_t*) (output);
|
||||
|
||||
InitOptionStructure(&intOpt, desc->base._name, 1, 0, po->_longopts._length);
|
||||
|
||||
|
@ -602,7 +580,7 @@ static void CreateUInt64Option (po_uint64_t * desc, void const * input, void * o
|
|||
TRI_program_options_t * po;
|
||||
struct option intOpt;
|
||||
|
||||
po = output;
|
||||
po = (TRI_program_options_t*) (output);
|
||||
|
||||
InitOptionStructure(&intOpt, desc->base._name, 1, 0, po->_longopts._length);
|
||||
|
||||
|
@ -639,7 +617,7 @@ static void CreateVectorStringOption (TRI_PO_vector_string_t * desc, void const
|
|||
TRI_program_options_t * po;
|
||||
struct option vectorOpt;
|
||||
|
||||
po = output;
|
||||
po = (TRI_program_options_t*) (output);
|
||||
|
||||
InitOptionStructure(&vectorOpt, desc->base._name, 1, 0, po->_longopts._length);
|
||||
|
||||
|
@ -995,7 +973,9 @@ TRI_program_options_t * TRI_CreateProgramOptions (TRI_PO_section_t * desc) {
|
|||
po_visit_functions_t optionBuilders;
|
||||
struct option nullOpt;
|
||||
|
||||
po = TRI_Allocate(TRI_CORE_MEM_ZONE, sizeof(TRI_program_options_t), false);
|
||||
po = (TRI_program_options_t*) (TRI_Allocate(TRI_CORE_MEM_ZONE, sizeof(TRI_program_options_t), false));
|
||||
|
||||
// TODO: not safe since po could be 0
|
||||
|
||||
TRI_InitVector(&po->_longopts, TRI_CORE_MEM_ZONE, sizeof(struct option));
|
||||
TRI_InitVector(&po->_items, TRI_CORE_MEM_ZONE, sizeof(TRI_PO_item_t));
|
||||
|
@ -1366,107 +1346,6 @@ char * TRI_UsagePODescription (TRI_PO_section_t * desc) {
|
|||
/// @brief parses a command line of arguments
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __TCHAR_DEFINED
|
||||
|
||||
bool TRI_ParseArgumentsProgramOptions (TRI_program_options_t * options,
|
||||
int argc,
|
||||
char ** argv) {
|
||||
extern TCHAR *optarg;
|
||||
extern int optind;
|
||||
|
||||
TRI_string_buffer_t buffer;
|
||||
TRI_PO_item_t * item;
|
||||
char const* shortOptions;
|
||||
size_t i;
|
||||
int c;
|
||||
int idx;
|
||||
int maxIdx;
|
||||
|
||||
TRI_set_errno(TRI_ERROR_NO_ERROR);
|
||||
|
||||
TRI_InitStringBuffer(&buffer, TRI_CORE_MEM_ZONE);
|
||||
|
||||
for (i = 0; i < options->_items._length; ++i) {
|
||||
item = TRI_AtVector(&options->_items, i);
|
||||
|
||||
if (item->_desc->_short != '\0') {
|
||||
TRI_AppendCharStringBuffer(&buffer, item->_desc->_short);
|
||||
|
||||
if (item->_desc->_type == TRI_PO_FLAG) {
|
||||
po_flag_t* p;
|
||||
|
||||
p = (po_flag_t*) item->_desc;
|
||||
|
||||
if (p->_value != 0) {
|
||||
TRI_AppendCharStringBuffer(&buffer, ':');
|
||||
}
|
||||
}
|
||||
else {
|
||||
TRI_AppendCharStringBuffer(&buffer, ':');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TRI_LengthStringBuffer(&buffer) == 0) {
|
||||
shortOptions = "";
|
||||
}
|
||||
else {
|
||||
shortOptions = TRI_BeginStringBuffer(&buffer);
|
||||
}
|
||||
|
||||
optind = 1;
|
||||
maxIdx = options->_items._length;
|
||||
|
||||
while (true) {
|
||||
c = getopt_long(argc, argv, shortOptions, (const struct option*) options->_longopts._buffer, &idx);
|
||||
|
||||
if (c == -1) {
|
||||
for (i = optind; i < (size_t) argc; ++i) {
|
||||
TRI_PushBackVectorString(&options->_arguments, TRI_DuplicateString(argv[i]));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (c < 256) {
|
||||
for (i = 0; i < options->_items._length; ++i) {
|
||||
item = TRI_AtVector(&options->_items, i);
|
||||
|
||||
if (item->_desc->_short == c) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == options->_items._length) {
|
||||
TRI_set_errno(TRI_ERROR_ILLEGAL_OPTION);
|
||||
TRI_DestroyStringBuffer(&buffer);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
c -= 256;
|
||||
|
||||
if (c >= maxIdx) {
|
||||
TRI_set_errno(TRI_ERROR_ILLEGAL_OPTION);
|
||||
TRI_DestroyStringBuffer(&buffer);
|
||||
return false;
|
||||
}
|
||||
|
||||
item = TRI_AtVector(&options->_items, c);
|
||||
}
|
||||
|
||||
// the opt.. are external variables
|
||||
item->_used = true;
|
||||
item->parse(optarg, item->_desc);
|
||||
}
|
||||
|
||||
TRI_AnnihilateStringBuffer(&buffer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool TRI_ParseArgumentsProgramOptions (TRI_program_options_t * options,
|
||||
int argc,
|
||||
char ** argv) {
|
||||
|
@ -1564,8 +1443,6 @@ bool TRI_ParseArgumentsProgramOptions (TRI_program_options_t * options,
|
|||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief parses a text file containing the configuration variables
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -68,17 +68,6 @@ typedef enum {
|
|||
/// @brief abstract base structure for descriptions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __TCHAR_DEFINED
|
||||
|
||||
typedef struct TRI_PO_desc_s {
|
||||
TRI_PO_description_types_e _type;
|
||||
TCHAR * _name;
|
||||
char _short;
|
||||
char * _desc;
|
||||
} TRI_PO_desc_t;
|
||||
|
||||
#else
|
||||
|
||||
typedef struct TRI_PO_desc_s {
|
||||
TRI_PO_description_types_e _type;
|
||||
char * _name;
|
||||
|
@ -86,7 +75,6 @@ typedef struct TRI_PO_desc_s {
|
|||
char * _desc;
|
||||
} TRI_PO_desc_t;
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief description of attribute of type string
|
||||
|
|
|
@ -384,6 +384,7 @@ AnyServer::~AnyServer () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int AnyServer::start () {
|
||||
|
||||
if (_applicationServer == 0) {
|
||||
buildApplicationServer();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
using namespace triagens::basics;
|
||||
using namespace triagens::rest;
|
||||
using namespace std;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- local constants
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#include "Basics/StringBuffer.h"
|
||||
#include "Rest/ConnectionInfo.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class HttpRequest
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
/// @author Copyright 2009-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Initialise.h"
|
||||
#include "InitialiseRest.h"
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include "build.h"
|
||||
|
||||
#include "Basics/Initialise.h"
|
||||
#include "Basics/InitialiseBasics.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "Rest/HttpResponse.h"
|
||||
#include "Rest/Url.h"
|
|
@ -25,8 +25,8 @@
|
|||
/// @author Copyright 2009-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_FYN_REST_INITIALISE_H
|
||||
#define TRIAGENS_FYN_REST_INITIALISE_H 1
|
||||
#ifndef TRIAGENS_FYN_REST_INITIALISE_REST_H
|
||||
#define TRIAGENS_FYN_REST_INITIALISE_REST_H 1
|
||||
|
||||
#include <Basics/Common.h>
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
#include <openssl/evp.h>
|
||||
#include <openssl/hmac.h>
|
||||
|
||||
#include <Basics/Random.h>
|
||||
#include <Basics/RandomGenerator.h>
|
||||
#include <Basics/StringUtils.h>
|
||||
|
||||
using namespace triagens::basics;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Oreste Costa-Panaia
|
||||
/// @author Dr. O
|
||||
/// @author Copyright 2011, triagens GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
/// @author Copyright 2009-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Initialise.h"
|
||||
#include "InitialiseGenerator.h"
|
||||
|
||||
#include <Rest/Initialise.h>
|
||||
#include <Rest/InitialiseRest.h>
|
||||
|
||||
#include "ResultGenerator/HtmlResultGenerator.h"
|
||||
#include "ResultGenerator/JsonResultGenerator.h"
|
|
@ -25,8 +25,8 @@
|
|||
/// @author Copyright 2009-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_FYN_REST_INITIALISE2_H
|
||||
#define TRIAGENS_FYN_REST_INITIALISE2_H 1
|
||||
#ifndef TRIAGENS_FYN_REST_INITIALISE_GENERATOR_H
|
||||
#define TRIAGENS_FYN_REST_INITIALISE_GENERATOR_H 1
|
||||
|
||||
#include <Basics/Common.h>
|
||||
|
|
@ -63,8 +63,8 @@ namespace {
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
bool static CtrlHandler(DWORD eventType);
|
||||
static SignalTask* localSignalTask;
|
||||
bool static CtrlHandler(DWORD eventType);
|
||||
static SignalTask* localSignalTask;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -184,6 +184,7 @@ namespace {
|
|||
Scheduler* _scheduler;
|
||||
};
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "Scheduler/Scheduler.h"
|
||||
|
||||
using namespace triagens::rest;
|
||||
using namespace std;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
|
|
Loading…
Reference in New Issue