ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

tkeydef.cpp
Go to the documentation of this file.
00001 
00002 //Telnet Win32 : an ANSI telnet client.
00003 //Copyright (C) 1998-2000 Paul Brannan
00004 //Copyright (C) 1998 I.Ioannou
00005 //Copyright (C) 1997 Brad Johnson
00006 //
00007 //This program is free software; you can redistribute it and/or
00008 //modify it under the terms of the GNU General Public License
00009 //as published by the Free Software Foundation; either version 2
00010 //of the License, or (at your option) any later version.
00011 //
00012 //This program is distributed in the hope that it will be useful,
00013 //but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //GNU General Public License for more details.
00016 //
00017 //You should have received a copy of the GNU General Public License
00018 //along with this program; if not, write to the Free Software
00019 //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 //
00021 //I.Ioannou
00022 //roryt@hol.gr
00023 //
00025 
00027 //     Class TkeyDef - Key Definitions                 //
00028 //                   - kept in an array container      //
00029 //     originally part of KeyTrans.cpp                 //
00031 
00032 #include "precomp.h"
00033 
00034 // This class did not properly release memory before, and a buffer overrun
00035 // was apparent in operator=(char*).  Fixed.  (Paul Brannan Feb. 4, 1999)
00036 
00037 TKeyDef::TKeyDef() {
00038     uKeyDef.szKeyDef = 0;
00039     vk_code = dwState = 0;
00040 }
00041 
00042 TKeyDef::TKeyDef(char *def, DWORD state, DWORD code) {
00043     uKeyDef.szKeyDef = 0;
00044     if (def != NULL && *def != 0) {
00045         // szKeyDef = (char *) GlobalAlloc(GPTR, strlen(def) +1);
00046         uKeyDef.szKeyDef = new char[strlen(def)+1];
00047         strcpy(uKeyDef.szKeyDef, def);
00048     }
00049     dwState = state;
00050     vk_code = code;
00051 }
00052 
00053 TKeyDef::TKeyDef(optype op, DWORD state, DWORD code) {
00054     uKeyDef.op = new optype;
00055     uKeyDef.op->sendstr = 0;
00056     uKeyDef.op->the_op = op.the_op;
00057     dwState = state;
00058     vk_code = code;
00059 }
00060 
00061 TKeyDef::TKeyDef(const TKeyDef &t) {
00062     if(t.uKeyDef.szKeyDef == NULL) {
00063         uKeyDef.szKeyDef = (char *)NULL;
00064     } else if(t.uKeyDef.op->sendstr == 0) {
00065         uKeyDef.op = new optype;
00066         uKeyDef.op->sendstr = 0;
00067         uKeyDef.op->the_op = t.uKeyDef.op->the_op;
00068     } else {
00069         uKeyDef.szKeyDef = new char[strlen(t.uKeyDef.szKeyDef)+1];
00070         strcpy(uKeyDef.szKeyDef, t.uKeyDef.szKeyDef);
00071     }
00072     dwState = t.dwState;
00073     vk_code = t.vk_code;
00074 }
00075 
00076 TKeyDef::~TKeyDef() {
00077     if(uKeyDef.szKeyDef) delete[] uKeyDef.szKeyDef;
00078 }
00079 
00080 char * TKeyDef::operator=(char *def) {
00081     if(def != NULL && *def != 0) {
00082         if(uKeyDef.szKeyDef) delete[] uKeyDef.szKeyDef;
00083         uKeyDef.szKeyDef = new char[strlen(def)+1];
00084         strcpy(uKeyDef.szKeyDef, def);
00085     }
00086     return uKeyDef.szKeyDef;
00087 }
00088 
00089 DWORD TKeyDef::operator=(DWORD code) {
00090     return vk_code = code;
00091 }
00092 
00093 TKeyDef& TKeyDef::operator=(const TKeyDef &t) {
00094     if(t.uKeyDef.szKeyDef) {
00095         if(uKeyDef.szKeyDef) delete[] uKeyDef.szKeyDef;
00096         if(t.uKeyDef.op->sendstr) {
00097             uKeyDef.szKeyDef = new char[strlen(t.uKeyDef.szKeyDef)+1];
00098             strcpy(uKeyDef.szKeyDef, t.uKeyDef.szKeyDef);
00099         } else {
00100             uKeyDef.op = new optype;
00101             uKeyDef.op->sendstr = 0;
00102             uKeyDef.op->the_op = t.uKeyDef.op->the_op;
00103         }
00104     } else {
00105         uKeyDef.szKeyDef = (char *)NULL;
00106     }
00107     dwState = t.dwState;
00108     vk_code = t.vk_code;
00109     return *this;
00110 }
00111 
00112 const optype& TKeyDef::operator=(optype op) {
00113     uKeyDef.op = new optype;
00114     uKeyDef.op->sendstr = 0;
00115     uKeyDef.op->the_op = op.the_op;
00116     return *uKeyDef.op;
00117 }
00118 
00119 // STL requires that operators be friends rather than member functions
00120 // (Paul Brannan 5/25/98)
00121 #ifndef __BORLANDC__
00122 bool operator==(const TKeyDef & t1, const TKeyDef & t2) {
00123     return ((t1.vk_code == t2.vk_code) && (t1.dwState == t2.dwState));
00124 }
00125 // We need this function for compatibility with STL (Paul Brannan 5/25/98)
00126 bool operator< (const TKeyDef& t1, const TKeyDef& t2) {
00127     if (t1.vk_code == t2.vk_code) return t1.dwState < t2.dwState;
00128     return t1.vk_code < t2.vk_code;
00129 }
00130 #else
00131 int   TKeyDef::operator==(TKeyDef & t) {
00132     return ((vk_code == t.vk_code) && (dwState == t.dwState));
00133 }
00134 #endif
00135 

Generated on Sun May 27 2012 04:17:16 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.