Пример #1
0
int ArchivePanel::pProcessKey(
		int nKey,
		DWORD dwControlState
		)
{
	if ( (nKey == VK_F7) && (dwControlState == 0) )
	{
		TCHAR szFolderPath[MAX_PATH];

		if ( Info.InputBox (
				_M(MMakeFolderTitle),
				_M(MMakeFolderPrompt),
				NULL,
				NULL,
				szFolderPath,
				MAX_PATH,
				NULL,
				FIB_EXPANDENV|FIB_BUTTONS
				) )
		{
			bool bResult = MakeDirectory(szFolderPath);

			if ( bResult )
				Update();

			return FALSE;
		}
	}

	return FALSE;
}
Пример #2
0
/*
 * 初始化缓存区,生成接口句柄
 * skfd: 被初始化的接口句柄
 * @return: 0: 成功
 *          -1: 初始化接口句柄失败
 */
static int eapol_init(pcap_t **skfd)
{
    pcap_if_t *alldevs, *d;
    char errbuf[PCAP_ERRBUF_SIZE];
    char ifbuff[8+IFNAMSIZ] = "rpcap://";

    sendethii = (ethII_t*)sendbuff;
    sendeapol = (eapol_t*)((uchar*)sendethii+sizeof(ethII_t));
    sendeap = (eap_t*)((uchar*)sendeapol+sizeof(eapol_t));
    sendeapbody = (eapbody_t*)((uchar*)sendeap+sizeof(eap_t));

    if (-1 == pcap_findalldevs(&alldevs, errbuf)) {
        _M("Get interface: %s\n", errbuf);
        return -1;
    }

    for (d = alldevs; NULL != d; d = d->next)
        if (0 == strcmp(ifname, d->name))
            break;
    if (NULL == d) return -1;
    /* 获取mac */
    LPADAPTER lpAdapter = PacketOpenAdapter(d->name);
    if (!lpAdapter || (lpAdapter->hFile == INVALID_HANDLE_VALUE))
        return -1;

    PPACKET_OID_DATA oidData = malloc(ETH_ALEN + sizeof(PACKET_OID_DATA));
    if (NULL == oidData) {
        PacketCloseAdapter(lpAdapter);
        return -1;
    }
    oidData->Oid = OID_802_3_CURRENT_ADDRESS;
    oidData->Length = ETH_ALEN;
    memset(oidData->Data, 0, ETH_ALEN);
    if (0 == PacketRequest(lpAdapter, FALSE, oidData)) {
        free(oidData);
        return -1;
    }
    memcpy(client_mac, oidData->Data, ETH_ALEN);
    PacketCloseAdapter(lpAdapter);
    _D("%s's MAC: %02X-%02X-%02X-%02X-%02X-%02X\n", ifname,
            client_mac[0],client_mac[1],client_mac[2],
            client_mac[3],client_mac[4],client_mac[5]);

    /* 获取网络接口句柄 */
    strncat(ifbuff, ifname, IFNAMSIZ);
    if (NULL == (*skfd = pcap_open(d->name, MTU_MAX,
                    PCAP_OPENFLAG_PROMISCUOUS, TIMEOUT*1000, NULL, errbuf))) {
        _M("Get interface handler:%s\n", errbuf);
        pcap_freealldevs(alldevs);
        return -1;
    }
    pcap_freealldevs(alldevs);

    return 0;
}
Пример #3
0
int __stdcall Archive::OnQueryPassword (int nMode, ArchivePassword *pPassword)
{
   	if ( nMode == PASSWORD_RESET )
   	{
   		if ( m_lpLastUsedPassword )
   		{
   			free (m_lpLastUsedPassword);
   			m_lpLastUsedPassword = NULL;
   		}
   	}

   	if ( (nMode == PASSWORD_LIST) || (nMode == PASSWORD_FILE) )
   	{
   		bool bResult = true;

   		if ( !m_lpLastUsedPassword )
   		{
   			m_lpLastUsedPassword = StrCreate (512);

   			bResult = Info.InputBox (
   					(nMode == PASSWORD_LIST)?_M(MQueryPasswordFileList):_M(MQueryPasswordContents),
   					_M(MQueryPasswordEnterPassword),
   					NULL,
   					NULL,
   					m_lpLastUsedPassword,
   					512,
   					NULL,
   					0
   					);

   			if ( !bResult )
   			{
   				StrFree (m_lpLastUsedPassword);
   				m_lpLastUsedPassword = NULL;
   			}
   		}

   		if ( m_lpLastUsedPassword && bResult )
   		{
   			strcpy (pPassword->lpBuffer, m_lpLastUsedPassword);
   			return TRUE;
   		}

   		return FALSE;
   	}

   	return FALSE;
}
Пример #4
0
SEXP Rhpc_number_of_worker(SEXP cl)
{
  MPI_Comm comm;
  SEXP num;
  int procs;

  if(TYPEOF(cl)!=EXTPTRSXP){
    error("it's not MPI_Comm external pointer\n");
  }
  comm = SXP2COMM(cl);

  if(finalize){
    warning("Rhpc were already finalized.");
    return(R_NilValue);
  }
  if(!initialize){
    warning("Rhpc not initialized.");
    return(R_NilValue);
  }

  PROTECT(num=allocVector(INTSXP,1));
  _M(MPI_Comm_size(comm, &procs));
  INTEGER(num)[0]=procs-1;
  UNPROTECT(1);
  return(num);
}
PrintObject::PrintObject(PrintInterface * ptr, const CharString & t)
{
  TRACE_OUT_E(ActiveObject_PrintObject::engine, _M("created"));

  target = ptr;
  text = t;
}
void mnuCommandLinesAndParams(ArchiveManagerConfig* pCfg)
{
	Array<ArchiveFormat*> formats;
	pManager->GetFormats(formats);

	FarMenu menu(_M(MCommandLinesAndParamsArchiveFormat));

	for (unsigned int i = 0; i < formats.count(); i++)
	{
		ArchiveFormat* pFormat = formats[i];

		if ( pFormat->QueryCapability(AFF_SUPPORT_DEFAULT_COMMANDS) )
			menu.Add(pFormat->GetName(), 0, (void*)pFormat);
	}

	while ( true )
	{
		int nResult = menu.Run();

		if ( nResult != -1 )
		{
			ArchiveFormat* pFormat = (ArchiveFormat*)menu.GetData(nResult);
			dlgCommandLinesAndParams(pCfg, pFormat);
		}
		else
			break;
	}
}
//some parts of the following two functions are copied from prp2obj
int PlasmaImport::DoImport(const TCHAR *name,ImpInterface *i,Interface *gi, BOOL suppressPrompts)
{
    plResManager rm;
    plPageInfo *page;
    char* msg;

    //Reading the Page
    try
    {
        page = rm.ReadPage(name);
    }
    catch (const std::exception &e)
    {
        msg = const_cast<char*>(e.what());
        gi->PushPrompt(_M(msg));
        return 0;
    }
    catch (...)
    {
        gi->PushPrompt(_M("Unkown Error during Import (1)"));
        return 0;
    }
    //Extract the Object

    size_t objCount = 0;
    try
    {
        std::vector<plKey> objList = rm.getKeys(page->getLocation(), kSceneObject);
        for (size_t j = 0; j < objList.size(); j++)
        {
            plSceneObject* obj = plSceneObject::Convert(rm.getObject(objList[j]));
            if (obj->getDrawInterface().Exists())
                if(IImportObject(obj, i))
                    objCount++;
        }
    }
    catch (...)
    {
        gi->PushPrompt(_M("Unknown Error during Import (2)"));
        return 0;
    }

    sprintf(msg, "Successfully imported %u objects", (unsigned int)objCount);
    gi->PushPrompt(_M(msg));
    delete msg;
    return 1;
}
Пример #8
0
int ArchivePanel::OnQueryPassword(int nMode, PasswordStruct* pPassword)
{
	if ( nMode == PASSWORD_RESET )
	{
		m_bPasswordSet = false;
		m_strPassword = NULL;
		return TRUE;
	}

	bool bResult = true;

	if ( !m_bPasswordSet )
	{
		TCHAR *buffer = m_strPassword.GetBuffer(512);

		bResult = Info.InputBox (
				(nMode == PASSWORD_LIST)?_M(MQueryPasswordFileList):_M(MQueryPasswordContents),
				_M(MQueryPasswordEnterPassword),
				NULL,
				NULL,
				buffer,
				512,
				NULL,
				0
				);

		m_strPassword.ReleaseBuffer();

		if ( !bResult )
		{
			m_strPassword = NULL;
			m_bPasswordSet = false;
		}
		else
			m_bPasswordSet = true;
	}

	if ( m_bPasswordSet && bResult )
	{
		_tcscpy (pPassword->lpBuffer, m_strPassword);
		return TRUE;
	}

	return FALSE;
}
    GeometricObjectTutorialParams()
        : ParamBlockDescUtil(
			0,
			_M("GeometricObjectTutorialParameters"),
            IDS_PARAMS, 
			GeometricObjectTutorialClassDesc::GetInstance(),  
			0,
			0,
			IDD_PANEL, 
			IDS_TITLE,
			NULL)
    {
        // Adds a float parameter, with a spinner UI
        AddFloatSpinnerParam(GeometricObjectTutorial::SIZE_PARAM_ID, _M("Size"), IDS_FLOAT_PARAM, 0.0f, 1000.0f, 0.0f, IDC_PARAM_EDIT, IDC_PARAM_SPIN);

        // Prevent further changes to the parameter block descriptor
        SetFinished(); 
    }
Пример #10
0
bool dlgFilterOneFormat(ArchiveFilterEntry* pFE)
{
	bool bResult = false;

	FarDialog D(-1, -1, 50, 17);

	D.DoubleBox(3, 1, 46, 15, _T("Add filter")); //0

	int Y = 2;

	D.Text(5, Y, _T("Action:")); //1
	D.ComboBox(15, Y++, 20, NULL); //2
	D.SetFlags(DIF_DROPDOWNLIST); 

	D.Separator(Y++); //3

	D.Text(5, Y, _T("Name:")); //4
	D.Edit(15, Y++, 20, pFE->GetName()); //5

	D.Text(5, Y, _T("Mask:")); //6
	D.Edit(15, Y++, 20, pFE->GetMask());  //7

	D.Separator(Y++); //8

	D.Text(5, Y, _T("Module:")); //9
	D.ComboBox(5+8, Y++, 30, NULL, 0); //10
	D.SetFlags(DIF_DROPDOWNLIST); 

	D.Text(5, Y, _T("Plugin:")); //11
	D.ComboBox(5+8, Y++, 30, NULL, 0); //12
	D.SetFlags(DIF_DROPDOWNLIST); 

	D.Text(5, Y, _T("Format:")); //13
	D.ComboBox(5+8, Y++, 30, NULL, 0); //14
	D.SetFlags(DIF_DROPDOWNLIST);

	D.Separator(Y++); //15

	D.CheckBox(5, Y++, pFE->IsEnabled(), _T("Enabled")); //16
	D.CheckBox(5, Y++, pFE->IsContinueProcessing(), _T("Continue processing")); //17
	D.Separator(Y++); //18

	D.Button (-1, Y, _T("Add")); //19
	D.DefaultButton ();

	D.Button (-1, Y, _M(MSG_cmn_B_CANCEL)); //20

	if ( D.Run(hndFilterOneFormat, (void*)pFE) == D.FirstButton() )
	{
		pFE->SetEnabled(D.GetResultCheck(ID_FOF_ENABLED));
		pFE->SetContinueProcessing(D.GetResultCheck(ID_FOF_CONTINUEPROCESSING));

		bResult = true;
	}

	return bResult;
}
void SMBrushSculpt::EndStroke(const SMHit &hit)
{

  if (m_stroking)
    theHold.Accept(_M("AIF Sculpt"));

  m_actrestore = NULL;
  m_stroking = FALSE;

  m_SM->m_epoly->LocalDataChanged(PART_GEOM);
}
Пример #12
0
void AscentAP::SetLaunchAzimuth (double azimuth)
{
	launch_azimuth = azimuth;

	// current launch location in local planet frame
	VECTOR3 pos, equ, dir, nml, ne, nd;
	double lng, lat, rad;
	double slng, clng, slat, clat;
	double saz = sin(azimuth), caz = cos(azimuth);
	OBJHANDLE hRef = vessel->GetGravityRef();
	vessel->GetGlobalPos(pos);
	oapiGlobalToLocal (hRef, &pos, &equ);
	oapiLocalToEqu (hRef, equ, &lng, &lat, &rad);
	slng = sin(lng), clng = cos(lng), slat = sin(lat), clat = cos(lat);
	normalise(equ); // unit radius vector
	
	// launch direction in local planet frame
	dir = _V(-clng*slat*caz - slng*saz, clat*caz, -slng*slat*caz + clng*saz);

	// normal of orbital plane in local planet frame
	nml = crossp(dir, equ);

	// normal of equator plane in local planet frame
	ne = _V(0,1,0);

	// direction of ascending node
	nd = unit (crossp(nml, ne));

	// orbit inclination
	tgt.inc = acos(dotp(nml, ne));

	// longitude of ascending node
	tgt.lan = atan2(nd.z, nd.x);

	// rotation matrix from equator plane to target orbit plane
	double sinc = sin(tgt.inc), cinc = cos(tgt.inc);
	double slan = sin(tgt.lan), clan = cos(tgt.lan);
	MATRIX3 R1 = _M(1,0,0, 0,cinc,sinc, 0,-sinc,cinc);
	MATRIX3 R2 = _M(clan,0,-slan, 0,1,0, slan,0,clan);
	tgt.R = mul(R2,R1);
}
Пример #13
0
void Dot11ATxApp(const Config& config)
{
    SampleBufferSize = _M(2);
    SampleBuffer = SoraUAllocBuffer(SampleBufferSize);
	printf("tx buffer: %08x\n", SampleBuffer);
	printf("tx buffer size: %08x\n", SampleBufferSize);
	if (SampleBuffer == NULL) return;

	PreparePacket(config, (PVOID)SampleBuffer, (ULONG)SampleBufferSize);

    HRESULT hr;
	do
	{
		//Generate Signal
		hr = BB11ATxFrameMod(&TxVector, &Packet);
		printf("GenSignal return %08x\n", hr);
		printf("Signal bytes = %d\n", Packet.Reserved3);

        /*{
            PCOMPLEX8 pSampleBuffer = (PCOMPLEX8)SampleBuffer;
            for (i = 0; i < Packet.Reserved3; i++)
                printf("(%5d, %5d)\t", pSampleBuffer[i].re, pSampleBuffer[i].im);
            printf("\n");
        }*/

		hr = SoraURadioTransferEx(TARGET_RADIO, SampleBuffer, Packet.Reserved3, &TxID);
		printf("transfer, hr=%08x, id=%d\n", hr, TxID);
        FAILED_BREAK(hr);

        Monitor monitor;
        TxContext ctx(config, monitor);
        HANDLE hTxThread = AllocStartThread(DoDot11ATx, &ctx);

		if (SUCCEEDED(hr) && hTxThread)
		{
            printf("\n\nPress any key to exit the program\n");			
            time_t start = time(NULL);
	        while(!_kbhit())
            {
                if (config.Interval() != 0 && difftime(time(NULL), start) >= config.Interval()) break;
	        }

            StopFreeThread(hTxThread);
			hr = SoraURadioTxFree(TARGET_RADIO, TxID);
			printf("tx free return %08x\n", hr);
		}
	} while (FALSE);

	SoraUReleaseBuffer((PVOID)SampleBuffer);
	printf("unmap tx buffer ret: %08x\n", hr);

	printf("Tx out.\n");
}
void  ToolBarFrame::Create(HWND toolbarHWND)
{
	//create our window if need be


	if (toolbarHWND)
	{
		mToolBarWindow = toolbarHWND;
	}
	else
	{
	if (mPopup)
	{

		mPopUpWindow = CreateWindow(_M("ToolBarFrameWindow"),mName.data(),WS_POPUP|WS_BORDER | WS_VISIBLE, mX, mY, mW, mH, mParentWindow,NULL,mhInstance,NULL);
		mDummyWindow = CreateWindow(_M("ToolBarFrameWindow"),_M("DummyWindow"),WS_CHILD | WS_BORDER | WS_VISIBLE, mX, mY, mW, mH, mParentWindow,NULL,mhInstance,NULL);
			GetCOREInterface()->RegisterDlgWnd ( mPopUpWindow );
	}

	//set up toolbar	
	if (mPopup)
		mToolBarWindow = CreateWindow(CUSTTOOLBARWINDOWCLASS,NULL,WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, 0, 0, mW, mH,mPopUpWindow,NULL,mhInstance,NULL);
	else
			mToolBarWindow = CreateWindow(CUSTTOOLBARWINDOWCLASS,NULL,WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS , 0, 0, mW, mH,mParentWindow,NULL,mhInstance,NULL);

		
	}


	mToolBar = GetICustToolbar(mToolBarWindow);
	mToolBar->SetBottomBorder(FALSE);
	mToolBar->SetTopBorder(FALSE);

	//set the type of tool bar
	mToolBar->SetNumRows(1);
	mToolBar->SetImage(mImages);
	ShowWindow(mToolBarWindow,SW_SHOW);


}
Пример #15
0
int main(int argc, char **argv) {
    int      fd;
    uint8_t *full_map;
    char     path[] = "tmp/testrand.txt";
    _(  fd=open(path,O_RDWR|O_NONBLOCK|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)) _abort();
    //_(  fstat(fd, &filestat)                                                             ) _raise(-1);
    //curr_size = filestat.st_size;
    //mfd->map_size = max(curr_size, pagesize());
    _M( full_map = mmap(NULL, pagesize() << 1, PROT_READ|PROT_WRITE, MAP_SHARED, fd,0)) _abort();

    printf("%x | %x\n", full_map[0], full_map[pagesize()]);

#ifdef __LINUX__
    _M( full_map = mremap(full_map, pagesize() << 1, pagesize() * 3, MREMAP_MAYMOVE)) _abort();
#else
    #error mremap not yet implemented on mac (TODO)
#endif

    printf("%x | %x | %x\n", full_map[0], full_map[pagesize()], full_map[pagesize() << 1]);

    return 0;
}
Пример #16
0
extern int eap_daemon(char const *ifname)
{
    pcap_t *skfd;
    setifname((char*)ifname);
    if (0 != eapol_init(&skfd))
        return -1;
    char pid_file[EXE_PATH_MAX];
    if (0 != getexedir(pid_file)) {
        _M("[KPALV] get currently path error!\n");
        return -1;
    }
    int rest = EXE_PATH_MAX-strlen(pid_file);
    strncat(pid_file, "cwnu-drcom.pid", rest);
    _D("pid_file: %s\n", pid_file);
    FILE *kpalvfd = fopen(pid_file, "r+");
    if (NULL == kpalvfd) {
        _M("[KPALV] No process pidfile. %s: %s\n", pid_file, strerror(errno));
        kpalvfd = fopen(pid_file, "w+"); /* 不存在,创建 */
        if (NULL == kpalvfd) {
            _M("[KPALV] Detect pid file eror(%s)! quit!\n", strerror(errno));
            return -1;
        }
    }

#define pid_t DWORD
    pid_t oldpid;
    fseek(kpalvfd, 0L, SEEK_SET);
    if ((1 == fscanf(kpalvfd, "%lu", (unsigned long*)&oldpid)) && (oldpid != (pid_t)-1)) {
        _D("oldkpalv pid: %lu\n", oldpid);
        HANDLE hp = OpenProcess(PROCESS_TERMINATE, 0, oldpid);
        TerminateProcess(hp, 0);
    }
	/* 在可执行程序所在目录下写入自己(keep alive)pid */
    pid_t curpid = GetCurrentProcessId();
    _D("kpalv curpid: %lu\n", curpid);
    /* 使用ansi c的方式使pid_file里的内容被截断为0 */
    if (NULL == (kpalvfd = freopen(pid_file, "w+", kpalvfd)))
        _M("[KPALV:WARN] truncat pidfile '%s': %s\n", pid_file, strerror(errno));
    fprintf(kpalvfd, "%lu", curpid);
    fflush(kpalvfd);
    if (0 == eap_keep_alive(skfd)) {
        _M("[KPALV] Server maybe not need keep alive paket.\n");
        _M("[KPALV] Now, keep alive process quit!\n");
    }
    if (NULL == (kpalvfd = freopen(pid_file, "w+", kpalvfd)))
        _M("[KPALV:WARN] truncat pidfile '%s': %s\n", pid_file, strerror(errno));
    fprintf(kpalvfd, "0");	/* 写入0表示已经离开 */
    fflush(kpalvfd);
    fclose(kpalvfd);
    pcap_close(skfd);

    return 0;
}
Пример #17
0
int eaplogoff(void)
{
    pcap_t *skfd;
    int state;
    int i;

    _M("[0] Initilize interface...\n");
    if (0 != eapol_init(&skfd))
        return -1;
    _M("[1] Requset logoff...\n");
    for (i = 0; i < TRY_TIMES; ++i) {
        eapol_logoff(skfd);
        state = filte_success(skfd);
        if (-2 == state) {
            _M("[2] Logoff!\n");
            return 0;
        }
        _M(" [1] %dth Try Requset logoff...\n", i+1);
    }
    _M("[ERROR] Not server in range. or You were logoff.\n");
    pcap_close(skfd);
    return -1;
}
void ToolBarFrame::Init()
{
	mParentWindow = NULL;
	mToolBarWindow = NULL;
	mPopUpWindow = NULL;
	mDummyWindow = NULL;

	mToolBar = NULL;
	mOwner = 0;

	mX = 0;
	mY = 0;
	mW = 0;
	mH = 0;

	mLocation = kFloat;

	mLoaded = false;

	mCenter = false;

	mImages = NULL; 
	

	static BOOL registered = FALSE;
	if (!registered && mhInstance) {
		registered = TRUE;
		WNDCLASS  wc;
		wc.style         = 0;
		wc.hInstance     = mhInstance;
		wc.hIcon         = NULL;
		wc.hCursor       = NULL;
		wc.hbrBackground = NULL; 
		wc.lpszMenuName  = NULL;
		wc.cbClsExtra    = 0;
		wc.cbWndExtra    = 0;
		wc.lpfnWndProc   = PopUpToolbarProc;
		wc.lpszClassName = _M("ToolBarFrameWindow");
		RegisterClass(&wc);

	}

	HBITMAP hBitmap, hMask;	
	mImages = ImageList_Create(16, 15, TRUE, 4, 0);
	hBitmap = LoadBitmap(mhInstance,MAKEINTRESOURCE(IDB_UNWRAP_TRANSFORM));
	hMask   = LoadBitmap(mhInstance,MAKEINTRESOURCE(IDB_UNWRAP_TRANSFORM_MASK));
	ImageList_Add(mImages,hBitmap,hMask);
	DeleteObject(hBitmap);
	DeleteObject(hMask);
}
Пример #19
0
void NaboPairAssignment::setModel(double** model, int size)
{
	if(_nns)
	{
		delete _nns;
		_nns = NULL;
	}
	_model = model;
	_M.resize(_dimension, size);
	for(int i=0; i<size; i++)
	  for(int j=0; j<_dimension; j++)
	  {
	    _M(j, i) = (float)model[i][j];
	  }
	_nns = NNSearchF::createKDTreeLinearHeap(_M);
}
Пример #20
0
static int Dot11BTxInit()
{
    SampleBufferSize = _M(2);
    SampleBuffer = SoraUAllocBuffer(SampleBufferSize);
	printf("[dot11b:tx] tx buffer: %08x\n", SampleBuffer);
	printf("[dot11b:tx] tx buffer size: %08x\n", SampleBufferSize);
	if (SampleBuffer == NULL) return -1;

	HRESULT hr;
	if (SampleBufferSize < BB11B_MAX_SYMBOL_LENGTH)
	{
		printf("[dot11b:tx] Buffer size not enough.\n");
		return -1;
	}
	
	return 0;
}
Пример #21
0
EllipseObject::EllipseObject() : SimpleSpline() 
{
	myParentNumRefs = SimpleSpline::NumRefs();

	// The ellipse does not have any more reference than its parent, 
	// since the only parameter hosted by ellipse is overriding the parents
	myNumRefs = 0;					
	pblock = NULL;
	myParamBlock = NULL;

	// Build the interpolations parameter block in SimpleSpline
	ReadyInterpParameterBlock();
	ellipseObjDesc.MakeAutoParamBlocks(this);

	DbgAssert(myParamBlock && _M("Fail to Create Parameter Block"));

	// Set class value
	myParamBlock->SetValue(PB_OUTLINE, 0, msBuild_outline);
}
Пример #22
0
SEXP Rhpc_mpi_finalize(void)
{
  int cmd[CMDLINESZ];

  if(finalize){
    warning("Rhpc were already finalized.");
    return(R_NilValue);
  }
  if(!initialize){
    warning("Rhpc not initialized.");
    return(R_NilValue);
  }

  SET_CMD(cmd, CMD_NAME_ENDL, SUBCMD_NORMAL, 0, 0);
  _M(MPI_Bcast(cmd, CMDLINESZ, MPI_INT, 0, RHPC_Comm));
  MPI_Finalize();
  finalize =1;
  Rhpc_set_options( -1, -1, MPI_COMM_NULL);
  return(R_NilValue);
}
Пример #23
0
void TestGradient::mulVM02() {
	Variable x;
	Array<const ExprNode> _row1(x,ExprConstant::new_scalar(1));
	Array<const ExprNode> _row2(ExprConstant::new_scalar(0),x);
	const ExprVector& row1=ExprVector::new_(_row1,true);
	const ExprVector& row2=ExprVector::new_(_row2,true);
	Array<const ExprNode> _M(row1,row2);
	const ExprVector& M=ExprVector::new_(_M,false);

	Array<const ExprNode> _v(x,-x);
	const ExprVector& v=ExprVector::new_(_v,true);

	Function f(x,v*M);
	IntervalVector box(1,Interval(3.0));
	IntervalMatrix J=f.jacobian(box);

	check(J[0][0],Interval(6));
	check(J[1][0],Interval(-5));
	CPPUNIT_ASSERT(J[0][0].is_superset(Interval(6)));
	CPPUNIT_ASSERT(J[1][0].is_superset(Interval(-5)));
}
Пример #24
0
void ViewportLoader::LoadEffect(ClassDesc * pd)
{

	ReferenceTarget * newEffect;
	ReferenceTarget * oldEffect;

	if (theHold.Holding())
	{
		oldEffect = effect;

//		theHold.Suspend(); 


		if(pd == NULL){
			newEffect = NULL;
		}
		else{
			newEffect = (ReferenceTarget *)pd->Create(FALSE);
			DbgAssert(newEffect && _M("Plug-in instance creation failed. Possible cause: deferred plug-in failed to load."));
			if(!newEffect)
			{
				// maybe deferred
				ClassDesc * def = FindandLoadDeferedEffect(pd);
				if(def)
				{
					newEffect = (ReferenceTarget *)def->Create(FALSE);
				}

			}

		}

//		theHold.Resume(); 

		if (theHold.Holding())
			theHold.Put(new AddEffectRestore(this,oldEffect,newEffect));

		SwapEffect(newEffect);
	}
}
Пример #25
0
/* 保持在线,实现心跳逻辑 */
static int eap_keep_alive(pcap_t *skfd)
{
    int status;
    time_t stime, etime;
    stime = time((time_t*)NULL);
    //for (; difftime(time((time_t*)NULL), stime) <= EAP_KPALV_TIMEOUT; ) {
    for (;;) {
        status = filte_req_identity(skfd);
        if (0 == status) {
            etime = time((time_t*)NULL);
			_D("dtime: %fs\n", difftime(etime, stime));
			if (difftime(etime, stime) <= 10) {
				stime = time((time_t*)NULL);
				continue;
			}
			stime = time((time_t*)NULL);
			_M("%s: [KPALV] get a request-identity\n", format_time());
            eap_res_identity(skfd);
        }
        status = -1;
    }
    return 0;
}
Пример #26
0
/*
 * 过滤得到eap-request-md5clg包
 * @return: 0: 成功获取
 *          -1: 超时
 *          -2: 服务器中止登录,用户名不存在
 */
static int filte_req_md5clg(pcap_t *skfd)
{
    int stime = time((time_t*)NULL);
    struct pcap_pkthdr *pkt_hd;
    const uchar *recvbuff;
    int timeout;
    for (; time((time_t*)NULL)-stime <= TIMEOUT;) {
        timeout = pcap_next_ex(skfd, &pkt_hd, &recvbuff);
        if (0 >= timeout) return -1;
        FORMAT_RECVPKT(recvbuff);
        /* 是request且是eap-request-md5clg */
        if (recvethii->type == htons(ETHII_8021X)
                && mac_equal(recvethii->dst_mac, client_mac)
                && recveapol->type == EAPOL_PACKET ) {
            if (recveap->code == EAP_CODE_REQ
                    && recveap->type == EAP_TYPE_MD5) {
#ifdef DEBUG
                _M("id: %d\n", sendeap->id);
                _M("md5: ");
                for (int i = 0; i < recveapbody->md5size; ++i)
                    _M("%.2x", recveapbody->md5value[i]);
                _M("\n");
                _M("ex-md5: ");
                for (int i = 0; i < ntohs(recveap->len) - recveapbody->md5size - 2; ++i)
                    _M("%.2x", recveapbody->md5exdata[i]);
                _M("\n");
#endif
                return 0;
            } else if (recveap->id == sendeap->id
                    && recveap->code == EAP_CODE_FAIL) {
                _D("id: %d fail.\n", sendeap->id);
                return -2;
            }
        }
    }
    return -1;
}
Пример #27
0
const MCHAR* TemplateGlobalUtilityClassDesc::ClassName()
{
    TODO("Replace with your own localized plug-in name");
    return _M("Template Global Utility");
}
Пример #28
0
	const MCHAR* 	Category() { return _M("");  }
const MCHAR* TemplateFileImporterClassDesc::ClassName() 
{ 
    TODO("Replace with your own localized plug-in name");
    return _M("Template File Importer"); 
} 
Пример #30
0
	virtual const MCHAR* InternalName() { return _M("Texmaps"); }