vfs: check userland buffers before reading them.
[haiku.git] / src / tests / kits / app / bmessage / MessagePointerItemTest.h
blobb7135f51529b41661564787fea72156025095cc9
1 //------------------------------------------------------------------------------
2 // MessagePointerItemTest.h
3 //
4 //------------------------------------------------------------------------------
6 #ifndef MESSAGEPOINTERITEMTEST_H
7 #define MESSAGEPOINTERITEMTEST_H
9 // Standard Includes -----------------------------------------------------------
11 // System Includes -------------------------------------------------------------
13 // Project Includes ------------------------------------------------------------
15 // Local Includes --------------------------------------------------------------
16 #include "MessageItemTest.h"
18 // Local Defines ---------------------------------------------------------------
20 // Globals ---------------------------------------------------------------------
22 struct TPointerFuncPolicy
24 static status_t Add(BMessage& msg, const char* name, const void* val)
25 { return msg.AddPointer(name, val); }
26 static status_t AddData(BMessage& msg, const char* name, type_code type,
27 const void* data, ssize_t size, bool)
28 { return msg.AddData(name, type, data, size); }
29 static status_t Find(BMessage& msg, const char* name, int32 index,
30 const void** val)
31 { return msg.FindPointer(name, index, (void**)val); }
32 static status_t ShortFind(BMessage& msg, const char* name, const void** val)
33 { return msg.FindPointer(name, (void**)val); }
34 static const void* QuickFind(BMessage& msg, const char* name, int32 index)
36 const void* ptr;
37 msg.FindPointer(name, index, (void**)&ptr);
38 return ptr;
40 static bool Has(BMessage& msg, const char* name, int32 index)
41 { return msg.HasPointer(name, index); }
42 static status_t Replace(BMessage& msg, const char* name, int32 index,
43 const void* val)
44 { return msg.ReplacePointer(name, index, val); }
45 static status_t FindData(BMessage& msg, const char* name, type_code type,
46 int32 index, const void** data, ssize_t* size)
47 { return msg.FindData(name, type, index, data, size); }
50 struct TPointerInitPolicy : public ArrayTypeBase<const void*>
52 inline static const void* Zero() { return NULL; }
53 inline static const void* Test1() { return (const void*)&Test1; }
54 inline static const void* Test2() { return (const void*)&Test2; }
55 inline static size_t SizeOf(const void*) { return sizeof (const void*); }
56 inline static ArrayType Array()
58 ArrayType array;
59 array.push_back(Zero());
60 array.push_back(Test1());
61 array.push_back(Test2());
62 return array;
66 struct TPointerAssertPolicy
68 inline static const void* Zero() { return NULL; }
69 inline static const void* Invalid() { return NULL; }
70 inline static bool Size(size_t size, const void* t)
71 { return size == sizeof (t); }
74 typedef TMessageItemTest
76 const void*,
77 B_POINTER_TYPE,
78 TPointerFuncPolicy,
79 TPointerInitPolicy,
80 TPointerAssertPolicy
82 TMessagePointerItemTest;
84 #endif // MESSAGEPOINTERITEMTEST_H
87 * $Log $
89 * $Id $