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

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

unix.superglobalmegacorp.com

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