btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / debug / DebugEventStream.h
bloba8be6f42e372cf2fa2acfedd2b2bbc6c9632fb01
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _DEBUG_EVENT_STREAM_H
6 #define _DEBUG_EVENT_STREAM_H
8 #include <SupportDefs.h>
11 class BDataIO;
14 struct debug_event_stream_header {
15 char signature[32];
16 uint32 version;
17 uint32 flags;
18 uint32 event_mask;
19 uint32 reserved;
23 // signature and version
24 #define B_DEBUG_EVENT_STREAM_SIGNATURE "Haiku debug events"
25 #define B_DEBUG_EVENT_STREAM_VERSION 1
28 // flags
29 enum {
30 B_DEBUG_EVENT_STREAM_FLAG_HOST_ENDIAN = 0x00000001,
31 B_DEBUG_EVENT_STREAM_FLAG_SWAPPED_ENDIAN = 0x01000000,
33 B_DEBUG_EVENT_STREAM_FLAG_ZIPPED = 0x00000002
37 class BDebugEventInputStream {
38 public:
39 BDebugEventInputStream();
40 ~BDebugEventInputStream();
42 status_t SetTo(BDataIO* stream);
43 status_t SetTo(const void* data, size_t size,
44 bool takeOverOwnership);
45 void Unset();
47 status_t Seek(off_t streamOffset);
49 ssize_t ReadNextEvent(uint32* _event, uint32* _cpu,
50 const void** _buffer,
51 off_t* _streamOffset = NULL);
53 private:
54 status_t _Init();
55 ssize_t _Read(void* buffer, size_t size);
56 status_t _GetData(size_t size);
58 private:
59 BDataIO* fStream;
60 uint32 fFlags;
61 uint32 fEventMask;
62 uint8* fBuffer;
63 size_t fBufferCapacity;
64 size_t fBufferSize;
65 size_t fBufferPosition;
66 off_t fStreamPosition;
67 bool fOwnsBuffer;
71 class BDebugEventOutputStream {
72 public:
73 BDebugEventOutputStream();
74 ~BDebugEventOutputStream();
76 status_t SetTo(BDataIO* stream, uint32 flags,
77 uint32 eventMask);
78 void Unset();
80 status_t Write(const void* buffer, size_t size);
81 status_t Flush();
83 private:
84 BDataIO* fStream;
85 uint32 fFlags;
89 #endif // _DEBUG_EVENT_STREAM_H