ReactOS 0.4.16-dev-338-g34e76ad
msgtrace.c File Reference
#include <apitest.h>
#include <stdio.h>
#include <winuser.h>
#include <msgtrace.h>
#include <undocuser.h>
Include dependency graph for msgtrace.c:

Go to the source code of this file.

Functions

static charget_msg_name (UINT msg)
 
static charget_hook_name (UINT id)
 
void empty_message_cache (MSG_CACHE *cache)
 
void sprintf_msg_entry (char *buffer, MSG_ENTRY *msg)
 
void trace_cache (MSG_CACHE *cache, const char *file, int line)
 
void compare_cache (MSG_CACHE *cache, const char *file, int line, MSG_ENTRY *msg_chain)
 
void record_message (MSG_CACHE *cache, int iwnd, UINT message, MSG_TYPE type, int param1, int param2)
 

Variables

MSG_CACHE default_cache
 
MSG_ENTRY empty_chain [] = {{0,0}}
 

Function Documentation

◆ compare_cache()

void compare_cache ( MSG_CACHE cache,
const char file,
int  line,
MSG_ENTRY msg_chain 
)

Definition at line 143 of file msgtrace.c.

144{
145 int i = 0;
146 char buffGot[100], buffExp[100];
147 BOOL got_error = FALSE;
148
149 while(1)
150 {
151 BOOL same = !memcmp(&cache->message_cache[i],msg_chain, sizeof(MSG_ENTRY));
152
153 sprintf_msg_entry(buffGot, &cache->message_cache[i]);
154 sprintf_msg_entry(buffExp, msg_chain);
155 ok_(file,line)(same,"%d: got %s, expected %s\n",i, buffGot, buffExp);
156
157 if(!got_error && !same)
158 got_error = TRUE;
159
160 if(msg_chain->msg !=0 || msg_chain->iwnd != 0)
161 msg_chain++;
162 else
163 {
164 if(i > cache->count)
165 break;
166 }
167 i++;
168 }
169
170 if(got_error )
171 {
172 trace_(file,line)("The complete list of messages got is:\n");
174 }
175
177}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ok_(x1, x2)
Definition: atltest.h:61
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define trace_(file, line,...)
Definition: kmt_test.h:223
void trace_cache(MSG_CACHE *cache, const char *file, int line)
Definition: msgtrace.c:130
void sprintf_msg_entry(char *buffer, MSG_ENTRY *msg)
Definition: msgtrace.c:88
void empty_message_cache(MSG_CACHE *cache)
Definition: msgtrace.c:83
Definition: msgtrace.h:15
int iwnd
Definition: msgtrace.h:16
UINT msg
Definition: msgtrace.h:17
Definition: cache.c:49
Definition: fci.c:127
Definition: parser.c:49

◆ empty_message_cache()

void empty_message_cache ( MSG_CACHE cache)

Definition at line 83 of file msgtrace.c.

84{
85 memset(cache, 0, sizeof(MSG_CACHE));
86}
#define memset(x, y, z)
Definition: compat.h:39

Referenced by compare_cache().

◆ get_hook_name()

static char * get_hook_name ( UINT  id)
static

Definition at line 71 of file msgtrace.c.

72{
73 switch (id)
74 {
75 case WH_KEYBOARD: return "WH_KEYBOARD";
76 case WH_KEYBOARD_LL: return "WH_KEYBOARD_LL";
77 case WH_MOUSE: return "WH_MOUSE";
78 case WH_MOUSE_LL: return "WH_MOUSE_LL";
79 default: return NULL;
80 }
81}
#define NULL
Definition: types.h:112
#define WH_KEYBOARD
Definition: winuser.h:32
#define WH_MOUSE_LL
Definition: winuser.h:44
#define WH_MOUSE
Definition: winuser.h:37
#define WH_KEYBOARD_LL
Definition: winuser.h:43

Referenced by sprintf_msg_entry().

◆ get_msg_name()

static char * get_msg_name ( UINT  msg)
static

Definition at line 22 of file msgtrace.c.

23{
24 switch(msg)
25 {
26 case WM_CREATE: return "WM_CREATE";
27 case WM_NCCREATE: return "WM_NCCREATE";
28 case WM_PARENTNOTIFY: return "WM_PARENTNOTIFY";
29 case WM_DESTROY: return "WM_DESTROY";
30 case WM_NCDESTROY: return "WM_NCDESTROY";
31 case WM_CHILDACTIVATE: return "WM_CHILDACTIVATE";
32 case WM_NCACTIVATE: return "WM_NCACTIVATE";
33 case WM_ACTIVATE: return "WM_ACTIVATE";
34 case WM_ACTIVATEAPP: return "WM_ACTIVATEAPP";
35 case WM_WINDOWPOSCHANGING: return "WM_WINDOWPOSCHANGING";
36 case WM_WINDOWPOSCHANGED: return "WM_WINDOWPOSCHANGED";
37 case WM_SETFOCUS: return "WM_SETFOCUS";
38 case WM_KILLFOCUS: return "WM_KILLFOCUS";
39 case WM_NCPAINT: return "WM_NCPAINT";
40 case WM_PAINT: return "WM_PAINT";
41 case WM_ERASEBKGND: return "WM_ERASEBKGND";
42 case WM_SIZE: return "WM_SIZE";
43 case WM_MOVE: return "WM_MOVE";
44 case WM_SHOWWINDOW: return "WM_SHOWWINDOW";
45 case WM_QUERYNEWPALETTE: return "WM_QUERYNEWPALETTE";
46 case WM_MOUSELEAVE: return "WM_MOUSELEAVE";
47 case WM_MOUSEHOVER: return "WM_MOUSEHOVER";
48 case WM_NCMOUSELEAVE: return "WM_NCMOUSELEAVE";
49 case WM_NCMOUSEHOVER: return "WM_NCMOUSEHOVER";
50 case WM_NCHITTEST: return "WM_NCHITTEST";
51 case WM_SETCURSOR: return "WM_SETCURSOR";
52 case WM_MOUSEMOVE: return "WM_MOUSEMOVE";
53 case WM_SYSTIMER: return "WM_SYSTIMER";
54 case WM_GETMINMAXINFO: return "WM_GETMINMAXINFO";
55 case WM_NCCALCSIZE: return "WM_NCCALCSIZE";
56 case WM_SETTINGCHANGE: return "WM_SETTINGCHANGE";
57 case WM_GETICON: return "WM_GETICON";
58 case WM_SETICON: return "WM_SETICON";
59 case WM_KEYDOWN: return "WM_KEYDOWN";
60 case WM_KEYUP: return "WM_KEYUP";
61 case WM_NOTIFY: return "WM_NOTIFY";
62 case WM_COMMAND: return "WM_COMMAND";
63 case WM_PRINTCLIENT: return "WM_PRINTCLIENT";
64 case WM_CTLCOLORSTATIC: return "WM_CTLCOLORSTATIC";
65 case WM_STYLECHANGING: return "WM_STYLECHANGING";
66 case WM_STYLECHANGED: return "WM_STYLECHANGED";
67 default: return NULL;
68 }
69}
#define msg(x)
Definition: auth_time.c:54
#define WM_SYSTIMER
Definition: comctl32.h:125
#define WM_MOUSELEAVE
Definition: commctrl.h:4980
#define WM_MOUSEHOVER
Definition: commctrl.h:4979
#define WM_PRINTCLIENT
Definition: richedit.h:70
#define WM_NOTIFY
Definition: richedit.h:61
#define WM_PAINT
Definition: winuser.h:1623
#define WM_ERASEBKGND
Definition: winuser.h:1628
#define WM_QUERYNEWPALETTE
Definition: winuser.h:1881
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1775
#define WM_KEYUP
Definition: winuser.h:1719
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1664
#define WM_CHILDACTIVATE
Definition: winuser.h:1641
#define WM_CREATE
Definition: winuser.h:1611
#define WM_SIZE
Definition: winuser.h:1614
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_NCHITTEST
Definition: winuser.h:1689
#define WM_SETFOCUS
Definition: winuser.h:1616
#define WM_MOUSEMOVE
Definition: winuser.h:1778
#define WM_NCCREATE
Definition: winuser.h:1686
#define WM_ACTIVATE
Definition: winuser.h:1615
#define WM_SHOWWINDOW
Definition: winuser.h:1631
#define WM_SETTINGCHANGE
Definition: winuser.h:1632
#define WM_NCACTIVATE
Definition: winuser.h:1691
#define WM_GETMINMAXINFO
Definition: winuser.h:1643
#define WM_MOVE
Definition: winuser.h:1613
#define WM_NCDESTROY
Definition: winuser.h:1687
#define WM_SETCURSOR
Definition: winuser.h:1639
#define WM_ACTIVATEAPP
Definition: winuser.h:1635
#define WM_DESTROY
Definition: winuser.h:1612
#define WM_KEYDOWN
Definition: winuser.h:1718
#define WM_PARENTNOTIFY
Definition: winuser.h:1806
#define WM_NCMOUSELEAVE
Definition: winuser.h:1845
#define WM_NCCALCSIZE
Definition: winuser.h:1688
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1665
#define WM_KILLFOCUS
Definition: winuser.h:1617
#define WM_NCMOUSEHOVER
Definition: winuser.h:1844
#define WM_NCPAINT
Definition: winuser.h:1690

Referenced by sprintf_msg_entry().

◆ record_message()

void record_message ( MSG_CACHE cache,
int  iwnd,
UINT  message,
MSG_TYPE  type,
int  param1,
int  param2 
)

Definition at line 179 of file msgtrace.c.

180{
181 if(cache->count >= 100)
182 {
183 return;
184 }
185
186 /* do not report a post message a second time */
187 if(type == SENT &&
188 cache->last_post_message.iwnd == iwnd &&
189 cache->last_post_message.msg == message &&
190 cache->last_post_message.param1 == param1 &&
191 cache->last_post_message.param2 == param2)
192 {
193 memset(&cache->last_post_message, 0, sizeof(MSG_ENTRY));
194 return;
195 }
196
197 cache->message_cache[cache->count].iwnd = iwnd;
198 cache->message_cache[cache->count].msg = message;
199 cache->message_cache[cache->count].type = type;
200 cache->message_cache[cache->count].param1 = param1;
201 cache->message_cache[cache->count].param2 = param2;
202
203 if(cache->message_cache[cache->count].type == POST)
204 {
205 cache->last_post_message = cache->message_cache[cache->count];
206 }
207 else
208 {
209 memset(&cache->last_post_message, 0, sizeof(MSG_ENTRY));
210 }
211
212 cache->count++;
213}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
@ POST
Definition: msgtrace.h:7
@ SENT
Definition: msgtrace.h:6
Definition: tftpd.h:60

Referenced by FlushMessages(), TestProc(), and thread_proc().

◆ sprintf_msg_entry()

void sprintf_msg_entry ( char buffer,
MSG_ENTRY msg 
)

Definition at line 88 of file msgtrace.c.

89{
90 if(!msg->iwnd && !msg->msg)
91 {
92 sprintf(buffer, "nothing");
93 }
94 else
95 {
96 char* msgName;
97 char* msgType;
98
99 switch (msg->type)
100 {
101 case POST:
102 case MARKER:
103 msgName = get_msg_name(msg->msg);
104 msgType = msg->type == POST ? "post msg" : "marker";
105 break;
106 case SENT:
107 case SENT_RET:
108 msgName = get_msg_name(msg->msg);
109 msgType = msg->type == SENT ? "sent msg" : "sent_ret msg";
110 break;
111 case HOOK:
112 msgName = get_hook_name(msg->msg);
113 msgType = "hook";
114 break;
115 case EVENT:
116 msgName = NULL;
117 msgType = "event";
118 break;
119 default:
120 return;
121 }
122
123 if(msgName)
124 sprintf(buffer, "hwnd%d %s %s %d %d", msg->iwnd, msgType, msgName, msg->param1, msg->param2);
125 else
126 sprintf(buffer, "hwnd%d %s %d %d %d", msg->iwnd, msgType, msg->msg, msg->param1, msg->param2);
127 }
128}
GLuint buffer
Definition: glext.h:5915
struct tagHOOK HOOK
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static char * get_msg_name(UINT msg)
Definition: msgtrace.c:22
static char * get_hook_name(UINT id)
Definition: msgtrace.c:71
@ EVENT
Definition: msgtrace.h:9
@ MARKER
Definition: msgtrace.h:11
@ SENT_RET
Definition: msgtrace.h:10

Referenced by compare_cache(), and trace_cache().

◆ trace_cache()

void trace_cache ( MSG_CACHE cache,
const char file,
int  line 
)

Definition at line 130 of file msgtrace.c.

131{
132 int i;
133 char buff[100];
134
135 for (i=0; i < cache->count; i++)
136 {
137 sprintf_msg_entry(buff, &cache->message_cache[i]);
138 trace_(file,line)("%d: %s\n", i, buff);
139 }
140 trace_(file,line)("\n");
141}
static unsigned char buff[32768]
Definition: fatten.c:17

Referenced by compare_cache().

Variable Documentation

◆ default_cache

MSG_CACHE default_cache
Initial value:
= {
}

Definition at line 15 of file msgtrace.c.

◆ empty_chain