]> git.saurik.com Git - apple/security.git/blob - libsecurityd/lib/SharedMemoryClient.h
Security-55471.tar.gz
[apple/security.git] / libsecurityd / lib / SharedMemoryClient.h
1 #ifndef __SHAREDMEMORYCLIENT__
2 #define __SHAREDMEMORYCLIENT__
3
4
5
6 #include <string>
7 #include <stdlib.h>
8 #include <securityd_client/SharedMemoryCommon.h>
9 #include <security_utilities/threading.h>
10
11 namespace Security
12 {
13
14 enum UnavailableReason {kURNone, kURMessageDropped, kURMessagePending, kURNoMessage, kURBufferCorrupt};
15
16 class SharedMemoryClient
17 {
18 protected:
19 std::string mSegmentName;
20 size_t mSegmentSize;
21 Mutex mMutex;
22
23 u_int8_t* mSegment;
24 u_int8_t* mDataArea;
25 u_int8_t* mDataPtr;
26 u_int8_t* mDataMax;
27
28 SegmentOffsetType GetProducerCount ();
29
30 void ReadData (void* buffer, SegmentOffsetType bytesToRead);
31 SegmentOffsetType ReadOffset ();
32
33 public:
34 SharedMemoryClient (const char* segmentName, SegmentOffsetType segmentSize);
35 virtual ~SharedMemoryClient ();
36
37 bool ReadMessage (void* message, SegmentOffsetType &length, UnavailableReason &ur);
38
39 const char* GetSegmentName ();
40 size_t GetSegmentSize ();
41 };
42
43 };
44
45
46 #endif