| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file provides forward declarations for XPC symbols that are not | 5 // This file provides forward declarations for private XPC symbols. |
| 6 // present in the 10.6 SDK. It uses generate_stubs to produce code to | |
| 7 // dynamically load the libxpc.dylib library and set up a stub table, with | |
| 8 // the same names as the real XPC functions. | |
| 9 | 6 |
| 10 #ifndef SANDBOX_MAC_XPC_H_ | 7 #ifndef SANDBOX_MAC_XPC_H_ |
| 11 #define SANDBOX_MAC_XPC_H_ | 8 #define SANDBOX_MAC_XPC_H_ |
| 12 | 9 |
| 13 #include <AvailabilityMacros.h> | 10 #include <AvailabilityMacros.h> |
| 14 #include <mach/mach.h> | 11 #include <mach/mach.h> |
| 12 #include <bsm/libbsm.h> |
| 13 #include <xpc/xpc.h> |
| 15 | 14 |
| 16 #include "sandbox/sandbox_export.h" | 15 #include "sandbox/sandbox_export.h" |
| 17 | 16 |
| 18 // Declares XPC object types. This includes <xpc/xpc.h> if available. | 17 // Declare private types. |
| 19 #include "sandbox/mac/xpc_stubs_header.fragment" | |
| 20 | |
| 21 #if !defined(MAC_OS_X_VERSION_10_7) || \ | |
| 22 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | |
| 23 | |
| 24 // C++ library loader. | |
| 25 #include "sandbox/mac/xpc_stubs.h" | |
| 26 | |
| 27 extern "C" { | 18 extern "C" { |
| 28 // Signatures for XPC public functions that are loaded by xpc_stubs.h. | 19 typedef struct _xpc_pipe_s* xpc_pipe_t; |
| 29 #include "sandbox/mac/xpc_stubs.sig" | |
| 30 // Signatures for private XPC functions. | |
| 31 #include "sandbox/mac/xpc_private_stubs.sig" | |
| 32 } // extern "C" | 20 } // extern "C" |
| 33 | 21 |
| 34 #else | 22 #if defined(MAC_OS_X_VERSION_10_7) && \ |
| 23 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 |
| 24 // Redeclare methods that only exist on 10.7+ to suppress |
| 25 // -Wpartial-availability warnings. |
| 26 extern "C" { |
| 27 void xpc_dictionary_set_int64(xpc_object_t xdict, |
| 28 const char* key, |
| 29 int64_t value); |
| 30 void xpc_release(xpc_object_t object); |
| 31 bool xpc_dictionary_get_bool(xpc_object_t xdict, const char* key); |
| 32 int64_t xpc_dictionary_get_int64(xpc_object_t xdict, const char* key); |
| 33 const char* xpc_dictionary_get_string(xpc_object_t xdict, const char* key); |
| 34 uint64_t xpc_dictionary_get_uint64(xpc_object_t xdict, const char* key); |
| 35 void xpc_dictionary_set_uint64(xpc_object_t xdict, |
| 36 const char* key, |
| 37 uint64_t value); |
| 38 void xpc_dictionary_set_string(xpc_object_t xdict, const char* key, |
| 39 const char* string); |
| 40 xpc_object_t xpc_dictionary_create(const char* const* keys, |
| 41 const xpc_object_t* values, |
| 42 size_t count); |
| 43 xpc_object_t xpc_dictionary_create_reply(xpc_object_t original); |
| 44 xpc_object_t xpc_dictionary_get_value(xpc_object_t xdict, const char* key); |
| 45 char* xpc_copy_description(xpc_object_t object); |
| 46 } // extern "C" |
| 47 #endif |
| 35 | 48 |
| 36 // Signatures for private XPC functions. | 49 // Signatures for private XPC functions. |
| 37 extern "C" { | 50 extern "C" { |
| 38 #include "sandbox/mac/xpc_private_stubs.sig" | 51 // Dictionary manipulation. |
| 52 void xpc_dictionary_set_mach_send(xpc_object_t dictionary, |
| 53 const char* name, |
| 54 mach_port_t port); |
| 55 void xpc_dictionary_get_audit_token(xpc_object_t dictionary, |
| 56 audit_token_t* token); |
| 57 |
| 58 // Raw object getters. |
| 59 mach_port_t xpc_mach_send_get_right(xpc_object_t value); |
| 60 |
| 61 // Pipe methods. |
| 62 xpc_pipe_t xpc_pipe_create_from_port(mach_port_t port, int flags); |
| 63 int xpc_pipe_receive(mach_port_t port, xpc_object_t* message); |
| 64 int xpc_pipe_routine(xpc_pipe_t pipe, |
| 65 xpc_object_t request, |
| 66 xpc_object_t* reply); |
| 67 int xpc_pipe_routine_reply(xpc_object_t reply); |
| 68 int xpc_pipe_simpleroutine(xpc_pipe_t pipe, xpc_object_t message); |
| 69 int xpc_pipe_routine_forward(xpc_pipe_t forward_to, xpc_object_t request); |
| 39 } // extern "C" | 70 } // extern "C" |
| 40 | 71 |
| 41 #endif | |
| 42 | |
| 43 namespace sandbox { | |
| 44 | |
| 45 // Dynamically loads the XPC library. | |
| 46 bool SANDBOX_EXPORT InitializeXPC(); | |
| 47 | |
| 48 } // namespace sandbox | |
| 49 | |
| 50 #endif // SANDBOX_MAC_XPC_H_ | 72 #endif // SANDBOX_MAC_XPC_H_ |
| OLD | NEW |