Esempio n. 1
0
void CCommandParser::ParseParam(int argc, const std::string& paramFile, CParameterList* aParamList)
    {
	if (paramFile.size() > 0)
	    {
		std::ifstream params;
		params.open(paramFile.c_str(), std::ios::in);

		if (!params.good())
            {
			throw CCommandParser::ECmdLineMissingParamFile;
            }

		std::vector<std::string> tokens;
		argc = 0;
		while (params.good())
		    {
			std::string token;
			params >> token;
			if(token != "")
				{
				argc++;
				tokens.push_back(token);
				}
		    }

		const char** newArgv = new const char*[tokens.size()+1];
		for (int i = 0 ; i < tokens.size() ; ++i)
            {
			newArgv[i+1] = tokens[i].c_str();
            }

        ParseParam(argc+1, newArgv, aParamList);
		delete [] newArgv;
        params.close();
	    }
Esempio n. 2
0
	bool doRequest(FCGX_Request& request){
		map<string, string> mapParam;
		string query_string = FCGX_GetParam("QUERY_STRING", request.envp);
		ParseParam(mapParam, query_string);
		map<string, string>::iterator itU = mapParam.find("uid");
		if(itU == mapParam.end()){
			return false;
		}
		int userId;
		try{
			userId = boost::lexical_cast<int>((*itU).second);
		}catch(...){
			return false;
		}
		TipPtr tp;
		try{
			tp = QuestCacheAdapter::instance().showTip(userId);
			if(tp->id==-1)
				return false;
		}catch(...){
			return false;
		}
		string res = "Content-type: text/html\r\n\r\n" + tp->content;
		FCGX_FPrintF(request.out, res.c_str());
		FCGX_Finish_r(&request);
		return true;

	}	
Esempio n. 3
0
/* Given the argument list, parse it into ArgList format. */
ArgList ParseArgList(VyObj list){
    int num = CountParams(list);
    Param* params = VyMalloc(sizeof(Param) * num);
    int i;

    /* Each element of the list is either a parameter or an argument mode setting symbol...
     * Check if it sets the argument type (?, ~, or ..), and if it doesn't, parse it as a parameter 
     */
    VyObj opt_arg_set = CreateSymbol("?");
    VyObj rest_arg_set = CreateSymbol("..");

    bool opt, rest;
    opt = rest = false;

    int param_num = 0;
    int arg_list_len = ListLen(list);
    for(i = 0; i < arg_list_len; i++){
        VyObj next = ListGet(UNWRAP(list, VyCons), i);

        if(ObjEq(next, opt_arg_set)){
            opt = true;
        }
        else if(ObjEq(next, rest_arg_set)){
            opt = rest = true;
        }
        else {
            params[param_num] = ParseParam(next, opt, rest);
            param_num++;
        }

    }

    ArgList args = {num_params: num, params: params};
    return args;
}
Esempio n. 4
0
void NewGame(void)
{
    do {
        ParseParam(ReadLevel());
        Game();
    } while (_level_resolved);
}
Esempio n. 5
0
//
// Open this viewport's window.
//
void UXViewport::OpenWindow( DWORD InParentWindow, UBOOL IsTemporary, INT NewX, INT NewY, INT OpenX, INT OpenY )
{
	guard(UXViewport::OpenWindow);
	check(Actor);
	check(!HoldCount);
	UXClient* C = GetOuterUXClient();

	if (!XWindow)
		return;

	debugf( TEXT("Opening X viewport.") );

	// Create or update the window.
	SizeX = C->FullscreenViewportX;
	SizeY = C->FullscreenViewportY;
	if (!Mapped)
	{
		XMoveResizeWindow( XDisplay, XWindow, 0, 0, SizeX, SizeY );
		XMapWindow( XDisplay, XWindow );
	}

	// Create rendering device.
	if( !RenDev && !GIsEditor && !ParseParam(appCmdLine(),TEXT("nohard")) )
		TryRenderDevice( TEXT("ini:Engine.Engine.GameRenderDevice"), NewX, NewY, ColorBytes, C->StartupFullscreen );
	check(RenDev);
	UpdateWindowFrame();
	Repaint( 1 );

	unguard;
}
Esempio n. 6
0
char* CNWNXHashSet::GetNthKey(char* gameObject, char* Parameters)
{
   string name;
   int value;
   if (!ParseParam(gameObject, Parameters, name, value))
      return NULL;

   // does hashset exist
   if (HashSets.find(name) == HashSets.end()) {
      iLastOperation = false;
      return "";
   }

   HashSet *pSet = &(HashSets[name]);
   if (value >= pSet->hashset.size())
      return "";

   int i = 0;
   StringMap::iterator iSM = pSet->hashset.begin();

   while (i<value && iSM!=pSet->hashset.end()) {
      ++i;
      ++iSM;
   }

   if (iSM != pSet->hashset.end()) {
      pSet->p = iSM;
      return (char*)(pSet->p->first.c_str());
   }

   return "";
}
/**
 * Hidden so that only the factory or derived class can create these
 *
 * @param InProviderName the name of this provider
 * @param InProviderCmdLine	Short name for this provider that may be specified on the app's command line
 */
FStatNotifyProvider::FStatNotifyProvider( const TCHAR* InProviderName, const TCHAR* InProviderCmdLine ) :
	ProviderName(InProviderName),
	bIsEnabled(FALSE),
	CurrentFrame((DWORD)-1)
{
	if (GConfig != NULL)
	{
		// Figure out if this provider is enabled or not
		GConfig->GetBool(TEXT("StatNotifyProviders"),ProviderName,bIsEnabled,
			GEngineIni);
	}
	// Check to see if the provider was listed on the commandline
	if( ParseParam( appCmdLine(), ProviderName ) ||
		( InProviderCmdLine != NULL && ParseParam( appCmdLine(), InProviderCmdLine ) ) )
	{
		bIsEnabled = TRUE;
	}
}
Esempio n. 8
0
void GoLevel(void)
/* pide un nivel y su c?digo de acceso y lo lanza si es v?lido */
{
    int n_password;

    _level = GetNumber("GO LEVEL\n\n\n\n\nLEVEL NUMBER: %s\n", 30);

    if (_level == 0) {
        _level = 1;
        return;
    }

    n_password = GetNumber("GO LEVEL\n\n\n\n\nACCESS CODE: %s\n", 999998);

    ParseParam(ReadLevel());

    if (n_password == 822994)
        GameEnd();
    else if (n_password != 170868 && _password != n_password) {
        _level = 1;

        strcpy(_text_mask, "GO LEVEL\n\n\n\n\nWRONG ACCESS CODE\n");

        for (;;) {
            DrawWaterVirtualScreen();
            DrawText();
            qdgdfv_dump_virtual_screen();

            qdgdfv_input_poll();

            if (_qdgdfv_key_escape || _qdgdfv_key_enter)
                break;
        }

        while (_qdgdfv_key_escape || _qdgdfv_key_enter)
            qdgdfv_input_poll();
    }
    else {
        do {
            Game();
            ParseParam(ReadLevel());
        } while (_level_resolved);
    }
}
Esempio n. 9
0
char* CNWNXHashSet::Delete(char* gameObject, char* Parameters)
{
    string name, key;
    if (!ParseParam(gameObject, Parameters, name, key))
        return NULL;

    HashSets[name].hashset.erase(key);

    return NULL;
}
Esempio n. 10
0
char* CNWNXHashSet::Insert(char* gameObject, char* Parameters)
{
    string name, key, value;
    if (!ParseParam(gameObject, Parameters, name, key, value))
        return NULL;

    HashSets[name].hashset[key] = value;

    return NULL;
}
/**
 * Tells the parent class to open the file and then writes the opening data to it
 */
UBOOL FStatNotifyProvider_CSV::Init(void)
{
	UBOOL bOk = FStatNotifyProvider_File::Init();
	if (bOk && ParseParam(appCmdLine(),TEXT("CSVStats")))
	{
		// CSV stat provider starts capturing immediately!
		bOk = CreateOutputFile();
	}
	return bOk;
}
Esempio n. 12
0
CParameterList* CCommandParser::ParseOptions(int argc, const char**argv)
    {
	CParameterList* paramList = new CParameterList();
	bool bAbort = ParseParam(argc, argv, paramList);
	if(bAbort)
		{
		delete paramList;
		paramList = NULL;
		}
	return paramList;
    }
Esempio n. 13
0
bool CNWNXHashSet::ParseParam(char *gameObj, char *Param, string &Name, int &Value)
{
    string aval;

    // iLastOp set by ParseParam, string value version
    if (ParseParam(gameObj, Param, Name, aval)) {
        Value = atoi(aval.c_str());
    }

    return iLastOperation;
}
Esempio n. 14
0
char* CNWNXHashSet::GetNthKey(char* gameObject, char* Parameters)
{
    string name;
    int value;
    if(!ParseParam(gameObject,Parameters, name,value))
        return NULL;

    Log(0,"Ack! GetNthKey called!\n");

    return "";
}
Esempio n. 15
0
char* CNWNXHashSet::Create(char* gameObject, char* Parameters)
{
    string name;
    int value;
    if (!ParseParam(gameObject, Parameters, name, value))
        return NULL;

    // alakazam!
    HashSets[name];

    return NULL;
}
Esempio n. 16
0
void Parser :: ParseArgList(){
    Token *token =scan.GetNext();
    while(!isEq(token, _SEPARATION, ")")){
        ParseParam();
        token = scan.Get();
        if(isEq(token, _OPERATION, ","))
            token =scan.GetNext();
        else
            errorIf(!isEq(token, _SEPARATION, ")"), "Closing bracket expected", token);
    }
    scan.Next();
}
Esempio n. 17
0
bool CHistogram::GetValueFromVo(string VO)
{
	if (!ParseTypeMode(VO)) return false;
	if (!ParseDataType(VO)) return false;
	if (!ParseAxis(VO)) return false;
	if (!ParseVar(VO)) return false;
	if (!ParseDefLine(VO)) return false;
	if (!ParseWeight(VO)) return false;
	if (!ParseOutput(VO)) return false;
	if (!ParseParam(VO)) return false;
	return true;
}
Esempio n. 18
0
File: PRead.c Progetto: aosm/X11
/* read an RX document stream and augment the given list of arguments */
int
RxReadParams(char *stream,
	     char **argn_ret[], char **argv_ret[], int *argc_ret)
{
    char **argv, **argn;
    int argc, n;
    NString param;
    char *name, *value;
    int status;

    status = 0;
    argc = n = 0;
    argn = argv = NULL;
    if (stream != NULL) {
	do {
	    stream = NextParam(stream, &param);
	    if (param.length != 0 && ParseParam(&param, &name, &value) == 0) {
		argc++;
		if (n == 0) {	/* alloc first block */
		    n = PARAMSINC;
		    argn = (char **)Malloc(sizeof(char *) * n);
		    if (!argn)
			return 1;
		    argv = (char **)Malloc(sizeof(char *) * n);
		    if (!argv) {
			Free(argn);
			return 1;
		    }
		}
		if (argc % PARAMSINC == 0) { /* we need to add a block */
		    n += PARAMSINC;
		    argn = (char **)
		      Realloc(argn, sizeof(char *) * argc, sizeof(char *) * n);
		    argv = (char **)
		      Realloc(argv, sizeof(char *) * argc, sizeof(char *) * n);
		    if (!argn || !argv) {
			argc--;
			status = 1;
			break;
		    }
		}
		argn[argc - 1] = name;
		argv[argc - 1] = value;
	    }
	} while (*stream);
    }
    *argn_ret = argn;
    *argv_ret = argv;
    *argc_ret = argc;

    return status;
}
Esempio n. 19
0
char* CNWNXHashSet::Valid(char* gameObject, char* Parameters)
{
    string name, key;
    if (!ParseParam(gameObject, Parameters, name, key))
        return "0";

    // does hashset exist
    if (HashSets.find(name) == HashSets.end()) {
        return "0";
    }

    return "1";
}
Esempio n. 20
0
char* CNWNXHashSet::Destroy(char* gameObject, char* Parameters)
{
    string name;
    if (!ParseParam(gameObject, Parameters, name))
        return NULL;

    if (HashSets.find(name) != HashSets.end()) {
        HashSets.erase(name);
    } else {
        iLastOperation = false;
    }

    return NULL;
}
Esempio n. 21
0
char* CNWNXHashSet::Lookup(char* gameObject, char* Parameters)
{
    string name, key;
    if (!ParseParam(gameObject, Parameters, name, key))
        return "";

    if (HashSets.find(name) == HashSets.end() ||
            HashSets[name].hashset.find(key) == HashSets[name].hashset.end()) {
        iLastOperation = false;
        return "";
    }

    return (char*)(HashSets[name].hashset[key].c_str());
}
Esempio n. 22
0
char* CNWNXHashSet::Exists(char* gameObject, char* Parameters)
{
    string name, key;
    if (!ParseParam(gameObject, Parameters, name, key))
        return "0";

    // does hashset and key exist
    if (HashSets.find(name) == HashSets.end() ||
            HashSets[name].hashset.find(key) == HashSets[name].hashset.end()) {
        return "0";
    }

    return "1";
}
/**
 * Tells the parent class to open the file and then writes the opening
 * XML data to it
 */
UBOOL FStatNotifyProvider_XML::Init(void)
{
	UBOOL bOk = FStatNotifyProvider_File::Init();
	if (bOk && ParseParam(appCmdLine(),TEXT("XMLStats")))
	{
		// XML stat provider starts capturing immediately!
		bOk = CreateOutputFile();
		if( bOk	)
		{
			// Create the opening element
			WriteString("<StatFile SecondsPerCycle=\"%e\">\r\n",GSecondsPerCycle);
		}
	}
	return bOk;
}
Esempio n. 24
0
DualErr 
CPGPdiskCmdLine::ParseCommandLine()
{
	DualErr 	derr;
	LPCTSTR 	param;
	PGPBoolean	isFlag;
	PGPBoolean	commandReady	= FALSE;
	PGPBoolean	stopParsing 	= FALSE;

	// Iterate through all the arguments and construct the ACI packet.
	for (PGPInt32 i=1; i < __argc; i++)
	{
		param = __targv[i];

		isFlag = FALSE;

		if (param[0] == '-' || param[0] == '/')
		{
			isFlag = TRUE;
			++param;			// remove flag specifier
		}

		// Parse the parameter. Stop if we are told to.
		derr = ParseParam(param, isFlag, &stopParsing, &commandReady);

		// Process the ACI only if refCommandReady is TRUE.
		if (derr.IsntError())
		{
			if (commandReady)
			{
				App->DispatchAppCommandInfo(&ACI);

				ClearData();
				commandReady = FALSE;
			}

			if (stopParsing)
				break;
		}

		if (derr.IsError())
		{
			break;
		}
	}

	return derr;
}
Esempio n. 25
0
int ScriptEngine::ParseInputParam(STEP_LIST::iterator iter)
{
    USES_CONVERSION;

    PARM_LIST::iterator paramiter = (*iter)->paramList.begin();
    for (; paramiter != (*iter)->paramList.end(); ++paramiter)
    {
        PARAM *param = (*paramiter);

        ParseParam(param);

        param->updateData();
    }

    return 0;
}
/**
 * Creates the file that is going to be written to
 */
UBOOL FStatNotifyProvider_BinaryFile::Init(void)
{
	if( !FStatNotifyProvider_File::Init() )
	{
		return FALSE;
	}

	// NOTE: Binary stats capture doesn't start capturing until the user enters "Stat StartFile"

	if( ParseParam( appCmdLine(), TEXT( "StartStatsFile" ) ) )
	{
		// Start capturing right away!
		StartWritingStatsFile();
	}

	return TRUE;
}
Esempio n. 27
0
int HttpRequestPacket::decode_get( string& sHttpHead )
{

		//LOG4CPLUS_DEBUG(logger, "http head: " << sHttpHead);
	//get first line, GET /xx?xxx
	string::size_type requestPos = sHttpHead.find("\r\n");
	if ( requestPos == string::npos )
	{   // unfinished recv data, need more
		MYLOG_ERROR( "error http request : %s" , sHttpHead.c_str());
		return -1;
	}
    
	//ready to parse param
	string sRequestLine = sHttpHead.substr(0, requestPos);
	string::size_type pos1 = sRequestLine.find("/");
	if ( pos1 == string::npos )
	{
			MYLOG_DEBUG(  "can't find /");
			return -1;
	}
	string::size_type pos2 = sRequestLine.find(" ", pos1);//find space
	if ( pos2 == string::npos )
	{
			MYLOG_DEBUG(  "can't find space");
			return -1;
	}
	m_str_GetRequest = sRequestLine.substr(pos1, pos2-pos1);
	ParseParam(m_str_GetRequest);
	//LOG4CPLUS_DEBUG(logger, "m_str_GetRequest: " << m_str_GetRequest);
	
	ParseHead(sHttpHead);

	/*std::map<std::string, std::string>::iterator iter;
	for (iter = mapHead.begin(); iter!= mapHead.end(); iter++)
	{
		LOG4CPLUS_DEBUG(logger, "key="<<iter->first<<"  value="<<iter->second);
	}*/

	
	//ready to parse cookie	
	string sCookie = GetLine("COOKIE", sHttpHead);
	ParseCookie(sCookie);

	return 0;
}
Esempio n. 28
0
char* CNWNXHashSet::GetSize(char* gameObject, char* Parameters)
{
    string name;
    static char sizebuf[16];

    if (!ParseParam(gameObject, Parameters, name))
        return "0";

    // does hashset exist
    if (HashSets.find(name) == HashSets.end()) {
        iLastOperation = false;
        return "0";
    }

    sprintf(sizebuf, "%d", HashSets[name].hashset.size());

    return sizebuf;
}
Esempio n. 29
0
char* CNWNXHashSet::GetCurrentKey(char* gameObject, char* Parameters)
{
    string name;
    if (!ParseParam(gameObject, Parameters, name))
        return "";

    // does hashset exist
    if (HashSets.find(name) == HashSets.end()) {
        iLastOperation = false;
        return "";
    }

    HashSet *pSet = &(HashSets[name]);
    if (pSet->p == pSet->hashset.end())
        return "";

    return (char*)(pSet->p->first.c_str());
}
Esempio n. 30
0
/**
 * Static function creating appropriate database connection object.
 *
 * @return	instance of platform specific database connection object
 */
FDataBaseConnection* FDataBaseConnection::CreateObject()
{
	if( ParseParam( appCmdLine(), TEXT("NODATABASE") ) )
	{
		return NULL;
	}
#if USE_ADO_INTEGRATION
	if( !GIsCOMInitialized )
	{
		// Initialize COM. We only want to do this once and not override settings of previous calls.
		CoInitialize( NULL );
		GIsCOMInitialized = TRUE;
	}
	return new FADODataBaseConnection();
#elif USE_REMOTE_INTEGRATION
	return new FRemoteDatabaseConnection();
#else
	return new FDataBaseConnection();
#endif
}