Exemple #1
0
void CommandData::ParseCommandLine(int argc, char *argv[])
{
#ifdef CUSTOM_CMDLINE_PARSER
  // In Windows we may prefer to implement our own command line parser
  // to avoid replacing \" by " in standard parser. Such replacing corrupts
  // destination paths like "dest path\" in extraction commands.
  const wchar *CmdLine=GetCommandLine();

  wchar *ParW;
  char *ParA;
  for (bool FirstParam=true;;FirstParam=false)
  {
    if ((CmdLine=AllocCmdParam(CmdLine,&ParW,&ParA))==NULL)
      break;
    if (!FirstParam) // First parameter is the executable name.
      ParseArg(ParA,ParW);
    free(ParW);
    free(ParA);
  }
#else
  for (int I=1;I<argc;I++)
    ParseArg(argv[I],NULL);
#endif
  ParseDone();
}
void CWebinosUI::Initialise()
{
	m_confirmingExit = false;
	m_restartingPzh = m_restartingPzp = 0;

	// Register to receive session-change notifications.
	WTSRegisterSessionNotification(m_hWnd, NOTIFY_FOR_THIS_SESSION);

	// Set user info for this session (this will initialise m_user_params).
	SetSession();

	// Initialise the node services we are interested in.
	m_pzh_params.serviceName = WEBINOS_PZH;
	m_pzp_params.serviceName = WEBINOS_PZP;

	CServiceManager mgr;

	// Get PZH parameters.
	mgr.GetServiceParameters(m_user_params,m_pzh_params);

	// Get PZP parameters.
	mgr.GetServiceParameters(m_user_params,m_pzp_params);

	// Initialise dialog controls with configuration folders.
	SetDlgItemText(IDC_PATH_TO_NODE_EDIT,m_pzp_params.nodePath.c_str());
	SetDlgItemText(IDC_PATH_TO_WEBINOS_EDIT,m_pzp_params.workingDirectoryPath.c_str());

	// Parse node arguments to extract PZP specific params.
  std::vector<std::string> toks = webinos::split(m_pzp_params.nodeArgs.c_str(),' ');
  for (std::vector<std::string>::iterator it = toks.begin(); it != toks.end(); it++)
  {
    std::string tok = *it;
    if (tok.length() == 0)
      continue;

		std::string argVal;
		if (ParseArg(tok,_T("--auth-code=\""),argVal))
			SetDlgItemText(IDC_AUTH_CODE_EDIT,argVal.c_str());
		else if (ParseArg(tok,_T("--pzh-name=\""),argVal))
			SetDlgItemText(IDC_PZH_NAME_EDIT,argVal.c_str());
  }

	// Re-set PZH service parameters.
	m_pzh_params.instance = 0;
	mgr.SetServiceParameters(m_user_params,m_pzh_params);

	// Re-set PZP service parameters.
	m_pzp_params.instance = 0;
	mgr.SetServiceParameters(m_user_params,m_pzp_params);

	// Start timer to poll for status
	SetTimer(ID_POLL_TIMER,SERVICE_POLL_INTERVAL,NULL);
}
Exemple #3
0
void qCtx::ParseArgs(qStr *in, qArgAry *out)
{
    bool quot = false;
    bool more = true;
    qStrBuf cur;
//	bool trim = true;
    char c;

    do {
        while ( isspace((c = in->GetC())) );

        if (c == T_SQ) {
            quot = true;
            c = in->GetC();
            more = ParseArgQuoted(in, cur, c);
        } else {
            quot = false;
            more = ParseArg(in, cur, c);
        }

        out->Add(cur);
        cur.Grow(0);
        out->SetQuot(out->Count()-1,quot);
    } while (more && c != EOF);
}
Exemple #4
0
HRESULT AutoTest(PMP_ADAPTER Adapter, int argc, char *argv[])
{
    ARG_STRING  timesArg   = {{"t", "times", "Specify Loop times", STR}, NULL, 0};
    void *ArgTable[] = {&timesArg};
    
    ULONG nLoopCount = 0;
    ULONG TestType = 0;
    HRESULT hr = E_CMD_SYNTAX;

    if (argc >= 1)
    {
        ParseHex(argv[0], &TestType);
        if (argc >= 3)
        {
            int ret = ParseArg(argc - 1, &argv[1], ArgTable, sizeof(ArgTable)/sizeof(PVOID));
            if (timesArg.Count == 1)
            {
                ParseHex(timesArg.szStrValue, &nLoopCount);
            }
        }
    }

    switch (TestType)
    {
    case 0:
        break;
    }

    return hr;
}
Exemple #5
0
void qCtx::ParseArgsQmap(qStr *in, qArgAry *out, const char *qmap)
{
    bool quot = false;
    bool more = true;
//	bool trim = true;
//	char quoted = '\x0';
//	int qcnt = 0;
    char c;
//	int acnt = 0;

    if (!qmap) {
        ParseArgs(in, out);
        return;
    }

    char qmode = *qmap == 'A' ? '1' : *qmap == '1' ? '1' : '0';

    if (*qmap != 'A' )
        ++qmap;

    do {
        qStrBuf cur;
        while ( isspace((c = in->GetC())) );

        if (c == T_SQ) {
            quot = true;
            c = in->GetC();
        } else {
            quot = false;
        }

        if (qmode == '1' || quot) {
            more = ParseArgQuoted(in, cur, c);
        } else {
            more = ParseArg(in, cur, c);
        }

        out->Add(cur);
        out->SetQuot(out->Count()-1,quot);

        if (*qmap) {
            if (*qmap == '1') {
                qmode = '1';
                ++qmap;
            } else if (*qmap == '0') {
                qmode = '0';
                ++qmap;
            }
        } else {
            qmode = '0';

        }
    } while (more && c != EOF);
}
Exemple #6
0
Type * ParseTypeInline() 
/*
Syntax: "+" full_type | "(" full_type ")" | normal_type |  identifier | int ".." exp | "-" int ".." exp
*/{
	Type * type = NULL;
	Var * var;
	UInt16 bookmark;
	BigInt * bi;

	PARSE_INLINE = true;

	if (TOK == TOKEN_OPEN_P || TOK == TOKEN_PLUS) {
		type = ParseType2(INSTR_TYPE);
	} else {
		type = ParseType3();
		if (!TOK) return NULL;
		if (type != NULL) return type;

		if (ParseArg(&var)) {
			type = TypeAllocVar(var);
		} else if (TOK == TOKEN_ID) {
			bookmark = SetBookmark();
			var = ParseVariable();
			if (TOK) {
				if (var->mode == INSTR_TYPE) {
					type = var->type;
				} else if (var->mode == INSTR_VAR && var->type->variant == TYPE_TYPE) {
					type = var->type_value;
				} else {
					ErrArg(var);
					SyntaxErrorBmk("Variable [A] does not define type.", bookmark);
				}
			}
		} else if (TOK == TOKEN_INT || TOK == TOKEN_MINUS) {
			type = TypeAlloc(TYPE_INT);
			bi = ParseIntConstExpression(NULL);
			if (TOK) {
				IntModify(&type->range.min, bi);
				if (NextIs(TOKEN_DOTDOT)) {
					bi = ParseIntConstExpression(NULL);
					if (TOK) {
						IntModify(&type->range.max, bi);
					}
				} else {
					IntModify(&type->range.max, &type->range.min);
				}
			}
		}
	}
	return type;
}
Exemple #7
0
void CommandData::ParseCommandLine(bool Preprocess,int argc, char *argv[])
{
  *Command=0;
  NoMoreSwitches=false;
#ifdef CUSTOM_CMDLINE_PARSER
  // In Windows we may prefer to implement our own command line parser
  // to avoid replacing \" by " in standard parser. Such replacing corrupts
  // destination paths like "dest path\" in extraction commands.
  // Also our own parser is Unicode compatible.
  const wchar *CmdLine=GetCommandLine();

  wchar *Par;
  for (bool FirstParam=true;;FirstParam=false)
  {
    if ((CmdLine=AllocCmdParam(CmdLine,&Par))==NULL)
      break;
    if (!FirstParam) // First parameter is the executable name.
      if (Preprocess)
        PreprocessArg(Par);
      else
        ParseArg(Par);
    free(Par);
  }
#else
  Array<wchar> Arg;
  for (int I=1;I<argc;I++)
  {
    Arg.Alloc(strlen(argv[I])+1);
    CharToWide(argv[I],&Arg[0],Arg.Size());
    if (Preprocess)
      PreprocessArg(&Arg[0]);
    else
      ParseArg(&Arg[0]);
  }
#endif
  if (!Preprocess)
    ParseDone();
}
Exemple #8
0
void Options::Parse( int argCount, char const * const * args )
{
    int ii = 1;
    while( ii < argCount )
    {
        char const* arg = args[ii++];
        
        if( arg[0] == '-' )
        {
            // possibly an option
            
            if( arg[1] == '-' )
            {
                // possibly a long option
                if( arg[2] == 0 )
                {
                    // Option was "--", usually refers to stdin
                    fprintf(stderr, "Unexpected option %s\n", arg);
                }
                else
                {
                    // Look up the appropriate option
                    ParseLongOptionFlag( arg + 2, &ii, argCount, args );
                }
            }
            else
            {
                // seems to be a short option
                ParseShortOptionFlag( arg + 1, &ii, argCount, args );
            }
        }
        else
        {
            // appears to be a non-option argument
            ParseArg( arg );
        }
    }
    
    if( inputFileName.length() == 0 )
    {
        fprintf(stderr, "No input file specified\n");
    }
}
Exemple #9
0
void CAppParamParser::Parse(const char* argv[], int nArgs)
{
  if (nArgs > 1)
  {
    for (int i = 1; i < nArgs; i++)
    {
      ParseArg(argv[i]);
#ifdef HAS_LIRC
      if (strnicmp(argv[i], "-l", 2) == 0 || strnicmp(argv[i], "--lircdev", 9) == 0)
      {
        // check the next arg with the proper value.
        int next=i+1;
        if (next < nArgs)
        {
          if ((argv[next][0] != '-' ) && (argv[next][0] == '/' ))
          {
            g_RemoteControl.setDeviceName(argv[next]);
            i++;
          }
        }
      }
      else if (strnicmp(argv[i], "-n", 2) == 0 || strnicmp(argv[i], "--nolirc", 8) == 0)
         g_RemoteControl.setUsed(false);
#endif
      if (stricmp(argv[i], "-d") == 0)
      {
        if (i + 1 < nArgs)
        {
          int sleeptime = atoi(argv[i + 1]);
          if (sleeptime > 0 && sleeptime < 360)
            Sleep(sleeptime*1000);
        }
        i++;
      }
    }
  }
  PlayPlaylist();
}
Exemple #10
0
EFI_STATUS
ExecDriver (
  IN OUT EFI_NETWORK_TEST_FILE    *TestFile,
  IN CHAR16                       *TestNodeName
  )
/*++

Routine Description:

  Execute a driver.

Arguments:

  TestFile      - Pointer to the EFI_EFI_NETWORK_TEST_FILE structure.
  TestNodeName  - Test node name string.

Returns:

  EFI_SUCCESS          - Operation succeeded.
  EFI_OUT_OF_RESOURCES - Memory allocation failed.
  Others               - Some failure happened.

--*/
{
  EFI_ENTS_PROTOCOL *EntsProtocol;
  ENTS_INTERFACE    *EntsInterface;
  EFI_STATUS        Status;
  EFI_STATUS        TestStatus;
  RIVL_VARIABLE     *DelayTimeVariable;
  UINT64            StartTick;
  UINT64            StopTick;

  //
  // Find the EntsProtocol instance by name
  // and install the client instance by index
  //
  Status  = LocateEntsProtocol (TestFile->CmdName, &EntsProtocol);
  if (EFI_ERROR (Status)) {
    EFI_ENTS_DEBUG ((EFI_ENTS_D_ERROR, L"Error in LocateEntsProtocol: Status - %r\n", Status));
    return Status;
  }
  //
  // Find the EntsInterface by name
  //
  Status = LocateEntsInterface (EntsProtocol, TestNodeName, &EntsInterface);
  if (EFI_ERROR (Status)) {
    EFI_ENTS_DEBUG ((EFI_ENTS_D_ERROR, L"Error in LocateEntsInterface: Status - %r\n", Status));
    return Status;
  }
  //
  // Parse the argument list
  //
  Status = ParseArg (EntsInterface->ArgFieldList);
  if (EFI_ERROR (Status)) {
    EFI_ENTS_DEBUG ((EFI_ENTS_D_ERROR, L"Error in ParseArg: Status - %r\n", Status));
    return Status;
  }
  //
  // Find variable (DelayTime)
  //
  DelayTimeVariable = SearchRivlVariable (DELAY_TIME_NAME);
  if (DelayTimeVariable != NULL) {
    BS->Stall (*(UINTN *) DelayTimeVariable->Address);
  }
  //
  // Call the entry point
  //
#ifdef EFIARM
      StartTick = 0;
#else 
      StartTick = EfiReadTsc ();
#endif
  TestStatus  = EntsInterface->EntsInterfaceEntry (EntsProtocol->ClientInterface);
#ifdef EFIARM
      StopTick = 0;
#else 
      StopTick = EfiReadTsc ();
#endif
  RecordExecTime (StartTick, StopTick);

  if (EntsProtocol->RuntimeInfo != NULL) {
    (gEasFT->Cmd)->ComdRuntimeInfo = EntsStrDuplicate (EntsProtocol->RuntimeInfo);
    if ((gEasFT->Cmd)->ComdRuntimeInfo == NULL) {
      return EFI_OUT_OF_RESOURCES;
    }
    (gEasFT->Cmd)->ComdRuntimeInfoSize = (StrLen (EntsProtocol->RuntimeInfo) + 1) * 2;
    BS->FreePool (EntsProtocol->RuntimeInfo);
	EntsProtocol->RuntimeInfo = NULL;
	EntsProtocol->RuntimeInfoSize = 0;
  }

  return EFI_SUCCESS;
}
int
SDLVisualTest_ParseHarnessArgs(char** argv, SDLVisualTest_HarnessState* state)
{
    int i;

    SDLTest_Log("Parsing commandline arguments..");

    if(!argv)
    {
        SDLTest_LogError("argv is NULL");
        return 0;
    }
    if(!state)
    {
        SDLTest_LogError("state is NULL");
        return 0;
    }

    /* initialize the state object */
    state->sutargs[0] = '\0';
    state->sutapp[0] = '\0';
    state->output_dir[0] = '\0';
    state->verify_dir[0] = '\0';
    state->timeout = DEFAULT_SUT_TIMEOUT;
    SDL_memset(&state->sut_config, 0, sizeof(SDLVisualTest_SUTConfig));
    SDL_memset(&state->action_queue, 0, sizeof(SDLVisualTest_ActionQueue));
    state->variator_type = SDL_VARIATOR_RANDOM;
    state->num_variations = -1;
    state->no_launch = SDL_FALSE;

    /* parse config file if passed */
    for(i = 0; argv[i]; i++)
    {
        if(StrCaseCmpIgnoreHyphen("config", argv[i]) == 0)
        {
            if(!argv[i + 1])
            {
                SDLTest_Log("Arguments parsing error: invalid argument for config.");
                return 0;
            }
            if(!ParseConfig(argv[i + 1], state))
            {
                SDLTest_LogError("ParseConfig() failed");
                return 0;
            }
        }
    }

    /* parse the arguments */
    for(i = 0; argv[i];)
    {
        int consumed = ParseArg(argv, i, state);
        if(consumed == -1 || consumed == 0)
        {
            SDLTest_LogError("ParseArg() failed");
            return 0;
        }
        i += consumed;
    }

    if(state->variator_type == SDL_VARIATOR_RANDOM && state->num_variations == -1)
        state->num_variations = 1;

    /* check to see if required options have been passed */
    if(!state->sutapp[0])
    {
        SDLTest_LogError("sutapp must be passed.");
        return 0;
    }
    if(!state->sutargs[0] && !state->sut_config.options)
    {
        SDLTest_LogError("Either sutargs or parameter-config must be passed.");
        return 0;
    }
    if(!state->output_dir[0])
    {
        SDL_strlcpy(state->output_dir, "./output", MAX_PATH_LEN);
    }
    if(!state->verify_dir[0])
    {
        SDL_strlcpy(state->verify_dir, "./verify", MAX_PATH_LEN);
    }

    return 1;
}
/* TODO: Trailing/leading spaces and spaces between equals sign not supported. */
static int
ParseConfig(char* file, SDLVisualTest_HarnessState* state)
{
    SDL_RWops* rw;
    SDLVisualTest_RWHelperBuffer buffer;
    char line[MAX_CONFIG_LINE_LEN];

    rw = SDL_RWFromFile(file, "r");
    if(!rw)
    {
        SDLTest_LogError("SDL_RWFromFile() failed");
        return 0;
    }

    SDLVisualTest_RWHelperResetBuffer(&buffer);
    while(SDLVisualTest_RWHelperReadLine(rw, line, MAX_CONFIG_LINE_LEN,
                                         &buffer, '#'))
    {
        char** argv;
        int i, num_params;

        /* count number of parameters and replace the trailing newline with 0 */
        num_params = 1;
        for(i = 0; line[i]; i++)
        {
            if(line[i] == '=')
            {
                num_params = 2;
                break;
            }
        }

        /* populate argv */
        argv = (char**)SDL_malloc((num_params + 1) * sizeof(char*));
        if(!argv)
        {
            SDLTest_LogError("malloc() failed.");
            SDL_RWclose(rw);
            return 0;
        }

        argv[num_params] = NULL;
        for(i = 0; i < num_params; i++)
        {
            argv[i] = strtok(i == 0 ? line : NULL, "=");
        }

        if(ParseArg(argv, 0, state) == -1)
        {
            SDLTest_LogError("ParseArg() failed");
            SDL_free(argv);
            SDL_RWclose(rw);
            return 0;
        }
        SDL_free(argv);
    }
    SDL_RWclose(rw);

    if(!state->sutapp[0])
        return 0;
    return 1;
}
status_t ParseArgs(int argc, char ** argv, Queue<String> & addTo, bool cs)
{
   for (int i=0; i<argc; i++) if (ParseArg(argv[i], addTo, cs) != B_NO_ERROR) return B_ERROR;
   return B_NO_ERROR;
}
Exemple #14
0
int _tmain(int argc, _TCHAR* argv[])
{
	bool		result = false;
	TArgInfo	info;

	ParseArg(info,argc,argv);
	const std::string &m = info.m_mode;

	//printf("mode=%s\n", m.c_str());

	if("f32_hex" == m){
		result = Float32ToHex(info);
	}else if("f64_hex" == m){
		result = Float64ToHex(info);
	}else if("hex_f32" == m){
		result = HexToFloat32(info);
	}else if("hex_f64" == m){
		result = HexToFloat64(info);
	}else if("2_10" == m){
		result = ConvertNumber(info,10,2);
	}else if("2_16" == m){
		result = ConvertNumber(info,16,2);
	}else if("10_2" == m){
		result = ConvertNumber(info,2,10);
	}else if("10_16" == m){
		result = ConvertNumber(info,16,10);
	}else if("16_2" == m){
		result = ConvertNumber(info,2,16);
	}else if("16_10" == m){
		result = ConvertNumber(info,10,16);
	}else if("r_d" == m){
		result = RadianToDegree(info);
	}else if("d_r" == m){
		result = DegreeToRadian(info);
	}else if("v_h" == m){
		result = MatrixSub(info,FovVerticalToHorizontal,3);
	}else if("h_v" == m){
		result = MatrixSub(info,FovHorizontalToVertical,3);
	}else if("ql" == m){
		result = MatrixSub(info,QuatLength,4);
	}else if("qn" == m){
		result = MatrixSub(info,QuatNormalize,4);
	}else if("qi" == m){
		result = MatrixSub(info,QuatInverse,4);
	}else if("q_m33" == m){
		result = MatrixSub(info,QuatToMat,4);
	}else if("q_a" == m){
		result = MatrixSub(info,QuatToAAng,4);
	}else if("q_xyz" == m){
		result = MatrixSub(info,QuatToXYZ,4);
	}else if("m33_q" == m){
		result = MatrixSub(info,Mat33ToQuat,9);
	}else if("m33_a" == m){
		result = MatrixSub(info,Mat33ToAAng,9);
	}else if("m33t" == m){
		result = MatrixSub(info,Mat33Transpose,9);
	}else if("m33d" == m){
		result = MatrixSub(info,Mat33Determinant,9);
	}else if("m33i" == m){
		result = MatrixSub(info,Mat33Invert,9);
	}else if("m33_s" == m){
		result = MatrixSub(info,Mat33Scale,9);
	}else if("x_m33" == m){
		result = MatrixSub(info,Mat33RotX,1);
	}else if("y_m33" == m){
		result = MatrixSub(info,Mat33RotY,1);
	}else if("z_m33" == m){
		result = MatrixSub(info,Mat33RotZ,1);
	}else if("yxz_m33" == m){
		result = MatrixSub(info,Mat33RotYXZ,3);
	}else if("zxy_m33" == m){
		result = MatrixSub(info,Mat33RotZXY,3);
	}else if("zyx_m33" == m){
		result = MatrixSub(info,Mat33RotZYX,3);
	}else if("yzx_m33" == m){
		result = MatrixSub(info,Mat33RotYZX,3);
	}else if("xzy_m33" == m){
		result = MatrixSub(info,Mat33RotXZY,3);
	}else if("xyz_m33" == m){
		result = MatrixSub(info,Mat33RotXYZ,3);
	}else if("m33_yxz" == m){
		result = MatrixSub(info,Mat33EulerYXZ,9);
	}else if("m33_zxy" == m){
		result = MatrixSub(info,Mat33EulerZXY,9);
	}else if("m33_zyx" == m){
		result = MatrixSub(info,Mat33EulerZYX,9);
	}else if("m33_yzx" == m){
		result = MatrixSub(info,Mat33EulerYZX,9);
	}else if("m33_xzy" == m){
		result = MatrixSub(info,Mat33EulerXZY,9);
	}else if("m33_xyz" == m){
		result = MatrixSub(info,Mat33EulerXYZ,9);
	}else if("v3l" == m){
		result = MatrixSub(info,Vector3Length,3);
	}else if("v3n" == m){
		result = MatrixSub(info,Vector3Normalize,3);
	}

	if(result){
		return 0;
	}
	usage();

	return 1;
}
Exemple #15
0
int main(int argc, char * argv[])
{
	ParseArg(argc,argv);

	if (gDaemonFlag)
	{
		CUtil::DaemonInit();
	}
	
	sSessCtrl;
	sLog->Initialize();

	//if (!CUtil::SetRLimit())
	//	return 0;

	if (!g_serverIni.OpenFile("server.ini"))
	{
		IME_ERROR("Cannot open server.ini");
		return 0;
	}

	if (!InitServer())
	{
		IME_ERROR("InitServer failed");
		return 0;
	}

//	//do many init db here
//	if (!StartDB())
//	{
//		IME_ERROR("StartDB failed");
//		return 0;
//	}

	IME_LOG("GameServer Start!");
	
	//todo 
	//hooksignal
	HookSignals();

	///- Launch CNetRunnable thread
	CNetRunnable * pNetRunnable = new CNetRunnable;
	ZThread::Thread netThread(pNetRunnable);
	netThread.setPriority((ZThread::Priority)1);

	ZThread::Thread *pRelayClientThread = NULL;
	if (CSet::ClientSessionRun)
	{
		///- Launch CRelayClientRunnable thread
		CRelayClientRunnable * pRelayClientRunnable = new CRelayClientRunnable;
//		ZThread::Thread relayClientThread(pRelayClientRunnable);
//		relayClientThread.setPriority((ZThread::Priority)1);
		pRelayClientThread = new ZThread::Thread(pRelayClientRunnable);
		pRelayClientThread->setPriority((ZThread::Priority)1);
	}

	///- Launch CWorldRunnable thread
	ZThread::Thread worldThread(new CWorldRunnable);
	worldThread.setPriority((ZThread::Priority)1);

	worldThread.wait();
	netThread.wait();
	//relayClientThread.wait();
	if (pRelayClientThread != NULL)
		pRelayClientThread->wait();

	//unhooksignal	
	UnHookSignals();
	EndServer();
	IME_LOG("GameServer End!");

	return 0;
}