Martijn The avatar Martijn The committed 99e93f7

Moved SKUtilsCreateStringHexadecimalRepresentationOfBytes to NSURLConnectionVCR.mm

Comments (0)

Files changed (3)

NSURLConnectionVCR/NSURLConnectionVCR.mm

 
 @implementation VCRCache (Private)
 
+static CFStringRef SKUtilsCreateStringHexadecimalRepresentationOfBytes(const UInt8* bytes, CFIndex length) {
+    UInt8 hexMap[] = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF";
+    
+    UInt8 *c = (UInt8 *)malloc(length * 2);
+    UInt16 *ptr = (UInt16*) c;
+    UInt16 *last = (UInt16*) (c + (length * 2));
+    for (;;) {
+        *ptr = ((UInt16*)hexMap)[*bytes];
+        ++ptr;
+        ++bytes;
+        if (ptr == last) {
+            return (__bridge_retained CFStringRef)[[NSString alloc] initWithBytesNoCopy:c length:length * 2 encoding:NSUTF8StringEncoding freeWhenDone:YES];
+            
+            // Not implemented in Cocotron:
+            //            return CFStringCreateWithBytesNoCopy(NULL, c, length * 2, kCFStringEncodingUTF8, false, kCFAllocatorMalloc);
+        }
+    }
+}
+
 + (NSString*)hashForRequest:(NSURLRequest*)request {
     NSData* data = [NSKeyedArchiver archivedDataWithRootObject:request];
     unsigned char md5[CC_MD5_DIGEST_LENGTH];

NSURLConnectionVCR/SKUtils.h

-//
-//  SKUtils.h
-//  Keychain+
-//
-//  Created by Martijn Thé on 08-01-12.
-//  Copyright (c) 2012 Martijn Thé. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-
-CFStringRef SKUtilsCreateStringHexadecimalRepresentationOfBytes(const UInt8* bytes, CFIndex length);

NSURLConnectionVCR/SKUtils.mm

-//
-//  SKUtils.m
-//  Keychain+
-//
-//  Created by Martijn Thé on 08-01-12.
-//  Copyright (c) 2012 Martijn Thé. All rights reserved.
-//
-
-#import "SKUtils.h"
-
-CFStringRef SKUtilsCreateStringHexadecimalRepresentationOfBytes(const UInt8* bytes, CFIndex length) {
-    UInt8 hexMap[] = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF";
-    
-    UInt8 *c = (UInt8 *)malloc(length * 2);
-    UInt16 *ptr = (UInt16*) c;
-    UInt16 *last = (UInt16*) (c + (length * 2));
-    for (;;) {
-        *ptr = ((UInt16*)hexMap)[*bytes];
-        ++ptr;
-        ++bytes;
-        if (ptr == last) {
-            return (__bridge_retained CFStringRef)[[NSString alloc] initWithBytesNoCopy:c length:length * 2 encoding:NSUTF8StringEncoding freeWhenDone:YES];
-            
-            // Not implemented in Cocotron:
-//            return CFStringCreateWithBytesNoCopy(NULL, c, length * 2, kCFStringEncodingUTF8, false, kCFAllocatorMalloc);
-        }
-    }
-}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.