示例#1
0
文件: item.cpp 项目: 1suming/pap2
int KItemNull::Init(KItemNullData & ItemNullData)
{
    if (ItemNullData.wszName[0] != L'\0')
        SetName(ATL::CW2A(ItemNullData.wszName, GetCodePage()));
    
    m_nLink = ItemNullData.nLink;
    if (m_nLink)
        SetLinkInfo(ATL::CW2A(ItemNullData.wszLinkInfo, GetCodePage()));

    m_dwPosType = static_cast<DWORD>(ItemNullData.nPosType);
	SetRelPos(ItemNullData.fRelX, ItemNullData.fRelY);
	SetSize(ItemNullData.fWidth, ItemNullData.fHeight);
	SetAlpha(ItemNullData.nAlpha);
	m_nTipIndex = ItemNullData.nTipIndex;

	if (ItemNullData.nDisableScale)
	{
		EnableScale(false);
		m_fRelX *= ItemNullData.fScale;
		m_fRelY *= ItemNullData.fScale;
	}
	else
	{
		m_fRelX *= ItemNullData.fScale;
		m_fRelY *= ItemNullData.fScale;
		m_fWidth *= ItemNullData.fScale;
		m_fHeight *= ItemNullData.fScale;
	}
	if (ItemNullData.nLockShowAndHide)
	{
		Hide();
		LockShowAndHide(true);
	}

	m_fUserData = ItemNullData.fUserData;

    if (ItemNullData.pEventOwner)
	{
		ItemNullData.pEventOwner->UpdateDrawList();
		if(ItemNullData.dwEventID)
		{
			m_dwEvent = ItemNullData.dwEventID;
			ItemNullData.pEventOwner->UpdateEvent();
		}
	}

	m_nAreaIndex = ItemNullData.nAreaTestIndex;

	if (ItemNullData.nIntPos)
		SetIntPos(true);

    return true;
}
示例#2
0
/**
 * Respond2 initialization function
 *
 * @param data argument passed to the resp keyword
 * @param otn pointer to an OptTreeNode structure
 * @param protocol Snort rule protocol (IP/TCP/UDP)
 *
 * @return void function
 */
static void Respond2Init(char *data, OptTreeNode *otn, int protocol) 
{
    static int setup = 0;
    RespondData *rd = NULL;

    if (!(protocol & (IPPROTO_ICMP | IPPROTO_TCP | IPPROTO_UDP)))
        FatalError("%s: %s(%d): Can't respond to IP protocol rules.\n", 
                MODNAME, file_name, file_line);

    rd = (RespondData *)SnortAlloc(sizeof(RespondData));

    if (!setup)
    {
        SetLinkInfo();      /* setup link-layer pointer arithmetic info */
        SetRespAttempts(&config);       /* configure # of TCP attempts */
        SetRespCacheRows(&config);      /* configure # of rows in cache */
        SetRespCacheMemcap(&config);    /* configure response cache memcap */

        if ((respcache_init(&respcache, &config)) != 0)
            FatalError("%s: Unable to allocate hash table memory.\n", MODNAME);

        /* Open raw socket or network device before Snort drops privileges */
        if (link_offset)
        {
            if (config.ethdev == NULL)     /* open link-layer device */
            {
                if ((config.ethdev = eth_open(pv.respond2_ethdev)) == NULL)
                    FatalError("%s: Unable to open link-layer device: %s.\n", 
                            MODNAME, pv.respond2_ethdev);
            }
            DEBUG_WRAP(
                    DebugMessage(DEBUG_PLUGIN, "%s: using link-layer "
                            "injection on interface %s\n", MODNAME,
                            pv.respond2_ethdev);
                    DebugMessage(DEBUG_PLUGIN, "%s: link_offset = %d\n", 
                            MODNAME, link_offset);
        
                    );
        }