objc2-system-configuration 0.3.2

Bindings to the SystemConfiguration framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "dispatch2")]
use dispatch2::*;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;

use crate::*;

/// This is the handle to an open a dynamic store session
/// with the system configuration daemon.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/systemconfiguration/scdynamicstore?language=objc)
#[doc(alias = "SCDynamicStoreRef")]
#[repr(C)]
pub struct SCDynamicStore {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

cf_type!(
    unsafe impl SCDynamicStore {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
    unsafe impl RefEncode<"__SCDynamicStore"> for SCDynamicStore {}
);

/// Structure containing user-specified data and callbacks for an
/// SCDynamicStore session.
/// Field: version The version number of the structure type being passed
/// in as a parameter to the SCDynamicStore creation function.
/// This structure is version 0.
/// Field: info A C pointer to a user-specified block of data.
/// Field: retain The callback used to add a retain for the info field.
/// If this parameter is not a pointer to a function of the correct
/// prototype, the behavior is undefined.  The value may be NULL.
/// Field: release The calllback used to remove a retain previously added
/// for the info field.  If this parameter is not a pointer to a
/// function of the correct prototype, the behavior is undefined.
/// The value may be NULL.
/// Field: copyDescription The callback used to provide a description of
/// the info field.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/systemconfiguration/scdynamicstorecontext?language=objc)
#[repr(C)]
#[allow(unpredictable_function_pointer_comparisons)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct SCDynamicStoreContext {
    pub version: CFIndex,
    pub info: *mut c_void,
    pub retain: Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NonNull<c_void>>,
    pub release: Option<unsafe extern "C-unwind" fn(NonNull<c_void>)>,
    pub copyDescription: Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NonNull<CFString>>,
}

#[cfg(feature = "objc2")]
unsafe impl Encode for SCDynamicStoreContext {
    const ENCODING: Encoding = Encoding::Struct(
        "?",
        &[
            <CFIndex>::ENCODING,
            <*mut c_void>::ENCODING,
            <Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NonNull<c_void>>>::ENCODING,
            <Option<unsafe extern "C-unwind" fn(NonNull<c_void>)>>::ENCODING,
            <Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NonNull<CFString>>>::ENCODING,
        ],
    );
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for SCDynamicStoreContext {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Type of callback function used when notification of
/// changes to the dynamic store is delivered.
///
/// Parameter `store`: The dynamic store session.
///
/// Parameter `changedKeys`: The list of changed keys.
///
/// The list includes any specific SCDynamicStore keys that
/// changed (add, update, remove, notify) since the last call
/// to SCDynamicStoreSetNotificationKeys or since the last
/// notification callback. The list also includes any specific
/// keys matching one of the pattern string(s) that changed.
///
/// An empty list indicates that the SCDynamicStore server
/// restarted and that any assumptions based on prior content
/// of the SCDynamicStore should be discarded.
///
///
/// Parameter `info`: A C pointer to a user-specified block of data.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/systemconfiguration/scdynamicstorecallback?language=objc)
pub type SCDynamicStoreCallBack =
    Option<unsafe extern "C-unwind" fn(NonNull<SCDynamicStore>, NonNull<CFArray>, *mut c_void)>;

unsafe impl ConcreteType for SCDynamicStore {
    /// Returns the type identifier of all SCDynamicStore instances.
    #[doc(alias = "SCDynamicStoreGetTypeID")]
    #[inline]
    fn type_id() -> CFTypeID {
        extern "C-unwind" {
            fn SCDynamicStoreGetTypeID() -> CFTypeID;
        }
        unsafe { SCDynamicStoreGetTypeID() }
    }
}

impl SCDynamicStore {
    /// Creates a new session used to interact with the dynamic
    /// store maintained by the System Configuration server.
    ///
    /// Parameter `allocator`: The CFAllocator that should be used to allocate
    /// memory for the local dynamic store object.
    /// This parameter may be NULL in which case the current
    /// default CFAllocator is used. If this reference is not
    /// a valid CFAllocator, the behavior is undefined.
    ///
    /// Parameter `name`: A string that describes the name of the calling
    /// process or plug-in of the caller.
    ///
    /// Parameter `callout`: The function to be called when a watched value
    /// in the dynamic store is changed.
    /// A NULL value can be specified if no callouts are
    /// desired.
    ///
    /// Parameter `context`: The SCDynamicStoreContext associated with the callout.
    ///
    /// Returns: Returns a reference to the new SCDynamicStore session.
    /// You must release the returned value.
    ///
    /// # Safety
    ///
    /// - `callout` must be implemented correctly.
    /// - `context` must be a valid pointer or null.
    #[doc(alias = "SCDynamicStoreCreate")]
    #[inline]
    pub unsafe fn new(
        allocator: Option<&CFAllocator>,
        name: &CFString,
        callout: SCDynamicStoreCallBack,
        context: *mut SCDynamicStoreContext,
    ) -> Option<CFRetained<SCDynamicStore>> {
        extern "C-unwind" {
            fn SCDynamicStoreCreate(
                allocator: Option<&CFAllocator>,
                name: &CFString,
                callout: SCDynamicStoreCallBack,
                context: *mut SCDynamicStoreContext,
            ) -> Option<NonNull<SCDynamicStore>>;
        }
        let ret = unsafe { SCDynamicStoreCreate(allocator, name, callout, context) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Creates a new session used to interact with the dynamic
    /// store maintained by the System Configuration server.
    ///
    /// Parameter `allocator`: The CFAllocator that should be used to allocate
    /// memory for the local dynamic store object.
    /// This parameter may be NULL in which case the current
    /// default CFAllocator is used. If this reference is not
    /// a valid CFAllocator, the behavior is undefined.
    ///
    /// Parameter `name`: A string that describes the name of the calling
    /// process or plug-in of the caller.
    ///
    /// Parameter `storeOptions`: A CFDictionary containing options for the
    /// dynamic store session (such as whether all keys added or set
    /// into the dynamic store should be per-session keys).
    ///
    /// Currently available options include:
    ///
    /// <TABLE
    /// BORDER>
    /// <TR
    /// >
    /// <TH
    /// >key
    /// </TD
    /// >
    /// <TH
    /// >value
    /// </TD
    /// >
    /// </TR
    /// >
    /// <TR
    /// >
    /// <TD
    /// >kSCDynamicStoreUseSessionKeys
    /// </TD
    /// >
    /// <TD
    /// >CFBooleanRef
    /// </TD
    /// >
    /// </TR
    /// >
    /// </TABLE
    /// >
    ///
    /// A NULL value can be specified if no options are desired.
    ///
    /// Parameter `callout`: The function to be called when a watched value
    /// in the dynamic store is changed.
    /// A NULL value can be specified if no callouts are
    /// desired.
    ///
    /// Parameter `context`: The SCDynamicStoreContext associated with the callout.
    ///
    /// Returns: Returns a reference to the new SCDynamicStore session.
    /// You must release the returned value.
    ///
    /// # Safety
    ///
    /// - `store_options` generics must be of the correct type.
    /// - `callout` must be implemented correctly.
    /// - `context` must be a valid pointer or null.
    #[doc(alias = "SCDynamicStoreCreateWithOptions")]
    #[inline]
    pub unsafe fn with_options(
        allocator: Option<&CFAllocator>,
        name: &CFString,
        store_options: Option<&CFDictionary>,
        callout: SCDynamicStoreCallBack,
        context: *mut SCDynamicStoreContext,
    ) -> Option<CFRetained<SCDynamicStore>> {
        extern "C-unwind" {
            fn SCDynamicStoreCreateWithOptions(
                allocator: Option<&CFAllocator>,
                name: &CFString,
                store_options: Option<&CFDictionary>,
                callout: SCDynamicStoreCallBack,
                context: *mut SCDynamicStoreContext,
            ) -> Option<NonNull<SCDynamicStore>>;
        }
        let ret = unsafe {
            SCDynamicStoreCreateWithOptions(allocator, name, store_options, callout, context)
        };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/systemconfiguration/kscdynamicstoreusesessionkeys?language=objc)
    pub static kSCDynamicStoreUseSessionKeys: &'static CFString;
}

impl SCDynamicStore {
    /// Creates a CFRunLoopSource object that can be added to the
    /// application's run loop.  All dynamic store notifications are
    /// delivered using this run loop source.
    ///
    /// Parameter `allocator`: The CFAllocator that should be used to allocate
    /// memory for this run loop source.
    /// This parameter may be NULL in which case the current
    /// default CFAllocator is used. If this reference is not
    /// a valid CFAllocator, the behavior is undefined.
    ///
    /// Parameter `store`: A reference to the dynamic store session.
    ///
    /// Parameter `order`: On platforms which support it, for source versions
    /// which support it, this parameter determines the order in
    /// which the sources which are ready to be processed are
    /// handled. A lower order number causes processing before
    /// higher order number sources. It is inadvisable to depend
    /// on the order number for any architectural or design aspect
    /// of code. In the absence of any reason to do otherwise,
    /// zero should be used.
    ///
    /// Returns: A reference to the new CFRunLoopSource.
    /// You must release the returned value.
    #[doc(alias = "SCDynamicStoreCreateRunLoopSource")]
    #[inline]
    pub fn new_run_loop_source(
        allocator: Option<&CFAllocator>,
        store: &SCDynamicStore,
        order: CFIndex,
    ) -> Option<CFRetained<CFRunLoopSource>> {
        extern "C-unwind" {
            fn SCDynamicStoreCreateRunLoopSource(
                allocator: Option<&CFAllocator>,
                store: &SCDynamicStore,
                order: CFIndex,
            ) -> Option<NonNull<CFRunLoopSource>>;
        }
        let ret = unsafe { SCDynamicStoreCreateRunLoopSource(allocator, store, order) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Initiates notifications for the Notification
    /// Keys in store to the callback contained in store.
    ///
    /// Parameter `store`: A reference to the dynamic store session.
    ///
    /// Parameter `queue`: The dispatch queue to run the callback function on.
    /// Pass NULL to disable notifications, and release the queue.
    ///
    /// Returns: Returns TRUE on success, FALSE on failure.
    ///
    /// # Safety
    ///
    /// `queue` possibly has additional threading requirements.
    #[doc(alias = "SCDynamicStoreSetDispatchQueue")]
    #[cfg(feature = "dispatch2")]
    #[inline]
    pub unsafe fn set_dispatch_queue(&self, queue: Option<&DispatchQueue>) -> bool {
        extern "C-unwind" {
            fn SCDynamicStoreSetDispatchQueue(
                store: &SCDynamicStore,
                queue: Option<&DispatchQueue>,
            ) -> Boolean;
        }
        let ret = unsafe { SCDynamicStoreSetDispatchQueue(self, queue) };
        ret != 0
    }

    /// Returns an array of CFString keys representing the
    /// current dynamic store entries that match a specified pattern.
    ///
    /// Parameter `store`: The dynamic store session.
    ///
    /// Parameter `pattern`: A regex(3) regular expression pattern
    /// used to match the dynamic store keys.
    ///
    /// Returns: Returns the list of matching keys; NULL if an error was
    /// encountered.
    /// You must release the returned value.
    #[doc(alias = "SCDynamicStoreCopyKeyList")]
    #[inline]
    pub fn key_list(
        store: Option<&SCDynamicStore>,
        pattern: &CFString,
    ) -> Option<CFRetained<CFArray>> {
        extern "C-unwind" {
            fn SCDynamicStoreCopyKeyList(
                store: Option<&SCDynamicStore>,
                pattern: &CFString,
            ) -> Option<NonNull<CFArray>>;
        }
        let ret = unsafe { SCDynamicStoreCopyKeyList(store, pattern) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Adds the key-value pair to the dynamic store if no
    /// such key already exists.
    ///
    /// Parameter `store`: The dynamic store session.
    ///
    /// Parameter `key`: The key of the value to add to the dynamic store.
    ///
    /// Parameter `value`: The value to add to the dynamic store.
    ///
    /// Returns: Returns TRUE if the key was added; FALSE if the key was already
    /// present in the dynamic store or if an error was encountered.
    ///
    /// # Safety
    ///
    /// `value` should be of the correct type.
    #[doc(alias = "SCDynamicStoreAddValue")]
    #[inline]
    pub unsafe fn add_value(
        store: Option<&SCDynamicStore>,
        key: &CFString,
        value: &CFPropertyList,
    ) -> bool {
        extern "C-unwind" {
            fn SCDynamicStoreAddValue(
                store: Option<&SCDynamicStore>,
                key: &CFString,
                value: &CFPropertyList,
            ) -> Boolean;
        }
        let ret = unsafe { SCDynamicStoreAddValue(store, key, value) };
        ret != 0
    }

    /// Temporarily adds the key-value pair to the dynamic store
    /// if no such key already exists.  Unless the key is updated by another
    /// session, the key-value pair will be removed automatically when the
    /// session is closed.
    ///
    /// Parameter `store`: The dynamic store session.
    ///
    /// Parameter `key`: The key of the value to add to the dynamic store.
    ///
    /// Parameter `value`: The value to add to the dynamic store.
    ///
    /// Returns: Returns TRUE if the key was added; FALSE if the key was already
    /// present in the dynamic store or if an error was encountered.
    ///
    /// # Safety
    ///
    /// `value` should be of the correct type.
    #[doc(alias = "SCDynamicStoreAddTemporaryValue")]
    #[inline]
    pub unsafe fn add_temporary_value(&self, key: &CFString, value: &CFPropertyList) -> bool {
        extern "C-unwind" {
            fn SCDynamicStoreAddTemporaryValue(
                store: &SCDynamicStore,
                key: &CFString,
                value: &CFPropertyList,
            ) -> Boolean;
        }
        let ret = unsafe { SCDynamicStoreAddTemporaryValue(self, key, value) };
        ret != 0
    }

    /// Gets the value of the specified key from the dynamic store.
    ///
    /// Parameter `store`: The dynamic store session.
    ///
    /// Parameter `key`: The key associated with the value you want to get.
    ///
    /// Returns: Returns the value from the dynamic store that is associated with the given
    /// key; NULL if no value was located or an error was encountered.
    /// You must release the returned value.
    #[doc(alias = "SCDynamicStoreCopyValue")]
    #[inline]
    pub fn value(
        store: Option<&SCDynamicStore>,
        key: &CFString,
    ) -> Option<CFRetained<CFPropertyList>> {
        extern "C-unwind" {
            fn SCDynamicStoreCopyValue(
                store: Option<&SCDynamicStore>,
                key: &CFString,
            ) -> Option<NonNull<CFPropertyList>>;
        }
        let ret = unsafe { SCDynamicStoreCopyValue(store, key) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Gets the values of multiple keys in the dynamic store.
    ///
    /// Parameter `store`: The dynamic store session.
    ///
    /// Parameter `keys`: The keys associated with the values you want to get; NULL if no specific
    /// keys are requested.
    ///
    /// Parameter `patterns`: An array of regex(3) pattern strings used to match the keys; NULL
    /// if no key patterns are requested.
    ///
    /// Returns: Returns a dictionary containing the key-value pairs of specific keys and the
    /// key-value pairs of keys that matched the specified patterns;
    /// NULL if an error was encountered.
    /// You must release the returned value.
    ///
    /// # Safety
    ///
    /// - `keys` generic must be of the correct type.
    /// - `patterns` generic must be of the correct type.
    #[doc(alias = "SCDynamicStoreCopyMultiple")]
    #[inline]
    pub unsafe fn multiple(
        store: Option<&SCDynamicStore>,
        keys: Option<&CFArray>,
        patterns: Option<&CFArray>,
    ) -> Option<CFRetained<CFDictionary>> {
        extern "C-unwind" {
            fn SCDynamicStoreCopyMultiple(
                store: Option<&SCDynamicStore>,
                keys: Option<&CFArray>,
                patterns: Option<&CFArray>,
            ) -> Option<NonNull<CFDictionary>>;
        }
        let ret = unsafe { SCDynamicStoreCopyMultiple(store, keys, patterns) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    /// Adds or replaces a value in the dynamic store for
    /// the specified key.
    ///
    /// Parameter `store`: The dynamic store session.
    ///
    /// Parameter `key`: The key you want to set.
    ///
    /// Parameter `value`: The value to add to or replace in the dynamic store.
    ///
    /// Returns: Returns TRUE if the key was updated; FALSE if an error was encountered.
    ///
    /// # Safety
    ///
    /// `value` should be of the correct type.
    #[doc(alias = "SCDynamicStoreSetValue")]
    #[inline]
    pub unsafe fn set_value(
        store: Option<&SCDynamicStore>,
        key: &CFString,
        value: &CFPropertyList,
    ) -> bool {
        extern "C-unwind" {
            fn SCDynamicStoreSetValue(
                store: Option<&SCDynamicStore>,
                key: &CFString,
                value: &CFPropertyList,
            ) -> Boolean;
        }
        let ret = unsafe { SCDynamicStoreSetValue(store, key, value) };
        ret != 0
    }

    /// Updates multiple values in the dynamic store.
    ///
    /// Parameter `store`: The dynamic store session.
    ///
    /// Parameter `keysToSet`: A dictionary of key-value pairs you want to set into the dynamic store.
    ///
    /// Parameter `keysToRemove`: An array of keys you want to remove from the dynamic store.
    ///
    /// Parameter `keysToNotify`: An array of keys to flag as changed (without changing their values).
    ///
    /// Returns: Returns TRUE if the dynamic store updates were successful; FALSE if an error was encountered.
    ///
    /// # Safety
    ///
    /// - `keys_to_set` generics must be of the correct type.
    /// - `keys_to_remove` generic must be of the correct type.
    /// - `keys_to_notify` generic must be of the correct type.
    #[doc(alias = "SCDynamicStoreSetMultiple")]
    #[inline]
    pub unsafe fn set_multiple(
        store: Option<&SCDynamicStore>,
        keys_to_set: Option<&CFDictionary>,
        keys_to_remove: Option<&CFArray>,
        keys_to_notify: Option<&CFArray>,
    ) -> bool {
        extern "C-unwind" {
            fn SCDynamicStoreSetMultiple(
                store: Option<&SCDynamicStore>,
                keys_to_set: Option<&CFDictionary>,
                keys_to_remove: Option<&CFArray>,
                keys_to_notify: Option<&CFArray>,
            ) -> Boolean;
        }
        let ret = unsafe {
            SCDynamicStoreSetMultiple(store, keys_to_set, keys_to_remove, keys_to_notify)
        };
        ret != 0
    }

    /// Removes the value of the specified key from the
    /// dynamic store.
    ///
    /// Parameter `store`: The dynamic store session.
    ///
    /// Parameter `key`: The key of the value you want to remove.
    ///
    /// Returns: Returns TRUE if the key was removed; FALSE if no value was
    /// located or an error was encountered.
    #[doc(alias = "SCDynamicStoreRemoveValue")]
    #[inline]
    pub fn remove_value(store: Option<&SCDynamicStore>, key: &CFString) -> bool {
        extern "C-unwind" {
            fn SCDynamicStoreRemoveValue(store: Option<&SCDynamicStore>, key: &CFString)
                -> Boolean;
        }
        let ret = unsafe { SCDynamicStoreRemoveValue(store, key) };
        ret != 0
    }

    /// Triggers a notification to be delivered for the
    /// specified key in the dynamic store.
    ///
    /// Parameter `store`: The dynamic store session.
    ///
    /// Parameter `key`: The key that should be flagged as changed.  Any dynamic store sessions
    /// that are monitoring this key will received a notification.  Note that the
    /// key's value is not updated.
    ///
    /// Returns: Returns TRUE if the notification was processed; FALSE if an error was encountered.
    #[doc(alias = "SCDynamicStoreNotifyValue")]
    #[inline]
    pub fn notify_value(store: Option<&SCDynamicStore>, key: &CFString) -> bool {
        extern "C-unwind" {
            fn SCDynamicStoreNotifyValue(store: Option<&SCDynamicStore>, key: &CFString)
                -> Boolean;
        }
        let ret = unsafe { SCDynamicStoreNotifyValue(store, key) };
        ret != 0
    }

    /// Specifies a set of specific keys and key patterns
    /// that should be monitored for changes.
    ///
    /// Parameter `store`: The dynamic store session being watched.
    ///
    /// Parameter `keys`: An array of keys to be monitored; NULL if no specific keys
    /// are to be monitored.
    ///
    /// Parameter `patterns`: An array of regex(3) pattern strings used to match keys to be monitored;
    /// NULL if no key patterns are to be monitored.
    ///
    /// Returns: Returns TRUE if the set of notification keys and patterns was successfully
    /// updated; FALSE if an error was encountered.
    ///
    /// # Safety
    ///
    /// - `keys` generic must be of the correct type.
    /// - `patterns` generic must be of the correct type.
    #[doc(alias = "SCDynamicStoreSetNotificationKeys")]
    #[inline]
    pub unsafe fn set_notification_keys(
        &self,
        keys: Option<&CFArray>,
        patterns: Option<&CFArray>,
    ) -> bool {
        extern "C-unwind" {
            fn SCDynamicStoreSetNotificationKeys(
                store: &SCDynamicStore,
                keys: Option<&CFArray>,
                patterns: Option<&CFArray>,
            ) -> Boolean;
        }
        let ret = unsafe { SCDynamicStoreSetNotificationKeys(self, keys, patterns) };
        ret != 0
    }

    /// Returns an array of CFString keys representing the
    /// dynamic store entries that have changed since this
    /// function was last called.  If possible, your application should
    /// use the notification functions instead of polling for the list
    /// of changed keys returned by this function.
    ///
    /// Parameter `store`: The dynamic store session.
    ///
    /// Returns: Returns the list of changed keys;
    /// NULL if an error was encountered.
    /// You must release the returned value.
    #[doc(alias = "SCDynamicStoreCopyNotifiedKeys")]
    #[inline]
    pub fn notified_keys(&self) -> Option<CFRetained<CFArray>> {
        extern "C-unwind" {
            fn SCDynamicStoreCopyNotifiedKeys(store: &SCDynamicStore) -> Option<NonNull<CFArray>>;
        }
        let ret = unsafe { SCDynamicStoreCopyNotifiedKeys(self) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }
}

#[deprecated = "renamed to `SCDynamicStore::new`"]
#[inline]
pub unsafe extern "C-unwind" fn SCDynamicStoreCreate(
    allocator: Option<&CFAllocator>,
    name: &CFString,
    callout: SCDynamicStoreCallBack,
    context: *mut SCDynamicStoreContext,
) -> Option<CFRetained<SCDynamicStore>> {
    extern "C-unwind" {
        fn SCDynamicStoreCreate(
            allocator: Option<&CFAllocator>,
            name: &CFString,
            callout: SCDynamicStoreCallBack,
            context: *mut SCDynamicStoreContext,
        ) -> Option<NonNull<SCDynamicStore>>;
    }
    let ret = unsafe { SCDynamicStoreCreate(allocator, name, callout, context) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `SCDynamicStore::with_options`"]
#[inline]
pub unsafe extern "C-unwind" fn SCDynamicStoreCreateWithOptions(
    allocator: Option<&CFAllocator>,
    name: &CFString,
    store_options: Option<&CFDictionary>,
    callout: SCDynamicStoreCallBack,
    context: *mut SCDynamicStoreContext,
) -> Option<CFRetained<SCDynamicStore>> {
    extern "C-unwind" {
        fn SCDynamicStoreCreateWithOptions(
            allocator: Option<&CFAllocator>,
            name: &CFString,
            store_options: Option<&CFDictionary>,
            callout: SCDynamicStoreCallBack,
            context: *mut SCDynamicStoreContext,
        ) -> Option<NonNull<SCDynamicStore>>;
    }
    let ret = unsafe {
        SCDynamicStoreCreateWithOptions(allocator, name, store_options, callout, context)
    };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `SCDynamicStore::new_run_loop_source`"]
#[inline]
pub extern "C-unwind" fn SCDynamicStoreCreateRunLoopSource(
    allocator: Option<&CFAllocator>,
    store: &SCDynamicStore,
    order: CFIndex,
) -> Option<CFRetained<CFRunLoopSource>> {
    extern "C-unwind" {
        fn SCDynamicStoreCreateRunLoopSource(
            allocator: Option<&CFAllocator>,
            store: &SCDynamicStore,
            order: CFIndex,
        ) -> Option<NonNull<CFRunLoopSource>>;
    }
    let ret = unsafe { SCDynamicStoreCreateRunLoopSource(allocator, store, order) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "dispatch2")]
#[deprecated = "renamed to `SCDynamicStore::set_dispatch_queue`"]
#[inline]
pub unsafe extern "C-unwind" fn SCDynamicStoreSetDispatchQueue(
    store: &SCDynamicStore,
    queue: Option<&DispatchQueue>,
) -> bool {
    extern "C-unwind" {
        fn SCDynamicStoreSetDispatchQueue(
            store: &SCDynamicStore,
            queue: Option<&DispatchQueue>,
        ) -> Boolean;
    }
    let ret = unsafe { SCDynamicStoreSetDispatchQueue(store, queue) };
    ret != 0
}

#[deprecated = "renamed to `SCDynamicStore::key_list`"]
#[inline]
pub extern "C-unwind" fn SCDynamicStoreCopyKeyList(
    store: Option<&SCDynamicStore>,
    pattern: &CFString,
) -> Option<CFRetained<CFArray>> {
    extern "C-unwind" {
        fn SCDynamicStoreCopyKeyList(
            store: Option<&SCDynamicStore>,
            pattern: &CFString,
        ) -> Option<NonNull<CFArray>>;
    }
    let ret = unsafe { SCDynamicStoreCopyKeyList(store, pattern) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `SCDynamicStore::add_value`"]
#[inline]
pub unsafe extern "C-unwind" fn SCDynamicStoreAddValue(
    store: Option<&SCDynamicStore>,
    key: &CFString,
    value: &CFPropertyList,
) -> bool {
    extern "C-unwind" {
        fn SCDynamicStoreAddValue(
            store: Option<&SCDynamicStore>,
            key: &CFString,
            value: &CFPropertyList,
        ) -> Boolean;
    }
    let ret = unsafe { SCDynamicStoreAddValue(store, key, value) };
    ret != 0
}

#[deprecated = "renamed to `SCDynamicStore::add_temporary_value`"]
#[inline]
pub unsafe extern "C-unwind" fn SCDynamicStoreAddTemporaryValue(
    store: &SCDynamicStore,
    key: &CFString,
    value: &CFPropertyList,
) -> bool {
    extern "C-unwind" {
        fn SCDynamicStoreAddTemporaryValue(
            store: &SCDynamicStore,
            key: &CFString,
            value: &CFPropertyList,
        ) -> Boolean;
    }
    let ret = unsafe { SCDynamicStoreAddTemporaryValue(store, key, value) };
    ret != 0
}

#[deprecated = "renamed to `SCDynamicStore::value`"]
#[inline]
pub extern "C-unwind" fn SCDynamicStoreCopyValue(
    store: Option<&SCDynamicStore>,
    key: &CFString,
) -> Option<CFRetained<CFPropertyList>> {
    extern "C-unwind" {
        fn SCDynamicStoreCopyValue(
            store: Option<&SCDynamicStore>,
            key: &CFString,
        ) -> Option<NonNull<CFPropertyList>>;
    }
    let ret = unsafe { SCDynamicStoreCopyValue(store, key) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `SCDynamicStore::multiple`"]
#[inline]
pub unsafe extern "C-unwind" fn SCDynamicStoreCopyMultiple(
    store: Option<&SCDynamicStore>,
    keys: Option<&CFArray>,
    patterns: Option<&CFArray>,
) -> Option<CFRetained<CFDictionary>> {
    extern "C-unwind" {
        fn SCDynamicStoreCopyMultiple(
            store: Option<&SCDynamicStore>,
            keys: Option<&CFArray>,
            patterns: Option<&CFArray>,
        ) -> Option<NonNull<CFDictionary>>;
    }
    let ret = unsafe { SCDynamicStoreCopyMultiple(store, keys, patterns) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `SCDynamicStore::set_value`"]
#[inline]
pub unsafe extern "C-unwind" fn SCDynamicStoreSetValue(
    store: Option<&SCDynamicStore>,
    key: &CFString,
    value: &CFPropertyList,
) -> bool {
    extern "C-unwind" {
        fn SCDynamicStoreSetValue(
            store: Option<&SCDynamicStore>,
            key: &CFString,
            value: &CFPropertyList,
        ) -> Boolean;
    }
    let ret = unsafe { SCDynamicStoreSetValue(store, key, value) };
    ret != 0
}

#[deprecated = "renamed to `SCDynamicStore::set_multiple`"]
#[inline]
pub unsafe extern "C-unwind" fn SCDynamicStoreSetMultiple(
    store: Option<&SCDynamicStore>,
    keys_to_set: Option<&CFDictionary>,
    keys_to_remove: Option<&CFArray>,
    keys_to_notify: Option<&CFArray>,
) -> bool {
    extern "C-unwind" {
        fn SCDynamicStoreSetMultiple(
            store: Option<&SCDynamicStore>,
            keys_to_set: Option<&CFDictionary>,
            keys_to_remove: Option<&CFArray>,
            keys_to_notify: Option<&CFArray>,
        ) -> Boolean;
    }
    let ret =
        unsafe { SCDynamicStoreSetMultiple(store, keys_to_set, keys_to_remove, keys_to_notify) };
    ret != 0
}

#[deprecated = "renamed to `SCDynamicStore::remove_value`"]
#[inline]
pub extern "C-unwind" fn SCDynamicStoreRemoveValue(
    store: Option<&SCDynamicStore>,
    key: &CFString,
) -> bool {
    extern "C-unwind" {
        fn SCDynamicStoreRemoveValue(store: Option<&SCDynamicStore>, key: &CFString) -> Boolean;
    }
    let ret = unsafe { SCDynamicStoreRemoveValue(store, key) };
    ret != 0
}

#[deprecated = "renamed to `SCDynamicStore::notify_value`"]
#[inline]
pub extern "C-unwind" fn SCDynamicStoreNotifyValue(
    store: Option<&SCDynamicStore>,
    key: &CFString,
) -> bool {
    extern "C-unwind" {
        fn SCDynamicStoreNotifyValue(store: Option<&SCDynamicStore>, key: &CFString) -> Boolean;
    }
    let ret = unsafe { SCDynamicStoreNotifyValue(store, key) };
    ret != 0
}

#[deprecated = "renamed to `SCDynamicStore::set_notification_keys`"]
#[inline]
pub unsafe extern "C-unwind" fn SCDynamicStoreSetNotificationKeys(
    store: &SCDynamicStore,
    keys: Option<&CFArray>,
    patterns: Option<&CFArray>,
) -> bool {
    extern "C-unwind" {
        fn SCDynamicStoreSetNotificationKeys(
            store: &SCDynamicStore,
            keys: Option<&CFArray>,
            patterns: Option<&CFArray>,
        ) -> Boolean;
    }
    let ret = unsafe { SCDynamicStoreSetNotificationKeys(store, keys, patterns) };
    ret != 0
}

#[deprecated = "renamed to `SCDynamicStore::notified_keys`"]
#[inline]
pub extern "C-unwind" fn SCDynamicStoreCopyNotifiedKeys(
    store: &SCDynamicStore,
) -> Option<CFRetained<CFArray>> {
    extern "C-unwind" {
        fn SCDynamicStoreCopyNotifiedKeys(store: &SCDynamicStore) -> Option<NonNull<CFArray>>;
    }
    let ret = unsafe { SCDynamicStoreCopyNotifiedKeys(store) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}