OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 #ifndef CRASHPAD_UTIL_MACH_MACH_MESSAGE_UTIL_H_ | |
16 #define CRASHPAD_UTIL_MACH_MACH_MESSAGE_UTIL_H_ | |
17 | |
18 #include <mach/mach.h> | |
19 | |
20 namespace crashpad { | |
21 | |
22 //! \brief Initializes a reply message for a MIG server routine based on its | |
23 //! corresponding request. | |
24 //! | |
25 //! If a request is handled by a server routine, it may be necessary to revise | |
26 //! some of the fields set by this function, such as `msgh_size` and any fields | |
27 //! defined in a routine’s reply structure type. | |
28 //! | |
29 //! \param[in] in_header The request message to base the reply on. | |
30 //! \param[out] out_header The reply message to initialize. \a out_header will | |
31 //! be treated as a `mig_reply_error_t*` and all of its fields will be set | |
32 //! except for `RetCode`, which must be set by SetMIGReplyError(). This | |
33 //! argument is accepted as a `mach_msg_header_t*` instead of a | |
34 //! `mig_reply_error_t*` because that is the type that callers are expected | |
35 //! to possess in the C API. | |
36 void PrepareMIGReplyFromRequest(const mach_msg_header_t* in_header, | |
37 mach_msg_header_t* out_header); | |
38 | |
39 //! \brief Sets the error code in a reply message for a MIG server routine. | |
40 //! | |
41 //! \param[inout] out_header The reply message to operate on. \a out_header will | |
42 //! be treated as a `mig_reply_error_t*` and its `RetCode` field will be | |
43 //! set. This argument is accepted as a `mach_msg_header_t*` instead of a | |
44 //! `mig_reply_error_t*` because that is the type that callers are expected | |
45 //! to possess in the C API. | |
46 //! \param[in] error The error code to store in \a out_header. | |
47 //! | |
48 //! \sa PrepareMIGReplyFromRequest() | |
49 void SetMIGReplyError(mach_msg_header_t* out_header, kern_return_t error); | |
50 | |
51 //! \brief Returns a Mach message trailer for a message that has been received. | |
52 //! | |
53 //! This function must only be called on Mach messages that have been received | |
54 //! via the Mach messaging interface, such as `mach_msg()`. Messages constructed | |
55 //! for sending do not contain trailers. | |
56 //! | |
57 //! \param[in] header A pointer to a received Mach message. | |
58 //! | |
59 //! \return A pointer to the trailer following the received Mach message’s body. | |
60 //! The contents of the trailer depend on the options provided to | |
61 //! `mach_msg()` or a similar function when the message was received. | |
62 const mach_msg_trailer_t* MachMessageTrailerFromHeader( | |
63 const mach_msg_header_t* header); | |
64 | |
65 } // namespace crashpad | |
66 | |
67 #endif // CRASHPAD_UTIL_MACH_MACH_MESSAGE_UTIL_H_ | |
OLD | NEW |