Пример #1
0
void RawParser::ParseInfoToken(const char *&pcs, int &iLen, bool *pbMoreFollows)
{
	if (!FindNextToken()) {
		if (pbMoreFollows) *pbMoreFollows = false;
		return;
	}

	pcs = (const char *)pbPos;
	if (*pcs == '"') pcs++;

	ParseToken(sz, pbMoreFollows);

	iLen = int(strlen(sz));
}
Пример #2
0
/**
 * @brief Parses an incoming SVC_PRINT message.
 */
static void Cl_ParsePrint(void) {

	const byte level = Net_ReadByte(&net_message);
	const char *string = Net_ReadString(&net_message);

	// the server shouldn't have sent us anything below our level anyway
	if (level >= message_level->integer) {

		// check to see if we should ignore the message
		if (*cl_ignore->string) {

			char patterns[MAX_STRING_CHARS];
			g_strlcpy(patterns, cl_ignore->string, sizeof(patterns));

			const char *p = patterns;
			while (true) {
				const char *pattern = ParseToken(&p);
				if (pattern == NULL) {
					break;
				}

				if (GlobMatch(pattern, string)) {
					return;
				}
			}
		}

		char *sample = NULL;
		switch (level) {
			case PRINT_CHAT:
			case PRINT_TEAM_CHAT:
				if (level == PRINT_CHAT && *cl_chat_sound->string) {
					sample = cl_chat_sound->string;
				} else if (level == PRINT_TEAM_CHAT && *cl_team_chat_sound->string) {
					sample = cl_team_chat_sound->string;
				}
				break;
			default:
				break;
		}

		if (sample) {
			S_AddSample(&(const s_play_sample_t) {
				.sample = S_LoadSample(sample)
			});
		}

		Con_Append(level, string);
	}
Пример #3
0
// Initialize net service list
void InitNetSvcList(CEDAR *cedar)
{
	char filename[MAX_PATH] = "/etc/services";
	BUF *b;
	// Validate arguments
	if (cedar == NULL)
	{
		return;
	}

#ifdef	OS_WIN32
	Format(filename, sizeof(filename), "%s\\drivers\\etc\\services", MsGetSystem32Dir());
#endif

	cedar->NetSvcList = NewList(CompareNetSvc);

	b = ReadDump(filename);
	if (b == NULL)
	{
		return;
	}

	while (true)
	{
		char *s = CfgReadNextLine(b);
		if (s == NULL)
		{
			break;
		}

		Trim(s);
		if (s[0] != '#')
		{
			TOKEN_LIST *t = ParseToken(s, " \t/");
			if (t->NumTokens >= 3)
			{
				NETSVC *n = ZeroMalloc(sizeof(NETSVC));
				n->Name = CopyStr(t->Token[0]);
				n->Udp = (StrCmpi(t->Token[2], "udp") == 0 ? true : false);
				n->Port = ToInt(t->Token[1]);
				Add(cedar->NetSvcList, n);
			}
			FreeToken(t);
		}
		Free(s);
	}

	FreeBuf(b);
}
Пример #4
0
eTokenType asCTokenizer::GetToken(const char *source, size_t sourceLength, size_t *tokenLength)
{
	assert(source != 0);
	assert(tokenLength != 0);

	this->source = source;
	this->sourceLength = sourceLength;

	ParseToken();

	// Copy the output to the token
	*tokenLength = this->tokenLength;

	return tokenType;
}
Пример #5
0
int Anasin::ListidP(){
	Lexema nextLexema = this->_symTab->lookAheadLexema();
	if(nextLexema._tipo == "Punctuation" && nextLexema._valor == ","){
		//12) ListidP -> , Listid
		if(!ParseToken(Lexema("Punctuation",","),true)) return 0;
		if(!Listid()) return 0;
	}else if(nextLexema._tipo == "Reserved" && nextLexema._valor == "nil"){
		//13) ListidP -> €
		// No hago nada
	}else{
		std::cout << "Error sintáctico, se esperaba : Punctuation, nil y se obtuvo: " << nextLexema._tipo << " ("<< nextLexema._valor <<")["<< this->_symTab->getOffset() <<"]" << std::endl;
		return 0;
	}
	return 1;
}
Пример #6
0
Value* JSONReader::JsonToValue(const std::string& json, bool check_root,
                               bool allow_trailing_comma)
{
    // 输入必须是UTF-8编码.
    if(!IsStringUTF8(json.c_str()))
    {
        error_code_ = JSON_UNSUPPORTED_ENCODING;
        return NULL;
    }

    // 从UTF8到wstring的转换会移除空字节(好事).
    std::wstring json_wide(UTF8ToWide(json));
    start_pos_ = json_wide.c_str();

    // 当输入的JSON字符串开头有UTF-8的Byte-Order-Mark(0xEF, 0xBB, 0xBF),
    // UTF8ToWide()函数会把它转换成BOM(U+FEFF). 为防止JSONReader::BuildValue()
    // 函数把它当成非法字符而返回NULL, 如果存在Unicode的BOM则先跳过.
    if(!json_wide.empty() && start_pos_[0]==0xFEFF)
    {
        ++start_pos_;
    }

    json_pos_ = start_pos_;
    allow_trailing_comma_ = allow_trailing_comma;
    stack_depth_ = 0;
    error_code_ = JSON_NO_ERROR;

    scoped_ptr<Value> root(BuildValue(check_root));
    if(root.get())
    {
        if(ParseToken().type == Token::END_OF_INPUT)
        {
            return root.release();
        }
        else
        {
            SetErrorCode(JSON_UNEXPECTED_DATA_AFTER_ROOT, json_pos_);
        }
    }

    // "语法错误".
    if(error_code_ == 0)
    {
        SetErrorCode(JSON_SYNTAX_ERROR, json_pos_);
    }

    return NULL;
}
eTokenType asCTokenizer::GetToken(const char *source, size_t sourceLength, size_t *tokenLength, asETokenClass *tc)
{
	asASSERT(source != 0);
	asASSERT(tokenLength != 0);

	this->source = source;
	this->sourceLength = sourceLength;

	asETokenClass t = ParseToken();
	if( tc ) *tc = t;

	// Copy the output to the token
	*tokenLength = this->tokenLength;

	return tokenType;
}
Пример #8
0
static int
ParseExtendedTX(void)
{
    int style = TX_ORIGINAL;

    if (ParseToken(PARSE_COMMENT)) {
	if (!strncmp(token, "//TX", 4)) {
	    if (token[4] == '1')
		style = TX_QUARK_TYPE1;
	    else if (token[4] == '2')
		style = TX_QUARK_TYPE2;
	}
    }

    return style;
}
Пример #9
0
static texcoord_style_t
ParseExtendedTX(parser_t *parser)
{
    texcoord_style_t style = TX_ORIGINAL;

    if (ParseToken(parser, PARSE_COMMENT)) {
	if (!strncmp(parser->token, "//TX", 4)) {
	    if (parser->token[4] == '1')
		style = TX_QUARK_TYPE1;
	    else if (parser->token[4] == '2')
		style = TX_QUARK_TYPE2;
	}
    }

    return style;
}
Пример #10
0
void CommandLineMode(int argc, char *argv[], void *htmsocket) {
    char *messageName;
    char *token;
    typedArg args[MAX_ARGS];
    int i,j, numArgs;
    OSCbuf buf[1];

    OSC_initBuffer(buf, SC_BUFFER_SIZE, bufferForOSCbuf);

    if (argc > 1) {
	if (OSC_openBundle(buf, OSCTT_Immediately())) {
	    complain("Problem opening bundle: %s\n", OSC_errorMessage);
	    return;
	}
    }

    for (i = 0; i < argc; i++) {
        messageName = strtok(argv[i], ",");
        if (messageName == NULL) {
            break;
        }

        j = 0;
        while ((token = strtok(NULL, ",")) != NULL) {
            args[j] = ParseToken(token);
            j++;
	    if (j >= MAX_ARGS) {
		complain("Sorry; your message has more than MAX_ARGS (%d) arguments; ignoring the rest.\n",
			 MAX_ARGS);
		break;
	    }
        }
        numArgs = j;

        WriteMessage(buf, messageName, numArgs, args);
    }

    if (argc > 1) {
	if (OSC_closeBundle(buf)) {
	    complain("Problem closing bundle: %s\n", OSC_errorMessage);
	    return;
	}
    }

    SendBuffer(htmsocket, buf);
}
Пример #11
0
int Anasin::Operador(){
	Lexema nextLexema = this->_symTab->lookAheadLexema();
	if(nextLexema._tipo == "Arithmetic"){
		// 27) Operador  -> arithmetic Expresion
		if(!ParseToken(Lexema("Arithmetic",""),false)) return 0;
		if(!Expresion()) return 0;
	}else if(nextLexema._tipo == "Relational" ||
			(nextLexema._tipo == "Agrupation" && nextLexema._valor == ")") ||
			(nextLexema._tipo == "Punctuation" && nextLexema._valor == ";")){
		// 28) Operador  -> €
		// No hago nada
	}else{
		std::cout << "Error sintáctico, se esperaba : Arithmetic, Relational, ) o ; y se obtuvo: " << nextLexema._tipo << " ("<< nextLexema._valor <<")["<< this->_symTab->getOffset() <<"]" << std::endl;
		return 0;
	}
	return 1;
}
Пример #12
0
int DoInclude(ParsePtr p)
{
    DynamicBuffer buf;
    int r, e;

    DBufInit(&buf);
    if ( (r=ParseToken(p, &buf)) ) return r;
    e = VerifyEoln(p);
    if (e) Eprint("%s", ErrMsg[e]);
    if ( (r=IncludeFile(DBufValue(&buf))) ) {
	DBufFree(&buf);
	return r;
    }
    DBufFree(&buf);
    NumIfs = 0;
    IfFlags = 0;
    return OK;
}
Пример #13
0
bool CXMLElement::ParseRootTag (IMemoryBlock &Stream, CString *retsTag)

//	ParseRootTag
//
//	This function parses only enough to determine the root tag, either by reading
//	as far as the first open tag or by getting the DOCTYPE.
//
//	This function is a hack to allow Transcendence to read the root tag for an
//	extension without loading the whole file.

	{
	//	Initialize context

	ParserCtx Ctx(Stream, NULL);
	Ctx.m_bParseRootTag = true;

	//	Parse the prologue

	if (!ParsePrologue(&Ctx))
		return false;

	if (!Ctx.m_sRootTag.IsEmpty())
		{
		*retsTag = Ctx.m_sRootTag;
		return true;
		}

	//	Next token must be an element open tag

	if (Ctx.iToken != tkTagOpen)
		return false;

	//	Parse the root element name

	if (ParseToken(&Ctx) != tkText)
		return false;

	*retsTag = Ctx.sToken;

	//	Done

	return true;
	}
Пример #14
0
int CCloseCaptionPhrase::CountTokens( void ) const
{
	int count = 0;
	wchar_t token[ 1024 ];
	wchar_t const *in = GetStream();

	while ( in )
	{
		in = ParseToken( in, token, sizeof( token ) );
		if ( wcslen( token ) > 0 )
		{
			count++;
		}
		if ( !in || *in == L'\0' )
			break;
	}

	return count;
}
Пример #15
0
bool Scanner::GetToken(Token *token)
{
	if ((token == NULL))
	{
		return false;
	}

	Skip();

	if (ParseDigit(token))
		return true;

	if (ParseToken(token))
		return true;

	if (ParseOperator(token))
		return true;

	return false;
}
Пример #16
0
bool RawParser::ParseParams(PCTCHAR pcszDefaultFile)
{
	if (!ParseToken(sz)) return false;
	if (_strcmpi(sz, "RawImage") != 0) return false;

	for (int n = 0; n < 4; n++) {
		_tcscpy(Comps[n].szFile, pcszDefaultFile);
		Comps[n].nStart = 0;
		Comps[n].nDelta = -1;
	}

	ParseMainBlock();

	for (int n = 0; n < 4; n++) {
		if (Comps[n].nDelta < 0)
			Comps[n].nDelta = cbComp;
	}

	return true;
}
Пример #17
0
static inline
int ParseFile(char* Filename, GLArbToken* ArbHash,
               GLToken* FunctionsHash, unsigned int* FunctionCount,
               GLToken* DefinesHash, unsigned int* DefinesCount,
               GLSettings* Settings)
{
  char* Data = ReadEntireFile(Filename);
  int Success = 0;
  if (Data)
  {
    GLTokenizer Tokenizer;
    Tokenizer.At = Data;
    while(*Tokenizer.At)
    {
      GLToken Token = ParseToken(&Tokenizer);
      if (StartsWith(Token.Value, "gl") && IsUpperCase(Token.Value.Chars[2]))
      {
        if (!Contains(FunctionsHash, Token) && IsKnownOrIgnoredToken(ArbHash, &Token, Settings))
        {
          AddToken(FunctionsHash, Token);
          *FunctionCount += 1;
        }
      }
      if (StartsWith(Token.Value, "GL_"))
      {
        if (!Contains(DefinesHash, Token) && IsKnownOrIgnoredToken(ArbHash, &Token, Settings))
        {
          AddToken(DefinesHash, Token);
          *DefinesCount += 1;
        }
      }
    }
    free(Data);
    Success = 1;
  }
  else
  {
    fprintf(stderr, "Couldn't open file %s", Filename);
  }
  return Success;
}
Пример #18
0
//
// parses format and (via UpdateAttr and convert) outputs data
void ydpDictionary::ParseRTF(void) {
	char *def = curDefinition;
	int level=0, attr=0, attrs[16], phon;

	newline_=0; newattr=0; newphon=0;

	textlen=0;
	outputView->SetText("");

	while(*def) {
		switch(*def) {
			case '{':
				if (level<16) attrs[level++] = attr;
				break;
			case '\\':
				def = ParseToken(def);
				UpdateAttr(attr);
				attr = newattr;
				break;
			case '}':
				newattr = attrs[--level];
				UpdateAttr(attr);
				break;
			default:
				line += *def;
				break;
		}
		def++;
		if (newline_) {
			if (newattr & A_MARGIN) {
				line.Prepend("\t\t",2);
			}
			line.Append("\n",1);
			UpdateAttr(attr);
			newline_ = 0;
		}
		attr = newattr;
		phon = newphon;
	}
	UpdateAttr(attr);
}
Пример #19
0
// returns pointer to array of pointers to null terminated strings
// (like argc, argv from main), quoted arguments have quotes stripped.
// this function is destructive in that it will write null's and remove
// quotes from the string.
//
// the caller must use HeapFree to free the returned pointer.
//
LPCTSTR * TokenizeString (
   LPCTSTR pszInput,
   LPUINT  pcArgs)
{
   *pcArgs = 0;
   if ( ! pszInput)
      return NULL;

   UINT cch = lstrlen (pszInput);
   if ( ! cch)
      return NULL;

   UINT cbAlloc = ((cch + 1) * sizeof(char*) +  cch * sizeof(TCHAR) * 2);
   LPCTSTR * pArgv = (LPCTSTR *)HeapAlloc(GetProcessHeap(), 0, cbAlloc);
   if ( ! pArgv)
      return NULL;

   LPTSTR pszToken = (LPTSTR)(&pArgv[cch + 1]);
   UINT   cArgs    = 0;

   CopyMemory(pszToken, pszInput, (cch+1) * sizeof(TCHAR));

   pszToken = _SkipWhiteSpace (pszToken);
   while (0 != pszToken[0])
      {
      LPTSTR psz = ParseToken(pszToken);
      pArgv[cArgs++] = pszToken;
      pszToken = _SkipWhiteSpace (psz);
      }

   *pcArgs = cArgs;
   pArgv[cArgs] = NULL;
   if ( ! cArgs)
      {
      HeapFree(GetProcessHeap(), 0, pArgv);
      pArgv = NULL;
      }

   return pArgv;
}
Пример #20
0
void ParseMoves(POS *p, char *ptr) {
  
  char token[180];
  UNDO u[1];

  for (;;) {

    // Get next move to parse

    ptr = ParseToken(ptr, token);

  // No more moves!

    if (*token == '\0') break;

    p->DoMove(StrToMove(p, token), u);

  // We won't be taking back moves beyond this point:

    if (p->rev_moves == 0) p->head = 0;
  }
}
Пример #21
0
int Anasin::BloqueE(){
	Lexema nextLexema = this->_symTab->lookAheadLexema();
	if(nextLexema._tipo == "Reserved" && nextLexema._valor == "else"){
		// 15) BloqueE -> else BloqueS
		if(!ParseToken(Lexema("Reserved","else"),true)) return 0;
		if(!BloqueS()) return 0;
	}else if(nextLexema._tipo == "id" ||
			nextLexema._tipo == "Output" ||
			(nextLexema._tipo == "Agrupation" && nextLexema._valor == "}") ||
			(nextLexema._tipo == "Reserved" && nextLexema._valor == "while") ||
			(nextLexema._tipo == "Reserved" && nextLexema._valor == "if") ||
			(nextLexema._tipo == "Reserved" && nextLexema._valor == "arr") ||
			(nextLexema._tipo == "Reserved" && nextLexema._valor == "count")||
			nextLexema._tipo == "$"){
		// 16) BloqueE -> €
		// No hago nada
	}else{
		std::cout << "Error sintáctico, se esperaba : else, id, }, output, while, if, arr, count y se obtuvo: " << nextLexema._tipo << " ("<< nextLexema._valor <<")["<< this->_symTab->getOffset() <<"]" << std::endl;
		return 0;
	}
	return 1;
}
void CEnvEffectsScript::LoadFromBuffer( const char *scriptfile, const char *buffer )
{
	while ( 1 )
	{
		ParseToken();
		
		if ( !token[0] )
		{
			break;
		}

		if ( !Q_stricmp( token, "effect" ) )
		{
			ParseNewEffect();
		}
		else
		{
			Warning( "CEnvEffectsScript: Unknown entry type '%s'\n", token );
			break;
		}
	}
}
Пример #23
0
wchar_t const *CCloseCaptionPhrase::GetToken( int token_number ) const
{
	int count = 0;
	static wchar_t token[ 1024 ];
	wchar_t const *in = GetStream();

	token[ 0 ] = L'\0';

	while ( in )
	{
		in = ParseToken( in, token, sizeof( token ) );
		if ( wcslen( token ) > 0 )
		{
			if ( count == token_number )
				break;
			count++;
		}
		if ( !in || *in == L'\0' )
			break;
	}

	return token;
}
Пример #24
0
asCScriptNode *asCParser::ParseTypeMod(bool isParam)
{
	asCScriptNode *node = new asCScriptNode(snDataType);

	sToken t;

	// Parse possibly byref token
	GetToken(&t);
	RewindTo(&t);
	if( t.type == ttAmp )
	{
		node->AddChildLast(ParseToken(ttAmp));
		if( isSyntaxError ) return node;

		if( isParam )
		{
			int tokens[3] = {ttIn, ttOut, ttInOut};
			node->AddChildLast(ParseOneOf(tokens, 3));
		}
	}

	return node;
}
/* Scans the next token and checks that it is the one that's expected */
static int MatchToken( ParseContext* ctx, ConfigToken token )
{
	ConfigToken parsed_token;
	
	parsed_token = ParseToken( ctx );

	if( parsed_token != token )
	{
		if( parsed_token != Token_Unknown ) 
		{
			sprintf( error_buffer, "%s: unexpected configuration token: found: '%s', expected: '%s'",
				ERROR_PREFIX, TokenToString( parsed_token ), TokenToString( token ) );
		}
		else
		{
			sprintf( error_buffer, "%s: unknown configuration token: '%s', expected: '%s'",
				ERROR_PREFIX, ctx->token, TokenToString( token ) );
		}

		return CONFIG_PARSE_ERROR;
	}

	return 0;
}
Пример #26
0
int Anasin::EControl(){
	Lexema nextLexema = this->_symTab->lookAheadLexema();
	if(nextLexema._tipo == "Reserved" && nextLexema._valor == "while"){
		// 06) EControl    ->	while(Condicion)BloqueS
		if(!ParseToken(Lexema("Reserved","while"),true)) return 0;
		if(!ParseToken(Lexema("Agrupation","("),true)) return 0;
		if(!Condicion()) return 0;
		if(!ParseToken(Lexema("Agrupation",")"),true)) return 0;
		if(!BloqueS()) return 0;
	}else if(nextLexema._tipo == "Reserved" && nextLexema._valor == "if"){
		// 07) EControl    ->	if(Condicion)BloqueS BloqueE
		if(!ParseToken(Lexema("Reserved","if"),true)) return 0;
		if(!ParseToken(Lexema("Agrupation","("),true)) return 0;
		if(!Condicion()) return 0;
		if(!ParseToken(Lexema("Agrupation",")"),true)) return 0;
		if(!BloqueS()) return 0;
		if(!BloqueE()) return 0;
	}else{
		std::cout << "Error sintáctico, se esperaba : while, if y se obtuvo: " << nextLexema._tipo << " ("<< nextLexema._valor <<")["<< this->_symTab->getOffset() <<"]" << std::endl;
		return 0;
	}
	return 1;
}
Пример #27
0
// Check whether the specified string is a number
bool IsNum(char *str)
{
	char c;
	UINT i, len;
	UINT n = 0;
	char tmp[MAX_SIZE];
	TOKEN_LIST *t;
	// Validate arguments
	if (str == NULL)
	{
		return false;
	}

	StrCpy(tmp, sizeof(tmp), str);
	Trim(tmp);

	if (StrLen(tmp) == 0)
	{
		return false;
	}

	t = ParseToken(tmp, " ");

	if (t->NumTokens >= 1)
	{
		StrCpy(tmp, sizeof(tmp), t->Token[0]);
	}

	FreeToken(t);

	len = StrLen(tmp);
	for (i = 0;i < len;i++)
	{
		bool b = false;
		c = tmp[i];
		if (('0' <= c && c <= '9') || (c == '+') || (c == '-') || (c == ','))
		{
			b = true;
		}

		if (b == false)
		{
			return false;
		}
	}

	for (i = 0;i < len;i++)
	{
		c = tmp[i];
		if (c == '-')
		{
			n++;
		}
	}
	if (n >= 2)
	{
		return false;
	}

	return true;
}
Пример #28
0
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//
// Command - Process text command
//
// Inputs:      Line command to process
//
// Outputs:     None.
//
void Command(char *Buffer) {

    ParseInit(Buffer);

    char *Command = ParseToken();

#ifdef USE_MAIN_SCREEN
    //
    // MA - Show the main screen
    //
    if( StrEQ(Command,"MA") ) {
        ShowScreen('MA');
        return;
        }

#ifdef USE_MAIN_SCREEN_CMDS
    //
    // See if the local screen can manage the command
    //
    if( SelectedScreen == 'MA' ) {
        if( MAScreenCommand(Command) )
            return;
        }

    //
    // Universally accept <ESC> as an escape to the main screen.
    //
    if( StrEQ(Command,ESC_CMD) ) {
        ShowScreen('MA');
        return;
        }
#endif
#endif

//////////////////////////////////////////////////////////////////////////////////////////

#ifdef USE_HELP_SCREEN
    //
    // HE - Help screen
    //
    if( StrEQ(Command,"HE") ||
        StrEQ(Command,"?" ) ) {
        ShowScreen('HE');
        return;
        }

#ifdef USE_HELP_SCREEN_CMDS
    //
    // See if the local screen can manage the command
    //
    if( SelectedScreen == 'HE' ) {
        if( HEScreenCommand(Command) )
            return;
        }
#endif
#endif

//////////////////////////////////////////////////////////////////////////////////////////

#ifdef USE_DEBUG_SCREEN
    //
    // DE - Show the debug screen
    //
    if( StrEQ(Command,"DE") ) {
        ShowScreen('DE');
        return;
        }

#ifdef USE_DEBUG_SCREEN_CMDS
    //
    // See if the local screen can manage the command
    //
    if( SelectedScreen == 'DE' ) {
        if( DEScreenCommand(Command) )
            return;
        }
#endif
#endif

//////////////////////////////////////////////////////////////////////////////////////////

#ifdef USE_MEMORY_SCREEN
    //
    // ME - Show the memory screen
    //
    if( StrEQ(Command,"ME") ) {
        ShowScreen('ME');
        return;
        }

#ifdef USE_MEMORY_SCREEN_CMDS
    //
    // See if the local screen can manage the command
    //
    if( SelectedScreen == 'ME' ) {
        if( MEScreenCommand(Command) )
            return;
        }
#endif
#endif

#ifdef USE_EEPROM_SCREEN
    //
    // EE - Show the memory screen
    //
    if( StrEQ(Command,"EE") ) {
        ShowScreen('EE');
        return;
        }

#ifdef USE_EEPROM_SCREEN_CMDS
    //
    // See if the local screen can manage the command
    //
    if( SelectedScreen == 'EE' ) {
        if( EEScreenCommand(Command) )
            return;
        }
#endif
#endif

    //
    // Not a recognized command. Let the user know he goofed.
    //
    CursorPos(1,ERROR_ROW);
    ClearEOL;
    PrintString("Unrecognized command (");
    PrintString(Command);
    PrintString(")\r\n");

    PrintStringP(PSTR(BEEP));
    }
Пример #29
0
RTFStatus RTFReader::Parse(void)
{
	RTFStatus t_status;
	t_status = kRTFStatusSuccess;
			
	while(t_status == kRTFStatusSuccess)
	{
		RTFToken t_token;
		int4 t_value;
		
		if (m_input_skip_count > 0)
		{
			while(m_input_skip_count > 0)
			{
				t_status = ParseToken(t_token, t_value);
				if (t_status != kRTFStatusSuccess)
					break;

				if (t_token == kRTFTokenEnd || t_token == kRTFTokenBeginGroup || t_token == kRTFTokenEndGroup)
				{
					m_input_skip_count = 0;
					break;
				}

				if ((t_token & kRTFTokenMask) == kRTFTokenBin)
					m_input += t_value;

				m_input_skip_count -= 1;
			}
		}

		if (t_status == kRTFStatusSuccess)
			t_status = ParseToken(t_token, t_value);

		if (t_status != kRTFStatusSuccess)
			break;

		if (t_token == kRTFTokenEnd)
			break;
			
		if (t_token == kRTFTokenBeginGroup)
			t_status = m_state . Save();
		else if (t_token == kRTFTokenEndGroup)
		{
			// Take into account implementation of 'destinations'.
			bool t_was_list;
			t_was_list = m_state . GetDestination() == kRTFDestinationLegacyList;

			bool t_was_list_text;
			t_was_list_text = m_state . GetDestination() == kRTFDestinationListText;

			bool t_was_field;
			t_was_field = m_state . GetDestination() == kRTFDestinationFldInst;

			// MW-2014-01-08: [[ Bug 11627 ]] If the paragraph attributes have changed then
			//   force a flush so that a new paragraph with said attributes is created. [ This
			//   isn't 100% correct from my reading of the RTF Spec - really paragraph attrs
			//   should be set on the current paragraph as the paragraph is parsed, rather than
			//   before the first text is emitted - however due to the way LiveCode and Word Processors
			//   generate RTF, this at least makes things roundtrip ].
			if (m_state . HasParagraphChanged())
				Flush(true);

			t_status = m_state . Restore();

			if (t_was_list)
			{
				m_state . SetListStyle(m_list_style);
				m_state . SetListLevel(m_list_level);
			}
			else if (t_was_list_text)
			{
				if (m_list_skip)
					m_state . SetListStyle(kMCTextListStyleSkip);
			}
			else if (t_was_field && m_state . GetDestination() != kRTFDestinationFldInst)
			{
				ProcessField();
			}

			m_attributes_changed = true;
		}
		else if ((t_token & kRTFTokenMask) == kRTFTokenBin)
		{
			m_input_binary_count = t_value;
			m_input_state = kRTFInputStateBinary;
		}
		else switch(m_state . GetDestination())
		{
		case kRTFDestinationSkip:
			// If the skipped destination is in fact the 'list' destination then
			// handle it. We ignore 'pn' destinations if we have a listtable though.
			if (t_token == kRTFTokenLegacyList && m_lists . Count() == 0)
			{
				m_list_style = kMCTextListStyleNone;
				m_list_level = 0;
				m_state . SetDestination(kRTFDestinationLegacyList);
			}
			else if (t_token == kRTFTokenListTable)
				m_state . SetDestination(kRTFDestinationListTable);
			else if (t_token == kRTFTokenListOverrideTable)
				m_state . SetDestination(kRTFDestinationListOverrideTable);
			else if (t_token == kRTFTokenFldInst)
				m_state . SetDestination(kRTFDestinationFldInst);
		break;
		
		case kRTFDestinationNormal:
			t_status = ParseDocument(t_token, t_value);
		break;
		
		case kRTFDestinationFontTable:
			t_status = ParseFontTable(t_token, t_value);
		break;
		
		case kRTFDestinationColorTable:
			t_status = ParseColorTable(t_token, t_value);
		break;

		case kRTFDestinationLegacyList:
			t_status = ParseLegacyList(t_token, t_value);
		break;

		case kRTFDestinationLegacyListPrefix:
			t_status = ParseLegacyListPrefix(t_token, t_value);
		break;
				
		case kRTFDestinationListTable:
			t_status = ParseListTable(t_token, t_value);
		break;
				
		case kRTFDestinationListTableLevelText:
			t_status = ParseListTableLevelText(t_token, t_value);
		break;
				
		case kRTFDestinationListOverrideTable:
			t_status = ParseListOverrideTable(t_token, t_value);
		break;

		case kRTFDestinationListText:
			t_status = ParseListText(t_token, t_value);
		break;

		case kRTFDestinationField:
		break;

		case kRTFDestinationFldInst:
			t_status = ParseFldInst(t_token, t_value);
		break;
		}
	}
	
	return t_status;
}
Пример #30
0
// Read the inf file from the buffer
bool ViLoadInfFromBuf(VI_SETTING *set, BUF *buf)
{
	bool ret;
	if (set == NULL || buf == NULL)
	{
		return false;
	}

	Zero(set, sizeof(VI_SETTING));

	SeekBuf(buf, 0, 0);
	while (true)
	{
		char *tmp = CfgReadNextLine(buf);
		TOKEN_LIST *tokens;

		if (tmp == NULL)
		{
			break;
		}

		tokens = ParseToken(tmp, " \t");

		if (tokens != NULL)
		{
			if (tokens->NumTokens >= 2)
			{
				if (StartWith(tokens->Token[0], "#") == false
					|| StartWith(tokens->Token[0], "//") == false)
				{
					char *name, *value;
					name = tokens->Token[0];
					value = tokens->Token[1];

					if (StrCmpi(name, "VpnInstallBuild") == 0)
					{
						set->VpnInstallBuild = ToInt(value);
					}
					else if (StrCmpi(name, "NormalMode") == 0)
					{
						set->NormalMode = ToBool(value);
					}
					else if (StrCmpi(name, "VpnSettingPath") == 0)
					{
						StrCpy(set->SettingPath, sizeof(set->SettingPath), value);
					}
					else if (StrCmpi(name, "VpnClientBuild") == 0)
					{
						set->x86.Build = ToInt(value);
					}
					else if (StrCmpi(name, "VpnClientPath") == 0)
					{
						StrCpy(set->x86.Path, sizeof(set->x86.Path), value);
					}
				}
			}
			FreeToken(tokens);
		}

		Free(tmp);
	}

	ret = false;

	StrCpy(set->x86.VpnCMgrExeFileName, sizeof(set->x86.VpnCMgrExeFileName), (MsIsX64() ? "vpncmgr_x64.exe" : "vpncmgr.exe"));

	if (set->VpnInstallBuild != 0)
	{
		if (set->x86.Build != 0 && IsEmptyStr(set->x86.Path) == false)
		{
			set->x86.Supported = true;
			ret = true;
		}
	}

	return ret;
}