ReactOS 0.4.15-dev-8102-g108db8f
tkeydef.cpp
Go to the documentation of this file.
1
2//Telnet Win32 : an ANSI telnet client.
3//Copyright (C) 1998-2000 Paul Brannan
4//Copyright (C) 1998 I.Ioannou
5//Copyright (C) 1997 Brad Johnson
6//
7//This program is free software; you can redistribute it and/or
8//modify it under the terms of the GNU General Public License
9//as published by the Free Software Foundation; either version 2
10//of the License, or (at your option) any later version.
11//
12//This program is distributed in the hope that it will be useful,
13//but WITHOUT ANY WARRANTY; without even the implied warranty of
14//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15//GNU General Public License for more details.
16//
17//You should have received a copy of the GNU General Public License
18//along with this program; if not, write to the Free Software
19//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20//
21//I.Ioannou
22//roryt@hol.gr
23//
25
27// Class TkeyDef - Key Definitions //
28// - kept in an array container //
29// originally part of KeyTrans.cpp //
31
32#include "precomp.h"
33
34// This class did not properly release memory before, and a buffer overrun
35// was apparent in operator=(char*). Fixed. (Paul Brannan Feb. 4, 1999)
36
38 uKeyDef.szKeyDef = 0;
39 vk_code = dwState = 0;
40}
41
43 uKeyDef.szKeyDef = 0;
44 if (def != NULL && *def != 0) {
45 // szKeyDef = (char *) GlobalAlloc(GPTR, strlen(def) +1);
46 uKeyDef.szKeyDef = new char[strlen(def)+1];
48 }
49 dwState = state;
50 vk_code = code;
51}
52
54 uKeyDef.op = new optype;
55 uKeyDef.op->sendstr = 0;
56 uKeyDef.op->the_op = op.the_op;
57 dwState = state;
58 vk_code = code;
59}
62 if(t.uKeyDef.szKeyDef == NULL) {
63 uKeyDef.szKeyDef = (char *)NULL;
64 } else if(t.uKeyDef.op->sendstr == 0) {
65 uKeyDef.op = new optype;
66 uKeyDef.op->sendstr = 0;
67 uKeyDef.op->the_op = t.uKeyDef.op->the_op;
68 } else {
69 uKeyDef.szKeyDef = new char[strlen(t.uKeyDef.szKeyDef)+1];
70 strcpy(uKeyDef.szKeyDef, t.uKeyDef.szKeyDef);
71 }
72 dwState = t.dwState;
73 vk_code = t.vk_code;
74}
75
77 if(uKeyDef.szKeyDef) delete[] uKeyDef.szKeyDef;
78}
79
80char * TKeyDef::operator=(char *def) {
81 if(def != NULL && *def != 0) {
82 if(uKeyDef.szKeyDef) delete[] uKeyDef.szKeyDef;
83 uKeyDef.szKeyDef = new char[strlen(def)+1];
85 }
86 return uKeyDef.szKeyDef;
87}
88
90 return vk_code = code;
91}
92
94 if(t.uKeyDef.szKeyDef) {
95 if(uKeyDef.szKeyDef) delete[] uKeyDef.szKeyDef;
96 if(t.uKeyDef.op->sendstr) {
97 uKeyDef.szKeyDef = new char[strlen(t.uKeyDef.szKeyDef)+1];
98 strcpy(uKeyDef.szKeyDef, t.uKeyDef.szKeyDef);
99 } else {
100 uKeyDef.op = new optype;
101 uKeyDef.op->sendstr = 0;
102 uKeyDef.op->the_op = t.uKeyDef.op->the_op;
103 }
104 } else {
105 uKeyDef.szKeyDef = (char *)NULL;
106 }
107 dwState = t.dwState;
108 vk_code = t.vk_code;
109 return *this;
110}
111
113 uKeyDef.op = new optype;
114 uKeyDef.op->sendstr = 0;
115 uKeyDef.op->the_op = op.the_op;
116 return *uKeyDef.op;
117}
118
119// STL requires that operators be friends rather than member functions
120// (Paul Brannan 5/25/98)
121#ifndef __BORLANDC__
122bool operator==(const TKeyDef & t1, const TKeyDef & t2) {
123 return ((t1.vk_code == t2.vk_code) && (t1.dwState == t2.dwState));
124}
125// We need this function for compatibility with STL (Paul Brannan 5/25/98)
126bool operator< (const TKeyDef& t1, const TKeyDef& t2) {
127 if (t1.vk_code == t2.vk_code) return t1.dwState < t2.dwState;
128 return t1.vk_code < t2.vk_code;
129}
130#else
132 return ((vk_code == t.vk_code) && (dwState == t.dwState));
133}
134#endif
135
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static int state
Definition: maze.c:121
~TKeyDef()
Definition: tkeydef.cpp:76
DWORD dwState
Definition: tkeydef.h:40
TKeyDef()
Definition: tkeydef.cpp:37
char * operator=(char *def)
Definition: tkeydef.cpp:80
DWORD vk_code
Definition: tkeydef.h:39
KeyDefType uKeyDef
Definition: tkeydef.h:38
friend bool operator==(const TKeyDef &t1, const TKeyDef &t2)
Definition: tkeydef.cpp:122
#define NULL
Definition: types.h:112
UINT op
Definition: effect.c:236
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble t
Definition: gl.h:2047
Definition: inflate.c:139
Definition: tkeydef.h:21
tn_ops the_op
Definition: tkeydef.h:23
char sendstr
Definition: tkeydef.h:22
bool operator<(const TKeyDef &t1, const TKeyDef &t2)
Definition: tkeydef.cpp:126
bool operator==(const TKeyDef &t1, const TKeyDef &t2)
Definition: tkeydef.cpp:122
char * szKeyDef
Definition: tkeydef.h:27
optype * op
Definition: tkeydef.h:28