Annotation of mstools/samples/comm/tty.h, revision 1.1

1.1     ! root        1: //---------------------------------------------------------------------------
        !             2: //
        !             3: //  Module: tty.h
        !             4: //
        !             5: //  Purpose:
        !             6: //     This is the header file for the TTY sample.
        !             7: //
        !             8: //  Development Team:
        !             9: //     Bryan A. Woodruff
        !            10: //
        !            11: //  History:   Date       Author      Comment
        !            12: //              5/ 9/91   BryanW      Wrote it.
        !            13: //
        !            14: //---------------------------------------------------------------------------
        !            15: //
        !            16: //  Written by Microsoft Product Support Services, Windows Developer Support.
        !            17: //  Copyright (c) 1991 Microsoft Corporation.  All Rights Reserved.
        !            18: //
        !            19: //---------------------------------------------------------------------------
        !            20: 
        !            21: #define USECOMM      // yes, we need the COMM API
        !            22: 
        !            23: #ifndef WIN32
        !            24: #define WIN31        // this is a Windows 3.1 application
        !            25: #endif
        !            26: 
        !            27: #include <windows.h>
        !            28: #include <commdlg.h>
        !            29: #include <string.h>
        !            30: 
        !            31: #include "version.h"
        !            32: #include "resource.h"
        !            33: 
        !            34: // constant definitions
        !            35: 
        !            36: #ifdef WIN32
        !            37: #define GWL_NPTTYINFO        0
        !            38: #define TTYEXTRABYTES        sizeof( LONG )
        !            39: #else
        !            40: #define GWW_NPTTYINFO        0
        !            41: #define TTYEXTRABYTES        sizeof( WORD )
        !            42: #endif
        !            43: 
        !            44: #define ABOUTDLG_USEBITMAP  1
        !            45: 
        !            46: #define ATOM_TTYINFO       0x100
        !            47: 
        !            48: // terminal size
        !            49: 
        !            50: #define MAXROWS         25
        !            51: #define MAXCOLS         80
        !            52: 
        !            53: #define MAXBLOCK        80
        !            54: 
        !            55: #define MAXLEN_TEMPSTR  81
        !            56: 
        !            57: #define RXQUEUE         4096
        !            58: #define TXQUEUE         4096
        !            59: 
        !            60: // cursor states
        !            61: 
        !            62: #define CS_HIDE         0x00
        !            63: #define CS_SHOW         0x01
        !            64: 
        !            65: // Flow control flags
        !            66: 
        !            67: #define FC_DTRDSR       0x01
        !            68: #define FC_RTSCTS       0x02
        !            69: #define FC_XONXOFF      0x04
        !            70: 
        !            71: // ascii definitions
        !            72: 
        !            73: #define ASCII_BEL       0x07
        !            74: #define ASCII_BS        0x08
        !            75: #define ASCII_LF        0x0A
        !            76: #define ASCII_CR        0x0D
        !            77: #define ASCII_XON       0x11
        !            78: #define ASCII_XOFF      0x13
        !            79: 
        !            80: // we are going to fake the CN_EVENT notifications using another
        !            81: // thread in Win32
        !            82: 
        !            83: #ifdef WIN32
        !            84: #define CN_EVENT 0x04
        !            85: #endif
        !            86: 
        !            87: // data structures
        !            88: 
        !            89: typedef struct tagTTYINFO
        !            90: {
        !            91: #ifdef WIN32
        !            92:    HANDLE  idComDev ;
        !            93: #else
        !            94:    int     idComDev ;
        !            95: #endif
        !            96:    BYTE    bPort, abScreen[ MAXROWS * MAXCOLS ] ;
        !            97:    BOOL    fConnected, fXonXoff, fLocalEcho, fNewLine, fAutoWrap,
        !            98:            fUseCNReceive, fDisplayErrors;
        !            99:    BYTE    bByteSize, bFlowCtrl, bParity, bStopBits ;
        !           100: #ifdef WIN32
        !           101:    DWORD   dwBaudRate ;
        !           102:    WORD    wCursorState ;
        !           103: #else
        !           104:    WORD    wBaudRate, wCursorState ;
        !           105: #endif
        !           106:    HFONT   hTTYFont ;
        !           107:    LOGFONT lfTTYFont ;
        !           108:    DWORD   rgbFGColor ;
        !           109:    int     xSize, ySize, xScroll, yScroll, xOffset, yOffset,
        !           110:            nColumn, nRow, xChar, yChar ;
        !           111: #ifdef WIN32
        !           112:    HANDLE      hPostEvent, hWatchThread, hWatchEvent ;
        !           113:    HWND        hTermWnd ;
        !           114:    DWORD       dwThreadID ;
        !           115:    OVERLAPPED  osWrite, osRead ;
        !           116: #endif
        !           117: 
        !           118: } TTYINFO, NEAR *NPTTYINFO ;
        !           119: 
        !           120: // macros ( for easier readability )
        !           121: 
        !           122: #ifdef WIN32
        !           123: #define GETHINST( x )  ((HINSTANCE) GetWindowLong( x, GWL_HINSTANCE ))
        !           124: #define GETNPTTYINFO( x ) ((NPTTYINFO) GetWindowLong( x, GWL_NPTTYINFO ))
        !           125: #define SETNPTTYINFO( x, y ) SetWindowLong( x, GWL_NPTTYINFO, (LONG) y )
        !           126: #else
        !           127: #define GETHINST( x )  ((HINSTANCE) GetWindowWord( x, GWW_HINSTANCE ))
        !           128: #define GETNPTTYINFO( x ) ((NPTTYINFO) GetWindowWord( x, GWW_NPTTYINFO ))
        !           129: #define SETNPTTYINFO( x, y ) SetWindowWord( x, GWW_NPTTYINFO, (WPARAM) y )
        !           130: #endif
        !           131: 
        !           132: #define COMDEV( x ) (x -> idComDev)
        !           133: #define PORT( x )   (x -> bPort)
        !           134: #define SCREEN( x ) (x -> abScreen)
        !           135: #define CONNECTED( x ) (x -> fConnected)
        !           136: #define XONXOFF( x ) (x -> fXonXoff)
        !           137: #define LOCALECHO( x ) (x -> fLocalEcho)
        !           138: #define NEWLINE( x ) (x -> fNewLine)
        !           139: #define AUTOWRAP( x ) (x -> fAutoWrap)
        !           140: #define BYTESIZE( x ) (x -> bByteSize)
        !           141: #define FLOWCTRL( x ) (x -> bFlowCtrl)
        !           142: #define PARITY( x ) (x -> bParity)
        !           143: #define STOPBITS( x ) (x -> bStopBits)
        !           144: #ifdef WIN32
        !           145: #define BAUDRATE( x ) (x -> dwBaudRate)
        !           146: #else
        !           147: #define BAUDRATE( x ) (x -> wBaudRate)
        !           148: #endif
        !           149: #define CURSORSTATE( x ) (x -> wCursorState)
        !           150: #define HTTYFONT( x ) (x -> hTTYFont)
        !           151: #define LFTTYFONT( x ) (x -> lfTTYFont)
        !           152: #define FGCOLOR( x ) (x -> rgbFGColor)
        !           153: #define XSIZE( x ) (x -> xSize)
        !           154: #define YSIZE( x ) (x -> ySize)
        !           155: #define XSCROLL( x ) (x -> xScroll)
        !           156: #define YSCROLL( x ) (x -> yScroll)
        !           157: #define XOFFSET( x ) (x -> xOffset)
        !           158: #define YOFFSET( x ) (x -> yOffset)
        !           159: #define COLUMN( x ) (x -> nColumn)
        !           160: #define ROW( x ) (x -> nRow)
        !           161: #define XCHAR( x ) (x -> xChar)
        !           162: #define YCHAR( x ) (x -> yChar )
        !           163: #define USECNRECEIVE( x ) (x -> fUseCNReceive)
        !           164: #define DISPLAYERRORS( x ) (x -> fDisplayErrors)
        !           165: 
        !           166: #ifdef WIN32
        !           167: #define POSTEVENT( x ) (x -> hPostEvent)
        !           168: #define TERMWND( x ) (x -> hTermWnd)
        !           169: #define HTHREAD( x ) (x -> hWatchThread)
        !           170: #define THREADID( x ) (x -> dwThreadID)
        !           171: #define WRITE_OS( x ) (x -> osWrite)
        !           172: #define READ_OS( x ) (x -> osRead)
        !           173: #endif
        !           174: 
        !           175: #define SET_PROP( x, y, z )  SetProp( x, MAKEINTATOM( y ), z )
        !           176: #define GET_PROP( x, y )     GetProp( x, MAKEINTATOM( y ) )
        !           177: #define REMOVE_PROP( x, y )  RemoveProp( x, MAKEINTATOM( y ) )
        !           178: 
        !           179: // global stuff
        !           180: 
        !           181: char     gszTTYClass[] = "TTYWndClass" ;
        !           182: char     gszAppName[] = "TTY" ;
        !           183: HANDLE   ghAccel ;
        !           184: 
        !           185: DWORD    BaudTable[] =
        !           186:          {
        !           187:             CBR_110, CBR_300, CBR_600, CBR_1200, CBR_2400,
        !           188:             CBR_4800, CBR_9600, CBR_14400, CBR_19200, CBR_38400,
        !           189:             CBR_56000, CBR_128000, CBR_256000
        !           190:          } ;
        !           191: 
        !           192: DWORD    ParityTable[] =
        !           193:          {
        !           194:             NOPARITY, EVENPARITY, ODDPARITY, MARKPARITY, SPACEPARITY
        !           195:          } ;
        !           196: 
        !           197: DWORD    StopBitsTable[] =
        !           198:          {
        !           199:             ONESTOPBIT, ONE5STOPBITS, TWOSTOPBITS
        !           200:          } ;
        !           201: 
        !           202: // CRT mappings to NT API
        !           203: 
        !           204: #define _fmemset   memset
        !           205: #define _fmemmove  memmove
        !           206: 
        !           207: // function prototypes (private)
        !           208: 
        !           209: BOOL NEAR InitApplication( HANDLE ) ;
        !           210: HWND NEAR InitInstance( HANDLE, int ) ;
        !           211: LRESULT NEAR CreateTTYInfo( HWND ) ;
        !           212: BOOL NEAR DestroyTTYInfo( HWND ) ;
        !           213: BOOL NEAR ResetTTYScreen( HWND, NPTTYINFO ) ;
        !           214: BOOL NEAR KillTTYFocus( HWND ) ;
        !           215: BOOL NEAR PaintTTY( HWND ) ;
        !           216: BOOL NEAR SetTTYFocus( HWND ) ;
        !           217: BOOL NEAR ScrollTTYHorz( HWND, WORD, WORD ) ;
        !           218: BOOL NEAR ScrollTTYVert( HWND, WORD, WORD ) ;
        !           219: BOOL NEAR SizeTTY( HWND, WORD, WORD ) ;
        !           220: BOOL NEAR ProcessTTYCharacter( HWND, BYTE ) ;
        !           221: BOOL NEAR WriteTTYBlock( HWND, LPSTR, int ) ;
        !           222: int NEAR ReadCommBlock( HWND, LPSTR, int ) ;
        !           223: BOOL NEAR WriteCommByte( HWND, BYTE ) ;
        !           224: BOOL NEAR MoveTTYCursor( HWND ) ;
        !           225: BOOL NEAR OpenConnection( HWND ) ;
        !           226: BOOL NEAR SetupConnection( HWND ) ;
        !           227: BOOL NEAR CloseConnection( HWND ) ;
        !           228: BOOL NEAR ProcessCOMMNotification( HWND, WPARAM, LPARAM ) ;
        !           229: VOID NEAR GoModalDialogBoxParam( HINSTANCE, LPCSTR, HWND, DLGPROC, LPARAM ) ;
        !           230: VOID NEAR FillComboBox( HINSTANCE, HWND, int, DWORD NEAR *, WORD, DWORD ) ;
        !           231: BOOL NEAR SelectTTYFont( HWND ) ;
        !           232: BOOL NEAR SettingsDlgInit( HWND ) ;
        !           233: BOOL NEAR SettingsDlgTerm( HWND ) ;
        !           234: 
        !           235: // function prototypes (public)
        !           236: 
        !           237: LRESULT FAR PASCAL TTYWndProc( HWND, UINT, WPARAM, LPARAM ) ;
        !           238: BOOL FAR PASCAL AboutDlgProc( HWND, UINT, WPARAM, LPARAM ) ;
        !           239: BOOL FAR PASCAL SettingsDlgProc( HWND, UINT, WPARAM, LPARAM ) ;
        !           240: 
        !           241: #ifdef WIN32
        !           242: DWORD FAR PASCAL CommWatchProc( LPSTR ) ;
        !           243: #endif
        !           244: 
        !           245: //---------------------------------------------------------------------------
        !           246: //  End of File: tty.h
        !           247: //---------------------------------------------------------------------------

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.