Ignore:
Timestamp:
May 12, 2013, 4:05:34 AM (6 years ago)
Author:
landonf@…
Message:

Remove ARC dependency for Mac OS 10.6.

Location:
trunk/dports/security/certsync
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dports/security/certsync/Portfile

    r105983 r105984  
    33PortSystem 1.0
    44name                    certsync
    5 version                 1.0
     5version                 1.0.1
    66categories              security
    77maintainers             landonf openmaintainer
     
    2626        system "${configure.objc} \
    2727                ${configure.objcflags} \
    28                 -fobjc-arc \
    2928                -mmacosx-version-min=10.6 \
    3029                -Wall \
  • trunk/dports/security/certsync/files/certsync.m

    r105983 r105984  
    2727
    2828#import <Foundation/Foundation.h>
     29#import <AvailabilityMacros.h>
     30
    2931#import <unistd.h>
    3032#import <stdio.h>
     
    5355   
    5456    NSString *str;
    55     str = (__bridge_transfer NSString *) CFStringCreateWithFormatAndArguments(NULL, NULL, (CFStringRef) format, args);
     57    str = (NSString *) CFStringCreateWithFormatAndArguments(NULL, NULL, (CFStringRef) format, args);
    5658    retval = fprintf(stream, "%s", [str UTF8String]);
    5759   
     
    114116    /* Extract trusted roots */
    115117    NSMutableArray *results = [NSMutableArray arrayWithCapacity: CFArrayGetCount(certs)];
    116     for (id certObj in (__bridge NSArray *) certs) {
    117         SecCertificateRef cert = (__bridge SecCertificateRef) certObj;
     118    for (id certObj in (NSArray *) certs) {
     119        SecCertificateRef cert = (SecCertificateRef) certObj;
    118120       
    119121        /* Fetch the trust settings */
     
    133135        } else {
    134136            /* Otherwise, walk the properties and evaluate the trust settings result */
    135             for (NSDictionary *trustProps in (__bridge NSArray *) trustSettings) {
     137            for (NSDictionary *trustProps in (NSArray *) trustSettings) {
    136138                CFNumberRef settingsResultNum;
    137139                SInt32 settingsResult;
    138140               
    139                 settingsResultNum = (__bridge CFNumberRef) [trustProps objectForKey: (__bridge id) kSecTrustSettingsResult];
     141                settingsResultNum = (CFNumberRef) [trustProps objectForKey: (id) kSecTrustSettingsResult];
    140142                CFNumberGetValue(settingsResultNum, kCFNumberSInt32Type, &settingsResult);
    141143               
     
    192194    for (id certObj in result) {
    193195        CFErrorRef cferror;
    194         CFStringRef subject = SecCertificateCopyShortDescription(NULL, (__bridge SecCertificateRef) certObj, &cferror);
     196        CFStringRef subject = SecCertificateCopyShortDescription(NULL, (SecCertificateRef) certObj, &cferror);
    195197        if (subject == NULL) {
    196198            nsfprintf(stderr, @"Failed to extract certificate description: %@\n", cferror);
     
    207209    OSStatus err;
    208210   
    209     /* Prefer the non-deprecated SecItemExport on Mac OS X >= 10.7 */
    210     if (NO && SecItemExport != NULL) {
    211         err = SecItemExport((__bridge CFArrayRef) anchors, kSecFormatPEMSequence, kSecItemPemArmour, NULL, &pemData);
    212     } else {
    213         err = SecKeychainItemExport((__bridge CFArrayRef) anchors, kSecFormatPEMSequence, kSecItemPemArmour, NULL, &pemData);
    214     }
     211    /* Prefer the non-deprecated SecItemExport on Mac OS X >= 10.7. We use an ifdef to keep the code buildable with earlier SDKs, too. */
     212#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6
     213    if (SecItemExport != NULL) {
     214        err = SecItemExport((CFArrayRef) anchors, kSecFormatPEMSequence, kSecItemPemArmour, NULL, &pemData);
     215    } else {
     216        err = SecKeychainItemExport((CFArrayRef) anchors, kSecFormatPEMSequence, kSecItemPemArmour, NULL, &pemData);
     217    }
     218#else
     219    err = SecItemExport((CFArrayRef) anchors, kSecFormatPEMSequence, kSecItemPemArmour, NULL, &pemData);
     220#endif
    215221   
    216222    if (err != errSecSuccess) {
     
    220226
    221227    if (outputFile == nil) {
    222         NSString *str = [[NSString alloc] initWithData: (__bridge NSData *) pemData encoding:NSUTF8StringEncoding];
     228        NSString *str = [[[NSString alloc] initWithData: (NSData *) pemData encoding:NSUTF8StringEncoding] autorelease];
    223229        nsfprintf(stdout, @"%@", str);
    224230    } else {
    225         if (![(__bridge NSData *) pemData writeToFile: outputFile options: NSDataWritingAtomic error: &error]) {
     231        if (![(NSData *) pemData writeToFile: outputFile options: NSDataWritingAtomic error: &error]) {
    226232            nsfprintf(stderr, @"Failed to write to pem output file: %@\n", error);
    227233            return EXIT_FAILURE;
     
    266272        argc -= optind;
    267273        argv += optind;
    268 
     274       
     275        /* Perform export  */
    269276        return exportCertificates(userAnchors, outputFile);
    270277    }
Note: See TracChangeset for help on using the changeset viewer.