You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.2 KiB
91 lines
2.2 KiB
// NOTE: This file contains the main entry points into the DLL, so everything needs "C" linkage.
|
|
// It's called from C#, so strings need to be BSTR's.
|
|
|
|
#include <stdexcept>
|
|
#include "api.hpp"
|
|
#include "globals.hpp"
|
|
#include "utils.hpp"
|
|
|
|
using namespace std ;
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
extern "C" __declspec(dllexport) BSTR
|
|
open_api( PCALLBACKFN pCallbackFn , const wchar_t* pDebugConfigFilename )
|
|
{
|
|
// open the API
|
|
try
|
|
{
|
|
openApi( pCallbackFn , pDebugConfigFilename ) ;
|
|
return NULL ;
|
|
}
|
|
catch ( exception& xcptn )
|
|
{
|
|
return SysAllocString( fromUtf8( MAKE_STRING(xcptn) ).c_str() ) ;
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
extern "C" __declspec(dllexport) BSTR
|
|
close_api()
|
|
{
|
|
// close the API
|
|
try
|
|
{
|
|
closeApi() ;
|
|
return NULL ;
|
|
}
|
|
catch ( exception& xcptn )
|
|
{
|
|
return SysAllocString( fromUtf8( MAKE_STRING(xcptn) ).c_str() ) ;
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
extern "C" __declspec(dllexport) BSTR
|
|
reload_config(
|
|
const ApiAppConfig* pAppConfig ,
|
|
const ApiDevice* pDevices , int nDevices ,
|
|
const ApiDeviceConfig* pDeviceConfigs , int nDeviceConfigs ,
|
|
const ApiAppProfile* pAppProfiles , int nAppProfiles ,
|
|
const ApiEvent* pEvents , int nEvents ,
|
|
const ApiAction* pActions , int nActions
|
|
)
|
|
{
|
|
// reload the config
|
|
try
|
|
{
|
|
reloadConfig(
|
|
pAppConfig ,
|
|
pDevices , nDevices ,
|
|
pDeviceConfigs , nDeviceConfigs ,
|
|
pAppProfiles , nAppProfiles ,
|
|
pEvents , nEvents ,
|
|
pActions , nActions
|
|
) ;
|
|
return NULL ;
|
|
}
|
|
catch ( exception& xcptn )
|
|
{
|
|
return SysAllocString( fromUtf8( MAKE_STRING(xcptn) ).c_str() ) ;
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
extern "C" __declspec(dllexport) BSTR
|
|
run_main_loop( int* pExitFlag )
|
|
{
|
|
// run the main loop
|
|
try
|
|
{
|
|
runMainLoop( pExitFlag ) ;
|
|
return NULL ;
|
|
}
|
|
catch ( exception& xcptn )
|
|
{
|
|
return SysAllocString( fromUtf8( MAKE_STRING(xcptn) ).c_str() ) ;
|
|
}
|
|
}
|
|
|