vfs: check userland buffers before reading them.
[haiku.git] / src / tests / servers / app / stacktile / main.cpp
blobaf7dad25d879073b862eae5b071a5d548106b1ee
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
6 #include <Application.h>
7 #include <OS.h>
8 #include <Window.h>
9 #include <WindowStack.h>
12 static BRect* sFrames = NULL;
13 static uint32 sNumFrames = 0;
16 class TestApp : public BApplication {
17 public:
18 TestApp(uint32 numWindows);
19 virtual ~TestApp();
21 private:
22 void _CreateFrames(uint32 numWindows);
23 int32 _WindowCreator();
24 static int32 _ThreadStarter(void* data);
26 private:
27 uint32 fFrameNum;
28 uint32 fNumWindows;
29 uint32 fMaxWindows;
33 class TestWindow : public BWindow {
34 public:
35 TestWindow(BRect frame);
36 virtual ~TestWindow();
38 virtual void DispatchMessage(BMessage* message, BHandler* handler);
42 TestApp::TestApp(uint32 numWindows)
44 BApplication("application/x.vnd-Haiku.stack-tile"),
45 fNumWindows(0),
46 fMaxWindows(numWindows)
48 _CreateFrames(numWindows);
52 TestApp::~TestApp()
54 delete[] sFrames;
58 void
59 TestApp::_CreateFrames(uint32 numWindows)
61 BWindowStack* stack = NULL;
62 while (fNumWindows < fMaxWindows) {
63 if (fFrameNum >= sNumFrames)
64 fFrameNum = 0;
66 BWindow* window = new TestWindow(BRect(20, 20, 300, 200));
68 if (!stack) stack = new BWindowStack(window);
69 else stack->AddWindow(window);
71 window->Show();
72 fNumWindows++;
77 TestWindow::TestWindow(BRect frame)
79 BWindow(frame, "Test", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
84 TestWindow::~TestWindow()
89 void
90 TestWindow::DispatchMessage(BMessage* message, BHandler* handler)
92 BWindow::DispatchMessage(message, handler);
94 int a = rand();
95 char buf[32];
96 sprintf(buf, "%d", a);
97 SetTitle(buf);
102 main(int argc, char** argv)
104 uint32 numWindows = 2;
105 if (argc > 1)
106 numWindows = atoi(argv[1]);
108 TestApp app(numWindows);
109 app.Run();
111 return 0;