Last change
on this file since 61 was
48,
checked in by sherbold, 13 years ago
|
- code clean-up: moved deprecated filter code to a txt-file for potential reuse
- code clean-up: moved helper functions to separate source code file
|
File size:
2.1 KB
|
Line | |
---|
1 | #include "stdafx.h"
|
---|
2 | #include "helpers.h"
|
---|
3 |
|
---|
4 | bool MessageEquals(const MSG & msg1, const MSG & msg2) {
|
---|
5 | bool retVal = false;
|
---|
6 | if( (msg1.time==-1 && msg1.pt.x==-1 && msg1.pt.y==-1) || (msg2.time==-1 && msg2.pt.x==-1 && msg2.pt.y==-1) ) {
|
---|
7 | retVal = msg1.hwnd==msg2.hwnd && msg1.message==msg2.message && msg1.lParam==msg2.lParam &&
|
---|
8 | msg1.wParam==msg2.wParam;
|
---|
9 | } else {
|
---|
10 | retVal = msg1.hwnd==msg2.hwnd && msg1.message==msg2.message && msg1.lParam==msg2.lParam &&
|
---|
11 | msg1.wParam==msg2.wParam && msg1.time==msg2.time && msg1.pt.x==msg2.pt.x && msg1.pt.y==msg2.pt.y;
|
---|
12 | }
|
---|
13 | return retVal;
|
---|
14 | }
|
---|
15 |
|
---|
16 | int replaceWithXmlEntitiesWString(const wchar_t * source, wchar_t ** target, size_t sourceLength) {
|
---|
17 | size_t j=0;
|
---|
18 | size_t extraLength = 0;
|
---|
19 | size_t bufsize = 300;
|
---|
20 | wchar_t * tmpTarget = new wchar_t[sourceLength+bufsize];
|
---|
21 | size_t i;
|
---|
22 | for( i=0; i<sourceLength && j<sourceLength+bufsize-5; i++ ) {
|
---|
23 | switch (source[i]) {
|
---|
24 | case L'&':
|
---|
25 | tmpTarget[j] = L'&';
|
---|
26 | tmpTarget[j+1]=L'a';
|
---|
27 | tmpTarget[j+2]=L'm';
|
---|
28 | tmpTarget[j+3]=L'p';
|
---|
29 | tmpTarget[j+4]=L';';
|
---|
30 | j += 5;
|
---|
31 | extraLength += 4;
|
---|
32 | break;
|
---|
33 | case L'<':
|
---|
34 | tmpTarget[j] = L'&';
|
---|
35 | tmpTarget[j+1]=L'l';
|
---|
36 | tmpTarget[j+2]=L't';
|
---|
37 | tmpTarget[j+3]=L';';
|
---|
38 | j += 4;
|
---|
39 | extraLength += 3;
|
---|
40 | break;
|
---|
41 | case L'>':
|
---|
42 | tmpTarget[j] = L'&';
|
---|
43 | tmpTarget[j+1]=L'g';
|
---|
44 | tmpTarget[j+2]=L't';
|
---|
45 | tmpTarget[j+3]=L';';
|
---|
46 | j += 4;
|
---|
47 | extraLength += 3;
|
---|
48 | break;
|
---|
49 | case L'\"':
|
---|
50 | tmpTarget[j] = L'&';
|
---|
51 | tmpTarget[j+1]=L'q';
|
---|
52 | tmpTarget[j+2]=L'u';
|
---|
53 | tmpTarget[j+3]=L'o';
|
---|
54 | tmpTarget[j+4]=L't';
|
---|
55 | tmpTarget[j+5]=L';';
|
---|
56 | j += 6;
|
---|
57 | extraLength += 5;
|
---|
58 | break;
|
---|
59 | case L'\'':
|
---|
60 | tmpTarget[j] = L'&';
|
---|
61 | tmpTarget[j+1]=L'a';
|
---|
62 | tmpTarget[j+2]=L'p';
|
---|
63 | tmpTarget[j+3]=L'o';
|
---|
64 | tmpTarget[j+4]=L's';
|
---|
65 | tmpTarget[j+5]=L';';
|
---|
66 | j += 6;
|
---|
67 | extraLength += 5;
|
---|
68 | break;
|
---|
69 | case L'%':
|
---|
70 | tmpTarget[j] = L'\\';
|
---|
71 | tmpTarget[j+1] = L'%';
|
---|
72 | j += 2;
|
---|
73 | extraLength += 1;
|
---|
74 | break;
|
---|
75 | default:
|
---|
76 | tmpTarget[j] = source[i];
|
---|
77 | j++;
|
---|
78 | }
|
---|
79 | }
|
---|
80 | *target = new wchar_t[j+1];
|
---|
81 | memcpy(*target,tmpTarget,j*sizeof(wchar_t));
|
---|
82 | (*target)[j] = '\0';
|
---|
83 | return j;
|
---|
84 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.