Example #1
0
void CEMSocket::AssertValid() const
{
    CEncryptedStreamSocket::AssertValid();

    const_cast<CEMSocket*>(this)->sendLocker.Lock();

    ASSERT( byConnected==ES_DISCONNECTED || byConnected==ES_NOTCONNECTED || byConnected==ES_CONNECTED );
    CHECK_BOOL(m_bProxyConnectFailed);
    CHECK_PTR(m_pProxyLayer);
    (void)downloadLimit;
    CHECK_BOOL(downloadLimitEnable);
    CHECK_BOOL(pendingOnReceive);
    //char pendingHeader[PACKET_HEADER_SIZE];
    pendingHeaderSize;
    CHECK_PTR(pendingPacket);
    (void)pendingPacketSize;
    CHECK_ARR(sendbuffer, sendblen);
    (void)sent;
    controlpacket_queue.AssertValid();
    standartpacket_queue.AssertValid();
    CHECK_BOOL(m_currentPacket_is_controlpacket);
    //(void)sendLocker;
    (void)m_numberOfSentBytesCompleteFile;
    (void)m_numberOfSentBytesPartFile;
    (void)m_numberOfSentBytesControlPacket;
    CHECK_BOOL(m_currentPackageIsFromPartFile);
    (void)lastCalledSend;
    (void)m_actualPayloadSize;
    (void)m_actualPayloadSizeSent;

    const_cast<CEMSocket*>(this)->sendLocker.Unlock();
}
Example #2
0
END_TEST

/* Miscellaneous */

START_TEST (test_misc)
{
  enum { MAX_BUFFER_SIZE = 512 };

  XML_Char buffer[MAX_BUFFER_SIZE] = _XT("");

  scew_writer *writer = scew_writer_buffer_create (buffer, MAX_BUFFER_SIZE);

  CHECK_PTR (writer, "Unable to create buffer writer");

  CHECK_BOOL (scew_writer_end (writer), SCEW_FALSE,
              "Writer should be at the beginning");

  CHECK_BOOL (scew_writer_error (writer), SCEW_FALSE,
              "Writer should have no error (nothing done yet)");

  /* Close writer */
  scew_writer_close (writer);

  CHECK_BOOL (scew_writer_end (writer), SCEW_TRUE,
              "Writer is closed, thus at the end");

  scew_writer_free (writer);
}
void FileAttributes::Load(TiXmlElement * node)
{
    CHECK_BOOL(node != NULL,
        L"Expected 'fileattributes' node");

    CHECK_BOOL(0 == strcmp(node->Value(), "fileattributes"),
        L"Expected 'fileattributes' node, got '" << DVLib::string2wstring(node->Value()) << L"'");

    TiXmlNode * child = NULL;
    while( (child = node->IterateChildren(child)) != NULL )
    {
        TiXmlElement * child_element = child->ToElement();

        if (child_element == NULL)
            continue;

        if (strcmp(child_element->Value(), "fileattribute") == 0)
        {
            FileAttributePtr fileattribute(new FileAttribute());
            fileattribute->Load(child_element);
            (* this)[fileattribute->name] = fileattribute;
        }
        else
        {
            THROW_EX(L"Unexpected node '" << child_element->Value() << L"'");
        }
    }

    LOG(L"Read " << size() << L" file attribute(s)");
}
void ExeComponent::Wait(DWORD tt)
{
    ProcessComponent::Wait(tt);

    DWORD exitcode = ProcessComponent::GetProcessExitCode();

    LOG(L"Component '" << id << "' return code " << exitcode
        << DVLib::FormatMessage(L" (0x%x).", exitcode));

    // check for reboot
    if (! returncodes_reboot.empty() && IsReturnCode(exitcode, returncodes_reboot))
    {
        LOG(L"Component '" << id << "' return code '" << exitcode
            << L", defined as reboot required in '" << returncodes_reboot << L".");
        return;
    }

    // check for explicit success, where defined
    if (returncodes_success.empty())
    {
        CHECK_BOOL(ERROR_SUCCESS == exitcode,
                   L"Error executing '" << id << "' (" << GetDisplayName() << L"): " << exitcode << DVLib::FormatMessage(L" (0x%x)", exitcode));
    }
    else
    {
        CHECK_BOOL(IsReturnCode(exitcode, returncodes_success),
                   L"Error executing component '" << id << "' (" << GetDisplayName() << L"), return code "
                   << exitcode << DVLib::FormatMessage(L" (0x%x)", exitcode)
                   << L" is not in '" << returncodes_success << L"'");

        LOG(L"Component '" << id << "' (" << GetDisplayName() << L") return code " << exitcode
            << DVLib::FormatMessage(L" (0x%x)", exitcode)
            << L", defined as success in '" << returncodes_success << L"'.");
    }
}
Example #5
0
static void dwc2_check_params(struct dwc2_hsotg *hsotg)
{
	struct dwc2_hw_params *hw = &hsotg->hw_params;
	struct dwc2_core_params *p = &hsotg->params;
	bool dma_capable = !(hw->arch == GHWCFG2_SLAVE_ONLY_ARCH);

	dwc2_check_param_otg_cap(hsotg);
	dwc2_check_param_phy_type(hsotg);
	dwc2_check_param_speed(hsotg);
	dwc2_check_param_phy_utmi_width(hsotg);
	CHECK_BOOL(enable_dynamic_fifo, hw->enable_dynamic_fifo);
	CHECK_BOOL(en_multiple_tx_fifo, hw->en_multiple_tx_fifo);
	CHECK_BOOL(i2c_enable, hw->i2c_enable);
	CHECK_BOOL(reload_ctl, (hsotg->hw_params.snpsid > DWC2_CORE_REV_2_92a));
	CHECK_RANGE(max_packet_count,
		    15, hw->max_packet_count,
		    hw->max_packet_count);
	CHECK_RANGE(max_transfer_size,
		    2047, hw->max_transfer_size,
		    hw->max_transfer_size);

	if ((hsotg->dr_mode == USB_DR_MODE_HOST) ||
	    (hsotg->dr_mode == USB_DR_MODE_OTG)) {
		CHECK_BOOL(host_dma, dma_capable);
		CHECK_BOOL(dma_desc_enable, p->host_dma);
		CHECK_BOOL(dma_desc_fs_enable, p->dma_desc_enable);
		CHECK_BOOL(host_ls_low_power_phy_clk,
			   p->phy_type == DWC2_PHY_TYPE_PARAM_FS);
		CHECK_RANGE(host_channels,
			    1, hw->host_channels,
			    hw->host_channels);
		CHECK_RANGE(host_rx_fifo_size,
			    16, hw->rx_fifo_size,
			    hw->rx_fifo_size);
		CHECK_RANGE(host_nperio_tx_fifo_size,
			    16, hw->host_nperio_tx_fifo_size,
			    hw->host_nperio_tx_fifo_size);
		CHECK_RANGE(host_perio_tx_fifo_size,
			    16, hw->host_perio_tx_fifo_size,
			    hw->host_perio_tx_fifo_size);
	}

	if ((hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) ||
	    (hsotg->dr_mode == USB_DR_MODE_OTG)) {
		CHECK_BOOL(g_dma, dma_capable);
		CHECK_BOOL(g_dma_desc, (p->g_dma && hw->dma_desc_enable));
		CHECK_RANGE(g_rx_fifo_size,
			    16, hw->rx_fifo_size,
			    hw->rx_fifo_size);
		CHECK_RANGE(g_np_tx_fifo_size,
			    16, hw->dev_nperio_tx_fifo_size,
			    hw->dev_nperio_tx_fifo_size);
		dwc2_check_param_tx_fifo_sizes(hsotg);
	}
}
Example #6
0
void CAbstractFile::AssertValid() const
{
	CObject::AssertValid();
	(void)m_strFileName;
	(void)m_abyFileHash;
	(void)m_nFileSize;
	(void)m_strComment;
	(void)m_uRating;
	(void)m_strFileType;
	(void)m_uUserRating;
	CHECK_BOOL(m_bHasComment);
	CHECK_BOOL(m_bCommentLoaded);
	taglist.AssertValid();
}
void EmbedFile::Load(TiXmlElement * node)
{
    CHECK_BOOL(node != NULL,
        L"Expected 'embedfile' node");

    CHECK_BOOL(0 == strcmp(node->Value(), "embedfile"),
        L"Expected 'embedfile' node, got '" << DVLib::string2wstring(node->Value()) << L"'");

    sourcefilepath = node->Attribute("sourcefilepath");
    targetfilepath = node->Attribute("targetfilepath");

    LOG(L"Read 'embedfile', source=" << sourcefilepath
        << L", target=" << targetfilepath);
}
void CLanguageSelectorDialog::OnOK()
{
    Configuration * p = static_cast<Configuration *>(m_listLanguages.GetItemDataPtr(m_listLanguages.GetCurSel()));
    CHECK_BOOL(p != NULL, L"Missing configuration");

    CHECK_BOOL(! p->language_id.empty(),
        L"Chosen configuration of type '" << p->type << L"' is missing a language_id");

    LOG(L"User-chosen language id: " << p->language_id);
    InstallerSession::Instance->languageid = DVLib::wstring2long(p->language_id);
    InstallerSession::Instance->language = p->GetLanguageString();

    CDialog::OnOK();
}
void ConfigFileManager::CreateInstallerWindow(const std::wstring& title)
{
	if (m_pInstallerWindow != NULL)
	{
		delete m_pInstallerWindow;
		m_pInstallerWindow = NULL;
	}

	MONITORINFO mi = { 0 };
	mi.cbSize = sizeof(mi);
	CHECK_WIN32_BOOL(GetMonitorInfo(MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY), & mi),
		L"GetMonitorInfo");

	int cx = 640;
	int cy = 480;

	m_pInstallerWindow = new InstallerWindow(); // deletes itself
	m_pInstallerWindow->Create(
		(mi.rcWork.left + mi.rcWork.right) / 2 - cx / 2, 
		(mi.rcWork.top + mi.rcWork.bottom) / 2 - cy / 2, 
		cx, cy, title.c_str());

	CHECK_BOOL(m_pInstallerWindow->hwnd != NULL,
		L"InstallerWindow::Create");
}
Example #10
0
//setters
int ElementFormControlSetAttrdisabled(lua_State* L)
{
    ElementFormControl* efc = LuaType<ElementFormControl>::check(L,1);
    LUACHECKOBJ(efc);
    efc->SetDisabled(CHECK_BOOL(L,2));
    return 0;
}
bool ConfigFileManager::OnRunConfiguration(const ConfigurationPtr& config)
{
	InstallConfiguration * p_configuration = reinterpret_cast<InstallConfiguration *>(get(config));
	CHECK_BOOL(p_configuration != NULL, L"Invalid configuration");
	CreateInstallerWindow(p_configuration->dialog_caption);
	return m_pInstallerWindow->RunInstallConfiguration(config, config != (* this)[size() - 1]);
}
void ConfigFileManager::CreateDownloadWindow(const DownloadDialogPtr& dialog)
{
	if (m_pDownloadWindow != NULL)
	{
		delete m_pDownloadWindow;
		m_pDownloadWindow = NULL;
	}

	MONITORINFO mi = { 0 };
	mi.cbSize = sizeof(mi);
	CHECK_WIN32_BOOL(GetMonitorInfo(MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY), & mi),
		L"GetMonitorInfo");

	int cx = 550;
	int cy = 250;

	m_pDownloadWindow = new DownloadWindow(dialog); // deletes itself
	m_pDownloadWindow->Create(
		(mi.rcWork.left + mi.rcWork.right) / 2 - cx / 2, 
		(mi.rcWork.top + mi.rcWork.bottom) / 2 - cy / 2, 
		cx, cy, dialog->caption.GetValue().c_str());

	CHECK_BOOL(m_pDownloadWindow->hwnd != NULL,
		L"DownloadWindow::Create");
}
BOOL CDFA::ConstructDFA()
{
    BOOL bRet = FALSE;
    CHECK_BOOL ( CreateSyntaxTree() );
    CHECK_BOOL ( m_pSyntaxNode->CalculateAllFunction() );
    m_pSyntaxNode->ShowAllFunction(m_pSyntaxNode);
    CHECK_BOOL ( CreateDFA(m_pSyntaxNode) );
    CHECK_BOOL ( MinimizeDFA(m_lstSet.size(), m_lstNodeRelation, 
                             m_setAcceptingIdx, m_lstFinalSet) );

    assert(m_lstFinalSet.size() <= m_lstSet.size());

    bRet = TRUE;
Exit0:
    return bRet;
}
Example #14
0
DVLib::FileVersionInfo DVLib::GetFileVersionInfo(const std::wstring& filename)
{
	DVLib::FileVersionInfo result = { 0 };
	DWORD dwVerHnd = 0;
	DWORD dwVerInfoSize = ::GetFileVersionInfoSize(filename.c_str(), & dwVerHnd);
	CHECK_WIN32_BOOL(dwVerInfoSize != 0,
		L"GetFileVersionInfoSize(" << filename << L")");
	std::vector<byte> versioninfo_data;
	versioninfo_data.resize(dwVerInfoSize);
	dwVerInfoSize = versioninfo_data.size();
	CHECK_WIN32_BOOL(::GetFileVersionInfo(filename.c_str(), dwVerHnd, dwVerInfoSize, & * versioninfo_data.begin()),
		L"GetFileVersionInfo(" << filename << L")");
	// VS_FIXEDFILEINFO
	UINT fixed_len = 0;
	VS_FIXEDFILEINFO * lpvi = NULL;
	CHECK_WIN32_BOOL(0 != ::VerQueryValueW(& * versioninfo_data.begin(), L"\\", reinterpret_cast<LPVOID *>(& lpvi), & fixed_len),
		L"VerQueryValue(" << filename << L")");
	result.fixed_info = * lpvi;
	// translation info
	UINT translation_len = 0;
	TranslationInfo * lpti = NULL;
	CHECK_WIN32_BOOL(0 != ::VerQueryValueW(& * versioninfo_data.begin(), L"\\VarFileInfo\\Translation", reinterpret_cast<LPVOID *>(& lpti), & translation_len),
		L"VerQueryValue(" << filename << L", \"\\VarFileInfo\\Translation\")");
	CHECK_BOOL(translation_len <= sizeof(TranslationInfo),
		L"VerQueryValue(" << filename << L", \"\\VarFileInfo\\Translation\"): invalid size");
	result.translation_info = * lpti;
	return result;
}
std::wstring DVLib::RegistryGetStringValue(HKEY root, const std::wstring& key, const std::wstring& name, DWORD ulFlags)
{
    HKEY reg = NULL;

    CHECK_WIN32_DWORD(::RegOpenKeyEx(root, key.c_str(), 0, ulFlags | KEY_READ, & reg),
        L"Error opening " << HKEY2wstring(root) << L"\\" << key);

    auto_hkey reg_ptr(reg);

    DWORD dwSize = 0;
    DWORD dwType = 0;

    CHECK_WIN32_DWORD(::RegQueryValueEx(reg, name.c_str(), 0, & dwType, NULL, & dwSize),
        L"Error quering '" << HKEY2wstring(root) << L"\\" << key << L"\\" << name << L"' value size:");

    CHECK_BOOL(dwType == REG_SZ || dwType == REG_EXPAND_SZ,
        L"Error quering '" << HKEY2wstring(root) << L"\\" << key << L"\\" << name << L"' value, unexpected type " << dwType);

    std::wstring value;
    if (dwSize > 0)
    {
        value.resize(dwSize / sizeof(WCHAR));

        CHECK_WIN32_DWORD(::RegQueryValueEx(reg, name.c_str(), 0, & dwType, reinterpret_cast<LPBYTE>(& * value.begin()), & dwSize),
            L"Error quering '" << HKEY2wstring(root) << L"\\" << key << L"\\" << name << L"' value data");

        value.resize((dwSize - 1) / sizeof(WCHAR));
    }

    return value;
}
void ProcessComponent::Wait(DWORD tt)
{
    CHECK_BOOL(m_process_handle != NULL, L"Invalid process handle")

    CHECK_WIN32_BOOL(WAIT_OBJECT_0 == WaitForSingleObject(m_process_handle, tt),
        L"WaitForSingleObject");
}
Example #17
0
static void
gopal_rd_init(const char *fname)
{char buff[32];
	char *ck;
	char *filename;
	CHECK_BOOL(optclean);
	if (optminspeed) 
	{
		minspeed=atof(optminspeed);
		if (global_opts.debug_level > 1) fprintf(stderr,"options from command line : gopal minspeed = %s\n",optminspeed);
	}
	else
	minspeed=0;
	if (optmaxspeed) 
	{
		maxspeed=atof(optmaxspeed);
		if (global_opts.debug_level > 1) fprintf(stderr,"options from command line : gopal maxspeed = %s\n",optmaxspeed);
	}
	else
	maxspeed=200;
	if (global_opts.debug_level > 1) fprintf(stderr,"setting minspeed to %5.1lf km/h and maxspeed to %5.1lf km/h\n",minspeed,maxspeed);

	fin = gbfopen(fname, "r", MYNAME);

	memset(buff,0,sizeof(buff));
	if (optdate)
	{  
		memset(&opt_tm, 0, sizeof(opt_tm));
		
		ck = (char *)strptime(optdate, "%Y%m%d", &opt_tm);
		if ((ck == NULL) || (*ck != '\0') || (strlen(optdate) != 8))
		fatal(MYNAME ": Invalid date \"%s\"!\n", optdate);
		else if (opt_tm.tm_year < 70)
		fatal(MYNAME ": Date \"%s\" is out of range (have to be 19700101 or later)!\n", optdate);
		tx = mkgmtime(&opt_tm);
		
	}
	else
	{
		/* remove path */
		filename = get_filename(fname);
		
		if ((strncmp(filename,"track",5)==0)&&(strlen(filename)>13)) // we need at least 13 letters: trackYYYYMMDD...
		{
			strncpy(&buff[0],&filename[5],8);
		}
		else
		if ((strncmp(filename,"A_",2)==0)&&(strlen(filename)>10))// here we expect at least 10 letters: A_YYYYMMDD...
		{
			strncpy(&buff[0],&filename[2],8);
		}
		// in buff we should now have something wich looks like a valid date starting with YYYYMMDD
		ck = (char *)strptime(buff, "%Y%m%d", &filenamedate);
		if (((ck == NULL) || (*ck != '\0') )&&!(optdate))
		fatal(MYNAME ": Invalid date in filename \"%s\", try to set manually using \"optdate\" switch!\n", buff);
		else if (filenamedate.tm_year < 70)
		fatal(MYNAME ": Date \"%s\" is out of range (have to be 19700101 or later)!\n", buff);
		tx= mkgmtime(&filenamedate);
	}
}
std::wstring DVLib::DirectoryCombine(const std::wstring& dir, const std::wstring& file)
{
    wchar_t buffer[MAX_PATH] = { 0 };
    CHECK_BOOL(NULL != ::PathCombineW(buffer, dir.length() ? dir.c_str() : NULL, file.length() ? file.c_str() : NULL),
        L"Error combining \"" << dir << "\" and \"" << file << "\"");
    return buffer;
}
Example #19
0
void DSNAttributes::Add(const std::wstring& namevaluepair)
{
    CHECK_BOOL(namevaluepair.find(L"=") != namevaluepair.npos,
        L"Missing = in \"" << namevaluepair << L"\"");

    _attributes.push_back(namevaluepair);
}
Example #20
0
std::string AppSecInc::TcpIp::DNS::GetHostByAddress(const std::string& ip_addr, int family)
{
	struct sockaddr_in saGNI;
	saGNI.sin_family = family;
    saGNI.sin_addr.s_addr = inet_addr(ip_addr.c_str());
	char hostname[NI_MAXHOST] = { 0 };
	char servInfo[NI_MAXSERV] = { 0 };

	CHECK_BOOL(saGNI.sin_addr.s_addr != INADDR_NONE && saGNI.sin_addr.s_addr != INADDR_ANY,
		L"Invalid IP address: " << AppSecInc::StringUtils::mb2wc(ip_addr));

	CHECK_BOOL(0 == getnameinfo(reinterpret_cast<struct sockaddr *>(& saGNI), sizeof (struct sockaddr), hostname, NI_MAXHOST, servInfo, NI_MAXSERV, NI_NUMERICSERV),
		CWSAStartup::ErrorMessage(WSAGetLastError()));

	return hostname;
}
Example #21
0
void InstallerWindow::CopyingFile(const std::wstring& filename)
{
	m_download_started = true;
	CHECK_BOOL(get(m_downloaddialog) != NULL, L"Invalid download dialog");
	std::wstring message = DVLib::FormatMessage(const_cast<wchar_t *>(m_downloaddialog->copying_message.GetValue().c_str()), filename.c_str());
	SetStatus(message);
}
Example #22
0
void MsiDatabase::Import(const std::wstring& path, const std::wstring& file)
{
    CHECK_BOOL(IsOpen(), 
        L"A database must be opened first");

    CHECK_WIN32_DWORD(::MsiDatabaseImport(m_h, path.c_str(), file.c_str()),
        L"Error importing " << path << L"\\" << file);
}
Example #23
0
void MsiDatabase::Commit()
{
    CHECK_BOOL(IsOpen(), 
        L"A database must be opened first");

    CHECK_WIN32_DWORD(::MsiDatabaseCommit(m_h),
        L"Error committing MSI database \"" << _filepath << "\"");
}
BOOL CDFA::RegExpToDFA(CString strPattern)
{
    BOOL bRet = FALSE;

    if ("" == strPattern)
        goto Exit0;

    if (strPattern == m_strPattern)
        return TRUE;

    CHECK_BOOL ( m_TreeConstructer.SetPattern(strPattern) );
    CHECK_BOOL ( ConstructDFA() );

    bRet = TRUE;
Exit0:
    return bRet;
}
Example #25
0
long DVLib::GetFileSize(const std::wstring& filename)
{
    WIN32_FILE_ATTRIBUTE_DATA attr = { 0 };
	CHECK_WIN32_BOOL(GetFileAttributesExW(filename.c_str(), GetFileExInfoStandard, & attr),
        L"Error getting file attributes of " << filename);
    CHECK_BOOL(0 == attr.nFileSizeHigh,
        L"File " << filename << L" is > 2GB (" << attr.nFileSizeHigh << ")");
    return (long) attr.nFileSizeLow; 
}
Example #26
0
int LuaSpell_Cast(lua_State * L, Spell * sp)
{
    if(sp == NULL)
        RET_NIL(false);

    bool check = CHECK_BOOL(L, 1);
    sp->cast(check);
    return 1;
}
Example #27
0
END_TEST

/* Write */

START_TEST (test_write)
{
  enum { MAX_BUFFER_SIZE = 512 };

  static XML_Char const *BUFFER = _XT("This is a buffer for the reader");

  XML_Char write_buffer[MAX_BUFFER_SIZE] = _XT("");

  scew_writer *writer = scew_writer_buffer_create (write_buffer,
                                                   scew_strlen (BUFFER) + 1);

  CHECK_PTR (writer, "Unable to create buffer writer");

  unsigned int i = 0;
  while (i < scew_strlen (BUFFER))
    {
      CHECK_U_INT (scew_writer_write (writer, BUFFER + i, 1), 1,
                   "Invalid number of written bytes");
      i += 1;
    }

  CHECK_STR (write_buffer, BUFFER, "Buffers do not match");

  CHECK_BOOL (scew_writer_end (writer), SCEW_FALSE,
              "Writer buffer is bigger than read buffer (no end yet)");

  scew_writer_free (writer);

  /* Try to writer full buffer */
  writer = scew_writer_buffer_create (write_buffer, scew_strlen (BUFFER) + 1);

  scew_writer_write (writer, write_buffer, scew_strlen (BUFFER) + 1);

  CHECK_STR (write_buffer, BUFFER, "Buffers do not match");

  CHECK_BOOL (scew_writer_end (writer), SCEW_FALSE,
              "Writer buffer is bigger than read buffer (no end yet)");

  scew_writer_free (writer);
}
Example #28
0
void AppSecInc::TcpIp::DNS::GetHostInfo(const std::string& name, std::string& hostname, std::vector<std::string>& aliases, std::vector<std::string>& ipaddresses, int family)
{
	CHECK_BOOL(! name.empty(),
		L"Missing host name");

	struct hostent * r = NULL;
	// check whether this is a well-formed IP address
	struct in_addr addr = { 0 };
	addr.s_addr = inet_addr(name.c_str());
	if (addr.s_addr == INADDR_NONE || addr.s_addr == INADDR_ANY)
	{
		// resolve the host name
		r = ::gethostbyname(name.c_str());
	}
	else
	{
		r = ::gethostbyaddr(reinterpret_cast<const char *>(& addr), 4, family);
	}

	CHECK_BOOL(NULL != r,
		CWSAStartup::ErrorMessage(WSAGetLastError()));

	hostname = r->h_name;
	
	aliases.empty();
	if (r->h_aliases)
	{
		for (int i = 0; r->h_aliases[i]; ++i)
		{
			aliases.push_back(r->h_aliases[i]);
		}
	}

	ipaddresses.empty();
	if (r->h_addr_list)
	{
		for (int i = 0; r->h_addr_list[i]; ++i)
		{
			ipaddresses.push_back(inet_ntoa( * reinterpret_cast<struct in_addr *>(r->h_addr_list[i])));
		}
	}
}
Example #29
0
void InstallerWindow::OnExecBegin()
{
	SetProgress(m_recorded_progress + 1);

	SetControlValues();

	InstallConfiguration * p_configuration = reinterpret_cast<InstallConfiguration *>(get(m_configuration));
	CHECK_BOOL(p_configuration != NULL, L"Invalid configuration");

    ExtractCab(L"", p_configuration->show_cab_dialog);		
}
Example #30
0
int LuaSpell_SetVar(lua_State * L, Spell * sp)
{
    if(sp == NULL)
        RET_BOOL(false);

    const char* var = luaL_checkstring(L,1);
    if (var == NULL)
        RET_BOOL(false);

    int subindex = 0;
    if (lua_gettop(L) == 3)
    {
        subindex = luaL_optint(L,2,0);
    }
    if (subindex < 0)
        RET_BOOL(false);

    int valindex = 2;
    if (subindex)
        valindex++;

//    sp->InitProtoOverride();
    SpellEntry * proto = sp->GetSpellProto();
    if(proto == NULL)
        RET_BOOL(false);

    LuaSpellEntry l = GetLuaSpellEntryByName(var);
    if (!l.name)
        RET_BOOL(false);

    switch (l.typeId) //0: int, 1: char*, 2: bool, 3: float
    {
    case 0:
        GET_SPELLVAR_INT(proto,l.offset,subindex) = luaL_checkinteger(L, valindex);
        lua_pushboolean(L, 1);
        break;
    case 1:
        strcpy(GET_SPELLVAR_CHAR(proto,l.offset,subindex), luaL_checkstring(L, valindex));
        lua_pushboolean(L, 1);
        break;
    case 2:
        GET_SPELLVAR_BOOL(proto,l.offset,subindex) = CHECK_BOOL(L, valindex);
        lua_pushboolean(L, 1);
        break;
    case 3:
        GET_SPELLVAR_FLOAT(proto,l.offset,subindex) = (float)luaL_checknumber(L, valindex);
        lua_pushboolean(L, 1);
        break;
    default:
        RET_BOOL(false);
        break;
    }
    return 1;
}