/*-------------------------------------------------------------------
 * Rijndael encryption function. Takes 16-byte input and creates
 * 16-byte output (using round keys already derived from 16-byte
 * key).
 *-----------------------------------------------------------------*/
void RijndaelEncrypt( u8 input[16], u8 output[16] )
{
  u8 state[4][4];
  int i, r;

  /* initialise state array from input byte string */
  for (i=0; i<16; i++)
    state[i & 0x3][i>>2] = input[i];

  /* add first round_key */
  KeyAdd(state, roundKeys, 0);

  /* do lots of full rounds */
  for (r=1; r<=9; r++) {
    ByteSub(state);
    ShiftRow(state);
    MixColumn(state);
    KeyAdd(state, roundKeys, r);
  }

  /* final round */
  ByteSub(state);
  ShiftRow(state);
  KeyAdd(state, roundKeys, r);

  /* produce output byte string from state array */
  for (i=0; i<16; i++) {
    output[i] = state[i & 0x3][i>>2];
  }

  return;
} /* end of function RijndaelEncrypt */
Beispiel #2
0
/*
 * AddCurrentMouseEvent - add current mouse event to the override buffer
 */
void AddCurrentMouseEvent( void )
{
    KeyAdd( VI_KEY( MOUSEEVENT ) );
    KeyAdd( LastMouseEvent );
    KeyAdd( MouseRow );
    KeyAdd( MouseCol );
    KeyAdd( MouseStatus );

} /* AddCurrentMouseEvent */
Beispiel #3
0
static bool fileComplete( input_buffer *input, vi_key first_event )
{
    bool        exit, done;
    vi_rc       rc;
    vi_key      event;
    int         old_len;

    exit = false;
    if( input->curr_pos != strlen( input->buffer ) ) {
        MyBeep();
    } else {
        saveStr( input );
        old_len = strlen( input->buffer ) - 1;
        rc = StartFileComplete( input->buffer, old_len,
                                 input->buffer_length, first_event );
        if( rc > ERR_NO_ERR ) {
            MyBeep();
        } else {
            if( rc != FILE_COMPLETE ) {
                done = false;
                do {
                    endColumn( input );
                    displayLine( input );
                    event = GetNextEvent( true );
                    switch( event ) {
                    case VI_KEY( FAKEMOUSE ):
                    case VI_KEY( MOUSEEVENT ):
                    case VI_KEY( TAB ):
                    case VI_KEY( SHIFT_TAB ):
                    case VI_KEY( UP ):
                    case VI_KEY( DOWN ):
                    case VI_KEY( LEFT ):
                    case VI_KEY( RIGHT ):
                    case VI_KEY( PAGEDOWN ):
                    case VI_KEY( PAGEUP ):
                    case VI_KEY( ALT_END ):
                        rc = ContinueFileComplete( input->buffer, old_len,
                                                    input->buffer_length, event );
                        if( rc != ERR_NO_ERR ) {
                            FinishFileComplete();
                            if( rc == FILE_COMPLETE_ENTER ) {
                                exit = true;
                            }
                            done = true;
                        }
                        old_len = strlen( input->buffer );
                        break;
                    default:
                        KeyAdd( event );
                        PauseFileComplete();
                        done = true;
                    }
                } while( !done );
            }
        }
    }
    return( exit );

} /* fileComplete */
Beispiel #4
0
WINEXPORT LRESULT CALLBACK CommandWindowProc( HWND hwnd, UINT msg, WPARAM w, LPARAM l )
{
    PAINTSTRUCT ps;
    HDC         hdc;
    window_id   wid;

    switch( msg ) {
    case WM_CREATE:
        command_window_id = hwnd;
        SET_WNDINFO( hwnd, (LONG_PTR)&CommandWindow );
        break;
    case WM_SETFOCUS:
        /* turn on caret */
        NewCursor( hwnd, EditVars.NormalCursorType );
        break;
    case WM_KILLFOCUS:
        /* turn off the caret */
        MyHideCaret( hwnd );
        DestroyCaret();
        wid = (window_id)w;
        if( !BAD_ID( wid ) && ( wid == root_window_id || GetWindow( wid, GW_OWNER ) == edit_container_id ) ) {
            /* hmmm... losing focus to one of our own windows - suicide */
            if( ReadingAString ) {
                KeyAdd( VI_KEY( ESC ) );
            }
        }
        break;
    case WM_KEYDOWN:
        if( WindowsKeyPush( w, HIWORD( l ) ) ) {
            return( 0 );
        }
        break;
    case WM_PAINT:
        hdc = BeginPaint( hwnd, &ps );
        FillRect( hdc, &ps.rcPaint, ColorBrush( WIN_TEXT_BACKCOLOR( &CommandWindow ) ) );
        /* this will cause the command window to redraw itself in readstr.c */
        KeyAdd( VI_KEY( ALT_END ) );
        EndPaint( hwnd, &ps );
        break;
    case WM_DESTROY:
        command_window_id = NO_WINDOW;
        break;
    }
    return( DefWindowProc( hwnd, msg, w, l ) );
}
Beispiel #5
0
/*
 * IMMenuKey - process menu keys from insert mode
 */
vi_rc IMMenuKey( void )
{
    if( IsMenuHotKey( LastEvent ) ) {
        DoneCurrentInsert( TRUE );
        KeyAdd( LastEvent );
        EditFlags.ReturnToInsertMode = TRUE;
    }
    return( ERR_NO_ERR );

} /* IMMenuKey */
Beispiel #6
0
static bool mouseHandler( window_id wid, int x, int y )
{
    /* unused parameters */ (void)x; (void)y;

    if( wid != thisWindow ) {
        if( LastMouseEvent == VI_MOUSE_PRESS ) {
            KeyAdd( VI_KEY( ESC ) );
            AddCurrentMouseEvent();
        }
    }
    return( false );

} /* mouseHandler */
Beispiel #7
0
static bool mouseHandler( window_id wid, int x, int y )
{
    x = x;
    y = y;
    if( wid != thisWindow ) {
        if( LastMouseEvent == MOUSE_PRESS ) {
            KeyAdd( VI_KEY( ESC ) );
            AddCurrentMouseEvent();
        }
    }
    return( false );

} /* mouseHandler */
Beispiel #8
0
/*
 * KeyAddString - add an entire string
 */
void KeyAddString( const char *str )
{
    key_map     scr;
    vi_rc       rc;
    vi_key      *keys;

    rc = AddKeyMap( &scr, str );
    if( rc == ERR_NO_ERR ) {
        for( keys = scr.data; *keys != VI_KEY( NULL ); ++keys ) {
            KeyAdd( *keys );
        }
    }
    MemFree( scr.data );

} /* KeyAddString */
Beispiel #9
0
/*
 * KeyAddString - add an entire string
 */
void KeyAddString( char *str )
{
    key_map     scr;
    vi_rc       rc;
    vi_key      *s;

    rc = AddKeyMap( &scr, str );
    if( rc == ERR_NO_ERR ) {
        s = scr.data;
        while( *s != 0 ) {
            KeyAdd( *s );
            s++;
        }
    }
    MemFree( scr.data );

} /* KeyAddString */
Beispiel #10
0
static void doHistorySearch( input_buffer *input )
{
    int             curr;
    char            *str;
    vi_key          event;

    curr = input->h->curr;
    str = alloca( strlen( input->buffer ) + 1 );
    strcpy( str, input->buffer );
    event = VI_KEY( CTRL_TAB );
    while( curr != -1 ) {
        if( event == VI_KEY( ALT_TAB ) || event == VI_KEY( CTRL_TAB ) ) {
            saveStr( input );
            curr = searchHistory( input, str, curr );
            displayLine( input );
            event = GetNextEvent( true );
            continue;
        }
        KeyAdd( event );
        return;
    }

} /* doHistorySearch */
Beispiel #11
0
vi_rc Change( range *r )
{
    int         scol, ecol;
    int         tmp;
    vi_rc       rc;
    vi_key      key;
#ifndef __WIN__
    int         vecol;
#endif

    /*
     * change line ranges
     */
    if( r->start.line != r->end.line ) {
        StartUndoGroup( UndoStack );
        if( !r->line_based ) {
            rc = Cut( r->start.line, r->start.column, r->end.line, r->end.column, true );
            r->end.column = -1;
            scol = -1;
            ecol = -1;
        } else {
            if( r->start.line == CurrentPos.line ) {
                r->start.line++;
            } else {
                r->end.line--;
            }
            if( r->start.line <= r->end.line ) {
                rc = DeleteLineRange( r->start.line, r->end.line, 0 );
                if( rc != ERR_NO_ERR ) {
                    EndUndoGroup( UndoStack );
                    return( rc );
                }
            }
            scol = FindStartOfCurrentLine() - 1;
            ecol = CurrentLine->len - 1;
        }
        DCDisplayAllLines();
        rc = DeleteAndInsertText( scol, ecol );
        EndUndoGroup( UndoStack );
        return( rc );
    }

    /*
     * change text on current line
     */
    rc = ERR_NO_ERR;
    GoToLineNoRelCurs( r->start.line );
    ecol = r->end.column;
    scol = r->start.column;
#ifdef __WIN__
//    GetCurrentLine();
    strcpy( WorkLine->data, CurrentLine->data );
    tmp = WorkLine->data[ecol];
    WorkLine->data[ecol] = '$';
#else
    vecol = VirtualColumnOnCurrentLine( ecol + 1 );
    vecol--;
    ExpandTabsInABuffer( CurrentLine->data, CurrentLine->len, WorkLine->data, EditVars.MaxLine + 1 );
    WorkLine->len = strlen( WorkLine->data );
    tmp = WorkLine->data[vecol];
    WorkLine->data[vecol] = '$';
#endif
    if( WorkLine->len == 0 ) {
        WorkLine->data[1] = '\0';
    }
    EditFlags.InsertModeActive = true;
    GoToColumn( scol + 1, CurrentLine->len );
    EditFlags.InsertModeActive = false;
    DisplayWorkLine( true );
    UnselectRegion();
    DCUpdate();
#ifndef __WIN__
    HiliteAColumnRange( CurrentPos.line, scol, ecol );
#endif

    /*
     * now, get ready to do change
     */
    key = GetNextEvent( false );
#ifdef __WIN__
    WorkLine->data[ecol] = tmp;
#else
    WorkLine->data[vecol] = tmp;
#endif
    DisplayWorkLine( true );
    if( key == VI_KEY( ESC ) && !EditFlags.ChangeLikeVI ) {
        WorkLine->len = -1;
        GoToColumn( scol + 1, CurrentLine->len );
    } else {
        KeyAdd( key );
        rc = DeleteAndInsertText( scol, ecol );
    }
    return( rc );

} /* Change */
Beispiel #12
0
void CreateTF5000Keys( keyCodes_Struct *keyCodes )
{
    KeyDestroy( keyCodes );												// clear out any old keycodes, and allocated memory

    KeyAdd( keyCodes, RKEY_Mute, "Mute" );
    KeyAdd( keyCodes, RKEY_Mute, "UHF" );
    KeyAdd( keyCodes, RKEY_TvSat, "TV/Sat" );
    KeyAdd( keyCodes, RKEY_Sleep, "Sleep" );

    KeyAdd( keyCodes, RKEY_1, "1" );
    KeyAdd( keyCodes, RKEY_2, "2" );
    KeyAdd( keyCodes, RKEY_3, "3" );
    KeyAdd( keyCodes, RKEY_4, "4" );
    KeyAdd( keyCodes, RKEY_5, "5" );
    KeyAdd( keyCodes, RKEY_6, "6" );
    KeyAdd( keyCodes, RKEY_7, "7" );
    KeyAdd( keyCodes, RKEY_8, "8" );
    KeyAdd( keyCodes, RKEY_9, "9" );
    KeyAdd( keyCodes, RKEY_0, "0" );
    KeyAdd( keyCodes, RKEY_Recall, "Recall" );
    KeyAdd( keyCodes, RKEY_Info, "Info" );

    KeyAdd( keyCodes, RKEY_VolUp, "Right Arrow (volume up)" );
    KeyAdd( keyCodes, RKEY_VolDown, "Left Arrow (volume down)" );
    KeyAdd( keyCodes, RKEY_ChUp, "Up Arrow (channel up)" );
    KeyAdd( keyCodes, RKEY_ChDown, "Down Arrow (channel down)" );
    KeyAdd( keyCodes, RKEY_Ok, "Ok" );
    KeyAdd( keyCodes, RKEY_Menu, "Menu" );
    KeyAdd( keyCodes, RKEY_Guide, "Guide" );
    KeyAdd( keyCodes, RKEY_TvRadio, "TV/Radio" );
    KeyAdd( keyCodes, RKEY_AudioTrk, "Audio Track" );
    KeyAdd( keyCodes, RKEY_Subt, "Subtitle" );
    KeyAdd( keyCodes, RKEY_Teletext, "Teletext" );
    KeyAdd( keyCodes, RKEY_Exit, "Exit" );
    KeyAdd( keyCodes, RKEY_Fav, "Fav" );

    KeyAdd( keyCodes, RKEY_Forward, "Fast Forward" );
    KeyAdd( keyCodes, RKEY_Rewind, "Rewind" );
    KeyAdd( keyCodes, RKEY_Play, "Play" );
    KeyAdd( keyCodes, RKEY_Pause, "Pause" );
    KeyAdd( keyCodes, RKEY_Record, "Record" );
    KeyAdd( keyCodes, RKEY_Stop, "Stop" );
    KeyAdd( keyCodes, RKEY_Slow, "Slow Motion" );
    KeyAdd( keyCodes, RKEY_Prev, "Previous" );
    KeyAdd( keyCodes, RKEY_PlayList, "File List" );
    KeyAdd( keyCodes, RKEY_Next, "Next" );

    KeyAdd( keyCodes, RKEY_Red, "Red" );
    KeyAdd( keyCodes, RKEY_Green, "Green" );
    KeyAdd( keyCodes, RKEY_Yellow, "Yellow" );
    KeyAdd( keyCodes, RKEY_Blue, "Blue" );

    KeyAdd( keyCodes, RKEY_Sat, "Sat" );
    KeyAdd( keyCodes, RKEY_White, "White" );
}
Beispiel #13
0
//---------------
//
void CreateTF5800Keys( keyCodes_Struct *keyCodes )
{
    KeyDestroy( keyCodes );												// clear out any old keycodes, and allocated memory

    KeyAdd( keyCodes, 0x1000c, "Mute" );
    KeyAdd( keyCodes, 0x10018, "TV/Radio or List" );
    KeyAdd( keyCodes, 0x10022, "TV/Sat" );
    KeyAdd( keyCodes, 0x10010, "Opt" );

    KeyAdd( keyCodes, 0x10001, "1" );
    KeyAdd( keyCodes, 0x10002, "2" );
    KeyAdd( keyCodes, 0x10003, "3" );
    KeyAdd( keyCodes, 0x10004, "4" );
    KeyAdd( keyCodes, 0x10005, "5" );
    KeyAdd( keyCodes, 0x10006, "6" );
    KeyAdd( keyCodes, 0x10007, "7" );
    KeyAdd( keyCodes, 0x10008, "8" );
    KeyAdd( keyCodes, 0x10009, "9" );
    KeyAdd( keyCodes, 0x10000, "0" );
    KeyAdd( keyCodes, 0x1000b, "Recall" );
    KeyAdd( keyCodes, 0x10014, "Info" );

    KeyAdd( keyCodes, 0x1000f, "Right Arrow" );
    KeyAdd( keyCodes, 0x10015, "Left Arrow" );
    KeyAdd( keyCodes, 0x10012, "Up Arrow" );
    KeyAdd( keyCodes, 0x1001d, "Down Arrow" );
    KeyAdd( keyCodes, 0x1001e, "Ok" );
    KeyAdd( keyCodes, 0x1001c, "Menu" );
    KeyAdd( keyCodes, 0x10016, "Guide" );
//    KeyAdd( keyCodes, 0x10018, "List" );								// can't have duplicates
    KeyAdd( keyCodes, 0x10017, "Exit" );

    KeyAdd( keyCodes, 0x1003a, "Fast Forward" );
    KeyAdd( keyCodes, 0x10038, "Rewind" );
    KeyAdd( keyCodes, 0x10039, "Play" );
    KeyAdd( keyCodes, 0x1001a, "Pause" );
    KeyAdd( keyCodes, 0x1003d, "Record" );
    KeyAdd( keyCodes, 0x1003c, "Stop" );
    KeyAdd( keyCodes, 0x1003b, "Slow Motion" );
    KeyAdd( keyCodes, 0x10041, "PIP" );
    KeyAdd( keyCodes, 0x10042, "File List" );
    KeyAdd( keyCodes, 0x10043, "Text" );

    KeyAdd( keyCodes, 0x1003f, "Red" );
    KeyAdd( keyCodes, 0x10024, "Green" );
    KeyAdd( keyCodes, 0x10025, "Yellow" );
    KeyAdd( keyCodes, 0x10026, "Blue" );

    KeyAdd( keyCodes, 0x10040, "PIP Swap" );
    KeyAdd( keyCodes, 0x1003e, "White" );
}