Ejemplo n.º 1
0
/* EXPORT->InitMem: Initialise the module.  */
void InitMem(void)
{
   int i;
   Boolean b;
   
   Register(hmem_version, hmem_vc_id);
   CreateHeap(&gstack, "Global Stack",  MSTAK, 1, 0.0, 100000, ULONG_MAX ); /* #### should be max size_t */
   CreateHeap(&gcheap, "Global C Heap", CHEAP, 1, 0.0, 0,      0 );
   numParm = GetConfig("HMEM", TRUE, cParm, MAXGLOBS);
   if (numParm>0){
      if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i;
      if (GetConfBool(cParm,numParm,"PROTECTSTAKS",&b)) protectStaks = b;
   }
}
Ejemplo n.º 2
0
#define T_CMV     0012           /* doing CMV */



static int  trace    = 0;           /* trace level */

static ConfParam *cParm[MAXGLOBS];   /* configuration parameters */

static int nParm = 0;               /* total num params */



/* ---------------------- Global Variables ----------------------- */
Ejemplo n.º 3
0
extern "C" void Init(const char* serverType, int argc, char* argv[], HandleNameHandleChangedPtr nameHandleCallback, HandleMessagePtr msgCallback, HandleMessageResultPtr msgResultCallback, HandleCommandPtr cmdCallback)
{
#if defined(__LINUX__)
  signal(SIGPIPE, SIG_IGN);
#endif

  InitConfigState(serverType, argc, argv);

  const char* pIp = GetConfig("ip");
  if (NULL == pIp)
    pIp = "127.0.0.1";
  const char* pPort = GetConfig("port");
  int port = 20000;
  if (NULL != pPort)
    port = (int)atoi(pPort);

  tsnprintf(g_Ip, sizeof(g_Ip), "%s", pIp);
  g_Port = port;

  g_HandleNameHandleChangedPtr = nameHandleCallback;
  g_HandleMessagePtr = msgCallback;
  g_HandleMessageResultPtr = msgResultCallback;
  g_HandleCommandPtr = cmdCallback;

  g_pSessionManager = new SessionManager();
  if (NULL != g_pSessionManager) {
    g_pSessionManager->Init();
    g_pSessionManager->UpdateMyName();
  }

  g_pNetIoService = new NetIoService();
  g_pNetIoService->Init();
  g_EventBase = g_pNetIoService->EventBase();
  if (NULL != g_EventBase) {
    g_Connector = new Connector(g_EventBase);
  }
}
Ejemplo n.º 4
0
void wxGISMapView::StartFlashing(wxGISEnumFlashStyle eFlashStyle)
{
    m_eFlashStyle = eFlashStyle;

    Flash(eFlashStyle);

    Refresh();

    //wait drawings end to flash
    if (GetThread() && GetThread()->IsRunning())
    {
        GetThread()->Wait();
    }

    int nMilliSec = DEFAULT_FLASH_PERIOD;
    switch(eFlashStyle)
    {
    case enumGISMapFlashWaves:
        nMilliSec /= 2;
        {
        wxGISAppConfig oConfig = GetConfig();
        if(oConfig.IsOk())
            nMilliSec = oConfig.ReadInt(enumGISHKCU, wxString(wxT("wxGISCommon/map/flash_waves_time")), nMilliSec);
        }
        break;
    default:
    case enumGISMapFlashNewColor:
        {
        wxGISAppConfig oConfig = GetConfig();
        if(oConfig.IsOk())
            nMilliSec = oConfig.ReadInt(enumGISHKCU, wxString(wxT("wxGISCommon/map/flash_newcolor_time")), nMilliSec);
        }
        break;
    };
    m_nDrawingState = enumGISMapFlashing;
    m_timer.Start(nMilliSec);
}
Ejemplo n.º 5
0
bool wxGISCatalogMainCmd::OnCreate(wxGISApplicationBase* pApp)
{
	m_pApp = pApp;
    m_pGxApp = dynamic_cast<wxGxApplicationBase*>(pApp);
    if(m_pApp)
    {
        wxGISAppConfig oConfig = GetConfig();
        if(oConfig.IsOk())
            m_nPrevNextSelCount = oConfig.ReadInt(enumGISHKCU, m_pApp->GetAppName() + wxString(wxT("/catalog/prev_next_sel_count")), 7);
    }
    else
        m_nPrevNextSelCount = 7;

	return true;
}
Ejemplo n.º 6
0
void wxGISTaskManager::StartTaskManagerServer()
{
#ifdef __WXMSW__
    wxString sTaskMngrServerPath(wxT("wxgistaskmanager.exe"));
#else
    wxString sTaskMngrServerPath(wxT("wxgistaskmanager"));
#endif
    wxGISAppConfig oConfig = GetConfig();
    if(oConfig.IsOk())
        sTaskMngrServerPath = oConfig.Read(enumGISHKCU, wxString(wxT("wxGISCommon/tasks/exe_path")), sTaskMngrServerPath);
    if(wxExecute(sTaskMngrServerPath + wxT(" -a"), wxEXEC_ASYNC | wxEXEC_HIDE_CONSOLE ) == 0)
    {
        wxLogError(_("Task Manager Server start failed. Path '%s'"), sTaskMngrServerPath.c_str());
    }
}
Ejemplo n.º 7
0
int main()
{
    Gateway gate;

    auto cfg = GetConfig();
    if (cfg.empty()) {
        return 0;
    }

    try {
        gate.Run(cfg[0], cfg[1], atoi(cfg[2].c_str()));
    } catch (std::exception& e) {
        LOG("exception: %s", e.what());
    }
}
Ejemplo n.º 8
0
_Use_decl_annotations_
Texture AssetLoader::LoadTextureFromFile(const char* filename, bool supportsMips) const
{
    char source[MAX_PATH];
    sprintf_s(source, "%s%s", GetConfig().ContentRoot, filename);

    ImageFileData data;
    LoadImageFileData(source, &data);

    Texture texture(LoadTextureFromMemory(data.Width, data.Height, data.Pitch, data.Data, data.Format, data.MipCount, supportsMips));

    FreeImageFileData(&data);

    return texture;
}
Ejemplo n.º 9
0
char *lpcalc_vc_id = "$Id: LPCalc.c,v 1.1.1.1 2006/10/11 09:54:43 jal58 Exp $";



#include "HShell.h"     /* HMM ToolKit Modules */

#include "HMem.h"

#include "HMath.h"

#include "HWave.h"

#include "HLabel.h"

#include "LWMap.h"      
Ejemplo n.º 10
0
bool
FlarmDevice::GetBaudRate(unsigned &baud_id, OperationEnvironment &env)
{
  TCHAR buffer[12];
  if (!GetConfig("BAUD", buffer, ARRAY_SIZE(buffer), env))
    return false;

  TCHAR *end_ptr;
  unsigned value = ParseUnsigned(buffer, &end_ptr, 10);
  if (end_ptr == buffer)
    return false;

  baud_id = value;
  return true;
}
Ejemplo n.º 11
0
Buffer *ConfigStore::GetConfigAsBuffer(const char *key, const char *def)
{
        const char *value = NULL;

        value = (char *)GetConfig(key);
        if (value == NULL) {
                if (def == NULL) {
                        return NULL;
                } else {
                  return Util::Str2Buf(def);
                }
        } else {
                return Util::Str2Buf(value);
        }
}
Ejemplo n.º 12
0
	codeare::error_code
	RemoteConnector::Init (const std::string& name) {
		
		// Prepare configuration for the journey
		std::stringstream  temp;
		temp << GetConfig();
		m_rrsi->config  (temp.str().c_str());
		
		// Initialise back end
        if (m_rrsi->Init (name.c_str(), m_client_id.c_str()) != codeare::OK)
	  return codeare::CANNOT_LOAD_LIBRARY;
		
		return (codeare::error_code)codeare::OK;
		
	}
Ejemplo n.º 13
0
_Use_decl_annotations_
void AssetLoader::GetTextureMetadata(const char* filename, TextureMetadata* metadata) const
{
    char source[MAX_PATH];
    sprintf_s(source, "%s%s", GetConfig().ContentRoot, filename);

    ImageMetadata data;
    DDSGetImageMetadata(filename, &data);

    ZeroMemory(metadata, sizeof(TextureMetadata));
    metadata->Width = data.Width;
    metadata->Height = data.Height;
    metadata->Format = data.Format;
    metadata->MipLevels = data.MipLevels;
}
Ejemplo n.º 14
0
void CCopyHandlerApp::OnConfigNotify(uint_t uiPropID)
{
	// is this language
	switch(uiPropID)
	{
	case PP_PLANGUAGE:
		{
			// update language in resource manager
			TCHAR szPath[_MAX_PATH];
			GetConfig().get_string(PP_PLANGUAGE, szPath, _MAX_PATH);
			GetResManager().SetLanguage(ExpandPath(szPath));
			break;
		}
	case PP_LOGENABLELOGGING:
		{
			chcore::TLogger& rLogger = chcore::TLogger::Acquire();

			rLogger.Enable(GetConfig().get_bool(PP_LOGENABLELOGGING));
			break;
		}
	case PP_LOGLEVEL:
		{
			chcore::TLogger& rLogger = chcore::TLogger::Acquire();

			rLogger.set_log_level((int_t)GetConfig().get_unsigned_num(PP_LOGLEVEL));
			break;
		}
	case PP_LOGMAXSIZE:
		{
			chcore::TLogger& rLogger = chcore::TLogger::Acquire();

			rLogger.set_max_size((int_t)GetConfig().get_signed_num(PP_LOGMAXSIZE));
			break;
		}
	}
}
Ejemplo n.º 15
0
bool
FlarmDevice::GetRange(unsigned &range, OperationEnvironment &env)
{
  TCHAR buffer[12];
  if (!GetConfig("RANGE", buffer, ARRAY_SIZE(buffer), env))
    return false;

  TCHAR *end_ptr;
  unsigned value = ParseUnsigned(buffer, &end_ptr, 10);
  if (end_ptr == buffer)
    return false;

  range = value;
  return true;
}
Ejemplo n.º 16
0
/**
 * Retrieves configuration value as boolean. If name is
 * not defined, default value is returned.
 */
TPS_PUBLIC bool ConfigStore::GetConfigAsBool(const char *name, bool def)
{
        char *value = NULL;

        value = (char *)GetConfig(name);
        if (value == NULL)
                return def;

        if (PL_CompareStrings("true", value) != 0)
          return true;
	else if (PL_CompareStrings("false", value) != 0)
	  return false;
	else
	  return def;
}
Ejemplo n.º 17
0
bool
FlarmDevice::GetRange(unsigned &range)
{
  TCHAR buffer[12];
  if (!GetConfig("RANGE", buffer, ARRAY_SIZE(buffer)))
    return false;

  TCHAR *end_ptr;
  unsigned value = _tcstoul(buffer, &end_ptr, 10);
  if (end_ptr == buffer)
    return false;

  range = value;
  return true;
}
Ejemplo n.º 18
0
_Use_decl_annotations_
SpriteFont AssetLoader::LoadSpriteFontFromFile(const char* filename) const
{
    char source[MAX_PATH];
    sprintf_s(source, "%s%s", GetConfig().ContentRoot, filename);

    SpriteFontFileData data;
    LoadSpriteFontFileData(source, &data);

    SpriteFont spriteFont(SpriteFont::Load(&data));

    FreeSpriteFontFileData(&data);

    return spriteFont;
}
Ejemplo n.º 19
0
void CLATEDView::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) 
{
    HTREEITEM hItem;
    CLCConfig* pConfig = NULL;
    CLCBase* pBase = NULL;
    CLCDataType* pType = NULL;

	TV_DISPINFO* pTVDispInfo = (TV_DISPINFO*)pNMHDR;
    ASSERT(pTVDispInfo);
	*pResult = FALSE;

    if(!pTVDispInfo->item.pszText) {
        return;
    }

    hItem = pTVDispInfo->item.hItem;
    if(!hItem) {
        return;
    }

    pConfig = GetConfig();
    if(!pConfig) {
        return;
    }

    pBase = GetNode(hItem);
    if(!pBase) {
        return;
    }


    pType = dynamic_cast<CLCDataType*>(pBase);
    if(pType) {
        //rename a datatype;
        CString str = pTVDispInfo->item.pszText;
        CLCDataType* p = pConfig->GetDatatype(str);
        if(p && p != pType) { //another datatype has same name
            FC_RELEASE_PTR(p);    
            return;
        }

        FC_RELEASE_PTR(p);
        pConfig->RenameDatatype(str,pType);
        SetModified();
        *pResult = TRUE;
        return;
    }
}
Ejemplo n.º 20
0
void RedisConfigUI::DoApplyData()
{
	CEditUI exampleEditUI;
	CComboUI exampleComboUI;

	RedisClient::TDicConfig::const_iterator it = m_dicConfig.begin();
	RedisClient::TDicConfig::const_iterator itend = m_dicConfig.end();
	RedisClient::TDicConfig config;
	for ( ; it!=itend; ++it)
	{
		CDuiString name = _T("redisconfig_");
		CDuiString key = CharacterSet::ANSIToUnicode(it->first).c_str();	
		name.Append(key);
		CControlUI* pCtl = GetPaintMgr()->FindControl(name);

		string val ;
		if (pCtl->GetClass() == exampleEditUI.GetClass())
		{
			CEditUI* pEdit = static_cast<CEditUI*> (pCtl);
			val = CharacterSet::UnicodeToANSI(pEdit->GetText().GetData());
		}
		else if (pCtl->GetClass() == exampleComboUI.GetClass())
		{
			CComboUI* pCombo = static_cast<CComboUI*> (pCtl);
			int idx = pCombo->GetCurSel();
			if (it->first == "loglevel")
			{
				if (idx == 0) val = "debug";
				else if (idx == 1) val = "verbose";
				else if (idx == 2) val = "notice";
				else if (idx == 3) val = "warning";
			}
			else 
			{
				if (idx == 0) val = "yes";
				else if (idx == 1) val = "no";
			}
		}
		if (val != it->second)
		{
			config.insert(std::make_pair(it->first, val));
		}
	}
	if (SetConfig(config) && GetConfig())
	{
		DoFillData();
	}
}
Ejemplo n.º 21
0
////////////////////////////////////////////////////////////////////////////////
/// Process incoming requests
int CameraV4L2::HandleRequests()
{
    void *client;
    char request[PLAYER_MAX_REQREP_SIZE];
    char outBuf[PLAYER_MAX_REQREP_SIZE];
    int len;


    while ((len = GetConfig(&client, &request, sizeof(request),NULL)) > 0)
    {
        int ret = -1;
        PLAYER_MSG2(2,"Got Reguest %c (size: %d)", request[0], len);
        if (len>1 && (request[0]=='g' || request[0]=='G')){
            // pobranie jakiejs wartosci
            PLAYER_MSG0(2,"Get type request");
            ret = handleCommand(request, len, outBuf, PLAYER_MAX_REQREP_SIZE-1);

            if (ret==0) {
                outBuf[PLAYER_MAX_REQREP_SIZE-1] = '\0';
                PLAYER_MSG1(2,"Sending Ack: %s", outBuf);
                if (PutReply(client, PLAYER_MSGTYPE_RESP_ACK, outBuf, strlen(outBuf)+1,NULL) != 0)
                    PLAYER_ERROR("PutReply() failed");
            } else {
                PLAYER_MSG0(2,"Sendinf NACK");
                if (PutReply(client, PLAYER_MSGTYPE_RESP_NACK,NULL) != 0)
                    PLAYER_ERROR("PutReply() failed");
            }

        } else {
            if (len>0) {
                ret = handleCommand(request, len);
            }

            if (ret == 0){
                PLAYER_MSG0(2,"Sending Ack");
                if (PutReply(client, PLAYER_MSGTYPE_RESP_ACK,NULL) != 0)
                    PLAYER_ERROR("PutReply() failed");
            } else {
                PLAYER_MSG0(2,"Sending Nack");
                if (PutReply(client, PLAYER_MSGTYPE_RESP_NACK,NULL) != 0)
                    PLAYER_ERROR("PutReply() failed");
            }
        }
        // if framegrabber is slow(1-10s), it is worth handling all commands at once
        //usleep(30000);
    }
    return 0;
}
Ejemplo n.º 22
0
bool Game::Fail(){
	StatusUnstable();
	ExecTrials++;
	if(ExecTrials >= GetConfig()->MaxExecTrials) {
		Status = Failed;
		GetOut()->Put(Parent, OutPrefix, " Maximum execution attempts for game exceeded.", NULL);
		StatusStable();
		return true;
	} else {
		StatusStable();
		if(cleanup) return true;
		Halt(5);
		Start();
		return false;
	}
}
Ejemplo n.º 23
0
/* EXPORT->InitMap: initialise configuration parameters */
void InitMap(void)
{
   int i;
   double f;

   Register(hmap_version,hmap_vc_id);
   nParm = GetConfig("HMAP", TRUE, cParm, MAXGLOBS);
   if (nParm>0){
     if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i;
     if (GetConfInt(cParm,nParm,"MINEGS",&i)) minEgs = i;
     if (GetConfFlt(cParm,nParm,"MINOBS",&f)) minObs = f;
     if (GetConfFlt(cParm,nParm,"MINVAR",&f)) minVar = f;
     if (GetConfFlt(cParm,nParm,"MAPTAU",&f)) mapTau = f;
     if (GetConfFlt(cParm,nParm,"MIXWEIGHTFLOOR",&f)) mixWeightFloor = MINMIX*f;
   }
}
Ejemplo n.º 24
0
mongo::DBClientConnection& GetDB() {
	if(!connected) {
		std::string host(GetConfig().GetAttribute("Database.host").ToString());
		LOGINFO("正在连接到 " + host + " 的 mongodb 服务器");
		try {
			dbconnection.connect(host);
			connected = true;
			LOGINFO("已连接");
		} catch(mongo::DBException &e) {
			LOGERROR("连接数据库时发生错误: " + e.toString());
			throw FCException("无法连接至数据库");
		}
	}

	return dbconnection;
}
Ejemplo n.º 25
0
bool
FlarmDevice::GetStealthMode(bool &enabled)
{
  TCHAR buffer[2];
  if (!GetConfig("PRIV", buffer, ARRAY_SIZE(buffer)))
    return false;

  if (buffer[0] == _T('1'))
    enabled = true;
  else if (buffer[0] == _T('0'))
    enabled = false;
  else
    return false;

  return true;
}
Ejemplo n.º 26
0
error_code cellKbGetConfiguration(u32 port_no, vm::ptr<CellKbConfig> config)
{
	sys_io.trace("cellKbGetConfiguration(port_no=%d, config=*0x%x)", port_no, config);

	const auto handler = fxm::get<KeyboardHandlerBase>();

	if (!handler)
		return CELL_KB_ERROR_UNINITIALIZED;

	const KbConfig& current_config = handler->GetConfig(port_no);
	config->arrange = current_config.arrange;
	config->read_mode = current_config.read_mode;
	config->code_type = current_config.code_type;

	return CELL_OK;
}
Ejemplo n.º 27
0
bool
FlarmDevice::GetStealthMode(bool &enabled, OperationEnvironment &env)
{
  char buffer[2];
  if (!GetConfig("PRIV", buffer, ARRAY_SIZE(buffer), env))
    return false;

  if (buffer[0] == '1')
    enabled = true;
  else if (buffer[0] == '0')
    enabled = false;
  else
    return false;

  return true;
}
Ejemplo n.º 28
0
/**
 * Retrieves configuration value as unsigned integer. If name is
 * not defined, default value is returned.
 */
TPS_PUBLIC unsigned int ConfigStore::GetConfigAsUnsignedInt(const char *name, unsigned int def)
{
        char *value = NULL;
		int i = 0;

        value = (char *)GetConfig(name);
        if (value == NULL) {
          return def;
        }

        i = atoi(value);
        if (i < 0) {
          return def;
        }
        return i;
}
Ejemplo n.º 29
0
// Constructor: builds a Grammar from given file, or empty gram if no file
AGram::AGram(const string& name, const string& fname):AResource(name)
{
   ConfParam *cParm[MAXGLOBS];       /* config parameters */
   int numParm,i;
   char buf[100];

   main = NULL; isOpen = TRUE;
   // Read configuration file
   strcpy(buf,name.c_str());
   for (i=0; i<int(strlen(buf)); i++) buf[i] = toupper(buf[i]);
   numParm = GetConfig(buf, TRUE, cParm, MAXGLOBS);
   if (numParm>0){
      if (GetConfInt(cParm,numParm,"TRACE",&i)) trace = i;
   }
   if (fname!="") InitFromFile(fname.c_str());
   isOpen = FALSE;
}
Ejemplo n.º 30
0
bool CPDF_OCContext::LoadOCGStateFromConfig(
    const ByteString& csConfig,
    const CPDF_Dictionary* pOCGDict) const {
  CPDF_Dictionary* pConfig = GetConfig(m_pDocument.Get(), pOCGDict);
  if (!pConfig)
    return true;

  bool bState = pConfig->GetStringFor("BaseState", "ON") != "OFF";
  CPDF_Array* pArray = pConfig->GetArrayFor("ON");
  if (pArray) {
    if (FindGroup(pArray, pOCGDict) >= 0)
      bState = true;
  }
  pArray = pConfig->GetArrayFor("OFF");
  if (pArray) {
    if (FindGroup(pArray, pOCGDict) >= 0)
      bState = false;
  }
  pArray = pConfig->GetArrayFor("AS");
  if (!pArray)
    return bState;

  ByteString csFind = csConfig + "State";
  for (size_t i = 0; i < pArray->size(); i++) {
    CPDF_Dictionary* pUsage = pArray->GetDictAt(i);
    if (!pUsage)
      continue;

    if (pUsage->GetStringFor("Event", "View") != csConfig)
      continue;

    CPDF_Array* pOCGs = pUsage->GetArrayFor("OCGs");
    if (!pOCGs)
      continue;

    if (FindGroup(pOCGs, pOCGDict) < 0)
      continue;

    CPDF_Dictionary* pState = pUsage->GetDictFor(csConfig);
    if (!pState)
      continue;

    bState = pState->GetStringFor(csFind) != "OFF";
  }
  return bState;
}