objc2-security 0.3.2

Bindings to the Security 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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;

use crate::*;

/// Within a transform, each of its attributes is a collection of
/// "metadata attributes", of which name and current value are two. The
/// value is directly visible from outside; the other metadata
/// attributes direct the behavior of the transform and
/// its function within its group. Each attribute may be tailored by setting its metadata.
///
///
/// The actual value of the attribute. The attribute value has a default
/// value of NULL.
///
///
/// The name of the attribute. Attribute name is read only and may
/// not be used with the SecTransformSetAttributeBlock block.
///
///
/// A direct reference to an attribute's value. This reference allows
/// for direct access to an attribute without having to look up the
/// attribute by name.  If a transform commonly uses an attribute, using
/// a reference speeds up the use of that attribute. Attribute
/// references are not visible or valid from outside of the particular
/// transform instance.
///
///
/// Specifies if an attribute must have a non NULL value set or have an
/// incoming connection before the transform starts to execute. This
/// metadata has a default value of true for the input attribute, but
/// false for all other attributes.
///
///
/// Specifies if an attribute must have an outbound connection. This
/// metadata has a default value of true for the output attribute but is
/// false for all other attributes.
///
///
/// Determines if the AttributeSetNotification notification or the
/// ProcessData blocks are deferred until SecExecuteTransform is called.
/// This metadata value has a default value of true for the input
/// attribute but is false for all other attributes.
///
///
/// Specifies if the attribute should expect a series of values ending
/// with a NULL to specify the end of the data stream. This metadata has
/// a default value of true for the input and output attributes, but is
/// false for all other attributes.
///
///
/// A Transform group is a directed graph which is typically acyclic.
/// Some transforms need to work with cycles. For example, a transform
/// that emits a header and trailer around the data of another transform
/// must create a cycle. If this metadata set to true, no error is
/// returned if a cycle is detected for this attribute.
///
///
/// Specifies if this attribute should be written out when creating the
/// external representation of this transform. This metadata has a
/// default value of true.
///
///
/// This metadata value is true if the attribute has an outbound
/// connection. This metadata is read only.
///
///
/// This metadata value is true if the attribute has an inbound
/// connection. This metadata is read only.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformmetaattributetype?language=objc)
// NS_ENUM
#[deprecated = "SecTransform is no longer supported"]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SecTransformMetaAttributeType(pub CFIndex);
impl SecTransformMetaAttributeType {
    #[doc(alias = "kSecTransformMetaAttributeValue")]
    #[deprecated = "SecTransform is no longer supported"]
    pub const Value: Self = Self(0);
    #[doc(alias = "kSecTransformMetaAttributeName")]
    #[deprecated = "SecTransform is no longer supported"]
    pub const Name: Self = Self(1);
    #[doc(alias = "kSecTransformMetaAttributeRef")]
    #[deprecated = "SecTransform is no longer supported"]
    pub const Ref: Self = Self(2);
    #[doc(alias = "kSecTransformMetaAttributeRequired")]
    #[deprecated = "SecTransform is no longer supported"]
    pub const Required: Self = Self(3);
    #[doc(alias = "kSecTransformMetaAttributeRequiresOutboundConnection")]
    #[deprecated = "SecTransform is no longer supported"]
    pub const RequiresOutboundConnection: Self = Self(4);
    #[doc(alias = "kSecTransformMetaAttributeDeferred")]
    #[deprecated = "SecTransform is no longer supported"]
    pub const Deferred: Self = Self(5);
    #[doc(alias = "kSecTransformMetaAttributeStream")]
    #[deprecated = "SecTransform is no longer supported"]
    pub const Stream: Self = Self(6);
    #[doc(alias = "kSecTransformMetaAttributeCanCycle")]
    #[deprecated = "SecTransform is no longer supported"]
    pub const CanCycle: Self = Self(7);
    #[doc(alias = "kSecTransformMetaAttributeExternalize")]
    #[deprecated = "SecTransform is no longer supported"]
    pub const Externalize: Self = Self(8);
    #[doc(alias = "kSecTransformMetaAttributeHasOutboundConnections")]
    #[deprecated = "SecTransform is no longer supported"]
    pub const HasOutboundConnections: Self = Self(9);
    #[doc(alias = "kSecTransformMetaAttributeHasInboundConnection")]
    #[deprecated = "SecTransform is no longer supported"]
    pub const HasInboundConnection: Self = Self(10);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for SecTransformMetaAttributeType {
    const ENCODING: Encoding = CFIndex::ENCODING;
}

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

/// A direct reference to an attribute. Using an attribute
/// reference speeds up using an attribute's value by removing
/// the need to look
/// it up by name.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformattribute?language=objc)
#[doc(alias = "SecTransformAttributeRef")]
#[deprecated = "SecTransform is no longer supported"]
pub type SecTransformAttribute = CFType;

/// This type signifies that either a CFStringRef or
/// a SecTransformAttributeRef may be used.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformstringorattribute?language=objc)
#[doc(alias = "SecTransformStringOrAttributeRef")]
#[deprecated = "SecTransform is no longer supported"]
pub type SecTransformStringOrAttribute = CFType;

/// A block that overrides the default behavior of a
/// custom transform.
///
///
/// Returns: If this block is used to overide the
/// kSecTransformActionExternalizeExtraData action then the
/// block should return a CFDictinaryRef of the custom
/// items to be exported. For all of other actions the
/// block should return NULL. If an error occurs for
/// any action, the block should return a CFErrorRef.
///
///
/// A SecTransformTransformActionBlock block is used to
/// override
/// the default behavior of a custom transform. This block is
/// associated with the SecTransformOverrideTransformAction
/// block.
///
/// The behaviors that can be overridden are:
///
/// kSecTransformActionCanExecute
/// Determine if the transform has all of the data
/// needed to run.
///
/// kSecTransformActionStartingExecution
/// Called just before running ProcessData.
///
/// kSecTransformActionFinalize
/// Called just before deleting the custom transform.
///
/// kSecTransformActionExternalizeExtraData
/// Called to allow for writing out custom data
/// to be exported.
///
/// Example:
/// <pre>
///
/// ```text
///                     SecTransformImplementationRef ref;
///                     CFErrorRef error = NULL;
///
///                     error = SecTransformSetTransformAction(ref, kSecTransformActionStartingExecution,
///                     ^{
///                         // This is where the work to initialize any data needed
///                         // before running
///                         CFErrorRef result = DoMyInitialization();
///                         return result;
///                     });
///
///                     SecTransformTransformActionBlock actionBlock =
///                     ^{
///                         // This is where the work to clean up any existing data
///                         // before running
///                         CFErrorRef result = DoMyFinalization();
///                         return result;
///                     };
///
///                     error = SecTransformSetTransformAction(ref, kSecTransformActionFinalize,
///                         actionBlock);
/// ```
///
/// </pre>
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformactionblock?language=objc)
#[deprecated = "SecTransform is no longer supported"]
#[cfg(feature = "block2")]
pub type SecTransformActionBlock = *mut block2::DynBlock<dyn Fn() -> *const CFType>;

/// A block used to override the default attribute handling
/// for when an attribute is set.
///
///
/// Parameter `attribute`: The attribute whose default is being overridden or NULL
/// if this is a generic notification override
///
///
/// Parameter `value`: Proposed new value for the attribute.
///
///
/// Returns: The new value of the attribute if successful. If an
/// error occurred then a CFErrorRef is returned. If a transform
/// needs to have a CFErrorRef as the value of an attribute,
/// then the CFErrorRef needs to be placed into a container such
/// as a CFArrayRef, CFDictionaryRef etc.
///
///
/// See the example program in this header for more details.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformattributeactionblock?language=objc)
#[deprecated = "SecTransform is no longer supported"]
#[cfg(feature = "block2")]
pub type SecTransformAttributeActionBlock =
    *mut block2::DynBlock<dyn Fn(NonNull<SecTransformAttribute>, NonNull<CFType>) -> *const CFType>;

/// A block used to override the default data handling
/// for a transform.
///
///
/// Parameter `data`: The data to be processed. When this block is used
/// to to implement the kSecTransformActionProcessData action,
/// the data is the input data that is to be processed into the
/// output data.  When this block is used to implement the
/// kSecTransformActionInternalizeExtraData action, the data is
/// a CFDictionaryRef that contains the data that needs to be
/// imported.
///
///
/// Returns: When this block is used to implment the
/// kSecTransformActionProcessData action, the value returned
/// is to be the data that will be passed to the output
/// attribute.  If an error occured while processing the input
/// data then the block should return a CFErrorRef.
///
/// When this block is used to implement the
/// kSecTransformActionInternalizeExtraData action then this block
/// should return NULL or a CFErrorRef if an error occurred.
///
///
/// See the example program for more details.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformdatablock?language=objc)
#[cfg(feature = "block2")]
pub type SecTransformDataBlock = *mut block2::DynBlock<dyn Fn(NonNull<CFType>) -> *const CFType>;

/// This is the block that is returned from an
/// implementation of a CreateTransform function.
///
///
/// Returns: A CFErrorRef if an error occurred or NULL.
///
///
/// The instance block that is returned from the
/// developers CreateTransform function, defines
/// the behavior of a custom attribute.  Please
/// see the example at the head of this file.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransforminstanceblock?language=objc)
#[cfg(feature = "block2")]
pub type SecTransformInstanceBlock = *mut block2::DynBlock<dyn Fn() -> *mut CFError>;

/// [Apple's documentation](https://developer.apple.com/documentation/security/opaquesectransformimplementation?language=objc)
#[repr(C)]
#[derive(Debug)]
pub struct OpaqueSecTransformImplementation {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for OpaqueSecTransformImplementation {
    const ENCODING_REF: Encoding =
        Encoding::Pointer(&Encoding::Struct("OpaqueSecTransformImplementation", &[]));
}

/// The SecTransformImplementationRef is a pointer to a block
/// that implements an instance of a transform.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformimplementationref?language=objc)
pub type SecTransformImplementationRef = *const OpaqueSecTransformImplementation;

/// Be notified when a attribute is set. The supplied block is
/// called when the attribute is set. This can be done for a
/// specific named attribute or all attributes.
///
///
/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
/// of a custom transform.
///
///
/// Parameter `action`: The behavior to be set. This can be one of the following
/// actions:
///
/// kSecTransformActionAttributeNotification - add a block that
/// is called when an attribute is set. If the name is NULL,
/// then the supplied block is called for all set attributes
/// except for ones that have a specific block as a handler.
///
/// For example, if there is a handler for the attribute "foo"
/// and for all attributes, the "foo" handler is called when the
/// "foo" attribute is set, but all other attribute sets will
/// call the NULL handler.
///
/// The kSecTransformActionProcessData action is a special case
/// of a SecTransformSetAttributeAction action.  If this is
/// called on the input attribute then it will overwrite any
/// kSecTransformActionProcessData that was set.
///
/// kSecTransformActionAttributeValidation Add a block that is
/// called to validate the input to an attribute.
///
///
/// Parameter `attribute`: The name of the attribute that will be handled. An attribute
/// reference may also be given here. A NULL name indicates that
/// the supplied action is for all attributes.
///
///
/// Parameter `newAction`: A SecTransformAttributeActionBlock which implements the
/// behavior.
///
///
/// Returns: A CFErrorRef if an error occured NULL otherwise.
///
///
/// This function may be called multiple times for either a
/// named attribute or for all attributes when the attribute
/// parameter is NULL. Each time the API is called it overwrites
/// what was there previously.
///
/// # Safety
///
/// - `ref` must be a valid pointer.
/// - `attribute` should be of the correct type.
/// - `new_action` must be a valid pointer.
#[cfg(feature = "block2")]
#[deprecated = "SecTransform is no longer supported"]
#[inline]
pub unsafe extern "C-unwind" fn SecTransformSetAttributeAction(
    r#ref: SecTransformImplementationRef,
    action: &CFString,
    attribute: Option<&SecTransformStringOrAttribute>,
    new_action: SecTransformAttributeActionBlock,
) -> Option<CFRetained<CFError>> {
    extern "C-unwind" {
        fn SecTransformSetAttributeAction(
            r#ref: SecTransformImplementationRef,
            action: &CFString,
            attribute: Option<&SecTransformStringOrAttribute>,
            new_action: SecTransformAttributeActionBlock,
        ) -> Option<NonNull<CFError>>;
    }
    let ret = unsafe { SecTransformSetAttributeAction(r#ref, action, attribute, new_action) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

/// Change the way a custom transform will do data processing.
/// When the action parameter is kSecTransformActionProcessData
/// The newAction block will change the way that input data is
/// processed to become the output data. When the action
/// parameter is kSecTransformActionInternalizeExtraData it will
/// change the way a custom transform reads in data to be
/// imported into the transform.
///
///
/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
/// of a custom transform.
///
///
/// Parameter `action`: The action being overridden.  This value should be one of the
/// following:
/// kSecTransformActionProcessData
/// Change the way that input data is processed into the
/// output data. The default behavior is to simply copy
/// the input data to the output attribute.
///
/// The kSecTransformActionProcessData action is really
/// a special case of a SecTransformSetAttributeAction
/// action. If you call this method with
/// kSecTransformActionProcessData it would overwrite
/// any kSecTransformActionAttributeNotification action
/// that was set proviously
///
/// kSecTransformActionInternalizeExtraData
/// Change the way that custom externalized data is
/// imported into the transform.  The default behavior
/// is to do nothing.
///
///
/// Parameter `newAction`: A SecTransformDataBlock which implements the behavior.
///
/// If the action parameter is kSecTransformActionProcessData then
/// this block will be called to process the input data into the
/// output data.
///
/// if the action parameter is kSecTransformActionInternalizeExtraData then
/// this block will called to input custom data into the transform.
///
///
/// Returns: A CFErrorRef is an error occured NULL otherwise.
///
///
/// This API may be called multiple times.  Each time the API is called
/// it overwrites what was there previously.
///
/// # Safety
///
/// - `ref` must be a valid pointer.
/// - `new_action` must be a valid pointer.
#[cfg(feature = "block2")]
#[deprecated = "SecTransform is no longer supported"]
#[inline]
pub unsafe extern "C-unwind" fn SecTransformSetDataAction(
    r#ref: SecTransformImplementationRef,
    action: &CFString,
    new_action: SecTransformDataBlock,
) -> Option<CFRetained<CFError>> {
    extern "C-unwind" {
        fn SecTransformSetDataAction(
            r#ref: SecTransformImplementationRef,
            action: &CFString,
            new_action: SecTransformDataBlock,
        ) -> Option<NonNull<CFError>>;
    }
    let ret = unsafe { SecTransformSetDataAction(r#ref, action, new_action) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

/// # Safety
///
/// - `ref` must be a valid pointer.
/// - `new_action` must be a valid pointer.
#[cfg(feature = "block2")]
#[deprecated = "SecTransform is no longer supported"]
#[inline]
pub unsafe extern "C-unwind" fn SecTransformSetTransformAction(
    r#ref: SecTransformImplementationRef,
    action: &CFString,
    new_action: SecTransformActionBlock,
) -> Option<CFRetained<CFError>> {
    extern "C-unwind" {
        fn SecTransformSetTransformAction(
            r#ref: SecTransformImplementationRef,
            action: &CFString,
            new_action: SecTransformActionBlock,
        ) -> Option<NonNull<CFError>>;
    }
    let ret = unsafe { SecTransformSetTransformAction(r#ref, action, new_action) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

/// Allow a custom transform to get an attribute value
///
///
/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
/// of a custom transform.
///
///
/// Parameter `attribute`: The name or the attribute handle of the attribute whose
/// value is to be retrieved.
///
///
/// Parameter `type`: The type of data to be retrieved for the attribute.  See the
/// discussion on SecTransformMetaAttributeType for details.
///
///
/// Returns: The value of the attribute.
///
/// # Safety
///
/// - `ref` must be a valid pointer.
/// - `attribute` should be of the correct type.
#[deprecated]
#[inline]
pub unsafe extern "C-unwind" fn SecTranformCustomGetAttribute(
    r#ref: SecTransformImplementationRef,
    attribute: &SecTransformStringOrAttribute,
    r#type: SecTransformMetaAttributeType,
) -> Option<CFRetained<CFType>> {
    extern "C-unwind" {
        fn SecTranformCustomGetAttribute(
            r#ref: SecTransformImplementationRef,
            attribute: &SecTransformStringOrAttribute,
            r#type: SecTransformMetaAttributeType,
        ) -> Option<NonNull<CFType>>;
    }
    let ret = unsafe { SecTranformCustomGetAttribute(r#ref, attribute, r#type) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

/// Allow a custom transform to get an attribute value
///
///
/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
/// of a custom transform.
///
///
/// Parameter `attribute`: The name or the attribute handle of the attribute whose
/// value is to be retrieved.
///
///
/// Parameter `type`: The type of data to be retrieved for the attribute.  See the
/// discussion on SecTransformMetaAttributeType for details.
///
///
/// Returns: The value of the attribute.
///
/// # Safety
///
/// - `ref` must be a valid pointer.
/// - `attribute` should be of the correct type.
#[deprecated = "SecTransform is no longer supported"]
#[inline]
pub unsafe extern "C-unwind" fn SecTransformCustomGetAttribute(
    r#ref: SecTransformImplementationRef,
    attribute: &SecTransformStringOrAttribute,
    r#type: SecTransformMetaAttributeType,
) -> Option<CFRetained<CFType>> {
    extern "C-unwind" {
        #[link_name = "SecTranformCustomGetAttribute"]
        fn SecTransformCustomGetAttribute(
            r#ref: SecTransformImplementationRef,
            attribute: &SecTransformStringOrAttribute,
            r#type: SecTransformMetaAttributeType,
        ) -> Option<NonNull<CFType>>;
    }
    let ret = unsafe { SecTransformCustomGetAttribute(r#ref, attribute, r#type) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

/// Allow a custom transform to set an attribute value
///
///
/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
/// of a custom transform.
///
///
/// Parameter `attribute`: The name or the attribute handle of the attribute whose
/// value is to be set.
///
///
/// Parameter `type`: The type of data to be retrieved for the attribute.  See the
/// discussion on SecTransformMetaAttributeType for details.
///
///
/// Parameter `value`: The new value for the attribute
///
///
/// Returns: A CFErrorRef if an error occured , NULL otherwise.
///
///
/// Unlike the SecTransformSetAttribute API this API can set
/// attribute values while a transform is executing.  These
/// values are limited to the custom transform instance that
/// is bound to the ref parameter.
///
/// # Safety
///
/// - `ref` must be a valid pointer.
/// - `attribute` should be of the correct type.
/// - `value` should be of the correct type.
#[deprecated = "SecTransform is no longer supported"]
#[inline]
pub unsafe extern "C-unwind" fn SecTransformCustomSetAttribute(
    r#ref: SecTransformImplementationRef,
    attribute: &SecTransformStringOrAttribute,
    r#type: SecTransformMetaAttributeType,
    value: Option<&CFType>,
) -> Option<CFRetained<CFType>> {
    extern "C-unwind" {
        fn SecTransformCustomSetAttribute(
            r#ref: SecTransformImplementationRef,
            attribute: &SecTransformStringOrAttribute,
            r#type: SecTransformMetaAttributeType,
            value: Option<&CFType>,
        ) -> Option<NonNull<CFType>>;
    }
    let ret = unsafe { SecTransformCustomSetAttribute(r#ref, attribute, r#type, value) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

/// Allows for putting a single value back for a specific
/// attribute.  This will stop the flow of data into the
/// specified attribute until any attribute is changed for the
/// transform instance bound to the ref parameter.
///
///
/// Parameter `ref`: A SecTransformImplementationRef that is bound to an instance
/// of a custom transform.
///
///
/// Parameter `attribute`: The name or the attribute handle of the attribute whose
/// value is to be pushed back.
///
///
/// Parameter `value`: The value being pushed back.
///
///
/// Returns: A CFErrorRef if an error occured , NULL otherwise.
///
/// # Safety
///
/// - `ref` must be a valid pointer.
/// - `attribute` should be of the correct type.
/// - `value` should be of the correct type.
#[deprecated = "SecTransform is no longer supported"]
#[inline]
pub unsafe extern "C-unwind" fn SecTransformPushbackAttribute(
    r#ref: SecTransformImplementationRef,
    attribute: &SecTransformStringOrAttribute,
    value: &CFType,
) -> Option<CFRetained<CFType>> {
    extern "C-unwind" {
        fn SecTransformPushbackAttribute(
            r#ref: SecTransformImplementationRef,
            attribute: &SecTransformStringOrAttribute,
            value: &CFType,
        ) -> Option<NonNull<CFType>>;
    }
    let ret = unsafe { SecTransformPushbackAttribute(r#ref, attribute, value) };
    ret.map(|ret| unsafe { CFRetained::retain(ret) })
}

/// A function pointer to a function that will create a
/// new instance of a custom transform.
///
///
/// Parameter `name`: The name of the new custom transform. This name MUST be
/// unique.
///
///
/// Parameter `newTransform`: The newly created transform Ref.
///
///
/// Parameter `ref`: A reference that is bound to an instance of a custom
/// transform.
///
///
/// Returns: A SecTransformInstanceBlock that is used to create a new
/// instance of a custom transform.
///
///
/// The CreateTransform function creates a new transform. The
/// SecTransformInstanceBlock that is returned from this
/// function provides the implementation of all of the overrides
/// necessary to create the custom transform. This returned
/// SecTransformInstanceBlock is also where the "instance"
/// variables for the custom transform may be defined. See the
/// example in the header section of this file for more detail.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/security/sectransformcreatefp?language=objc)
#[deprecated = "SecTransform is no longer supported"]
#[cfg(all(feature = "SecTransform", feature = "block2"))]
pub type SecTransformCreateFP = Option<
    unsafe extern "C-unwind" fn(
        NonNull<CFString>,
        NonNull<SecTransform>,
        SecTransformImplementationRef,
    ) -> SecTransformInstanceBlock,
>;

extern "C" {
    /// Overrides the standard behavior that checks to see if all of the
    /// required attributes either have been set or are connected to
    /// another transform.  When overriding the default behavior the
    /// developer can decided what the necessary data is to have for a
    /// transform to be considered 'ready to run'.  Returning NULL means
    /// that the transform is ready to be run. If the transform is NOT
    /// ready to run then the override should return a CFErrorRef
    /// stipulating the error.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactioncanexecute?language=objc)
    #[deprecated = "SecTransform is no longer supported"]
    pub static kSecTransformActionCanExecute: &'static CFString;
}

extern "C" {
    /// Overrides the standard behavior that occurs just before starting
    /// execution of a custom transform. This is typically overridden
    /// to allow for initialization. This is used with the
    /// SecTransformOverrideTransformAction block.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionstartingexecution?language=objc)
    #[deprecated = "SecTransform is no longer supported"]
    pub static kSecTransformActionStartingExecution: &'static CFString;
}

extern "C" {
    /// Overrides the standard behavior that occurs just before deleting
    /// a custom transform. This is typically overridden to allow for
    /// memory clean up of a custom transform.  This is used with the
    /// SecTransformOverrideTransformAction block.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionfinalize?language=objc)
    #[deprecated = "SecTransform is no longer supported"]
    pub static kSecTransformActionFinalize: &'static CFString;
}

extern "C" {
    /// Allows for adding to the data that is stored using an override
    /// to the kSecTransformActionExternalizeExtraData block. The output
    /// of this override is a dictionary that contains the custom
    /// externalized data. A common use of this override is to write out
    /// a version number of a custom transform.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionexternalizeextradata?language=objc)
    #[deprecated = "SecTransform is no longer supported"]
    pub static kSecTransformActionExternalizeExtraData: &'static CFString;
}

extern "C" {
    /// Overrides the standard data processing for an attribute. This is
    /// almost exclusively used for processing the input attribute as
    /// the return value of their block sets the output attribute. This
    /// is used with the SecTransformOverrideAttributeAction block.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionprocessdata?language=objc)
    #[deprecated = "SecTransform is no longer supported"]
    pub static kSecTransformActionProcessData: &'static CFString;
}

extern "C" {
    /// Overrides the standard processing that occurs when externalized
    /// data is used to create a transform.  This is closely tied to the
    /// kSecTransformActionExternalizeExtraData override. The 'normal'
    /// attributes are read into the new transform and then this is
    /// called to read in the items that were written out using
    /// kSecTransformActionExternalizeExtraData override. A common use
    /// of this override would be to read in the version number of the
    /// externalized custom transform.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactioninternalizeextradata?language=objc)
    #[deprecated = "SecTransform is no longer supported"]
    pub static kSecTransformActionInternalizeExtraData: &'static CFString;
}

extern "C" {
    /// Allows a block to be called when an attribute is set.  This
    /// allows for caching the value as a block variable in the instance
    /// block or transmogrifying the data to be set. This action is
    /// where a custom transform would be able to do processing outside
    /// of processing input to output as process data does.  One the
    /// data has been processed the action block can call
    /// SecTransformCustomSetAttribute to update and other attribute.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionattributenotification?language=objc)
    #[deprecated = "SecTransform is no longer supported"]
    pub static kSecTransformActionAttributeNotification: &'static CFString;
}

extern "C" {
    /// Allows a block to be called to validate the new value for an
    /// attribute.  The default is no validation and any CFTypeRef can
    /// be used as the new value.  The block should return NULL if the
    /// value is ok to set on the attribute or a CFErrorRef otherwise.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/security/ksectransformactionattributevalidation?language=objc)
    #[deprecated = "SecTransform is no longer supported"]
    pub static kSecTransformActionAttributeValidation: &'static CFString;
}

/// Register a new custom transform so that it may be used to
/// process data
///
///
/// Parameter `uniqueName`: A unique name for this custom transform.  It is recommended
/// that a reverse DNS name be used for the name of your custom
/// transform
///
///
/// Parameter `createTransformFunction`: A SecTransformCreateFP function pointer. The function must
/// return a SecTransformInstanceBlock block that block_copy has
/// been called on before returning the block. Failure to call
/// block_copy will cause undefined behavior.
///
///
/// Parameter `error`: This pointer is set if an error occurred.  This value
/// may be NULL if you do not want an error returned.
///
///
/// Returns: True if the custom transform was registered false otherwise
///
/// # Safety
///
/// - `create_transform_function` must be implemented correctly.
/// - `error` must be a valid pointer or null.
#[cfg(all(feature = "SecTransform", feature = "block2"))]
#[deprecated = "SecTransform is no longer supported"]
#[inline]
pub unsafe extern "C-unwind" fn SecTransformRegister(
    unique_name: &CFString,
    create_transform_function: SecTransformCreateFP,
    error: *mut *mut CFError,
) -> bool {
    extern "C-unwind" {
        fn SecTransformRegister(
            unique_name: &CFString,
            create_transform_function: SecTransformCreateFP,
            error: *mut *mut CFError,
        ) -> Boolean;
    }
    let ret = unsafe { SecTransformRegister(unique_name, create_transform_function, error) };
    ret != 0
}

/// Creates a transform computation object.
///
///
/// Parameter `name`: The type of transform to create, must have been registered
/// by SecTransformRegister, or be a system pre-defined
/// transform type.
///
///
/// Parameter `error`: A pointer to a CFErrorRef.  This pointer is set if an error
/// occurred.  This value may be NULL if you do not want an
/// error returned.
///
///
/// Returns: A pointer to a SecTransformRef object.  This object must be
/// released with CFRelease when you are done with it.  This
/// function returns NULL if an error occurred.
///
/// # Safety
///
/// `error` must be a valid pointer or null.
#[cfg(feature = "SecTransform")]
#[deprecated = "SecTransform is no longer supported"]
#[inline]
pub unsafe extern "C-unwind" fn SecTransformCreate(
    name: &CFString,
    error: *mut *mut CFError,
) -> Option<CFRetained<SecTransform>> {
    extern "C-unwind" {
        fn SecTransformCreate(
            name: &CFString,
            error: *mut *mut CFError,
        ) -> Option<NonNull<SecTransform>>;
    }
    let ret = unsafe { SecTransformCreate(name, error) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

/// Returns back A CFTypeRef from inside a processData
/// override that says that while no data is being returned
/// the transform is still active and awaiting data.
///
///
/// Returns: A 'special' value that allows that specifies that the
/// transform is still active and awaiting data.
///
///
/// The standard behavior for the ProcessData override is that
/// it will receive a CFDataRef and it processes that data and
/// returns a CFDataRef that contains the processed data. When
/// there is no more data to process the ProcessData override
/// block is called one last time with a NULL CFDataRef.  The
/// ProcessData block should/must return the NULL CFDataRef to
/// complete the processing.  This model does not work well for
/// some transforms. For example a digest transform needs to see
/// ALL of the data that is being digested before it can send
/// out the digest value.
///
/// If a ProcessData block has no data to return, it can return
/// SecTransformNoData(), which informs the transform system
/// that there is no data to pass on to the next transform.
#[deprecated = "SecTransform is no longer supported"]
#[inline]
pub unsafe extern "C-unwind" fn SecTransformNoData() -> CFRetained<CFType> {
    extern "C-unwind" {
        fn SecTransformNoData() -> Option<NonNull<CFType>>;
    }
    let ret = unsafe { SecTransformNoData() };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::retain(ret) }
}