zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

xpc.h (83695B) - Raw


      1 // Copyright (c) 2009-2020 Apple Inc. All rights reserved. 
      2 
      3 #ifndef __XPC_H__
      4 #define __XPC_H__
      5 
      6 #include <os/object.h>
      7 #include <dispatch/dispatch.h>
      8 
      9 #include <sys/mman.h>
     10 #include <uuid/uuid.h>
     11 #include <bsm/audit.h>
     12 #include <stdarg.h>
     13 #include <stdbool.h>
     14 #include <stdint.h>
     15 #include <stdlib.h>
     16 #include <stdio.h>
     17 #include <string.h>
     18 #include <unistd.h>
     19 #include <fcntl.h>
     20 
     21 #ifndef __XPC_INDIRECT__
     22 #define __XPC_INDIRECT__
     23 #endif // __XPC_INDIRECT__
     24 
     25 #include <xpc/base.h>
     26 
     27 #if __has_include(<xpc/xpc_transaction_deprecate.h>)
     28 #include <xpc/xpc_transaction_deprecate.h>
     29 #else // __has_include(<xpc/transaction_deprecate.h>)
     30 #define XPC_TRANSACTION_DEPRECATED
     31 #endif // __has_include(<xpc/transaction_deprecate.h>)
     32 
     33 XPC_ASSUME_NONNULL_BEGIN
     34 __BEGIN_DECLS
     35 
     36 #ifndef __OSX_AVAILABLE_STARTING
     37 #define __OSX_AVAILABLE_STARTING(x, y)
     38 #endif // __OSX_AVAILABLE_STARTING
     39 
     40 #define XPC_API_VERSION 20200610
     41 
     42 /*!
     43  * @typedef xpc_type_t
     44  * A type that describes XPC object types.
     45  */
     46 typedef const struct _xpc_type_s * xpc_type_t;
     47 #ifndef XPC_TYPE
     48 #define XPC_TYPE(type) const struct _xpc_type_s type
     49 #endif // XPC_TYPE
     50 
     51 /*!
     52  * @typedef xpc_object_t
     53  * A type that can describe all XPC objects. Dictionaries, arrays, strings, etc.
     54  * are all described by this type.
     55  *
     56  * XPC objects are created with a retain count of 1, and therefore it is the
     57  * caller's responsibility to call xpc_release() on them when they are no longer
     58  * needed.
     59  */
     60 
     61 #if OS_OBJECT_USE_OBJC
     62 /* By default, XPC objects are declared as Objective-C types when building with
     63  * an Objective-C compiler. This allows them to participate in ARC, in RR
     64  * management by the Blocks runtime and in leaks checking by the static
     65  * analyzer, and enables them to be added to Cocoa collections.
     66  *
     67  * See <os/object.h> for details.
     68  */
     69 OS_OBJECT_DECL(xpc_object);
     70 #ifndef XPC_DECL
     71 #define XPC_DECL(name) typedef xpc_object_t name##_t
     72 #endif // XPC_DECL
     73 
     74 #define XPC_GLOBAL_OBJECT(object) ((OS_OBJECT_BRIDGE xpc_object_t)&(object))
     75 #define XPC_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED
     76 XPC_INLINE XPC_NONNULL_ALL
     77 void
     78 _xpc_object_validate(xpc_object_t object) {
     79 	(void)*(unsigned long volatile *)(OS_OBJECT_BRIDGE void *)object;
     80 }
     81 #else // OS_OBJECT_USE_OBJC
     82 typedef void * xpc_object_t;
     83 #define XPC_DECL(name) typedef struct _##name##_s * name##_t
     84 #define XPC_GLOBAL_OBJECT(object) (&(object))
     85 #define XPC_RETURNS_RETAINED
     86 #endif // OS_OBJECT_USE_OBJC 
     87 
     88 /*!
     89  * @typedef xpc_handler_t
     90  * The type of block that is accepted by the XPC connection APIs.
     91  *
     92  * @param object
     93  * An XPC object that is to be handled. If there was an error, this object will
     94  * be equal to one of the well-known XPC_ERROR_* dictionaries and can be
     95  * compared with the equality operator.
     96  *
     97  * @discussion
     98  * You are not responsible for releasing the event object.
     99  */
    100 #if __BLOCKS__
    101 typedef void (^xpc_handler_t)(xpc_object_t object);
    102 #endif // __BLOCKS__ 
    103 
    104 /*!
    105  * @define XPC_TYPE_CONNECTION
    106  * A type representing a connection to a named service. This connection is
    107  * bidirectional and can be used to both send and receive messages. A
    108  * connection carries the credentials of the remote service provider.
    109  */
    110 #define XPC_TYPE_CONNECTION (&_xpc_type_connection)
    111 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    112 XPC_EXPORT
    113 XPC_TYPE(_xpc_type_connection);
    114 XPC_DECL(xpc_connection);
    115 
    116 /*!
    117  * @typedef xpc_connection_handler_t
    118  * The type of the function that will be invoked for a bundled XPC service when
    119  * there is a new connection on the service.
    120  *
    121  * @param connection
    122  * A new connection that is equivalent to one received by a listener connection.
    123  * See the documentation for {@link xpc_connection_set_event_handler} for the
    124  * semantics associated with the received connection.
    125  */
    126 typedef void (*xpc_connection_handler_t)(xpc_connection_t connection);
    127 
    128 /*!
    129  * @define XPC_TYPE_ENDPOINT
    130  * A type representing a connection in serialized form. Unlike a connection, an
    131  * endpoint is an inert object that does not have any runtime activity
    132  * associated with it. Thus, it is safe to pass an endpoint in a message. Upon
    133  * receiving an endpoint, the recipient can use
    134  * xpc_connection_create_from_endpoint() to create as many distinct connections
    135  * as desired. 
    136  */
    137 #define XPC_TYPE_ENDPOINT (&_xpc_type_endpoint)
    138 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    139 XPC_EXPORT
    140 XPC_TYPE(_xpc_type_endpoint);
    141 XPC_DECL(xpc_endpoint);
    142 
    143 /*!
    144  * @define XPC_TYPE_NULL
    145  * A type representing a null object. This type is useful for disambiguating
    146  * an unset key in a dictionary and one which has been reserved but set empty.
    147  * Also, this type is a way to represent a "null" value in dictionaries, which
    148  * do not accept NULL.
    149  */
    150 #define XPC_TYPE_NULL (&_xpc_type_null)
    151 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    152 XPC_EXPORT
    153 XPC_TYPE(_xpc_type_null);
    154 
    155 /*!
    156  * @define XPC_TYPE_BOOL
    157  * A type representing a Boolean value.
    158  */
    159 #define XPC_TYPE_BOOL (&_xpc_type_bool)
    160 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    161 XPC_EXPORT
    162 XPC_TYPE(_xpc_type_bool);
    163 
    164 /*!
    165  * @define XPC_BOOL_TRUE
    166  * A constant representing a Boolean value of true. You may compare a Boolean
    167  * object against this constant to determine its value.
    168  */
    169 #define XPC_BOOL_TRUE XPC_GLOBAL_OBJECT(_xpc_bool_true)
    170 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    171 XPC_EXPORT
    172 const struct _xpc_bool_s _xpc_bool_true;
    173 
    174 /*!
    175  * @define XPC_BOOL_FALSE
    176  * A constant representing a Boolean value of false. You may compare a Boolean
    177  * object against this constant to determine its value.
    178  */
    179 #define XPC_BOOL_FALSE XPC_GLOBAL_OBJECT(_xpc_bool_false)
    180 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    181 XPC_EXPORT
    182 const struct _xpc_bool_s _xpc_bool_false;
    183 
    184 /*!
    185  * @define XPC_TYPE_INT64
    186  * A type representing a signed, 64-bit integer value.
    187  */
    188 #define XPC_TYPE_INT64 (&_xpc_type_int64)
    189 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    190 XPC_EXPORT
    191 XPC_TYPE(_xpc_type_int64);
    192 
    193 /*!
    194  * @define XPC_TYPE_UINT64
    195  * A type representing an unsigned, 64-bit integer value.
    196  */
    197 #define XPC_TYPE_UINT64 (&_xpc_type_uint64)
    198 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    199 XPC_EXPORT
    200 XPC_TYPE(_xpc_type_uint64);
    201 
    202 /*!
    203  * @define XPC_TYPE_DOUBLE
    204  * A type representing an IEEE-compliant, double-precision floating point value.
    205  */
    206 #define XPC_TYPE_DOUBLE (&_xpc_type_double)
    207 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    208 XPC_EXPORT
    209 XPC_TYPE(_xpc_type_double);
    210 
    211 /*!
    212  * @define XPC_TYPE_DATE
    213  * A type representing a date interval. The interval is with respect to the
    214  * Unix epoch. XPC dates are in Unix time and are thus unaware of local time
    215  * or leap seconds.
    216  */
    217 #define XPC_TYPE_DATE (&_xpc_type_date)
    218 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    219 XPC_EXPORT
    220 XPC_TYPE(_xpc_type_date);
    221 
    222 /*!
    223  * @define XPC_TYPE_DATA
    224  * A type representing a an arbitrary buffer of bytes.
    225  */
    226 #define XPC_TYPE_DATA (&_xpc_type_data)
    227 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    228 XPC_EXPORT
    229 XPC_TYPE(_xpc_type_data);
    230 
    231 /*!
    232  * @define XPC_TYPE_STRING
    233  * A type representing a NUL-terminated C-string.
    234  */
    235 #define XPC_TYPE_STRING (&_xpc_type_string)
    236 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    237 XPC_EXPORT
    238 XPC_TYPE(_xpc_type_string);
    239 
    240 /*!
    241  * @define XPC_TYPE_UUID
    242  * A type representing a Universally Unique Identifier as defined by uuid(3). 
    243  */
    244 #define XPC_TYPE_UUID (&_xpc_type_uuid)
    245 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    246 XPC_EXPORT
    247 XPC_TYPE(_xpc_type_uuid);
    248 
    249 /*!
    250  * @define XPC_TYPE_FD
    251  * A type representing a POSIX file descriptor.
    252  */
    253 #define XPC_TYPE_FD (&_xpc_type_fd)
    254 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    255 XPC_EXPORT
    256 XPC_TYPE(_xpc_type_fd);
    257 
    258 /*!
    259  * @define XPC_TYPE_SHMEM
    260  * A type representing a region of shared memory.
    261  */
    262 #define XPC_TYPE_SHMEM (&_xpc_type_shmem)
    263 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    264 XPC_EXPORT
    265 XPC_TYPE(_xpc_type_shmem);
    266 
    267 /*!
    268  * @define XPC_TYPE_ARRAY
    269  * A type representing an array of XPC objects. This array must be contiguous,
    270  * i.e. it cannot contain NULL values. If you wish to indicate that a slot
    271  * is empty, you can insert a null object. The array will grow as needed to
    272  * accommodate more objects.
    273  */
    274 #define XPC_TYPE_ARRAY (&_xpc_type_array)
    275 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    276 XPC_EXPORT
    277 XPC_TYPE(_xpc_type_array);
    278 
    279 /*!
    280  * @define XPC_TYPE_DICTIONARY
    281  * A type representing a dictionary of XPC objects, keyed off of C-strings.
    282  * You may insert NULL values into this collection. The dictionary will grow
    283  * as needed to accommodate more key/value pairs.
    284  */
    285 #define XPC_TYPE_DICTIONARY (&_xpc_type_dictionary)
    286 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    287 XPC_EXPORT
    288 XPC_TYPE(_xpc_type_dictionary);
    289 
    290 /*!
    291  * @define XPC_TYPE_ERROR
    292  * A type representing an error object. Errors in XPC are dictionaries, but
    293  * xpc_get_type() will return this type when given an error object. You
    294  * cannot create an error object directly; XPC will only give them to handlers.
    295  * These error objects have pointer values that are constant across the lifetime
    296  * of your process and can be safely compared.
    297  *
    298  * These constants are enumerated in the header for the connection object. Error
    299  * dictionaries may reserve keys so that they can be queried to obtain more
    300  * detailed information about the error. Currently, the only reserved key is
    301  * XPC_ERROR_KEY_DESCRIPTION.
    302  */
    303 #define XPC_TYPE_ERROR (&_xpc_type_error)
    304 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    305 XPC_EXPORT
    306 XPC_TYPE(_xpc_type_error);
    307 
    308 /*!
    309  * @define XPC_ERROR_KEY_DESCRIPTION
    310  * In an error dictionary, querying for this key will return a string object
    311  * that describes the error in a human-readable way.
    312  */
    313 #define XPC_ERROR_KEY_DESCRIPTION _xpc_error_key_description
    314 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    315 XPC_EXPORT
    316 const char * const _xpc_error_key_description;
    317 
    318 /*!
    319  * @define XPC_EVENT_KEY_NAME
    320  * In an event dictionary, this querying for this key will return a string
    321  * object that describes the event.
    322  */
    323 #define XPC_EVENT_KEY_NAME _xpc_event_key_name
    324 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    325 XPC_EXPORT
    326 const char * const _xpc_event_key_name;
    327 
    328 /*!
    329  * @define XPC_TYPE_RICH_ERROR
    330  *
    331  * @discussion
    332  * Rich errors provide a simple dynamic error type that can indicate whether an
    333  * error is retry-able or not.
    334  */
    335 #define XPC_TYPE_RICH_ERROR (&_xpc_type_rich_error)
    336 XPC_EXPORT
    337 XPC_TYPE(_xpc_type_rich_error);
    338 XPC_DECL(xpc_rich_error);
    339 
    340 __END_DECLS
    341 XPC_ASSUME_NONNULL_END
    342 #if !defined(__XPC_BUILDING_XPC__) || !__XPC_BUILDING_XPC__
    343 #include <xpc/endpoint.h>
    344 #include <xpc/debug.h>
    345 #if __BLOCKS__
    346 #include <xpc/activity.h>
    347 #include <xpc/connection.h>
    348 #include <xpc/rich_error.h>
    349 #include <xpc/session.h>
    350 #include <xpc/listener.h>
    351 #endif // __BLOCKS__
    352 #undef __XPC_INDIRECT__
    353 #if __has_include(<launch.h>)
    354 #include <launch.h>
    355 #endif // __has_include(<launch.h>)
    356 #endif // !defined(__XPC_BUILDING_XPC__) || !__XPC_BUILDING_XPC__
    357 XPC_ASSUME_NONNULL_BEGIN
    358 __BEGIN_DECLS
    359 
    360 #pragma mark XPC Object Protocol
    361 /*!
    362  * @function xpc_retain
    363  *
    364  * @abstract
    365  * Increments the reference count of an object.
    366  *
    367  * @param object
    368  * The object which is to be manipulated.
    369  *
    370  * @result
    371  * The object which was given.
    372  *
    373  * @discussion
    374  * Calls to xpc_retain() must be balanced with calls to xpc_release()
    375  * to avoid leaking memory.
    376  */
    377 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    378 XPC_EXPORT XPC_NONNULL1
    379 xpc_object_t
    380 xpc_retain(xpc_object_t object);
    381 #if OS_OBJECT_USE_OBJC_RETAIN_RELEASE
    382 #undef xpc_retain
    383 #define xpc_retain(object) ({ xpc_object_t _o = (object); \
    384 		_xpc_object_validate(_o); [_o retain]; })
    385 #endif // OS_OBJECT_USE_OBJC_RETAIN_RELEASE
    386 
    387 /*!
    388  * @function xpc_release
    389  *
    390  * @abstract
    391  * Decrements the reference count of an object.
    392  *
    393  * @param object
    394  * The object which is to be manipulated.
    395  *
    396  * @discussion
    397  * The caller must take care to balance retains and releases. When creating or
    398  * retaining XPC objects, the creator obtains a reference on the object. Thus,
    399  * it is the caller's responsibility to call xpc_release() on those objects when
    400  * they are no longer needed.
    401  */
    402 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    403 XPC_EXPORT XPC_NONNULL1
    404 void
    405 xpc_release(xpc_object_t object);
    406 #if OS_OBJECT_USE_OBJC_RETAIN_RELEASE
    407 #undef xpc_release
    408 #define xpc_release(object) ({ xpc_object_t _o = (object); \
    409 		_xpc_object_validate(_o); [_o release]; })
    410 #endif // OS_OBJECT_USE_OBJC_RETAIN_RELEASE
    411 
    412 /*!
    413  * @function xpc_get_type
    414  *
    415  * @abstract
    416  * Returns the type of an object.
    417  *
    418  * @param object
    419  * The object to examine.
    420  *
    421  * @result
    422  * An opaque pointer describing the type of the object. This pointer is suitable
    423  * direct comparison to exported type constants with the equality operator.
    424  */
    425 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    426 XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT
    427 xpc_type_t
    428 xpc_get_type(xpc_object_t object);
    429 
    430 /*!
    431  * @function xpc_type_get_name
    432  *
    433  * @abstract
    434  * Returns a string describing an XPC object type.
    435  *
    436  * @param type
    437  * The type to describe.
    438  *
    439  * @result
    440  * A string describing the type of an object, like "string" or "int64".
    441  * This string should not be freed or modified.
    442  */
    443 __OSX_AVAILABLE_STARTING(__MAC_10_15, __IPHONE_13_0)
    444 XPC_EXPORT XPC_NONNULL1
    445 const char *
    446 xpc_type_get_name(xpc_type_t type);
    447 
    448 /*!
    449  * @function xpc_copy
    450  *
    451  * @abstract
    452  * Creates a copy of the object.
    453  *
    454  * @param object
    455  * The object to copy.
    456  *
    457  * @result
    458  * The new object. NULL if the object type does not support copying or if
    459  * sufficient memory for the copy could not be allocated. Service objects do
    460  * not support copying.
    461  *
    462  * @discussion
    463  * When called on an array or dictionary, xpc_copy() will perform a deep copy.
    464  *
    465  * The object returned is not necessarily guaranteed to be a new object, and
    466  * whether it is will depend on the implementation of the object being copied.
    467  */
    468 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    469 XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT XPC_RETURNS_RETAINED
    470 xpc_object_t _Nullable
    471 xpc_copy(xpc_object_t object);
    472 
    473 /*!
    474  * @function xpc_equal
    475  *
    476  * @abstract
    477  * Compares two objects for equality.
    478  *
    479  * @param object1
    480  * The first object to compare.
    481  *
    482  * @param object2
    483  * The second object to compare.
    484  *
    485  * @result
    486  * Returns true if the objects are equal, otherwise false. Two objects must be
    487  * of the same type in order to be equal.
    488  *
    489  * For two arrays to be equal, they must contain the same values at the 
    490  * same indexes. For two dictionaries to be equal, they must contain the same
    491  * values for the same keys.
    492  *
    493  * Two objects being equal implies that their hashes (as returned by xpc_hash())
    494  * are also equal.
    495  */
    496 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    497 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_WARN_RESULT
    498 bool
    499 xpc_equal(xpc_object_t object1, xpc_object_t object2);
    500 
    501 /*!
    502  * @function xpc_hash
    503  *
    504  * @abstract
    505  * Calculates a hash value for the given object.
    506  *
    507  * @param object
    508  * The object for which to calculate a hash value. This value may be modded
    509  * with a table size for insertion into a dictionary-like data structure.
    510  *
    511  * @result
    512  * The calculated hash value.
    513  *
    514  * @discussion
    515  * Note that the computed hash values for any particular type and value of an 
    516  * object can change from across releases and platforms and should not be
    517  * assumed to be constant across all time and space or stored persistently.
    518  */
    519 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    520 XPC_EXPORT XPC_NONNULL1 XPC_WARN_RESULT
    521 size_t
    522 xpc_hash(xpc_object_t object);
    523 
    524 /*!
    525  * @function xpc_copy_description
    526  *
    527  * @abstract
    528  * Copies a debug string describing the object.
    529  *
    530  * @param object
    531  * The object which is to be examined.
    532  *
    533  * @result
    534  * A string describing object which contains information useful for debugging.
    535  * This string should be disposed of with free(3) when done.
    536  */
    537 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    538 XPC_EXPORT XPC_MALLOC XPC_WARN_RESULT XPC_NONNULL1
    539 char *
    540 xpc_copy_description(xpc_object_t object);
    541 
    542 #pragma mark XPC Object Types
    543 #pragma mark Null
    544 /*!
    545  * @function xpc_null_create
    546  *
    547  * @abstract
    548  * Creates an XPC object representing the null object.
    549  *
    550  * @result
    551  * A new null object.
    552  */
    553 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    554 XPC_EXPORT XPC_RETURNS_RETAINED XPC_WARN_RESULT
    555 xpc_object_t
    556 xpc_null_create(void);
    557 
    558 #pragma mark Boolean
    559 /*!
    560  * @function xpc_bool_create
    561  *
    562  * @abstract
    563  * Creates an XPC Boolean object.
    564  *
    565  * @param value
    566  * The Boolean primitive value which is to be boxed.
    567  *
    568  * @result
    569  * A new Boolean object. 
    570  */
    571 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    572 XPC_EXPORT XPC_RETURNS_RETAINED XPC_WARN_RESULT
    573 xpc_object_t
    574 xpc_bool_create(bool value);
    575 
    576 /*!
    577  * @function xpc_bool_get_value
    578  *
    579  * @abstract
    580  * Returns the underlying Boolean value from the object.
    581  *
    582  * @param xbool
    583  * The Boolean object which is to be examined.
    584  *
    585  * @result
    586  * The underlying Boolean value or false if the given object was not an XPC
    587  * Boolean object.
    588  */
    589 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    590 XPC_EXPORT
    591 bool
    592 xpc_bool_get_value(xpc_object_t xbool);
    593 
    594 #pragma mark Signed Integer
    595 /*!
    596  * @function xpc_int64_create
    597  *
    598  * @abstract
    599  * Creates an XPC signed integer object.
    600  *
    601  * @param value
    602  * The signed integer value which is to be boxed.
    603  *
    604  * @result
    605  * A new signed integer object.
    606  */
    607 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    608 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
    609 xpc_object_t
    610 xpc_int64_create(int64_t value);
    611 
    612 /*!
    613  * @function xpc_int64_get_value
    614  *
    615  * @abstract
    616  * Returns the underlying signed 64-bit integer value from an object.
    617  *
    618  * @param xint
    619  * The signed integer object which is to be examined.
    620  *
    621  * @result
    622  * The underlying signed 64-bit value or 0 if the given object was not an XPC
    623  * integer object.
    624  */
    625 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    626 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
    627 int64_t
    628 xpc_int64_get_value(xpc_object_t xint);
    629 
    630 #pragma mark Unsigned Integer
    631 /*!
    632  * @function xpc_uint64_create
    633  *
    634  * @abstract
    635  * Creates an XPC unsigned integer object.
    636  *
    637  * @param value
    638  * The unsigned integer value which is to be boxed.
    639  *
    640  * @result
    641  * A new unsigned integer object.
    642  */
    643 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    644 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
    645 xpc_object_t
    646 xpc_uint64_create(uint64_t value);
    647 
    648 /*!
    649  * @function xpc_uint64_get_value
    650  *
    651  * @abstract
    652  * Returns the underlying unsigned 64-bit integer value from an object.
    653  *
    654  * @param xuint
    655  * The unsigned integer object which is to be examined.
    656  *
    657  * @result
    658  * The underlying unsigned integer value or 0 if the given object was not an XPC
    659  * unsigned integer object.
    660  */
    661 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    662 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
    663 uint64_t
    664 xpc_uint64_get_value(xpc_object_t xuint);
    665 
    666 #pragma mark Double
    667 /*!
    668  * @function xpc_double_create
    669  *
    670  * @abstract
    671  * Creates an XPC double object.
    672  *
    673  * @param value
    674  * The floating point quantity which is to be boxed.
    675  *
    676  * @result
    677  * A new floating point object.
    678  */
    679 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    680 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
    681 xpc_object_t
    682 xpc_double_create(double value);
    683 
    684 /*!
    685  * @function xpc_double_get_value
    686  *
    687  * @abstract
    688  * Returns the underlying double-precision floating point value from an object.
    689  *
    690  * @param xdouble
    691  * The floating point object which is to be examined.
    692  *
    693  * @result
    694  * The underlying floating point value or NAN if the given object was not an XPC
    695  * floating point object.
    696  */
    697 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    698 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
    699 double
    700 xpc_double_get_value(xpc_object_t xdouble);
    701 
    702 #pragma mark Date
    703 /*!
    704  * @function xpc_date_create
    705  *
    706  * @abstract
    707  * Creates an XPC date object.
    708  *
    709  * @param interval
    710  * The date interval which is to be boxed. Negative values indicate the number
    711  * of nanoseconds before the epoch. Positive values indicate the number of
    712  * nanoseconds after the epoch.
    713  *
    714  * @result
    715  * A new date object.
    716  */
    717 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    718 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
    719 xpc_object_t
    720 xpc_date_create(int64_t interval);
    721 
    722 /*!
    723  * @function xpc_date_create_from_current
    724  *
    725  * @abstract
    726  * Creates an XPC date object representing the current date.
    727  *
    728  * @result
    729  * A new date object representing the current date.
    730  */
    731 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    732 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
    733 xpc_object_t
    734 xpc_date_create_from_current(void);
    735 
    736 /*!
    737  * @function xpc_date_get_value
    738  *
    739  * @abstract
    740  * Returns the underlying date interval from an object.
    741  *
    742  * @param xdate
    743  * The date object which is to be examined.
    744  *
    745  * @result
    746  * The underlying date interval or 0 if the given object was not an XPC date
    747  * object.
    748  */
    749 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    750 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
    751 int64_t
    752 xpc_date_get_value(xpc_object_t xdate);
    753 
    754 #pragma mark Data
    755 /*!
    756  * @function xpc_data_create
    757  *
    758  * @abstract
    759  * Creates an XPC object representing buffer of bytes.
    760  *
    761  * @param bytes
    762  * The buffer of bytes which is to be boxed. You may create an empty data object
    763  * by passing NULL for this parameter and 0 for the length. Passing NULL with
    764  * any other length will result in undefined behavior.
    765  *
    766  * @param length
    767  * The number of bytes which are to be boxed.
    768  *
    769  * @result
    770  * A new data object. 
    771  *
    772  * @discussion
    773  * This method will copy the buffer given into internal storage. After calling
    774  * this method, it is safe to dispose of the given buffer.
    775  */
    776 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    777 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
    778 xpc_object_t
    779 xpc_data_create(const void * _Nullable XPC_SIZEDBY(length) bytes, size_t length);
    780 
    781 /*!
    782  * @function xpc_data_create_with_dispatch_data
    783  *
    784  * @abstract
    785  * Creates an XPC object representing buffer of bytes described by the given GCD
    786  * data object.
    787  *
    788  * @param ddata
    789  * The GCD data object containing the bytes which are to be boxed. This object
    790  * is retained by the data object.
    791  *
    792  * @result
    793  * A new data object. 
    794  *
    795  * @discussion
    796  * The object returned by this method will refer to the buffer returned by
    797  * dispatch_data_create_map(). The point where XPC will make the call to
    798  * dispatch_data_create_map() is undefined.
    799  */
    800 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    801 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
    802 xpc_object_t
    803 xpc_data_create_with_dispatch_data(dispatch_data_t ddata);
    804 
    805 /*!
    806  * @function xpc_data_get_length
    807  *
    808  * @abstract
    809  * Returns the length of the data encapsulated by an XPC data object.
    810  *
    811  * @param xdata
    812  * The data object which is to be examined.
    813  *
    814  * @result
    815  * The length of the underlying boxed data or 0 if the given object was not an
    816  * XPC data object.
    817  */
    818 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    819 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
    820 size_t
    821 xpc_data_get_length(xpc_object_t xdata);
    822 
    823 /*!
    824  * @function xpc_data_get_bytes_ptr
    825  *
    826  * @abstract
    827  * Returns a pointer to the internal storage of a data object.
    828  *
    829  * @param xdata
    830  * The data object which is to be examined.
    831  *
    832  * @result
    833  * A pointer to the underlying boxed data or NULL if the given object was not an
    834  * XPC data object.
    835  */
    836 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    837 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
    838 const void * _Nullable
    839 xpc_data_get_bytes_ptr(xpc_object_t xdata);
    840 
    841 /*!
    842  * @function xpc_data_get_bytes
    843  *
    844  * @abstract
    845  * Copies the bytes stored in an data objects into the specified buffer.
    846  *
    847  * @param xdata
    848  * The data object which is to be examined.
    849  *
    850  * @param buffer
    851  * The buffer in which to copy the data object's bytes.
    852  *
    853  * @param off
    854  * The offset at which to begin the copy. If this offset is greater than the 
    855  * length of the data element, nothing is copied. Pass 0 to start the copy
    856  * at the beginning of the buffer.
    857  *
    858  * @param length
    859  * The length of the destination buffer.
    860  *
    861  * @result
    862  * The number of bytes that were copied into the buffer or 0 if the given object
    863  * was not an XPC data object.
    864  */
    865 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    866 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2
    867 size_t
    868 xpc_data_get_bytes(xpc_object_t xdata, 
    869 	void *buffer, size_t off, size_t length);
    870 
    871 #pragma mark String
    872 /*!
    873  * @function xpc_string_create
    874  *
    875  * @abstract
    876  * Creates an XPC object representing a NUL-terminated C-string.
    877  *
    878  * @param string
    879  * The C-string which is to be boxed.
    880  *
    881  * @result
    882  * A new string object. 
    883  */
    884 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    885 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
    886 xpc_object_t
    887 xpc_string_create(const char *string);
    888 
    889 /*!
    890  * @function xpc_string_create_with_format
    891  *
    892  * @abstract
    893  * Creates an XPC object representing a C-string that is generated from the
    894  * given format string and arguments.
    895  *
    896  * @param fmt
    897  * The printf(3)-style format string from which to construct the final C-string
    898  * to be boxed.
    899  *
    900  * @param ...
    901  * The arguments which correspond to those specified in the format string.
    902  *
    903  * @result
    904  * A new string object. 
    905  */
    906 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    907 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
    908 XPC_PRINTF(1, 2)
    909 xpc_object_t
    910 xpc_string_create_with_format(const char *fmt, ...);
    911 
    912 /*!
    913  * @function xpc_string_create_with_format_and_arguments
    914  *
    915  * @abstract
    916  * Creates an XPC object representing a C-string that is generated from the
    917  * given format string and argument list pointer.
    918  *
    919  * @param fmt
    920  * The printf(3)-style format string from which to construct the final C-string
    921  * to be boxed.
    922  *
    923  * @param ap
    924  * A pointer to the arguments which correspond to those specified in the format
    925  * string.
    926  *
    927  * @result
    928  * A new string object. 
    929  */
    930 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    931 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
    932 XPC_PRINTF(1, 0)
    933 xpc_object_t
    934 xpc_string_create_with_format_and_arguments(const char *fmt, va_list ap);
    935 
    936 /*!
    937  * @function xpc_string_get_length
    938  *
    939  * @abstract
    940  * Returns the length of the underlying string.
    941  *
    942  * @param xstring
    943  * The string object which is to be examined.
    944  *
    945  * @result
    946  * The length of the underlying string, not including the NUL-terminator, or 0 
    947  * if the given object was not an XPC string object.
    948  */
    949 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    950 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
    951 size_t
    952 xpc_string_get_length(xpc_object_t xstring);
    953 
    954 /*!
    955  * @function xpc_string_get_string_ptr
    956  *
    957  * @abstract
    958  * Returns a pointer to the internal storage of a string object.
    959  *
    960  * @param xstring
    961  * The string object which is to be examined.
    962  *
    963  * @result
    964  * A pointer to the string object's internal storage or NULL if the given object
    965  * was not an XPC string object.
    966  */
    967 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    968 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
    969 const char * _Nullable
    970 xpc_string_get_string_ptr(xpc_object_t xstring);
    971 
    972 #pragma mark UUID
    973 /*!
    974  * @function xpc_uuid_create
    975  *
    976  * @abstract
    977  * Creates an XPC object representing a universally-unique identifier (UUID) as
    978  * described by uuid(3).
    979  *
    980  * @param uuid
    981  * The UUID which is to be boxed.
    982  *
    983  * @result
    984  * A new UUID object. 
    985  */
    986 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
    987 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
    988 xpc_object_t
    989 xpc_uuid_create(const uuid_t XPC_NONNULL_ARRAY uuid);
    990 
    991 /*!
    992  * @function xpc_uuid_get_bytes
    993  *
    994  * @abstract
    995  * Returns a pointer to the the boxed UUID bytes in an XPC UUID object.
    996  *
    997  * @param xuuid
    998  * The UUID object which is to be examined.
    999  * 
   1000  * @result
   1001  * The underlying <code>uuid_t</code> bytes or NULL if the given object was not
   1002  * an XPC UUID object. The returned pointer may be safely passed to the uuid(3)
   1003  * APIs.
   1004  */
   1005 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1006 XPC_EXPORT XPC_NONNULL1
   1007 const uint8_t * _Nullable
   1008 xpc_uuid_get_bytes(xpc_object_t xuuid);
   1009 
   1010 #pragma mark File Descriptors
   1011 /*!
   1012  * @function xpc_fd_create
   1013  *
   1014  * @abstract
   1015  * Creates an XPC object representing a POSIX file descriptor.
   1016  *
   1017  * @param fd
   1018  * The file descriptor which is to be boxed.
   1019  *
   1020  * @result
   1021  * A new file descriptor object. NULL if sufficient memory could not be
   1022  * allocated or if the given file descriptor was not valid.
   1023  *
   1024  * @discussion
   1025  * This method performs the equivalent of a dup(2) on the descriptor, and thus
   1026  * it is safe to call close(2) on the descriptor after boxing it with a file
   1027  * descriptor object.
   1028  *
   1029  * IMPORTANT: Pointer equality is the ONLY valid test for equality between two
   1030  * file descriptor objects. There is no reliable way to determine whether two
   1031  * file descriptors refer to the same inode with the same capabilities, so two
   1032  * file descriptor objects created from the same underlying file descriptor
   1033  * number will not compare equally with xpc_equal(). This is also true of a
   1034  * file descriptor object created using xpc_copy() and the original.
   1035  *
   1036  * This also implies that two collections containing file descriptor objects
   1037  * cannot be equal unless the exact same object was inserted into both.
   1038  */
   1039 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1040 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
   1041 xpc_object_t _Nullable
   1042 xpc_fd_create(int fd);
   1043 
   1044 /*!
   1045  * @function xpc_fd_dup
   1046  *
   1047  * @abstract
   1048  * Returns a file descriptor that is equivalent to the one boxed by the file
   1049  * file descriptor object.
   1050  *
   1051  * @param xfd
   1052  * The file descriptor object which is to be examined.
   1053  *
   1054  * @result
   1055  * A file descriptor that is equivalent to the one originally given to
   1056  * xpc_fd_create(). If the descriptor could not be created or if the given 
   1057  * object was not an XPC file descriptor, -1 is returned.
   1058  *
   1059  * @discussion
   1060  * Multiple invocations of xpc_fd_dup() will not return the same file descriptor
   1061  * number, but they will return descriptors that are equivalent, as though they
   1062  * had been created by dup(2).
   1063  *
   1064  * The caller is responsible for calling close(2) on the returned descriptor.
   1065  */
   1066 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1067 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   1068 int
   1069 xpc_fd_dup(xpc_object_t xfd);
   1070 
   1071 #pragma mark Shared Memory
   1072 /*!
   1073  * @function xpc_shmem_create
   1074  *
   1075  * @abstract
   1076  * Creates an XPC object representing the given shared memory region.
   1077  *
   1078  * @param region
   1079  * A pointer to a region of shared memory, created through a call to mmap(2)
   1080  * with the MAP_SHARED flag, which is to be boxed.
   1081  *
   1082  * @param length
   1083  * The length of the region.
   1084  *
   1085  * @result
   1086  * A new shared memory object.
   1087  *
   1088  * @discussion
   1089  * Only memory regions whose exact characteristics are known to the caller
   1090  * should be boxed using this API. Memory returned from malloc(3) may not be
   1091  * safely shared on either OS X or iOS because the underlying virtual memory
   1092  * objects for malloc(3)ed allocations are owned by the malloc(3) subsystem and
   1093  * not the caller of malloc(3).
   1094  *
   1095  * If you wish to share a memory region that you receive from another subsystem,
   1096  * part of the interface contract with that other subsystem must include how to
   1097  * create the region of memory, or sharing it may be unsafe.
   1098  *
   1099  * Certain operations may internally fragment a region of memory in a way that
   1100  * would truncate the range detected by the shared memory object. vm_copy(), for
   1101  * example, may split the region into multiple parts to avoid copying certain
   1102  * page ranges. For this reason, it is recommended that you delay all VM
   1103  * operations until the shared memory object has been created so that the VM
   1104  * system knows that the entire range is intended for sharing.
   1105  */
   1106 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1107 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
   1108 xpc_object_t
   1109 xpc_shmem_create(void *region, size_t length);
   1110 
   1111 /*!
   1112  * @function xpc_shmem_map
   1113  *
   1114  * @abstract
   1115  * Maps the region boxed by the XPC shared memory object into the caller's
   1116  * address space.
   1117  *
   1118  * @param xshmem
   1119  * The shared memory object to be examined.
   1120  *
   1121  * @param region
   1122  * On return, this will point to the region at which the shared memory was
   1123  * mapped.
   1124  *
   1125  * @result
   1126  * The length of the region that was mapped. If the mapping failed or if the
   1127  * given object was not an XPC shared memory object, 0 is returned. The length 
   1128  * of the mapped region will always be an integral page size, even if the
   1129  * creator of the region specified a non-integral page size.
   1130  *
   1131  * @discussion
   1132  * The resulting region must be disposed of with munmap(2).
   1133  *
   1134  * It is the responsibility of the caller to manage protections on the new
   1135  * region accordingly. 
   1136  */
   1137 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1138 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   1139 size_t
   1140 xpc_shmem_map(xpc_object_t xshmem, void * _Nullable * _Nonnull region);
   1141 
   1142 #pragma mark Array
   1143 /*!
   1144  * @typedef xpc_array_applier_t
   1145  * A block to be invoked for every value in the array.
   1146  *
   1147  * @param index
   1148  * The current index in the iteration.
   1149  *
   1150  * @param value
   1151  * The current value in the iteration.
   1152  *
   1153  * @result
   1154  * A Boolean indicating whether iteration should continue.
   1155  */
   1156 #ifdef __BLOCKS__
   1157 typedef bool (^xpc_array_applier_t)(size_t index, xpc_object_t _Nonnull value);
   1158 #endif // __BLOCKS__ 
   1159 
   1160 /*!
   1161  * @function xpc_array_create
   1162  *
   1163  * @abstract
   1164  * Creates an XPC object representing an array of XPC objects.
   1165  *
   1166  * @discussion
   1167  * This array must be contiguous and cannot contain any NULL values. If you
   1168  * wish to insert the equivalent of a NULL value, you may use the result of
   1169  * {@link xpc_null_create}.
   1170  *
   1171  * @param objects
   1172  * An array of XPC objects which is to be boxed. The order of this array is
   1173  * preserved in the object. If this array contains a NULL value, the behavior
   1174  * is undefined. This parameter may be NULL only if the count is 0.
   1175  *
   1176  * @param count
   1177  * The number of objects in the given array. If the number passed is less than
   1178  * the actual number of values in the array, only the specified number of items
   1179  * are inserted into the resulting array. If the number passed is more than
   1180  * the the actual number of values, the behavior is undefined.
   1181  *
   1182  * @result
   1183  * A new array object. 
   1184  */
   1185 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1186 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
   1187 xpc_object_t
   1188 xpc_array_create(
   1189 	const xpc_object_t _Nonnull *XPC_COUNTEDBY(count) _Nullable objects,
   1190 	size_t count);
   1191 
   1192 /*!
   1193  * @function xpc_array_create_empty
   1194  *
   1195  * @abstract
   1196  * Creates an XPC object representing an array of XPC objects.
   1197  *
   1198  * @result
   1199  * A new array object.
   1200  *
   1201  * @see
   1202  * xpc_array_create
   1203  */
   1204 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
   1205 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
   1206 xpc_object_t
   1207 xpc_array_create_empty(void);
   1208 
   1209 /*!
   1210  * @function xpc_array_set_value
   1211  *
   1212  * @abstract
   1213  * Inserts the specified object into the array at the specified index.
   1214  *
   1215  * @param xarray
   1216  * The array object which is to be manipulated.
   1217  *
   1218  * @param index
   1219  * The index at which to insert the value. This value must lie within the index
   1220  * space of the array (0 to N-1 inclusive, where N is the count of the array).
   1221  * If the index is outside that range, the behavior is undefined.
   1222  * 
   1223  * @param value
   1224  * The object to insert. This value is retained by the array and cannot be
   1225  * NULL. If there is already a value at the specified index, it is released,
   1226  * and the new value is inserted in its place.
   1227  */
   1228 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1229 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
   1230 void
   1231 xpc_array_set_value(xpc_object_t xarray, size_t index, xpc_object_t value);
   1232 
   1233 /*!
   1234  * @function xpc_array_append_value
   1235  *
   1236  * @abstract
   1237  * Appends an object to an XPC array.
   1238  *
   1239  * @param xarray
   1240  * The array object which is to be manipulated.
   1241  *
   1242  * @param value
   1243  * The object to append. This object is retained by the array.
   1244  */
   1245 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1246 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
   1247 void
   1248 xpc_array_append_value(xpc_object_t xarray, xpc_object_t value);
   1249 
   1250 /*!
   1251  * @function xpc_array_get_count
   1252  *
   1253  * @abstract
   1254  * Returns the count of values currently in the array.
   1255  *
   1256  * @param xarray
   1257  * The array object which is to be examined.
   1258  *
   1259  * @result
   1260  * The count of values in the array or 0 if the given object was not an XPC 
   1261  * array.
   1262  */
   1263 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1264 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   1265 size_t
   1266 xpc_array_get_count(xpc_object_t xarray);
   1267 
   1268 /*!
   1269  * @function xpc_array_get_value
   1270  *
   1271  * @abstract
   1272  * Returns the value at the specified index in the array.
   1273  *
   1274  * @param xarray
   1275  * The array object which is to be examined.
   1276  *
   1277  * @param index
   1278  * The index of the value to obtain. This value must lie within the range of
   1279  * indexes as specified in xpc_array_set_value().
   1280  * 
   1281  * @result
   1282  * The object at the specified index within the array or NULL if the given
   1283  * object was not an XPC array.
   1284  *
   1285  * @discussion
   1286  * This method does not grant the caller a reference to the underlying object,
   1287  * and thus the caller is not responsible for releasing the object.
   1288  */
   1289 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1290 XPC_EXPORT XPC_NONNULL_ALL
   1291 xpc_object_t
   1292 xpc_array_get_value(xpc_object_t xarray, size_t index);
   1293 
   1294 /*!
   1295  * @function xpc_array_apply
   1296  *
   1297  * @abstract
   1298  * Invokes the given block for every value in the array.
   1299  *
   1300  * @param xarray
   1301  * The array object which is to be examined.
   1302  *
   1303  * @param applier
   1304  * The block which this function applies to every element in the array.
   1305  * 
   1306  * @result
   1307  * A Boolean indicating whether iteration of the array completed successfully.
   1308  * Iteration will only fail if the applier block returns false.
   1309  *
   1310  * @discussion
   1311  * You should not modify an array's contents during iteration. The array indexes
   1312  * are iterated in order.
   1313  */
   1314 #ifdef __BLOCKS__
   1315 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1316 XPC_EXPORT XPC_NONNULL_ALL
   1317 bool
   1318 xpc_array_apply(xpc_object_t xarray, XPC_NOESCAPE xpc_array_applier_t applier);
   1319 #endif // __BLOCKS__ 
   1320 
   1321 #pragma mark Array Primitive Setters
   1322 /*!
   1323  * @define XPC_ARRAY_APPEND
   1324  * A constant that may be passed as the destination index to the class of
   1325  * primitive XPC array setters indicating that the given primitive should be
   1326  * appended to the array.
   1327  */
   1328 #define XPC_ARRAY_APPEND ((size_t)(-1))
   1329 
   1330 /*!
   1331  * @function xpc_array_set_bool
   1332  *
   1333  * @abstract
   1334  * Inserts a <code>bool</code> (primitive) value into an array.
   1335  *
   1336  * @param xarray
   1337  * The array object which is to be manipulated.
   1338  *
   1339  * @param index
   1340  * The index at which to insert the value. This value must lie within the index
   1341  * space of the array (0 to N-1 inclusive, where N is the count of the array) or
   1342  * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
   1343  * undefined.
   1344  *
   1345  * @param value
   1346  * The <code>bool</code> value to insert. After calling this method, the XPC
   1347  * object corresponding to the primitive value inserted may be safely retrieved
   1348  * with {@link xpc_array_get_value()}.
   1349  */
   1350 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1351 XPC_EXPORT XPC_NONNULL1
   1352 void
   1353 xpc_array_set_bool(xpc_object_t xarray, size_t index, bool value);
   1354 
   1355 /*!
   1356  * @function xpc_array_set_int64
   1357  *
   1358  * @abstract
   1359  * Inserts an <code>int64_t</code> (primitive) value into an array.
   1360  *
   1361  * @param xarray
   1362  * The array object which is to be manipulated.
   1363  *
   1364  * @param index
   1365  * The index at which to insert the value. This value must lie within the index
   1366  * space of the array (0 to N-1 inclusive, where N is the count of the array) or
   1367  * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
   1368  * undefined.
   1369  *
   1370  * @param value
   1371  * The <code>int64_t</code> value to insert. After calling this method, the XPC
   1372  * object corresponding to the primitive value inserted may be safely retrieved
   1373  * with {@link xpc_array_get_value()}.
   1374  */
   1375 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1376 XPC_EXPORT XPC_NONNULL1
   1377 void
   1378 xpc_array_set_int64(xpc_object_t xarray, size_t index, int64_t value);
   1379 
   1380 /*!
   1381  * @function xpc_array_set_uint64
   1382  *
   1383  * @abstract
   1384  * Inserts a <code>uint64_t</code> (primitive) value into an array.
   1385  *
   1386  * @param xarray
   1387  * The array object which is to be manipulated.
   1388  *
   1389  * @param index
   1390  * The index at which to insert the value. This value must lie within the index
   1391  * space of the array (0 to N-1 inclusive, where N is the count of the array) or
   1392  * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
   1393  * undefined.
   1394  *
   1395  * @param value
   1396  * The <code>uint64_t</code> value to insert. After calling this method, the XPC
   1397  * object corresponding to the primitive value inserted may be safely retrieved
   1398  * with {@link xpc_array_get_value()}.
   1399  */
   1400 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1401 XPC_EXPORT XPC_NONNULL1
   1402 void
   1403 xpc_array_set_uint64(xpc_object_t xarray, size_t index, uint64_t value);
   1404 
   1405 /*!
   1406  * @function xpc_array_set_double
   1407  *
   1408  * @abstract
   1409  * Inserts a <code>double</code> (primitive) value into an array.
   1410  *
   1411  * @param xarray
   1412  * The array object which is to be manipulated.
   1413  *
   1414  * @param index
   1415  * The index at which to insert the value. This value must lie within the index
   1416  * space of the array (0 to N-1 inclusive, where N is the count of the array) or
   1417  * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
   1418  * undefined.
   1419  *
   1420  * @param value
   1421  * The <code>double</code> value to insert. After calling this method, the XPC
   1422  * object corresponding to the primitive value inserted may be safely retrieved
   1423  * with {@link xpc_array_get_value()}.
   1424  */
   1425 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1426 XPC_EXPORT XPC_NONNULL1
   1427 void
   1428 xpc_array_set_double(xpc_object_t xarray, size_t index, double value);
   1429 
   1430 /*!
   1431  * @function xpc_array_set_date
   1432  *
   1433  * @abstract
   1434  * Inserts a date value into an array.
   1435  *
   1436  * @param xarray
   1437  * The array object which is to be manipulated.
   1438  *
   1439  * @param index
   1440  * The index at which to insert the value. This value must lie within the index
   1441  * space of the array (0 to N-1 inclusive, where N is the count of the array) or
   1442  * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
   1443  * undefined.
   1444  *
   1445  * @param value
   1446  * The date value to insert, represented as an <code>int64_t</code>. After 
   1447  * calling this method, the XPC object corresponding to the primitive value 
   1448  * inserted may be safely retrieved with {@link xpc_array_get_value()}.
   1449  */
   1450 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1451 XPC_EXPORT XPC_NONNULL1
   1452 void
   1453 xpc_array_set_date(xpc_object_t xarray, size_t index, int64_t value);
   1454 
   1455 /*!
   1456  * @function xpc_array_set_data
   1457  *
   1458  * @abstract
   1459  * Inserts a raw data value into an array.
   1460  *
   1461  * @param xarray
   1462  * The array object which is to be manipulated.
   1463  *
   1464  * @param index
   1465  * The index at which to insert the value. This value must lie within the index
   1466  * space of the array (0 to N-1 inclusive, where N is the count of the array) or
   1467  * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
   1468  * undefined.
   1469  *
   1470  * @param bytes
   1471  * The raw data to insert. After calling this method, the XPC object
   1472  * corresponding to the primitive value inserted may be safely retrieved with
   1473  * {@link xpc_array_get_value()}.
   1474  *
   1475  * @param length
   1476  * The length of the data.
   1477  */
   1478 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1479 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
   1480 void
   1481 xpc_array_set_data(xpc_object_t xarray, size_t index,
   1482 	const void *XPC_SIZEDBY(length) bytes, size_t length);
   1483 
   1484 /*!
   1485  * @function xpc_array_set_string
   1486  *
   1487  * @abstract
   1488  * Inserts a C string into an array.
   1489  *
   1490  * @param xarray
   1491  * The array object which is to be manipulated.
   1492  *
   1493  * @param index
   1494  * The index at which to insert the value. This value must lie within the index
   1495  * space of the array (0 to N-1 inclusive, where N is the count of the array) or
   1496  * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
   1497  * undefined.
   1498  *
   1499  * @param string
   1500  * The C string to insert. After calling this method, the XPC object
   1501  * corresponding to the primitive value inserted may be safely retrieved with
   1502  * {@link xpc_array_get_value()}.
   1503  */
   1504 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1505 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
   1506 void
   1507 xpc_array_set_string(xpc_object_t xarray, size_t index, const char *string);
   1508 
   1509 /*!
   1510  * @function xpc_array_set_uuid
   1511  *
   1512  * @abstract
   1513  * Inserts a <code>uuid_t</code> (primitive) value into an array.
   1514  *
   1515  * @param xarray
   1516  * The array object which is to be manipulated.
   1517  *
   1518  * @param index
   1519  * The index at which to insert the value. This value must lie within the index
   1520  * space of the array (0 to N-1 inclusive, where N is the count of the array) or
   1521  * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
   1522  * undefined.
   1523  *
   1524  * @param uuid
   1525  * The UUID primitive to insert. After calling this method, the XPC object
   1526  * corresponding to the primitive value inserted may be safely retrieved with
   1527  * {@link xpc_array_get_value()}.
   1528  */
   1529 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1530 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
   1531 void
   1532 xpc_array_set_uuid(xpc_object_t xarray, size_t index,
   1533 	const uuid_t XPC_NONNULL_ARRAY uuid);
   1534 
   1535 /*!
   1536  * @function xpc_array_set_fd
   1537  *
   1538  * @abstract
   1539  * Inserts a file descriptor into an array.
   1540  *
   1541  * @param xarray
   1542  * The array object which is to be manipulated.
   1543  *
   1544  * @param index
   1545  * The index at which to insert the value. This value must lie within the index
   1546  * space of the array (0 to N-1 inclusive, where N is the count of the array) or
   1547  * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
   1548  * undefined.
   1549  *
   1550  * @param fd
   1551  * The file descriptor to insert. After calling this method, the XPC object
   1552  * corresponding to the primitive value inserted may be safely retrieved with
   1553  * {@link xpc_array_get_value()}.
   1554  */
   1555 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1556 XPC_EXPORT XPC_NONNULL1
   1557 void
   1558 xpc_array_set_fd(xpc_object_t xarray, size_t index, int fd);
   1559 
   1560 /*!
   1561  * @function xpc_array_set_connection
   1562  *
   1563  * @abstract
   1564  * Inserts a connection into an array.
   1565  *
   1566  * @param xarray
   1567  * The array object which is to be manipulated.
   1568  *
   1569  * @param index
   1570  * The index at which to insert the value. This value must lie within the index
   1571  * space of the array (0 to N-1 inclusive, where N is the count of the array) or
   1572  * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is
   1573  * undefined.
   1574  *
   1575  * @param connection
   1576  * The connection to insert. After calling this method, the XPC object
   1577  * corresponding to the primitive value inserted may be safely retrieved with
   1578  * {@link xpc_array_get_value()}. The connection is NOT retained by the array.
   1579  */
   1580 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1581 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
   1582 void
   1583 xpc_array_set_connection(xpc_object_t xarray, size_t index,
   1584 	xpc_connection_t connection);
   1585 
   1586 #pragma mark Array Primitive Getters
   1587 /*!
   1588  * @function xpc_array_get_bool
   1589  *
   1590  * @abstract
   1591  * Gets a <code>bool</code> primitive value from an array directly.
   1592  *
   1593  * @param xarray
   1594  * The array which is to be examined.
   1595  *
   1596  * @param index
   1597  * The index of the value to obtain. This value must lie within the index space
   1598  * of the array (0 to N-1 inclusive, where N is the count of the array). If the
   1599  * index is outside that range, the behavior is undefined.
   1600  *
   1601  * @result
   1602  * The underlying <code>bool</code> value at the specified index. false if the
   1603  * value at the specified index is not a Boolean value.
   1604  */
   1605 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1606 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   1607 bool
   1608 xpc_array_get_bool(xpc_object_t xarray, size_t index);
   1609 
   1610 /*!
   1611  * @function xpc_array_get_int64
   1612  *
   1613  * @abstract
   1614  * Gets an <code>int64_t</code> primitive value from an array directly.
   1615  *
   1616  * @param xarray
   1617  * The array which is to be examined.
   1618  *
   1619  * @param index
   1620  * The index of the value to obtain. This value must lie within the index space
   1621  * of the array (0 to N-1 inclusive, where N is the count of the array). If the
   1622  * index is outside that range, the behavior is undefined.
   1623  *
   1624  * @result
   1625  * The underlying <code>int64_t</code> value at the specified index. 0 if the
   1626  * value at the specified index is not a signed integer value. 
   1627  */
   1628 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1629 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   1630 int64_t
   1631 xpc_array_get_int64(xpc_object_t xarray, size_t index);
   1632 
   1633 /*!
   1634  * @function xpc_array_get_uint64
   1635  *
   1636  * @abstract
   1637  * Gets a <code>uint64_t</code> primitive value from an array directly.
   1638  *
   1639  * @param xarray
   1640  * The array which is to be examined.
   1641  *
   1642  * @param index
   1643  * The index of the value to obtain. This value must lie within the index space
   1644  * of the array (0 to N-1 inclusive, where N is the count of the array). If the
   1645  * index is outside that range, the behavior is undefined.
   1646  *
   1647  * @result
   1648  * The underlying <code>uint64_t</code> value at the specified index. 0 if the
   1649  * value at the specified index is not an unsigned integer value.
   1650  */
   1651 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1652 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   1653 uint64_t
   1654 xpc_array_get_uint64(xpc_object_t xarray, size_t index);
   1655 
   1656 /*!
   1657  * @function xpc_array_get_double
   1658  *
   1659  * @abstract
   1660  * Gets a <code>double</code> primitive value from an array directly.
   1661  *
   1662  * @param xarray
   1663  * The array which is to be examined.
   1664  *
   1665  * @param index
   1666  * The index of the value to obtain. This value must lie within the index space
   1667  * of the array (0 to N-1 inclusive, where N is the count of the array). If the
   1668  * index is outside that range, the behavior is undefined.
   1669  *
   1670  * @result
   1671  * The underlying <code>double</code> value at the specified index. NAN if the
   1672  * value at the specified index is not a floating point value.
   1673  */
   1674 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1675 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   1676 double
   1677 xpc_array_get_double(xpc_object_t xarray, size_t index);
   1678 
   1679 /*!
   1680  * @function xpc_array_get_date
   1681  *
   1682  * @abstract
   1683  * Gets a date interval from an array directly.
   1684  *
   1685  * @param xarray
   1686  * The array which is to be examined.
   1687  *
   1688  * @param index
   1689  * The index of the value to obtain. This value must lie within the index space
   1690  * of the array (0 to N-1 inclusive, where N is the count of the array). If the
   1691  * index is outside that range, the behavior is undefined.
   1692  *
   1693  * @result
   1694  * The underlying date interval at the specified index. 0 if the value at the
   1695  * specified index is not a date value.
   1696  */
   1697 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1698 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   1699 int64_t
   1700 xpc_array_get_date(xpc_object_t xarray, size_t index);
   1701 
   1702 /*!
   1703  * @function xpc_array_get_data
   1704  *
   1705  * @abstract
   1706  * Gets a pointer to the raw bytes of a data object from an array directly.
   1707  *
   1708  * @param xarray
   1709  * The array which is to be examined.
   1710  *
   1711  * @param index
   1712  * The index of the value to obtain. This value must lie within the index space
   1713  * of the array (0 to N-1 inclusive, where N is the count of the array). If the
   1714  * index is outside that range, the behavior is undefined.
   1715  *
   1716  * @param length
   1717  * Upon return output, will contain the length of the data corresponding to the
   1718  * specified key.
   1719  *
   1720  * @result
   1721  * The underlying bytes at the specified index. NULL if the value at the
   1722  * specified index is not a data value.
   1723  */
   1724 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1725 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   1726 const void * _Nullable
   1727 xpc_array_get_data(xpc_object_t xarray, size_t index,
   1728 	size_t * _Nullable length);
   1729 
   1730 /*!
   1731  * @function xpc_array_get_string
   1732  *
   1733  * @abstract
   1734  * Gets a C string value from an array directly.
   1735  *
   1736  * @param xarray
   1737  * The array which is to be examined.
   1738  *
   1739  * @param index
   1740  * The index of the value to obtain. This value must lie within the index space
   1741  * of the array (0 to N-1 inclusive, where N is the count of the array). If the
   1742  * index is outside that range, the behavior is undefined.
   1743  *
   1744  * @result
   1745  * The underlying C string at the specified index. NULL if the value at the
   1746  * specified index is not a C string value.
   1747  */
   1748 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1749 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   1750 const char * _Nullable
   1751 xpc_array_get_string(xpc_object_t xarray, size_t index);
   1752 
   1753 /*!
   1754  * @function xpc_array_get_uuid
   1755  *
   1756  * @abstract
   1757  * Gets a <code>uuid_t</code> value from an array directly.
   1758  *
   1759  * @param xarray
   1760  * The array which is to be examined.
   1761  *
   1762  * @param index
   1763  * The index of the value to obtain. This value must lie within the index space
   1764  * of the array (0 to N-1 inclusive, where N is the count of the array). If the
   1765  * index is outside that range, the behavior is undefined.
   1766  *
   1767  * @result
   1768  * The underlying <code>uuid_t</code> value at the specified index. The null
   1769  * UUID if the value at the specified index is not a UUID value. The returned
   1770  * pointer may be safely passed to the uuid(3) APIs.
   1771  */
   1772 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1773 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   1774 const uint8_t * _Nullable
   1775 xpc_array_get_uuid(xpc_object_t xarray, size_t index);
   1776 
   1777 /*!
   1778  * @function xpc_array_dup_fd
   1779  *
   1780  * @abstract
   1781  * Gets a file descriptor from an array directly.
   1782  *
   1783  * @param xarray
   1784  * The array which is to be examined.
   1785  *
   1786  * @param index
   1787  * The index of the value to obtain. This value must lie within the index space
   1788  * of the array (0 to N-1 inclusive, where N is the count of the array). If the
   1789  * index is outside that range, the behavior is undefined.
   1790  *
   1791  * @result
   1792  * A new file descriptor created from the value at the specified index. You are
   1793  * responsible for close(2)ing this descriptor. -1 if the value at the specified
   1794  * index is not a file descriptor value.
   1795  */
   1796 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1797 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   1798 int
   1799 xpc_array_dup_fd(xpc_object_t xarray, size_t index);
   1800 
   1801 /*!
   1802  * @function xpc_array_create_connection
   1803  *
   1804  * @abstract
   1805  * Creates a connection object from an array directly.
   1806  *
   1807  * @param xarray
   1808  * The array which is to be examined.
   1809  *
   1810  * @param index
   1811  * The index of the value to obtain. This value must lie within the index space
   1812  * of the array (0 to N-1 inclusive, where N is the count of the array). If the
   1813  * index is outside that range, the behavior is undefined.
   1814  *
   1815  * @result
   1816  * A new connection created from the value at the specified index. You are
   1817  * responsible for calling xpc_release() on the returned connection. NULL if the
   1818  * value at the specified index is not an endpoint containing a connection. Each
   1819  * call to this method for the same index in the same array will yield a
   1820  * different connection. See {@link xpc_connection_create_from_endpoint()} for
   1821  * discussion as to the responsibilities when dealing with the returned
   1822  * connection.
   1823  */
   1824 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1825 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1
   1826 xpc_connection_t _Nullable
   1827 xpc_array_create_connection(xpc_object_t xarray, size_t index);
   1828 
   1829 /*!
   1830  * @function xpc_array_get_dictionary
   1831  *
   1832  * @abstract
   1833  * Returns the dictionary at the specified index in the array.
   1834  *
   1835  * @param xarray
   1836  * The array object which is to be examined.
   1837  *
   1838  * @param index
   1839  * The index of the value to obtain. This value must lie within the range of
   1840  * indexes as specified in xpc_array_set_value().
   1841  * 
   1842  * @result
   1843  * The object at the specified index within the array or NULL if the given
   1844  * object was not an XPC array or if the the value at the specified index was
   1845  * not a dictionary.
   1846  *
   1847  * @discussion
   1848  * This method does not grant the caller a reference to the underlying object,
   1849  * and thus the caller is not responsible for releasing the object.
   1850  */
   1851 __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)
   1852 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   1853 xpc_object_t _Nullable
   1854 xpc_array_get_dictionary(xpc_object_t xarray, size_t index);
   1855 
   1856 /*!
   1857  * @function xpc_array_get_array
   1858  *
   1859  * @abstract
   1860  * Returns the array at the specified index in the array.
   1861  *
   1862  * @param xarray
   1863  * The array object which is to be examined.
   1864  *
   1865  * @param index
   1866  * The index of the value to obtain. This value must lie within the range of
   1867  * indexes as specified in xpc_array_set_value().
   1868  * 
   1869  * @result
   1870  * The object at the specified index within the array or NULL if the given
   1871  * object was not an XPC array or if the the value at the specified index was
   1872  * not an array.
   1873  *
   1874  * @discussion
   1875  * This method does not grant the caller a reference to the underlying object,
   1876  * and thus the caller is not responsible for releasing the object.
   1877  */
   1878 __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)
   1879 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   1880 xpc_object_t _Nullable
   1881 xpc_array_get_array(xpc_object_t xarray, size_t index);
   1882 
   1883 #pragma mark Dictionary
   1884 /*!
   1885  * @typedef xpc_dictionary_applier_t
   1886  * A block to be invoked for every key/value pair in the dictionary.
   1887  *
   1888  * @param key
   1889  * The current key in the iteration.
   1890  *
   1891  * @param value
   1892  * The current value in the iteration.
   1893  *
   1894  * @result
   1895  * A Boolean indicating whether iteration should continue.
   1896  */
   1897 #ifdef __BLOCKS__
   1898 typedef bool (^xpc_dictionary_applier_t)(const char * _Nonnull key,
   1899 		xpc_object_t _Nonnull value);
   1900 #endif // __BLOCKS__ 
   1901 
   1902 /*!
   1903  * @function xpc_dictionary_create
   1904  *
   1905  * @abstract
   1906  * Creates an XPC object representing a dictionary of XPC objects keyed to
   1907  * C-strings.
   1908  *
   1909  * @param keys
   1910  * An array of C-strings that are to be the keys for the values to be inserted.
   1911  * Each element of this array is copied into the dictionary's internal storage.
   1912  * Elements of this array may NOT be NULL.
   1913  *
   1914  * @param values
   1915  * A C-array that is parallel to the array of keys, consisting of objects that
   1916  * are to be inserted. Each element in this array is retained. Elements in this
   1917  * array may be NULL.
   1918  *
   1919  * @param count
   1920  * The number of key/value pairs in the given arrays. If the count is less than
   1921  * the actual count of values, only that many key/value pairs will be inserted
   1922  * into the dictionary.
   1923  *
   1924  * If the count is more than the the actual count of key/value pairs, the
   1925  * behavior is undefined. If one array is NULL and the other is not, the 
   1926  * behavior is undefined. If both arrays are NULL and the count is non-0, the
   1927  * behavior is undefined.
   1928  *
   1929  * @result
   1930  * The new dictionary object.
   1931  */
   1932 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1933 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
   1934 xpc_object_t
   1935 xpc_dictionary_create(
   1936 	const char *XPC_CSTRING _Nonnull const *XPC_COUNTEDBY(count) _Nullable keys,
   1937 	const xpc_object_t _Nullable *XPC_COUNTEDBY(count) _Nullable values, size_t count);
   1938 
   1939 /*!
   1940  * @function xpc_dictionary_create_empty
   1941  *
   1942  * @abstract
   1943  * Creates an XPC object representing a dictionary of XPC objects keyed to
   1944  * C-strings.
   1945  *
   1946  * @result
   1947  * The new dictionary object.
   1948  *
   1949  * @see
   1950  * xpc_dictionary_create
   1951  */
   1952 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0))
   1953 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT
   1954 xpc_object_t
   1955 xpc_dictionary_create_empty(void);
   1956 
   1957 /*!
   1958  * @function xpc_dictionary_create_reply
   1959  * 
   1960  * @abstract
   1961  * Creates a dictionary that is in reply to the given dictionary.
   1962  *
   1963  * @param original
   1964  * The original dictionary that is to be replied to.
   1965  *
   1966  * @result
   1967  * The new dictionary object. NULL if the object was not a dictionary with a
   1968  * reply context.
   1969  *
   1970  * @discussion
   1971  * After completing successfully on a dictionary, this method may not be called
   1972  * again on that same dictionary. Attempts to do so will return NULL.
   1973  *
   1974  * When this dictionary is sent across the reply connection, the remote end's
   1975  * reply handler is invoked.
   1976  */
   1977 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   1978 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL
   1979 xpc_object_t _Nullable
   1980 xpc_dictionary_create_reply(xpc_object_t original);
   1981 
   1982 /*!
   1983  * @function xpc_dictionary_set_value
   1984  *
   1985  * @abstract
   1986  * Sets the value for the specified key to the specified object.
   1987  *
   1988  * @param xdict
   1989  * The dictionary object which is to be manipulated.
   1990  *
   1991  * @param key
   1992  * The key for which the value shall be set.
   1993  *
   1994  * @param value
   1995  * The object to insert. The object is retained by the dictionary. If there
   1996  * already exists a value for the specified key, the old value is released
   1997  * and overwritten by the new value. This parameter may be NULL, in which case
   1998  * the value corresponding to the specified key is deleted if present.
   1999  */
   2000 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2001 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
   2002 void
   2003 xpc_dictionary_set_value(xpc_object_t xdict, const char *key,
   2004 	xpc_object_t _Nullable value);
   2005 
   2006 /*!
   2007  * @function xpc_dictionary_get_value
   2008  *
   2009  * @abstract
   2010  * Returns the value for the specified key.
   2011  *
   2012  * @param xdict
   2013  * The dictionary object which is to be examined.
   2014  *
   2015  * @param key
   2016  * The key whose value is to be obtained.
   2017  * 
   2018  * @result
   2019  * The object for the specified key within the dictionary. NULL if there is no
   2020  * value associated with the specified key or if the given object was not an
   2021  * XPC dictionary.
   2022  *
   2023  * @discussion
   2024  * This method does not grant the caller a reference to the underlying object,
   2025  * and thus the caller is not responsible for releasing the object.
   2026  */
   2027 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2028 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2
   2029 xpc_object_t _Nullable
   2030 xpc_dictionary_get_value(xpc_object_t xdict, const char *key);
   2031 
   2032 /*!
   2033  * @function xpc_dictionary_get_count
   2034  *
   2035  * @abstract
   2036  * Returns the number of values stored in the dictionary.
   2037  *
   2038  * @param xdict
   2039  * The dictionary object which is to be examined.
   2040  *
   2041  * @result
   2042  * The number of values stored in the dictionary or 0 if the given object was 
   2043  * not an XPC dictionary. Calling xpc_dictionary_set_value() with a non-NULL
   2044  * value will increment the count. Calling xpc_dictionary_set_value() with a 
   2045  * NULL value will decrement the count.
   2046  */
   2047 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2048 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   2049 size_t
   2050 xpc_dictionary_get_count(xpc_object_t xdict);
   2051 
   2052 /*!
   2053  * @function xpc_dictionary_apply
   2054  *
   2055  * @abstract
   2056  * Invokes the given block for every key/value pair in the dictionary.
   2057  *
   2058  * @param xdict
   2059  * The dictionary object which is to be examined.
   2060  *
   2061  * @param applier
   2062  * The block which this function applies to every key/value pair in the 
   2063  * dictionary.
   2064  * 
   2065  * @result
   2066  * A Boolean indicating whether iteration of the dictionary completed
   2067  * successfully. Iteration will only fail if the applier block returns false.
   2068  *
   2069  * @discussion
   2070  * You should not modify a dictionary's contents during iteration. There is no
   2071  * guaranteed order of iteration over dictionaries.
   2072  */
   2073 #ifdef __BLOCKS__
   2074 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2075 XPC_EXPORT XPC_NONNULL_ALL
   2076 bool
   2077 xpc_dictionary_apply(xpc_object_t xdict,
   2078 		XPC_NOESCAPE xpc_dictionary_applier_t applier);
   2079 #endif // __BLOCKS__ 
   2080 
   2081 /*!
   2082  * @function xpc_dictionary_get_remote_connection
   2083  *
   2084  * @abstract
   2085  * Returns the connection from which the dictionary was received.
   2086  *
   2087  * @param xdict
   2088  * The dictionary object which is to be examined.
   2089  *
   2090  * @result
   2091  * If the dictionary was received by a connection event handler or a dictionary
   2092  * created through xpc_dictionary_create_reply(), a connection object over which
   2093  * a reply message can be sent is returned. For any other dictionary, NULL is
   2094  * returned.
   2095  */
   2096 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2097 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   2098 xpc_connection_t _Nullable
   2099 xpc_dictionary_get_remote_connection(xpc_object_t xdict);
   2100 
   2101 #pragma mark Dictionary Primitive Setters
   2102 /*!
   2103  * @function xpc_dictionary_set_bool
   2104  *
   2105  * @abstract
   2106  * Inserts a <code>bool</code> (primitive) value into a dictionary.
   2107  *
   2108  * @param xdict
   2109  * The dictionary which is to be manipulated.
   2110  *
   2111  * @param key
   2112  * The key for which the primitive value shall be set.
   2113  *
   2114  * @param value
   2115  * The <code>bool</code> value to insert. After calling this method, the XPC
   2116  * object corresponding to the primitive value inserted may be safely retrieved
   2117  * with {@link xpc_dictionary_get_value()}.
   2118  */
   2119 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2120 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
   2121 void
   2122 xpc_dictionary_set_bool(xpc_object_t xdict, const char *key, bool value);
   2123 
   2124 /*!
   2125  * @function xpc_dictionary_set_int64
   2126  *
   2127  * @abstract
   2128  * Inserts an <code>int64_t</code> (primitive) value into a dictionary.
   2129  *
   2130  * @param xdict
   2131  * The dictionary which is to be manipulated.
   2132  *
   2133  * @param key
   2134  * The key for which the primitive value shall be set.
   2135  *
   2136  * @param value
   2137  * The <code>int64_t</code> value to insert. After calling this method, the XPC
   2138  * object corresponding to the primitive value inserted may be safely retrieved
   2139  * with {@link xpc_dictionary_get_value()}.
   2140  */
   2141 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2142 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
   2143 void
   2144 xpc_dictionary_set_int64(xpc_object_t xdict, const char *key, int64_t value);
   2145 
   2146 /*!
   2147  * @function xpc_dictionary_set_uint64
   2148  *
   2149  * @abstract
   2150  * Inserts a <code>uint64_t</code> (primitive) value into a dictionary.
   2151  *
   2152  * @param xdict
   2153  * The dictionary which is to be manipulated.
   2154  *
   2155  * @param key
   2156  * The key for which the primitive value shall be set.
   2157  *
   2158  * @param value
   2159  * The <code>uint64_t</code> value to insert. After calling this method, the XPC
   2160  * object corresponding to the primitive value inserted may be safely retrieved
   2161  * with {@link xpc_dictionary_get_value()}.
   2162  */
   2163 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2164 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
   2165 void
   2166 xpc_dictionary_set_uint64(xpc_object_t xdict, const char *key, uint64_t value);
   2167 
   2168 /*!
   2169  * @function xpc_dictionary_set_double
   2170  *
   2171  * @abstract
   2172  * Inserts a <code>double</code> (primitive) value into a dictionary.
   2173  *
   2174  * @param xdict
   2175  * The dictionary which is to be manipulated.
   2176  *
   2177  * @param key
   2178  * The key for which the primitive value shall be set.
   2179  *
   2180  * @param value
   2181  * The <code>double</code> value to insert. After calling this method, the XPC
   2182  * object corresponding to the primitive value inserted may be safely retrieved
   2183  * with {@link xpc_dictionary_get_value()}.
   2184  */
   2185 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2186 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
   2187 void
   2188 xpc_dictionary_set_double(xpc_object_t xdict, const char *key, double value);
   2189 
   2190 /*!
   2191  * @function xpc_dictionary_set_date
   2192  *
   2193  * @abstract
   2194  * Inserts a date (primitive) value into a dictionary.
   2195  *
   2196  * @param xdict
   2197  * The dictionary which is to be manipulated.
   2198  *
   2199  * @param key
   2200  * The key for which the primitive value shall be set.
   2201  *
   2202  * @param value
   2203  * The date value to insert. After calling this method, the XPC object
   2204  * corresponding to the primitive value inserted may be safely retrieved with
   2205  * {@link xpc_dictionary_get_value()}.
   2206  */
   2207 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2208 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
   2209 void
   2210 xpc_dictionary_set_date(xpc_object_t xdict, const char *key, int64_t value);
   2211 
   2212 /*!
   2213  * @function xpc_dictionary_set_data
   2214  *
   2215  * @abstract
   2216  * Inserts a raw data value into a dictionary.
   2217  *
   2218  * @param xdict
   2219  * The dictionary which is to be manipulated.
   2220  *
   2221  * @param key
   2222  * The key for which the primitive value shall be set.
   2223  *
   2224  * @param bytes
   2225  * The bytes to insert. After calling this method, the XPC object corresponding
   2226  * to the primitive value inserted may be safely retrieved with
   2227  * {@link xpc_dictionary_get_value()}.
   2228  *
   2229  * @param length
   2230  * The length of the data.
   2231  */
   2232 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2233 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3
   2234 void
   2235 xpc_dictionary_set_data(xpc_object_t xdict, const char *key,
   2236 	const void *XPC_SIZEDBY(length) bytes, size_t length);
   2237 
   2238 /*!
   2239  * @function xpc_dictionary_set_string
   2240  *
   2241  * @abstract
   2242  * Inserts a C string value into a dictionary.
   2243  *
   2244  * @param xdict
   2245  * The dictionary which is to be manipulated.
   2246  *
   2247  * @param key
   2248  * The key for which the primitive value shall be set.
   2249  *
   2250  * @param string
   2251  * The C string to insert. After calling this method, the XPC object 
   2252  * corresponding to the primitive value inserted may be safely retrieved with
   2253  * {@link xpc_dictionary_get_value()}.
   2254  */
   2255 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2256 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3
   2257 void
   2258 xpc_dictionary_set_string(xpc_object_t xdict, const char *key,
   2259 	const char *string);
   2260 
   2261 /*!
   2262  * @function xpc_dictionary_set_uuid
   2263  *
   2264  * @abstract
   2265  * Inserts a uuid (primitive) value into an array.
   2266  *
   2267  * @param xdict
   2268  * The dictionary which is to be manipulated.
   2269  *
   2270  * @param key
   2271  * The key for which the primitive value shall be set.
   2272  *
   2273  * @param uuid
   2274  * The <code>uuid_t</code> value to insert. After calling this method, the XPC
   2275  * object corresponding to the primitive value inserted may be safely retrieved
   2276  * with {@link xpc_dictionary_get_value()}.
   2277  */
   2278 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2279 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3
   2280 void
   2281 xpc_dictionary_set_uuid(xpc_object_t xdict, const char *key,
   2282 	const uuid_t XPC_NONNULL_ARRAY uuid);
   2283 
   2284 /*!
   2285  * @function xpc_dictionary_set_fd
   2286  *
   2287  * @abstract
   2288  * Inserts a file descriptor into a dictionary.
   2289  *
   2290  * @param xdict
   2291  * The dictionary which is to be manipulated.
   2292  *
   2293  * @param key
   2294  * The key for which the primitive value shall be set.
   2295  *
   2296  * @param fd
   2297  * The file descriptor to insert. After calling this method, the XPC object
   2298  * corresponding to the primitive value inserted may be safely retrieved
   2299  * with {@link xpc_dictionary_get_value()}.
   2300  */
   2301 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2302 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
   2303 void
   2304 xpc_dictionary_set_fd(xpc_object_t xdict, const char *key, int fd);
   2305 
   2306 /*!
   2307  * @function xpc_dictionary_set_connection
   2308  *
   2309  * @abstract
   2310  * Inserts a connection into a dictionary.
   2311  *
   2312  * @param xdict
   2313  * The dictionary which is to be manipulated.
   2314  *
   2315  * @param key
   2316  * The key for which the primitive value shall be set.
   2317  *
   2318  * @param connection
   2319  * The connection to insert. After calling this method, the XPC object
   2320  * corresponding to the primitive value inserted may be safely retrieved
   2321  * with {@link xpc_dictionary_get_value()}. The connection is NOT retained by
   2322  * the dictionary.
   2323  */
   2324 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2325 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3
   2326 void
   2327 xpc_dictionary_set_connection(xpc_object_t xdict, const char *key,
   2328 	xpc_connection_t connection);
   2329 
   2330 /*!
   2331  * @function xpc_dictionary_set_mach_send
   2332  *
   2333  * @abstract
   2334  * Inserts a send right into a dictionary.
   2335  *
   2336  * @param xdict
   2337  * The dictionary which is to be manipulated.
   2338  *
   2339  * @param key
   2340  * The key for which the primitive value shall be set.
   2341  *
   2342  * @param p
   2343  * The port to insert. After calling this method, the XPC object
   2344  * corresponding to the primitive value inserted may be safely retrieved
   2345  * with {@link xpc_dictionary_copy_mach_send()}.
   2346  *
   2347  * @discussion
   2348  * The XPC runtime sends the port with disposition `MACH_MSG_TYPE_COPY_SEND`
   2349  */
   2350 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2351 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2
   2352 void
   2353 xpc_dictionary_set_mach_send(xpc_object_t xdict, const char *key,
   2354 	mach_port_t p);
   2355 
   2356 #pragma mark Dictionary Primitive Getters
   2357 /*!
   2358  * @function xpc_dictionary_get_bool
   2359  *
   2360  * @abstract
   2361  * Gets a <code>bool</code> primitive value from a dictionary directly.
   2362  *
   2363  * @param xdict
   2364  * The dictionary object which is to be examined.
   2365  *
   2366  * @param key
   2367  * The key whose value is to be obtained.
   2368  *
   2369  * @result
   2370  * The underlying <code>bool</code> value for the specified key. false if the
   2371  * the value for the specified key is not a Boolean value or if there is no
   2372  * value for the specified key.
   2373  */
   2374 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2375 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   2376 bool
   2377 xpc_dictionary_get_bool(xpc_object_t xdict, const char *key);
   2378 
   2379 /*!
   2380  * @function xpc_dictionary_get_int64
   2381  *
   2382  * @abstract
   2383  * Gets an <code>int64</code> primitive value from a dictionary directly.
   2384  *
   2385  * @param xdict
   2386  * The dictionary object which is to be examined.
   2387  *
   2388  * @param key
   2389  * The key whose value is to be obtained.
   2390  *
   2391  * @result
   2392  * The underlying <code>int64_t</code> value for the specified key. 0 if the
   2393  * value for the specified key is not a signed integer value or if there is no
   2394  * value for the specified key.
   2395  */
   2396 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2397 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   2398 int64_t
   2399 xpc_dictionary_get_int64(xpc_object_t xdict, const char *key);
   2400 
   2401 /*!
   2402  * @function xpc_dictionary_get_uint64
   2403  *
   2404  * @abstract
   2405  * Gets a <code>uint64</code> primitive value from a dictionary directly.
   2406  *
   2407  * @param xdict
   2408  * The dictionary object which is to be examined.
   2409  *
   2410  * @param key
   2411  * The key whose value is to be obtained.
   2412  *
   2413  * @result
   2414  * The underlying <code>uint64_t</code> value for the specified key. 0 if the
   2415  * value for the specified key is not an unsigned integer value or if there is
   2416  * no value for the specified key.
   2417  */
   2418 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2419 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   2420 uint64_t
   2421 xpc_dictionary_get_uint64(xpc_object_t xdict, const char *key);
   2422 
   2423 /*!
   2424  * @function xpc_dictionary_get_double
   2425  *
   2426  * @abstract
   2427  * Gets a <code>double</code> primitive value from a dictionary directly.
   2428  *
   2429  * @param xdict
   2430  * The dictionary object which is to be examined.
   2431  *
   2432  * @param key
   2433  * The key whose value is to be obtained.
   2434  *
   2435  * @result
   2436  * The underlying <code>double</code> value for the specified key. NAN if the
   2437  * value for the specified key is not a floating point value or if there is no
   2438  * value for the specified key.
   2439  */
   2440 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2441 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   2442 double
   2443 xpc_dictionary_get_double(xpc_object_t xdict, const char *key);
   2444 
   2445 /*!
   2446  * @function xpc_dictionary_get_date
   2447  *
   2448  * @abstract
   2449  * Gets a date value from a dictionary directly.
   2450  *
   2451  * @param xdict
   2452  * The dictionary object which is to be examined.
   2453  *
   2454  * @param key
   2455  * The key whose value is to be obtained.
   2456  *
   2457  * @result
   2458  * The underlying date interval for the specified key. 0 if the value for the
   2459  * specified key is not a date value or if there is no value for the specified
   2460  * key.
   2461  */
   2462 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2463 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   2464 int64_t
   2465 xpc_dictionary_get_date(xpc_object_t xdict, const char *key);
   2466 
   2467 /*!
   2468  * @function xpc_dictionary_get_data
   2469  *
   2470  * @abstract
   2471  * Gets a raw data value from a dictionary directly.
   2472  *
   2473  * @param xdict
   2474  * The dictionary object which is to be examined.
   2475  *
   2476  * @param key
   2477  * The key whose value is to be obtained.
   2478  *
   2479  * @param length
   2480  * For the data type, the third parameter, upon output, will contain the length
   2481  * of the data corresponding to the specified key. May be NULL.
   2482  *
   2483  * @result
   2484  * The underlying raw data for the specified key. NULL if the value for the
   2485  * specified key is not a data value or if there is no value for the specified
   2486  * key.
   2487  */
   2488 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2489 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1
   2490 const void * _Nullable
   2491 xpc_dictionary_get_data(xpc_object_t xdict, const char *key,
   2492 	size_t * _Nullable length);
   2493 
   2494 /*!
   2495  * @function xpc_dictionary_get_string
   2496  *
   2497  * @abstract
   2498  * Gets a C string value from a dictionary directly.
   2499  *
   2500  * @param xdict
   2501  * The dictionary object which is to be examined.
   2502  *
   2503  * @param key
   2504  * The key whose value is to be obtained.
   2505  *
   2506  * @result
   2507  * The underlying C string for the specified key. NULL if the value for the
   2508  * specified key is not a C string value or if there is no value for the
   2509  * specified key.
   2510  */
   2511 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2512 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   2513 const char * _Nullable
   2514 xpc_dictionary_get_string(xpc_object_t xdict, const char *key);
   2515 
   2516 /*!
   2517  * @function xpc_dictionary_get_uuid
   2518  *
   2519  * @abstract
   2520  * Gets a uuid value from a dictionary directly.
   2521  *
   2522  * @param xdict
   2523  * The dictionary object which is to be examined.
   2524  *
   2525  * @param key
   2526  * The key whose value is to be obtained.
   2527  *
   2528  * @result
   2529  * The underlying <code>uuid_t</code> value for the specified key. NULL if the
   2530  * value at the specified index is not a UUID value. The returned pointer may be
   2531  * safely passed to the uuid(3) APIs.
   2532  */
   2533 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2534 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2
   2535 const uint8_t * _Nullable
   2536 xpc_dictionary_get_uuid(xpc_object_t xdict, const char *key);
   2537 
   2538 /*!
   2539  * @function xpc_dictionary_dup_fd
   2540  *
   2541  * @abstract
   2542  * Creates a file descriptor from a dictionary directly.
   2543  *
   2544  * @param xdict
   2545  * The dictionary object which is to be examined.
   2546  *
   2547  * @param key
   2548  * The key whose value is to be obtained.
   2549  *
   2550  * @result
   2551  * A new file descriptor created from the value for the specified key. You are
   2552  * responsible for close(2)ing this descriptor. -1 if the value for the
   2553  * specified key is not a file descriptor value or if there is no value for the
   2554  * specified key.
   2555  */
   2556 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2557 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   2558 int
   2559 xpc_dictionary_dup_fd(xpc_object_t xdict, const char *key);
   2560 
   2561 /*!
   2562  * @function xpc_dictionary_create_connection
   2563  *
   2564  * @abstract
   2565  * Creates a connection from a dictionary directly.
   2566  *
   2567  * @param xdict
   2568  * The dictionary object which is to be examined.
   2569  *
   2570  * @param key
   2571  * The key whose value is to be obtained.
   2572  *
   2573  * @result
   2574  * A new connection created from the value for the specified key. You are
   2575  * responsible for calling xpc_release() on the returned connection. NULL if the
   2576  * value for the specified key is not an endpoint containing a connection or if
   2577  * there is no value for the specified key. Each call to this method for the
   2578  * same key in the same dictionary will yield a different connection. See
   2579  * {@link xpc_connection_create_from_endpoint()} for discussion as to the
   2580  * responsibilities when dealing with the returned connection.
   2581  */
   2582 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2583 XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL
   2584 xpc_connection_t _Nullable
   2585 xpc_dictionary_create_connection(xpc_object_t xdict, const char *key);
   2586 
   2587 /*!
   2588  * @function xpc_dictionary_get_dictionary
   2589  *
   2590  * @abstract
   2591  * Returns the dictionary value for the specified key.
   2592  *
   2593  * @param xdict
   2594  * The dictionary object which is to be examined.
   2595  *
   2596  * @param key
   2597  * The key whose value is to be obtained.
   2598  * 
   2599  * @result
   2600  * The object for the specified key within the dictionary. NULL if there is no
   2601  * value associated with the specified key, if the given object was not an
   2602  * XPC dictionary, or if the object for the specified key is not a dictionary.
   2603  *
   2604  * @discussion
   2605  * This method does not grant the caller a reference to the underlying object,
   2606  * and thus the caller is not responsible for releasing the object.
   2607  */
   2608 __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)
   2609 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   2610 xpc_object_t _Nullable
   2611 xpc_dictionary_get_dictionary(xpc_object_t xdict, const char *key);
   2612 
   2613 /*!
   2614  * @function xpc_dictionary_get_array
   2615  *
   2616  * @abstract
   2617  * Returns the array value for the specified key.
   2618  *
   2619  * @param xdict
   2620  * The dictionary object which is to be examined.
   2621  *
   2622  * @param key
   2623  * The key whose value is to be obtained.
   2624  * 
   2625  * @result
   2626  * The object for the specified key within the dictionary. NULL if there is no
   2627  * value associated with the specified key, if the given object was not an
   2628  * XPC dictionary, or if the object for the specified key is not an array.
   2629  *
   2630  * @discussion
   2631  * This method does not grant the caller a reference to the underlying object,
   2632  * and thus the caller is not responsible for releasing the object.
   2633  */
   2634 __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0)
   2635 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL
   2636 xpc_object_t _Nullable
   2637 xpc_dictionary_get_array(xpc_object_t xdict, const char *key);
   2638 
   2639 /*!
   2640  * @function xpc_dictionary_copy_mach_send
   2641  *
   2642  * @abstract
   2643  * Returns a send right to the mach port.
   2644  *
   2645  * @param xdict
   2646  * The dictionary object which is to be examined.
   2647  *
   2648  * @param key
   2649  * The key whose value is to be obtained.
   2650  *
   2651  * @result
   2652  * The object for the specified key within the dictionary. `MACH_PORT_NULL`
   2653  * if there is no value associated with the specified key, if the given object
   2654  * was not an XPC dictionary, or if the object for the specified key is not a send
   2655  * right.
   2656  *
   2657  * @discussion
   2658  * The XPC runtime will copy the send right using `mach_port_mod_refs`
   2659  * before returning the port
   2660  */
   2661 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0)
   2662 XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2
   2663 mach_port_t
   2664 xpc_dictionary_copy_mach_send(xpc_object_t xdict, const char *key);
   2665 
   2666 #pragma mark Runtime
   2667 /*!
   2668  * @function xpc_main
   2669  * The springboard into the XPCService runtime. This function will set up your
   2670  * service bundle's listener connection and manage it automatically. After this
   2671  * initial setup, this function will, by default, call dispatch_main(). You may
   2672  * override this behavior by setting the RunLoopType key in your XPC service
   2673  * bundle's Info.plist under the XPCService dictionary.
   2674  *
   2675  * @param handler
   2676  * The handler with which to accept new connections.
   2677  */
   2678 API_AVAILABLE(macos(10.7), macCatalyst(5.0))
   2679 API_UNAVAILABLE(ios)
   2680 XPC_EXPORT XPC_NORETURN XPC_NONNULL1
   2681 void
   2682 xpc_main(xpc_connection_handler_t handler);
   2683 
   2684 #pragma mark Transactions
   2685 /*!
   2686  * @function xpc_transaction_begin
   2687  * Informs the XPC runtime that a transaction has begun and that the service
   2688  * should not exit due to inactivity.
   2689  * 
   2690  * @discussion
   2691  * A service with no outstanding transactions may automatically exit due to
   2692  * inactivity as determined by the system.
   2693  *
   2694  * This function may be used to manually manage transactions in cases where
   2695  * their automatic management (as described below) does not meet the needs of an
   2696  * XPC service. This function also updates the transaction count used for sudden
   2697  * termination, i.e. vproc_transaction_begin(), and these two interfaces may be
   2698  * used in combination.
   2699  *
   2700  * The XPC runtime will automatically begin a transaction on behalf of a service
   2701  * when a new message is received. If no reply message is expected, the
   2702  * transaction is automatically ended when the last reference to the message is released.
   2703  * If a reply message is created, the transaction will end when the reply
   2704  * message is sent or released. An XPC service may use xpc_transaction_begin()
   2705  * and xpc_transaction_end() to inform the XPC runtime about activity that
   2706  * occurs outside of this common pattern.
   2707  *
   2708  * On macOS, when the XPC runtime has determined that the service should exit,
   2709  * the event handlers for all active peer connections will receive
   2710  * {@link XPC_ERROR_TERMINATION_IMMINENT} as an indication that they should
   2711  * unwind their existing transactions. After this error is delivered to a
   2712  * connection's event handler, no more messages will be delivered to the
   2713  * connection.
   2714  */
   2715 API_AVAILABLE(macos(10.7))
   2716 API_UNAVAILABLE(ios)
   2717 XPC_TRANSACTION_DEPRECATED
   2718 XPC_EXPORT
   2719 void
   2720 xpc_transaction_begin(void);
   2721 
   2722 /*!
   2723  * @function xpc_transaction_end
   2724  * Informs the XPC runtime that a transaction has ended.
   2725  * 
   2726  * @discussion
   2727  * As described in {@link xpc_transaction_begin()}, this API may be used
   2728  * interchangeably with vproc_transaction_end().
   2729  *
   2730  * See the discussion for {@link xpc_transaction_begin()} for details regarding
   2731  * the XPC runtime's idle-exit policy.
   2732  */
   2733 API_AVAILABLE(macos(10.7))
   2734 API_UNAVAILABLE(ios)
   2735 XPC_TRANSACTION_DEPRECATED
   2736 XPC_EXPORT
   2737 void
   2738 xpc_transaction_end(void);
   2739 
   2740 #pragma mark XPC Event Stream
   2741 /*!
   2742  * @function xpc_set_event_stream_handler
   2743  * Sets the event handler to invoke when streamed events are received.
   2744  *
   2745  * @param stream
   2746  * The name of the event stream for which this handler will be invoked.
   2747  *
   2748  * @param targetq
   2749  * The GCD queue to which the event handler block will be submitted. This
   2750  * parameter may be NULL, in which case the connection's target queue will be
   2751  * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT.
   2752  * 
   2753  * @param handler
   2754  * The event handler block. The event which this block receives as its first
   2755  * parameter will always be a dictionary which contains the XPC_EVENT_KEY_NAME
   2756  * key. The value for this key will be a string whose value is the name assigned
   2757  * to the XPC event specified in the launchd.plist. Future keys may be added to
   2758  * this dictionary.
   2759  *
   2760  * @discussion
   2761  * Multiple calls to this function for the same event stream will result in
   2762  * undefined behavior.
   2763  *
   2764  * There is no API to pause delivery of XPC events. If a process that
   2765  * has set an XPC event handler exits, events may be dropped due to races
   2766  * between the event handler running and the process exiting.
   2767  */
   2768 #if __BLOCKS__
   2769 API_AVAILABLE(macos(10.7))
   2770 API_UNAVAILABLE(ios)
   2771 XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3
   2772 void
   2773 xpc_set_event_stream_handler(const char *stream,
   2774 	dispatch_queue_t _Nullable targetq, xpc_handler_t handler);
   2775 #endif // __BLOCKS__ 
   2776 
   2777 __END_DECLS
   2778 XPC_ASSUME_NONNULL_END
   2779 
   2780 #endif // __XPC_H__