vfs: check userland buffers before reading them.
[haiku.git] / src / tests / kits / app / bmessenger / ForwardMessageTest.cpp
blob0240e0a1d0f305439621422c008fc9572092e43a
1 #include <stdio.h>
2 #include <Application.h>
3 #include <Looper.h>
5 class MyLooper : public BLooper
7 public:
8 MyLooper(BLooper *looper) : BLooper("test") {
9 printf("Looper created\n");
10 fLooper = looper;
13 virtual void MessageReceived(BMessage *msg) {
14 printf("MessageReceived : %.4s\n", (char*)&msg->what);
15 switch (msg->what) {
16 case 'toto':
17 if (fLooper) {
18 BMessenger(fLooper).SendMessage(msg);
19 break;
21 msg->SendReply('couc');
22 break;
23 default:
24 BLooper::MessageReceived(msg);
28 BLooper *fLooper;
31 class App : public BApplication
33 public:
34 App() : BApplication("application/test") {
37 virtual void ReadyToRun() {
38 MyLooper looper2(NULL);
39 looper2.Run();
40 MyLooper looper1(&looper2);
41 looper1.Run();
42 printf("loopers run\n");
43 BMessage reply;
44 BMessenger(&looper1).SendMessage('toto', &reply);
45 printf("message sent and replied\ncheck there is only a 'couc' what in the reply\n");
46 reply.PrintToStream();
47 exit(0);
52 int main()
54 App().Run();