Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial import

  • Loading branch information...
commit 0bcf66d4392da9dc45bcf65058407bbef314aa9a 1 parent e260cee
@st3fan st3fan authored
Showing with 45,382 additions and 0 deletions.
  1. +33 −0 ExternalSources/RegexKitLite-4.0/License.html
  2. +27 −0 ExternalSources/RegexKitLite-4.0/License.rtf
  3. +295 −0 ExternalSources/RegexKitLite-4.0/RegexKitLite.h
  4. +6,990 −0 ExternalSources/RegexKitLite-4.0/RegexKitLite.html
  5. +2,636 −0 ExternalSources/RegexKitLite-4.0/RegexKitLite.m
  6. +5 −0 ExternalSources/RegexKitLite-4.0/examples/NSString-HexConversion.h
  7. +24 −0 ExternalSources/RegexKitLite-4.0/examples/NSString-HexConversion.m
  8. +22 −0 ExternalSources/RegexKitLite-4.0/examples/compiledRegexCache.d
  9. +20 −0 ExternalSources/RegexKitLite-4.0/examples/for_in.m
  10. +22 −0 ExternalSources/RegexKitLite-4.0/examples/link_example.m
  11. +26 −0 ExternalSources/RegexKitLite-4.0/examples/main.m
  12. +33 −0 ExternalSources/RegexKitLite-4.0/examples/utf16ConversionCache.d
  13. +35 −0 ExternalSources/asi-http-request/Classes/ASIAuthenticationDialog.h
  14. +465 −0 ExternalSources/asi-http-request/Classes/ASIAuthenticationDialog.m
  15. +55 −0 ExternalSources/asi-http-request/Classes/ASICacheDelegate.h
  16. +47 −0 ExternalSources/asi-http-request/Classes/ASIDownloadCache.h
  17. +374 −0 ExternalSources/asi-http-request/Classes/ASIDownloadCache.m
  18. +76 −0 ExternalSources/asi-http-request/Classes/ASIFormDataRequest.h
  19. +358 −0 ExternalSources/asi-http-request/Classes/ASIFormDataRequest.m
  20. +830 −0 ExternalSources/asi-http-request/Classes/ASIHTTPRequest.h
  21. +4,020 −0 ExternalSources/asi-http-request/Classes/ASIHTTPRequest.m
  22. +32 −0 ExternalSources/asi-http-request/Classes/ASIHTTPRequestConfig.h
  23. +33 −0 ExternalSources/asi-http-request/Classes/ASIHTTPRequestDelegate.h
  24. +26 −0 ExternalSources/asi-http-request/Classes/ASIInputStream.h
  25. +136 −0 ExternalSources/asi-http-request/Classes/ASIInputStream.m
  26. +102 −0 ExternalSources/asi-http-request/Classes/ASINetworkQueue.h
  27. +322 −0 ExternalSources/asi-http-request/Classes/ASINetworkQueue.m
  28. +38 −0 ExternalSources/asi-http-request/Classes/ASIProgressDelegate.h
  29. +58 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesCDNRequest.h
  30. +147 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesCDNRequest.m
  31. +41 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesContainer.h
  32. +28 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesContainer.m
  33. +43 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesContainerRequest.h
  34. +134 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesContainerRequest.m
  35. +31 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesContainerXMLParserDelegate.h
  36. +72 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesContainerXMLParserDelegate.m
  37. +30 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesObject.h
  38. +29 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesObject.m
  39. +71 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesObjectRequest.h
  40. +261 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesObjectRequest.m
  41. +40 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesRequest.h
  42. +123 −0 ExternalSources/asi-http-request/Classes/CloudFiles/ASICloudFilesRequest.m
  43. +23 −0 ExternalSources/asi-http-request/Classes/S3/ASINSXMLParserCompat.h
  44. +34 −0 ExternalSources/asi-http-request/Classes/S3/ASIS3Bucket.h
  45. +32 −0 ExternalSources/asi-http-request/Classes/S3/ASIS3Bucket.m
  46. +54 −0 ExternalSources/asi-http-request/Classes/S3/ASIS3BucketObject.h
  47. +74 −0 ExternalSources/asi-http-request/Classes/S3/ASIS3BucketObject.m
  48. +75 −0 ExternalSources/asi-http-request/Classes/S3/ASIS3BucketRequest.h
  49. +178 −0 ExternalSources/asi-http-request/Classes/S3/ASIS3BucketRequest.m
  50. +70 −0 ExternalSources/asi-http-request/Classes/S3/ASIS3ObjectRequest.h
  51. +152 −0 ExternalSources/asi-http-request/Classes/S3/ASIS3ObjectRequest.m
  52. +93 −0 ExternalSources/asi-http-request/Classes/S3/ASIS3Request.h
  53. +284 −0 ExternalSources/asi-http-request/Classes/S3/ASIS3Request.m
  54. +31 −0 ExternalSources/asi-http-request/Classes/S3/ASIS3ServiceRequest.h
  55. +76 −0 ExternalSources/asi-http-request/Classes/S3/ASIS3ServiceRequest.m
  56. +18 −0 ExternalSources/asi-http-request/Classes/Tests/ASICloudFilesRequestTests.h
  57. +338 −0 ExternalSources/asi-http-request/Classes/Tests/ASICloudFilesRequestTests.m
  58. +16 −0 ExternalSources/asi-http-request/Classes/Tests/ASIDownloadCacheTests.h
  59. +243 −0 ExternalSources/asi-http-request/Classes/Tests/ASIDownloadCacheTests.m
  60. +22 −0 ExternalSources/asi-http-request/Classes/Tests/ASIFormDataRequestTests.h
  61. +270 −0 ExternalSources/asi-http-request/Classes/Tests/ASIFormDataRequestTests.m
  62. +70 −0 ExternalSources/asi-http-request/Classes/Tests/ASIHTTPRequestTests.h
  63. +1,635 −0 ExternalSources/asi-http-request/Classes/Tests/ASIHTTPRequestTests.m
  64. +83 −0 ExternalSources/asi-http-request/Classes/Tests/ASINetworkQueueTests.h
  65. +1,207 −0 ExternalSources/asi-http-request/Classes/Tests/ASINetworkQueueTests.m
  66. +26 −0 ExternalSources/asi-http-request/Classes/Tests/ASIS3RequestTests.h
  67. +763 −0 ExternalSources/asi-http-request/Classes/Tests/ASIS3RequestTests.m
  68. +20 −0 ExternalSources/asi-http-request/Classes/Tests/ASITestCase.h
  69. +23 −0 ExternalSources/asi-http-request/Classes/Tests/ASITestCase.m
  70. +89 −0 ExternalSources/asi-http-request/Classes/Tests/GHUnitTestMain.m
  71. +28 −0 ExternalSources/asi-http-request/Classes/Tests/PerformanceTests.h
  72. +225 −0 ExternalSources/asi-http-request/Classes/Tests/PerformanceTests.m
  73. +29 −0 ExternalSources/asi-http-request/Classes/Tests/ProxyTests.h
  74. +196 −0 ExternalSources/asi-http-request/Classes/Tests/ProxyTests.m
  75. +46 −0 ExternalSources/asi-http-request/Classes/Tests/StressTests.h
  76. +185 −0 ExternalSources/asi-http-request/Classes/Tests/StressTests.m
  77. +193 −0 ExternalSources/asi-http-request/External/Reachability/Reachability.h
  78. +814 −0 ExternalSources/asi-http-request/External/Reachability/Reachability.m
  79. +28 −0 ExternalSources/asi-http-request/LICENSE
  80. +71 −0 ExternalSources/asi-http-request/Mac Sample/AppDelegate.h
  81. +387 −0 ExternalSources/asi-http-request/Mac Sample/AppDelegate.m
  82. BIN  ExternalSources/asi-http-request/Mac Sample/English.lproj/InfoPlist.strings
  83. +5,339 −0 ExternalSources/asi-http-request/Mac Sample/English.lproj/MainMenu.xib
  84. +30 −0 ExternalSources/asi-http-request/Mac Sample/Info.plist
  85. +7 −0 ExternalSources/asi-http-request/Mac Sample/Mac_Prefix.pch
  86. +30 −0 ExternalSources/asi-http-request/Mac Sample/Tests-Info.plist
  87. +14 −0 ExternalSources/asi-http-request/Mac Sample/main.m
  88. BIN  ExternalSources/asi-http-request/Mac.xcodeproj/TemplateIcon.icns
  89. +748 −0 ExternalSources/asi-http-request/Mac.xcodeproj/project.pbxproj
  90. +24 −0 ExternalSources/asi-http-request/README.textile
  91. +3 −0  ExternalSources/asi-http-request/clang.sh
  92. +24 −0 ExternalSources/asi-http-request/iPhone Sample/AuthenticationViewController.h
  93. +230 −0 ExternalSources/asi-http-request/iPhone Sample/AuthenticationViewController.m
  94. +17 −0 ExternalSources/asi-http-request/iPhone Sample/DetailCell.h
  95. +35 −0 ExternalSources/asi-http-request/iPhone Sample/DetailCell.m
  96. +17 −0 ExternalSources/asi-http-request/iPhone Sample/InfoCell.h
  97. +64 −0 ExternalSources/asi-http-request/iPhone Sample/InfoCell.m
  98. +34 −0 ExternalSources/asi-http-request/iPhone Sample/QueueViewController.h
  99. +276 −0 ExternalSources/asi-http-request/iPhone Sample/QueueViewController.m
  100. +349 −0 ExternalSources/asi-http-request/iPhone Sample/Resources/Sample.xib
  101. +461 −0 ExternalSources/asi-http-request/iPhone Sample/Resources/iPadMainWindow.xib
  102. +641 −0 ExternalSources/asi-http-request/iPhone Sample/Resources/iPhoneMainWindow.xib
  103. BIN  ExternalSources/asi-http-request/iPhone Sample/Resources/info.png
  104. +19 −0 ExternalSources/asi-http-request/iPhone Sample/RootViewController.h
  105. +115 −0 ExternalSources/asi-http-request/iPhone Sample/RootViewController.m
  106. +22 −0 ExternalSources/asi-http-request/iPhone Sample/SampleViewController.h
  107. +55 −0 ExternalSources/asi-http-request/iPhone Sample/SampleViewController.m
  108. +24 −0 ExternalSources/asi-http-request/iPhone Sample/SynchronousViewController.h
  109. +198 −0 ExternalSources/asi-http-request/iPhone Sample/SynchronousViewController.m
  110. +24 −0 ExternalSources/asi-http-request/iPhone Sample/Tests-Info.plist
  111. +18 −0 ExternalSources/asi-http-request/iPhone Sample/ToggleCell.h
  112. +24 −0 ExternalSources/asi-http-request/iPhone Sample/ToggleCell.m
  113. +25 −0 ExternalSources/asi-http-request/iPhone Sample/UploadViewController.h
  114. +176 −0 ExternalSources/asi-http-request/iPhone Sample/UploadViewController.m
  115. +26 −0 ExternalSources/asi-http-request/iPhone Sample/iPadInfo.plist
  116. +19 −0 ExternalSources/asi-http-request/iPhone Sample/iPadSampleAppDelegate.h
  117. +28 −0 ExternalSources/asi-http-request/iPhone Sample/iPadSampleAppDelegate.m
  118. +26 −0 ExternalSources/asi-http-request/iPhone Sample/iPhoneInfo.plist
  119. +21 −0 ExternalSources/asi-http-request/iPhone Sample/iPhoneSampleAppDelegate.h
  120. +50 −0 ExternalSources/asi-http-request/iPhone Sample/iPhoneSampleAppDelegate.m
  121. +8 −0 ExternalSources/asi-http-request/iPhone Sample/iPhone_Prefix.pch
  122. BIN  ExternalSources/asi-http-request/iPhone Sample/iphone-icon.png
  123. BIN  ExternalSources/asi-http-request/iPhone Sample/iphone-tests-icon.png
  124. +17 −0 ExternalSources/asi-http-request/iPhone Sample/main.m
  125. +975 −0 ExternalSources/asi-http-request/iPhone.xcodeproj/project.pbxproj
  126. +13 −0 ExternalSources/asi-http-request/set_version_number.rb
  127. +26 −0 ExternalSources/asi-http-request/strict.xcconfig
  128. +14 −0 ExternalSources/checkout.sh
  129. +1 −0  ExternalSources/ios-jpake/README
  130. +124 −0 ExternalSources/ios-jpake/Sources/JPAKEClient.h
  131. +1,119 −0 ExternalSources/ios-jpake/Sources/JPAKEClient.m
  132. +52 −0 ExternalSources/ios-jpake/Sources/JPAKEKeys.h
  133. +67 −0 ExternalSources/ios-jpake/Sources/JPAKEKeys.m
  134. +58 −0 ExternalSources/ios-jpake/Sources/JPAKEParty.h
  135. +327 −0 ExternalSources/ios-jpake/Sources/JPAKEParty.m
  136. +51 −0 ExternalSources/ios-jpake/Sources/JPAKEReporter.h
  137. +95 −0 ExternalSources/ios-jpake/Sources/JPAKEReporter.m
  138. +77 −0 ExternalSources/ios-jpake/Sources/JPAKEViewController.h
  139. +98 −0 ExternalSources/ios-jpake/Sources/JPAKEViewController.m
  140. +468 −0 ExternalSources/ios-jpake/Sources/JPAKEViewController.xib
  141. +441 −0 ExternalSources/ios-jpake/Sources/jpake.c
  142. +100 −0 ExternalSources/ios-jpake/Sources/jpake.h
  143. +105 −0 ExternalSources/ios-jpake/Sources/jpake_err.c
  144. +192 −0 ExternalSources/ios-jpake/Sources/jpaketest.c
  145. +47 −0 ExternalSources/ios-jpake/Tests/JPAKEKeysTest.h
  146. +71 −0 ExternalSources/ios-jpake/Tests/JPAKEKeysTest.m
  147. +22 −0 ExternalSources/ios-jpake/Tests/JPAKEPartyTest.h
  148. +148 −0 ExternalSources/ios-jpake/Tests/JPAKEPartyTest.m
  149. +79 −0 ExternalSources/ios-openssl/#build.sh#
  150. +22 −0 ExternalSources/ios-openssl/Example/Classes/ExampleAppDelegate.h
  151. +88 −0 ExternalSources/ios-openssl/Example/Classes/ExampleAppDelegate.m
  152. +16 −0 ExternalSources/ios-openssl/Example/Classes/ExampleViewController.h
  153. +43 −0 ExternalSources/ios-openssl/Example/Classes/ExampleViewController.m
  154. +30 −0 ExternalSources/ios-openssl/Example/Example-Info.plist
  155. +293 −0 ExternalSources/ios-openssl/Example/Example.xcodeproj/project.pbxproj
  156. +1,401 −0 ExternalSources/ios-openssl/Example/Example.xcodeproj/stefan.mode1v3
  157. +379 −0 ExternalSources/ios-openssl/Example/ExampleViewController.xib
  158. +8 −0 ExternalSources/ios-openssl/Example/Example_Prefix.pch
  159. +444 −0 ExternalSources/ios-openssl/Example/MainWindow.xib
  160. +17 −0 ExternalSources/ios-openssl/Example/main.m
  161. +41 −0 ExternalSources/ios-openssl/README
  162. +79 −0 ExternalSources/ios-openssl/build.sh
  163. +142 −0 ExternalSources/ios-openssl/include/openssl/aes.h
  164. +1,402 −0 ExternalSources/ios-openssl/include/openssl/asn1.h
  165. +578 −0 ExternalSources/ios-openssl/include/openssl/asn1_mac.h
Sorry, we could not display the entire diff because too many files (909) changed.
View
33 ExternalSources/RegexKitLite-4.0/License.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+ <meta http-equiv="Content-Language" content="EN-US">
+ <style type="text/css">
+.RegexKitLiteLicense { margin: 2em 4ex; max-width: 5.75in; text-align: justify; font-family: "lucida grande", helvetica, arial, sans-serif; }
+.RegexKitLiteLicense p, .RegexKitLiteLicense ul { margin: 1em 0px; }
+.RegexKitLiteLicense ul li { margin-bottom: 0.75em; }
+.RegexKitLiteLicense .disclaimer { font-family: courier, times, monospace; }
+ </style>
+ <title>RegexKitLite License</title>
+ </head>
+ <body>
+ <div class="RegexKitLiteLicense">
+ <h3>RegexKit<i>List</i> License</h3>
+
+ <p>Copyright &copy; 2008-2010, John Engelhart</p>
+
+ <p>All rights reserved.</p>
+
+ <p>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</p>
+
+ <ul>
+ <li>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</li>
+ <li>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</li>
+ <li>Neither the name of the Zang Industries nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.</li>
+ </ul>
+
+ <p class="disclaimer">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
+ </div>
+ </body>
+</html>
View
27 ExternalSources/RegexKitLite-4.0/License.rtf
@@ -0,0 +1,27 @@
+{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf290
+{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 LucidaGrande;\f2\fmodern\fcharset0 Courier;
+}
+{\colortbl;\red255\green255\blue255;}
+{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}}
+{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}}
+\margl1440\margr1440\vieww10960\viewh15160\viewkind0
+\deftab720
+\pard\pardeftab720\sa180\ql\qnatural
+
+\f0\b\fs38 \cf0 RegexKit
+\i Lite
+\i0 License
+\f1 \
+\pard\pardeftab720\sa240\ql\qnatural
+
+\b0\fs24 \cf0 Copyright \'a9 2008-2010, John Engelhart\
+All rights reserved.\
+\pard\pardeftab720\sa240\qj
+\cf0 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\
+\pard\tx220\tx720\pardeftab720\li720\fi-720\sa180\qj
+\ls1\ilvl0\cf0 {\listtext \'95 }Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\
+{\listtext \'95 }Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\
+{\listtext \'95 }Neither the name of the Zang Industries nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\
+\pard\pardeftab720\sa240\qj
+
+\f2 \cf0 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.}
View
295 ExternalSources/RegexKitLite-4.0/RegexKitLite.h
@@ -0,0 +1,295 @@
+//
+// RegexKitLite.h
+// http://regexkit.sourceforge.net/
+// Licensed under the terms of the BSD License, as specified below.
+//
+
+/*
+ Copyright (c) 2008-2010, John Engelhart
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of the Zang Industries nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifdef __OBJC__
+#import <Foundation/NSArray.h>
+#import <Foundation/NSError.h>
+#import <Foundation/NSObjCRuntime.h>
+#import <Foundation/NSRange.h>
+#import <Foundation/NSString.h>
+#endif // __OBJC__
+
+#include <limits.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <TargetConditionals.h>
+#include <AvailabilityMacros.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef REGEXKITLITE_VERSION_DEFINED
+#define REGEXKITLITE_VERSION_DEFINED
+
+#define _RKL__STRINGIFY(b) #b
+#define _RKL_STRINGIFY(a) _RKL__STRINGIFY(a)
+#define _RKL_JOIN_VERSION(a,b) _RKL_STRINGIFY(a##.##b)
+#define _RKL_VERSION_STRING(a,b) _RKL_JOIN_VERSION(a,b)
+
+#define REGEXKITLITE_VERSION_MAJOR 4
+#define REGEXKITLITE_VERSION_MINOR 0
+
+#define REGEXKITLITE_VERSION_CSTRING _RKL_VERSION_STRING(REGEXKITLITE_VERSION_MAJOR, REGEXKITLITE_VERSION_MINOR)
+#define REGEXKITLITE_VERSION_NSSTRING @REGEXKITLITE_VERSION_CSTRING
+
+#endif // REGEXKITLITE_VERSION_DEFINED
+
+#if !defined(RKL_BLOCKS) && defined(NS_BLOCKS_AVAILABLE) && (NS_BLOCKS_AVAILABLE == 1)
+#define RKL_BLOCKS 1
+#endif
+
+#if defined(RKL_BLOCKS) && (RKL_BLOCKS == 1)
+#define _RKL_BLOCKS_ENABLED 1
+#endif // defined(RKL_BLOCKS) && (RKL_BLOCKS == 1)
+
+#if defined(_RKL_BLOCKS_ENABLED) && !defined(__BLOCKS__)
+#warning RegexKitLite support for Blocks is enabled, but __BLOCKS__ is not defined. This compiler may not support Blocks, in which case the behavior is undefined. This will probably cause numerous compiler errors.
+#endif // defined(_RKL_BLOCKS_ENABLED) && !defined(__BLOCKS__)
+
+// For Mac OS X < 10.5.
+#ifndef NSINTEGER_DEFINED
+#define NSINTEGER_DEFINED
+#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+#define NSIntegerMin LONG_MIN
+#define NSIntegerMax LONG_MAX
+#define NSUIntegerMax ULONG_MAX
+#else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+#define NSIntegerMin INT_MIN
+#define NSIntegerMax INT_MAX
+#define NSUIntegerMax UINT_MAX
+#endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
+#endif // NSINTEGER_DEFINED
+
+#ifndef RKLREGEXOPTIONS_DEFINED
+#define RKLREGEXOPTIONS_DEFINED
+
+// These must be identical to their ICU regex counterparts. See http://www.icu-project.org/userguide/regexp.html
+enum {
+ RKLNoOptions = 0,
+ RKLCaseless = 2,
+ RKLComments = 4,
+ RKLDotAll = 32,
+ RKLMultiline = 8,
+ RKLUnicodeWordBoundaries = 256
+};
+typedef uint32_t RKLRegexOptions; // This must be identical to the ICU 'flags' argument type.
+
+#endif // RKLREGEXOPTIONS_DEFINED
+
+#ifndef RKLREGEXENUMERATIONOPTIONS_DEFINED
+#define RKLREGEXENUMERATIONOPTIONS_DEFINED
+
+enum {
+ RKLRegexEnumerationNoOptions = 0UL,
+ RKLRegexEnumerationCapturedStringsNotRequired = 1UL << 9,
+ RKLRegexEnumerationReleaseStringReturnedByReplacementBlock = 1UL << 10,
+ RKLRegexEnumerationFastCapturedStringsXXX = 1UL << 11,
+};
+typedef NSUInteger RKLRegexEnumerationOptions;
+
+#endif // RKLREGEXENUMERATIONOPTIONS_DEFINED
+
+#ifndef _REGEXKITLITE_H_
+#define _REGEXKITLITE_H_
+
+#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465)
+#define RKL_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
+#else
+#define RKL_DEPRECATED_ATTRIBUTE
+#endif
+
+#if defined(NS_REQUIRES_NIL_TERMINATION)
+#define RKL_REQUIRES_NIL_TERMINATION NS_REQUIRES_NIL_TERMINATION
+#else // defined(NS_REQUIRES_NIL_TERMINATION)
+#define RKL_REQUIRES_NIL_TERMINATION
+#endif // defined(NS_REQUIRES_NIL_TERMINATION)
+
+// This requires a few levels of rewriting to get the desired results.
+#define _RKL_CONCAT_2(c,d) c ## d
+#define _RKL_CONCAT(a,b) _RKL_CONCAT_2(a,b)
+
+#ifdef RKL_PREPEND_TO_METHODS
+#define RKL_METHOD_PREPEND(x) _RKL_CONCAT(RKL_PREPEND_TO_METHODS, x)
+#else // RKL_PREPEND_TO_METHODS
+#define RKL_METHOD_PREPEND(x) x
+#endif // RKL_PREPEND_TO_METHODS
+
+// If it looks like low memory notifications might be available, add code to register and respond to them.
+// This is (should be) harmless if it turns out that this isn't the case, since the notification that we register for,
+// UIApplicationDidReceiveMemoryWarningNotification, is dynamically looked up via dlsym().
+#if ((defined(TARGET_OS_EMBEDDED) && (TARGET_OS_EMBEDDED != 0)) || (defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE != 0))) && (!defined(RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS) || (RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS != 0))
+#define RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS 1
+#endif
+
+#ifdef __OBJC__
+
+// NSException exception name.
+extern NSString * const RKLICURegexException;
+
+// NSError error domains and user info keys.
+extern NSString * const RKLICURegexErrorDomain;
+
+extern NSString * const RKLICURegexEnumerationOptionsErrorKey;
+extern NSString * const RKLICURegexErrorCodeErrorKey;
+extern NSString * const RKLICURegexErrorNameErrorKey;
+extern NSString * const RKLICURegexLineErrorKey;
+extern NSString * const RKLICURegexOffsetErrorKey;
+extern NSString * const RKLICURegexPreContextErrorKey;
+extern NSString * const RKLICURegexPostContextErrorKey;
+extern NSString * const RKLICURegexRegexErrorKey;
+extern NSString * const RKLICURegexRegexOptionsErrorKey;
+extern NSString * const RKLICURegexReplacedCountErrorKey;
+extern NSString * const RKLICURegexReplacedStringErrorKey;
+extern NSString * const RKLICURegexReplacementStringErrorKey;
+extern NSString * const RKLICURegexSubjectRangeErrorKey;
+extern NSString * const RKLICURegexSubjectStringErrorKey;
+
+@interface NSString (RegexKitLiteAdditions)
+
++ (void)RKL_METHOD_PREPEND(clearStringCache);
+
+// Although these are marked as deprecated, a bug in GCC prevents a warning from being issues for + class methods. Filed bug with Apple, #6736857.
++ (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex RKL_DEPRECATED_ATTRIBUTE;
++ (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex options:(RKLRegexOptions)options error:(NSError **)error RKL_DEPRECATED_ATTRIBUTE;
+
+- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex;
+- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex range:(NSRange)range;
+- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error;
+
+- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex;
+- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex inRange:(NSRange)range;
+- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error;
+
+- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex;
+- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex capture:(NSInteger)capture;
+- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex inRange:(NSRange)range;
+- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error;
+
+- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex;
+- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex capture:(NSInteger)capture;
+- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex inRange:(NSRange)range;
+- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error;
+
+- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement;
+- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange;
+- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error;
+
+ //// >= 3.0
+
+- (NSInteger)RKL_METHOD_PREPEND(captureCount);
+- (NSInteger)RKL_METHOD_PREPEND(captureCountWithOptions):(RKLRegexOptions)options error:(NSError **)error;
+
+- (BOOL)RKL_METHOD_PREPEND(isRegexValid);
+- (BOOL)RKL_METHOD_PREPEND(isRegexValidWithOptions):(RKLRegexOptions)options error:(NSError **)error;
+
+- (void)RKL_METHOD_PREPEND(flushCachedRegexData);
+
+- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex;
+- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex capture:(NSInteger)capture;
+- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex range:(NSRange)range;
+- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range capture:(NSInteger)capture error:(NSError **)error;
+
+
+- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex;
+- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range;
+- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error;
+
+- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex;
+- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range;
+- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error;
+
+ //// >= 4.0
+
+- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
+- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex range:(NSRange)range withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
+- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
+- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withFirstKey:(id)firstKey arguments:(va_list)varArgsList;
+
+- (NSArray *)RKL_METHOD_PREPEND(arrayOfDictionariesByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeys:(id *)keys forCaptures:(int *)captures count:(NSUInteger)count;
+
+- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
+- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex range:(NSRange)range withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
+- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeysAndCaptures:(id)firstKey, ... RKL_REQUIRES_NIL_TERMINATION;
+- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withFirstKey:(id)firstKey arguments:(va_list)varArgsList;
+
+- (NSDictionary *)RKL_METHOD_PREPEND(dictionaryByMatchingRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error withKeys:(id *)keys forCaptures:(int *)captures count:(NSUInteger)count;
+
+#ifdef _RKL_BLOCKS_ENABLED
+
+- (BOOL)RKL_METHOD_PREPEND(enumerateStringsMatchedByRegex):(NSString *)regex usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
+- (BOOL)RKL_METHOD_PREPEND(enumerateStringsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
+
+- (BOOL)RKL_METHOD_PREPEND(enumerateStringsSeparatedByRegex):(NSString *)regex usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
+- (BOOL)RKL_METHOD_PREPEND(enumerateStringsSeparatedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(void (^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
+
+- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
+- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
+
+#endif // _RKL_BLOCKS_ENABLED
+
+@end
+
+@interface NSMutableString (RegexKitLiteAdditions)
+
+- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement;
+- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange;
+- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error;
+
+ //// >= 4.0
+
+#ifdef _RKL_BLOCKS_ENABLED
+
+- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
+- (NSInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error enumerationOptions:(RKLRegexEnumerationOptions)enumerationOptions usingBlock:(NSString *(^)(NSInteger captureCount, NSString * const capturedStrings[captureCount], const NSRange capturedRanges[captureCount], volatile BOOL * const stop))block;
+
+#endif // _RKL_BLOCKS_ENABLED
+
+@end
+
+#endif // __OBJC__
+
+#endif // _REGEXKITLITE_H_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
View
6,990 ExternalSources/RegexKitLite-4.0/RegexKitLite.html
6,990 additions, 0 deletions not shown
View
2,636 ExternalSources/RegexKitLite-4.0/RegexKitLite.m
2,636 additions, 0 deletions not shown
View
5 ExternalSources/RegexKitLite-4.0/examples/NSString-HexConversion.h
@@ -0,0 +1,5 @@
+#import <Foundation/NSString.h>
+
+@interface NSString (HexConversion)
+-(NSInteger)hexValue;
+@end
View
24 ExternalSources/RegexKitLite-4.0/examples/NSString-HexConversion.m
@@ -0,0 +1,24 @@
+#import "NSString-HexConversion.h"
+#import <CoreFoundation/CFString.h>
+#include <stdlib.h>
+
+@implementation NSString (HexConversion)
+
+-(NSInteger)hexValue
+{
+ CFStringRef cfSelf = (CFStringRef)self;
+ UInt8 buffer[64];
+ const char *cptr;
+
+ if((cptr = CFStringGetCStringPtr(cfSelf, kCFStringEncodingMacRoman)) == NULL) {
+ CFRange range = CFRangeMake(0L, CFStringGetLength(cfSelf));
+ CFIndex usedBytes = 0L;
+ CFStringGetBytes(cfSelf, range, kCFStringEncodingUTF8, '?', false, buffer, 60L, &usedBytes);
+ buffer[usedBytes] = 0;
+ cptr = (const char *)buffer;
+ }
+
+ return((NSInteger)strtol(cptr, NULL, 16));
+}
+
+@end
View
22 ExternalSources/RegexKitLite-4.0/examples/compiledRegexCache.d
@@ -0,0 +1,22 @@
+#!/usr/sbin/dtrace -s
+
+RegexKitLite*:::compiledRegexCache {
+ this->eventID = (unsigned long)arg0;
+ this->regexUTF8 = copyinstr(arg1);
+ this->options = (unsigned int)arg2;
+ this->captures = (int)arg3;
+ this->hitMiss = (int)arg4;
+ this->icuStatusCode = (int)arg5;
+ this->icuErrorMessage = (arg6 == 0) ? "" : copyinstr(arg6);
+ this->hitRate = (double *)copyin(arg7, sizeof(double));
+
+ printf("%5d: %-60.60s Opt: %#8.8x Cap: %2d Hit: %2d Rate: %6.2f%% code: %5d msg: %s\n",
+ this->eventID,
+ this->regexUTF8,
+ this->options,
+ this->captures,
+ this->hitMiss,
+ *this->hitRate,
+ this->icuStatusCode,
+ this->icuErrorMessage);
+}
View
20 ExternalSources/RegexKitLite-4.0/examples/for_in.m
@@ -0,0 +1,20 @@
+#import <Foundation/Foundation.h>
+#import "RegexKitLite.h"
+
+int main(int argc, char *argv[]) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSString *searchString = @"one\ntwo\n\nfour\n";
+ NSString *regexString = @"(?m)^.*$";
+ NSUInteger line = 0UL;
+
+ NSLog(@"searchString: '%@'", searchString);
+ NSLog(@"regexString : '%@'", regexString);
+
+ for(NSString *matchedString in [searchString componentsMatchedByRegex:regexString]) {
+ NSLog(@"%lu: %lu '%@'", (u_long)++line, (u_long)[matchedString length], matchedString);
+ }
+
+ [pool release];
+ return(0);
+}
View
22 ExternalSources/RegexKitLite-4.0/examples/link_example.m
@@ -0,0 +1,22 @@
+#import <Foundation/NSObjCRuntime.h>
+#import <Foundation/NSAutoreleasePool.h>
+#import "RegexKitLite.h"
+
+int main(int argc, char *argv[]) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ // Copyright COPYRIGHT_SIGN APPROXIMATELY_EQUAL_TO 2008
+ // Copyright \u00a9 \u2245 2008
+
+ char *utf8CString = "Copyright \xC2\xA9 \xE2\x89\x85 2008";
+ NSString *regexString = @"Copyright (.*) (\\d+)";
+
+ NSString *subjectString = [NSString stringWithUTF8String:utf8CString];
+ NSString *matchedString = [subjectString stringByMatching:regexString capture:1L];
+
+ NSLog(@"subject: \"%@\"", subjectString);
+ NSLog(@"matched: \"%@\"", matchedString);
+
+ [pool release];
+ return(0);
+}
View
26 ExternalSources/RegexKitLite-4.0/examples/main.m
@@ -0,0 +1,26 @@
+#import <Foundation/NSAutoreleasePool.h>
+#import "RegexKitLite.h"
+#import "RKLMatchEnumerator.h"
+
+int main(int argc, char *argv[]) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSString *searchString = @"one\ntwo\n\nfour\n";
+ NSEnumerator *matchEnumerator = NULL;
+ NSString *regexString = @"(?m)^.*$";
+
+ NSLog(@"searchString: '%@'", searchString);
+ NSLog(@"regexString : '%@'", regexString);
+
+ matchEnumerator = [searchString matchEnumeratorWithRegex:regexString];
+
+ NSUInteger line = 0UL;
+ NSString *matchedString = NULL;
+
+ while((matchedString = [matchEnumerator nextObject]) != NULL) {
+ NSLog(@"%lu: %lu '%@'", (u_long)++line, (u_long)[matchedString length], matchedString);
+ }
+
+ [pool release];
+ return(0);
+}
View
33 ExternalSources/RegexKitLite-4.0/examples/utf16ConversionCache.d
@@ -0,0 +1,33 @@
+#!/usr/sbin/dtrace -s
+
+enum {
+ RKLCacheHitLookupFlag = 1 << 0,
+ RKLConversionRequiredLookupFlag = 1 << 1,
+ RKLSetTextLookupFlag = 1 << 2,
+ RKLDynamicBufferLookupFlag = 1 << 3,
+ RKLErrorLookupFlag = 1 << 4
+};
+
+RegexKitLite*:::utf16ConversionCache {
+ this->eventID = (unsigned long)arg0;
+ this->lookupResultFlags = (unsigned int)arg1;
+ this->hitRate = (double *)copyin(arg2, sizeof(double));
+ this->stringPtr = (void *)arg3;
+ this->NSRange_location = (unsigned long)arg4;
+ this->NSRange_length = (unsigned long)arg5;
+ this->length = (long)arg6;
+
+ printf("%5lu: flags: %#8.8x {Hit: %d Conv: %d SetText: %d Dyn: %d Error: %d} rate: %6.2f%% string: %#8.8p NSRange {%6lu, %6lu} length: %ld\n",
+ this->eventID,
+ this->lookupResultFlags,
+ (this->lookupResultFlags & RKLCacheHitLookupFlag) != 0,
+ (this->lookupResultFlags & RKLConversionRequiredLookupFlag) != 0,
+ (this->lookupResultFlags & RKLSetTextLookupFlag) != 0,
+ (this->lookupResultFlags & RKLDynamicBufferLookupFlag) != 0,
+ (this->lookupResultFlags & RKLErrorLookupFlag) != 0,
+ *this->hitRate,
+ this->stringPtr,
+ this->NSRange_location,
+ this->NSRange_length,
+ this->length);
+}
View
35 ExternalSources/asi-http-request/Classes/ASIAuthenticationDialog.h
@@ -0,0 +1,35 @@
+//
+// ASIAuthenticationDialog.h
+// Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+// Created by Ben Copsey on 21/08/2009.
+// Copyright 2009 All-Seeing Interactive. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+@class ASIHTTPRequest;
+
+typedef enum _ASIAuthenticationType {
+ ASIStandardAuthenticationType = 0,
+ ASIProxyAuthenticationType = 1
+} ASIAuthenticationType;
+
+@interface ASIAutorotatingViewController : UIViewController
+@end
+
+@interface ASIAuthenticationDialog : ASIAutorotatingViewController <UIActionSheetDelegate, UITableViewDelegate, UITableViewDataSource> {
+ ASIHTTPRequest *request;
+ ASIAuthenticationType type;
+ UITableView *tableView;
+ UIViewController *presentingController;
+ BOOL didEnableRotationNotifications;
+}
++ (void)presentAuthenticationDialogForRequest:(ASIHTTPRequest *)request;
++ (void)dismiss;
+
+@property (retain) ASIHTTPRequest *request;
+@property (assign) ASIAuthenticationType type;
+@property (assign) BOOL didEnableRotationNotifications;
+@property (retain) UIViewController *presentingController;
+@end
View
465 ExternalSources/asi-http-request/Classes/ASIAuthenticationDialog.m
@@ -0,0 +1,465 @@
+//
+// ASIAuthenticationDialog.m
+// Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+// Created by Ben Copsey on 21/08/2009.
+// Copyright 2009 All-Seeing Interactive. All rights reserved.
+//
+
+#import "ASIAuthenticationDialog.h"
+#import "ASIHTTPRequest.h"
+#import <CoreGraphics/CoreGraphics.h>
+
+ASIAuthenticationDialog *sharedDialog = nil;
+BOOL isDismissing = NO;
+static NSMutableArray *requestsNeedingAuthentication = nil;
+
+static const NSUInteger kUsernameRow = 0;
+static const NSUInteger kUsernameSection = 0;
+static const NSUInteger kPasswordRow = 1;
+static const NSUInteger kPasswordSection = 0;
+static const NSUInteger kDomainRow = 0;
+static const NSUInteger kDomainSection = 1;
+
+
+@implementation ASIAutorotatingViewController
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
+{
+ return YES;
+}
+
+@end
+
+
+@interface ASIAuthenticationDialog ()
+- (void)showTitle;
+- (void)show;
+- (NSArray *)requestsRequiringTheseCredentials;
+- (void)presentNextDialog;
+@property (retain) UITableView *tableView;
+@end
+
+@implementation ASIAuthenticationDialog
+
+#pragma mark init / dealloc
+
++ (void)initialize
+{
+ if (self == [ASIAuthenticationDialog class]) {
+ requestsNeedingAuthentication = [[NSMutableArray array] retain];
+ }
+}
+
++ (void)presentAuthenticationDialogForRequest:(ASIHTTPRequest *)request
+{
+ // No need for a lock here, this will always be called on the main thread
+ if (!sharedDialog) {
+ sharedDialog = [[self alloc] init];
+ [sharedDialog setRequest:request];
+ if ([request authenticationNeeded] == ASIProxyAuthenticationNeeded) {
+ [sharedDialog setType:ASIProxyAuthenticationType];
+ } else {
+ [sharedDialog setType:ASIStandardAuthenticationType];
+ }
+ [sharedDialog show];
+ } else {
+ [requestsNeedingAuthentication addObject:request];
+ }
+}
+
+- (id)init
+{
+ if ((self = [self initWithNibName:nil bundle:nil])) {
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
+
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
+#endif
+ if (![UIDevice currentDevice].generatesDeviceOrientationNotifications) {
+ [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
+ [self setDidEnableRotationNotifications:YES];
+ }
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
+ }
+#endif
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ if ([self didEnableRotationNotifications]) {
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
+ }
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
+
+ [request release];
+ [tableView release];
+ [presentingController.view removeFromSuperview];
+ [presentingController release];
+ [super dealloc];
+}
+
+#pragma mark keyboard notifications
+
+- (void)keyboardWillShow:(NSNotification *)notification
+{
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
+#endif
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_2
+ NSValue *keyboardBoundsValue = [[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey];
+#else
+ NSValue *keyboardBoundsValue = [[notification userInfo] objectForKey:UIKeyboardBoundsUserInfoKey];
+#endif
+ CGRect keyboardBounds;
+ [keyboardBoundsValue getValue:&keyboardBounds];
+ UIEdgeInsets e = UIEdgeInsetsMake(0, 0, keyboardBounds.size.height, 0);
+ [[self tableView] setScrollIndicatorInsets:e];
+ [[self tableView] setContentInset:e];
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
+ }
+#endif
+}
+
+// Manually handles orientation changes on iPhone
+- (void)orientationChanged:(NSNotification *)notification
+{
+ [[self view] setTransform:CGAffineTransformIdentity];
+ [self showTitle];
+ CGRect frame = [[self view] frame];
+ [[self view] setCenter:CGPointMake(frame.size.height/2,frame.size.width/2)];
+ float targetRotation = 0;
+
+ frame = [[UIScreen mainScreen] bounds];
+ switch ([[UIDevice currentDevice] orientation]) {
+ case UIDeviceOrientationPortraitUpsideDown:
+ targetRotation = 180;
+ frame = CGRectMake(0, 0, frame.size.width, frame.size.height-20);
+ break;
+ case UIDeviceOrientationLandscapeLeft:
+ targetRotation = 90;
+ frame = CGRectMake(0, 0, frame.size.width-20, frame.size.height);
+ break;
+ case UIDeviceOrientationLandscapeRight:
+ frame = CGRectMake(20, 0, frame.size.width-20, frame.size.height);
+ targetRotation = 270;
+ break;
+ case UIDeviceOrientationPortrait:
+ frame = CGRectMake(0, 20, frame.size.width, frame.size.height-20);
+ break;
+ }
+
+ [[self view] setTransform:CGAffineTransformMakeRotation(targetRotation / 180.0 * M_PI)];
+ [[self view] setFrame:frame];
+}
+
+#pragma mark utilities
+
+- (UIViewController *)presentingController
+{
+ if (!presentingController) {
+ presentingController = [[ASIAutorotatingViewController alloc] initWithNibName:nil bundle:nil];
+
+ // Attach to the window, but don't interfere.
+ UIWindow *window = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
+ [window addSubview:presentingController.view];
+ [[presentingController view] setFrame:CGRectZero];
+ [[presentingController view] setUserInteractionEnabled:NO];
+ }
+
+ return presentingController;
+}
+
+- (UITextField *)textFieldInRow:(NSUInteger)row section:(NSUInteger)section
+{
+ return [[[[[self tableView] cellForRowAtIndexPath:
+ [NSIndexPath indexPathForRow:row inSection:section]]
+ contentView] subviews] objectAtIndex:0];
+}
+
+- (UITextField *)usernameField
+{
+ return [self textFieldInRow:kUsernameRow section:kUsernameSection];
+}
+
+- (UITextField *)passwordField
+{
+ return [self textFieldInRow:kPasswordRow section:kPasswordSection];
+}
+
+- (UITextField *)domainField
+{
+ return [self textFieldInRow:kDomainRow section:kDomainSection];
+}
+
+#pragma mark show / dismiss
+
++ (void)dismiss
+{
+ [[sharedDialog parentViewController] dismissModalViewControllerAnimated:YES];
+ [sharedDialog release];
+ sharedDialog = nil;
+}
+
+- (void)dismiss
+{
+ if (self == sharedDialog) {
+ [[self class] dismiss];
+ } else {
+ [[self parentViewController] dismissModalViewControllerAnimated:YES];
+ }
+}
+
+- (void)showTitle
+{
+ UINavigationBar *navigationBar = [[[self view] subviews] objectAtIndex:0];
+ UINavigationItem *navItem = [[navigationBar items] objectAtIndex:0];
+ if (UIInterfaceOrientationIsPortrait([[UIDevice currentDevice] orientation])) {
+ // Setup the title
+ if ([self type] == ASIProxyAuthenticationType) {
+ [navItem setPrompt:@"Login to this secure proxy server."];
+ } else {
+ [navItem setPrompt:@"Login to this secure server."];
+ }
+ } else {
+ [navItem setPrompt:nil];
+ }
+ [navigationBar sizeToFit];
+ CGRect f = [[self view] bounds];
+ f.origin.y = [navigationBar frame].size.height;
+ f.size.height -= f.origin.y;
+ [[self tableView] setFrame:f];
+}
+
+- (void)show
+{
+ // Remove all subviews
+ UIView *v;
+ while ((v = [[[self view] subviews] lastObject])) {
+ [v removeFromSuperview];
+ }
+
+ // Setup toolbar
+ UINavigationBar *bar = [[[UINavigationBar alloc] init] autorelease];
+ [bar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
+
+ UINavigationItem *navItem = [[[UINavigationItem alloc] init] autorelease];
+ bar.items = [NSArray arrayWithObject:navItem];
+
+ [[self view] addSubview:bar];
+
+ [self showTitle];
+
+ // Setup toolbar buttons
+ if ([self type] == ASIProxyAuthenticationType) {
+ [navItem setTitle:[[self request] proxyHost]];
+ } else {
+ [navItem setTitle:[[[self request] url] host]];
+ }
+
+ [navItem setLeftBarButtonItem:[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelAuthenticationFromDialog:)] autorelease]];
+ [navItem setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithTitle:@"Login" style:UIBarButtonItemStyleDone target:self action:@selector(loginWithCredentialsFromDialog:)] autorelease]];
+
+ // We show the login form in a table view, similar to Safari's authentication dialog
+ [bar sizeToFit];
+ CGRect f = [[self view] bounds];
+ f.origin.y = [bar frame].size.height;
+ f.size.height -= f.origin.y;
+
+ [self setTableView:[[[UITableView alloc] initWithFrame:f style:UITableViewStyleGrouped] autorelease]];
+ [[self tableView] setDelegate:self];
+ [[self tableView] setDataSource:self];
+ [[self tableView] setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
+ [[self view] addSubview:[self tableView]];
+
+ // Force reload the table content, and focus the first field to show the keyboard
+ [[self tableView] reloadData];
+ [[[[[self tableView] cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]].contentView subviews] objectAtIndex:0] becomeFirstResponder];
+
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+ [self setModalPresentationStyle:UIModalPresentationFormSheet];
+ }
+#endif
+
+ [[self presentingController] presentModalViewController:self animated:YES];
+}
+
+#pragma mark button callbacks
+
+- (void)cancelAuthenticationFromDialog:(id)sender
+{
+ for (ASIHTTPRequest *theRequest in [self requestsRequiringTheseCredentials]) {
+ [theRequest cancelAuthentication];
+ [requestsNeedingAuthentication removeObject:theRequest];
+ }
+ [self dismiss];
+ [self performSelector:@selector(presentNextDialog) withObject:nil afterDelay:1];
+}
+
+- (NSArray *)requestsRequiringTheseCredentials
+{
+ NSMutableArray *requestsRequiringTheseCredentials = [NSMutableArray array];
+ NSURL *requestURL = [[self request] url];
+ for (ASIHTTPRequest *otherRequest in requestsNeedingAuthentication) {
+ NSURL *theURL = [otherRequest url];
+ if (([otherRequest authenticationNeeded] == [[self request] authenticationNeeded]) && [[theURL host] isEqualToString:[requestURL host]] && ([theURL port] == [requestURL port] || ([requestURL port] && [[theURL port] isEqualToNumber:[requestURL port]])) && [[theURL scheme] isEqualToString:[requestURL scheme]] && ((![otherRequest authenticationRealm] && ![[self request] authenticationRealm]) || ([otherRequest authenticationRealm] && [[self request] authenticationRealm] && [[[self request] authenticationRealm] isEqualToString:[otherRequest authenticationRealm]]))) {
+ [requestsRequiringTheseCredentials addObject:otherRequest];
+ }
+ }
+ [requestsRequiringTheseCredentials addObject:[self request]];
+ return requestsRequiringTheseCredentials;
+}
+
+- (void)presentNextDialog
+{
+ if ([requestsNeedingAuthentication count]) {
+ ASIHTTPRequest *nextRequest = [requestsNeedingAuthentication objectAtIndex:0];
+ [requestsNeedingAuthentication removeObjectAtIndex:0];
+ [[self class] presentAuthenticationDialogForRequest:nextRequest];
+ }
+}
+
+
+- (void)loginWithCredentialsFromDialog:(id)sender
+{
+ for (ASIHTTPRequest *theRequest in [self requestsRequiringTheseCredentials]) {
+
+ NSString *username = [[self usernameField] text];
+ NSString *password = [[self passwordField] text];
+
+ if (username == nil) { username = @""; }
+ if (password == nil) { password = @""; }
+
+ if ([self type] == ASIProxyAuthenticationType) {
+ [theRequest setProxyUsername:username];
+ [theRequest setProxyPassword:password];
+ } else {
+ [theRequest setUsername:username];
+ [theRequest setPassword:password];
+ }
+
+ // Handle NTLM domains
+ NSString *scheme = ([self type] == ASIStandardAuthenticationType) ? [[self request] authenticationScheme] : [[self request] proxyAuthenticationScheme];
+ if ([scheme isEqualToString:(NSString *)kCFHTTPAuthenticationSchemeNTLM]) {
+ NSString *domain = [[self domainField] text];
+ if ([self type] == ASIProxyAuthenticationType) {
+ [theRequest setProxyDomain:domain];
+ } else {
+ [theRequest setDomain:domain];
+ }
+ }
+
+ [theRequest retryUsingSuppliedCredentials];
+ [requestsNeedingAuthentication removeObject:theRequest];
+ }
+ [self performSelector:@selector(presentNextDialog) withObject:nil afterDelay:1];
+ [self dismiss];
+}
+
+#pragma mark table view data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView
+{
+ NSString *scheme = ([self type] == ASIStandardAuthenticationType) ? [[self request] authenticationScheme] : [[self request] proxyAuthenticationScheme];
+ if ([scheme isEqualToString:(NSString *)kCFHTTPAuthenticationSchemeNTLM]) {
+ return 2;
+ }
+ return 1;
+}
+
+- (CGFloat)tableView:(UITableView *)aTableView heightForFooterInSection:(NSInteger)section
+{
+ if (section == [self numberOfSectionsInTableView:aTableView]-1) {
+ return 30;
+ }
+ return 0;
+}
+
+- (CGFloat)tableView:(UITableView *)aTableView heightForHeaderInSection:(NSInteger)section
+{
+ if (section == 0) {
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+ return 54;
+ }
+#endif
+ return 30;
+ }
+ return 0;
+}
+
+- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
+{
+ if (section == 0) {
+ return [[self request] authenticationRealm];
+ }
+ return nil;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0
+ UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];
+#else
+ UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,0,0) reuseIdentifier:nil] autorelease];
+#endif
+
+ [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
+
+ CGRect f = CGRectInset([cell bounds], 10, 10);
+ UITextField *textField = [[[UITextField alloc] initWithFrame:f] autorelease];
+ [textField setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
+ [textField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
+ [textField setAutocorrectionType:UITextAutocorrectionTypeNo];
+
+ NSUInteger s = [indexPath section];
+ NSUInteger r = [indexPath row];
+
+ if (s == kUsernameSection && r == kUsernameRow) {
+ [textField setPlaceholder:@"User"];
+ } else if (s == kPasswordSection && r == kPasswordRow) {
+ [textField setPlaceholder:@"Password"];
+ [textField setSecureTextEntry:YES];
+ } else if (s == kDomainSection && r == kDomainRow) {
+ [textField setPlaceholder:@"Domain"];
+ }
+ [cell.contentView addSubview:textField];
+
+ return cell;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ if (section == 0) {
+ return 2;
+ } else {
+ return 1;
+ }
+}
+
+- (NSString *)tableView:(UITableView *)aTableView titleForFooterInSection:(NSInteger)section
+{
+ if (section == [self numberOfSectionsInTableView:aTableView]-1) {
+ // If we're using Basic authentication and the connection is not using SSL, we'll show the plain text message
+ if ([[[self request] authenticationScheme] isEqualToString:(NSString *)kCFHTTPAuthenticationSchemeBasic] && ![[[[self request] url] scheme] isEqualToString:@"https"]) {
+ return @"Password will be sent in the clear.";
+ // We are using Digest, NTLM, or any scheme over SSL
+ } else {
+ return @"Password will be sent securely.";
+ }
+ }
+ return nil;
+}
+
+#pragma mark -
+
+@synthesize request;
+@synthesize type;
+@synthesize tableView;
+@synthesize didEnableRotationNotifications;
+@synthesize presentingController;
+@end
View
55 ExternalSources/asi-http-request/Classes/ASICacheDelegate.h
@@ -0,0 +1,55 @@
+//
+// ASICacheDelegate.h
+// Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+// Created by Ben Copsey on 01/05/2010.
+// Copyright 2010 All-Seeing Interactive. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+@class ASIHTTPRequest;
+
+typedef enum _ASICachePolicy {
+ ASIDefaultCachePolicy = 0,
+ ASIIgnoreCachePolicy = 1,
+ ASIReloadIfDifferentCachePolicy = 2,
+ ASIOnlyLoadIfNotCachedCachePolicy = 3,
+ ASIUseCacheIfLoadFailsCachePolicy = 4
+} ASICachePolicy;
+
+typedef enum _ASICacheStoragePolicy {
+ ASICacheForSessionDurationCacheStoragePolicy = 0,
+ ASICachePermanentlyCacheStoragePolicy = 1
+} ASICacheStoragePolicy;
+
+
+@protocol ASICacheDelegate <NSObject>
+
+@required
+
+// Should return the cache policy that will be used when requests have their cache policy set to ASIDefaultCachePolicy
+- (ASICachePolicy)defaultCachePolicy;
+
+// Should Remove cached data for a particular request
+- (void)removeCachedDataForRequest:(ASIHTTPRequest *)request;
+
+// Should return YES if the cache considers its cached response current for the request
+// Should return NO is the data is not cached, or (for example) if the cached headers state the request should have expired
+- (BOOL)isCachedDataCurrentForRequest:(ASIHTTPRequest *)request;
+
+// Should store the response for the passed request in the cache
+// When a non-zero maxAge is passed, it should be used as the expiry time for the cached response
+- (void)storeResponseForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge;
+
+// Should return an NSDictionary of cached headers for the passed request, if it is stored in the cache
+- (NSDictionary *)cachedHeadersForRequest:(ASIHTTPRequest *)request;
+
+// Should return the cached body of a response for the passed request, if it is stored in the cache
+- (NSData *)cachedResponseDataForRequest:(ASIHTTPRequest *)request;
+
+// Same as the above, but returns a path to the cached response body instead
+- (NSString *)pathToCachedResponseDataForRequest:(ASIHTTPRequest *)request;
+
+// Clear cached data stored for the passed storage policy
+- (void)clearCachedResponsesForStoragePolicy:(ASICacheStoragePolicy)cachePolicy;
+@end
View
47 ExternalSources/asi-http-request/Classes/ASIDownloadCache.h
@@ -0,0 +1,47 @@
+//
+// ASIDownloadCache.h
+// Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+// Created by Ben Copsey on 01/05/2010.
+// Copyright 2010 All-Seeing Interactive. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "ASICacheDelegate.h"
+
+@interface ASIDownloadCache : NSObject <ASICacheDelegate> {
+
+ // The default cache policy for this cache
+ // Requests that store data in the cache will use this cache policy if their cache policy is set to ASIDefaultCachePolicy
+ // Defaults to ASIReloadIfDifferentCachePolicy
+ ASICachePolicy defaultCachePolicy;
+
+ // The directory in which cached data will be stored
+ // Defaults to a directory called 'ASIHTTPRequestCache' in the temporary directory
+ NSString *storagePath;
+
+ // Mediates access to the cache
+ NSRecursiveLock *accessLock;
+
+ // When YES, the cache will look for cache-control / pragma: no-cache headers, and won't reuse store responses if it finds them
+ BOOL shouldRespectCacheControlHeaders;
+}
+
+// Returns a static instance of an ASIDownloadCache
+// In most circumstances, it will make sense to use this as a global cache, rather than creating your own cache
+// To make ASIHTTPRequests use it automatically, use [ASIHTTPRequest setDefaultCache:[ASIDownloadCache sharedCache]];
++ (id)sharedCache;
+
+// A helper function that determines if the server has requested data should not be cached by looking at the request's response headers
++ (BOOL)serverAllowsResponseCachingForRequest:(ASIHTTPRequest *)request;
+
+// A date formatter that can be used to construct an RFC 1123 date
+// The returned formatter is safe to use on the calling thread
+// Do not use this formatter for parsing dates because the format can vary slightly - use ASIHTTPRequest's dateFromRFC1123String: class method instead
++ (NSDateFormatter *)rfc1123DateFormatter;
+
+@property (assign) ASICachePolicy defaultCachePolicy;
+@property (retain) NSString *storagePath;
+@property (retain) NSRecursiveLock *accessLock;
+@property (assign) BOOL shouldRespectCacheControlHeaders;
+@end
View
374 ExternalSources/asi-http-request/Classes/ASIDownloadCache.m
@@ -0,0 +1,374 @@
+//
+// ASIDownloadCache.m
+// Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+// Created by Ben Copsey on 01/05/2010.
+// Copyright 2010 All-Seeing Interactive. All rights reserved.
+//
+
+#import "ASIDownloadCache.h"
+#import "ASIHTTPRequest.h"
+#import <CommonCrypto/CommonHMAC.h>
+
+static ASIDownloadCache *sharedCache = nil;
+
+static NSString *sessionCacheFolder = @"SessionStore";
+static NSString *permanentCacheFolder = @"PermanentStore";
+
+@interface ASIDownloadCache ()
++ (NSString *)keyForRequest:(ASIHTTPRequest *)request;
+@end
+
+@implementation ASIDownloadCache
+
+- (id)init
+{
+ self = [super init];
+ [self setShouldRespectCacheControlHeaders:YES];
+ [self setDefaultCachePolicy:ASIReloadIfDifferentCachePolicy];
+ [self setAccessLock:[[[NSRecursiveLock alloc] init] autorelease]];
+ return self;
+}
+
++ (id)sharedCache
+{
+ if (!sharedCache) {
+ sharedCache = [[self alloc] init];
+ [sharedCache setStoragePath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"ASIHTTPRequestCache"]];
+
+ }
+ return sharedCache;
+}
+
+- (void)dealloc
+{
+ [storagePath release];
+ [accessLock release];
+ [super dealloc];
+}
+
+- (void)setStoragePath:(NSString *)path
+{
+ [[self accessLock] lock];
+ [self clearCachedResponsesForStoragePolicy:ASICacheForSessionDurationCacheStoragePolicy];
+ [storagePath release];
+ storagePath = [path retain];
+ BOOL isDirectory = NO;
+ NSArray *directories = [NSArray arrayWithObjects:path,[path stringByAppendingPathComponent:sessionCacheFolder],[path stringByAppendingPathComponent:permanentCacheFolder],nil];
+ for (NSString *directory in directories) {
+ BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:directory isDirectory:&isDirectory];
+ if (exists && !isDirectory) {
+ [[self accessLock] unlock];
+ [NSException raise:@"FileExistsAtCachePath" format:@"Cannot create a directory for the cache at '%@', because a file already exists",directory];
+ } else if (!exists) {
+ [[NSFileManager defaultManager] createDirectoryAtPath:directory attributes:nil];
+ if (![[NSFileManager defaultManager] fileExistsAtPath:directory]) {
+ [[self accessLock] unlock];
+ [NSException raise:@"FailedToCreateCacheDirectory" format:@"Failed to create a directory for the cache at '%@'",directory];
+ }
+ }
+ }
+ [self clearCachedResponsesForStoragePolicy:ASICacheForSessionDurationCacheStoragePolicy];
+ [[self accessLock] unlock];
+}
+
+- (void)storeResponseForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge
+{
+ [[self accessLock] lock];
+
+ if ([request error] || ![request responseHeaders] || ([request responseStatusCode] != 200)) {
+ [[self accessLock] unlock];
+ return;
+ }
+
+ if ([self shouldRespectCacheControlHeaders] && ![[self class] serverAllowsResponseCachingForRequest:request]) {
+ [[self accessLock] unlock];
+ return;
+ }
+
+ // If the request is set to use the default policy, use this cache's default policy
+ ASICachePolicy policy = [request cachePolicy];
+ if (policy == ASIDefaultCachePolicy) {
+ policy = [self defaultCachePolicy];
+ }
+
+ if (policy == ASIIgnoreCachePolicy) {
+ [[self accessLock] unlock];
+ return;
+ }
+ NSString *path = nil;
+ if ([request cacheStoragePolicy] == ASICacheForSessionDurationCacheStoragePolicy) {
+ path = [[self storagePath] stringByAppendingPathComponent:sessionCacheFolder];
+ } else {
+ path = [[self storagePath] stringByAppendingPathComponent:permanentCacheFolder];
+ }
+ path = [path stringByAppendingPathComponent:[[self class] keyForRequest:request]];
+ NSString *metadataPath = [path stringByAppendingPathExtension:@"cachedheaders"];
+ NSString *dataPath = [path stringByAppendingPathExtension:@"cacheddata"];
+
+ NSMutableDictionary *responseHeaders = [NSMutableDictionary dictionaryWithDictionary:[request responseHeaders]];
+ if ([request isResponseCompressed]) {
+ [responseHeaders removeObjectForKey:@"Content-Encoding"];
+ }
+ if (maxAge != 0) {
+ [responseHeaders removeObjectForKey:@"Expires"];
+ [responseHeaders setObject:[NSString stringWithFormat:@"max-age=%i",(int)maxAge] forKey:@"Cache-Control"];
+ }
+ // We use this special key to help expire the request when we get a max-age header
+ [responseHeaders setObject:[[[self class] rfc1123DateFormatter] stringFromDate:[NSDate date]] forKey:@"X-ASIHTTPRequest-Fetch-date"];
+ [responseHeaders writeToFile:metadataPath atomically:NO];
+
+ if ([request responseData]) {
+ [[request responseData] writeToFile:dataPath atomically:NO];
+ } else if ([request downloadDestinationPath]) {
+ NSError *error = nil;
+ [[NSFileManager defaultManager] copyItemAtPath:[request downloadDestinationPath] toPath:dataPath error:&error];
+ }
+ [[self accessLock] unlock];
+}
+
+- (NSDictionary *)cachedHeadersForRequest:(ASIHTTPRequest *)request
+{
+ [[self accessLock] lock];
+ if (![self storagePath]) {
+ [[self accessLock] unlock];
+ return nil;
+ }
+ // Look in the session store
+ NSString *path = [[self storagePath] stringByAppendingPathComponent:sessionCacheFolder];
+ NSString *dataPath = [path stringByAppendingPathComponent:[[[self class] keyForRequest:request] stringByAppendingPathExtension:@"cachedheaders"]];
+ if ([[NSFileManager defaultManager] fileExistsAtPath:dataPath]) {
+ [[self accessLock] unlock];
+ return [NSDictionary dictionaryWithContentsOfFile:dataPath];
+ }
+ // Look in the permanent store
+ path = [[self storagePath] stringByAppendingPathComponent:permanentCacheFolder];
+ dataPath = [path stringByAppendingPathComponent:[[[self class] keyForRequest:request] stringByAppendingPathExtension:@"cachedheaders"]];
+ if ([[NSFileManager defaultManager] fileExistsAtPath:dataPath]) {
+ [[self accessLock] unlock];
+ return [NSDictionary dictionaryWithContentsOfFile:dataPath];
+ }
+ [[self accessLock] unlock];
+ return nil;
+}
+
+- (NSData *)cachedResponseDataForRequest:(ASIHTTPRequest *)request
+{
+ NSString *path = [self pathToCachedResponseDataForRequest:request];
+ if (path) {
+ return [NSData dataWithContentsOfFile:path];
+ }
+ return nil;
+}
+
+- (NSString *)pathToCachedResponseDataForRequest:(ASIHTTPRequest *)request
+{
+ [[self accessLock] lock];
+ if (![self storagePath]) {
+ [[self accessLock] unlock];
+ return nil;
+ }
+ // Look in the session store
+ NSString *path = [[self storagePath] stringByAppendingPathComponent:sessionCacheFolder];
+ NSString *dataPath = [path stringByAppendingPathComponent:[[[self class] keyForRequest:request] stringByAppendingPathExtension:@"cacheddata"]];
+ if ([[NSFileManager defaultManager] fileExistsAtPath:dataPath]) {
+ [[self accessLock] unlock];
+ return dataPath;
+ }
+ // Look in the permanent store
+ path = [[self storagePath] stringByAppendingPathComponent:permanentCacheFolder];
+ dataPath = [path stringByAppendingPathComponent:[[[self class] keyForRequest:request] stringByAppendingPathExtension:@"cacheddata"]];
+ if ([[NSFileManager defaultManager] fileExistsAtPath:dataPath]) {
+ [[self accessLock] unlock];
+ return dataPath;
+ }
+ [[self accessLock] unlock];
+ return nil;
+}
+
+- (void)removeCachedDataForRequest:(ASIHTTPRequest *)request
+{
+ [[self accessLock] lock];
+ if (![self storagePath]) {
+ [[self accessLock] unlock];
+ return;
+ }
+ NSString *cachedHeadersPath = [[self storagePath] stringByAppendingPathComponent:[[[self class] keyForRequest:request] stringByAppendingPathExtension:@"cachedheaders"]];
+ if (!cachedHeadersPath) {
+ [[self accessLock] unlock];
+ return;
+ }
+ NSString *dataPath = [self pathToCachedResponseDataForRequest:request];
+ if (!dataPath) {
+ [[self accessLock] unlock];
+ return;
+ }
+ [[NSFileManager defaultManager] removeItemAtPath:cachedHeadersPath error:NULL];
+ [[NSFileManager defaultManager] removeItemAtPath:dataPath error:NULL];
+ [[self accessLock] unlock];
+}
+
+- (BOOL)isCachedDataCurrentForRequest:(ASIHTTPRequest *)request
+{
+ [[self accessLock] lock];
+ if (![self storagePath]) {
+ [[self accessLock] unlock];
+ return NO;
+ }
+ NSDictionary *cachedHeaders = [self cachedHeadersForRequest:request];
+ if (!cachedHeaders) {
+ [[self accessLock] unlock];
+ return NO;
+ }
+ NSString *dataPath = [self pathToCachedResponseDataForRequest:request];
+ if (!dataPath) {
+ [[self accessLock] unlock];
+ return NO;
+ }
+
+ if ([self shouldRespectCacheControlHeaders]) {
+
+ // Look for an Expires header to see if the content is out of data
+ NSString *expires = [cachedHeaders objectForKey:@"Expires"];
+ if (expires) {
+ if ([[ASIHTTPRequest dateFromRFC1123String:expires] timeIntervalSinceNow] < 0) {
+ [[self accessLock] unlock];
+ return NO;
+ }
+ }
+ // Look for a max-age header
+ NSString *cacheControl = [[cachedHeaders objectForKey:@"Cache-Control"] lowercaseString];
+ if (cacheControl) {
+ NSScanner *scanner = [NSScanner scannerWithString:cacheControl];
+ if ([scanner scanString:@"max-age" intoString:NULL]) {
+ [scanner scanString:@"=" intoString:NULL];
+ NSTimeInterval maxAge = 0;
+ [scanner scanDouble:&maxAge];
+ NSDate *fetchDate = [ASIHTTPRequest dateFromRFC1123String:[cachedHeaders objectForKey:@"X-ASIHTTPRequest-Fetch-date"]];
+
+ #if (TARGET_OS_IPHONE && (!defined(__IPHONE_4_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_4_0)) || !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
+ NSDate *expiryDate = [fetchDate addTimeInterval:maxAge];
+ #else
+ NSDate *expiryDate = [fetchDate dateByAddingTimeInterval:maxAge];
+ #endif
+
+ if ([expiryDate timeIntervalSinceNow] < 0) {
+ [[self accessLock] unlock];
+ return NO;
+ }
+ }
+ }
+
+ }
+
+ // If we already have response headers for this request, check to see if the new content is different
+ if ([request responseHeaders] && [request responseStatusCode] != 304) {
+ // If the Etag or Last-Modified date are different from the one we have, fetch the document again
+ NSArray *headersToCompare = [NSArray arrayWithObjects:@"Etag",@"Last-Modified",nil];
+ for (NSString *header in headersToCompare) {
+ if (![[[request responseHeaders] objectForKey:header] isEqualToString:[cachedHeaders objectForKey:header]]) {
+ [[self accessLock] unlock];
+ return NO;
+ }
+ }
+ }
+ [[self accessLock] unlock];
+ return YES;
+}
+
+
+- (void)setDefaultCachePolicy:(ASICachePolicy)cachePolicy
+{
+ [[self accessLock] lock];
+ if (cachePolicy == ASIDefaultCachePolicy) {
+ defaultCachePolicy = ASIReloadIfDifferentCachePolicy;
+ } else {
+ defaultCachePolicy = cachePolicy;
+ }
+ [[self accessLock] unlock];
+}
+
+- (void)clearCachedResponsesForStoragePolicy:(ASICacheStoragePolicy)storagePolicy
+{
+ [[self accessLock] lock];
+ if (![self storagePath]) {
+ [[self accessLock] unlock];
+ return;
+ }
+ NSString *path;
+ if (storagePolicy == ASICacheForSessionDurationCacheStoragePolicy) {
+ path = [[self storagePath] stringByAppendingPathComponent:sessionCacheFolder];
+ } else if (storagePolicy == ASICachePermanentlyCacheStoragePolicy) {
+ path = [[self storagePath] stringByAppendingPathComponent:permanentCacheFolder];
+ }
+ BOOL isDirectory = NO;
+ BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDirectory];
+ if (exists && !isDirectory || !exists) {
+ [[self accessLock] unlock];
+ return;
+ }
+ NSError *error = nil;
+ NSArray *cacheFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:&error];
+ if (error) {
+ [[self accessLock] unlock];
+ [NSException raise:@"FailedToTraverseCacheDirectory" format:@"Listing cache directory failed at path '%@'",path];
+ }
+ for (NSString *file in cacheFiles) {
+ NSString *extension = [file pathExtension];
+ if ([extension isEqualToString:@"cacheddata"] || [extension isEqualToString:@"cachedheaders"]) {
+ [[NSFileManager defaultManager] removeItemAtPath:[path stringByAppendingPathComponent:file] error:&error];
+ if (error) {
+ [[self accessLock] unlock];
+ [NSException raise:@"FailedToRemoveCacheFile" format:@"Failed to remove cached data at path '%@'",path];
+ }
+ }
+ }
+ [[self accessLock] unlock];
+}
+
++ (BOOL)serverAllowsResponseCachingForRequest:(ASIHTTPRequest *)request
+{
+ NSString *cacheControl = [[[request responseHeaders] objectForKey:@"Cache-Control"] lowercaseString];
+ if (cacheControl) {
+ if ([cacheControl isEqualToString:@"no-cache"] || [cacheControl isEqualToString:@"no-store"]) {
+ return NO;
+ }
+ }
+ NSString *pragma = [[[request responseHeaders] objectForKey:@"Pragma"] lowercaseString];
+ if (pragma) {
+ if ([pragma isEqualToString:@"no-cache"]) {
+ return NO;
+ }
+ }
+ return YES;
+}
+
+// Borrowed from: http://stackoverflow.com/questions/652300/using-md5-hash-on-a-string-in-cocoa
++ (NSString *)keyForRequest:(ASIHTTPRequest *)request
+{
+ const char *cStr = [[[request url] absoluteString] UTF8String];
+ unsigned char result[16];
+ CC_MD5(cStr, (CC_LONG)strlen(cStr), result);
+ return [NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7],result[8], result[9], result[10], result[11],result[12], result[13], result[14], result[15]];
+}
+
++ (NSDateFormatter *)rfc1123DateFormatter
+{
+ NSMutableDictionary *threadDict = [[NSThread currentThread] threadDictionary];
+ NSDateFormatter *dateFormatter = [threadDict objectForKey:@"ASIDownloadCacheDateFormatter"];
+ if (dateFormatter == nil) {
+ dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
+ [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
+ [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
+ [dateFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss 'GMT'"];
+ [threadDict setObject:dateFormatter forKey:@"ASIDownloadCacheDateFormatter"];
+ }
+ return dateFormatter;
+}
+
+
+@synthesize storagePath;
+@synthesize defaultCachePolicy;
+@synthesize accessLock;
+@synthesize shouldRespectCacheControlHeaders;
+@end
View
76 ExternalSources/asi-http-request/Classes/ASIFormDataRequest.h
@@ -0,0 +1,76 @@
+//
+// ASIFormDataRequest.h
+// Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+// Created by Ben Copsey on 07/11/2008.
+// Copyright 2008-2009 All-Seeing Interactive. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "ASIHTTPRequest.h"
+#import "ASIHTTPRequestConfig.h"
+
+typedef enum _ASIPostFormat {
+ ASIMultipartFormDataPostFormat = 0,
+ ASIURLEncodedPostFormat = 1
+
+} ASIPostFormat;
+
+@interface ASIFormDataRequest : ASIHTTPRequest <NSCopying> {
+
+ // Parameters that will be POSTed to the url
+ NSMutableArray *postData;
+
+ // Files that will be POSTed to the url
+ NSMutableArray *fileData;
+
+ ASIPostFormat postFormat;
+
+ NSStringEncoding stringEncoding;
+
+#if DEBUG_FORM_DATA_REQUEST
+ // Will store a string version of the request body that will be printed to the console when ASIHTTPREQUEST_DEBUG is set in GCC_PREPROCESSOR_DEFINITIONS
+ NSString *debugBodyString;
+#endif
+
+}
+
+#pragma mark utilities
+- (NSString*)encodeURL:(NSString *)string;
+
+#pragma mark setup request
+
+// Add a POST variable to the request
+- (void)addPostValue:(id <NSObject>)value forKey:(NSString *)key;
+
+// Set a POST variable for this request, clearing any others with the same key
+- (void)setPostValue:(id <NSObject>)value forKey:(NSString *)key;
+
+// Add the contents of a local file to the request
+- (void)addFile:(NSString *)filePath forKey:(NSString *)key;
+
+// Same as above, but you can specify the content-type and file name
+- (void)addFile:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
+
+// Add the contents of a local file to the request, clearing any others with the same key
+- (void)setFile:(NSString *)filePath forKey:(NSString *)key;
+
+// Same as above, but you can specify the content-type and file name
+- (void)setFile:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
+
+// Add the contents of an NSData object to the request
+- (void)addData:(NSData *)data forKey:(NSString *)key;
+
+// Same as above, but you can specify the content-type and file name
+- (void)addData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
+
+// Add the contents of an NSData object to the request, clearing any others with the same key
+- (void)setData:(NSData *)data forKey:(NSString *)key;
+
+// Same as above, but you can specify the content-type and file name
+- (void)setData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
+
+
+@property (assign) ASIPostFormat postFormat;
+@property (assign) NSStringEncoding stringEncoding;
+@end
View
358 ExternalSources/asi-http-request/Classes/ASIFormDataRequest.m
@@ -0,0 +1,358 @@
+//
+// ASIFormDataRequest.m
+// Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+// Created by Ben Copsey on 07/11/2008.
+// Copyright 2008-2009 All-Seeing Interactive. All rights reserved.
+//
+
+#import "ASIFormDataRequest.h"
+
+
+// Private stuff
+@interface ASIFormDataRequest ()
+- (void)buildMultipartFormDataPostBody;
+- (void)buildURLEncodedPostBody;
+- (void)appendPostString:(NSString *)string;
+
+@property (retain) NSMutableArray *postData;
+@property (retain) NSMutableArray *fileData;
+
+#if DEBUG_FORM_DATA_REQUEST
+- (void)addToDebugBody:(NSString *)string;
+@property (retain, nonatomic) NSString *debugBodyString;
+#endif
+
+@end
+
+@implementation ASIFormDataRequest
+
+#pragma mark utilities
+- (NSString*)encodeURL:(NSString *)string
+{
+ NSString *newString = NSMakeCollectable([(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding([self stringEncoding])) autorelease]);
+ if (newString) {
+ return newString;
+ }
+ return @"";
+}
+
+#pragma mark init / dealloc
+
++ (id)requestWithURL:(NSURL *)newURL
+{
+ return [[[self alloc] initWithURL:newURL] autorelease];
+}
+
+- (id)initWithURL:(NSURL *)newURL
+{
+ self = [super initWithURL:newURL];
+ [self setPostFormat:ASIURLEncodedPostFormat];
+ [self setStringEncoding:NSUTF8StringEncoding];
+ return self;
+}
+
+- (void)dealloc
+{
+#if DEBUG_FORM_DATA_REQUEST
+ [debugBodyString release];
+#endif
+
+ [postData release];
+ [fileData release];
+ [super dealloc];
+}
+
+#pragma mark setup request
+
+- (void)addPostValue:(id <NSObject>)value forKey:(NSString *)key
+{
+ if (![self postData]) {
+ [self setPostData:[NSMutableArray array]];
+ }
+ [[self postData] addObject:[NSDictionary dictionaryWithObjectsAndKeys:[value description],@"value",key,@"key",nil]];
+}
+
+- (void)setPostValue:(id <NSObject>)value forKey:(NSString *)key
+{
+ // Remove any existing value
+ NSUInteger i;
+ for (i=0; i<[[self postData] count]; i++) {
+ NSDictionary *val = [[self postData] objectAtIndex:i];
+ if ([[val objectForKey:@"key"] isEqualToString:key]) {
+ [[self postData] removeObjectAtIndex:i];
+ i--;
+ }
+ }
+ [self addPostValue:value forKey:key];
+}
+
+
+- (void)addFile:(NSString *)filePath forKey:(NSString *)key
+{
+ [self addFile:filePath withFileName:nil andContentType:nil forKey:key];
+}
+
+- (void)addFile:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key
+{
+ if (![self fileData]) {
+ [self setFileData:[NSMutableArray array]];
+ }
+
+ // If data is a path to a local file
+ if ([data isKindOfClass:[NSString class]]) {
+ BOOL isDirectory = NO;
+ BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:(NSString *)data isDirectory:&isDirectory];
+ if (!fileExists || isDirectory) {
+ [self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIInternalErrorWhileBuildingRequestType userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"No file exists at %@",data],NSLocalizedDescriptionKey,nil]]];
+ }
+
+ // If the caller didn't specify a custom file name, we'll use the file name of the file we were passed
+ if (!fileName) {
+ fileName = [(NSString *)data lastPathComponent];
+ }
+
+ // If we were given the path to a file, and the user didn't specify a mime type, we can detect it from the file extension
+ if (!contentType) {
+ contentType = [ASIHTTPRequest mimeTypeForFileAtPath:data];
+ }
+ }
+
+ NSDictionary *fileInfo = [NSDictionary dictionaryWithObjectsAndKeys:data, @"data", contentType, @"contentType", fileName, @"fileName", key, @"key", nil];
+ [[self fileData] addObject:fileInfo];
+}
+
+
+- (void)setFile:(NSString *)filePath forKey:(NSString *)key
+{
+ [self setFile:filePath withFileName:nil andContentType:nil forKey:key];
+}
+
+- (void)setFile:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key
+{
+ // Remove any existing value
+ NSUInteger i;
+ for (i=0; i<[[self fileData] count]; i++) {
+ NSDictionary *val = [[self fileData] objectAtIndex:i];
+ if ([[val objectForKey:@"key"] isEqualToString:key]) {
+ [[self fileData] removeObjectAtIndex:i];
+ i--;
+ }
+ }
+ [self addFile:data withFileName:fileName andContentType:contentType forKey:key];
+}
+
+- (void)addData:(NSData *)data forKey:(NSString *)key
+{
+ [self addData:data withFileName:@"file" andContentType:nil forKey:key];
+}
+
+- (void)addData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key
+{
+ if (![self fileData]) {
+ [self setFileData:[NSMutableArray array]];
+ }
+ if (!contentType) {
+ contentType = @"application/octet-stream";
+ }
+
+ NSDictionary *fileInfo = [NSDictionary dictionaryWithObjectsAndKeys:data, @"data", contentType, @"contentType", fileName, @"fileName", key, @"key", nil];
+ [[self fileData] addObject:fileInfo];
+}
+
+- (void)setData:(NSData *)data forKey:(NSString *)key
+{
+ [self setData:data withFileName:@"file" andContentType:nil forKey:key];
+}
+
+- (void)setData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key
+{
+ // Remove any existing value
+ NSUInteger i;
+ for (i=0; i<[[self fileData] count]; i++) {
+ NSDictionary *val = [[self fileData] objectAtIndex:i];
+ if ([[val objectForKey:@"key"] isEqualToString:key]) {
+ [[self fileData] removeObjectAtIndex:i];
+ i--;
+ }
+ }
+ [self addData:data withFileName:fileName andContentType:contentType forKey:key];
+}
+
+- (void)buildPostBody
+{
+ if ([self haveBuiltPostBody]) {
+ return;
+ }
+ if (![[self requestMethod] isEqualToString:@"PUT"]) {
+ [self setRequestMethod:@"POST"];
+ }
+
+#if DEBUG_FORM_DATA_REQUEST
+ [self setDebugBodyString:@""];
+#endif
+
+ if (![self postData] && ![self fileData]) {
+ [super buildPostBody];
+ return;
+ }
+ if ([[self fileData] count] > 0) {
+ [self setShouldStreamPostDataFromDisk:YES];
+ }
+
+ if ([self postFormat] == ASIURLEncodedPostFormat) {
+ [self buildURLEncodedPostBody];
+ } else {
+ [self buildMultipartFormDataPostBody];
+ }
+
+ [super buildPostBody];
+
+#if DEBUG_FORM_DATA_REQUEST
+ NSLog(@"%@",[self debugBodyString]);
+ [self setDebugBodyString:nil];
+#endif
+}
+
+
+- (void)buildMultipartFormDataPostBody
+{
+#if DEBUG_FORM_DATA_REQUEST
+ [self addToDebugBody:@"\r\n==== Building a multipart/form-data body ====\r\n"];
+#endif
+
+ NSString *charset = (NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding([self stringEncoding]));
+
+ // Set your own boundary string only if really obsessive. We don't bother to check if post data contains the boundary, since it's pretty unlikely that it does.
+ NSString *stringBoundary = @"0xKhTmLbOuNdArY";
+
+ [self addRequestHeader:@"Content-Type" value:[NSString stringWithFormat:@"multipart/form-data; charset=%@; boundary=%@", charset, stringBoundary]];
+
+ [self appendPostString:[NSString stringWithFormat:@"--%@\r\n",stringBoundary]];
+
+ // Adds post data
+ NSString *endItemBoundary = [NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary];
+ NSUInteger i=0;
+ for (NSDictionary *val in [self postData]) {
+ [self appendPostString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",[val objectForKey:@"key"]]];
+ [self appendPostString:[val objectForKey:@"value"]];
+ i++;
+ if (i != [[self postData] count] || [[self fileData] count] > 0) { //Only add the boundary if this is not the last item in the post body
+ [self appendPostString:endItemBoundary];
+ }
+ }
+
+ // Adds files to upload
+ i=0;
+ for (NSDictionary *val in [self fileData]) {
+
+ [self appendPostString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", [val objectForKey:@"key"], [val objectForKey:@"fileName"]]];
+ [self appendPostString:[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n", [val objectForKey:@"contentType"]]];
+
+ id data = [val objectForKey:@"data"];
+ if ([data isKindOfClass:[NSString class]]) {
+ [self appendPostDataFromFile:data];
+ } else {
+ [self appendPostData:data];
+ }
+ i++;
+ // Only add the boundary if this is not the last item in the post body
+ if (i != [[self fileData] count]) {
+ [self appendPostString:endItemBoundary];
+ }
+ }
+
+ [self appendPostString:[NSString stringWithFormat:@"\r\n--%@--\r\n",stringBoundary]];
+
+#if DEBUG_FORM_DATA_REQUEST
+ [self addToDebugBody:@"==== End of multipart/form-data body ====\r\n"];
+#endif
+}
+
+- (void)buildURLEncodedPostBody
+{
+
+ // We can't post binary data using application/x-www-form-urlencoded
+ if ([[self fileData] count] > 0) {
+ [self setPostFormat:ASIMultipartFormDataPostFormat];
+ [self buildMultipartFormDataPostBody];
+ return;
+ }
+
+#if DEBUG_FORM_DATA_REQUEST
+ [self addToDebugBody:@"\r\n==== Building an application/x-www-form-urlencoded body ====\r\n"];
+#endif
+
+
+ NSString *charset = (NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding([self stringEncoding]));
+
+ [self addRequestHeader:@"Content-Type" value:[NSString stringWithFormat:@"application/x-www-form-urlencoded; charset=%@",charset]];
+
+
+ NSUInteger i=0;
+ NSUInteger count = [[self postData] count]-1;
+ for (NSDictionary *val in [self postData]) {
+ NSString *data = [NSString stringWithFormat:@"%@=%@%@", [self encodeURL:[val objectForKey:@"key"]], [self encodeURL:[val objectForKey:@"value"]],(i<count ? @"&" : @"")];
+ [self appendPostString:data];
+ i++;
+ }
+#if DEBUG_FORM_DATA_REQUEST
+ [self addToDebugBody:@"\r\n==== End of application/x-www-form-urlencoded body ====\r\n"];
+#endif
+}
+
+- (void)appendPostString:(NSString *)string
+{
+#if DEBUG_FORM_DATA_REQUEST
+ [self addToDebugBody:string];
+#endif
+ [super appendPostData:[string dataUsingEncoding:[self stringEncoding]]];
+}
+
+#if DEBUG_FORM_DATA_REQUEST
+- (void)appendPostData:(NSData *)data
+{
+ [self addToDebugBody:[NSString stringWithFormat:@"[%lu bytes of data]",(unsigned long)[data length]]];
+ [super appendPostData:data];
+}
+
+- (void)appendPostDataFromFile:(NSString *)file
+{
+ NSError *err = nil;
+ unsigned long long fileSize = [[[[NSFileManager defaultManager] attributesOfItemAtPath:file error:&err] objectForKey:NSFileSize] unsignedLongLongValue];
+ if (err) {
+ [self addToDebugBody:[NSString stringWithFormat:@"[Error: Failed to obtain the size of the file at '%@']",file]];
+ } else {
+ [self addToDebugBody:[NSString stringWithFormat:@"[%llu bytes of data from file '%@']",fileSize,file]];
+ }
+
+ [super appendPostDataFromFile:file];
+}
+
+- (void)addToDebugBody:(NSString *)string
+{
+ [self setDebugBodyString:[[self debugBodyString] stringByAppendingString:string]];
+}
+#endif
+
+#pragma mark NSCopying
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ ASIFormDataRequest *newRequest = [super copyWithZone:zone];
+ [newRequest setPostData:[[[self postData] mutableCopyWithZone:zone] autorelease]];
+ [newRequest setFileData:[[[self fileData] mutableCopyWithZone:zone] autorelease]];
+ [newRequest setPostFormat:[self postFormat]];
+ [newRequest setStringEncoding:[self stringEncoding]];
+ [newRequest setRequestMethod:[self requestMethod]];
+ return newRequest;
+}
+
+@synthesize postData;
+@synthesize fileData;
+@synthesize postFormat;
+@synthesize stringEncoding;
+#if DEBUG_FORM_DATA_REQUEST
+@synthesize debugBodyString;
+#endif
+@end
View
830 ExternalSources/asi-http-request/Classes/ASIHTTPRequest.h
@@ -0,0 +1,830 @@
+//
+// ASIHTTPRequest.h
+//
+// Created by Ben Copsey on 04/10/2007.
+// Copyright 2007-2010 All-Seeing Interactive. All rights reserved.
+//
+// A guide to the main features is available at:
+// http://allseeing-i.com/ASIHTTPRequest
+//
+// Portions are based on the ImageClient example from Apple:
+// See: http://developer.apple.com/samplecode/ImageClient/listing37.html
+
+#import <Foundation/Foundation.h>
+#if TARGET_OS_IPHONE
+ #import <CFNetwork/CFNetwork.h>
+#endif
+#import <stdio.h>
+#import "ASIHTTPRequestConfig.h"
+#import "ASIHTTPRequestDelegate.h"
+#import "ASIProgressDelegate.h"
+#import "ASICacheDelegate.h"
+
+extern NSString *ASIHTTPRequestVersion;
+
+// Make targeting different platforms more reliable
+// See: http://www.blumtnwerx.com/blog/2009/06/cross-sdk-code-hygiene-in-xcode/
+#ifndef __IPHONE_3_0
+ #define __IPHONE_3_0 30000
+#endif
+#ifndef __IPHONE_3_2
+ #define __IPHONE_3_2 30200
+#endif
+#ifndef __IPHONE_4_0
+ #define __IPHONE_4_0 40000
+#endif
+#ifndef __MAC_10_5
+ #define __MAC_10_5 1050
+#endif
+#ifndef __MAC_10_6
+ #define __MAC_10_6 1060
+#endif
+
+typedef enum _ASIAuthenticationState {
+ ASINoAuthenticationNeededYet = 0,
+ ASIHTTPAuthenticationNeeded = 1,
+ ASIProxyAuthenticationNeeded = 2
+} ASIAuthenticationState;
+
+typedef enum _ASINetworkErrorType {
+ ASIConnectionFailureErrorType = 1,
+ ASIRequestTimedOutErrorType = 2,
+ ASIAuthenticationErrorType = 3,
+ ASIRequestCancelledErrorType = 4,
+ ASIUnableToCreateRequestErrorType = 5,
+ ASIInternalErrorWhileBuildingRequestType = 6,
+ ASIInternalErrorWhileApplyingCredentialsType = 7,
+ ASIFileManagementError = 8,
+ ASITooMuchRedirectionErrorType = 9,
+ ASIUnhandledExceptionError = 10
+
+} ASINetworkErrorType;
+
+// The error domain that all errors generated by ASIHTTPRequest use
+extern NSString* const NetworkRequestErrorDomain;
+
+// You can use this number to throttle upload and download bandwidth in iPhone OS apps send or receive a large amount of data
+// This may help apps that might otherwise be rejected for inclusion into the app store for using excessive bandwidth
+// This number is not official, as far as I know there is no officially documented bandwidth limit
+extern unsigned long const ASIWWANBandwidthThrottleAmount;
+<