Annotation of sbbs/sbbs3/ctrl/spyformunit.cpp, revision 1.1

1.1     ! root        1: /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
        !             2: 
        !             3: /* $Id: SpyFormUnit.cpp,v 1.8 2000/11/02 11:31:50 rswindell Exp $ */
        !             4: 
        !             5: /****************************************************************************
        !             6:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
        !             7:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
        !             8:  *                                                                                                                                                     *
        !             9:  * Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html         *
        !            10:  *                                                                                                                                                     *
        !            11:  * This program is free software; you can redistribute it and/or                       *
        !            12:  * modify it under the terms of the GNU General Public License                         *
        !            13:  * as published by the Free Software Foundation; either version 2                      *
        !            14:  * of the License, or (at your option) any later version.                                      *
        !            15:  * See the GNU General Public License for more details: gpl.txt or                     *
        !            16:  * http://www.fsf.org/copyleft/gpl.html                                                                                *
        !            17:  *                                                                                                                                                     *
        !            18:  * Anonymous FTP access to the most recent released source is available at     *
        !            19:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
        !            20:  *                                                                                                                                                     *
        !            21:  * Anonymous CVS access to the development source and modification history     *
        !            22:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
        !            23:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
        !            24:  *     (just hit return, no password is necessary)                                                     *
        !            25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
        !            26:  *                                                                                                                                                     *
        !            27:  * For Synchronet coding style and modification guidelines, see                                *
        !            28:  * http://www.synchro.net/source.html                                                                          *
        !            29:  *                                                                                                                                                     *
        !            30:  * You are encouraged to submit any modifications (preferably in Unix diff     *
        !            31:  * format) via e-mail to [email protected]                                                                      *
        !            32:  *                                                                                                                                                     *
        !            33:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
        !            34:  ****************************************************************************/
        !            35: 
        !            36:  #include <vcl.h>
        !            37: #pragma hdrstop
        !            38: 
        !            39: #include "MainFormUnit.h"
        !            40: #include "SpyFormUnit.h"
        !            41: #include "telnet.h"
        !            42: 
        !            43: #define SPYBUF_LEN  10000
        !            44: //---------------------------------------------------------------------------
        !            45: #pragma package(smart_init)
        !            46: #pragma link "Emulvt"
        !            47: #pragma resource "*.dfm"
        !            48: TSpyForm *SpyForm;
        !            49: //---------------------------------------------------------------------------
        !            50: __fastcall TSpyForm::TSpyForm(TComponent* Owner)
        !            51:     : TForm(Owner)
        !            52: {
        !            53:     Width=MainForm->SpyTerminalWidth;
        !            54:     Height=MainForm->SpyTerminalHeight;
        !            55:     KeyboardActive->Checked=MainForm->SpyTerminalKeyboardActive;
        !            56:     Terminal = new TEmulVT(this);
        !            57:     Terminal->Parent=this;
        !            58:     Terminal->Align=alClient;
        !            59:     Terminal->OnKeyPress=FormKeyPress;
        !            60:     Terminal->OnMouseUp=FormMouseUp;
        !            61:     ActiveControl=Terminal;
        !            62: }
        !            63: //---------------------------------------------------------------------------
        !            64: int strip_telnet(uchar *buf, int len)
        !            65: {
        !            66:     int i;
        !            67:     int telnet_cmd=0;
        !            68:     int newlen=0;
        !            69: 
        !            70:     for(i=0;i<len;i++) {
        !            71:         if(buf[i]==TELNET_IAC || telnet_cmd) {
        !            72:             if(telnet_cmd==1 && buf[i]==TELNET_IAC) {
        !            73:                 telnet_cmd=0;   /* escape IAC */
        !            74:                 continue;
        !            75:             }
        !            76:             if(telnet_cmd==1 && buf[i]<TELNET_WILL) {
        !            77:                 telnet_cmd=0;   /* single byte command */
        !            78:                 continue;
        !            79:             }
        !            80:             if(telnet_cmd>=2) {
        !            81:                 telnet_cmd=0;   /* two byte command */
        !            82:                 continue;
        !            83:             }
        !            84:             telnet_cmd++;
        !            85:             continue;
        !            86:         }
        !            87:         buf[newlen++]=buf[i];
        !            88:     }
        !            89:     return(newlen);
        !            90: }
        !            91: //---------------------------------------------------------------------------
        !            92: void __fastcall TSpyForm::SpyTimerTick(TObject *Sender)
        !            93: {
        !            94:     uchar   buf[1024];
        !            95:     int     rd;
        !            96: 
        !            97:     if(*outbuf==NULL)
        !            98:         return;
        !            99: 
        !           100:     rd=RingBufRead(*outbuf,buf,sizeof(buf)-1);
        !           101:     if(rd) {
        !           102:         rd=strip_telnet(buf,rd);
        !           103:         Terminal->WriteBuffer(buf,rd);
        !           104:         Timer->Interval=1;
        !           105:     } else
        !           106:         Timer->Interval=250;
        !           107: }
        !           108: //---------------------------------------------------------------------------
        !           109: void __fastcall TSpyForm::FormShow(TObject *Sender)
        !           110: {
        !           111:     if((*outbuf=(RingBuf*)malloc(sizeof(RingBuf)))==NULL) {
        !           112:         Terminal->WriteStr("Malloc failure!");
        !           113:         return;
        !           114:     }
        !           115:     RingBufInit(*outbuf,SPYBUF_LEN);
        !           116: 
        !           117:     Timer->Enabled=true;
        !           118: 
        !           119:     Terminal->Font=MainForm->SpyTerminalFont;
        !           120:     Terminal->Clear();
        !           121:     Terminal->WriteStr("*** Synchronet Local Spy ***\r\n\r\n");
        !           122:     Terminal->WriteStr("ANSI Terminal Emulation:"+CopyRight+"\r\n\r\n");
        !           123:     KeyboardActiveClick(Sender);
        !           124: }
        !           125: //---------------------------------------------------------------------------
        !           126: 
        !           127: void __fastcall TSpyForm::FormClose(TObject *Sender, TCloseAction &Action)
        !           128: {
        !           129:     Timer->Enabled=false;
        !           130:     if(*outbuf!=NULL) {
        !           131:         RingBufDispose(*outbuf);
        !           132:         free(*outbuf);
        !           133:         *outbuf=NULL;
        !           134:     }
        !           135:     MainForm->SpyTerminalWidth=Width;
        !           136:     MainForm->SpyTerminalHeight=Height;
        !           137:     MainForm->SpyTerminalKeyboardActive=KeyboardActive->Checked;
        !           138: }
        !           139: //---------------------------------------------------------------------------
        !           140: 
        !           141: void __fastcall TSpyForm::ChangeFontClick(TObject *Sender)
        !           142: {
        !           143:        TFontDialog *FontDialog=new TFontDialog(this);
        !           144: 
        !           145:     FontDialog->Font=MainForm->SpyTerminalFont;
        !           146:     FontDialog->Execute();
        !           147:     MainForm->SpyTerminalFont->Assign(FontDialog->Font);
        !           148:     Terminal->Font=MainForm->SpyTerminalFont;
        !           149:     delete FontDialog;
        !           150:     Terminal->UpdateScreen();
        !           151: }
        !           152: //---------------------------------------------------------------------------
        !           153: 
        !           154: void __fastcall TSpyForm::FormKeyPress(TObject *Sender, char &Key)
        !           155: {
        !           156:     if(KeyboardActive->Checked && inbuf!=NULL && *inbuf!=NULL)
        !           157:         RingBufWrite(*inbuf,&Key,1);
        !           158: 
        !           159: }
        !           160: //---------------------------------------------------------------------------
        !           161: 
        !           162: void __fastcall TSpyForm::KeyboardActiveClick(TObject *Sender)
        !           163: {
        !           164:     KeyboardActive->Checked=!KeyboardActive->Checked;
        !           165:     if(KeyboardActive->Checked)
        !           166:         Terminal->Cursor=crIBeam;
        !           167:     else
        !           168:         Terminal->Cursor=crDefault;
        !           169: }
        !           170: //---------------------------------------------------------------------------
        !           171: 
        !           172: void __fastcall TSpyForm::FormMouseUp(TObject *Sender, TMouseButton Button,
        !           173:       TShiftState Shift, int X, int Y)
        !           174: {
        !           175:     if(Button==mbRight)
        !           176:         PopupMenu->Popup(ClientOrigin.x+X,ClientOrigin.y+Y);
        !           177: }
        !           178: //---------------------------------------------------------------------------
        !           179: 
        !           180: 

unix.superglobalmegacorp.com

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