Пример #1
0
//*****************************************************************************
void CDbMessageText::ImportText(const char** atts)
//Add a new message text for this language if one does not exist.
{
	//There must be exactly two attribute-value pairs, 'lang' and 'text'.
	if (!atts[0] || !atts[1] || !atts[2] || !atts[3] || atts[4]) return;
	if (strcmp("lang", atts[0]) != 0) return;
	if (strcmp("text", atts[2]) != 0) return;
	if (strlen(atts[3]) == 0) return; //empty text -- do nothing

	//Look whether this message exists in the specified language.
	const Language::LANGUAGE oldLanguage = Language::GetLanguage(), eLanguage = Language::Get(atts[1]);
	Language::SetLanguage(eLanguage);
	const UINT dwFoundRowI = FindMessageText(this->eMessageID, false);
	if (dwFoundRowI != ROW_NO_MATCH)
	{
		//message text already exists -- don't overwrite
		Language::SetLanguage(oldLanguage);
		return;
	}

	ASSERT(!this->bIsDirty); //don't lose any updates to a text in memory
	
	//Add new language version of this message.
	UTF8ToUCS2(atts[3], strlen(atts[3]), this->wstrText);
	AddMessageText(this->eMessageID, this->wstrText.c_str());
	this->bIsLoaded = true;

	Language::SetLanguage(oldLanguage);
}
Пример #2
0
//*****************************************************************************
MESSAGE_ID CDbMessageText::Flush()
//Commits changes to the database.  If text was not bound, it will become bound
//to new message ID.
{
    ASSERT(CDbBase::IsOpen());
	if (this->bIsDirty)
	{
		if (this->eMessageID != UNBOUND_MESSAGE)
			ChangeMessageText(this->eMessageID, 
					(this->wstrText.size()) ? this->wstrText.c_str() : wszEmpty);
		else
			this->eMessageID = AddMessageText(
					(this->wstrText.size()) ? this->wstrText.c_str() : wszEmpty);
		this->bIsDirty = false;
	}
	return this->eMessageID;
}
Пример #3
0
//*****************************************************************************
MESSAGE_ID CDbMessageText::UpdateText()
//Commits changes to the database.  If text was not bound, it will become bound
//to new message ID.
{
	ASSERT(CDbBase::IsOpen());
	if (this->bIsDirty)
	{
		const Language::LANGUAGE curLanguage = Language::GetLanguage();
		if (this->bUseDefaultLanguage)
			Language::SetLanguage(Language::English);
		if (this->eMessageID != UNBOUND_MESSAGE)
			this->eMessageID = ChangeMessageText(this->eMessageID, 
					(this->wstrText.size()) ? this->wstrText.c_str() : wszEmpty);
		else
			this->eMessageID = AddMessageText(
					(this->wstrText.size()) ? this->wstrText.c_str() : wszEmpty);
		Language::SetLanguage(curLanguage);
		this->bIsDirty = false;
	}
	return this->eMessageID;
}
Пример #4
0
BOOL
ReadTxtAndOutputHdr(
    PCHAR pszTxtFile,
    FILE *fhTxt,
    FILE *fhHdr
    )
{
    ULONG LanguageId;
    PMESSAGE_INFO MessageInfo;
    PCHAR s, s1, TextPtr, SyntaxPhrase, MsgName, MsgComment;
    ULONG MsgId, MsgLang;
    BOOL CopyComments;
    BOOL Result = TRUE;
    int LineNumber;
    int State;

    MessageInfo = NULL;
    LineNumber = 0;
    CopyComments = FALSE;
    State = LOOKING_FOR_MSGID;
    while (fgets( LineBuffer, sizeof( LineBuffer ), fhTxt )) {
        LineNumber += 1;

        if (!(s = SkipWhiteSpace( LineBuffer ))) {
            if (LineNumber > 1) {
                fprintf( fhHdr, "\r\n" );
                }
            CopyComments = TRUE;
            continue;
            }

tryagain:
        if (*s == ';') {
            if (CopyComments) {
                if (State == LOOKING_FOR_MSGID) {
                    State = PROCESSING_COMMENTS;
                    fprintf( fhHdr, "//\r\n" );
                    }

                if (State == PROCESSING_COMMENTS) {
                    fprintf( fhHdr, "//%s", s+1 );
                    }
                }
            else {
                fprintf( fhHdr, "//%s", s+1 );
                }
            continue;
            }

        if (State == PROCESSING_COMMENTS) {
            State = LOOKING_FOR_MSGID;
            fprintf( fhHdr, "//\r\n" );
            }

        if (State == LOOKING_FOR_MSGID) {
            SyntaxPhrase = "MessageId=";
            if (_strnicmp( s, SyntaxPhrase, strlen( SyntaxPhrase ) )) {
syntaxerr:
                fprintf( stderr,
                         "%s(%d) : error : invalid syntax - %s\n",
                         pszTxtFile,
                         LineNumber,
                         SyntaxPhrase
                       );

                Result = FALSE;
                }
            s += strlen( SyntaxPhrase );
            if (s1 = FindWhiteSpace( s ))  {
                *s1++ = '\0';
                }

            SyntaxPhrase = "MessageId=value";
            if (!CharToInteger( s, 0, &MsgId )) {
                goto syntaxerr;
                }

            SyntaxPhrase = "SymbolicName=";
            if (!(s = SkipWhiteSpace( s1 ))) {
                goto syntaxerr;
                }
            if (_strnicmp( s, SyntaxPhrase, strlen( SyntaxPhrase ) )) {
                goto syntaxerr;
                }
            MsgName = s + strlen( SyntaxPhrase );

            if (s = FindWhiteSpace( MsgName ))  {
                *s++ = '\0';
                MsgComment = SkipWhiteSpace( s );
                }

            MessageInfo = AddMessageInfo( MsgId, MsgName );
            fprintf( fhHdr, "//\r\n// MessageId: %s\r\n//\r\n// MessageText:\r\n//\r\n",
                     MessageInfo->Name
                   );

            State = LOOKING_FOR_LANGUAGE;
            }
        else
        if (State == LOOKING_FOR_LANGUAGE) {
            SyntaxPhrase = "Language=";
            if (_strnicmp( s, SyntaxPhrase, strlen( SyntaxPhrase ) )) {
                State = LOOKING_FOR_MSGID;
                goto tryagain;
                }

            s += strlen( SyntaxPhrase );
            if ((LanguageId = FindLanguageId( s ))) {
                State = LOOKING_FOR_PERIOD;
                TextPtr = TextBuffer;
                *TextPtr = '\0';
                }
            else {
                goto syntaxerr;
                }
            }

        else
        if (State == LOOKING_FOR_PERIOD) {
            if (!strcmp( s, ".\r\n" )) {
                State = LOOKING_FOR_LANGUAGE;
                *s = '\0';
                if (!AddMessageText( MessageInfo, LanguageId, TextBuffer )) {
                    SyntaxPhrase = "Message Text";
                    goto syntaxerr;
                    }
                }
            else {
                strcpy( TextPtr, s );
                TextPtr += strlen( s );
                }

            if (LanguageId == LANG_ENGLISH) {
                if (State == LOOKING_FOR_PERIOD) {
                    fprintf( fhHdr, "//  %s", s );
                    }
                else {
                    fprintf( fhHdr, "//\r\n#define %-32s %5ld  %s\r\n\r\n",
                             MessageInfo->Name,
                             MessageInfo->Id,
                             MsgComment ? MsgComment : ""
                           );
                    }
                }
            }
        }

    return( Result );
}
Пример #5
0
bool SetMsgText( char *message, unsigned *conditions )
/****************************************************/
{
    char        *equal,*comma1,*comma2;
    address     addr,buff_addr;
    long        buff_len;
    size_t      sym_len;
    long        num_returns;
    cmd_list    *cmds;

#define IS_DEBUGGER_COMMAND(m,x)   (memcmp( m, DEBUGGER_COMMAND( x ), sizeof( DEBUGGER_COMMAND( x ) ) - 1 ) == 0)
#define DEBUGGER_COMMAND_SKIP(m,x)   m += sizeof( DEBUGGER_COMMAND( x ) ) - 1

    if( IS_DEBUGGER_COMMAND( message, THREADID ) ) {
        DEBUGGER_COMMAND_SKIP( message, THREADID );
        equal = strchr( message, '=' );
        if( equal == NULL )
            return( true );
        *equal = NULLCHAR;
        CheckForNewThreads( false );
        NameThread( strtoul( message, NULL, 16 ), equal + 1 );
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, SETTRUE ) ) {
        DEBUGGER_COMMAND_SKIP( message, SETTRUE );
        if( DlgScanDataAddr( message, &addr ) ) {
            ProgPoke( addr, "\x1", 1 );
        }
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, EXECUTE ) ) {
        DEBUGGER_COMMAND_SKIP( message, EXECUTE );
        if( InCall == 0 ) {
            cmds = AllocCmdList( "go/keep", sizeof( "go/keep" ) - 1 );
            PushCmdList( cmds );
            TypeInpStack( INP_HOOK );
            FreeCmdList( cmds );
        }
        cmds = AllocCmdList( message, strlen( message ) );
        PushCmdList( cmds );
        TypeInpStack( INP_HOOK );
        FreeCmdList( cmds );
        *conditions |= COND_STOP;
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, MESSAGE ) ) {
        DEBUGGER_COMMAND_SKIP( message, MESSAGE );
        AddMessageText( message );
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, LOOKUP ) ) {
        DEBUGGER_COMMAND_SKIP( message, LOOKUP );
        comma1 = strchr( message, ',' );
        if( comma1 == NULL )
            return( true );
        *comma1++ = NULLCHAR;
        comma2 = strchr( comma1, ',' );
        if( comma2 == NULL )
            return( true );
        *comma2++ = NULLCHAR;
        if( !DlgScanDataAddr( message, &addr ) )
            return( true );
        if( !DlgScanDataAddr( comma1, &buff_addr ) )
            return( true );
        if( !DlgScanLong( comma2, &buff_len ) )
            return( true );
        CnvNearestAddr( addr, TxtBuff, TXT_LEN );
        sym_len = strlen( TxtBuff ) + 1;
        if( sym_len > buff_len ) {
            sym_len = (size_t)buff_len;
            TxtBuff[sym_len - 1] = NULLCHAR;
        }
        ProgPoke( buff_addr, TxtBuff, sym_len );
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, LOADMODULE ) ) {
        DEBUGGER_COMMAND_SKIP( message, LOADMODULE );
        comma1 = strchr( message, ',' );
        if( comma1 == NULL )
            return( true );
        *comma1++ = NULLCHAR;
        if( !DlgScanDataAddr( message, &addr ) )
            return( true );
        SymUserModLoad( comma1, &addr );
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, UNLOADMODULE ) ) {
        DEBUGGER_COMMAND_SKIP( message, UNLOADMODULE );
        SymUserModUnload( message );
        return( false );
    } else if( IS_DEBUGGER_COMMAND( message, BREAKRETURN ) ) {
        DEBUGGER_COMMAND_SKIP( message, BREAKRETURN );
        if( !DlgScanLong( message, &num_returns ) )
            return( true );
        // TODO: do something with num_returns value
        return( false );
    } else {
        AddMessageText( message );
        return( true );
    }

#undef IS_DEBUGGER_COMMAND
#undef DEBUGGER_COMMAND_SKIP

}
Пример #6
0
bool SetMsgText( char *message, unsigned *conditions )
/****************************************************/
{
    char        *equal,*comma1,*comma2;
    address     addr,buff_addr;
    long        buff_len,sym_len;
    long        num_returns;
    cmd_list    *cmds;

    if( memcmp( message, DEBUGGER_THREADID_COMMAND,
                sizeof( DEBUGGER_THREADID_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_THREADID_COMMAND ) - 1;
        equal = strchr( message, '=' );
        if( equal == NULL ) return( TRUE );
        *equal = '\0';
        CheckForNewThreads( FALSE );
        NoCRLF( equal + 1 );
        NameThread( strtoul( message, NULL, 16 ), equal + 1 );
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_SETTRUE_COMMAND,
                sizeof( DEBUGGER_SETTRUE_COMMAND ) - 1 ) == 0 ) {
        unsigned old = NewCurrRadix( 16 );
        NoCRLF( message );
        if( DlgScanDataAddr( message + sizeof( DEBUGGER_SETTRUE_COMMAND ) - 1, &addr ) ) {
            ProgPoke( addr, "\x1", 1 );
        }
        NewCurrRadix( old );
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_EXECUTE_COMMAND,
                sizeof( DEBUGGER_EXECUTE_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_EXECUTE_COMMAND ) - 1;
        NoCRLF( message );
        if( InCall == 0 ) {
            cmds = AllocCmdList( "go/keep", strlen( "go/keep" ) );
            PushCmdList( cmds );
            TypeInpStack( INP_HOOK );
            FreeCmdList( cmds );
        }
        cmds = AllocCmdList( message, strlen( message ) );
        PushCmdList( cmds );
        TypeInpStack( INP_HOOK );
        FreeCmdList( cmds );
        *conditions |= COND_STOP;
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_MESSAGE_COMMAND,
                sizeof( DEBUGGER_MESSAGE_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_MESSAGE_COMMAND ) - 1;
        NoCRLF( message );
        AddMessageText( message );
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_LOOKUP_COMMAND,
                sizeof( DEBUGGER_LOOKUP_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_LOOKUP_COMMAND ) - 1;
        comma1 = strchr( message, ',' );
        if( comma1 == NULL ) return( TRUE );
        *comma1++ = '\0';
        comma2 = strchr( comma1, ',' );
        if( comma2 == NULL ) return( TRUE );
        *comma2++ = '\0';
        NoCRLF( comma2 );
        if( !DlgScanDataAddr( message, &addr ) )
            return( TRUE );
        if( !DlgScanDataAddr( comma1, &buff_addr ) )
            return( TRUE );
        if( !DlgScanLong( comma2, &buff_len ) )
            return( TRUE );
        CnvNearestAddr( addr, TxtBuff, TXT_LEN );
        sym_len = strlen( TxtBuff ) + 1;
        if( sym_len > buff_len ) {
            TxtBuff[buff_len - 1] = '\0';
            sym_len = buff_len;
        }
        ProgPoke( buff_addr, TxtBuff, sym_len );
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_LOADMODULE_COMMAND,
                sizeof( DEBUGGER_LOADMODULE_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_LOADMODULE_COMMAND ) - 1;
        comma1 = strchr( message, ',' );
        if( comma1 == NULL )
            return( TRUE );
        *comma1++ = '\0';
        NoCRLF( comma1 );
        if( !DlgScanDataAddr( message, &addr ) )
            return( TRUE );
        SymUserModLoad( comma1, &addr );
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_UNLOADMODULE_COMMAND,
                sizeof( DEBUGGER_UNLOADMODULE_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_UNLOADMODULE_COMMAND ) - 1;
        NoCRLF( message );
        SymUserModUnload( message );
        return( FALSE );
    } else if( memcmp( message, DEBUGGER_BREAKRETURN_COMMAND,
                sizeof( DEBUGGER_BREAKRETURN_COMMAND ) - 1 ) == 0 ) {
        message += sizeof( DEBUGGER_BREAKRETURN_COMMAND ) - 1;
        NoCRLF( message );
        if( !DlgScanLong( message, &num_returns ) )
            return( TRUE );
        // TODO: do something with num_returns value
        return( FALSE );
    } else {
        AddMessageText( message );
        return( TRUE );
    }
}