コード例 #1
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamRoundTimer::InputAddTeamTime( inputdata_t &input )
{
	char		token[128];
	const char	*p = STRING( input.value.StringID() );
	int			nTeam = TEAM_UNASSIGNED;
	int			nSeconds = 0;

	// get the team
	p = nexttoken( token, p, ' ' );
	if ( token[0] != '\0' )
	{
		nTeam = Q_atoi( token );
	}

	// get the time
	p = nexttoken( token, p, ' ' );
	if ( token[0] != '\0' )
	{
		nSeconds = Q_atoi( token );
	}

	if ( nSeconds != 0 )
	{
		AddTimerSeconds( nSeconds, nTeam );
	}
}
コード例 #2
0
bool CASW_Mission_Chooser_Source_Local::SavePassesFilter(ASW_Mission_Chooser_Saved_Campaign* pSaved, const char *szFilterID)
{
	if (!pSaved)
		return false;

	if (!szFilterID || Q_strlen(szFilterID) < 1)
		return true;

	// check our filterID is present in the playerids with this save
	const char	*p = pSaved->m_szPlayerIDs;
	char		token[128];
	
	p = nexttoken( token, p, ' ' );

	while ( Q_strlen( token ) > 0 )  
	{
		// found a match
		if (!Q_stricmp(szFilterID, token))
			return true;
		if (p)
			p = nexttoken( token, p, ' ' );
		else
			token[0] = '\0';
	}
	

	return false;
}
コード例 #3
0
// the player has been awarded medal(s), save it into our store
bool C_ASW_Medal_Store::OnAwardedPlayerMedals(int iPlayerIndex, const char *pszPlayerMedals, bool bMultiplayer)
{
	if (!m_bLoaded)
	{
		LoadMedalStore();
	}

	if (iPlayerIndex < 0 || iPlayerIndex >= ASW_MAX_READY_PLAYERS)
		return false;

	// NOTE: should only save if the playerindex matches the local player, but we can't check that here?
	//  we'll assume our caller has checked this
	
	// break up the medal string into medal numbers
	const char	*p = pszPlayerMedals;
	char		token[128];
	bool bAddedMedal = false;
	
	p = nexttoken( token, p, ' ' );	
	while ( Q_strlen( token ) > 0 )  
	{
		int iMedalIndex = atoi(token);
		bAddedMedal |= AddPlayerMedal(iMedalIndex, bMultiplayer);
		if (p)
			p = nexttoken( token, p, ' ' );
		else
			token[0] = '\0';		
	}

	if (bAddedMedal)
		SaveMedalStore();

	return bAddedMedal;
}
コード例 #4
0
// a marine has just been awarded some medals - add to the client store
//    HUMMM - what if the level is cancelled and retried?
// in single mission, this doesn't count, so medals should be awarded there fine.
// in campaign - only matters for outstanding execution and speed run really - but let's only award those if all marines make it there alive
bool C_ASW_Medal_Store::OnAwardedMedals(const char *pszMedalsAwarded, int iProfileIndex, bool bMultiplayer)
{
	if (!m_bLoaded)
	{
		LoadMedalStore();
	}
	
	// break up the medal string into medal numbers
	const char	*p = pszMedalsAwarded;
	char		token[128];
	bool bAddedMedal = false;
	
	p = nexttoken( token, p, ' ' );	
	while ( Q_strlen( token ) > 0 )  
	{
		int iMedalIndex = atoi(token);
		bAddedMedal |= AddMarineMedal(iProfileIndex, iMedalIndex, bMultiplayer);
		if (p)
			p = nexttoken( token, p, ' ' );
		else
			token[0] = '\0';
	}

	if (bAddedMedal)
		SaveMedalStore();

	return bAddedMedal;
}
コード例 #5
0
ファイル: Cpp.c プロジェクト: cage433/global_with_scala
/*
 * condition_macro: 
 *
 *	i)	cc	token
 *	i)	target	current target
 */
static void
condition_macro(int cc, int target)
{
	cur = &pifstack[piflevel];
	if (cc == SHARP_IFDEF || cc == SHARP_IFNDEF || cc == SHARP_IF) {
		DBG_PRINT(piflevel, "#if");
		if (++piflevel >= MAXPIFSTACK)
			die("#if pifstack over flow. [%s]", curfile);
		++cur;
		cur->start = level;
		cur->end = -1;
		cur->if0only = 0;
		if (peekc(0) == '0')
			cur->if0only = 1;
		else if ((cc = nexttoken(NULL, cpp_reserved_word)) == SYMBOL && !strcmp(token, "notdef"))
			cur->if0only = 1;
		else
			pushbacktoken();
	} else if (cc == SHARP_ELIF || cc == SHARP_ELSE) {
		DBG_PRINT(piflevel - 1, "#else");
		if (cur->end == -1)
			cur->end = level;
		else if (cur->end != level && wflag)
			warning("uneven level. [+%d %s]", lineno, curfile);
		level = cur->start;
		cur->if0only = 0;
	} else if (cc == SHARP_ENDIF) {
		int minus = 0;

		--piflevel;
		if (piflevel < 0) {
			minus = 1;
			piflevel = 0;
		}
		DBG_PRINT(piflevel, "#endif");
		if (minus) {
			if (wflag)
				warning("#if block unmatched. reseted. [+%d %s]", lineno, curfile);
		} else {
			if (cur->if0only)
				level = cur->start;
			else if (cur->end != -1) {
				if (cur->end != level && wflag)
					warning("uneven level. [+%d %s]", lineno, curfile);
				level = cur->end;
			}
		}
	}
	while ((cc = nexttoken(NULL, cpp_reserved_word)) != EOF && cc != '\n') {
                if (cc == SYMBOL && strcmp(token, "defined") != 0) {
			if (target == REF) {
				if (defined(token))
		                        PUT(token, lineno, sp);
			} else if (target == SYM) {
				if (!defined(token))
		                	PUT(token, lineno, sp);
			}
		}
	}
}
コード例 #6
0
ファイル: pkgdep.c プロジェクト: razzlefratz/MotleyTools
static void function (FIND * find, flag_t flags)

{
	if (! match (find->filename, find->wildcard))
	{
		return;
	}
	if (efreopen (find->fullname, "rb", stdin))
	{
		SCAN scan;
		char package [FILENAME_MAX];
		char scratch [FILENAME_MAX];
		char buffer [TEXTLINE_MAX];
		size_t line;
		scaninput (& scan, buffer, sizeof (buffer));
		for (line = 0; ~ fgetline (buffer, sizeof (buffer), stdin); line++)
		{
			scanwhile (& scan, gcsASCIIAlpha ".");
			scanbreak (& scan, ":");
			if (havetoken (& scan, "Name:"))
			{
				scanuntil (& scan, gcsBreak);
				extract (& scan, package, sizeof (package));
			}
			else if (havetoken (& scan, "Requires:"))
			{
				while (tokensize (& scan))
				{
					if (isclass (& scan, "A"))
					{
						extract (& scan, scratch, sizeof (scratch));
						printf ("\"%s\",\"%s\"\n", package, scratch);
					}
					nexttoken (& scan);
				}
			}
			else if (havetoken (& scan, "Requires.private:"))
			{
				while (tokensize (& scan))
				{
					if (isclass (& scan, "A"))
					{
						extract (& scan, scratch, sizeof (scratch));
						printf ("\"%s\",\"%s\"\n", package, scratch);
					}
					nexttoken (& scan);
				}
			}
			scanstart (& scan);
		}
	}
	return;
}
コード例 #7
0
ファイル: C.c プロジェクト: aYosukeAkatsuka/global-6.4
/**
 * condition_macro: 
 *
 *	@param	param	
 *	@param[in]	cc	token
 */
static void
condition_macro(const struct parser_param *param, int cc)
{
	cur = &stack[piflevel];
	if (cc == SHARP_IFDEF || cc == SHARP_IFNDEF || cc == SHARP_IF) {
		DBG_PRINT(piflevel, "#if");
		if (++piflevel >= MAXPIFSTACK)
			die("#if stack over flow. [%s]", curfile);
		++cur;
		cur->start = level;
		cur->end = -1;
		cur->if0only = 0;
		if (peekc(0) == '0')
			cur->if0only = 1;
		else if ((cc = nexttoken(NULL, c_reserved_word)) == SYMBOL && !strcmp(token, "notdef"))
			cur->if0only = 1;
		else
			pushbacktoken();
	} else if (cc == SHARP_ELIF || cc == SHARP_ELSE) {
		DBG_PRINT(piflevel - 1, "#else");
		if (cur->end == -1)
			cur->end = level;
		else if (cur->end != level && (param->flags & PARSER_WARNING))
			warning("uneven level. [+%d %s]", lineno, curfile);
		level = cur->start;
		cur->if0only = 0;
	} else if (cc == SHARP_ENDIF) {
		int minus = 0;

		--piflevel;
		if (piflevel < 0) {
			minus = 1;
			piflevel = 0;
		}
		DBG_PRINT(piflevel, "#endif");
		if (minus) {
			if (param->flags & PARSER_WARNING)
				warning("unmatched #if block. reseted. [+%d %s]", lineno, curfile);
		} else {
			if (cur->if0only)
				level = cur->start;
			else if (cur->end != -1) {
				if (cur->end != level && (param->flags & PARSER_WARNING))
					warning("uneven level. [+%d %s]", lineno, curfile);
				level = cur->end;
			}
		}
	}
	while ((cc = nexttoken(NULL, c_reserved_word)) != EOF && cc != '\n') {
		if (cc == SYMBOL && strcmp(token, "defined") != 0)
			PUT(PARSER_REF_SYM, token, lineno, sp);
	}
}
コード例 #8
0
ファイル: storeinfo.c プロジェクト: MhdAlyan/courier
int storeinfo_init(struct storeinfo *si)
{
struct imaptoken *t=currenttoken();
const char *p;

	if (t->tokentype != IT_ATOM)	return (-1);
	si->plusminus=0;
	si->silent=0;

	p=t->tokenbuf;
	if (*p == '+' || *p == '-')
		si->plusminus= *p++;
	if (strncmp(p, "FLAGS", 5))	return (-1);
	p += 5;
	if (*p)
	{
		if (strcmp(p, ".SILENT"))	return (-1);
		si->silent=1;
	}

	memset(&si->flags, 0, sizeof(si->flags));

	if ((si->keywords=libmail_kwmCreate()) == NULL)
		write_error_exit(0);

	t=nexttoken_noparseliteral();
	if (t->tokentype == IT_LPAREN)
	{
		if (get_flagsAndKeywords(&si->flags, &si->keywords))
		{
			libmail_kwmDestroy(si->keywords);
			si->keywords=NULL;
			return (-1);
		}
		nexttoken();
	}
	else if (t->tokentype == IT_NIL)
		nexttoken();
	else if (t->tokentype == IT_ATOM)
	{
		if (get_flagname(t->tokenbuf, &si->flags))
			libmail_kwmSetName(current_maildir_info
				       .keywordList,
				       si->keywords,
				       t->tokenbuf);
		nexttoken();
	}
	return (0);
}
コード例 #9
0
ファイル: Cpp.c プロジェクト: cage433/global_with_scala
/*
 * process_attribute: skip attributes in __attribute__((...)).
 *
 *	r)	target type
 */
static void
process_attribute(int target)
{
	int brace = 0;
	int c;
	/*
	 * Skip '...' in __attribute__((...))
	 * but pick up symbols in it.
	 */
	while ((c = nexttoken("()", cpp_reserved_word)) != EOF) {
		if (c == '(')
			brace++;
		else if (c == ')')
			brace--;
		else if (c == SYMBOL) {
			if (target == REF) {
				if (defined(token))
					PUT(token, lineno, sp);
			} else if (target == SYM) {
				if (!defined(token))
					PUT(token, lineno, sp);
			}
		}
		if (brace == 0)
			break;
	}
}
コード例 #10
0
ファイル: expr.c プロジェクト: syuu1228/openbsd-src
/* Parse and evaluate multiplication and division expressions */
struct val *
eval4(void)
{
	struct val     *l, *r;
	enum token	op;

	l = eval5();
	while ((op = token) == MUL || op == DIV || op == MOD) {
		nexttoken(0);
		r = eval5();

		if (!to_integer(l) || !to_integer(r)) {
			errx(2, "non-numeric argument");
		}

		if (op == MUL) {
			l->u.i *= r->u.i;
		} else {
			if (r->u.i == 0) {
				errx(2, "division by zero");
			}
			if (op == DIV) {
				l->u.i /= r->u.i;
			} else {
				l->u.i %= r->u.i;
			}
		}

		free_value(r);
	}

	return l;
}
コード例 #11
0
ファイル: rcon.c プロジェクト: DennisHeimbigner/utils
static int
value(rconlexer* lexer, rconnode** nodep)
{
    rconnode* node = NULL;
    int token = 0;

    ENTER(_value);

    token = nexttoken(lexer);
    switch (lexer->token) {
    case LBRACE:
	if(!map(lexer,&node,!OPTIONAL)) goto fail;
	break;
    case LBRACK:
	if(!array(lexer,&node)) goto fail;
	break;
    case _STRING:
    case _NUMBER:
    case _NULL:
    case _TRUE:
    case _FALSE:
	pushtoken(lexer);
	if(!makeconst(lexer,&node)) goto fail;
	break;
    case _ILLEGAL:
    default: goto fail;
    }
    if(nodep) *nodep = node;

    LEAVE(_value,1);
    return 1;
fail:
    LEAVE(_value,0);
    return 0;
}
コード例 #12
0
void SetupParentsForSpawnList( int nEntities, HierarchicalSpawn_t *pSpawnList )
{
	int nEntity;
	for (nEntity = nEntities - 1; nEntity >= 0; nEntity--)
	{
		CBaseEntity *pEntity = pSpawnList[nEntity].m_pEntity;
		if ( pEntity )
		{
			if ( strchr(STRING(pEntity->m_iParent), ',') )
			{
				char szToken[256];
				const char *pAttachmentName = nexttoken(szToken, STRING(pEntity->m_iParent), ',');
				pEntity->m_iParent = AllocPooledString(szToken);
				CBaseEntity *pParent = gEntList.FindEntityByName( NULL, pEntity->m_iParent );

				// setparent in the spawn pass instead - so the model will have been set & loaded
				pSpawnList[nEntity].m_pDeferredParent = pParent;
				pSpawnList[nEntity].m_pDeferredParentAttachment = pAttachmentName;
			}
			else
			{
				CBaseEntity *pParent = gEntList.FindEntityByName( NULL, pEntity->m_iParent );

				if ((pParent != NULL) && (pParent->edict() != NULL))
				{
					pEntity->SetParent( pParent ); 
				}
			}
		}
	}
}
コード例 #13
0
ファイル: tokconv.c プロジェクト: 8l/ucc-c-compiler
void eat2(enum token t, const char *fnam, int line, int die)
{
	if(t != curtok){
		const int ident = curtok == token_identifier;
		parse_had_error = 1;

		warn_at_print_error(NULL,
				"expecting token %s, got %s %s%s%s(%s:%d)",
				token_to_str(t), token_to_str(curtok),
				ident ? "\"" : "",
				ident ? token_current_spel_peek() : "",
				ident ? "\" " : "",
				fnam, line);

		if(die || --cc1_error_limit <= 0)
			exit(1);

		/* XXX: we continue here, assuming we had the token anyway */
	}else{
		if(curtok_save != token_unknown){
			curtok = curtok_save;
			curtok_save = token_unknown;
		}else{
			nexttoken();
		}
	}
}
コード例 #14
0
ファイル: ex19.c プロジェクト: lingyq/tcpl2
main()
{
	int type;
	char temp[MAXTOKEN];
	
	while(gettoken() != EOF)
	{
		strcpy(out, token);
		while((type = gettoken()) != '\n')
		{
			if((type == PARENS || type == BRACKETS))
				strcat(out,token);
			else if(type == '*')
			{
				if((type = nexttoken()) == PARENS || type == BRACKETS)
					sprintf(temp,"(**%s)",out);
				else
					sprintf(out,temp);
			}
			else if(type == NAME)
			{
				sprintf(temp,"%s %s",token,out);
				strcpy(out,temp);
			}
			else
				printf("invalid input at %s\n",token);
		}
		printf("%s\n",out);
	}
	return 0;
}
コード例 #15
0
ファイル: parser.c プロジェクト: Madx-com/BOSC
int acmd (char *s, Cmd **cmd)
{
  char *tok;
  int n, cnt = 0;
  Cmd *cmd0 = cmds;
  cmds = cmds->next;
  cmd0->next = NULL;
  cmd0->cmd = pp;

  while (1) {
    n = nexttoken(s, &tok);
    if (n == 0 || isspec(*tok))
      {
	*cmd = cmd0;
	*pp++ = NULL;
	return cnt;
      }
    else
      {
	*pp++ = tok;
	cnt += n;
	s += n;
      }
  }
}
コード例 #16
0
ファイル: expr.c プロジェクト: aibrahim/OpenBSD-src
int
main(int argc, char *argv[])
{
	struct val     *vp;

	(void) setlocale(LC_ALL, "");

	if (argc > 1 && !strcmp(argv[1], "--"))
		argv++;

	av = argv + 1;

	nexttoken(0);
	vp = eval0();

	if (token != EOI) {
		error();
		/* NOTREACHED */
	}

	if (vp->type == integer)
		printf("%d\n", vp->u.i);
	else
		printf("%s\n", vp->u.s);

	exit(is_zero_or_null(vp));
}
コード例 #17
0
ファイル: parse.c プロジェクト: ViktorLindstrm/OS-Lab1
int
acmd (char *s, Pgm **cmd)
{
    char *tok;
    int n, cnt = 0;
    Pgm *cmd0 = cmds;
    cmds = cmds->next;
    cmd0->next = NULL;
    cmd0->pgmlist = pp;

next:
    n = nexttoken(s, &tok);
    if (n == 0 || isspec(*tok))
    {
	*cmd = cmd0;
	*pp++ = NULL;
	return cnt;
    }
    else
    {
	*pp++ = tok;
	cnt += n;
	s += n;
	goto next;
    }
}
コード例 #18
0
ファイル: expr.c プロジェクト: aibrahim/OpenBSD-src
/* Parse and evaluate addition and subtraction expressions */
struct val *
eval3(void)
{
	struct val     *l, *r;
	enum token	op;

	l = eval4();
	while ((op = token) == ADD || op == SUB) {
		nexttoken(0);
		r = eval4();

		if (!to_integer(l) || !to_integer(r)) {
			errx(2, "non-numeric argument");
		}

		if (op == ADD) {
			l->u.i += r->u.i;
		} else {
			l->u.i -= r->u.i;
		}

		free_value(r);
	}

	return l;
}
コード例 #19
0
ファイル: MCPARSER.C プロジェクト: Clever-Boy/SuperMario
void shift(int state)
/* Shifts a token onto the stack */
{
 curtoken.state = state;
 push(&curtoken);
 tokentype = nexttoken();
} /* shift */
コード例 #20
0
ファイル: rcon.c プロジェクト: DennisHeimbigner/utils
static int
peek(rconlexer* lexer)
{
    int token = nexttoken(lexer);
    pushtoken(lexer);
    return token;
}
コード例 #21
0
ファイル: rcon.c プロジェクト: DennisHeimbigner/utils
static int
makeconst(rconlexer* lexer, rconnode** nodep)
{
    rconnode* node = NULL;
    int token;
    ENTER(_const);
    token = nexttoken(lexer);
    switch (token) {
    case _STRING:
    case _NUMBER:
	node = createrconnode(lexer,rcon_const);
	if(node == NULL) goto fail;
	node->constclass = token;
	node->constvalue = strdup(lexer->text.text);
	break;
    case _TRUE:
	node = &rcon_constant_true;
	break;
    case _FALSE:
	node = &rcon_constant_false;
	break;
    case _NULL:
	node = &rcon_constant_null;
	break;
    default: abort();
    }        
    if(nodep) *nodep = node;
    LEAVE(_const,1);
    return 1;
fail:
    LEAVE(_const,0);
    return 0;
}
コード例 #22
0
ファイル: rcon.c プロジェクト: DennisHeimbigner/utils
static int
array(rconlexer* lexer, rconnode** nodep)
{
    rconnode* subnode = NULL;
    struct rconlist list = {NULL,0,0};
    rconnode* node = NULL;

    ENTER(_array);

    node = createrconnode(lexer,rcon_array);
    for(;;) {
        int token = nexttoken(lexer);
	if(token == EOF)
	    FAIL(lexer,"unclosed array");
	if(token == RBRACK) goto done;
	if(token == COMMA || token == SEMICOLON) continue;
	pushtoken(lexer);
        if(!value(lexer,&subnode)) goto fail;
	if(!listadd(&list,subnode)) goto fail;
    }
done:
    node->list.values = list.contents;
    node->list.nvalues = list.len;
    if(nodep) *nodep = node;
    LEAVE(_array,1);
    return 1;
fail:
    listclear(&list);
    if(subnode != NULL) rconnodefree(subnode);
    if(node != NULL) rconnodefree(node);
    LEAVE(_array,0);
    return 0;
}
コード例 #23
0
ファイル: rcon.c プロジェクト: DennisHeimbigner/utils
static int
pair(rconlexer* lexer, rconnode** nodep)
{
    rconnode* node = NULL;
    int token = 0;

    ENTER(_pair);
    node = createrconnode(lexer,rcon_pair);
    if(!node) goto fail;
    if(!makeconst(lexer,&node->pair.key))
	FAIL(lexer,"map key is not a string or word");
    if(node->pair.key->constclass != rcon_string)
	FAIL(lexer,"map key is not a string or word");
    token = nexttoken(lexer);	
    if(token != ':') goto fail;
    if(!value(lexer,&node->pair.value))
	FAIL(lexer,"invalid map value");
    if(nodep) *nodep = node;
    LEAVE(_pair,1);
    return 1;
fail:
    if(node != NULL) rconnodefree(node);
    LEAVE(_pair,0);
    return 0;
}
コード例 #24
0
ファイル: mit_dump.c プロジェクト: SimonWilkinson/heimdal
static int
getint(char **p)
{
    int val;
    char *q = nexttoken(p);
    sscanf(q, "%d", &val);
    return val;
}
コード例 #25
0
ファイル: ttsgf_read.c プロジェクト: clody/PocketGNUGo
static void
match(int expected)
{
  if (lookahead != expected)
    parse_error("expected: %c", expected);
  else
    nexttoken();
}
コード例 #26
0
// parent name may have a , in it to include an attachment point
string_t ExtractParentName(string_t parentName)
{
	if ( !strchr(STRING(parentName), ',') )
		return parentName;

	char szToken[256];
	nexttoken(szToken, STRING(parentName), ',');
	return AllocPooledString(szToken);
}
コード例 #27
0
ファイル: havetoken.c プロジェクト: tcdog001/apv5sdk-v15
bool havetoken (SCAN * content, const char *literal) 

{
	if (istoken (content, literal)) 
	{
		nexttoken (content);
		return (true);
	}
	return (false);
}
コード例 #28
0
ファイル: parser.c プロジェクト: BackupTheBerlios/most
static ACE_err_t
match(CLI_parser_t *p, enum CLI_token_id t)
{
    if (p->lookahead == t) {
        p->lookahead = nexttoken(p);
    } else {
        return CLI_ERR_TOKEN;
    }
    return ACE_OK;
}
コード例 #29
0
ファイル: lcl.c プロジェクト: LuaDist/lcl
static int Lunpack(lua_State *L)		/** unpack(s) */
{
	const char *s=luaL_checkstring(L,1);
	lua_settop(L,1);
	for (;;) {
		int t=nexttoken(L,&s);
		if (t<0) return 3;
		if (t==0) break;
	}
	return lua_gettop(L)-1;
}
コード例 #30
0
ファイル: imaptoken.c プロジェクト: MhdAlyan/courier
struct imaptoken *nexttoken_okbracket(void)
{
	struct imaptoken *t;

	LBRACKET_CHAR=RBRACKET_CHAR='\n';

	t=nexttoken();

	LBRACKET_CHAR='[';
	RBRACKET_CHAR=']';
	return (t);
}