vfs: check userland buffers before reading them.
[haiku.git] / src / tests / kits / app / bmessenger / SMInvoker.cpp
blob96bc79b614fe28e9676e7748e0ab0a65a545fa4d
1 // SMInvoker.cpp
3 #include "SMInvoker.h"
4 #include "SMMessages.h"
6 // SMInvoker
8 // constructor
9 SMInvoker::SMInvoker()
10 : fReplyMessage(NULL)
14 // destructor
15 SMInvoker::~SMInvoker()
17 delete fReplyMessage;
20 // ReplySuccess
21 bool
22 SMInvoker::ReplySuccess()
24 return (fReplyMessage && fReplyMessage->what == MSG_REPLY);
27 // DirectReply
28 bool
29 SMInvoker::DirectReply()
31 return fReplyMessage;
35 // SMInvoker1
37 // constructor
38 SMInvoker1::SMInvoker1(bool useReplyTo)
39 : SMInvoker(),
40 fUseReplyTo(useReplyTo)
44 // Invoke
45 status_t
46 SMInvoker1::Invoke(BMessenger &target, BHandler *replyHandler,
47 BMessenger &replyMessenger)
49 BHandler *replyTo = (fUseReplyTo ? replyHandler : NULL);
50 status_t result = target.SendMessage(MSG_TEST, replyTo);
51 return result;
55 // SMInvoker2
57 // constructor
58 SMInvoker2::SMInvoker2(bool useMessage, bool useReplyTo, bigtime_t timeout)
59 : SMInvoker(),
60 fUseMessage(useMessage),
61 fUseReplyTo(useReplyTo),
62 fTimeout(timeout)
66 // Invoke
67 status_t
68 SMInvoker2::Invoke(BMessenger &target, BHandler *replyHandler,
69 BMessenger &replyMessenger)
71 BHandler *replyTo = (fUseReplyTo ? replyHandler : NULL);
72 BMessage _message(MSG_TEST);
73 BMessage *message = (fUseMessage ? &_message : NULL);
74 status_t result = target.SendMessage(message, replyTo, fTimeout);
75 return result;
79 // SMInvoker3
81 // constructor
82 SMInvoker3::SMInvoker3(bool useMessage, bool useReplyTo, bigtime_t timeout)
83 : SMInvoker(),
84 fUseMessage(useMessage),
85 fUseReplyTo(useReplyTo),
86 fTimeout(timeout)
90 // Invoke
91 status_t
92 SMInvoker3::Invoke(BMessenger &target, BHandler *replyHandler,
93 BMessenger &replyMessenger)
95 BMessenger badMessenger;
96 BMessenger &replyTo = (fUseReplyTo ? replyMessenger : badMessenger);
97 BMessage _message(MSG_TEST);
98 BMessage *message = (fUseMessage ? &_message : NULL);
99 status_t result = target.SendMessage(message, replyTo, fTimeout);
100 return result;
104 // SMInvoker4
106 // constructor
107 SMInvoker4::SMInvoker4(bool useReply)
108 : SMInvoker(),
109 fUseReply(useReply)
113 // Invoke
114 status_t
115 SMInvoker4::Invoke(BMessenger &target, BHandler *replyHandler,
116 BMessenger &replyMessenger)
118 if (fUseReply)
119 fReplyMessage = new BMessage(uint32(0));
120 status_t result = target.SendMessage(MSG_TEST, fReplyMessage);
121 return result;
125 // SMInvoker5
127 // constructor
128 SMInvoker5::SMInvoker5(bool useMessage, bool useReply,
129 bigtime_t deliveryTimeout, bigtime_t replyTimeout)
130 : SMInvoker(),
131 fUseMessage(useMessage),
132 fUseReply(useReply),
133 fDeliveryTimeout(deliveryTimeout),
134 fReplyTimeout(replyTimeout)
138 // Invoke
139 status_t
140 SMInvoker5::Invoke(BMessenger &target, BHandler *replyHandler,
141 BMessenger &replyMessenger)
143 if (fUseReply)
144 fReplyMessage = new BMessage(uint32(0));
145 BMessage _message(MSG_TEST);
146 BMessage *message = (fUseMessage ? &_message : NULL);
147 status_t result = target.SendMessage(message, fReplyMessage,
148 fDeliveryTimeout, fReplyTimeout);
149 return result;