예제 #1
0
파일: mgquery.c 프로젝트: plbogen/CSDL
void 
query (void)
{
  ProgTime TotalStartTime, TotalInvfTime, TotalTextTime;
  InitQueryTimes iqt;
  query_data *qd;

  TotalStartTime.RealTime = TotalStartTime.CPUTime = 0;
  TotalInvfTime.RealTime = TotalInvfTime.CPUTime = 0;
  TotalTextTime.RealTime = TotalTextTime.CPUTime = 0;

  qd = InitQuerySystem (GetDefEnv ("mgdir", "./"),
			GetDefEnv ("mgname", ""),
			&iqt);
  if (!qd)
    FatalError (1, mg_errorstrs[mg_errno], mg_error_data);
  start_up_stats (qd, iqt);


  while (1)
    {
      ProgTime StartTime, InvfTime, TextTime;
      char QueryType;
      char OutputType;
      char *line;
      ResetFileStats (qd);
      qd->max_mem_in_use = qd->mem_in_use = 0;

      qd->tot_hops_taken += qd->hops_taken;
      qd->tot_num_of_ptrs += qd->num_of_ptrs;
      qd->tot_num_of_accum += qd->num_of_accum;
      qd->tot_num_of_terms += qd->num_of_terms;
      qd->tot_num_of_ans += qd->num_of_ans;
      qd->tot_text_idx_lookups += qd->text_idx_lookups;
      qd->hops_taken = qd->num_of_ptrs = 0;
      qd->num_of_accum = qd->num_of_ans = qd->num_of_terms = 0;
      qd->text_idx_lookups = 0;

      Display_Stats (stderr);
      Clear_Stats ();
      line = get_query (qd);
      if (!line || Quitting)
	break;

      GetPostProc (line);

      GetTime (&StartTime);

      FreeQueryDocs (qd);

      QueryType = get_query_type ();
      OutputType = get_output_type ();
      /* No point in hiliting words on a docnum query */
      if (OutputType == OUTPUT_HILITE && QueryType == QUERY_DOCNUMS)
	OutputType = OUTPUT_TEXT;

      switch (QueryType)
	{
	case QUERY_BOOLEAN:
	  {
	    char *maxdocs;
	    BooleanQueryInfo bqi;
	    maxdocs = GetDefEnv ("maxdocs", "all");
	    bqi.MaxDocsToRetrieve = strcmp (maxdocs, "all") ? atoi (maxdocs) : -1;
	    BooleanQuery (qd, line, &bqi);
	    break;
	  }
	case QUERY_APPROX:
	case QUERY_RANKED:
	  {
	    char *maxdocs;
	    char *maxterms;
	    char *maxaccum;
	    RankedQueryInfo rqi;
	    maxdocs = GetDefEnv ("maxdocs", "all");
	    maxterms = GetDefEnv ("max_terms", "all");
	    maxaccum = GetDefEnv ("max_accumulators", "all");
	    rqi.Sort = BooleanEnv (GetEnv ("sorted_terms"), 0);
	    rqi.QueryFreqs = BooleanEnv (GetEnv ("qfreq"), 1);
	    rqi.Exact = QueryType == QUERY_RANKED;
	    rqi.MaxDocsToRetrieve = strcmp (maxdocs, "all") ? atoi (maxdocs) : -1;
	    rqi.MaxTerms = strcmp (maxterms, "all") ? atoi (maxterms) : -1;
	    rqi.MaxParasToRetrieve = rqi.MaxDocsToRetrieve;
	    if (qd->id->ifh.InvfLevel == 3 && GetEnv ("maxparas"))
	      rqi.MaxParasToRetrieve = atoi (GetEnv ("maxparas"));
	    rqi.AccumMethod = toupper (*GetDefEnv ("accumulator_method", "A"));
	    rqi.MaxAccums = strcmp (maxaccum, "all") ? atoi (maxaccum) : -1;
	    rqi.HashTblSize = IntEnv (GetEnv ("hash_tbl_size"), 1000);
	    rqi.StopAtMaxAccum = BooleanEnv (GetEnv ("stop_at_max_accum"), 0);
	    rqi.skip_dump = GetEnv ("skip_dump");
	    RankedQuery (qd, line, &rqi);
	    break;
	  }
	case QUERY_DOCNUMS:
	  {
	    DocnumsQuery (qd, line);
	    break;
	  }
	}

      GetTime (&InvfTime);

      if (qd->DL)
	MoreDocs (qd, line, OutputType);

      GetTime (&TextTime);

      if (BooleanEnv (GetEnv ("timestats"), 0) ||
	  BooleanEnv (GetEnv ("briefstats"), 0))
	QueryTimeStats (&StartTime, &InvfTime, &TextTime);

      if (BooleanEnv (GetEnv ("diskstats"), 0) ||
	  BooleanEnv (GetEnv ("briefstats"), 0))
	File_Stats (qd);

      if (BooleanEnv (GetEnv ("memstats"), 0) ||
	  BooleanEnv (GetEnv ("briefstats"), 0))
	MemStats (qd);

      if (BooleanEnv (GetEnv ("sizestats"), 0))
	SizeStats (qd);

      TotalInvfTime.RealTime += InvfTime.RealTime - StartTime.RealTime;
      TotalInvfTime.CPUTime += InvfTime.CPUTime - StartTime.CPUTime;
      TotalTextTime.RealTime += TextTime.RealTime - StartTime.RealTime;
      TotalTextTime.CPUTime += TextTime.CPUTime - StartTime.CPUTime;
    }

  if (isatty (fileno (InFile)) && !Quitting)
    fprintf (stderr, "\n");

  shut_down_stats (qd, &TotalStartTime, &TotalInvfTime, &TotalTextTime);

  Display_Stats (stderr);

}
예제 #2
0
String  GetHomeDirectory() {
	return GetEnv("HOMEDRIVE") + GetEnv("HOMEPATH");
}
예제 #3
0
void DoDfsvcExploit()
{
	CLSID clsid;

	CLSIDFromString(CLSID_DFSVC, &clsid);

	DebugPrintf("Starting DFSVC Exploit\n");

	mscorlib::_ObjectPtr obj;

	HRESULT hr = CoCreateInstance(clsid, nullptr, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&obj));

	if (FAILED(hr))
	{
		WCHAR cmdline[] = L"dfsvc.exe";

		STARTUPINFO startInfo = { 0 };
		PROCESS_INFORMATION procInfo = { 0 };

		// Start dfsvc (because we can due to the ElevationPolicy)
		if (CreateProcess(GetEnv(L"windir") + L"\\Microsoft.NET\\Framework\\v4.0.30319\\dfsvc.exe", cmdline,
			nullptr, nullptr, FALSE, 0, nullptr, nullptr, &startInfo, &procInfo))
		{
			CloseHandle(procInfo.hProcess);
			CloseHandle(procInfo.hThread);

			// Just sleep to ensure it comes up
			Sleep(4000);
			hr = CoCreateInstance(clsid, nullptr, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&obj));
		}
		else
		{
			DebugPrintf("Couldn't create service %d\n", GetLastError());
		}
	}

	if (SUCCEEDED(hr))
	{
		try
		{
			mscorlib::_TypePtr type = obj->GetType();

			// Get type of Type (note defaults to RuntimeType then TypeInfo)
			type = type->GetType()->BaseType->BaseType;

			DebugPrintf("TypeName: %ls", type->FullName.GetBSTR());

			mscorlib::_MethodInfoPtr getTypeMethod = GetStaticMethod(type, L"GetType", 1);

			DebugPrintf("getTypeMethod: %p", (void*)getTypeMethod);

			std::vector<variant_t> getTypeArgs;

			getTypeArgs.push_back(L"System.Diagnostics.Process, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");

			// Get process type
			type = ExecuteMethod<mscorlib::_TypePtr>(getTypeMethod, getTypeArgs);

			if (type)
			{
				mscorlib::_MethodInfoPtr startMethod = GetStaticMethod(type, L"Start", 2);

				if (startMethod)
				{
					std::vector<variant_t> startArgs;

					startArgs.push_back(L"powershell");
					startArgs.push_back(GetEnv(L"PSHCMD"));

					ExecuteMethod<mscorlib::_ObjectPtr>(startMethod, startArgs);
				}
				else
				{
					DebugPrintf("Couldn't find Start method");
				}
			}
			else
			{
				DebugPrintf("Couldn't find Process Type");
			}
		}
		catch (_com_error e)
		{
			DebugPrintf("COM Error: %ls\n", e.ErrorMessage());
		}
	}
	else
	{
		DebugPrintf("Error get dfsvc IUnknown: %08X\n", hr);
	}
}
예제 #4
0
AwtDesktopProperties::~AwtDesktopProperties() {
    GetEnv()->DeleteGlobalRef(self);
}
예제 #5
0
	Profiler()
		: ProfilerBase( COR_PRF_MONITOR_ENTERLEAVE, GetEnv( txtProfileEnv ) ), 
		writer( GetEnv( binProfileEnv ) )
	{
		__inst = this;
	}
예제 #6
0
void *__hxcpp_get_proc_address(String inLib, String full_name,bool inNdllProc)
{
#ifdef ANDROID
   inLib = HX_CSTRING("lib") + inLib;

   //__android_log_print(ANDROID_LOG_INFO, "loader", "%s: %s", inLib.__CStr(), inPrim.__CStr() );
#endif

   #ifdef IPHONE
   gLoadDebug = true;
   setenv("DYLD_PRINT_APIS","1",true);

   #elif !defined(HX_WINRT)
   gLoadDebug = gLoadDebug || getenv("HXCPP_LOAD_DEBUG");
   #endif

   String ext =
#if defined(_WIN32)
    HX_CSTRING(".dll");
#elif defined(IPHONEOS)
    HX_CSTRING(".ios.dylib");
#elif defined(IPHONESIM)
    HX_CSTRING(".sim.dylib");
#elif defined(__APPLE__)
    HX_CSTRING(".dylib");
#elif defined(ANDROID) || defined(GPH) || defined(WEBOS)  || defined(BLACKBERRY) || defined(EMSCRIPTEN) || defined(TIZEN)
    HX_CSTRING(".so");
#else
    HX_CSTRING(".dso");
#endif



   String bin =
#ifdef _WIN32
    HX_CSTRING("Windows");
// Unix...
#elif defined(__APPLE__)
  #ifdef HXCPP_M64
    HX_CSTRING("Mac64");
  #else
    HX_CSTRING("Mac");
  #endif
#elif defined (ANDROID)
    HX_CSTRING("Android");
#elif defined(WEBOS)
    HX_CSTRING("webOS");
#elif defined(BLACKBERRY)
    HX_CSTRING("BlackBerry");
#elif defined(RASPBERRYPI)
    HX_CSTRING("RPi");
#elif defined(EMSCRIPTEN)
	HX_CSTRING("Emscripten");
#elif defined(TIZEN)
    HX_CSTRING("Tizen");
#elif defined(IPHONESIM)
    HX_CSTRING("IPhoneSim");
#elif defined(IPHONEOS)
    HX_CSTRING("IPhoneOs");
#else
  #ifdef HXCPP_M64
    HX_CSTRING("Linux64");
  #else
    HX_CSTRING("Linux");
  #endif
#endif

    int passes = 4;

   #ifdef ANDROID
   std::string module_name = inLib.__CStr();
   Module module = sgLoadedModule[module_name];
   #else
   Module module = sgLoadedModule[inLib.__s];
   #endif
   bool new_module = module==0;


   if (!module && sgRegisteredPrims)
   {
      void *registered = (*sgRegisteredPrims)[full_name.__CStr()];
      if (registered)
         return registered;
   }

   if (!module && gLoadDebug)
   {
      #ifdef ANDROID
       __android_log_print(ANDROID_LOG_INFO, "loader", "Searching for %s...", module_name.c_str());
      #else
      printf("Searching for %s...\n", inLib.__CStr());
      #endif
   }


   for(int pass=0;module==0 && pass<2;pass++)
   {
      String dll_ext = HX_CSTRING("./") + inLib + ( (pass&1) ? HX_CSTRING(".ndll") : ext );

      // Try Current directory first ...
      if (gLoadDebug)
      {
         #ifndef ANDROID
         printf(" try %s...\n", dll_ext.__CStr());
         #else
         __android_log_print(ANDROID_LOG_INFO, "loader", "Try %s", dll_ext.__CStr());
         #endif
      }
      module = hxLoadLibrary(dll_ext);
      if (module)
         break;
      
      dll_ext = inLib + ( (pass&1) ? HX_CSTRING(".ndll") : ext );
      if (gLoadDebug)
      {
         #ifndef ANDROID
         printf(" try %s...\n", dll_ext.__CStr());
         #else
         __android_log_print(ANDROID_LOG_INFO, "loader", "Try %s", dll_ext.__CStr());
         #endif
      }
      module = hxLoadLibrary(dll_ext);

      // Try exactly as specified...
      if (!module)
      {
         String dll_ext = pass==0 ? inLib : HX_CSTRING("./") + inLib;
         if (gLoadDebug)
         {
            #ifndef ANDROID
            printf(" try %s...\n", dll_ext.__CStr());
            #else
            __android_log_print(ANDROID_LOG_INFO, "loader", "Try %s", dll_ext.__CStr());
            #endif
         }
         module = hxLoadLibrary(dll_ext);
      }
     
      #ifdef HX_MACOS
      if (!module)
      {
         String exe_path = HX_CSTRING("@executable_path/") + inLib + ( (pass&1) ? HX_CSTRING(".ndll") : ext );
         if (gLoadDebug)
         {
            printf(" try %s...\n", exe_path.__CStr());
         }
         module = hxLoadLibrary(exe_path);
      }
      #endif

      #if !defined(ANDROID) && !defined(HX_WINRT) && !defined(IPHONE) && !defined(EMSCRIPTEN)
      if (!module)
      {
         String hxcpp = GetEnv("HXCPP");
         if (hxcpp.length!=0)
         {
             String name = hxcpp + HX_CSTRING("/bin/") + bin + HX_CSTRING("/") + dll_ext;
             if (gLoadDebug)
                printf(" try %s...\n", name.__CStr());
             module = hxLoadLibrary(name);
         }
      }
   
      if (!module)
      {
         String hxcpp = FindHaxelib( HX_CSTRING("hxcpp") );
         if (hxcpp.length!=0)
         {
             String name = hxcpp + HX_CSTRING("/bin/") + bin + HX_CSTRING("/") + dll_ext;
             if (gLoadDebug)
                printf(" try %s...\n", name.__CStr());
             module = hxLoadLibrary(name);
         }
      }

      if (!module)
      {
         String path = FindHaxelib(inLib);
         if (path.length!=0)
         {
            String full_path  = path + HX_CSTRING("/ndll/") + bin + HX_CSTRING("/") + dll_ext;
            if (gLoadDebug)
               printf(" try %s...\n", full_path.__CStr());
            module = hxLoadLibrary(full_path);
         }
      }
      #endif
   }

   if (!module)
   {
     throw Dynamic(HX_CSTRING("Could not load module ") + inLib + HX_CSTRING("@") + full_name);
   }


   if (new_module)
   {
      #ifdef ANDROID
      sgLoadedModule[module_name] = module;
      #else
      sgLoadedModule[inLib.__s] = module;
      #endif

      SetLoaderProcFunc set_loader = (SetLoaderProcFunc)hxFindSymbol(module,"hx_set_loader");
      if (set_loader)
         set_loader(hx_cffi);

      GetNekoEntryFunc func = (GetNekoEntryFunc)hxFindSymbol(module,"__neko_entry_point");
      if (func)
      {
         NekoEntryFunc entry = (NekoEntryFunc)func();
         if (entry)
            entry();
      }
   }

   FundFunc proc_query = (FundFunc)hxFindSymbol(module,full_name.__CStr());
   if (!proc_query)
   {
      #ifdef ANDROID
       __android_log_print(ANDROID_LOG_ERROR, "loader", "Could not find primitive %s in %p",
        full_name.__CStr(), module);
      #else
      fprintf(stderr,"Could not find primitive %s.\n", full_name.__CStr());
      #endif
      return 0;
   }

   if (!inNdllProc)
      return (void *)proc_query;

   void *proc = proc_query();
   if (!proc)
   {
#ifdef ANDROID
      __android_log_print(ANDROID_LOG_ERROR, "loader", "Could not identify primitive %s in %s\n", full_name.__CStr(),inLib.__CStr());
      fprintf(stderr,"Could not identify primitive %s in %s\n", full_name.__CStr(),inLib.__CStr());
#elif defined(ANDROID)
   __android_log_print(ANDROID_LOG_ERROR, "loader", "Could not identify primitive %s in %s",
        inPrim.__CStr(), inLib.__CStr() );
#else
   fprintf(stderr,"Could not identify primitive %s in %s\n", full_name.__CStr(),inLib.__CStr());
#endif
   }

   return proc;
}
예제 #7
0
bool GeneralIK::_SolveTransThenRot(std::vector<dReal>& q_s)
{

    if(bPRINT)
        RAVELOG_INFO("Solving...\n");

    //clear from previous run
    _numitr = 0;    
    badjointinds.resize(0);
    prev_error = 1000000.0;

    //initialize stepsize and epsilon
    maxstep = 0.1*_targtms.size();
    stepsize = maxstep;
    epsilon = 0.001;

    bClearBadJoints = true; //setting this to true will make the algorithm attempt to move joints that are at joint limits at every iteration
        

    if(bDRAW)
    {
        for(int i = 0; i < _targmanips.size();i++)
        {
            GetEnv()->plot3( &(DoubleVectorToFloatVector(_targtms[i].trans)[0]), 1, 0, 5, Vector(0,1,0) );
        }
    }

    bBalanceGradient = false;
    Vector perpvec;
    //while(1)
    for(int kk = 0; kk < 3000; kk++)
    {

        _numitr++;

        bLimit = false;

        _pRobot->SetActiveDOFValues(q_s);
        if(bWRITETRAJ)
        {
            for(int i = 0; i < _pRobot->GetActiveDOF(); i++)
            {
                _trajpoint.q[i] = q_s[i];
            }
            ptraj->AddPoint(_trajpoint);
        }

        for(int i = 0; i < _targmanips.size();i++)
        {
            _pRobot->SetActiveManipulator(_targmanips[i]);
            _curtms[i] = _pRobot->GetActiveManipulator()->GetEndEffectorTransform();
    
            //since doing only translation, trick the solver into thinking it has achieved correct rotation
            _curtms[i].rot = _targtms[i].rot;
            
            if(bDRAW)
                GetEnv()->plot3( &(DoubleVectorToFloatVector(_curtms[i].trans)[0]), 1, 0, 5, Vector(1,0,0) );
        }

        x_error = TransformDifferenceVectorized(dx.Store(),_targtms,_curtms);

        if(bPRINT)
            PrintMatrix(dx.Store(),1,dx.Nrows(),"dx: ");           
        

        if(bPRINT)
            RAVELOG_INFO("x error: %f\n",x_error);


        //if balance stuff is on, error will go up sometimes, so don't do this check
        
        if(!bBalance && (x_error >= prev_error || (prev_error - x_error < epsilon/10))&& x_error > epsilon)
        {
            if(bPRINT)
            {
                RAVELOG_INFO("no progress\n");
                RAVELOG_INFO("prev: %f x_err: %f limit %d\n",prev_error,x_error,(int)bLimit);
            }
            stepsize = stepsize/2;
            x_error = prev_error;
            q_s = q_s_old;

        }
        else
            stepsize = maxstep;


        if(bPRINT)
            RAVELOG_INFO("stepsize: %f\n",stepsize);
        
        //don't let step size get too small

        if(stepsize < epsilon)
        {

            //RAVELOG_INFO("Projection stalled _numitr: %d\n",_numitr);
            return false;
        }


        if(bClearBadJoints)
        {
            badjointinds.resize(0);
        }
        do{
            q_s_old = q_s;

            if(bLimit == false)
                prev_error = x_error;

            if(bBalance)
            {
               GetCOGJacobian(Transform(),Jtemp2,curcog);
            }
            if(x_error < epsilon && (!bBalance || CheckSupport(curcog)))
            {        
                if(bPRINT)
                    RAVELOG_INFO("Translation component projection successfull _numitr: %d\n",_numitr);
                return _SolveStopAtLimits(q_s);
            }

            //only need to compute the jacobian once if there are joint limit problems
            if(bLimit == false)
            {
                for(int i = 0; i < _targmanips.size();i++)
                {
                    _pRobot->SetActiveManipulator(_targmanips[i]);
                    GetFullJacobian(_curtms[i],_targtms[i],Jtemp);
                    Jtrans.Rows(i*3 +1,(i+1)*3) = Jtemp.Rows(1,3);
                    dx_trans.Rows(i*3 +1,(i+1)*3) = dx.Rows(1,3);
                }


                if(bBalance)
                {
                   //the cog jacobian should only be 2 dimensional, b/c we don't care about z
                   GetCOGJacobian(Transform(),Jtemp2,curcog);

                   if(!CheckSupport(curcog))
                   {    
                        bBalanceGradient = true;
                        balancedx[0] = (curcog.x - cogtarg.x);
                        balancedx[1] = (curcog.y - cogtarg.y);
                   }
                   else
                   {
                        balancedx[0] = 0;
                        balancedx[1] = 0;
                        bBalanceGradient = false;
                   }
                }

    
            }
            //eliminate bad joint columns from the Jacobian
            for(int j = 0; j < badjointinds.size(); j++)
                for(int k = 0; k < _numtransdims; k++)
                      Jtrans[k][badjointinds[j]] = 0;

            if(bBalance)
            {
                for(int j = 0; j < badjointinds.size(); j++)
                    for(int k = 0; k <2; k++)
                          Jtemp2[k][badjointinds[j]] = 0;
            }



            if(x_error > stepsize)
                magnitude = stepsize/x_error;
            else
                magnitude = 1;       
            
            //NEWMAT::DiagonalMatrix Weights;
            //Weights.ReSize(_numdofs);
            //Weights = 1;
            //J = J * Weights;
            //PrintMatrix(J.Store(),_numtargdims,_numdofs,"J: ");
            
            NEWMAT::DiagonalMatrix Reg(_numtransdims);
            Reg = 0.0001;
            M << (Jtrans*Jtrans.t()) + Reg;
            //PrintMatrix(J.Store(),_numtargdims,_numtargdims,"M: ");

            invConditioningBound(100,M,Minv);
            
            //Minv = M.i();
            //PrintMatrix(Minv.Store(),_numtargdims,_numtargdims,"Minv: ");

            Jplus = Jtrans.t()*Minv;

            if(bBalanceGradient)
            {
               Mbal << (Jtemp2*Jtemp2.t());
               invConditioningBound(100,Mbal,Mbalinv);


               //do ik, then move toward balance in null space
               step =  magnitude*Jplus*(dx_trans) + (NEWMAT::IdentityMatrix(_numdofs) - Jplus*Jtrans)*(Jtemp2.t()*Mbalinv)*(1*balancedx);

            }
            else
            {

                step = magnitude*Jplus*(dx_trans);
            }
            if(bPRINT)
                PrintMatrix(step.Store(),1,step.Nrows(),"step: ");
           

            //add step and check for joint limits
            bLimit = false;
            for(int i = 0; i < _numdofs; i++)
            {
                q_s[i] = q_s_old[i] - step[i];
                if(q_s[i] < _lowerLimit[i] || q_s[i] > _upperLimit[i])
                {
                    if(bPRINT)
                        RAVELOG_INFO("Jacobian going past joint limit. J%d: %f outside %f to %f\n",i,q_s[i],_lowerLimit[i],_upperLimit[i]);

                    if(q_s[i] < _lowerLimit[i])
                        q_s[i] = _lowerLimit[i];
                    if(q_s[i] > _upperLimit[i])
                        q_s[i] = _upperLimit[i];
        
                    badjointinds.push_back(i); //note this will never add the same joint twice, even if bClearBadJoints = false
                    bLimit = true;

                }
                

            }

            //move back to previous point if any joint limits
            if(bLimit)
            {

                q_s = q_s_old;
            }

        }while(bLimit);
    

        if(bPRINT)
            RAVELOG_INFO("after limits\n");

    }

    RAVELOG_INFO("Iteration limit reached\n");
    return false;

}
예제 #8
0
파일: main.c 프로젝트: x-lugoo/pos
int main(void)
{
	uchar			bUpdateUI, bGallery = FALSE;
	int				iRet;
	ST_EVENT_MSG	stEventMsg;
	int iGallery_Image_Num = 0;
	uchar szGallery_Image_Num[5]= {0};
#ifdef APP_DEBUG
 	ST_KEY_INFO     stTmp_Key;
 	ST_KCV_INFO		stTmp_Kcv;
#endif

	OsLogSetTag(APP_NAME);
    OsRegGetValue("ro.fac.mach", gl_szTerminalType);

    // Application initialization
	memset(&stEventMsg, 0, sizeof(stEventMsg));
	stEventMsg.MsgType = USER_MSG;
	iRet = event_main(&stEventMsg);
	if (iRet == ERR_EXIT_APP)
	{
//	    CommOnHook(TRUE);
		return 0;
	}

	//////////////////////////////////////////////////////////////////////////
	//temp
#ifdef APP_DEBUG
	OsPedEraseKeys();
 	stTmp_Key.ucSrcKeyType = PED_TMK;
 	stTmp_Key.ucSrcKeyIdx  = 0;
 	stTmp_Key.ucDstKeyType = PED_TMK;
 	stTmp_Key.ucDstKeyIdx  = MASTER_KEY_ID;
 	memcpy(stTmp_Key.aucDstKeyValue,
 	        "\xAB\xCD\xEF\x01\x23\x45\x67\x89"\
 	        "\xAB\xCD\xEF\x01\x23\x45\x67\x89",
 	        16);
 	stTmp_Key.iDstKeyLen = 16;
 	stTmp_Kcv.iCheckMode =0;
	PedWriteKey(&stTmp_Key, &stTmp_Kcv);

 	stTmp_Key.ucSrcKeyType = PED_TMK;
 	stTmp_Key.ucSrcKeyIdx  = MASTER_KEY_ID;
 	stTmp_Key.ucDstKeyType = PED_TPK;
 	stTmp_Key.ucDstKeyIdx  = DEF_PIN_KEY_ID;
 	memcpy(stTmp_Key.aucDstKeyValue,
 	        "\xAB\xCD\xEF\x01\x23\x45\x67\x89"\
 	        "\xAB\xCD\xEF\x01\x23\x45\x67\x89",
 	        16);
 	stTmp_Key.iDstKeyLen = 16;
 	stTmp_Kcv.iCheckMode =0;
 	PedWriteKey(&stTmp_Key, &stTmp_Kcv);

    stTmp_Key.ucSrcKeyType = PED_TMK;
    stTmp_Key.ucSrcKeyIdx  = MASTER_KEY_ID;
    stTmp_Key.ucDstKeyType = PED_TDK;
    stTmp_Key.ucDstKeyIdx  = DEF_DATA_KEY_ID;
    memcpy(stTmp_Key.aucDstKeyValue,
            "\x12\x12\x12\x12\x12\x12\x12\x12"\
            "\x12\x12\x12\x12\x12\x12\x12\x12",
            16);
    stTmp_Key.iDstKeyLen = 16;
    stTmp_Kcv.iCheckMode =0;
    PedWriteKey(&stTmp_Key, &stTmp_Kcv);
#endif
	//////////////////////////////////////////////////////////////////////////

    // Main loop
	bUpdateUI = TRUE;
	if(0 == GetEnv("PIC_NO", szGallery_Image_Num))
	{
	    iGallery_Image_Num = atoi(szGallery_Image_Num);
	}
	else
	{
	    iGallery_Image_Num = 0;
	}

	//RunApp(1); test

	while( 1 )
	{
		// Setup idle timer
		if (bUpdateUI)
		{
			SetIdleTimer();
		}

		ShowIdleMainUI(&bUpdateUI, bGallery, iGallery_Image_Num);	// bUpdateUI value may change

        // When magstripe card swiped
		if( MagSwiped()==0 )
		{
			memset(&stEventMsg, 0, sizeof(ST_EVENT_MSG));
			stEventMsg.MsgType = MAGCARD_MSG;
			stEventMsg.MagMsg.RetCode = MagRead(stEventMsg.MagMsg.track1,
												stEventMsg.MagMsg.track2,
												stEventMsg.MagMsg.track3);
			iRet = event_main(&stEventMsg);
			if (iRet==ERR_EXIT_APP)
			{
//			    CommOnHook(TRUE);
				return 0;
			}
			bUpdateUI = TRUE;
			bGallery = FALSE;
			CommOnHook(FALSE);
			continue;
		}

        // When chip card inserted
		if( ChkIfEmvEnable() && IccDetect(ICC_USER)==0 )
		{
			memset(&stEventMsg, 0, sizeof(ST_EVENT_MSG));
			stEventMsg.MsgType = ICCARD_MSG;
			iRet = event_main(&stEventMsg);
			if (iRet==ERR_EXIT_APP)
			{
//			    CommOnHook(TRUE);
				return 0;
			}
			bUpdateUI = TRUE;
			bGallery = FALSE;
			CommOnHook(FALSE);
			continue;
		}

        // If any key is pressed
		if( 0==kbhit() )
		{
			memset(&stEventMsg, 0, sizeof(ST_EVENT_MSG));
			stEventMsg.MsgType  = KEYBOARD_MSG;
			stEventMsg.KeyValue = getkey();
			// Add by lirz v1.02.0000
			// If key enter,it repaint the main UI(mainly logo) again and again,do not do this
			if(KEYENTER == stEventMsg.KeyValue)
			{
			    //RunApp(1);  test
				continue;
			}
			iRet = event_main(&stEventMsg);
			if (iRet==ERR_EXIT_APP)
			{
			    SetCurrTitle(_T("Exit"));
//			    CommOnHook(TRUE);
				if(PasswordBank() == 0)
				{
					return 0;
				}
			}
			bUpdateUI = TRUE;
			bGallery = FALSE;
			CommOnHook(FALSE);
			continue;
		}

        // bug 803 change the sequence of 2 ChkIdleTimer
        if (ChkIdleTimer(glSysParam.stEdcInfo.ucIdleMinute * 60 /2))
        {
            bGallery = TRUE;
        }

		// One of idle-processing
		if (ChkIdleTimer(glSysParam.stEdcInfo.ucIdleMinute * 60))
		{
			if(0 == MainIdleProc())
			{
                bUpdateUI = TRUE;
                bGallery = FALSE;
			}
			continue;
		}

        // TODO:add your event-handlers here...

	} // end of while( 1
	return 0;
}
예제 #9
0
 ShortcutLinearPlanner(EnvironmentBasePtr penv, std::istream& sinput) : PlannerBase(penv)
 {
     __description = ":Interface Author: Rosen Diankov\n\npath optimizer using linear shortcuts.";
     _linearretimer = RaveCreatePlanner(GetEnv(), "LinearTrajectoryRetimer");
 }
예제 #10
0
    /// \brief jitters the current configuration and sets a new configuration on the environment
    ///
    int Sample(std::vector<dReal>& vnewdof, IntervalType interval=IT_Closed)
    {
        RobotBase::RobotStateSaver robotsaver(_probot, KinBody::Save_LinkTransformation|KinBody::Save_ActiveDOF);
        _InitRobotState();
        const dReal linkdistthresh = _linkdistthresh;
        const dReal linkdistthresh2 = _linkdistthresh2;

        vector<AABB> newLinkAABBs;
        bool bCollision = false;
        bool bConstraintFailed = false;
        bool bConstraint = !!_neighstatefn;

        // have to test with perturbations since very small changes in angles can produce collision inconsistencies
        std::vector<dReal> perturbations;
        if( _perturbation > 0 ) {
            perturbations.resize(3,0);
            perturbations[0] = _perturbation;
            perturbations[1] = -_perturbation;
        }
        else {
            perturbations.resize(1,0);
        }
        vnewdof.resize(GetDOF());
        int numNeighStateFailed = 0;
        FOREACH(itperturbation,perturbations) {
            if( bConstraint ) {
                FOREACH(it,_deltadof) {
                    *it = *itperturbation;
                }
                vnewdof = _curdof;
                if( !_neighstatefn(vnewdof,_deltadof,0) ) {
                    _probot->SetActiveDOFValues(_curdof);
//                    if( setret != 0 ) {
//                        // state failed to set, this could mean the initial state is just really bad, so resume jittering
//                        bCollision = true;
//                        break;
//                    }
                    ++numNeighStateFailed;
                    continue;
                }
            }
            else {
                for(size_t i = 0; i < vnewdof.size(); ++i) {
                    vnewdof[i] = _curdof[i]+*itperturbation;
                    if( vnewdof[i] > _upper.at(i) ) {
                        vnewdof[i] = _upper.at(i);
                    }
                    else if( vnewdof[i] < _lower.at(i) ) {
                        vnewdof[i] = _lower.at(i);
                    }
                }
            }

            // don't need to set state since CheckPathAllConstraints does it
            _probot->SetActiveDOFValues(vnewdof);

            if( !!_pConstraintToolDirection && !!_pmanip ) {
                if( !_pConstraintToolDirection->IsInConstraints(_pmanip->GetTransform()) ) {
                    bConstraintFailed = true;
                    break;

                }
            }
            if( !!_pConstraintToolPosition && !!_pmanip ) {
                if( !_pConstraintToolPosition->IsInConstraints(_pmanip->GetTransform()) ) {
                    bConstraintFailed = true;
                    break;

                }
            }
            if( GetEnv()->CheckCollision(_probot, _report) || _probot->CheckSelfCollision(_report) ) {
                bCollision = true;
                break;
            }
        }
예제 #11
0
        std::string GetEnv(const std::string& name)
        {
            static const std::string empty;

            return GetEnv(name, empty);
        }
int HttpRequestX::ParseUrlQuery(){
    if(m_initialized){
        return m_param_count;
    }

    m_initialized = true;

    char * content_type = GetContentType();
    if(content_type != NULL && strncmp(content_type, "multipart", 10) == 0) {
        return 0;  //  todo: support multipart/form-data
    }

    char * param_buffer = NULL;
    if(GetMethod() == HTTP_METHOD_POST) {
        unsigned long content_len;
        char * content_len_str = GetEnv("CONTENT_LENGTH");
        sscanf(content_len_str,"%ld",&content_len);
        content_len += 1;
        if(content_len > MAX_CONTENT_LENGTH) {
            // TODO 检查content_len是否超出最大
            return -2;
        }

        param_buffer = (char*) malloc (sizeof(char)*content_len);
        bzero(param_buffer, sizeof(char)*content_len);
        int read_num = FCGX_GetStr(param_buffer, content_len, request_.in);
        if (read_num < 0) {
            return -1;
        }
    }
    else if(GetMethod() == HTTP_METHOD_GET) {
        char * query_string = GetEnv("QUERY_STRING");
        param_buffer = strdup(query_string);
    }
    else {
        //TODO: 不支持的方法
        return -1;
    }

    char *query = param_buffer;
    int len = strlen(param_buffer);
    int num = 0;  // 参数个数
    char * q = query;

    if(q == NULL)
    {
        free(param_buffer);
        return 0;
    }

    while(strsep(&q, "&") != NULL){
        num ++;
    }

    if(num == 0) {
        free(param_buffer);
        return 0;
    }

    int size = (num)*sizeof(param_pair_t);
    if(m_params == NULL){
        m_params = (param_pair_t*)malloc(size);
    }
    else if(m_param_array_size<num){
        // 与上次请求的参数个数相比较,如果需要更多内存,则重新分配
        m_params = (param_pair_t*)realloc(m_params, size);
        m_param_array_size = num;
    }

    if(m_params == NULL)
    {
        free(param_buffer);
        return -1;
    }

    memset(m_params, 0, size);
    param_pair_t * my_param = m_params;

    char * name;
    char * value;
    for (q = query; q < (query + len);){
        name = q;
        value = q;
        q += strlen(q)+1;              // 跳到下一个参数
        name = strsep(&value, "=");    // 分解当前参数
        my_param->name = url_decode2(strdup(name));
        my_param->value = url_decode2(strdup(value==NULL ? "" : value) );
        my_param++;
    }
    free(param_buffer);
    return num;
}
예제 #13
0
  void Init()
  {
    Internal("Config::Init","()");

#ifndef REGAL_NO_GETENV
    const char *tmp;

#if !REGAL_FORCE_ES1_PROFILE
    tmp = GetEnv( "REGAL_FORCE_ES1_PROFILE" );
    if (tmp) forceES1Profile = atoi(tmp)!=0;
#endif

#if !REGAL_FORCE_ES2_PROFILE
    tmp = GetEnv( "REGAL_FORCE_ES2_PROFILE" );
    if (tmp) forceES2Profile = atoi(tmp)!=0;
#endif

#if !REGAL_FORCE_CORE_PROFILE
    tmp = GetEnv( "REGAL_FORCE_CORE_PROFILE" );
    if (tmp) forceCoreProfile = atoi(tmp)!=0;
#endif

  // With REGAL_SYS_GLX && REGAL_SYS_EGL
  // we infer each from other, if specified,
  // to behave as a toggle.

#if REGAL_SYS_GLX
    tmp = GetEnv( "REGAL_SYS_GLX" );
    if (tmp)
    {
      sysGLX = atoi(tmp)!=0;
#if REGAL_SYS_EGL
      sysEGL = !sysGLX;
#endif
    }
#endif

#if REGAL_SYS_EGL
    tmp = GetEnv( "REGAL_SYS_EGL" );
    if (tmp)
    {
      sysEGL = atoi(tmp)!=0;
#if REGAL_SYS_GLX
      sysGLX = !sysEGL;
#endif
     }
#endif

    // Default to GLX, if necessary

#if REGAL_SYS_GLX && REGAL_SYS_EGL
    if (sysGLX && sysEGL)
      sysEGL = false;
#endif

#if !REGAL_FORCE_EMULATION
    tmp = GetEnv( "REGAL_FORCE_EMULATION" );
    if (tmp) forceEmulation = atoi(tmp)!=0;
#endif

#if REGAL_EMULATION
    tmp = GetEnv( "REGAL_EMULATION" );
    if (tmp) enableEmulation = atoi(tmp)!=0;
#endif

    // Deprecated

    tmp = GetEnv( "REGAL_NO_EMULATION" );
    if (tmp) enableEmulation = atoi(tmp)==0;

#if REGAL_DEBUG
    tmp = GetEnv( "REGAL_DEBUG" );
    if (tmp) enableDebug = atoi(tmp)!=0;
#endif

#if REGAL_TRACE
    tmp = GetEnv( "REGAL_TRACE" );
    if (tmp) enableTrace = atoi(tmp)!=0;
#endif

#if REGAL_ERROR
    tmp = GetEnv( "REGAL_ERROR" );
    if (tmp) enableError = atoi(tmp)!=0;
#endif

#if REGAL_CODE
    tmp = GetEnv( "REGAL_CODE" );
    if (tmp) enableCode = atoi(tmp)!=0;
#endif

#if REGAL_LOG
    tmp = GetEnv( "REGAL_LOG" );
    if (tmp) enableLog = atoi(tmp)!=0;
#endif

#if REGAL_DRIVER
    tmp = GetEnv( "REGAL_DRIVER" );
    if (tmp) enableDriver = atoi(tmp)!=0;
#endif

#if REGAL_EMU_PPA
    tmp = GetEnv( "REGAL_EMU_PPA" );
    if (tmp) enableEmuPpa = atoi(tmp)!=0;
#endif

#if REGAL_EMU_PPCA
    tmp = GetEnv( "REGAL_EMU_PPCA" );
    if (tmp) enableEmuPpca = atoi(tmp)!=0;
#endif

#if REGAL_EMU_OBJ
    tmp = GetEnv( "REGAL_EMU_OBJ" );
    if (tmp) enableEmuObj = atoi(tmp)!=0;
#endif

#if REGAL_EMU_BIN
    tmp = GetEnv( "REGAL_EMU_BIN" );
    if (tmp) enableEmuBin = atoi(tmp)!=0;
#endif

#if REGAL_EMU_TEXSTO
    tmp = GetEnv( "REGAL_EMU_TEXSTO" );
    if (tmp) enableEmuTexSto = atoi(tmp)!=0;
#endif

#if REGAL_EMU_XFER
    tmp = GetEnv( "REGAL_EMU_XFER" );
    if (tmp) enableEmuXfer = atoi(tmp)!=0;
#endif

#if REGAL_EMU_DSA
    tmp = GetEnv( "REGAL_EMU_DSA" );
    if (tmp) enableEmuDsa = atoi(tmp)!=0;
#endif

#if REGAL_EMU_RECT
    tmp = GetEnv( "REGAL_EMU_RECT" );
    if (tmp) enableEmuRect = atoi(tmp)!=0;
#endif

#if REGAL_EMU_IFF
    tmp = GetEnv( "REGAL_EMU_IFF" );
    if (tmp) enableEmuIff = atoi(tmp)!=0;
#endif

#if REGAL_EMU_SO
    tmp = GetEnv( "REGAL_EMU_SO" );
    if (tmp) enableEmuSo = atoi(tmp)!=0;
#endif

#if REGAL_EMU_VAO
    tmp = GetEnv( "REGAL_EMU_VAO" );
    if (tmp) enableEmuVao = atoi(tmp)!=0;
#endif

#if REGAL_EMU_TEXC
    tmp = GetEnv( "REGAL_EMU_TEXC" );
    if (tmp) enableEmuTexC = atoi(tmp)!=0;
#endif

#if REGAL_EMU_FILTER
    tmp = GetEnv( "REGAL_EMU_FILTER" );
    if (tmp) enableEmuFilter = atoi(tmp)!=0;
#endif

    //

#if REGAL_EMU_PPA
    tmp = GetEnv( "REGAL_FORCE_EMU_PPA" );
    if (tmp) forceEmuPpa = atoi(tmp)!=0;
#endif

#if REGAL_EMU_PPCA
    tmp = GetEnv( "REGAL_FORCE_EMU_PPCA" );
    if (tmp) forceEmuPpca = atoi(tmp)!=0;
#endif

#if REGAL_EMU_OBJ
    tmp = GetEnv( "REGAL_FORCE_EMU_OBJ" );
    if (tmp) forceEmuObj = atoi(tmp)!=0;
#endif

#if REGAL_EMU_BIN
    tmp = GetEnv( "REGAL_FORCE_EMU_BIN" );
    if (tmp) forceEmuBin = atoi(tmp)!=0;
#endif

#if REGAL_EMU_TEXSTO
    tmp = GetEnv( "REGAL_FORCE_EMU_TEXSTO" );
    if (tmp) forceEmuTexSto = atoi(tmp)!=0;
#endif

#if REGAL_EMU_XFER
    tmp = GetEnv( "REGAL_FORCE_EMU_XFER" );
    if (tmp) forceEmuXfer = atoi(tmp)!=0;
#endif

#if REGAL_EMU_DSA
    tmp = GetEnv( "REGAL_FORCE_EMU_DSA" );
    if (tmp) forceEmuDsa = atoi(tmp)!=0;
#endif

#if REGAL_EMU_RECT
    tmp = GetEnv( "REGAL_FORCE_EMU_RECT" );
    if (tmp) forceEmuRect = atoi(tmp)!=0;
#endif

#if REGAL_EMU_IFF
    tmp = GetEnv( "REGAL_FORCE_EMU_IFF" );
    if (tmp) forceEmuIff = atoi(tmp)!=0;
#endif

#if REGAL_EMU_SO
    tmp = GetEnv( "REGAL_FORCE_EMU_SO" );
    if (tmp) forceEmuSo = atoi(tmp)!=0;
#endif

#if REGAL_EMU_VAO
    tmp = GetEnv( "REGAL_FORCE_EMU_VAO" );
    if (tmp) forceEmuVao = atoi(tmp)!=0;
#endif

#if REGAL_EMU_TEXC
    tmp = GetEnv( "REGAL_FORCE_EMU_TEXC" );
    if (tmp) forceEmuTexC = atoi(tmp)!=0;
#endif

#if REGAL_EMU_FILTER
    tmp = GetEnv( "REGAL_FORCE_EMU_FILTER" );
    if (tmp) forceEmuFilter = atoi(tmp)!=0;
#endif

    //

    tmp = GetEnv( "REGAL_FRAME_LIMIT" );
    if (tmp) frameLimit = atoi(tmp);

    //

    tmp = GetEnv( "REGAL_MD5_COLOR" );
    if (tmp) frameMd5Color = atoi(tmp)!=0;

    tmp = GetEnv( "REGAL_MD5_STENCIL" );
    if (tmp) frameMd5Stencil = atoi(tmp)!=0;

    tmp = GetEnv( "REGAL_MD5_DEPTH" );
    if (tmp) frameMd5Depth = atoi(tmp)!=0;

    tmp = GetEnv( "REGAL_MD5_COLOR_MASK" );
    if (tmp) frameMd5ColorMask = static_cast<unsigned char>(atoi(tmp));

    tmp = GetEnv( "REGAL_MD5_STENCIL_MASK" );
    if (tmp) frameMd5StencilMask = static_cast<unsigned char>(atoi(tmp));

    tmp = GetEnv( "REGAL_MD5_DEPTH_MASK" );
    if (tmp) frameMd5DepthMask = atoi(tmp);

    //

    tmp = GetEnv( "REGAL_SAVE_COLOR" );
    if (tmp) frameSaveColor = atoi(tmp)!=0;

    tmp = GetEnv( "REGAL_SAVE_STENCIL" );
    if (tmp) frameSaveStencil = atoi(tmp)!=0;

    tmp = GetEnv( "REGAL_SAVE_DEPTH" );
    if (tmp) frameSaveDepth = atoi(tmp)!=0;

    // Caching

#if REGAL_CACHE
    tmp = GetEnv( "REGAL_CACHE" );
    if (tmp) cache = atoi(tmp)!=0;

    // GLSL shader caching

#if REGAL_CACHE_SHADER
    tmp = GetEnv( "REGAL_CACHE_SHADER" );
    if (tmp) cacheShader = atoi(tmp)!=0;
#endif

#if REGAL_CACHE_SHADER_WRITE
    tmp = GetEnv( "REGAL_CACHE_SHADER_WRITE" );
    if (tmp) cacheShaderWrite = atoi(tmp)!=0;
#endif

#if REGAL_CACHE_SHADER_READ
    tmp = GetEnv( "REGAL_CACHE_SHADER_READ" );
    if (tmp) cacheShaderRead = atoi(tmp)!=0;
#endif

    // Teture caching

#if REGAL_CACHE_TEXTURE
    tmp = GetEnv( "REGAL_CACHE_TEXTURE" );
    if (tmp) cacheTexture = atoi(tmp)!=0;
#endif

#if REGAL_CACHE_TEXTURE_WRITE
    tmp = GetEnv( "REGAL_CACHE_TEXTURE_WRITE" );
    if (tmp) cacheTextureWrite = atoi(tmp)!=0;
#endif

#if REGAL_CACHE_TEXTURE_READ
    tmp = GetEnv( "REGAL_CACHE_TEXTURE_READ" );
    if (tmp) cacheTextureRead = atoi(tmp)!=0;
#endif

    tmp = GetEnv( "REGAL_CACHE_DIRECTORY" );
    if (tmp) cacheDirectory = tmp;
#endif

#if REGAL_CODE
    tmp = GetEnv( "REGAL_CODE_SOURCE" );
    if (tmp) codeSourceFile = tmp;

    tmp = GetEnv( "REGAL_CODE_HEADER" );
    if (tmp) codeHeaderFile = tmp;
#endif

#endif

#if REGAL_THREAD_LOCKING
    tmp = GetEnv( "REGAL_THREAD_LOCKING" );
    if (tmp) enableThreadLocking = atoi(tmp)!=0;
#else
    enableThreadLocking = false;
#endif

    // REGAL_NO_EMULATION is deprecated, use REGAL_EMULATION=0 instead.

#if REGAL_EMULATION && defined(REGAL_NO_EMULATION) && REGAL_NO_EMULATION
    enableEmulation = false;
#endif

#if REGAL_SYS_ES1
    Info("REGAL_FORCE_ES1_PROFILE   ", forceES1Profile  ? "enabled" : "disabled");
#endif

#if REGAL_SYS_ES2
    Info("REGAL_FORCE_ES2_PROFILE   ", forceES2Profile  ? "enabled" : "disabled");
#endif

    Info("REGAL_FORCE_CORE_PROFILE  ", forceCoreProfile ? "enabled" : "disabled");

#if REGAL_SYS_ES1
    Info("REGAL_SYS_ES1             ", sysES1           ? "enabled" : "disabled");
#endif

#if REGAL_SYS_ES2
    Info("REGAL_SYS_ES2             ", sysES2           ? "enabled" : "disabled");
#endif

#if REGAL_SYS_GL
    Info("REGAL_SYS_GL              ", sysGL            ? "enabled" : "disabled");
#endif

#if REGAL_SYS_GLX
    Info("REGAL_SYS_GLX             ", sysGLX           ? "enabled" : "disabled");
#endif

#if REGAL_SYS_EGL
    Info("REGAL_SYS_EGL             ", sysEGL           ? "enabled" : "disabled");
#endif

    Info("REGAL_FORCE_EMULATION     ", forceEmulation   ? "enabled" : "disabled");
#if REGAL_TRACE
    Info("REGAL_TRACE               ", enableTrace      ? "enabled" : "disabled");
#endif
    Info("REGAL_DEBUG               ", enableDebug      ? "enabled" : "disabled");
    Info("REGAL_ERROR               ", enableError      ? "enabled" : "disabled");
#if REGAL_CODE
    Info("REGAL_CODE                ", enableCode       ? "enabled" : "disabled");
#endif
    Info("REGAL_EMULATION           ", enableEmulation  ? "enabled" : "disabled");
    Info("REGAL_LOG                 ", enableLog        ? "enabled" : "disabled");
    Info("REGAL_DRIVER              ", enableDriver     ? "enabled" : "disabled");

    Info("REGAL_EMU_PPA             ", enableEmuPpa     ? "enabled" : "disabled");
    Info("REGAL_EMU_PPCA            ", enableEmuPpca    ? "enabled" : "disabled");
    Info("REGAL_EMU_OBJ             ", enableEmuObj     ? "enabled" : "disabled");
    Info("REGAL_EMU_BIN             ", enableEmuBin     ? "enabled" : "disabled");
    Info("REGAL_EMU_TEXSTO          ", enableEmuTexSto  ? "enabled" : "disabled");
    Info("REGAL_EMU_XFER            ", enableEmuXfer    ? "enabled" : "disabled");
    Info("REGAL_EMU_DSA             ", enableEmuDsa     ? "enabled" : "disabled");
    Info("REGAL_EMU_RECT            ", enableEmuRect    ? "enabled" : "disabled");
    Info("REGAL_EMU_IFF             ", enableEmuIff     ? "enabled" : "disabled");
    Info("REGAL_EMU_SO              ", enableEmuSo      ? "enabled" : "disabled");
    Info("REGAL_EMU_VAO             ", enableEmuVao     ? "enabled" : "disabled");
    Info("REGAL_EMU_FILTER          ", enableEmuFilter  ? "enabled" : "disabled");
    Info("REGAL_EMU_TEXC            ", enableEmuTexC    ? "enabled" : "disabled");

    Info("REGAL_FORCE_EMU_PPA       ", forceEmuPpa      ? "enabled" : "disabled");
    Info("REGAL_FORCE_EMU_PPCA      ", forceEmuPpca     ? "enabled" : "disabled");
    Info("REGAL_FORCE_EMU_OBJ       ", forceEmuObj      ? "enabled" : "disabled");
    Info("REGAL_FORCE_EMU_BIN       ", forceEmuBin      ? "enabled" : "disabled");
    Info("REGAL_FORCE_EMU_TEXSTO    ", forceEmuTexSto   ? "enabled" : "disabled");
    Info("REGAL_FORCE_EMU_XFER      ", forceEmuXfer     ? "enabled" : "disabled");
    Info("REGAL_FORCE_EMU_DSA       ", forceEmuDsa      ? "enabled" : "disabled");
    Info("REGAL_FORCE_EMU_RECT      ", forceEmuRect     ? "enabled" : "disabled");
    Info("REGAL_FORCE_EMU_IFF       ", forceEmuIff      ? "enabled" : "disabled");
    Info("REGAL_FORCE_EMU_SO        ", forceEmuSo       ? "enabled" : "disabled");
    Info("REGAL_FORCE_EMU_VAO       ", forceEmuVao      ? "enabled" : "disabled");
    Info("REGAL_FORCE_EMU_FILTER    ", forceEmuFilter   ? "enabled" : "disabled");
    Info("REGAL_FORCE_EMU_TEXC      ", forceEmuTexC     ? "enabled" : "disabled");

    Info("REGAL_FRAME_LIMIT         ", frameLimit                               );

    Info("REGAL_MD5_COLOR           ", frameMd5Color    ? "enabled" : "disabled");
    Info("REGAL_MD5_STENCIL         ", frameMd5Stencil  ? "enabled" : "disabled");
    Info("REGAL_MD5_DEPTH           ", frameMd5Depth    ? "enabled" : "disabled");

    Info("REGAL_SAVE_COLOR          ", frameSaveColor   ? "enabled" : "disabled");
    Info("REGAL_SAVE_STENCIL        ", frameSaveStencil ? "enabled" : "disabled");
    Info("REGAL_SAVE_DEPTH          ", frameSaveDepth   ? "enabled" : "disabled");

#if REGAL_CACHE
    Info("REGAL_CACHE               ", cache             ? "enabled" : "disabled");
    Info("REGAL_CACHE_TEXTURE       ", cacheTexture      ? "enabled" : "disabled");
    Info("REGAL_CACHE_TEXTURE_WRITE ", cacheTextureWrite ? "enabled" : "disabled");
#endif

#if REGAL_CODE
    Info("REGAL_CODE_SOURCE         ", codeSourceFile                            );
    Info("REGAL_CODE_HEADER         ", codeHeaderFile                            );
#endif

    Info("REGAL_THREAD_LOCKING      ", enableThreadLocking ? "enabled" : "disabled");
  }
예제 #14
0
파일: z09.c 프로젝트: thektulu/lout
OBJECT ClosureExpand(OBJECT x, OBJECT env, BOOLEAN crs_wanted,
OBJECT *crs, OBJECT *res_env)
{ OBJECT link, y, res, prnt_env, par, prnt;
  debug3(DCE, D, "[ ClosureExpand( %s, %s, %s, crs, res_env )",
    EchoObject(x), EchoObject(env), bool(crs_wanted));
  assert( type(x) == CLOSURE, "ClosureExpand given non-CLOSURE!");
  assert( predefined(actual(x)) == FALSE, "ClosureExpand given predefined!" );

  /* add tag to x if needed but not provided;  add cross-reference to crs  */
  if( has_tag(actual(x)) )  CrossAddTag(x);
  if( crs_wanted && has_tag(actual(x)) )
  { OBJECT tmp = CopyObject(x, no_fpos);  AttachEnv(env, tmp);
    y = CrossMake(actual(x), tmp, CROSS_TARG);
    New(tmp, CROSS_TARG);  actual(tmp) = y;  Link(tmp, y);
    if( *crs == nilobj )  New(*crs, CR_LIST);   Link(*crs, tmp);
  }

  /* case x is a parameter */
  res = *res_env = nilobj;
  if( is_par(type(actual(x))) )
  { prnt = SearchEnv(env, enclosing(actual(x)));
    if( prnt != nilobj )
    {
      prnt_env = GetEnv(prnt);
      for( link = Down(prnt);  link != prnt;  link = NextDown(link) )
      { Child(par, link);
        if( type(par) == PAR && actual(par) == actual(x) )
        { assert( Down(par) != par, "ExpandCLosure: Down(par)!");
	  Child(res, Down(par));
	  if( dirty(enclosing(actual(par))) || is_enclose(actual(par)) )
	  { debug2(DCE, DD, "copy %s %s", SymName(actual(par)), EchoObject(res));
	    res = CopyObject(res, no_fpos);
	  }
	  else
	  {
	    debug2(DCE, DD, "link %s %s",
	      FullSymName(actual(par), AsciiToFull(".")), EchoObject(res));
	    DeleteLink(Down(par));
	    y = MakeWord(WORD, STR_NOCROSS, &fpos(res));
	    Link(par, y);
	  }
	  ReplaceNode(res, x);
	  if( type(actual(x)) == RPAR && has_body(enclosing(actual(x))) )
	  { debug0(DCR, DDD, "  calling SetEnv from ClosureExpand (a)");
	    *res_env = SetEnv(prnt, nilobj);  DisposeObject(x);
	  }
	  else if( type(actual(x)) == NPAR && imports_encl(actual(x)) )
	  { debug0(DCR, DDD, "  calling SetEnv from ClosureExpand (x)");
	    AttachEnv(env, x);
	    *res_env = SetEnv(x, nilobj);
	  }
	  else
	  { AttachEnv(env, x);
	    debug0(DCR, DDD, "  calling SetEnv from ClosureExpand (b)");
	    *res_env = SetEnv(x, prnt_env);
	  }
	  break;
        }
      }
    }
    else
    {
      /* fail only if there is no default value available */
      if( sym_body(actual(x)) == nilobj )
      {
        debug3(DCE, D, "failing ClosureExpand( %s, crs, %s, %s, res_env )",
	  EchoObject(x), bool(crs_wanted), EchoObject(env));
        Error(9, 2, "no value for parameter %s of symbol %s:", WARN, &fpos(x),
	  SymName(actual(x)), SymName(enclosing(actual(x))));
        Error(9, 1, "symbol with import list misused", FATAL, &fpos(x));
      }
    }
  }

  /* case x is a user-defined symbol or default parameter */
  if( res == nilobj )
  { if( sym_body(actual(x)) == nilobj )
      res = MakeWord(WORD, STR_NOCROSS, &fpos(x));
    else
      res = CopyObject(sym_body(actual(x)), &fpos(x));
    ReplaceNode(res, x);  AttachEnv(env, x);
    debug0(DCR, DDD, "  calling SetEnv from ClosureExpand (c)");
    *res_env = SetEnv(x, nilobj);
  }

  assert( *res_env!=nilobj && type(*res_env)==ENV, "ClosureExpand: *res_env!");
  debug0(DCE, D, "] ClosureExpand returning, res =");
  ifdebug(DCE, D, DebugObject(res));
  debug1(DCE, D, "  environment = %s", EchoObject(*res_env));
  return res;
} /* end ClosureExpand */
예제 #15
0
LRESULT GlassApplication::WindowProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg) {
        case WM_DO_ACTION:
        case WM_DO_ACTION_LATER:
            {
                Action * action = (Action *)wParam;
                action->Do();
                if (msg == WM_DO_ACTION_LATER) {
                    delete action;
                }
            }
            return 0;
        case WM_CREATE:
            pInstance = this;
            STRACE(_T("GlassApplication: created."));
            break;
        case WM_DESTROY:
            //Alarm clipboard dispose if any.
            //Please, use RegisterClipboardViewer(NULL) instead of UnregisterClipboardViewer.
            RegisterClipboardViewer(NULL);
            return 0;
        case WM_NCDESTROY:
            // pInstance is deleted in BaseWnd::StaticWindowProc
            pInstance = NULL;
            STRACE(_T("GlassApplication: destroyed."));
            return 0;
        case WM_CHANGECBCHAIN:
            if ((HWND)wParam == m_hNextClipboardView) {
                m_hNextClipboardView = (HWND)lParam;
            } else if (NULL != m_hNextClipboardView) {
                ::SendMessage(m_hNextClipboardView, WM_CHANGECBCHAIN, wParam, lParam);
            }
            break;
        case WM_DRAWCLIPBOARD:
            if (NULL != m_clipboard) {
                GetEnv()->CallVoidMethod(m_clipboard, midContentChanged);
                CheckAndClearException(GetEnv());
            }
            if (NULL != m_hNextClipboardView) {
                ::SendMessage(m_hNextClipboardView, WM_DRAWCLIPBOARD, wParam, lParam);
            }
            break;
        case WM_SETTINGCHANGE:
            if ((UINT)wParam != SPI_SETWORKAREA) {
                break;
            }
            // Fall through
        case WM_DISPLAYCHANGE:
            GlassScreen::HandleDisplayChange();
            break;
        case WM_THEMECHANGED: {
            JNIEnv* env = GetEnv();
            jstring themeName = GlassApplication::GetThemeName(env);
            jboolean result = env->CallBooleanMethod(m_grefThis, javaIDs.Application.notifyThemeChangedMID, themeName);
            if (CheckAndClearException(env)) return 1;
            return !result;
        }
    }
    return ::DefWindowProc(GetHWND(), msg, wParam, lParam);
}
예제 #16
0
파일: utils.cpp 프로젝트: dfleury2/Nedit
// -------------------------------------------------------------------------
//  Returns a pointer to the name of an rc file of the requested type.
//
//  Preconditions:
//      - MAXPATHLEN is set to the max. allowed path length
//      - fullPath points to a buffer of at least MAXPATHLEN
//
//  Returns:
//      - NULL if an error occurs while creating a directory
//      - Pointer to a static array containing the file name
// -------------------------------------------------------------------------
const char* GetRCFileName(FileTypes type)
{
   static std::string rcFiles[N_FILE_TYPES];
   static bool namesDetermined = false;

   if (!namesDetermined)
   {
      std::string nedit_home = GetEnv("NEDIT_HOME");
      if (nedit_home.empty())
      {  //  No NEDIT_HOME
         // Let's try if ~/.nedit is a regular file or not.
         std::string  legacyFile = buildFilePath(GetHomeDir(), hiddenFileNames[NEDIT_RC]);
         if (isRegFile(legacyFile))
         {
            // This is a legacy setup with rc files in $HOME
            for (int i = 0; i < N_FILE_TYPES; i++)
            {
               rcFiles[i] = buildFilePath(GetHomeDir(), hiddenFileNames[i]);
            }
         }
         else
         {
            // ${HOME}/.nedit does not exist as a regular file.
            // FIXME: Devices, sockets and fifos are ignored for now.
            std::string defaultNEditHome = buildFilePath(GetHomeDir(), DEFAULT_NEDIT_HOME);
            if (!isDir(defaultNEditHome))
            {
               /* Create DEFAULT_NEDIT_HOME */
#ifdef WIN32
               if (mkdir(defaultNEditHome.c_str()) != 0)
#else
               if (mkdir(defaultNEditHome.c_str(), 0777) != 0)
#endif
               {
                  perror("nedit: Error while creating rc file directory"
                         " $HOME/" DEFAULT_NEDIT_HOME "\n"
                         " (Make sure all parent directories exist.)");
                  return NULL;
               }
            }

            /* All set for DEFAULT_NEDIT_HOME, let's copy the names */
            for (int i = 0; i < N_FILE_TYPES; i++)
            {
               rcFiles[i] = buildFilePath(defaultNEditHome.c_str(), plainFileNames[i]);
            }
         }
      }
      else
      {  // $NEDIT_HOME is set.
         // FIXME: Is this required? Does VMS know stat(), mkdir()?
         if (!isDir(nedit_home))
         {
            /* Create $NEDIT_HOME */
#ifdef WIN32
            if (mkdir(nedit_home.c_str()) != 0)
#else
            if (mkdir(nedit_home.c_str(), 0777) != 0)
#endif
            {
               perror("nedit: Error while creating rc file directory $NEDIT_HOME\n"
                      "nedit: (Make sure all parent directories exist.)");
               return NULL;
            }
         }

         // All set for NEDIT_HOME, let's copy the names
         for (int i = 0; i < N_FILE_TYPES; i++)
         {
            rcFiles[i] = buildFilePath(nedit_home.c_str(), plainFileNames[i]);
         }
      }

      namesDetermined = true;
   }

   return rcFiles[type].c_str();
}
예제 #17
0
 ENTER_MAIN_THREAD()
 {
     GetEnv()->CallVoidMethod(runnable, javaIDs.Runnable.run);
     CheckAndClearException(GetEnv());
 }
예제 #18
0
DWORD DosWindowThread(void *xx)
{
    struct _varData *vdata = (struct _varData *)xx;
    char *xcmd = GetCmd();
    if (xcmd)
    {
        BOOL bSeenInitialBP = FALSE;
        BOOL bContinue = TRUE;
        DWORD dwContinueStatus;
        BOOL bShownExitCode = FALSE;
        DEBUG_EVENT stDE;
        LPTCH env = GetEnv();
        BOOL bRet;
        STARTUPINFO stStartInfo;
        PROCESS_INFORMATION stProcessInfo;
        DWORD exitCode;
        char wd[MAX_PATH], *p, cmd[MAX_PATH];
        if (vdata->path)
        {
            strcpy(wd, vdata->path);
            p = strrchr(wd, '\\');
            if (p)
                if (p[-1] == ':')
                    p[1] = 0;
                else
                    p[0] = 0;
            else
                    wd[0] = 0;
        }
        else 
            GetCurrentDirectory(sizeof(wd), wd);
        if (vdata->exec)
        {
            sprintf(cmd,"\"%s\" %s", vdata->exec, vdata->args);
        }
        else
        {
            sprintf(cmd, "\"%s\"", xcmd);
        }
        memset(&stStartInfo, 0, sizeof(STARTUPINFO));
        memset(&stProcessInfo, 0, sizeof(PROCESS_INFORMATION));

        stStartInfo.cb = sizeof(STARTUPINFO);
        bRet = CreateProcess(NULL, cmd, NULL, NULL, TRUE, DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS | CREATE_NEW_CONSOLE, env, 
                wd,  &stStartInfo, &stProcessInfo);
        if (!bRet)
        {
            FreeEnv(env);
            ExtendedMessageBox("Command Execution", MB_SETFOREGROUND | MB_SYSTEMMODAL, 
                "Could not execute %s.", cmd);
            return 0;
        }
        ProcessToTop(stProcessInfo.dwProcessId);
        while (TRUE == bContinue)
        {
            // Pause until a debug event notification happens.
            bContinue = WaitForDebugEvent(&stDE, 200);
            if (bContinue)
            {
                switch (stDE.dwDebugEventCode)
                {
                    case CREATE_PROCESS_DEBUG_EVENT:
                        CloseHandle(stDE.u.CreateProcessInfo.hFile);
                        dwContinueStatus = DBG_CONTINUE;
                        break;
                    case CREATE_THREAD_DEBUG_EVENT:
                    case LOAD_DLL_DEBUG_EVENT:
                    case UNLOAD_DLL_DEBUG_EVENT:
                    case OUTPUT_DEBUG_STRING_EVENT:
                    case RIP_EVENT:
                        dwContinueStatus = DBG_CONTINUE;
                        break;
                    case EXIT_THREAD_DEBUG_EVENT:
                        // this catches the X button at the top right of the window.
                        // if it was pressed we do the dialog here to prevent the original window
                        // from auto-closing before we show it.
                        if (stDE.u.ExitThread.dwExitCode == STATUS_CONTROL_C_EXIT)
                        {
                            if (!bShownExitCode) 
                            {
                                if (vdata->rvTitle)
                                {
                                    ExtendedMessageBox(vdata->rvTitle, MB_SETFOREGROUND | MB_SYSTEMMODAL, vdata->rvBody, stDE.u.ExitProcess.dwExitCode);
                                    bShownExitCode = TRUE;
                                }
                            }
                        }
                        dwContinueStatus = DBG_CONTINUE;
                        break;
                    case EXIT_PROCESS_DEBUG_EVENT:
                        
                        if (!bShownExitCode) 
                        {
                            if (vdata->rvTitle)
                            {
                                ExtendedMessageBox(vdata->rvTitle, MB_SETFOREGROUND | MB_SYSTEMMODAL, vdata->rvBody, stDE.u.ExitProcess.dwExitCode);
                                bShownExitCode = TRUE;
                            }
                        }
                        dwContinueStatus = DBG_CONTINUE;
                        bContinue = FALSE;
                        break;
    
                    case EXCEPTION_DEBUG_EVENT:
                        switch (stDE.u.Exception.ExceptionRecord.ExceptionCode)
                        {
                            default:
                                dwContinueStatus = DBG_EXCEPTION_NOT_HANDLED;
                                break;
                            case EXCEPTION_BREAKPOINT:
                                if (!bSeenInitialBP)
                                {
                                    bSeenInitialBP = TRUE;									
                                    dwContinueStatus = DBG_CONTINUE;
                                }
                                else
                                {
                                    dwContinueStatus = DBG_EXCEPTION_NOT_HANDLED;
                                }
                                break;
                        }
                        break;
    
                        // For any other events, just continue on.
                    default:
                        dwContinueStatus = DBG_EXCEPTION_NOT_HANDLED;
                        break;
                }
                // Pass on to the operating system.
                ContinueDebugEvent(stDE.dwProcessId, stDE.dwThreadId, dwContinueStatus);
            }
            else
            {
                dwContinueStatus = DBG_CONTINUE;
                bContinue = TRUE;
            }
    
        }
        CloseHandle(stProcessInfo.hProcess);
        CloseHandle(stProcessInfo.hThread);
        FreeEnv(env);
    }
    free(vdata->rvTitle);
    free(vdata->rvBody);
    free(vdata->path);
    free(vdata->exec);
    free(vdata->args);
    free(vdata);
    return 0;
}
예제 #19
0
파일: Ini.cpp 프로젝트: AbdelghaniDr/mirror
static void LoadIniStream(Stream& in, VectorMap<String, String>& key, const char *sfile)
{
	bool env = false;
	while(!in.IsEof()) {
		String line = in.GetLine();
		CParser p(line);
		if(p.IsId()) {
			String k = p.ReadId();
			if(p.Char('=')) {
				String h = TrimBoth((String)p.GetSpacePtr());
				if(env) {
					String hh;
					const char *s = ~h;
					while(*s) {
						if(*s == '$') {
							s++;
							if(*s == '$') {
								hh.Cat('$');
								s++;
							}
							else {
								String id;
								if (*s == '{') {
									while(*++s != '}')
										id.Cat(*s);
									s++;
								} else {
									while(iscid(*s))
										id.Cat(*s++);
								}
								hh.Cat(GetEnv(id));
							}
						}
						else
							hh.Cat(*s++);
					}
					key.Add(k, hh);
				}
				else
					key.Add(k, h);
			}
		}
		else
		if(p.Char('@')) {
			if(p.Id("include")) {
				String fn = p.GetPtr();
				if(!IsFullPath(fn) && sfile)
					fn = AppendFileName(GetFileFolder(GetFullPath(sfile)), fn);
				LoadIniFile(fn, key);
			}
			else
			if(p.Id("end"))
				return;
			else
			if(p.Id("replace-env"))
				env = true;
			else
			if(p.Id("ignore-env"))
				env = false;
		}
	}
}
예제 #20
0
 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
 {

  if(intifinit)
  {
    return JNI_VERSION_1_6;
  }
  intifinit = 1;
  MSImageRef image_time;
  image_time = MSGetImageByName("/system/lib/libc.so");

  int (*gettimeofday_org)(struct timeval*tv, struct timezone *tz);
  gettimeofday_org = (int (*)(struct timeval*tv, struct timezone *tz)) MSFindSymbol(image_time, "gettimeofday");

  int (*clock_gettime_org)(clockid_t clk_id,struct timespec *tp);
  clock_gettime_org = (int (*)(clockid_t clk_id,struct timespec *tp)) MSFindSymbol(image_time, "clock_gettime");
  
 
  //MSHookFunction((void *)gettimeofday_org, (void*)gettimeofday_hook, (void**)&gettimeofday_f);
  //MSHookFunction((void *)clock_gettime_org, (void*)clock_gettime_hook, (void**)&clock_gettime_f);


 	MSImageRef image;
 	image = MSGetImageByName("/data/data/com.babeltime.fknsango_gwphone/lib/libgame.so");
  LOGD("image is %d" , image) ;
 	void *(*lua_loadbuffer_org_sym)(void *,  char *s, long len,void *s2,void *s5);
 	lua_loadbuffer_org_sym = (void * (*)(void *,  char *s, long len,void *s2,void *s5)) MSFindSymbol(image, "luaL_loadbufferx");
	//lua_gettop =(int (*) (void*)) MSFindSymbol(image, "lua_gettop") ;
 	lua_pcall= (int (*) (void *L, int nargs, int nresults, int errfunc))MSFindSymbol(image, "lua_pcall") ; 
  lua_gettop= (int (*) (void *L))MSFindSymbol(image, "lua_gettop") ; 
  lua_type= (int (*)(void *L,int i))MSFindSymbol(image, "lua_type") ; 
  lua_typename= (char* (* )(void *L, int a2))MSFindSymbol(image, "lua_typename") ; 
  lua_tolstring= (char* (*)(void *L, signed int a2, int a3))MSFindSymbol(image, "lua_tolstring") ; 
  _Z17getPackageNameJNIv = (  char* (* )(std::string &s  ))  MSFindSymbol(image, "_Z17getPackageNameJNIv");
  
  ; 
  _ZN7cocos2d18CCFileUtilsAndroid15getWritablePathEv = (std::string (*)(int a1)) MSFindSymbol(image,"_ZN7cocos2d18CCFileUtilsAndroid15getWritablePathEv") ;
  MSHookFunction((void *)_ZN7cocos2d18CCFileUtilsAndroid15getWritablePathEv, (void*)my_ZN7cocos2d18CCFileUtilsAndroid15getWritablePathEv, (void**)&_ZN7cocos2d18CCFileUtilsAndroid15getWritablePathEv);



	//lua_getfield = ( void (*) (void *L, int index, const char *k)) MSFindSymbol(image, "lua_getfield") ; 
	//MSHookFunction( (void *)lua_getfield,(void*)mylua_getfield,(void**)&lua_getfield);
	if(lua_loadbuffer_org_sym != NULL)
 	 {
 	 	//LOGD("lua_pushlstring_org_sym is %p!!!!!!!!!!!!\n",lua_loadbuffer_org_sym);
 	 	MSHookFunction((void *)lua_loadbuffer_org_sym, (void*)lua_loadbuffer_hook, (void**)&lua_loadbuffer_f);
 	 }
 	 else
 	 {
 	 //	LOGD("lua_pushlstring_org no find!!!!!!!!!!!!!!!!!!\n");
 	 }
   
 




 	//以下为hook java的,为了显示按钮
  JNIEnv *env = GetEnv(vm);
  MSImageRef dvm_image = MSGetImageByName("/system/lib/libc.so");
  void *gp = dlopen("/data/data/com.youzu.snsgz.linyou.youmi/lib/libsubstrate-dvm.so",RTLD_LAZY);
  cydia_dvm_image = MSGetImageByName("/data/data/sh.lilith.dgame.lemon/lib/libsubstrate-dvm.so");
  LOGD("dlopen %d , dvm %d" , gp , cydia_dvm_image) ; 

  jclass gameutil = env->FindClass("com/youzu/sanguohero/GameUtils");
  jmethodID getBRAND = env->GetStaticMethodID( gameutil, "getBRAND","()Ljava/lang/String;");
  jstring jstr =  (jstring)env->CallStaticObjectMethod( gameutil,getBRAND);
  const char* str;  
  str = env->GetStringUTFChars(jstr, false);  
  LOGD("getBRAND %s" , str) ; 
  if( strstr(str,"Meizu") != NULL) {
      return JNI_VERSION_1_6 ;
  }

  find_method = (void (*)(JNIEnv *, jclass , jmethodID , void *, void **)) MSFindSymbol(cydia_dvm_image, "MSJavaHookMethod");
  const char *target_class = "android/app/Instrumentation";//对大部分app来说,这是一个父类
  jvm_org = vm;
  jclass clazzTarget = env->FindClass(target_class);
   
  const char *fun_show = "init",*fun_hid = "hidden";
  javaClientClass_org = env->FindClass("com/youzu/sanguohero/TestWM");
   
  inject_method_show = env->GetStaticMethodID(javaClientClass_org, fun_show, "(Landroid/app/Activity;)V");
  
  inject_method_hidden = env->GetStaticMethodID(javaClientClass_org, fun_hid, "(Landroid/app/Activity;)V");
   
  //显示按钮
  jmethodID method_resume = env->GetMethodID(clazzTarget,
                 "callActivityOnResume",
                 "(Landroid/app/Activity;)V"
             );

  //隐藏按钮
  jmethodID method_pause = env->GetMethodID(clazzTarget,
                   "callActivityOnPause",
                   "(Landroid/app/Activity;)V"
               );


  find_method(env, clazzTarget, method_resume, reinterpret_cast<void *>(&newCodejava_show),reinterpret_cast<void **>(&oldCode_java_show));
  find_method(env, clazzTarget, method_pause, reinterpret_cast<void *>(&newCodejava_hidden),reinterpret_cast<void **>(&oldCode_java_hidden));

  DetachCurrent(vm);
   
  return JNI_VERSION_1_6;
 }
예제 #21
0
파일: mgquery.c 프로젝트: plbogen/CSDL
/* files.  Then calls  query ()  to perform the querying. */
int
main (int argc, char **argv)
{
  ProgTime StartTime;
  int decomp = 0;
  int ch;

  msg_prefix = argv[0];
  GetTime (&StartTime);

  /* Initialise the environment with default values */

  InitEnv ();

  read_mgrc_file ();

  OutFile = stdout;
  InFile = stdin;

  opterr = 0;
  while ((ch = getopt (argc, argv, "Df:d:h")) != -1)
    switch (ch)
      {
      case 'f':
	SetEnv ("mgname", optarg, NULL);
	break;
      case 'd':
	SetEnv ("mgdir", optarg, NULL);
	break;
      case 'D':
	decomp = 1;
	break;
      case 'h':
      case '?':
	fprintf (stderr, "usage: %s [-D] [-f base name of collection]"
		 "[-d data directory] [collection]\n", argv[0]);
	exit (1);
      }

  PushEnv ();

  if (decomp == 0)
    {

      Init_ReadLine ();

      /* write a first prompt, let the user start thinking */
      if (!BooleanEnv (GetEnv ("expert"), 0) && isatty (fileno (InFile)))
	{
	  fprintf (stderr, "\n\n\t     FULL TEXT RETRIEVAL QUERY PROGRAM\n");
	  fprintf (stderr, "%24s%s\n\n", "", *"30 Jul 1999" == '%' ? __DATE__ : "30 Jul 1999");
	  fprintf (stderr, "\n");
	  fprintf (stderr, "  mgquery version " VERSION ", Copyright (C) 1994 Neil Sharman\n");
	  fprintf (stderr, "  mgquery comes with ABSOLUTELY NO WARRANTY; for details type `.warranty'\n");
	  fprintf (stderr, "  This is free software, and you are welcome to redistribute it\n");
	  fprintf (stderr, "  under certain conditions; type `.conditions' for details.\n");
	  fprintf (stderr, "\n");
	}
    }
  if (optind < argc)
    search_for_collection (argv[optind]);

  if (decomp == 0)
    {
      query ();
    }
  else
    {
      int i;
      InitQueryTimes iqt;
      query_data *qd;

      qd = InitQuerySystem (GetDefEnv ("mgdir", "./"),
			    GetDefEnv ("mgname", ""),
			    &iqt);
      if (!qd)
	FatalError (1, mg_errorstrs[mg_errno], mg_error_data);


      start_up_stats (qd, iqt);

      Display_Stats (stderr);
      for (i = 0; i < qd->td->cth.num_of_docs; i++)
	{
	  RawDocOutput (qd, i + 1, stdout);
	  putc ('\2', stdout);
	}
      Message ("%s", ElapsedTime (&StartTime, NULL));

      FinishQuerySystem (qd);
    }

  UninitEnv ();
  exit (0);
}
예제 #22
0
static int stream_cache_open (stream_wrapper_t * wrapper,char *stream_name)
{
    int ret = 0;
    stream_ctrl_t *info = &wrapper->info;
    memset(info,0,sizeof(*info));

    //open real stream
    stream_wrapper_t *real_st = (stream_wrapper_t *)wrapper->stream_priv;
    ret = real_st->open(real_st,stream_name);
    if(ret != DTERROR_NONE)
    {
        ret = DTERROR_FAIL;
        goto ERR0;
    }
    memcpy(info,&real_st->info,sizeof(stream_ctrl_t));
    
    // ctx
    //get buf size
    char value[512];
    int cache_size = DEFAULT_CACHE_SIZE;
    if(GetEnv("STREAM","stream.cachesize",value) > 0)
    {
        cache_size = atoi(value);
        dt_info(TAG,"cache size:%d \n",cache_size);
    }
    else
        dt_info(TAG,"cache size not set, use default:%d \n",cache_size);
    
    cache_ctx_t *ctx = (cache_ctx_t *)malloc(sizeof(cache_ctx_t));
    if(!ctx)
    {
        dt_info(TAG,"cache_ctx_t malloc failed, ret\n");
        ret = DTERROR_FAIL;
        goto ERR1;
    }
    memset(ctx,0,sizeof(cache_ctx_t));
    ctx->wrapper = real_st;
    
    // get tmp buffer
    ctx->cache = create_cache(cache_size,f_pre);
    if(!ctx->cache)
    {
        ret = DTERROR_FAIL;
        goto ERR2;
    }
    wrapper->stream_priv = ctx;

    //start read thread
    ret = create_cache_thread(ctx);
    if (ret == -1)
    {
        dt_error (TAG "file:%s [%s:%d] data fill thread start failed \n", __FILE__, __FUNCTION__, __LINE__);
        goto ERR3;
    }
    return DTERROR_NONE;
ERR3:
    release_cache(ctx->cache);
ERR2:
    free(ctx);
ERR1:
    real_st->close(real_st);
ERR0:
    return ret;
}
예제 #23
0
파일: mgquery.c 프로젝트: plbogen/CSDL
static void 
MoreDocs (query_data * qd, char *Query, char OutputType)
{
  static char terms_str[MAXTERMSTRLEN + 1];
  int DocCount = 0;		/* number of actual matches */
  FILE *Output = NULL;
  int using_pipe = 0;
  char *pager = NULL;

  Ctrl_C = 0;

  qd->num_of_ans = qd->DL->num;

  signal (SIGPIPE, SIGPIPE_handler);
  signal (SIGINT, SIGINT_handler);

  PagerRunning = 1;
  if (isatty (fileno (OutFile)) && GetEnv ("pager") &&
      OutputType != OUTPUT_HILITE &&
      OutputType != OUTPUT_SILENT && OutputType != OUTPUT_COUNT)
    {
      pager = GetEnv ("pager");
    }
  else if (isatty (fileno (OutFile)) && OutputType == OUTPUT_HILITE)
    {
      /* concat the pager and its word argument strings */
      ConvertTermsToString (qd->TL, terms_str);
      pager = Xmalloc (MAX_HILITE_PAGER_STR + strlen (terms_str) + 1);
      if (!pager)
	{
	  fprintf (stderr, "Unable to allocate memory for highlighting\n");
	  return;
	}
      sprintf (pager, "%s --style=%s --pager=%s --stem_method=%ld %s",
	       HILITE_PAGER,
	       GetEnv ("hilite_style"),
	       GetEnv ("pager"),
	       qd->sd->sdh.stem_method,
	       terms_str);

    }
  else
    {
      Output = OutFile;
    }

  if (pager)
    {
      Output = popen (pager, "w");
      using_pipe = (Output != NULL);
      if (!using_pipe)
	{
	  fprintf (stderr, "Unable to run \"%s\"\n", pager);
	  return;
	}
    }


  if (qd->DL->num > 0)
    {
      if (OutputType == OUTPUT_COUNT && !post_proc)
	DocCount = qd->DL->num;
      else
	DocCount = ProcessDocs (qd, qd->DL->num,
				BooleanEnv (GetEnv ("verbatim"), 1),
				OutputType, Output);
    }

  if (PagerRunning)
    {
      output_terminator (Output);
      fflush (Output);
    }

  if (OutputType == OUTPUT_HILITE && pager)
    free (pager);		/* as needed to malloc to create the pager string */

  if (using_pipe)
    pclose (Output);

  if (qd->DL->num == 0)
    fprintf (stderr, "No entries correspond to that query.\n");
  else
    {
      if (OutputType == OUTPUT_COUNT)
	fprintf (stderr, "%d documents match.\n", DocCount);
      else
	fprintf (stderr, "%d documents retrieved.\n", DocCount);
    }

  signal (SIGINT, SIG_DFL);
}
예제 #24
0
char *curl_getenv(const char *v)
{
  return GetEnv(v);
}
예제 #25
0
AwtDesktopProperties::AwtDesktopProperties(jobject self) {
    this->self = GetEnv()->NewGlobalRef(self);
    GetEnv()->SetLongField( self, AwtDesktopProperties::pDataID,
                            ptr_to_jlong(this) );
}