diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.pbxproj b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000000000000000000000000000000..bf1f5da210f64ddcf44617297a44ef665ef1c6f2 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.pbxproj @@ -0,0 +1,668 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 7FA77A706ADB2579D0F321CD /* Pods_GJLocalDigitalDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9463708D551DF8AC78746988 /* Pods_GJLocalDigitalDemo.framework */; }; + A037D5F12B3D0B1800E1AF98 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A037D5F02B3D0B1800E1AF98 /* AVFoundation.framework */; }; + A04821D12B2C48BC005E06BD /* HttpClient.m in Sources */ = {isa = PBXBuildFile; fileRef = A04821CD2B2C48BC005E06BD /* HttpClient.m */; }; + A04821D92B2C49CC005E06BD /* OpenUDID.m in Sources */ = {isa = PBXBuildFile; fileRef = A04821D62B2C49CC005E06BD /* OpenUDID.m */; }; + A04821E42B2C4EC8005E06BD /* SVRadialGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A04821DB2B2C4EC8005E06BD /* SVRadialGradientLayer.m */; }; + A04821E52B2C4EC8005E06BD /* SVProgressAnimatedView.m in Sources */ = {isa = PBXBuildFile; fileRef = A04821DE2B2C4EC8005E06BD /* SVProgressAnimatedView.m */; }; + A04821E62B2C4EC8005E06BD /* SVProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = A04821E02B2C4EC8005E06BD /* SVProgressHUD.m */; }; + A04821E72B2C4EC8005E06BD /* SVIndefiniteAnimatedView.m in Sources */ = {isa = PBXBuildFile; fileRef = A04821E12B2C4EC8005E06BD /* SVIndefiniteAnimatedView.m */; }; + A04821E82B2C4EC8005E06BD /* SVProgressHUD.bundle in Resources */ = {isa = PBXBuildFile; fileRef = A04821E22B2C4EC8005E06BD /* SVProgressHUD.bundle */; }; + A04821F12B2C5650005E06BD /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A04821E92B2C5429005E06BD /* Security.framework */; }; + A04821F42B2C5695005E06BD /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A04821EF2B2C5608005E06BD /* libz.tbd */; }; + A04822222B2C5FF6005E06BD /* GJCheckNetwork.m in Sources */ = {isa = PBXBuildFile; fileRef = A04822212B2C5FF6005E06BD /* GJCheckNetwork.m */; }; + A0B1C4262B299D66009E0716 /* GJLocalDigitalSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A0FC3DBE2B282FC70069EA0E /* GJLocalDigitalSDK.framework */; }; + A0B1C4272B299D66009E0716 /* GJLocalDigitalSDK.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = A0FC3DBE2B282FC70069EA0E /* GJLocalDigitalSDK.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + A0B1C4362B29C1F2009E0716 /* 1.wav in Resources */ = {isa = PBXBuildFile; fileRef = A0B1C4352B29C1F2009E0716 /* 1.wav */; }; + A0BB09402B3C34A700BF0CC1 /* GJLDigitalAnswerModel.m in Sources */ = {isa = PBXBuildFile; fileRef = A0BB093F2B3C34A700BF0CC1 /* GJLDigitalAnswerModel.m */; }; + A0BB09432B3C34B800BF0CC1 /* GJDownWavTool.m in Sources */ = {isa = PBXBuildFile; fileRef = A0BB09422B3C34B800BF0CC1 /* GJDownWavTool.m */; }; + A0D3B8A52B3D740500983153 /* GYAccess.m in Sources */ = {isa = PBXBuildFile; fileRef = A0D3B8A42B3D740500983153 /* GYAccess.m */; }; + A0D81D9B2B299568002F98C1 /* bg2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = A0D81D9A2B299568002F98C1 /* bg2.jpg */; }; + A0F908C32B32E97500962346 /* 2.wav in Resources */ = {isa = PBXBuildFile; fileRef = A0F908C02B32E97500962346 /* 2.wav */; }; + A0F908C42B32E97500962346 /* 3.wav in Resources */ = {isa = PBXBuildFile; fileRef = A0F908C22B32E97500962346 /* 3.wav */; }; + A0FC3DA02B282F1B0069EA0E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A0FC3D9F2B282F1B0069EA0E /* AppDelegate.m */; }; + A0FC3DA62B282F1B0069EA0E /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = A0FC3DA52B282F1B0069EA0E /* ViewController.mm */; }; + A0FC3DA92B282F1B0069EA0E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A0FC3DA72B282F1B0069EA0E /* Main.storyboard */; }; + A0FC3DAB2B282F1D0069EA0E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A0FC3DAA2B282F1D0069EA0E /* Assets.xcassets */; }; + A0FC3DAE2B282F1D0069EA0E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A0FC3DAC2B282F1D0069EA0E /* LaunchScreen.storyboard */; }; + A0FC3DB12B282F1D0069EA0E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A0FC3DB02B282F1D0069EA0E /* main.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + A0FC3DBD2B282FC70069EA0E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = A0FC3DB92B282FC70069EA0E /* GJLocalDigitalSDK.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = A0FC3D822B282DC40069EA0E; + remoteInfo = GJLocalDigitalSDK; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + A0B1C4282B299D66009E0716 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + A0B1C4272B299D66009E0716 /* GJLocalDigitalSDK.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 9463708D551DF8AC78746988 /* Pods_GJLocalDigitalDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GJLocalDigitalDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + A037D5F02B3D0B1800E1AF98 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; + A04821CD2B2C48BC005E06BD /* HttpClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HttpClient.m; sourceTree = ""; }; + A04821CF2B2C48BC005E06BD /* HttpClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpClient.h; sourceTree = ""; }; + A04821D62B2C49CC005E06BD /* OpenUDID.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OpenUDID.m; sourceTree = ""; }; + A04821D72B2C49CC005E06BD /* OpenUDID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenUDID.h; sourceTree = ""; }; + A04821DB2B2C4EC8005E06BD /* SVRadialGradientLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVRadialGradientLayer.m; sourceTree = ""; }; + A04821DC2B2C4EC8005E06BD /* SVIndefiniteAnimatedView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVIndefiniteAnimatedView.h; sourceTree = ""; }; + A04821DD2B2C4EC8005E06BD /* SVProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVProgressHUD.h; sourceTree = ""; }; + A04821DE2B2C4EC8005E06BD /* SVProgressAnimatedView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVProgressAnimatedView.m; sourceTree = ""; }; + A04821DF2B2C4EC8005E06BD /* SVRadialGradientLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVRadialGradientLayer.h; sourceTree = ""; }; + A04821E02B2C4EC8005E06BD /* SVProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVProgressHUD.m; sourceTree = ""; }; + A04821E12B2C4EC8005E06BD /* SVIndefiniteAnimatedView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVIndefiniteAnimatedView.m; sourceTree = ""; }; + A04821E22B2C4EC8005E06BD /* SVProgressHUD.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = SVProgressHUD.bundle; sourceTree = ""; }; + A04821E32B2C4EC8005E06BD /* SVProgressAnimatedView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVProgressAnimatedView.h; sourceTree = ""; }; + A04821E92B2C5429005E06BD /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + A04821EB2B2C5508005E06BD /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + A04821ED2B2C550D005E06BD /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + A04821EF2B2C5608005E06BD /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; + A04821F22B2C567E005E06BD /* libz.1.2.8.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.1.2.8.tbd; path = usr/lib/libz.1.2.8.tbd; sourceTree = SDKROOT; }; + A04822202B2C5FF6005E06BD /* GJCheckNetwork.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GJCheckNetwork.h; sourceTree = ""; }; + A04822212B2C5FF6005E06BD /* GJCheckNetwork.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GJCheckNetwork.m; sourceTree = ""; }; + A0B1C4352B29C1F2009E0716 /* 1.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = 1.wav; sourceTree = ""; }; + A0BB093E2B3C34A700BF0CC1 /* GJLDigitalAnswerModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GJLDigitalAnswerModel.h; sourceTree = ""; }; + A0BB093F2B3C34A700BF0CC1 /* GJLDigitalAnswerModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GJLDigitalAnswerModel.m; sourceTree = ""; }; + A0BB09412B3C34B800BF0CC1 /* GJDownWavTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GJDownWavTool.h; sourceTree = ""; }; + A0BB09422B3C34B800BF0CC1 /* GJDownWavTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GJDownWavTool.m; sourceTree = ""; }; + A0D3B8A32B3D740500983153 /* GYAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GYAccess.h; sourceTree = ""; }; + A0D3B8A42B3D740500983153 /* GYAccess.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GYAccess.m; sourceTree = ""; }; + A0D81D6D2B298F7A002F98C1 /* GJLocalDigitalSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GJLocalDigitalSDK.framework; path = "../../Library/Developer/Xcode/DerivedData/GJLocalDigitalDemo-gebpkaexfkvglzatozdgkldxlnvo/Build/Products/Debug-iphoneos/GJLocalDigitalSDK.framework"; sourceTree = ""; }; + A0D81D7F2B29915D002F98C1 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; }; + A0D81D852B2992AD002F98C1 /* opencv2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = opencv2.framework; path = ../GJLocalDigitalSDK/GJLocalDigitalSDK/GJFrameWork/opencv2.framework; sourceTree = ""; }; + A0D81D892B2992B2002F98C1 /* ncnn.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ncnn.framework; path = ../GJLocalDigitalSDK/GJLocalDigitalSDK/GJFrameWork/ncnn.framework; sourceTree = ""; }; + A0D81D8C2B2992B4002F98C1 /* openmp.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = openmp.framework; path = ../GJLocalDigitalSDK/GJLocalDigitalSDK/GJFrameWork/openmp.framework; sourceTree = ""; }; + A0D81D8F2B2992C1002F98C1 /* onnxruntime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = onnxruntime.framework; path = ../GJLocalDigitalSDK/GJLocalDigitalSDK/GJFrameWork/onnxruntime.framework; sourceTree = ""; }; + A0D81D9A2B299568002F98C1 /* bg2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = bg2.jpg; sourceTree = ""; }; + A0F908C02B32E97500962346 /* 2.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = 2.wav; sourceTree = ""; }; + A0F908C22B32E97500962346 /* 3.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = 3.wav; sourceTree = ""; }; + A0FC3D9B2B282F1B0069EA0E /* GJLocalDigitalDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GJLocalDigitalDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + A0FC3D9E2B282F1B0069EA0E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + A0FC3D9F2B282F1B0069EA0E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + A0FC3DA42B282F1B0069EA0E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + A0FC3DA52B282F1B0069EA0E /* ViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ViewController.mm; sourceTree = ""; }; + A0FC3DA82B282F1B0069EA0E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + A0FC3DAA2B282F1D0069EA0E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + A0FC3DAD2B282F1D0069EA0E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + A0FC3DAF2B282F1D0069EA0E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A0FC3DB02B282F1D0069EA0E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + A0FC3DB92B282FC70069EA0E /* GJLocalDigitalSDK.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GJLocalDigitalSDK.xcodeproj; path = ../GJLocalDigitalSDK/GJLocalDigitalSDK.xcodeproj; sourceTree = ""; }; + A0FC3EAE2B2855AC0069EA0E /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; + CC0F95EC41CD11CE487F313E /* Pods-GJLocalDigitalDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GJLocalDigitalDemo.release.xcconfig"; path = "Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.release.xcconfig"; sourceTree = ""; }; + CDE763B79F6CA6E21DE1F3CE /* Pods-GJLocalDigitalDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GJLocalDigitalDemo.debug.xcconfig"; path = "Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A0FC3D982B282F1B0069EA0E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A037D5F12B3D0B1800E1AF98 /* AVFoundation.framework in Frameworks */, + A04821F42B2C5695005E06BD /* libz.tbd in Frameworks */, + A04821F12B2C5650005E06BD /* Security.framework in Frameworks */, + A0B1C4262B299D66009E0716 /* GJLocalDigitalSDK.framework in Frameworks */, + 7FA77A706ADB2579D0F321CD /* Pods_GJLocalDigitalDemo.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + A04821CC2B2C48BC005E06BD /* HttpClient */ = { + isa = PBXGroup; + children = ( + A04821CF2B2C48BC005E06BD /* HttpClient.h */, + A04821CD2B2C48BC005E06BD /* HttpClient.m */, + ); + path = HttpClient; + sourceTree = ""; + }; + A04821D52B2C49CC005E06BD /* OpenUDID-master */ = { + isa = PBXGroup; + children = ( + A04821D62B2C49CC005E06BD /* OpenUDID.m */, + A04821D72B2C49CC005E06BD /* OpenUDID.h */, + ); + path = "OpenUDID-master"; + sourceTree = ""; + }; + A04821DA2B2C4EC8005E06BD /* SVProgressHUD */ = { + isa = PBXGroup; + children = ( + A04821DB2B2C4EC8005E06BD /* SVRadialGradientLayer.m */, + A04821DC2B2C4EC8005E06BD /* SVIndefiniteAnimatedView.h */, + A04821DD2B2C4EC8005E06BD /* SVProgressHUD.h */, + A04821DE2B2C4EC8005E06BD /* SVProgressAnimatedView.m */, + A04821DF2B2C4EC8005E06BD /* SVRadialGradientLayer.h */, + A04821E02B2C4EC8005E06BD /* SVProgressHUD.m */, + A04821E12B2C4EC8005E06BD /* SVIndefiniteAnimatedView.m */, + A04821E22B2C4EC8005E06BD /* SVProgressHUD.bundle */, + A04821E32B2C4EC8005E06BD /* SVProgressAnimatedView.h */, + ); + path = SVProgressHUD; + sourceTree = ""; + }; + A048221F2B2C5FF6005E06BD /* GJCheckNetwork */ = { + isa = PBXGroup; + children = ( + A04822202B2C5FF6005E06BD /* GJCheckNetwork.h */, + A04822212B2C5FF6005E06BD /* GJCheckNetwork.m */, + ); + path = GJCheckNetwork; + sourceTree = ""; + }; + A0BB093D2B3C34A700BF0CC1 /* DigitalAnswerModel */ = { + isa = PBXGroup; + children = ( + A0BB093E2B3C34A700BF0CC1 /* GJLDigitalAnswerModel.h */, + A0BB093F2B3C34A700BF0CC1 /* GJLDigitalAnswerModel.m */, + A0BB09412B3C34B800BF0CC1 /* GJDownWavTool.h */, + A0BB09422B3C34B800BF0CC1 /* GJDownWavTool.m */, + ); + path = DigitalAnswerModel; + sourceTree = ""; + }; + A0D3B8A22B3D740500983153 /* GYAccess */ = { + isa = PBXGroup; + children = ( + A0D3B8A32B3D740500983153 /* GYAccess.h */, + A0D3B8A42B3D740500983153 /* GYAccess.m */, + ); + path = GYAccess; + sourceTree = ""; + }; + A0D81D992B299558002F98C1 /* Resources */ = { + isa = PBXGroup; + children = ( + A0B1C4352B29C1F2009E0716 /* 1.wav */, + A0F908C02B32E97500962346 /* 2.wav */, + A0F908C22B32E97500962346 /* 3.wav */, + A0D81D9A2B299568002F98C1 /* bg2.jpg */, + ); + path = Resources; + sourceTree = ""; + }; + A0FC3D922B282F1B0069EA0E = { + isa = PBXGroup; + children = ( + A0FC3DB92B282FC70069EA0E /* GJLocalDigitalSDK.xcodeproj */, + A0FC3D9D2B282F1B0069EA0E /* GJLocalDigitalDemo */, + A0FC3D9C2B282F1B0069EA0E /* Products */, + A0FC3EAC2B2855AC0069EA0E /* Frameworks */, + ECE2CDAA117EDC79BA8F9D60 /* Pods */, + ); + sourceTree = ""; + }; + A0FC3D9C2B282F1B0069EA0E /* Products */ = { + isa = PBXGroup; + children = ( + A0FC3D9B2B282F1B0069EA0E /* GJLocalDigitalDemo.app */, + ); + name = Products; + sourceTree = ""; + }; + A0FC3D9D2B282F1B0069EA0E /* GJLocalDigitalDemo */ = { + isa = PBXGroup; + children = ( + A0D3B8A22B3D740500983153 /* GYAccess */, + A0BB093D2B3C34A700BF0CC1 /* DigitalAnswerModel */, + A048221F2B2C5FF6005E06BD /* GJCheckNetwork */, + A04821DA2B2C4EC8005E06BD /* SVProgressHUD */, + A04821D52B2C49CC005E06BD /* OpenUDID-master */, + A04821CC2B2C48BC005E06BD /* HttpClient */, + A0D81D992B299558002F98C1 /* Resources */, + A0FC3D9E2B282F1B0069EA0E /* AppDelegate.h */, + A0FC3D9F2B282F1B0069EA0E /* AppDelegate.m */, + A0FC3DA42B282F1B0069EA0E /* ViewController.h */, + A0FC3DA52B282F1B0069EA0E /* ViewController.mm */, + A0FC3DA72B282F1B0069EA0E /* Main.storyboard */, + A0FC3DAA2B282F1D0069EA0E /* Assets.xcassets */, + A0FC3DAC2B282F1D0069EA0E /* LaunchScreen.storyboard */, + A0FC3DAF2B282F1D0069EA0E /* Info.plist */, + A0FC3DB02B282F1D0069EA0E /* main.m */, + ); + path = GJLocalDigitalDemo; + sourceTree = ""; + }; + A0FC3DBA2B282FC70069EA0E /* Products */ = { + isa = PBXGroup; + children = ( + A0FC3DBE2B282FC70069EA0E /* GJLocalDigitalSDK.framework */, + ); + name = Products; + sourceTree = ""; + }; + A0FC3EAC2B2855AC0069EA0E /* Frameworks */ = { + isa = PBXGroup; + children = ( + A037D5F02B3D0B1800E1AF98 /* AVFoundation.framework */, + A04821F22B2C567E005E06BD /* libz.1.2.8.tbd */, + A04821EF2B2C5608005E06BD /* libz.tbd */, + A04821ED2B2C550D005E06BD /* Foundation.framework */, + A04821EB2B2C5508005E06BD /* UIKit.framework */, + A04821E92B2C5429005E06BD /* Security.framework */, + A0D81D8F2B2992C1002F98C1 /* onnxruntime.framework */, + A0D81D8C2B2992B4002F98C1 /* openmp.framework */, + A0D81D892B2992B2002F98C1 /* ncnn.framework */, + A0D81D852B2992AD002F98C1 /* opencv2.framework */, + A0D81D7F2B29915D002F98C1 /* Metal.framework */, + A0D81D6D2B298F7A002F98C1 /* GJLocalDigitalSDK.framework */, + A0FC3EAE2B2855AC0069EA0E /* MetalKit.framework */, + 9463708D551DF8AC78746988 /* Pods_GJLocalDigitalDemo.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + ECE2CDAA117EDC79BA8F9D60 /* Pods */ = { + isa = PBXGroup; + children = ( + CDE763B79F6CA6E21DE1F3CE /* Pods-GJLocalDigitalDemo.debug.xcconfig */, + CC0F95EC41CD11CE487F313E /* Pods-GJLocalDigitalDemo.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + A0FC3D9A2B282F1B0069EA0E /* GJLocalDigitalDemo */ = { + isa = PBXNativeTarget; + buildConfigurationList = A0FC3DB42B282F1D0069EA0E /* Build configuration list for PBXNativeTarget "GJLocalDigitalDemo" */; + buildPhases = ( + 520A0B9D7BC7E31018FF2800 /* [CP] Check Pods Manifest.lock */, + A0FC3D972B282F1B0069EA0E /* Sources */, + A0FC3D982B282F1B0069EA0E /* Frameworks */, + A0FC3D992B282F1B0069EA0E /* Resources */, + A0B1C4282B299D66009E0716 /* Embed Frameworks */, + AEFFC1C636473627C8C0E111 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = GJLocalDigitalDemo; + productName = GJLocalDigitalDemo; + productReference = A0FC3D9B2B282F1B0069EA0E /* GJLocalDigitalDemo.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + A0FC3D932B282F1B0069EA0E /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastUpgradeCheck = 1500; + TargetAttributes = { + A0FC3D9A2B282F1B0069EA0E = { + CreatedOnToolsVersion = 15.0.1; + }; + }; + }; + buildConfigurationList = A0FC3D962B282F1B0069EA0E /* Build configuration list for PBXProject "GJLocalDigitalDemo" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = A0FC3D922B282F1B0069EA0E; + productRefGroup = A0FC3D9C2B282F1B0069EA0E /* Products */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = A0FC3DBA2B282FC70069EA0E /* Products */; + ProjectRef = A0FC3DB92B282FC70069EA0E /* GJLocalDigitalSDK.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + A0FC3D9A2B282F1B0069EA0E /* GJLocalDigitalDemo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + A0FC3DBE2B282FC70069EA0E /* GJLocalDigitalSDK.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = GJLocalDigitalSDK.framework; + remoteRef = A0FC3DBD2B282FC70069EA0E /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + A0FC3D992B282F1B0069EA0E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A0B1C4362B29C1F2009E0716 /* 1.wav in Resources */, + A0FC3DAE2B282F1D0069EA0E /* LaunchScreen.storyboard in Resources */, + A0D81D9B2B299568002F98C1 /* bg2.jpg in Resources */, + A04821E82B2C4EC8005E06BD /* SVProgressHUD.bundle in Resources */, + A0F908C42B32E97500962346 /* 3.wav in Resources */, + A0F908C32B32E97500962346 /* 2.wav in Resources */, + A0FC3DAB2B282F1D0069EA0E /* Assets.xcassets in Resources */, + A0FC3DA92B282F1B0069EA0E /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 520A0B9D7BC7E31018FF2800 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-GJLocalDigitalDemo-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + AEFFC1C636473627C8C0E111 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + A0FC3D972B282F1B0069EA0E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A04821E42B2C4EC8005E06BD /* SVRadialGradientLayer.m in Sources */, + A0FC3DA62B282F1B0069EA0E /* ViewController.mm in Sources */, + A0BB09402B3C34A700BF0CC1 /* GJLDigitalAnswerModel.m in Sources */, + A0FC3DA02B282F1B0069EA0E /* AppDelegate.m in Sources */, + A04821D12B2C48BC005E06BD /* HttpClient.m in Sources */, + A04821D92B2C49CC005E06BD /* OpenUDID.m in Sources */, + A04821E72B2C4EC8005E06BD /* SVIndefiniteAnimatedView.m in Sources */, + A0BB09432B3C34B800BF0CC1 /* GJDownWavTool.m in Sources */, + A0D3B8A52B3D740500983153 /* GYAccess.m in Sources */, + A04821E62B2C4EC8005E06BD /* SVProgressHUD.m in Sources */, + A04822222B2C5FF6005E06BD /* GJCheckNetwork.m in Sources */, + A0FC3DB12B282F1D0069EA0E /* main.m in Sources */, + A04821E52B2C4EC8005E06BD /* SVProgressAnimatedView.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + A0FC3DA72B282F1B0069EA0E /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + A0FC3DA82B282F1B0069EA0E /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + A0FC3DAC2B282F1D0069EA0E /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + A0FC3DAD2B282F1D0069EA0E /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + A0FC3DB22B282F1D0069EA0E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + A0FC3DB32B282F1D0069EA0E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + A0FC3DB52B282F1D0069EA0E /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = CDE763B79F6CA6E21DE1F3CE /* Pods-GJLocalDigitalDemo.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = RHWTKM535Q; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/GJLocalDigitalDemo"; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = GJLocalDigitalDemo/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = SDKDemo1.0.2; + INFOPLIST_KEY_NSMicrophoneUsageDescription = "需要录音权限来语音识别"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.1; + OTHER_LDFLAGS = "$(inherited)"; + PRODUCT_BUNDLE_IDENTIFIER = com.wanruyi.sdkdemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + A0FC3DB62B282F1D0069EA0E /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = CC0F95EC41CD11CE487F313E /* Pods-GJLocalDigitalDemo.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = RHWTKM535Q; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/GJLocalDigitalDemo"; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = GJLocalDigitalDemo/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = SDKDemo1.0.2; + INFOPLIST_KEY_NSMicrophoneUsageDescription = "需要录音权限来语音识别"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.1; + OTHER_LDFLAGS = "$(inherited)"; + PRODUCT_BUNDLE_IDENTIFIER = com.wanruyi.sdkdemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + A0FC3D962B282F1B0069EA0E /* Build configuration list for PBXProject "GJLocalDigitalDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A0FC3DB22B282F1D0069EA0E /* Debug */, + A0FC3DB32B282F1D0069EA0E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A0FC3DB42B282F1D0069EA0E /* Build configuration list for PBXNativeTarget "GJLocalDigitalDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A0FC3DB52B282F1D0069EA0E /* Debug */, + A0FC3DB62B282F1D0069EA0E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = A0FC3D932B282F1B0069EA0E /* Project object */; +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000000000000000000000000000000000..919434a6254f0e9651f402737811be6634a03e9c --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000000000000000000000000000000000..18d981003d68d0546c4804ac2ff47dd97c6e7921 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/xcshareddata/xcschemes/GJLocalDigitalDemo.xcscheme b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/xcshareddata/xcschemes/GJLocalDigitalDemo.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..3e7cd05e069d85d47845a1455dbfc6945ad3b2de --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcodeproj/xcshareddata/xcschemes/GJLocalDigitalDemo.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/contents.xcworkspacedata b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000000000000000000000000000000000..e2805fd6aaed17312ea939a44467be9b7e623de4 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000000000000000000000000000000000..18d981003d68d0546c4804ac2ff47dd97c6e7921 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcuserdata/guiji.xcuserdatad/UserInterfaceState.xcuserstate b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcuserdata/guiji.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..9249142daed2cb976d92bca1d97244caf6b90f5e Binary files /dev/null and b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcuserdata/guiji.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcuserdata/guiji.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcuserdata/guiji.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000000000000000000000000000000000000..5e89f2beb19bc089d54d440fc205d88b54d4f0f4 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo.xcworkspace/xcuserdata/guiji.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/GJLocalDigitalSDK b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/GJLocalDigitalSDK new file mode 100644 index 0000000000000000000000000000000000000000..8f188055958245cbda122940e98be79e533dee28 Binary files /dev/null and b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/GJLocalDigitalSDK differ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Headers/GJLDigitalManager.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Headers/GJLDigitalManager.h new file mode 100644 index 0000000000000000000000000000000000000000..2f02b0aa041f1275566a2c36c995df07012eb383 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Headers/GJLDigitalManager.h @@ -0,0 +1,51 @@ +// +// GJLDigitalManager.h +// GJLocalDigitalSDK +// +// Created by guiji on 2023/12/12. +// + +#import +#import + +@interface GJLDigitalManager : NSObject +//本地数字人模型下的最大帧数 +@property (nonatomic, assign)NSInteger maxCount; + ++ (GJLDigitalManager*)manager; +/* + *basePath 底层通用模型路径-保持不变 + *digitalPath 数字人模型路径- 替换数字人只需要替换这个路径 + *return 1 返回成功 -1 基本模型路径错误 -2 基本模型路径错误 -3 数字人模型路径错误 -4 数字人模型路径错误 -5数字人模型配置文件错误 + */ +-(NSInteger)initBaseModel:(NSString*)basePath digitalModel:(NSString*)digitalPath; +/* + 显示界面 + */ +-(void)toShow:(UIView*)view; +/* + *playImageIndex 播放数字人画面到第几帧 + *audioIndex 播放音频到第几帧 + *bbgPath 数字人背景-可替换 + */ +-(void)toPlayNext:(NSInteger)playImageIndex audioIndex:(NSInteger)audioIndex bbgPath:(NSString*)bbgPath; +/* + wavPath 音频的本地路径 + */ +-(void)onewavWithPath:(NSString*)wavPath; +/* +音频播放结束调用 + */ +-(void)toWavPlayEnd; +/* + 释放 + */ +-(void)toFree; +/* + 初始化模型过后才能获取 + getDigitalSize 数字人模型的宽度 数字人模型的高度 +*/ +-(CGSize)getDigitalSize; +@end + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Headers/GJLocalDigitalSDK.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Headers/GJLocalDigitalSDK.h new file mode 100644 index 0000000000000000000000000000000000000000..f6010a12ceac482900ee0ea2a9962d0fac8ab948 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Headers/GJLocalDigitalSDK.h @@ -0,0 +1,19 @@ +// +// GJLocalDigitalSDK.h +// GJLocalDigitalSDK +// +// Created by guiji on 2023/12/12. +// + +#import + +//! Project version number for GJLocalDigitalSDK. +FOUNDATION_EXPORT double GJLocalDigitalSDKVersionNumber; + +//! Project version string for GJLocalDigitalSDK. +FOUNDATION_EXPORT const unsigned char GJLocalDigitalSDKVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + +#import + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Info.plist b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..2d7984902cf8bf11ab7a14995969e3f574acca6d Binary files /dev/null and b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Info.plist differ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Modules/module.modulemap b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Modules/module.modulemap new file mode 100644 index 0000000000000000000000000000000000000000..86f280142f109d512317aa41c89783b1fab5b637 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module GJLocalDigitalSDK { + umbrella header "GJLocalDigitalSDK.h" + export * + + module * { export * } +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/_CodeSignature/CodeResources b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/_CodeSignature/CodeResources new file mode 100644 index 0000000000000000000000000000000000000000..c1c036a120a2b3aa7ba632f9ea3ee10de25e4527 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.framework/_CodeSignature/CodeResources @@ -0,0 +1,135 @@ + + + + + files + + Headers/GJLDigitalManager.h + + 5uaZHkukbAcZpPsq+CzQtyCQUUE= + + Headers/GJLocalDigitalSDK.h + + 3rBnLcGNU++wbCXGPIzZGr3dZrs= + + Info.plist + + Vpt2kAslfkyJxCgTSAZhn7z4BpQ= + + Modules/module.modulemap + + ypoW1ByUmKNew8insDYa6LlBgks= + + + files2 + + Headers/GJLDigitalManager.h + + hash2 + + qQWHeaapKyJwJFHjW5RmhNLTpCfUDu+Y0ifCqQ4qTxY= + + + Headers/GJLocalDigitalSDK.h + + hash2 + + H/1XlUfF+cVfaXPWADLRF7ypkwcM+3R5XcQy/Iup3mU= + + + Modules/module.modulemap + + hash2 + + UQmfiVmcinF15NRuEvyVP1de+1M7FRLzO2cPbsIhj+Y= + + + + rules + + ^.* + + ^.*\.lproj/ + + optional + + weight + 1000 + + ^.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^.* + + ^.*\.lproj/ + + optional + + weight + 1000 + + ^.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Base\.lproj/ + + weight + 1010 + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.md b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.md new file mode 100644 index 0000000000000000000000000000000000000000..b809bcd1824c888fd26497b98717fbfa12d031f8 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalSDK.md @@ -0,0 +1,181 @@ +## 硅基本地版DUIX SDK使⽤⽂档 (1.0.3) +##两个人物模型(切换男女形象,修改./GJLocalDigitalDemo/GJLocalDigitalDemo/GJLocalDigitalDemo/ViewController.mm的DIGITALMODELURL变量即可) +``` + 女:https://cdn.guiji.ai/duix/digital/model/1712034391673/bendi1_0329.zip + 男:https://digital-public.obs.cn-east-3.myhuaweicloud.com/duix/digital/model/1706009711636/liangwei_540s.zip +``` +### 开发环境 +开发⼯具: Xcode  ios12.0以上 iphoneX及以上 + +## 快速开始 +``` + + NSString *basePath =[NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] bundlePath],@"gj_dh_res"]; + NSString *digitalPath =[NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] bundlePath],@"lixin_a_540s"]; + + //初始化 + NSInteger result= [[GJLDigitalManager manager] initBaseModel:basePath digitalModel:digitalPath showView:weakSelf.showView]; + if(result==1) + { + //开始 + [[GJLDigitalManager manager] toStart:^(BOOL isSuccess, NSString *errorMsg) { + if(!isSuccess) + { + [SVProgressHUD showInfoWithStatus:errorMsg]; + } + }]; + } + +``` +## 调用流程 +``` +1. 启动服务前需要准备好同步数字人需要的基础配置和模型文件。 +2. 初始化数字人渲染服务。 +3. 调用toStart函数开始渲染数字人 +4. 调用toSpeakWithPath函数驱动数字人播报。 +5. 调用cancelAudioPlay函数可以主动停止播报。 +6. 调用toStop结束并释放数字人渲染 +``` + +### SDK回调 + +``` +/* +*数字人渲染报错回调 +*0 未授权 -1未初始化 50009资源超时或未配置 +*/ +@property (nonatomic, copy) void (^playFailed)(NSInteger code,NSString *errorMsg); + +/* +*音频播放结束回调 +*/ +@property (nonatomic, copy) void (^audioPlayEnd)(void); + +/* +*音频播放进度回调 +/ +@property (nonatomic, copy) void (^audioPlayProgress)(float current,float total); +``` + +## 方法 + +### 初始化 + +``` +/* +*basePath 底层通用模型路径-保持不变 +*digitalPath 数字人模型路径- 替换数字人只需要替换这个路径 +*return 1 返回成功 0未授权 -1 初始化失败 +*showView 显示界面 +*/ +-(NSInteger)initBaseModel:(NSString*)basePath digitalModel:(NSString*)digitalPath showView:(UIView*)showView; +``` + +### 替换背景 + +``` +/* +* bbgPath 替换背景 +* 注意: -jpg格式 ----背景size等于数字人模型的getDigitalSize----------- +*/ +-(void)toChangeBBGWithPath:(NSString*)bbgPath; +``` + +### 播放音频 + +``` +/* +*wavPath 音频的本地路径  +*/ +-(void)toSpeakWithPath:(NSString*)wavPath; +``` + +### 开始渲染数字人 + +``` +/* +*开始 +*/ +-(void)toStart:(void (^) (BOOL isSuccess, NSString *errorMsg))block; +``` + +### 结束渲染数字人并释放 +``` +/* +*结束 +*/ +-(void)toStop; +``` + +### 数字人模型的宽度高度 + +``` +/* +*初始化模型过后才能获取 +*getDigitalSize 数字人模型的宽度 数字人模型的高度 +*/ +-(CGSize)getDigitalSize; +``` + +### 取消播放音频 + +``` +/* +*取消播放音频 +*/ +-(void)cancelAudioPlay; +``` + + + + +## 动作 + +### 随机动作 + +``` +/* +* 开始动作前调用 +* 随机动作(一段文字包含多个音频,建议第一个音频开始时设置随机动作) +* return 0 数字人模型不支持随机动作 1 数字人模型支持随机动作 +*/ +-(NSInteger)toRandomMotion; +``` + +### 开始动作 + +``` +/* +* 开始动作 (一段文字包含多个音频,第一个音频开始时设置) +* return 0 数字人模型不支持开始动作 1 数字人模型支持开始动作 +*/ +-(NSInteger)toStartMotion; +``` + +### 结束动作 +``` +/* +* 结束动作 (一段文字包含多个音频,最后一个音频播放结束时设置) +*isQuickly YES 立即结束动作 NO 等待动作播放完成再静默 +*return 0 数字人模型不支持结束动作 1 数字人模型支持结束动作 +*/ +-(NSInteger)toSopMotion:(BOOL)isQuickly; +``` + +### 暂停后开始播放数字人 +``` +/* +*暂停后才需执行播放数字人 +*/ +-(void)toPlay; +``` + +### 暂停数字人播放 +``` +/* +*暂停数字人播放 +*/ +-(void)toPause; +``` + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Podfile b/GJLocalDigitalDemo/GJLocalDigitalDemo/Podfile new file mode 100644 index 0000000000000000000000000000000000000000..b8e60828d7cbdd88e2f26b08634c0dc41ebd6b11 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Podfile @@ -0,0 +1,31 @@ +# Uncomment the next line to define a global platform for your project +# platform :ios, '9.0' +post_install do |installer| + installer.generated_projects.each do |project| + project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0' + end + end + end + project_path = "GJLocalDigitalDemo.xcodeproj" + project = Xcodeproj::Project.open(project_path) + project.targets.each do |target| + shell_script_path = "Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-"+target.name+"-frameworks.sh" + shell_script_input_lines = File.readlines(shell_script_path) + shell_script_output_lines = shell_script_input_lines.map { |line| line.sub("source=\"$(readlink \"${source}\")\"", "source=\"$(readlink -f \"${source}\")\"") } + File.open(shell_script_path, 'w') do |f| + shell_script_output_lines.each do |line| + f.write line + end + end + end +end +target 'GJLocalDigitalDemo' do + # Comment the next line if you don't want to use dynamic frameworks + use_frameworks! + pod 'AFNetworking' + pod 'SSZipArchive' + # Pods for GJLocalDigitalDemo + +end diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Podfile.lock b/GJLocalDigitalDemo/GJLocalDigitalDemo/Podfile.lock new file mode 100644 index 0000000000000000000000000000000000000000..d30ede851e1cbfcf5c2910f3df4c76413d5b59d4 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Podfile.lock @@ -0,0 +1,34 @@ +PODS: + - AFNetworking (4.0.1): + - AFNetworking/NSURLSession (= 4.0.1) + - AFNetworking/Reachability (= 4.0.1) + - AFNetworking/Security (= 4.0.1) + - AFNetworking/Serialization (= 4.0.1) + - AFNetworking/UIKit (= 4.0.1) + - AFNetworking/NSURLSession (4.0.1): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (4.0.1) + - AFNetworking/Security (4.0.1) + - AFNetworking/Serialization (4.0.1) + - AFNetworking/UIKit (4.0.1): + - AFNetworking/NSURLSession + - SSZipArchive (2.4.3) + +DEPENDENCIES: + - AFNetworking + - SSZipArchive + +SPEC REPOS: + trunk: + - AFNetworking + - SSZipArchive + +SPEC CHECKSUMS: + AFNetworking: 3bd23d814e976cd148d7d44c3ab78017b744cd58 + SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef + +PODFILE CHECKSUM: 2206843f5bf8d13c4bb6ed97fc38d3ba27152b2e + +COCOAPODS: 1.14.3 diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFCompatibilityMacros.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFCompatibilityMacros.h new file mode 100644 index 0000000000000000000000000000000000000000..1f0ab26d98769de4e635d32ba455df3b458b9013 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFCompatibilityMacros.h @@ -0,0 +1,49 @@ +// AFCompatibilityMacros.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#ifndef AFCompatibilityMacros_h +#define AFCompatibilityMacros_h + +#ifdef API_AVAILABLE + #define AF_API_AVAILABLE(...) API_AVAILABLE(__VA_ARGS__) +#else + #define AF_API_AVAILABLE(...) +#endif // API_AVAILABLE + +#ifdef API_UNAVAILABLE + #define AF_API_UNAVAILABLE(...) API_UNAVAILABLE(__VA_ARGS__) +#else + #define AF_API_UNAVAILABLE(...) +#endif // API_UNAVAILABLE + +#if __has_warning("-Wunguarded-availability-new") + #define AF_CAN_USE_AT_AVAILABLE 1 +#else + #define AF_CAN_USE_AT_AVAILABLE 0 +#endif + +#if ((__IPHONE_OS_VERSION_MAX_ALLOWED && __IPHONE_OS_VERSION_MAX_ALLOWED < 100000) || (__MAC_OS_VERSION_MAX_ALLOWED && __MAC_OS_VERSION_MAX_ALLOWED < 101200) ||(__WATCH_OS_MAX_VERSION_ALLOWED && __WATCH_OS_MAX_VERSION_ALLOWED < 30000) ||(__TV_OS_MAX_VERSION_ALLOWED && __TV_OS_MAX_VERSION_ALLOWED < 100000)) + #define AF_CAN_INCLUDE_SESSION_TASK_METRICS 0 +#else + #define AF_CAN_INCLUDE_SESSION_TASK_METRICS 1 +#endif + +#endif /* AFCompatibilityMacros_h */ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h new file mode 100644 index 0000000000000000000000000000000000000000..943fc22df0a2d4da6ad5bdfe12a9d2170731d86a --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1,285 @@ +// AFHTTPSessionManager.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#if !TARGET_OS_WATCH +#import +#endif +#import + +#import "AFURLSessionManager.h" + +/** + `AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths. + + ## Subclassing Notes + + Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application. + + ## Methods to Override + + To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler:`. + + ## Serialization + + Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. + + Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` + + ## URL Construction Using Relative Paths + + For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`. + + Below are a few examples of how `baseURL` and relative paths interact: + + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; + [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz + [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo + [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ + [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ + + Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. + + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFHTTPSessionManager : AFURLSessionManager + +/** + The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. + */ +@property (readonly, nonatomic, strong, nullable) NSURL *baseURL; + +/** + Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies. + + @warning `requestSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. A security policy configured with `AFSSLPinningModePublicKey` or `AFSSLPinningModeCertificate` can only be applied on a session manager initialized with a secure base URL (i.e. https). Applying a security policy with pinning enabled on an insecure session manager throws an `Invalid Security Policy` exception. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns an `AFHTTPSessionManager` object. + */ ++ (instancetype)manager; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + @param url The base URL for the HTTP client. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(nullable NSURL *)url; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + This is the designated initializer. + + @param url The base URL for the HTTP client. + @param configuration The configuration used to create the managed session. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(nullable NSURL *)url + sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; + +///--------------------------- +/// @name Making HTTP Requests +///--------------------------- + +/** + Creates and runs an `NSURLSessionDataTask` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param headers The headers appended to the default headers for this request. + @param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: + */ +- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `HEAD` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param headers The headers appended to the default headers for this request. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + success:(nullable void (^)(NSURLSessionDataTask *task))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param headers The headers appended to the default headers for this request. + @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param headers The headers appended to the default headers for this request. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + constructingBodyWithBlock:(nullable void (^)(id formData))block + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PUT` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param headers The headers appended to the default headers for this request. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PATCH` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param headers The headers appended to the default headers for this request. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `DELETE` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param headers The headers appended to the default headers for this request. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates an `NSURLSessionDataTask` with a custom `HTTPMethod` request. + + @param method The HTTPMethod string used to create the request. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param headers The headers appended to the default headers for this request. + @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: + */ +- (nullable NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + uploadProgress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress + downloadProgress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m new file mode 100644 index 0000000000000000000000000000000000000000..b4ab5915c34e660c2a57a749e48eb9b0eb8550bb --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m @@ -0,0 +1,357 @@ +// AFHTTPSessionManager.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFHTTPSessionManager.h" + +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" + +#import +#import +#import + +#import +#import +#import +#import +#import + +#if TARGET_OS_IOS || TARGET_OS_TV +#import +#elif TARGET_OS_WATCH +#import +#endif + +@interface AFHTTPSessionManager () +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@end + +@implementation AFHTTPSessionManager +@dynamic responseSerializer; + ++ (instancetype)manager { + return [[[self class] alloc] initWithBaseURL:nil]; +} + +- (instancetype)init { + return [self initWithBaseURL:nil]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url { + return [self initWithBaseURL:url sessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + return [self initWithBaseURL:nil sessionConfiguration:configuration]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url + sessionConfiguration:(NSURLSessionConfiguration *)configuration +{ + self = [super initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected + if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { + url = [url URLByAppendingPathComponent:@""]; + } + + self.baseURL = url; + + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + return self; +} + +#pragma mark - + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + NSParameterAssert(requestSerializer); + + _requestSerializer = requestSerializer; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + [super setResponseSerializer:responseSerializer]; +} + +@dynamic securityPolicy; + +- (void)setSecurityPolicy:(AFSecurityPolicy *)securityPolicy { + if (securityPolicy.SSLPinningMode != AFSSLPinningModeNone && ![self.baseURL.scheme isEqualToString:@"https"]) { + NSString *pinningMode = @"Unknown Pinning Mode"; + switch (securityPolicy.SSLPinningMode) { + case AFSSLPinningModeNone: pinningMode = @"AFSSLPinningModeNone"; break; + case AFSSLPinningModeCertificate: pinningMode = @"AFSSLPinningModeCertificate"; break; + case AFSSLPinningModePublicKey: pinningMode = @"AFSSLPinningModePublicKey"; break; + } + NSString *reason = [NSString stringWithFormat:@"A security policy configured with `%@` can only be applied on a manager with a secure base URL (i.e. https)", pinningMode]; + @throw [NSException exceptionWithName:@"Invalid Security Policy" reason:reason userInfo:nil]; + } + + [super setSecurityPolicy:securityPolicy]; +} + +#pragma mark - + +- (NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + progress:(nullable void (^)(NSProgress * _Nonnull))downloadProgress + success:(nullable void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure +{ + + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET" + URLString:URLString + parameters:parameters + headers:headers + uploadProgress:nil + downloadProgress:downloadProgress + success:success + failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + success:(nullable void (^)(NSURLSessionDataTask * _Nonnull))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters headers:headers uploadProgress:nil downloadProgress:nil success:^(NSURLSessionDataTask *task, __unused id responseObject) { + if (success) { + success(task); + } + } failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters headers:headers uploadProgress:uploadProgress downloadProgress:nil success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + constructingBodyWithBlock:(nullable void (^)(id _Nonnull))block + progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgress + success:(nullable void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError]; + for (NSString *headerField in headers.keyEnumerator) { + [request setValue:headers[headerField] forHTTPHeaderField:headerField]; + } + if (serializationError) { + if (failure) { + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); + } + + return nil; + } + + __block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:uploadProgress completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(task, error); + } + } else { + if (success) { + success(task, responseObject); + } + } + }]; + + [task resume]; + + return task; +} + +- (NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters headers:headers uploadProgress:nil downloadProgress:nil success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters headers:headers uploadProgress:nil downloadProgress:nil success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters headers:headers uploadProgress:nil downloadProgress:nil success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + + +- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(nullable id)parameters + headers:(nullable NSDictionary *)headers + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgress + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgress + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError]; + for (NSString *headerField in headers.keyEnumerator) { + [request setValue:headers[headerField] forHTTPHeaderField:headerField]; + } + if (serializationError) { + if (failure) { + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); + } + + return nil; + } + + __block NSURLSessionDataTask *dataTask = nil; + dataTask = [self dataTaskWithRequest:request + uploadProgress:uploadProgress + downloadProgress:downloadProgress + completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(dataTask, error); + } + } else { + if (success) { + success(dataTask, responseObject); + } + } + }]; + + return dataTask; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))]; + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + if (!configuration) { + NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"]; + if (configurationIdentifier) { + configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier]; + } + } + + self = [self initWithBaseURL:baseURL sessionConfiguration:configuration]; + if (!self) { + return nil; + } + + self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + AFSecurityPolicy *decodedPolicy = [decoder decodeObjectOfClass:[AFSecurityPolicy class] forKey:NSStringFromSelector(@selector(securityPolicy))]; + if (decodedPolicy) { + self.securityPolicy = decodedPolicy; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; + if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; + } else { + [coder encodeObject:self.session.configuration.identifier forKey:@"identifier"]; + } + [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; + [coder encodeObject:self.securityPolicy forKey:NSStringFromSelector(@selector(securityPolicy))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration]; + + HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; + HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; + HTTPClient.securityPolicy = [self.securityPolicy copyWithZone:zone]; + return HTTPClient; +} + +@end diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h new file mode 100644 index 0000000000000000000000000000000000000000..21982a0e3c78ecbbff72fa3f0869b9170db00dbc --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1,216 @@ +// AFNetworkReachabilityManager.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#if !TARGET_OS_WATCH +#import + +typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { + AFNetworkReachabilityStatusUnknown = -1, + AFNetworkReachabilityStatusNotReachable = 0, + AFNetworkReachabilityStatusReachableViaWWAN = 1, + AFNetworkReachabilityStatusReachableViaWiFi = 2, +}; + +NS_ASSUME_NONNULL_BEGIN + +/** + `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + + Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability. + + See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ ) + + @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. + */ +@interface AFNetworkReachabilityManager : NSObject + +/** + The current network reachability status. + */ +@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; + +/** + Whether or not the network is currently reachable. + */ +@property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; + +/** + Whether or not the network is currently reachable via WWAN. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; + +/** + Whether or not the network is currently reachable via WiFi. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Returns the shared network reachability manager. + */ ++ (instancetype)sharedManager; + +/** + Creates and returns a network reachability manager with the default socket address. + + @return An initialized network reachability manager, actively monitoring the default socket address. + */ ++ (instancetype)manager; + +/** + Creates and returns a network reachability manager for the specified domain. + + @param domain The domain used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified domain. + */ ++ (instancetype)managerForDomain:(NSString *)domain; + +/** + Creates and returns a network reachability manager for the socket address. + + @param address The socket address (`sockaddr_in6`) used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified socket address. + */ ++ (instancetype)managerForAddress:(const void *)address; + +/** + Initializes an instance of a network reachability manager from the specified reachability object. + + @param reachability The reachability object to monitor. + + @return An initialized network reachability manager, actively monitoring the specified reachability. + */ +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER; + +/** + * Unavailable initializer + */ ++ (instancetype)new NS_UNAVAILABLE; + +/** + * Unavailable initializer + */ +- (instancetype)init NS_UNAVAILABLE; + +///-------------------------------------------------- +/// @name Starting & Stopping Reachability Monitoring +///-------------------------------------------------- + +/** + Starts monitoring for changes in network reachability status. + */ +- (void)startMonitoring; + +/** + Stops monitoring for changes in network reachability status. + */ +- (void)stopMonitoring; + +///------------------------------------------------- +/// @name Getting Localized Reachability Description +///------------------------------------------------- + +/** + Returns a localized string representation of the current network reachability status. + */ +- (NSString *)localizedNetworkReachabilityStatusString; + +///--------------------------------------------------- +/// @name Setting Network Reachability Change Callback +///--------------------------------------------------- + +/** + Sets a callback to be executed when the network availability of the `baseURL` host changes. + + @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`. + */ +- (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Network Reachability + + The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. + + enum { + AFNetworkReachabilityStatusUnknown, + AFNetworkReachabilityStatusNotReachable, + AFNetworkReachabilityStatusReachableViaWWAN, + AFNetworkReachabilityStatusReachableViaWiFi, + } + + `AFNetworkReachabilityStatusUnknown` + The `baseURL` host reachability is not known. + + `AFNetworkReachabilityStatusNotReachable` + The `baseURL` host cannot be reached. + + `AFNetworkReachabilityStatusReachableViaWWAN` + The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. + + `AFNetworkReachabilityStatusReachableViaWiFi` + The `baseURL` host can be reached via a Wi-Fi connection. + + ### Keys for Notification UserInfo Dictionary + + Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. + + `AFNetworkingReachabilityNotificationStatusItem` + A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. + The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. + */ + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when network reachability changes. + This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability. + + @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). + */ +FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification; +FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem; + +///-------------------- +/// @name Functions +///-------------------- + +/** + Returns a localized string representation of an `AFNetworkReachabilityStatus` value. + */ +FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); + +NS_ASSUME_NONNULL_END +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m new file mode 100644 index 0000000000000000000000000000000000000000..0322bf9b81e2e4d96d80a6743af07b7d471f2ad6 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m @@ -0,0 +1,269 @@ +// AFNetworkReachabilityManager.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFNetworkReachabilityManager.h" +#if !TARGET_OS_WATCH + +#import +#import +#import +#import +#import + +NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; +NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; + +typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); +typedef AFNetworkReachabilityManager * (^AFNetworkReachabilityStatusCallback)(AFNetworkReachabilityStatus status); + +NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { + switch (status) { + case AFNetworkReachabilityStatusNotReachable: + return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWWAN: + return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWiFi: + return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); + case AFNetworkReachabilityStatusUnknown: + default: + return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); + } +} + +static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { + BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); + BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); + BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); + BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); + BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); + + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; + if (isNetworkReachable == NO) { + status = AFNetworkReachabilityStatusNotReachable; + } +#if TARGET_OS_IPHONE + else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { + status = AFNetworkReachabilityStatusReachableViaWWAN; + } +#endif + else { + status = AFNetworkReachabilityStatusReachableViaWiFi; + } + + return status; +} + +/** + * Queue a status change notification for the main thread. + * + * This is done to ensure that the notifications are received in the same order + * as they are sent. If notifications are sent directly, it is possible that + * a queued notification (for an earlier status condition) is processed after + * the later update, resulting in the listener being left in the wrong state. + */ +static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusCallback block) { + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); + dispatch_async(dispatch_get_main_queue(), ^{ + AFNetworkReachabilityManager *manager = nil; + if (block) { + manager = block(status); + } + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) }; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:manager userInfo:userInfo]; + }); +} + +static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { + AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusCallback)info); +} + + +static const void * AFNetworkReachabilityRetainCallback(const void *info) { + return Block_copy(info); +} + +static void AFNetworkReachabilityReleaseCallback(const void *info) { + if (info) { + Block_release(info); + } +} + +@interface AFNetworkReachabilityManager () +@property (readonly, nonatomic, assign) SCNetworkReachabilityRef networkReachability; +@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; +@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; +@end + +@implementation AFNetworkReachabilityManager + ++ (instancetype)sharedManager { + static AFNetworkReachabilityManager *_sharedManager = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _sharedManager = [self manager]; + }); + + return _sharedManager; +} + ++ (instancetype)managerForDomain:(NSString *)domain { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); + + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + + CFRelease(reachability); + + return manager; +} + ++ (instancetype)managerForAddress:(const void *)address { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + + CFRelease(reachability); + + return manager; +} + ++ (instancetype)manager +{ +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) + struct sockaddr_in6 address; + bzero(&address, sizeof(address)); + address.sin6_len = sizeof(address); + address.sin6_family = AF_INET6; +#else + struct sockaddr_in address; + bzero(&address, sizeof(address)); + address.sin_len = sizeof(address); + address.sin_family = AF_INET; +#endif + return [self managerForAddress:&address]; +} + +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { + self = [super init]; + if (!self) { + return nil; + } + + _networkReachability = CFRetain(reachability); + self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; + + return self; +} + +- (instancetype)init +{ + @throw [NSException exceptionWithName:NSGenericException + reason:@"`-init` unavailable. Use `-initWithReachability:` instead" + userInfo:nil]; + return nil; +} + +- (void)dealloc { + [self stopMonitoring]; + + if (_networkReachability != NULL) { + CFRelease(_networkReachability); + } +} + +#pragma mark - + +- (BOOL)isReachable { + return [self isReachableViaWWAN] || [self isReachableViaWiFi]; +} + +- (BOOL)isReachableViaWWAN { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; +} + +- (BOOL)isReachableViaWiFi { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; +} + +#pragma mark - + +- (void)startMonitoring { + [self stopMonitoring]; + + if (!self.networkReachability) { + return; + } + + __weak __typeof(self)weakSelf = self; + AFNetworkReachabilityStatusCallback callback = ^(AFNetworkReachabilityStatus status) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + + strongSelf.networkReachabilityStatus = status; + if (strongSelf.networkReachabilityStatusBlock) { + strongSelf.networkReachabilityStatusBlock(status); + } + + return strongSelf; + }; + + SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; + SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); + SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ + SCNetworkReachabilityFlags flags; + if (SCNetworkReachabilityGetFlags(self.networkReachability, &flags)) { + AFPostReachabilityStatusChange(flags, callback); + } + }); +} + +- (void)stopMonitoring { + if (!self.networkReachability) { + return; + } + + SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); +} + +#pragma mark - + +- (NSString *)localizedNetworkReachabilityStatusString { + return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); +} + +#pragma mark - + +- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { + self.networkReachabilityStatusBlock = block; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { + if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { + return [NSSet setWithObject:@"networkReachabilityStatus"]; + } + + return [super keyPathsForValuesAffectingValueForKey:key]; +} + +@end +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworking.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworking.h new file mode 100644 index 0000000000000000000000000000000000000000..e2fb2f44e61205b271b8541c95d688abc51de591 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFNetworking.h @@ -0,0 +1,41 @@ +// AFNetworking.h +// +// Copyright (c) 2013 AFNetworking (http://afnetworking.com/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import +#import + +#ifndef _AFNETWORKING_ + #define _AFNETWORKING_ + + #import "AFURLRequestSerialization.h" + #import "AFURLResponseSerialization.h" + #import "AFSecurityPolicy.h" + +#if !TARGET_OS_WATCH + #import "AFNetworkReachabilityManager.h" +#endif + + #import "AFURLSessionManager.h" + #import "AFHTTPSessionManager.h" + +#endif /* _AFNETWORKING_ */ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h new file mode 100644 index 0000000000000000000000000000000000000000..9b966a5766f87adef3022d9c7c82ff9245afc822 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1,161 @@ +// AFSecurityPolicy.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, +}; + +/** + `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + + Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFSecurityPolicy : NSObject + +/** + The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. + */ +@property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; + +/** + The certificates used to evaluate server trust according to the SSL pinning mode. + + Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches. + + @see policyWithPinningMode:withPinnedCertificates: + */ +@property (nonatomic, strong, nullable) NSSet *pinnedCertificates; + +/** + Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL allowInvalidCertificates; + +/** + Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. + */ +@property (nonatomic, assign) BOOL validatesDomainName; + +///----------------------------------------- +/// @name Getting Certificates from the Bundle +///----------------------------------------- + +/** + Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`. + + @return The certificates included in the given bundle. + */ ++ (NSSet *)certificatesInBundle:(NSBundle *)bundle; + +///----------------------------------------- +/// @name Getting Specific Security Policies +///----------------------------------------- + +/** + Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys. + + @return The default security policy. + */ ++ (instancetype)defaultPolicy; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a security policy with the specified pinning mode. + + Certificates with the `.cer` extension found in the main bundle will be pinned. If you want more control over which certificates are pinned, please use `policyWithPinningMode:withPinnedCertificates:` instead. + + @param pinningMode The SSL pinning mode. + + @return A new security policy. + + @see -policyWithPinningMode:withPinnedCertificates: + */ ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; + +/** + Creates and returns a security policy with the specified pinning mode. + + @param pinningMode The SSL pinning mode. + @param pinnedCertificates The certificates to pin against. + + @return A new security policy. + + @see +certificatesInBundle: + @see -pinnedCertificates +*/ ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates; + +///------------------------------ +/// @name Evaluating Server Trust +///------------------------------ + +/** + Whether or not the specified server trust should be accepted, based on the security policy. + + This method should be used when responding to an authentication challenge from a server. + + @param serverTrust The X.509 certificate trust of the server. + @param domain The domain of serverTrust. If `nil`, the domain will not be validated. + + @return Whether or not to trust the server. + */ +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(nullable NSString *)domain; + +@end + +NS_ASSUME_NONNULL_END + +///---------------- +/// @name Constants +///---------------- + +/** + ## SSL Pinning Modes + + The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. + + enum { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, + } + + `AFSSLPinningModeNone` + Do not used pinned certificates to validate servers. + + `AFSSLPinningModePublicKey` + Validate host certificates against public keys of pinned certificates. + + `AFSSLPinningModeCertificate` + Validate host certificates against pinned certificates. +*/ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m new file mode 100644 index 0000000000000000000000000000000000000000..da199aa3b7fda05e1a8615db9fac3a94b37234de --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m @@ -0,0 +1,341 @@ +// AFSecurityPolicy.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFSecurityPolicy.h" + +#import + +#if !TARGET_OS_IOS && !TARGET_OS_WATCH && !TARGET_OS_TV +static NSData * AFSecKeyGetData(SecKeyRef key) { + CFDataRef data = NULL; + + __Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out); + + return (__bridge_transfer NSData *)data; + +_out: + if (data) { + CFRelease(data); + } + + return nil; +} +#endif + +static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { +#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV + return [(__bridge id)key1 isEqual:(__bridge id)key2]; +#else + return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)]; +#endif +} + +static id AFPublicKeyForCertificate(NSData *certificate) { + id allowedPublicKey = nil; + SecCertificateRef allowedCertificate; + SecPolicyRef policy = nil; + SecTrustRef allowedTrust = nil; + SecTrustResultType result; + + allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate); + __Require_Quiet(allowedCertificate != NULL, _out); + + policy = SecPolicyCreateBasicX509(); + __Require_noErr_Quiet(SecTrustCreateWithCertificates(allowedCertificate, policy, &allowedTrust), _out); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out); +#pragma clang diagnostic pop + + allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust); + +_out: + if (allowedTrust) { + CFRelease(allowedTrust); + } + + if (policy) { + CFRelease(policy); + } + + if (allowedCertificate) { + CFRelease(allowedCertificate); + } + + return allowedPublicKey; +} + +static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { + BOOL isValid = NO; + SecTrustResultType result; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out); +#pragma clang diagnostic pop + + isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); + +_out: + return isValid; +} + +static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; + } + + return [NSArray arrayWithArray:trustChain]; +} + +static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) { + SecPolicyRef policy = SecPolicyCreateBasicX509(); + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + + SecCertificateRef someCertificates[] = {certificate}; + CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL); + + SecTrustRef trust; + __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out); + SecTrustResultType result; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out); +#pragma clang diagnostic pop + [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; + + _out: + if (trust) { + CFRelease(trust); + } + + if (certificates) { + CFRelease(certificates); + } + + continue; + } + CFRelease(policy); + + return [NSArray arrayWithArray:trustChain]; +} + +#pragma mark - + +@interface AFSecurityPolicy() +@property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode; +@property (readwrite, nonatomic, strong) NSSet *pinnedPublicKeys; +@end + +@implementation AFSecurityPolicy + ++ (NSSet *)certificatesInBundle:(NSBundle *)bundle { + NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; + + NSMutableSet *certificates = [NSMutableSet setWithCapacity:[paths count]]; + for (NSString *path in paths) { + NSData *certificateData = [NSData dataWithContentsOfFile:path]; + [certificates addObject:certificateData]; + } + + return [NSSet setWithSet:certificates]; +} + ++ (instancetype)defaultPolicy { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = AFSSLPinningModeNone; + + return securityPolicy; +} + ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode { + NSSet *defaultPinnedCertificates = [self certificatesInBundle:[NSBundle mainBundle]]; + return [self policyWithPinningMode:pinningMode withPinnedCertificates:defaultPinnedCertificates]; +} + ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = pinningMode; + + [securityPolicy setPinnedCertificates:pinnedCertificates]; + + return securityPolicy; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.validatesDomainName = YES; + + return self; +} + +- (void)setPinnedCertificates:(NSSet *)pinnedCertificates { + _pinnedCertificates = pinnedCertificates; + + if (self.pinnedCertificates) { + NSMutableSet *mutablePinnedPublicKeys = [NSMutableSet setWithCapacity:[self.pinnedCertificates count]]; + for (NSData *certificate in self.pinnedCertificates) { + id publicKey = AFPublicKeyForCertificate(certificate); + if (!publicKey) { + continue; + } + [mutablePinnedPublicKeys addObject:publicKey]; + } + self.pinnedPublicKeys = [NSSet setWithSet:mutablePinnedPublicKeys]; + } else { + self.pinnedPublicKeys = nil; + } +} + +#pragma mark - + +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(NSString *)domain +{ + if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) { + // https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html + // According to the docs, you should only trust your provided certs for evaluation. + // Pinned certificates are added to the trust. Without pinned certificates, + // there is nothing to evaluate against. + // + // From Apple Docs: + // "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors). + // Instead, add your own (self-signed) CA certificate to the list of trusted anchors." + NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning."); + return NO; + } + + NSMutableArray *policies = [NSMutableArray array]; + if (self.validatesDomainName) { + [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)]; + } else { + [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()]; + } + + SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies); + + if (self.SSLPinningMode == AFSSLPinningModeNone) { + return self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust); + } else if (!self.allowInvalidCertificates && !AFServerTrustIsValid(serverTrust)) { + return NO; + } + + switch (self.SSLPinningMode) { + case AFSSLPinningModeCertificate: { + NSMutableArray *pinnedCertificates = [NSMutableArray array]; + for (NSData *certificateData in self.pinnedCertificates) { + [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; + } + SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); + + if (!AFServerTrustIsValid(serverTrust)) { + return NO; + } + + // obtain the chain after being validated, which *should* contain the pinned certificate in the last position (if it's the Root CA) + NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust); + + for (NSData *trustChainCertificate in [serverCertificates reverseObjectEnumerator]) { + if ([self.pinnedCertificates containsObject:trustChainCertificate]) { + return YES; + } + } + + return NO; + } + case AFSSLPinningModePublicKey: { + NSUInteger trustedPublicKeyCount = 0; + NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust); + + for (id trustChainPublicKey in publicKeys) { + for (id pinnedPublicKey in self.pinnedPublicKeys) { + if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) { + trustedPublicKeyCount += 1; + } + } + } + return trustedPublicKeyCount > 0; + } + + default: + return NO; + } + + return NO; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys { + return [NSSet setWithObject:@"pinnedCertificates"]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + + self = [self init]; + if (!self) { + return nil; + } + + self.SSLPinningMode = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(SSLPinningMode))] unsignedIntegerValue]; + self.allowInvalidCertificates = [decoder decodeBoolForKey:NSStringFromSelector(@selector(allowInvalidCertificates))]; + self.validatesDomainName = [decoder decodeBoolForKey:NSStringFromSelector(@selector(validatesDomainName))]; + self.pinnedCertificates = [decoder decodeObjectOfClass:[NSSet class] forKey:NSStringFromSelector(@selector(pinnedCertificates))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:[NSNumber numberWithUnsignedInteger:self.SSLPinningMode] forKey:NSStringFromSelector(@selector(SSLPinningMode))]; + [coder encodeBool:self.allowInvalidCertificates forKey:NSStringFromSelector(@selector(allowInvalidCertificates))]; + [coder encodeBool:self.validatesDomainName forKey:NSStringFromSelector(@selector(validatesDomainName))]; + [coder encodeObject:self.pinnedCertificates forKey:NSStringFromSelector(@selector(pinnedCertificates))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFSecurityPolicy *securityPolicy = [[[self class] allocWithZone:zone] init]; + securityPolicy.SSLPinningMode = self.SSLPinningMode; + securityPolicy.allowInvalidCertificates = self.allowInvalidCertificates; + securityPolicy.validatesDomainName = self.validatesDomainName; + securityPolicy.pinnedCertificates = [self.pinnedCertificates copyWithZone:zone]; + + return securityPolicy; +} + +@end diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..b17e871e632cca38af53bb6e4691a2ac8a508855 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1,479 @@ +// AFURLRequestSerialization.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +#if TARGET_OS_IOS || TARGET_OS_TV +#import +#elif TARGET_OS_WATCH +#import +#endif + +NS_ASSUME_NONNULL_BEGIN + +/** + Returns a percent-escaped string following RFC 3986 for a query string key or value. + RFC 3986 states that the following characters are "reserved" characters. + - General Delimiters: ":", "#", "[", "]", "@", "?", "/" + - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=" + + In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow + query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/" + should be percent-escaped in the query string. + + @param string The string to be percent-escaped. + + @return The percent-escaped string. + */ +FOUNDATION_EXPORT NSString * AFPercentEscapedStringFromString(NSString *string); + +/** + A helper method to generate encoded url query parameters for appending to the end of a URL. + + @param parameters A dictionary of key/values to be encoded. + + @return A url encoded query string + */ +FOUNDATION_EXPORT NSString * AFQueryStringFromParameters(NSDictionary *parameters); + +/** + The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary. + + For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`. + */ +@protocol AFURLRequestSerialization + +/** + Returns a request with the specified parameters encoded into a copy of the original request. + + @param request The original request. + @param parameters The parameters to be encoded. + @param error The error that occurred while attempting to encode the request parameters. + + @return A serialized request. + */ +- (nullable NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(nullable id)parameters + error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW; + +@end + +#pragma mark - + +/** + + */ +typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) { + AFHTTPRequestQueryStringDefaultStyle = 0, +}; + +@protocol AFMultipartFormData; + +/** + `AFHTTPRequestSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPRequestSerializer : NSObject + +/** + The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Whether created requests can use the device’s cellular radio (if present). `YES` by default. + + @see NSMutableURLRequest -setAllowsCellularAccess: + */ +@property (nonatomic, assign) BOOL allowsCellularAccess; + +/** + The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default. + + @see NSMutableURLRequest -setCachePolicy: + */ +@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy; + +/** + Whether created requests should use the default cookie handling. `YES` by default. + + @see NSMutableURLRequest -setHTTPShouldHandleCookies: + */ +@property (nonatomic, assign) BOOL HTTPShouldHandleCookies; + +/** + Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default + + @see NSMutableURLRequest -setHTTPShouldUsePipelining: + */ +@property (nonatomic, assign) BOOL HTTPShouldUsePipelining; + +/** + The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default. + + @see NSMutableURLRequest -setNetworkServiceType: + */ +@property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType; + +/** + The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds. + + @see NSMutableURLRequest -setTimeoutInterval: + */ +@property (nonatomic, assign) NSTimeInterval timeoutInterval; + +///--------------------------------------- +/// @name Configuring HTTP Request Headers +///--------------------------------------- + +/** + Default HTTP header field values to be applied to serialized requests. By default, these include the following: + + - `Accept-Language` with the contents of `NSLocale +preferredLanguages` + - `User-Agent` with the contents of various bundle identifiers and OS designations + + @discussion To add or remove default request headers, use `setValue:forHTTPHeaderField:`. + */ +@property (readonly, nonatomic, strong) NSDictionary *HTTPRequestHeaders; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +/** + Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header. + + @param field The HTTP header to set a default value for + @param value The value set as default for the specified header, or `nil` + */ +- (void)setValue:(nullable NSString *)value +forHTTPHeaderField:(NSString *)field; + +/** + Returns the value for the HTTP headers set in the request serializer. + + @param field The HTTP header to retrieve the default value for + + @return The value set as default for the specified header, or `nil` + */ +- (nullable NSString *)valueForHTTPHeaderField:(NSString *)field; + +/** + Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header. + + @param username The HTTP basic auth username + @param password The HTTP basic auth password + */ +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password; + +/** + Clears any existing value for the "Authorization" HTTP header. + */ +- (void)clearAuthorizationHeader; + +///------------------------------------------------------- +/// @name Configuring Query String Parameter Serialization +///------------------------------------------------------- + +/** + HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default. + */ +@property (nonatomic, strong) NSSet *HTTPMethodsEncodingParametersInURI; + +/** + Set the method of query string serialization according to one of the pre-defined styles. + + @param style The serialization style. + + @see AFHTTPRequestQueryStringSerializationStyle + */ +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style; + +/** + Set the a custom method of query string serialization according to the specified block. + + @param block A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request. + */ +- (void)setQueryStringSerializationWithBlock:(nullable NSString * _Nullable (^)(NSURLRequest *request, id parameters, NSError * __autoreleasing *error))block; + +///------------------------------- +/// @name Creating Request Objects +///------------------------------- + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string. + + If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body. + + @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body. + @param error The error that occurred while constructing the request. + + @return An `NSMutableURLRequest` object. + */ +- (nullable NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(nullable id)parameters + error:(NSError * _Nullable __autoreleasing *)error; + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2 + + Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream. + + @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded and set in the request HTTP body. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param error The error that occurred while constructing the request. + + @return An `NSMutableURLRequest` object + */ +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(nullable NSDictionary *)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + error:(NSError * _Nullable __autoreleasing *)error; + +/** + Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished. + + @param request The multipart form request. The `HTTPBodyStream` property of `request` must not be `nil`. + @param fileURL The file URL to write multipart form contents to. + @param handler A handler block to execute. + + @discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request. + + @see https://github.com/AFNetworking/AFNetworking/issues/1398 + */ +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(nullable void (^)(NSError * _Nullable error))handler; + +@end + +#pragma mark - + +/** + The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:`. + */ +@protocol AFMultipartFormData + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary. + + The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended, otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * _Nullable __autoreleasing *)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`. + @param mimeType The declared MIME type of the file data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * _Nullable __autoreleasing *)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary. + + @param inputStream The input stream to be appended to the form data + @param name The name to be associated with the specified input stream. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`. + @param length The length of the specified input stream in bytes. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithInputStream:(nullable NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified data. This parameter must not be `nil`. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + */ + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name; + + +/** + Appends HTTP headers, followed by the encoded data and the multipart form boundary. + + @param headers The HTTP headers to be appended to the form data. + @param body The data to be encoded and appended to the form data. This parameter must not be `nil`. + */ +- (void)appendPartWithHeaders:(nullable NSDictionary *)headers + body:(NSData *)body; + +/** + Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. + + When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, there is no definite way to distinguish between a 3G, EDGE, or LTE connection over `NSURLConnection`. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth. + + @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb. + @param delay Duration of delay each time a packet is read. By default, no delay is set. + */ +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay; + +@end + +#pragma mark - + +/** + `AFJSONRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`. + */ +@interface AFJSONRequestSerializer : AFHTTPRequestSerializer + +/** + Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONWritingOptions writingOptions; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param writingOptions The specified JSON writing options. + */ ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions; + +@end + +#pragma mark - + +/** + `AFPropertyListRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSPropertyListSerializer`, setting the `Content-Type` of the encoded request to `application/x-plist`. + */ +@interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + @warning The `writeOptions` property is currently unused. + */ +@property (nonatomic, assign) NSPropertyListWriteOptions writeOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param writeOptions The property list write options. + + @warning The `writeOptions` property is currently unused. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions; + +@end + +#pragma mark - + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLRequestSerializationErrorDomain` + + ### Constants + + `AFURLRequestSerializationErrorDomain` + AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFURLRequestSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLRequestErrorKey` + The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLRequestErrorKey; + +/** + ## Throttling Bandwidth for HTTP Request Input Streams + + @see -throttleBandwidthWithPacketSize:delay: + + ### Constants + + `kAFUploadStream3GSuggestedPacketSize` + Maximum packet size, in number of bytes. Equal to 16kb. + + `kAFUploadStream3GSuggestedDelay` + Duration of delay each time a packet is read. Equal to 0.2 seconds. + */ +FOUNDATION_EXPORT NSUInteger const kAFUploadStream3GSuggestedPacketSize; +FOUNDATION_EXPORT NSTimeInterval const kAFUploadStream3GSuggestedDelay; + +NS_ASSUME_NONNULL_END diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m new file mode 100644 index 0000000000000000000000000000000000000000..f60b6f9d8abc7b6feea2a578fc9297ad1d3965dd --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m @@ -0,0 +1,1399 @@ +// AFURLRequestSerialization.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLRequestSerialization.h" + +#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV +#import +#else +#import +#endif + +NSString * const AFURLRequestSerializationErrorDomain = @"com.alamofire.error.serialization.request"; +NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"com.alamofire.serialization.request.error.response"; + +typedef NSString * (^AFQueryStringSerializationBlock)(NSURLRequest *request, id parameters, NSError *__autoreleasing *error); + +/** + Returns a percent-escaped string following RFC 3986 for a query string key or value. + RFC 3986 states that the following characters are "reserved" characters. + - General Delimiters: ":", "#", "[", "]", "@", "?", "/" + - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=" + + In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow + query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/" + should be percent-escaped in the query string. + - parameter string: The string to be percent-escaped. + - returns: The percent-escaped string. + */ +NSString * AFPercentEscapedStringFromString(NSString *string) { + static NSString * const kAFCharactersGeneralDelimitersToEncode = @":#[]@"; // does not include "?" or "/" due to RFC 3986 - Section 3.4 + static NSString * const kAFCharactersSubDelimitersToEncode = @"!$&'()*+,;="; + + NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy]; + [allowedCharacterSet removeCharactersInString:[kAFCharactersGeneralDelimitersToEncode stringByAppendingString:kAFCharactersSubDelimitersToEncode]]; + + // FIXME: https://github.com/AFNetworking/AFNetworking/pull/3028 + // return [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; + + static NSUInteger const batchSize = 50; + + NSUInteger index = 0; + NSMutableString *escaped = @"".mutableCopy; + + while (index < string.length) { + NSUInteger length = MIN(string.length - index, batchSize); + NSRange range = NSMakeRange(index, length); + + // To avoid breaking up character sequences such as 👴🏻👮🏽 + range = [string rangeOfComposedCharacterSequencesForRange:range]; + + NSString *substring = [string substringWithRange:range]; + NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; + [escaped appendString:encoded]; + + index += range.length; + } + + return escaped; +} + +#pragma mark - + +@interface AFQueryStringPair : NSObject +@property (readwrite, nonatomic, strong) id field; +@property (readwrite, nonatomic, strong) id value; + +- (instancetype)initWithField:(id)field value:(id)value; + +- (NSString *)URLEncodedStringValue; +@end + +@implementation AFQueryStringPair + +- (instancetype)initWithField:(id)field value:(id)value { + self = [super init]; + if (!self) { + return nil; + } + + self.field = field; + self.value = value; + + return self; +} + +- (NSString *)URLEncodedStringValue { + if (!self.value || [self.value isEqual:[NSNull null]]) { + return AFPercentEscapedStringFromString([self.field description]); + } else { + return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedStringFromString([self.field description]), AFPercentEscapedStringFromString([self.value description])]; + } +} + +@end + +#pragma mark - + +FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary); +FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value); + +NSString * AFQueryStringFromParameters(NSDictionary *parameters) { + NSMutableArray *mutablePairs = [NSMutableArray array]; + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + [mutablePairs addObject:[pair URLEncodedStringValue]]; + } + + return [mutablePairs componentsJoinedByString:@"&"]; +} + +NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary) { + return AFQueryStringPairsFromKeyAndValue(nil, dictionary); +} + +NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { + NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; + + NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(compare:)]; + + if ([value isKindOfClass:[NSDictionary class]]) { + NSDictionary *dictionary = value; + // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + id nestedValue = dictionary[nestedKey]; + if (nestedValue) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; + } + } + } else if ([value isKindOfClass:[NSArray class]]) { + NSArray *array = value; + for (id nestedValue in array) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; + } + } else if ([value isKindOfClass:[NSSet class]]) { + NSSet *set = value; + for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)]; + } + } else { + [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]]; + } + + return mutableQueryStringComponents; +} + +#pragma mark - + +@interface AFStreamingMultipartFormData : NSObject +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding; + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData; +@end + +#pragma mark - + +static NSArray * AFHTTPRequestSerializerObservedKeyPaths() { + static NSArray *_AFHTTPRequestSerializerObservedKeyPaths = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _AFHTTPRequestSerializerObservedKeyPaths = @[NSStringFromSelector(@selector(allowsCellularAccess)), NSStringFromSelector(@selector(cachePolicy)), NSStringFromSelector(@selector(HTTPShouldHandleCookies)), NSStringFromSelector(@selector(HTTPShouldUsePipelining)), NSStringFromSelector(@selector(networkServiceType)), NSStringFromSelector(@selector(timeoutInterval))]; + }); + + return _AFHTTPRequestSerializerObservedKeyPaths; +} + +static void *AFHTTPRequestSerializerObserverContext = &AFHTTPRequestSerializerObserverContext; + +@interface AFHTTPRequestSerializer () +@property (readwrite, nonatomic, strong) NSMutableSet *mutableObservedChangedKeyPaths; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableHTTPRequestHeaders; +@property (readwrite, nonatomic, strong) dispatch_queue_t requestHeaderModificationQueue; +@property (readwrite, nonatomic, assign) AFHTTPRequestQueryStringSerializationStyle queryStringSerializationStyle; +@property (readwrite, nonatomic, copy) AFQueryStringSerializationBlock queryStringSerialization; +@end + +@implementation AFHTTPRequestSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.mutableHTTPRequestHeaders = [NSMutableDictionary dictionary]; + self.requestHeaderModificationQueue = dispatch_queue_create("requestHeaderModificationQueue", DISPATCH_QUEUE_CONCURRENT); + + // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 + NSMutableArray *acceptLanguagesComponents = [NSMutableArray array]; + [[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + float q = 1.0f - (idx * 0.1f); + [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]]; + *stop = q <= 0.5f; + }]; + [self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"]; + + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + NSString *userAgent = nil; +#if TARGET_OS_IOS + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; +#elif TARGET_OS_TV + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; tvOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; +#elif TARGET_OS_WATCH + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; watchOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[WKInterfaceDevice currentDevice] model], [[WKInterfaceDevice currentDevice] systemVersion], [[WKInterfaceDevice currentDevice] screenScale]]; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]; +#endif + if (userAgent) { + if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) { + NSMutableString *mutableUserAgent = [userAgent mutableCopy]; + if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) { + userAgent = mutableUserAgent; + } + } + [self setValue:userAgent forHTTPHeaderField:@"User-Agent"]; + } + + // HTTP Method Definitions; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html + self.HTTPMethodsEncodingParametersInURI = [NSSet setWithObjects:@"GET", @"HEAD", @"DELETE", nil]; + + self.mutableObservedChangedKeyPaths = [NSMutableSet set]; + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:AFHTTPRequestSerializerObserverContext]; + } + } + + return self; +} + +- (void)dealloc { + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self removeObserver:self forKeyPath:keyPath context:AFHTTPRequestSerializerObserverContext]; + } + } +} + +#pragma mark - + +// Workarounds for crashing behavior using Key-Value Observing with XCTest +// See https://github.com/AFNetworking/AFNetworking/issues/2523 + +- (void)setAllowsCellularAccess:(BOOL)allowsCellularAccess { + [self willChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))]; + _allowsCellularAccess = allowsCellularAccess; + [self didChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))]; +} + +- (void)setCachePolicy:(NSURLRequestCachePolicy)cachePolicy { + [self willChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))]; + _cachePolicy = cachePolicy; + [self didChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))]; +} + +- (void)setHTTPShouldHandleCookies:(BOOL)HTTPShouldHandleCookies { + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))]; + _HTTPShouldHandleCookies = HTTPShouldHandleCookies; + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))]; +} + +- (void)setHTTPShouldUsePipelining:(BOOL)HTTPShouldUsePipelining { + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))]; + _HTTPShouldUsePipelining = HTTPShouldUsePipelining; + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))]; +} + +- (void)setNetworkServiceType:(NSURLRequestNetworkServiceType)networkServiceType { + [self willChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))]; + _networkServiceType = networkServiceType; + [self didChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))]; +} + +- (void)setTimeoutInterval:(NSTimeInterval)timeoutInterval { + [self willChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))]; + _timeoutInterval = timeoutInterval; + [self didChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))]; +} + +#pragma mark - + +- (NSDictionary *)HTTPRequestHeaders { + NSDictionary __block *value; + dispatch_sync(self.requestHeaderModificationQueue, ^{ + value = [NSDictionary dictionaryWithDictionary:self.mutableHTTPRequestHeaders]; + }); + return value; +} + +- (void)setValue:(NSString *)value +forHTTPHeaderField:(NSString *)field +{ + dispatch_barrier_sync(self.requestHeaderModificationQueue, ^{ + [self.mutableHTTPRequestHeaders setValue:value forKey:field]; + }); +} + +- (NSString *)valueForHTTPHeaderField:(NSString *)field { + NSString __block *value; + dispatch_sync(self.requestHeaderModificationQueue, ^{ + value = [self.mutableHTTPRequestHeaders valueForKey:field]; + }); + return value; +} + +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password +{ + NSData *basicAuthCredentials = [[NSString stringWithFormat:@"%@:%@", username, password] dataUsingEncoding:NSUTF8StringEncoding]; + NSString *base64AuthCredentials = [basicAuthCredentials base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)0]; + [self setValue:[NSString stringWithFormat:@"Basic %@", base64AuthCredentials] forHTTPHeaderField:@"Authorization"]; +} + +- (void)clearAuthorizationHeader { + dispatch_barrier_sync(self.requestHeaderModificationQueue, ^{ + [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"]; + }); +} + +#pragma mark - + +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style { + self.queryStringSerializationStyle = style; + self.queryStringSerialization = nil; +} + +- (void)setQueryStringSerializationWithBlock:(NSString *(^)(NSURLRequest *, id, NSError *__autoreleasing *))block { + self.queryStringSerialization = block; +} + +#pragma mark - + +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(URLString); + + NSURL *url = [NSURL URLWithString:URLString]; + + NSParameterAssert(url); + + NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url]; + mutableRequest.HTTPMethod = method; + + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self.mutableObservedChangedKeyPaths containsObject:keyPath]) { + [mutableRequest setValue:[self valueForKeyPath:keyPath] forKey:keyPath]; + } + } + + mutableRequest = [[self requestBySerializingRequest:mutableRequest withParameters:parameters error:error] mutableCopy]; + + return mutableRequest; +} + +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]); + + NSMutableURLRequest *mutableRequest = [self requestWithMethod:method URLString:URLString parameters:nil error:error]; + + __block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:mutableRequest stringEncoding:NSUTF8StringEncoding]; + + if (parameters) { + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + NSData *data = nil; + if ([pair.value isKindOfClass:[NSData class]]) { + data = pair.value; + } else if ([pair.value isEqual:[NSNull null]]) { + data = [NSData data]; + } else { + data = [[pair.value description] dataUsingEncoding:self.stringEncoding]; + } + + if (data) { + [formData appendPartWithFormData:data name:[pair.field description]]; + } + } + } + + if (block) { + block(formData); + } + + return [formData requestByFinalizingMultipartFormData]; +} + +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(void (^)(NSError *error))handler +{ + NSParameterAssert(request.HTTPBodyStream); + NSParameterAssert([fileURL isFileURL]); + + NSInputStream *inputStream = request.HTTPBodyStream; + NSOutputStream *outputStream = [[NSOutputStream alloc] initWithURL:fileURL append:NO]; + __block NSError *error = nil; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + + [inputStream open]; + [outputStream open]; + + while ([inputStream hasBytesAvailable] && [outputStream hasSpaceAvailable]) { + uint8_t buffer[1024]; + + NSInteger bytesRead = [inputStream read:buffer maxLength:1024]; + if (inputStream.streamError || bytesRead < 0) { + error = inputStream.streamError; + break; + } + + NSInteger bytesWritten = [outputStream write:buffer maxLength:(NSUInteger)bytesRead]; + if (outputStream.streamError || bytesWritten < 0) { + error = outputStream.streamError; + break; + } + + if (bytesRead == 0 && bytesWritten == 0) { + break; + } + } + + [outputStream close]; + [inputStream close]; + + if (handler) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler(error); + }); + } + }); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + mutableRequest.HTTPBodyStream = nil; + + return mutableRequest; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + NSString *query = nil; + if (parameters) { + if (self.queryStringSerialization) { + NSError *serializationError; + query = self.queryStringSerialization(request, parameters, &serializationError); + + if (serializationError) { + if (error) { + *error = serializationError; + } + + return nil; + } + } else { + switch (self.queryStringSerializationStyle) { + case AFHTTPRequestQueryStringDefaultStyle: + query = AFQueryStringFromParameters(parameters); + break; + } + } + } + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + if (query && query.length > 0) { + mutableRequest.URL = [NSURL URLWithString:[[mutableRequest.URL absoluteString] stringByAppendingFormat:mutableRequest.URL.query ? @"&%@" : @"?%@", query]]; + } + } else { + // #2864: an empty string is a valid x-www-form-urlencoded payload + if (!query) { + query = @""; + } + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; + } + [mutableRequest setHTTPBody:[query dataUsingEncoding:self.stringEncoding]]; + } + + return mutableRequest; +} + +#pragma mark - NSKeyValueObserving + ++ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key { + if ([AFHTTPRequestSerializerObservedKeyPaths() containsObject:key]) { + return NO; + } + + return [super automaticallyNotifiesObserversForKey:key]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(__unused id)object + change:(NSDictionary *)change + context:(void *)context +{ + if (context == AFHTTPRequestSerializerObserverContext) { + if ([change[NSKeyValueChangeNewKey] isEqual:[NSNull null]]) { + [self.mutableObservedChangedKeyPaths removeObject:keyPath]; + } else { + [self.mutableObservedChangedKeyPaths addObject:keyPath]; + } + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.mutableHTTPRequestHeaders = [[decoder decodeObjectOfClass:[NSDictionary class] forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))] mutableCopy]; + self.queryStringSerializationStyle = (AFHTTPRequestQueryStringSerializationStyle)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + dispatch_sync(self.requestHeaderModificationQueue, ^{ + [coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))]; + }); + [coder encodeObject:@(self.queryStringSerializationStyle) forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFHTTPRequestSerializer *serializer = [[[self class] allocWithZone:zone] init]; + dispatch_sync(self.requestHeaderModificationQueue, ^{ + serializer.mutableHTTPRequestHeaders = [self.mutableHTTPRequestHeaders mutableCopyWithZone:zone]; + }); + serializer.queryStringSerializationStyle = self.queryStringSerializationStyle; + serializer.queryStringSerialization = self.queryStringSerialization; + + return serializer; +} + +@end + +#pragma mark - + +static NSString * AFCreateMultipartFormBoundary() { + return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()]; +} + +static NSString * const kAFMultipartFormCRLF = @"\r\n"; + +static inline NSString * AFMultipartFormInitialBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"--%@%@", boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormEncapsulationBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormFinalBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@--%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFContentTypeForPathExtension(NSString *extension) { + NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL); + NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType); + if (!contentType) { + return @"application/octet-stream"; + } else { + return contentType; + } +} + +NSUInteger const kAFUploadStream3GSuggestedPacketSize = 1024 * 16; +NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; + +@interface AFHTTPBodyPart : NSObject +@property (nonatomic, assign) NSStringEncoding stringEncoding; +@property (nonatomic, strong) NSDictionary *headers; +@property (nonatomic, copy) NSString *boundary; +@property (nonatomic, strong) id body; +@property (nonatomic, assign) unsigned long long bodyContentLength; +@property (nonatomic, strong) NSInputStream *inputStream; + +@property (nonatomic, assign) BOOL hasInitialBoundary; +@property (nonatomic, assign) BOOL hasFinalBoundary; + +@property (readonly, nonatomic, assign, getter = hasBytesAvailable) BOOL bytesAvailable; +@property (readonly, nonatomic, assign) unsigned long long contentLength; + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@interface AFMultipartBodyStream : NSInputStream +@property (nonatomic, assign) NSUInteger numberOfBytesInPacket; +@property (nonatomic, assign) NSTimeInterval delay; +@property (nonatomic, strong) NSInputStream *inputStream; +@property (readonly, nonatomic, assign) unsigned long long contentLength; +@property (readonly, nonatomic, assign, getter = isEmpty) BOOL empty; + +- (instancetype)initWithStringEncoding:(NSStringEncoding)encoding; +- (void)setInitialAndFinalBoundaries; +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart; +@end + +#pragma mark - + +@interface AFStreamingMultipartFormData () +@property (readwrite, nonatomic, copy) NSMutableURLRequest *request; +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, copy) NSString *boundary; +@property (readwrite, nonatomic, strong) AFMultipartBodyStream *bodyStream; +@end + +@implementation AFStreamingMultipartFormData + +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding +{ + self = [super init]; + if (!self) { + return nil; + } + + self.request = urlRequest; + self.stringEncoding = encoding; + self.boundary = AFCreateMultipartFormBoundary(); + self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding]; + + return self; +} + +- (void)setRequest:(NSMutableURLRequest *)request +{ + _request = [request mutableCopy]; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + + NSString *fileName = [fileURL lastPathComponent]; + NSString *mimeType = AFContentTypeForPathExtension([fileURL pathExtension]); + + return [self appendPartWithFileURL:fileURL name:name fileName:fileName mimeType:mimeType error:error]; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + if (![fileURL isFileURL]) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } + + NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:error]; + if (!fileAttributes) { + return NO; + } + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = fileURL; + bodyPart.bodyContentLength = [fileAttributes[NSFileSize] unsignedLongLongValue]; + [self.bodyStream appendHTTPBodyPart:bodyPart]; + + return YES; +} + +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = inputStream; + + bodyPart.bodyContentLength = (unsigned long long)length; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name +{ + NSParameterAssert(name); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithHeaders:(NSDictionary *)headers + body:(NSData *)body +{ + NSParameterAssert(body); + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = headers; + bodyPart.boundary = self.boundary; + bodyPart.bodyContentLength = [body length]; + bodyPart.body = body; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay +{ + self.bodyStream.numberOfBytesInPacket = numberOfBytes; + self.bodyStream.delay = delay; +} + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData { + if ([self.bodyStream isEmpty]) { + return self.request; + } + + // Reset the initial and final boundaries to ensure correct Content-Length + [self.bodyStream setInitialAndFinalBoundaries]; + [self.request setHTTPBodyStream:self.bodyStream]; + + [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary] forHTTPHeaderField:@"Content-Type"]; + [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"]; + + return self.request; +} + +@end + +#pragma mark - + +@interface NSStream () +@property (readwrite) NSStreamStatus streamStatus; +@property (readwrite, copy) NSError *streamError; +@end + +@interface AFMultipartBodyStream () +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, strong) NSMutableArray *HTTPBodyParts; +@property (readwrite, nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator; +@property (readwrite, nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart; +@property (readwrite, nonatomic, strong) NSOutputStream *outputStream; +@property (readwrite, nonatomic, strong) NSMutableData *buffer; +@end + +@implementation AFMultipartBodyStream +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1100) +@synthesize delegate; +#endif +@synthesize streamStatus; +@synthesize streamError; + +- (instancetype)initWithStringEncoding:(NSStringEncoding)encoding { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = encoding; + self.HTTPBodyParts = [NSMutableArray array]; + self.numberOfBytesInPacket = NSIntegerMax; + + return self; +} + +- (void)setInitialAndFinalBoundaries { + if ([self.HTTPBodyParts count] > 0) { + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + bodyPart.hasInitialBoundary = NO; + bodyPart.hasFinalBoundary = NO; + } + + [[self.HTTPBodyParts firstObject] setHasInitialBoundary:YES]; + [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES]; + } +} + +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart { + [self.HTTPBodyParts addObject:bodyPart]; +} + +- (BOOL)isEmpty { + return [self.HTTPBodyParts count] == 0; +} + +#pragma mark - NSInputStream + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + if ([self streamStatus] == NSStreamStatusClosed) { + return 0; + } + + NSInteger totalNumberOfBytesRead = 0; + + while ((NSUInteger)totalNumberOfBytesRead < MIN(length, self.numberOfBytesInPacket)) { + if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) { + if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) { + break; + } + } else { + NSUInteger maxLength = MIN(length, self.numberOfBytesInPacket) - (NSUInteger)totalNumberOfBytesRead; + NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:&buffer[totalNumberOfBytesRead] maxLength:maxLength]; + if (numberOfBytesRead == -1) { + self.streamError = self.currentHTTPBodyPart.inputStream.streamError; + break; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if (self.delay > 0.0f) { + [NSThread sleepForTimeInterval:self.delay]; + } + } + } + } + + return totalNumberOfBytesRead; +} + +- (BOOL)getBuffer:(__unused uint8_t **)buffer + length:(__unused NSUInteger *)len +{ + return NO; +} + +- (BOOL)hasBytesAvailable { + return [self streamStatus] == NSStreamStatusOpen; +} + +#pragma mark - NSStream + +- (void)open { + if (self.streamStatus == NSStreamStatusOpen) { + return; + } + + self.streamStatus = NSStreamStatusOpen; + + [self setInitialAndFinalBoundaries]; + self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; +} + +- (void)close { + self.streamStatus = NSStreamStatusClosed; +} + +- (id)propertyForKey:(__unused NSString *)key { + return nil; +} + +- (BOOL)setProperty:(__unused id)property + forKey:(__unused NSString *)key +{ + return NO; +} + +- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + length += [bodyPart contentLength]; + } + + return length; +} + +#pragma mark - Undocumented CFReadStream Bridged Methods + +- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags + callback:(__unused CFReadStreamClientCallBack)inCallback + context:(__unused CFStreamClientContext *)inContext { + return NO; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; + + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + [bodyStreamCopy appendHTTPBodyPart:[bodyPart copy]]; + } + + [bodyStreamCopy setInitialAndFinalBoundaries]; + + return bodyStreamCopy; +} + +@end + +#pragma mark - + +typedef enum { + AFEncapsulationBoundaryPhase = 1, + AFHeaderPhase = 2, + AFBodyPhase = 3, + AFFinalBoundaryPhase = 4, +} AFHTTPBodyPartReadPhase; + +@interface AFHTTPBodyPart () { + AFHTTPBodyPartReadPhase _phase; + NSInputStream *_inputStream; + unsigned long long _phaseReadOffset; +} + +- (BOOL)transitionToNextPhase; +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@implementation AFHTTPBodyPart + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + [self transitionToNextPhase]; + + return self; +} + +- (void)dealloc { + if (_inputStream) { + [_inputStream close]; + _inputStream = nil; + } +} + +- (NSInputStream *)inputStream { + if (!_inputStream) { + if ([self.body isKindOfClass:[NSData class]]) { + _inputStream = [NSInputStream inputStreamWithData:self.body]; + } else if ([self.body isKindOfClass:[NSURL class]]) { + _inputStream = [NSInputStream inputStreamWithURL:self.body]; + } else if ([self.body isKindOfClass:[NSInputStream class]]) { + _inputStream = self.body; + } else { + _inputStream = [NSInputStream inputStreamWithData:[NSData data]]; + } + } + + return _inputStream; +} + +- (NSString *)stringForHeaders { + NSMutableString *headerString = [NSMutableString string]; + for (NSString *field in [self.headers allKeys]) { + [headerString appendString:[NSString stringWithFormat:@"%@: %@%@", field, [self.headers valueForKey:field], kAFMultipartFormCRLF]]; + } + [headerString appendString:kAFMultipartFormCRLF]; + + return [NSString stringWithString:headerString]; +} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + length += [encapsulationBoundaryData length]; + + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + length += [headersData length]; + + length += _bodyContentLength; + + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + length += [closingBoundaryData length]; + + return length; +} + +- (BOOL)hasBytesAvailable { + // Allows `read:maxLength:` to be called again if `AFMultipartFormFinalBoundary` doesn't fit into the available buffer + if (_phase == AFFinalBoundaryPhase) { + return YES; + } + + switch (self.inputStream.streamStatus) { + case NSStreamStatusNotOpen: + case NSStreamStatusOpening: + case NSStreamStatusOpen: + case NSStreamStatusReading: + case NSStreamStatusWriting: + return YES; + case NSStreamStatusAtEnd: + case NSStreamStatusClosed: + case NSStreamStatusError: + default: + return NO; + } +} + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + NSInteger totalNumberOfBytesRead = 0; + + if (_phase == AFEncapsulationBoundaryPhase) { + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFHeaderPhase) { + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:headersData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFBodyPhase) { + NSInteger numberOfBytesRead = 0; + + numberOfBytesRead = [self.inputStream read:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + if (numberOfBytesRead == -1) { + return -1; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if ([self.inputStream streamStatus] >= NSStreamStatusAtEnd) { + [self transitionToNextPhase]; + } + } + } + + if (_phase == AFFinalBoundaryPhase) { + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + totalNumberOfBytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + return totalNumberOfBytesRead; +} + +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length)); + [data getBytes:buffer range:range]; + + _phaseReadOffset += range.length; + + if (((NSUInteger)_phaseReadOffset) >= [data length]) { + [self transitionToNextPhase]; + } + + return (NSInteger)range.length; +} + +- (BOOL)transitionToNextPhase { + if (![[NSThread currentThread] isMainThread]) { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self transitionToNextPhase]; + }); + return YES; + } + + switch (_phase) { + case AFEncapsulationBoundaryPhase: + _phase = AFHeaderPhase; + break; + case AFHeaderPhase: + [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; + [self.inputStream open]; + _phase = AFBodyPhase; + break; + case AFBodyPhase: + [self.inputStream close]; + _phase = AFFinalBoundaryPhase; + break; + case AFFinalBoundaryPhase: + default: + _phase = AFEncapsulationBoundaryPhase; + break; + } + _phaseReadOffset = 0; + + return YES; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init]; + + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = self.headers; + bodyPart.bodyContentLength = self.bodyContentLength; + bodyPart.body = self.body; + bodyPart.boundary = self.boundary; + + return bodyPart; +} + +@end + +#pragma mark - + +@implementation AFJSONRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithWritingOptions:(NSJSONWritingOptions)0]; +} + ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions +{ + AFJSONRequestSerializer *serializer = [[self alloc] init]; + serializer.writingOptions = writingOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + } + + if (![NSJSONSerialization isValidJSONObject:parameters]) { + if (error) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"The `parameters` argument is not valid JSON.", @"AFNetworking", nil)}; + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo]; + } + return nil; + } + + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:self.writingOptions error:error]; + + if (!jsonData) { + return nil; + } + + [mutableRequest setHTTPBody:jsonData]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.writingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writingOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.writingOptions) forKey:NSStringFromSelector(@selector(writingOptions))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFJSONRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.writingOptions = self.writingOptions; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFPropertyListRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 writeOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions +{ + AFPropertyListRequestSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.writeOptions = writeOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerializer + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-plist" forHTTPHeaderField:@"Content-Type"]; + } + + NSData *plistData = [NSPropertyListSerialization dataWithPropertyList:parameters format:self.format options:self.writeOptions error:error]; + + if (!plistData) { + return nil; + } + + [mutableRequest setHTTPBody:plistData]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.writeOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writeOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFPropertyListRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.format = self.format; + serializer.writeOptions = self.writeOptions; + + return serializer; +} + +@end diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h new file mode 100644 index 0000000000000000000000000000000000000000..56a4d28ae1a49b7b04a08b6411ae16b74e5dc53e --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1,313 @@ +// AFURLResponseSerialization.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + Recursively removes `NSNull` values from a JSON object. +*/ +FOUNDATION_EXPORT id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions); + +/** + The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data. + + For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object. + */ +@protocol AFURLResponseSerialization + +/** + The response object decoded from the data associated with a specified response. + + @param response The response to be processed. + @param data The response data to be decoded. + @param error The error that occurred while attempting to decode the response data. + + @return The object decoded from the specified response data. + */ +- (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response + data:(nullable NSData *)data + error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW; + +@end + +#pragma mark - + +/** + `AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPResponseSerializer : NSObject + +- (instancetype)init; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +///----------------------------------------- +/// @name Configuring Response Serialization +///----------------------------------------- + +/** + The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation. + + See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html + */ +@property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes; + +/** + The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation. + */ +@property (nonatomic, copy, nullable) NSSet *acceptableContentTypes; + +/** + Validates the specified response and data. + + In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks. + + @param response The response to be validated. + @param data The data associated with the response. + @param error The error that occurred while attempting to validate the response. + + @return `YES` if the response is valid, otherwise `NO`. + */ +- (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response + data:(nullable NSData *)data + error:(NSError * _Nullable __autoreleasing *)error; + +@end + +#pragma mark - + + +/** + `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses. + + By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: + + - `application/json` + - `text/json` + - `text/javascript` + + In RFC 7159 - Section 8.1, it states that JSON text is required to be encoded in UTF-8, UTF-16, or UTF-32, and the default encoding is UTF-8. NSJSONSerialization provides support for all the encodings listed in the specification, and recommends UTF-8 for efficiency. Using an unsupported encoding will result in serialization error. See the `NSJSONSerialization` documentation for more details. + */ +@interface AFJSONResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONReadingOptions readingOptions; + +/** + Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL removesKeysWithNullValues; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param readingOptions The specified JSON reading options. + */ ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions; + +@end + +#pragma mark - + +/** + `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects. + + By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +/** + `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSXMLDocument` documentation section "Input and Output Options". `0` by default. + */ +@property (nonatomic, assign) NSUInteger options; + +/** + Creates and returns an XML document serializer with the specified options. + + @param mask The XML document options. + */ ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask; + +@end + +#endif + +#pragma mark - + +/** + `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFPropertyListResponseSerializer` accepts the following MIME types: + + - `application/x-plist` + */ +@interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions." + */ +@property (nonatomic, assign) NSPropertyListReadOptions readOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param readOptions The property list reading options. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions; + +@end + +#pragma mark - + +/** + `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses. + + By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: + + - `image/tiff` + - `image/jpeg` + - `image/gif` + - `image/png` + - `image/ico` + - `image/x-icon` + - `image/bmp` + - `image/x-bmp` + - `image/x-xbitmap` + - `image/x-win-bitmap` + */ +@interface AFImageResponseSerializer : AFHTTPResponseSerializer + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH +/** + The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance. + */ +@property (nonatomic, assign) CGFloat imageScale; + +/** + Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default. + */ +@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage; +#endif + +@end + +#pragma mark - + +/** + `AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer. + */ +@interface AFCompoundResponseSerializer : AFHTTPResponseSerializer + +/** + The component response serializers. + */ +@property (readonly, nonatomic, copy) NSArray > *responseSerializers; + +/** + Creates and returns a compound serializer comprised of the specified response serializers. + + @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`. + */ ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray > *)responseSerializers; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLResponseSerializationErrorDomain` + + ### Constants + + `AFURLResponseSerializationErrorDomain` + AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` + - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLResponseErrorKey` + The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + + `AFNetworkingOperationFailingURLResponseDataErrorKey` + The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey; + +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey; + +NS_ASSUME_NONNULL_END diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m new file mode 100644 index 0000000000000000000000000000000000000000..2715a1b319804bc4976ae46317c900910d7c8289 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m @@ -0,0 +1,836 @@ +// AFURLResponseSerialization.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLResponseSerialization.h" + +#import + +#if TARGET_OS_IOS +#import +#elif TARGET_OS_WATCH +#import +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +#import +#endif + +NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response"; +NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response"; +NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data"; + +static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) { + if (!error) { + return underlyingError; + } + + if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) { + return error; + } + + NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy]; + mutableUserInfo[NSUnderlyingErrorKey] = underlyingError; + + return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo]; +} + +static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) { + if ([error.domain isEqualToString:domain] && error.code == code) { + return YES; + } else if (error.userInfo[NSUnderlyingErrorKey]) { + return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain); + } + + return NO; +} + +id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) { + if ([JSONObject isKindOfClass:[NSArray class]]) { + NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]]; + for (id value in (NSArray *)JSONObject) { + if (![value isEqual:[NSNull null]]) { + [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)]; + } + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray]; + } else if ([JSONObject isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject]; + for (id key in [(NSDictionary *)JSONObject allKeys]) { + id value = (NSDictionary *)JSONObject[key]; + if (!value || [value isEqual:[NSNull null]]) { + [mutableDictionary removeObjectForKey:key]; + } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) { + mutableDictionary[key] = AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions); + } + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary]; + } + + return JSONObject; +} + +@implementation AFHTTPResponseSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)]; + self.acceptableContentTypes = nil; + + return self; +} + +#pragma mark - + +- (BOOL)validateResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError * __autoreleasing *)error +{ + BOOL responseIsValid = YES; + NSError *validationError = nil; + + if ([response isKindOfClass:[NSHTTPURLResponse class]]) { + if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]] && + !([response MIMEType] == nil && [data length] == 0)) { + + if ([data length] > 0 && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError); + } + + responseIsValid = NO; + } + + if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError); + + responseIsValid = NO; + } + } + + if (error && !responseIsValid) { + *error = validationError; + } + + return responseIsValid; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + [self validateResponse:(NSHTTPURLResponse *)response data:data error:error]; + + return data; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + [coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone]; + serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone]; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFJSONResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithReadingOptions:(NSJSONReadingOptions)0]; +} + ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions { + AFJSONResponseSerializer *serializer = [[self alloc] init]; + serializer.readingOptions = readingOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + // Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization. + // See https://github.com/rails/rails/issues/1742 + BOOL isSpace = [data isEqualToData:[NSData dataWithBytes:" " length:1]]; + + if (data.length == 0 || isSpace) { + return nil; + } + + NSError *serializationError = nil; + + id responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError]; + + if (!responseObject) + { + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + return nil; + } + + if (self.removesKeysWithNullValues) { + return AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue]; + self.removesKeysWithNullValues = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))] boolValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))]; + [coder encodeObject:@(self.removesKeysWithNullValues) forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFJSONResponseSerializer *serializer = [super copyWithZone:zone]; + serializer.readingOptions = self.readingOptions; + serializer.removesKeysWithNullValues = self.removesKeysWithNullValues; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFXMLParserResponseSerializer + ++ (instancetype)serializer { + AFXMLParserResponseSerializer *serializer = [[self alloc] init]; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + return [[NSXMLParser alloc] initWithData:data]; +} + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +@implementation AFXMLDocumentResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithXMLDocumentOptions:0]; +} + ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask { + AFXMLDocumentResponseSerializer *serializer = [[self alloc] init]; + serializer.options = mask; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + NSError *serializationError = nil; + NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError]; + + if (!document) + { + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + return nil; + } + + return document; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFXMLDocumentResponseSerializer *serializer = [super copyWithZone:zone]; + serializer.options = self.options; + + return serializer; +} + +@end + +#endif + +#pragma mark - + +@implementation AFPropertyListResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions +{ + AFPropertyListResponseSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.readOptions = readOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + if (!data) { + return nil; + } + + NSError *serializationError = nil; + + id responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError]; + + if (!responseObject) + { + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + return nil; + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFPropertyListResponseSerializer *serializer = [super copyWithZone:zone]; + serializer.format = self.format; + serializer.readOptions = self.readOptions; + + return serializer; +} + +@end + +#pragma mark - + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH +#import +#import + +@interface UIImage (AFNetworkingSafeImageLoading) ++ (UIImage *)af_safeImageWithData:(NSData *)data; +@end + +static NSLock* imageLock = nil; + +@implementation UIImage (AFNetworkingSafeImageLoading) + ++ (UIImage *)af_safeImageWithData:(NSData *)data { + UIImage* image = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + imageLock = [[NSLock alloc] init]; + }); + + [imageLock lock]; + image = [UIImage imageWithData:data]; + [imageLock unlock]; + return image; +} + +@end + +static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) { + UIImage *image = [UIImage af_safeImageWithData:data]; + if (image.images) { + return image; + } + + return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation]; +} + +static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) { + if (!data || [data length] == 0) { + return nil; + } + + CGImageRef imageRef = NULL; + CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data); + + if ([response.MIMEType isEqualToString:@"image/png"]) { + imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + } else if ([response.MIMEType isEqualToString:@"image/jpeg"]) { + imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + + if (imageRef) { + CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef); + CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace); + + // CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so fall back to AFImageWithDataAtScale + if (imageColorSpaceModel == kCGColorSpaceModelCMYK) { + CGImageRelease(imageRef); + imageRef = NULL; + } + } + } + + CGDataProviderRelease(dataProvider); + + UIImage *image = AFImageWithDataAtScale(data, scale); + if (!imageRef) { + if (image.images || !image) { + return image; + } + + imageRef = CGImageCreateCopy([image CGImage]); + if (!imageRef) { + return nil; + } + } + + size_t width = CGImageGetWidth(imageRef); + size_t height = CGImageGetHeight(imageRef); + size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef); + + if (width * height > 1024 * 1024 || bitsPerComponent > 8) { + CGImageRelease(imageRef); + + return image; + } + + // CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate + size_t bytesPerRow = 0; + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace); + CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); + + if (colorSpaceModel == kCGColorSpaceModelRGB) { + uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wassign-enum" + if (alpha == kCGImageAlphaNone) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaNoneSkipFirst; + } else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaPremultipliedFirst; + } +#pragma clang diagnostic pop + } + + CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo); + + CGColorSpaceRelease(colorSpace); + + if (!context) { + CGImageRelease(imageRef); + + return image; + } + + CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef); + CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context); + + CGContextRelease(context); + + UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation]; + + CGImageRelease(inflatedImageRef); + CGImageRelease(imageRef); + + return inflatedImage; +} +#endif + + +@implementation AFImageResponseSerializer + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap", nil]; + +#if TARGET_OS_IOS || TARGET_OS_TV + self.imageScale = [[UIScreen mainScreen] scale]; + self.automaticallyInflatesResponseImage = YES; +#elif TARGET_OS_WATCH + self.imageScale = [[WKInterfaceDevice currentDevice] screenScale]; + self.automaticallyInflatesResponseImage = YES; +#endif + + return self; +} + +#pragma mark - AFURLResponseSerializer + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH + if (self.automaticallyInflatesResponseImage) { + return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale); + } else { + return AFImageWithDataAtScale(data, self.imageScale); + } +#else + // Ensure that the image is set to it's correct pixel width and height + NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data]; + NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])]; + [image addRepresentation:bitimage]; + + return image; +#endif + + return nil; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH + NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))]; +#if CGFLOAT_IS_DOUBLE + self.imageScale = [imageScale doubleValue]; +#else + self.imageScale = [imageScale floatValue]; +#endif + + self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH + [coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))]; + [coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFImageResponseSerializer *serializer = [super copyWithZone:zone]; + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH + serializer.imageScale = self.imageScale; + serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage; +#endif + + return serializer; +} + +@end + +#pragma mark - + +@interface AFCompoundResponseSerializer () +@property (readwrite, nonatomic, copy) NSArray *responseSerializers; +@end + +@implementation AFCompoundResponseSerializer + ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers { + AFCompoundResponseSerializer *serializer = [[self alloc] init]; + serializer.responseSerializers = responseSerializers; + + return serializer; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + for (id serializer in self.responseSerializers) { + if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) { + continue; + } + + NSError *serializerError = nil; + id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError]; + if (responseObject) { + if (error) { + *error = AFErrorWithUnderlyingError(serializerError, *error); + } + + return responseObject; + } + } + + return [super responseObjectForResponse:response data:data error:error]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + NSSet *classes = [NSSet setWithArray:@[[NSArray class], [AFHTTPResponseSerializer class]]]; + self.responseSerializers = [decoder decodeObjectOfClasses:classes forKey:NSStringFromSelector(@selector(responseSerializers))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFCompoundResponseSerializer *serializer = [super copyWithZone:zone]; + serializer.responseSerializers = self.responseSerializers; + + return serializer; +} + +@end diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h new file mode 100644 index 0000000000000000000000000000000000000000..88700c39a9d09733d2fd077a1af5bee786906afa --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h @@ -0,0 +1,516 @@ +// AFURLSessionManager.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import + +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" +#import "AFSecurityPolicy.h" +#import "AFCompatibilityMacros.h" +#if !TARGET_OS_WATCH +#import "AFNetworkReachabilityManager.h" +#endif + +/** + `AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + + ## Subclassing Notes + + This is the base class for `AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `AFURLSessionManager` specifically for HTTP, consider subclassing `AFHTTPSessionManager` instead. + + ## NSURLSession & NSURLSessionTask Delegate Methods + + `AFURLSessionManager` implements the following delegate methods: + + ### `NSURLSessionDelegate` + + - `URLSession:didBecomeInvalidWithError:` + - `URLSession:didReceiveChallenge:completionHandler:` + - `URLSessionDidFinishEventsForBackgroundURLSession:` + + ### `NSURLSessionTaskDelegate` + + - `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:` + - `URLSession:task:didReceiveChallenge:completionHandler:` + - `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:` + - `URLSession:task:needNewBodyStream:` + - `URLSession:task:didCompleteWithError:` + + ### `NSURLSessionDataDelegate` + + - `URLSession:dataTask:didReceiveResponse:completionHandler:` + - `URLSession:dataTask:didBecomeDownloadTask:` + - `URLSession:dataTask:didReceiveData:` + - `URLSession:dataTask:willCacheResponse:completionHandler:` + + ### `NSURLSessionDownloadDelegate` + + - `URLSession:downloadTask:didFinishDownloadingToURL:` + - `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:` + - `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:` + + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. + + ## Network Reachability Monitoring + + Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details. + + ## NSCoding Caveats + + - Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`. + + ## NSCopying Caveats + + - `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original. + - Operation copies do not include any delegate callback blocks, as they often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ session manager when copied. + + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFURLSessionManager : NSObject + +/** + The managed session. + */ +@property (readonly, nonatomic, strong) NSURLSession *session; + +/** + The operation queue on which delegate callbacks are run. + */ +@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) id responseSerializer; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +#if !TARGET_OS_WATCH +///-------------------------------------- +/// @name Monitoring Network Reachability +///-------------------------------------- + +/** + The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default. + */ +@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; +#endif + +///---------------------------- +/// @name Getting Session Tasks +///---------------------------- + +/** + The data, upload, and download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *tasks; + +/** + The data tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *dataTasks; + +/** + The upload tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *uploadTasks; + +/** + The download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *downloadTasks; + +///------------------------------- +/// @name Managing Callback Queues +///------------------------------- + +/** + The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. + */ +@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue; + +/** + The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. + */ +@property (nonatomic, strong, nullable) dispatch_group_t completionGroup; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a manager for a session created with the specified configuration. This is the designated initializer. + + @param configuration The configuration used to create the managed session. + + @return A manager for a newly-created session. + */ +- (instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; + +/** + Invalidates the managed session, optionally canceling pending tasks and optionally resets given session. + + @param cancelPendingTasks Whether or not to cancel pending tasks. + @param resetSession Whether or not to reset the session of the manager. + */ +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks resetSession:(BOOL)resetSession; + +///------------------------- +/// @name Running Data Tasks +///------------------------- + +/** + Creates an `NSURLSessionDataTask` with the specified request. + + @param request The HTTP request for the request. + @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + uploadProgress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock + downloadProgress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +///--------------------------- +/// @name Running Upload Tasks +///--------------------------- + +/** + Creates an `NSURLSessionUploadTask` with the specified request for a local file. + + @param request The HTTP request for the request. + @param fileURL A URL to the local file to be uploaded. + @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + + @see `attemptsToRecreateUploadTasksForBackgroundSessions` + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified request for an HTTP body. + + @param request The HTTP request for the request. + @param bodyData A data object containing the HTTP body to be uploaded. + @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(nullable NSData *)bodyData + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified streaming request. + + @param request The HTTP request for the request. + @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +///----------------------------- +/// @name Running Download Tasks +///----------------------------- + +/** + Creates an `NSURLSessionDownloadTask` with the specified request. + + @param request The HTTP request for the request. + @param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. + + @warning If using a background `NSURLSessionConfiguration` on iOS, these blocks will be lost when the app is terminated. Background sessions may prefer to use `-setDownloadTaskDidFinishDownloadingBlock:` to specify the URL for saving the downloaded file, rather than the destination block of this method. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock + destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler; + +/** + Creates an `NSURLSessionDownloadTask` with the specified resume data. + + @param resumeData The data used to resume downloading. + @param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock + destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler; + +///--------------------------------- +/// @name Getting Progress for Tasks +///--------------------------------- + +/** + Returns the upload progress of the specified task. + + @param task The session task. Must not be `nil`. + + @return An `NSProgress` object reporting the upload progress of a task, or `nil` if the progress is unavailable. + */ +- (nullable NSProgress *)uploadProgressForTask:(NSURLSessionTask *)task; + +/** + Returns the download progress of the specified task. + + @param task The session task. Must not be `nil`. + + @return An `NSProgress` object reporting the download progress of a task, or `nil` if the progress is unavailable. + */ +- (nullable NSProgress *)downloadProgressForTask:(NSURLSessionTask *)task; + +///----------------------------------------- +/// @name Setting Session Delegate Callbacks +///----------------------------------------- + +/** + Sets a block to be executed when the managed session becomes invalid, as handled by the `NSURLSessionDelegate` method `URLSession:didBecomeInvalidWithError:`. + + @param block A block object to be executed when the managed session becomes invalid. The block has no return value, and takes two arguments: the session, and the error related to the cause of invalidation. + */ +- (void)setSessionDidBecomeInvalidBlock:(nullable void (^)(NSURLSession *session, NSError *error))block; + +/** + Sets a block to be executed when a connection level authentication challenge has occurred, as handled by the `NSURLSessionDelegate` method `URLSession:didReceiveChallenge:completionHandler:`. + + @param block A block object to be executed when a connection level authentication challenge has occurred. The block returns the disposition of the authentication challenge, and takes three arguments: the session, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. + + @warning Implementing a session authentication challenge handler yourself totally bypasses AFNetworking's security policy defined in `AFSecurityPolicy`. Make sure you fully understand the implications before implementing a custom session authentication challenge handler. If you do not want to bypass AFNetworking's security policy, use `setTaskDidReceiveAuthenticationChallengeBlock:` instead. + + @see -securityPolicy + @see -setTaskDidReceiveAuthenticationChallengeBlock: + */ +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block; + +///-------------------------------------- +/// @name Setting Task Delegate Callbacks +///-------------------------------------- + +/** + Sets a block to be executed when a task requires a new request body stream to send to the remote server, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:needNewBodyStream:`. + + @param block A block object to be executed when a task requires a new request body stream. + */ +- (void)setTaskNeedNewBodyStreamBlock:(nullable NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block; + +/** + Sets a block to be executed when an HTTP request is attempting to perform a redirection to a different URL, as handled by the `NSURLSessionTaskDelegate` method `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`. + + @param block A block object to be executed when an HTTP request is attempting to perform a redirection to a different URL. The block returns the request to be made for the redirection, and takes four arguments: the session, the task, the redirection response, and the request corresponding to the redirection response. + */ +- (void)setTaskWillPerformHTTPRedirectionBlock:(nullable NSURLRequest * _Nullable (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block; + +/** + Sets a block to be executed when a session task has received a request specific authentication challenge, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didReceiveChallenge:completionHandler:`. + + @param authenticationChallengeHandler A block object to be executed when a session task has received a request specific authentication challenge. + + When implementing an authentication challenge handler, you should check the authentication method first (`challenge.protectionSpace.authenticationMethod `) to decide if you want to handle the authentication challenge yourself or if you want AFNetworking to handle it. If you want AFNetworking to handle the authentication challenge, just return `@(NSURLSessionAuthChallengePerformDefaultHandling)`. For example, you certainly want AFNetworking to handle certificate validation (i.e. authentication method == `NSURLAuthenticationMethodServerTrust`) as defined by the security policy. If you want to handle the challenge yourself, you have four options: + + 1. Return `nil` from the authentication challenge handler. You **MUST** call the completion handler with a disposition and credentials yourself. Use this if you need to present a user interface to let the user enter their credentials. + 2. Return an `NSError` object from the authentication challenge handler. You **MUST NOT** call the completion handler when returning an `NSError `. The returned error will be reported in the completion handler of the task. Use this if you need to abort an authentication challenge with a specific error. + 3. Return an `NSURLCredential` object from the authentication challenge handler. You **MUST NOT** call the completion handler when returning an `NSURLCredential`. The returned credentials will be used to fulfil the challenge. Use this when you can get credentials without presenting a user interface. + 4. Return an `NSNumber` object wrapping an `NSURLSessionAuthChallengeDisposition`. Supported values are `@(NSURLSessionAuthChallengePerformDefaultHandling)`, `@(NSURLSessionAuthChallengeCancelAuthenticationChallenge)` and `@(NSURLSessionAuthChallengeRejectProtectionSpace)`. You **MUST NOT** call the completion handler when returning an `NSNumber`. + + If you return anything else from the authentication challenge handler, an exception will be thrown. + + For more information about how URL sessions handle the different types of authentication challenges, see [NSURLSession](https://developer.apple.com/reference/foundation/nsurlsession?language=objc) and [URL Session Programming Guide](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html). + + @see -securityPolicy + */ +- (void)setAuthenticationChallengeHandler:(id (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, void (^completionHandler)(NSURLSessionAuthChallengeDisposition , NSURLCredential * _Nullable)))authenticationChallengeHandler; + +/** + Sets a block to be executed periodically to track upload progress, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`. + + @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes five arguments: the session, the task, the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread. + */ +- (void)setTaskDidSendBodyDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block; + +/** + Sets a block to be executed as the last message related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didCompleteWithError:`. + + @param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any error that occurred in the process of executing the task. + */ +- (void)setTaskDidCompleteBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSError * _Nullable error))block; + +/** + Sets a block to be executed when metrics are finalized related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didFinishCollectingMetrics:`. + + @param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any metrics that were collected in the process of executing the task. + */ +#if AF_CAN_INCLUDE_SESSION_TASK_METRICS +- (void)setTaskDidFinishCollectingMetricsBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSURLSessionTaskMetrics * _Nullable metrics))block AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10)); +#endif +///------------------------------------------- +/// @name Setting Data Task Delegate Callbacks +///------------------------------------------- + +/** + Sets a block to be executed when a data task has received a response, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveResponse:completionHandler:`. + + @param block A block object to be executed when a data task has received a response. The block returns the disposition of the session response, and takes three arguments: the session, the data task, and the received response. + */ +- (void)setDataTaskDidReceiveResponseBlock:(nullable NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block; + +/** + Sets a block to be executed when a data task has become a download task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didBecomeDownloadTask:`. + + @param block A block object to be executed when a data task has become a download task. The block has no return value, and takes three arguments: the session, the data task, and the download task it has become. + */ +- (void)setDataTaskDidBecomeDownloadTaskBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block; + +/** + Sets a block to be executed when a data task receives data, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveData:`. + + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the session, the data task, and the data received. This block may be called multiple times, and will execute on the session manager operation queue. + */ +- (void)setDataTaskDidReceiveDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block; + +/** + Sets a block to be executed to determine the caching behavior of a data task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:willCacheResponse:completionHandler:`. + + @param block A block object to be executed to determine the caching behavior of a data task. The block returns the response to cache, and takes three arguments: the session, the data task, and the proposed cached URL response. + */ +- (void)setDataTaskWillCacheResponseBlock:(nullable NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block; + +/** + Sets a block to be executed once all messages enqueued for a session have been delivered, as handled by the `NSURLSessionDataDelegate` method `URLSessionDidFinishEventsForBackgroundURLSession:`. + + @param block A block object to be executed once all messages enqueued for a session have been delivered. The block has no return value and takes a single argument: the session. + */ +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(nullable void (^)(NSURLSession *session))block AF_API_UNAVAILABLE(macos); + +///----------------------------------------------- +/// @name Setting Download Task Delegate Callbacks +///----------------------------------------------- + +/** + Sets a block to be executed when a download task has completed a download, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didFinishDownloadingToURL:`. + + @param block A block object to be executed when a download task has completed. The block returns the URL the download should be moved to, and takes three arguments: the session, the download task, and the temporary location of the downloaded file. If the file manager encounters an error while attempting to move the temporary file to the destination, an `AFURLSessionDownloadTaskDidFailToMoveFileNotification` will be posted, with the download task as its object, and the user info of the error. + */ +- (void)setDownloadTaskDidFinishDownloadingBlock:(nullable NSURL * _Nullable (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block; + +/** + Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:`. + + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes five arguments: the session, the download task, the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the session manager operation queue. + */ +- (void)setDownloadTaskDidWriteDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block; + +/** + Sets a block to be executed when a download task has been resumed, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`. + + @param block A block object to be executed when a download task has been resumed. The block has no return value and takes four arguments: the session, the download task, the file offset of the resumed download, and the total number of bytes expected to be downloaded. + */ +- (void)setDownloadTaskDidResumeBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block; + +@end + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when a task resumes. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidResumeNotification; + +/** + Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteNotification; + +/** + Posted when a task suspends its execution. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidSuspendNotification; + +/** + Posted when a session is invalidated. + */ +FOUNDATION_EXPORT NSString * const AFURLSessionDidInvalidateNotification; + +/** + Posted when a session download task finished moving the temporary download file to a specified destination successfully. + */ +FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidMoveFileSuccessfullyNotification; + +/** + Posted when a session download task encountered an error when moving the temporary download file to a specified destination. + */ +FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification; + +/** + The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if response data exists for the task. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseDataKey; + +/** + The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the response was serialized. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey; + +/** + The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the task has an associated response serializer. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey; + +/** + The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an the response data has been stored directly to disk. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteAssetPathKey; + +/** + Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an error exists. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteErrorKey; + +/** + The session task metrics taken from the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteSessionTaskMetrics` + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSessionTaskMetrics; + +NS_ASSUME_NONNULL_END diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m new file mode 100644 index 0000000000000000000000000000000000000000..c8b6810ef5501e008b8feba6228b283e9d3d7130 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m @@ -0,0 +1,1274 @@ +// AFURLSessionManager.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLSessionManager.h" +#import + +static dispatch_queue_t url_session_manager_processing_queue() { + static dispatch_queue_t af_url_session_manager_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_processing_queue = dispatch_queue_create("com.alamofire.networking.session.manager.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_url_session_manager_processing_queue; +} + +static dispatch_group_t url_session_manager_completion_group() { + static dispatch_group_t af_url_session_manager_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_completion_group = dispatch_group_create(); + }); + + return af_url_session_manager_completion_group; +} + +NSString * const AFNetworkingTaskDidResumeNotification = @"com.alamofire.networking.task.resume"; +NSString * const AFNetworkingTaskDidCompleteNotification = @"com.alamofire.networking.task.complete"; +NSString * const AFNetworkingTaskDidSuspendNotification = @"com.alamofire.networking.task.suspend"; +NSString * const AFURLSessionDidInvalidateNotification = @"com.alamofire.networking.session.invalidate"; +NSString * const AFURLSessionDownloadTaskDidMoveFileSuccessfullyNotification = @"com.alamofire.networking.session.download.file-manager-succeed"; +NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification = @"com.alamofire.networking.session.download.file-manager-error"; + +NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; +NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; +NSString * const AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; +NSString * const AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error"; +NSString * const AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; +NSString * const AFNetworkingTaskDidCompleteSessionTaskMetrics = @"com.alamofire.networking.complete.sessiontaskmetrics"; + +static NSString * const AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock"; + +typedef void (^AFURLSessionDidBecomeInvalidBlock)(NSURLSession *session, NSError *error); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); + +typedef NSURLRequest * (^AFURLSessionTaskWillPerformHTTPRedirectionBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionTaskDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); +typedef id (^AFURLSessionTaskAuthenticationChallengeBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, void (^completionHandler)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential)); +typedef void (^AFURLSessionDidFinishEventsForBackgroundURLSessionBlock)(NSURLSession *session); + +typedef NSInputStream * (^AFURLSessionTaskNeedNewBodyStreamBlock)(NSURLSession *session, NSURLSessionTask *task); +typedef void (^AFURLSessionTaskDidSendBodyDataBlock)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend); +typedef void (^AFURLSessionTaskDidCompleteBlock)(NSURLSession *session, NSURLSessionTask *task, NSError *error); +#if AF_CAN_INCLUDE_SESSION_TASK_METRICS +typedef void (^AFURLSessionTaskDidFinishCollectingMetricsBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLSessionTaskMetrics * metrics) AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10)); +#endif + +typedef NSURLSessionResponseDisposition (^AFURLSessionDataTaskDidReceiveResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response); +typedef void (^AFURLSessionDataTaskDidBecomeDownloadTaskBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask); +typedef void (^AFURLSessionDataTaskDidReceiveDataBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data); +typedef NSCachedURLResponse * (^AFURLSessionDataTaskWillCacheResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse); + +typedef NSURL * (^AFURLSessionDownloadTaskDidFinishDownloadingBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location); +typedef void (^AFURLSessionDownloadTaskDidWriteDataBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite); +typedef void (^AFURLSessionDownloadTaskDidResumeBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes); +typedef void (^AFURLSessionTaskProgressBlock)(NSProgress *); + +typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id responseObject, NSError *error); + +#pragma mark - + +@interface AFURLSessionManagerTaskDelegate : NSObject +- (instancetype)initWithTask:(NSURLSessionTask *)task; +@property (nonatomic, weak) AFURLSessionManager *manager; +@property (nonatomic, strong) NSMutableData *mutableData; +@property (nonatomic, strong) NSProgress *uploadProgress; +@property (nonatomic, strong) NSProgress *downloadProgress; +@property (nonatomic, copy) NSURL *downloadFileURL; +#if AF_CAN_INCLUDE_SESSION_TASK_METRICS +@property (nonatomic, strong) NSURLSessionTaskMetrics *sessionTaskMetrics AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10)); +#endif +@property (nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (nonatomic, copy) AFURLSessionTaskProgressBlock uploadProgressBlock; +@property (nonatomic, copy) AFURLSessionTaskProgressBlock downloadProgressBlock; +@property (nonatomic, copy) AFURLSessionTaskCompletionHandler completionHandler; +@end + +@implementation AFURLSessionManagerTaskDelegate + +- (instancetype)initWithTask:(NSURLSessionTask *)task { + self = [super init]; + if (!self) { + return nil; + } + + _mutableData = [NSMutableData data]; + _uploadProgress = [[NSProgress alloc] initWithParent:nil userInfo:nil]; + _downloadProgress = [[NSProgress alloc] initWithParent:nil userInfo:nil]; + + __weak __typeof__(task) weakTask = task; + for (NSProgress *progress in @[ _uploadProgress, _downloadProgress ]) + { + progress.totalUnitCount = NSURLSessionTransferSizeUnknown; + progress.cancellable = YES; + progress.cancellationHandler = ^{ + [weakTask cancel]; + }; + progress.pausable = YES; + progress.pausingHandler = ^{ + [weakTask suspend]; + }; +#if AF_CAN_USE_AT_AVAILABLE + if (@available(macOS 10.11, *)) +#else + if ([progress respondsToSelector:@selector(setResumingHandler:)]) +#endif + { + progress.resumingHandler = ^{ + [weakTask resume]; + }; + } + + [progress addObserver:self + forKeyPath:NSStringFromSelector(@selector(fractionCompleted)) + options:NSKeyValueObservingOptionNew + context:NULL]; + } + return self; +} + +- (void)dealloc { + [self.downloadProgress removeObserver:self forKeyPath:NSStringFromSelector(@selector(fractionCompleted))]; + [self.uploadProgress removeObserver:self forKeyPath:NSStringFromSelector(@selector(fractionCompleted))]; +} + +#pragma mark - NSProgress Tracking + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + if ([object isEqual:self.downloadProgress]) { + if (self.downloadProgressBlock) { + self.downloadProgressBlock(object); + } + } + else if ([object isEqual:self.uploadProgress]) { + if (self.uploadProgressBlock) { + self.uploadProgressBlock(object); + } + } +} + +static const void * const AuthenticationChallengeErrorKey = &AuthenticationChallengeErrorKey; + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ + error = objc_getAssociatedObject(task, AuthenticationChallengeErrorKey) ?: error; + __strong AFURLSessionManager *manager = self.manager; + + __block id responseObject = nil; + + NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer; + + //Performance Improvement from #2672 + NSData *data = nil; + if (self.mutableData) { + data = [self.mutableData copy]; + //We no longer need the reference, so nil it out to gain back some memory. + self.mutableData = nil; + } + +#if AF_CAN_USE_AT_AVAILABLE && AF_CAN_INCLUDE_SESSION_TASK_METRICS + if (@available(iOS 10, macOS 10.12, watchOS 3, tvOS 10, *)) { + if (self.sessionTaskMetrics) { + userInfo[AFNetworkingTaskDidCompleteSessionTaskMetrics] = self.sessionTaskMetrics; + } + } +#endif + + if (self.downloadFileURL) { + userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL; + } else if (data) { + userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = data; + } + + if (error) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = error; + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, error); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + } else { + dispatch_async(url_session_manager_processing_queue(), ^{ + NSError *serializationError = nil; + responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:data error:&serializationError]; + + if (self.downloadFileURL) { + responseObject = self.downloadFileURL; + } + + if (responseObject) { + userInfo[AFNetworkingTaskDidCompleteSerializedResponseKey] = responseObject; + } + + if (serializationError) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = serializationError; + } + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, serializationError); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + }); + } +} + +#if AF_CAN_INCLUDE_SESSION_TASK_METRICS +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didFinishCollectingMetrics:(NSURLSessionTaskMetrics *)metrics AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10)) { + self.sessionTaskMetrics = metrics; +} +#endif + +#pragma mark - NSURLSessionDataDelegate + +- (void)URLSession:(__unused NSURLSession *)session + dataTask:(__unused NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + self.downloadProgress.totalUnitCount = dataTask.countOfBytesExpectedToReceive; + self.downloadProgress.completedUnitCount = dataTask.countOfBytesReceived; + + [self.mutableData appendData:data]; +} + +- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task + didSendBodyData:(int64_t)bytesSent + totalBytesSent:(int64_t)totalBytesSent +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend{ + + self.uploadProgress.totalUnitCount = task.countOfBytesExpectedToSend; + self.uploadProgress.completedUnitCount = task.countOfBytesSent; +} + +#pragma mark - NSURLSessionDownloadDelegate + +- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask + didWriteData:(int64_t)bytesWritten + totalBytesWritten:(int64_t)totalBytesWritten +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite{ + + self.downloadProgress.totalUnitCount = totalBytesExpectedToWrite; + self.downloadProgress.completedUnitCount = totalBytesWritten; +} + +- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask + didResumeAtOffset:(int64_t)fileOffset +expectedTotalBytes:(int64_t)expectedTotalBytes{ + + self.downloadProgress.totalUnitCount = expectedTotalBytes; + self.downloadProgress.completedUnitCount = fileOffset; +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + self.downloadFileURL = nil; + + if (self.downloadTaskDidFinishDownloading) { + self.downloadFileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (self.downloadFileURL) { + NSError *fileManagerError = nil; + + if (![[NSFileManager defaultManager] moveItemAtURL:location toURL:self.downloadFileURL error:&fileManagerError]) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:fileManagerError.userInfo]; + } else { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidMoveFileSuccessfullyNotification object:downloadTask userInfo:nil]; + } + } + } +} + +@end + +#pragma mark - + +/** + * A workaround for issues related to key-value observing the `state` of an `NSURLSessionTask`. + * + * See: + * - https://github.com/AFNetworking/AFNetworking/issues/1477 + * - https://github.com/AFNetworking/AFNetworking/issues/2638 + * - https://github.com/AFNetworking/AFNetworking/pull/2702 + */ + +static inline void af_swizzleSelector(Class theClass, SEL originalSelector, SEL swizzledSelector) { + Method originalMethod = class_getInstanceMethod(theClass, originalSelector); + Method swizzledMethod = class_getInstanceMethod(theClass, swizzledSelector); + method_exchangeImplementations(originalMethod, swizzledMethod); +} + +static inline BOOL af_addMethod(Class theClass, SEL selector, Method method) { + return class_addMethod(theClass, selector, method_getImplementation(method), method_getTypeEncoding(method)); +} + +static NSString * const AFNSURLSessionTaskDidResumeNotification = @"com.alamofire.networking.nsurlsessiontask.resume"; +static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofire.networking.nsurlsessiontask.suspend"; + +@interface _AFURLSessionTaskSwizzling : NSObject + +@end + +@implementation _AFURLSessionTaskSwizzling + ++ (void)load { + /** + WARNING: Trouble Ahead + https://github.com/AFNetworking/AFNetworking/pull/2702 + */ + + if (NSClassFromString(@"NSURLSessionTask")) { + /** + iOS 7 and iOS 8 differ in NSURLSessionTask implementation, which makes the next bit of code a bit tricky. + Many Unit Tests have been built to validate as much of this behavior has possible. + Here is what we know: + - NSURLSessionTasks are implemented with class clusters, meaning the class you request from the API isn't actually the type of class you will get back. + - Simply referencing `[NSURLSessionTask class]` will not work. You need to ask an `NSURLSession` to actually create an object, and grab the class from there. + - On iOS 7, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `__NSCFURLSessionTask`. + - On iOS 8, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `NSURLSessionTask`. + - On iOS 7, `__NSCFLocalSessionTask` and `__NSCFURLSessionTask` are the only two classes that have their own implementations of `resume` and `suspend`, and `__NSCFLocalSessionTask` DOES NOT CALL SUPER. This means both classes need to be swizzled. + - On iOS 8, `NSURLSessionTask` is the only class that implements `resume` and `suspend`. This means this is the only class that needs to be swizzled. + - Because `NSURLSessionTask` is not involved in the class hierarchy for every version of iOS, its easier to add the swizzled methods to a dummy class and manage them there. + + Some Assumptions: + - No implementations of `resume` or `suspend` call super. If this were to change in a future version of iOS, we'd need to handle it. + - No background task classes override `resume` or `suspend` + + The current solution: + 1) Grab an instance of `__NSCFLocalDataTask` by asking an instance of `NSURLSession` for a data task. + 2) Grab a pointer to the original implementation of `af_resume` + 3) Check to see if the current class has an implementation of resume. If so, continue to step 4. + 4) Grab the super class of the current class. + 5) Grab a pointer for the current class to the current implementation of `resume`. + 6) Grab a pointer for the super class to the current implementation of `resume`. + 7) If the current class implementation of `resume` is not equal to the super class implementation of `resume` AND the current implementation of `resume` is not equal to the original implementation of `af_resume`, THEN swizzle the methods + 8) Set the current class to the super class, and repeat steps 3-8 + */ + NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration]; + NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration]; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnonnull" + NSURLSessionDataTask *localDataTask = [session dataTaskWithURL:nil]; +#pragma clang diagnostic pop + IMP originalAFResumeIMP = method_getImplementation(class_getInstanceMethod([self class], @selector(af_resume))); + Class currentClass = [localDataTask class]; + + while (class_getInstanceMethod(currentClass, @selector(resume))) { + Class superClass = [currentClass superclass]; + IMP classResumeIMP = method_getImplementation(class_getInstanceMethod(currentClass, @selector(resume))); + IMP superclassResumeIMP = method_getImplementation(class_getInstanceMethod(superClass, @selector(resume))); + if (classResumeIMP != superclassResumeIMP && + originalAFResumeIMP != classResumeIMP) { + [self swizzleResumeAndSuspendMethodForClass:currentClass]; + } + currentClass = [currentClass superclass]; + } + + [localDataTask cancel]; + [session finishTasksAndInvalidate]; + } +} + ++ (void)swizzleResumeAndSuspendMethodForClass:(Class)theClass { + Method afResumeMethod = class_getInstanceMethod(self, @selector(af_resume)); + Method afSuspendMethod = class_getInstanceMethod(self, @selector(af_suspend)); + + if (af_addMethod(theClass, @selector(af_resume), afResumeMethod)) { + af_swizzleSelector(theClass, @selector(resume), @selector(af_resume)); + } + + if (af_addMethod(theClass, @selector(af_suspend), afSuspendMethod)) { + af_swizzleSelector(theClass, @selector(suspend), @selector(af_suspend)); + } +} + +- (NSURLSessionTaskState)state { + NSAssert(NO, @"State method should never be called in the actual dummy class"); + return NSURLSessionTaskStateCanceling; +} + +- (void)af_resume { + NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state"); + NSURLSessionTaskState state = [self state]; + [self af_resume]; + + if (state != NSURLSessionTaskStateRunning) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidResumeNotification object:self]; + } +} + +- (void)af_suspend { + NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state"); + NSURLSessionTaskState state = [self state]; + [self af_suspend]; + + if (state != NSURLSessionTaskStateSuspended) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidSuspendNotification object:self]; + } +} +@end + +#pragma mark - + +@interface AFURLSessionManager () +@property (readwrite, nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration; +@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue; +@property (readwrite, nonatomic, strong) NSURLSession *session; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableTaskDelegatesKeyedByTaskIdentifier; +@property (readonly, nonatomic, copy) NSString *taskDescriptionForSessionTasks; +@property (readwrite, nonatomic, strong) NSLock *lock; +@property (readwrite, nonatomic, copy) AFURLSessionDidBecomeInvalidBlock sessionDidBecomeInvalid; +@property (readwrite, nonatomic, copy) AFURLSessionDidReceiveAuthenticationChallengeBlock sessionDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionDidFinishEventsForBackgroundURLSessionBlock didFinishEventsForBackgroundURLSession AF_API_UNAVAILABLE(macos); +@property (readwrite, nonatomic, copy) AFURLSessionTaskWillPerformHTTPRedirectionBlock taskWillPerformHTTPRedirection; +@property (readwrite, nonatomic, copy) AFURLSessionTaskAuthenticationChallengeBlock authenticationChallengeHandler; +@property (readwrite, nonatomic, copy) AFURLSessionTaskNeedNewBodyStreamBlock taskNeedNewBodyStream; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidSendBodyDataBlock taskDidSendBodyData; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidCompleteBlock taskDidComplete; +#if AF_CAN_INCLUDE_SESSION_TASK_METRICS +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidFinishCollectingMetricsBlock taskDidFinishCollectingMetrics AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10)); +#endif +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveResponseBlock dataTaskDidReceiveResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidBecomeDownloadTaskBlock dataTaskDidBecomeDownloadTask; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveDataBlock dataTaskDidReceiveData; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskWillCacheResponseBlock dataTaskWillCacheResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidWriteDataBlock downloadTaskDidWriteData; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidResumeBlock downloadTaskDidResume; +@end + +@implementation AFURLSessionManager + +- (instancetype)init { + return [self initWithSessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + self = [super init]; + if (!self) { + return nil; + } + + if (!configuration) { + configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; + } + + self.sessionConfiguration = configuration; + + self.operationQueue = [[NSOperationQueue alloc] init]; + self.operationQueue.maxConcurrentOperationCount = 1; + + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + +#if !TARGET_OS_WATCH + self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; +#endif + + self.mutableTaskDelegatesKeyedByTaskIdentifier = [[NSMutableDictionary alloc] init]; + + self.lock = [[NSLock alloc] init]; + self.lock.name = AFURLSessionManagerLockName; + + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + for (NSURLSessionDataTask *task in dataTasks) { + [self addDelegateForDataTask:task uploadProgress:nil downloadProgress:nil completionHandler:nil]; + } + + for (NSURLSessionUploadTask *uploadTask in uploadTasks) { + [self addDelegateForUploadTask:uploadTask progress:nil completionHandler:nil]; + } + + for (NSURLSessionDownloadTask *downloadTask in downloadTasks) { + [self addDelegateForDownloadTask:downloadTask progress:nil destination:nil completionHandler:nil]; + } + }]; + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +#pragma mark - + +- (NSURLSession *)session { + + @synchronized (self) { + if (!_session) { + _session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration delegate:self delegateQueue:self.operationQueue]; + } + } + return _session; +} + +#pragma mark - + + +- (NSString *)taskDescriptionForSessionTasks { + return [NSString stringWithFormat:@"%p", self]; +} + +- (void)taskDidResume:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task respondsToSelector:@selector(taskDescription)]) { + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidResumeNotification object:task]; + }); + } + } +} + +- (void)taskDidSuspend:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task respondsToSelector:@selector(taskDescription)]) { + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidSuspendNotification object:task]; + }); + } + } +} + +#pragma mark - + +- (AFURLSessionManagerTaskDelegate *)delegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + AFURLSessionManagerTaskDelegate *delegate = nil; + [self.lock lock]; + delegate = self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)]; + [self.lock unlock]; + + return delegate; +} + +- (void)setDelegate:(AFURLSessionManagerTaskDelegate *)delegate + forTask:(NSURLSessionTask *)task +{ + NSParameterAssert(task); + NSParameterAssert(delegate); + + [self.lock lock]; + self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)] = delegate; + [self addNotificationObserverForTask:task]; + [self.lock unlock]; +} + +- (void)addDelegateForDataTask:(NSURLSessionDataTask *)dataTask + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] initWithTask:dataTask]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + dataTask.taskDescription = self.taskDescriptionForSessionTasks; + [self setDelegate:delegate forTask:dataTask]; + + delegate.uploadProgressBlock = uploadProgressBlock; + delegate.downloadProgressBlock = downloadProgressBlock; +} + +- (void)addDelegateForUploadTask:(NSURLSessionUploadTask *)uploadTask + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] initWithTask:uploadTask]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + uploadTask.taskDescription = self.taskDescriptionForSessionTasks; + + [self setDelegate:delegate forTask:uploadTask]; + + delegate.uploadProgressBlock = uploadProgressBlock; +} + +- (void)addDelegateForDownloadTask:(NSURLSessionDownloadTask *)downloadTask + progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] initWithTask:downloadTask]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + if (destination) { + delegate.downloadTaskDidFinishDownloading = ^NSURL * (NSURLSession * __unused session, NSURLSessionDownloadTask *task, NSURL *location) { + return destination(location, task.response); + }; + } + + downloadTask.taskDescription = self.taskDescriptionForSessionTasks; + + [self setDelegate:delegate forTask:downloadTask]; + + delegate.downloadProgressBlock = downloadProgressBlock; +} + +- (void)removeDelegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + [self.lock lock]; + [self removeNotificationObserverForTask:task]; + [self.mutableTaskDelegatesKeyedByTaskIdentifier removeObjectForKey:@(task.taskIdentifier)]; + [self.lock unlock]; +} + +#pragma mark - + +- (NSArray *)tasksForKeyPath:(NSString *)keyPath { + __block NSArray *tasks = nil; + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(dataTasks))]) { + tasks = dataTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(uploadTasks))]) { + tasks = uploadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(downloadTasks))]) { + tasks = downloadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(tasks))]) { + tasks = [@[dataTasks, uploadTasks, downloadTasks] valueForKeyPath:@"@unionOfArrays.self"]; + } + + dispatch_semaphore_signal(semaphore); + }]; + + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + + return tasks; +} + +- (NSArray *)tasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)dataTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)uploadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)downloadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +#pragma mark - + +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks resetSession:(BOOL)resetSession { + if (cancelPendingTasks) { + [self.session invalidateAndCancel]; + } else { + [self.session finishTasksAndInvalidate]; + } + if (resetSession) { + self.session = nil; + } +} + +#pragma mark - + +- (void)setResponseSerializer:(id )responseSerializer { + NSParameterAssert(responseSerializer); + + _responseSerializer = responseSerializer; +} + +#pragma mark - +- (void)addNotificationObserverForTask:(NSURLSessionTask *)task { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidResume:) name:AFNSURLSessionTaskDidResumeNotification object:task]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidSuspend:) name:AFNSURLSessionTaskDidSuspendNotification object:task]; +} + +- (void)removeNotificationObserverForTask:(NSURLSessionTask *)task { + [[NSNotificationCenter defaultCenter] removeObserver:self name:AFNSURLSessionTaskDidSuspendNotification object:task]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:AFNSURLSessionTaskDidResumeNotification object:task]; +} + +#pragma mark - + +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler { + + NSURLSessionDataTask *dataTask = [self.session dataTaskWithRequest:request]; + + [self addDelegateForDataTask:dataTask uploadProgress:uploadProgressBlock downloadProgress:downloadProgressBlock completionHandler:completionHandler]; + + return dataTask; +} + +#pragma mark - + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + NSURLSessionUploadTask *uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + + if (uploadTask) { + [self addDelegateForUploadTask:uploadTask + progress:uploadProgressBlock + completionHandler:completionHandler]; + } + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(NSData *)bodyData + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + NSURLSessionUploadTask *uploadTask = [self.session uploadTaskWithRequest:request fromData:bodyData]; + + [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + NSURLSessionUploadTask *uploadTask = [self.session uploadTaskWithStreamedRequest:request]; + + [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler]; + + return uploadTask; +} + +#pragma mark - + +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + NSURLSessionDownloadTask *downloadTask = [self.session downloadTaskWithRequest:request]; + + [self addDelegateForDownloadTask:downloadTask progress:downloadProgressBlock destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + NSURLSessionDownloadTask *downloadTask = [self.session downloadTaskWithResumeData:resumeData]; + + [self addDelegateForDownloadTask:downloadTask progress:downloadProgressBlock destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +#pragma mark - +- (NSProgress *)uploadProgressForTask:(NSURLSessionTask *)task { + return [[self delegateForTask:task] uploadProgress]; +} + +- (NSProgress *)downloadProgressForTask:(NSURLSessionTask *)task { + return [[self delegateForTask:task] downloadProgress]; +} + +#pragma mark - + +- (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block { + self.sessionDidBecomeInvalid = block; +} + +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.sessionDidReceiveAuthenticationChallenge = block; +} + +#if !TARGET_OS_OSX +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block { + self.didFinishEventsForBackgroundURLSession = block; +} +#endif + +#pragma mark - + +- (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block { + self.taskNeedNewBodyStream = block; +} + +- (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block { + self.taskWillPerformHTTPRedirection = block; +} + +- (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block { + self.taskDidSendBodyData = block; +} + +- (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block { + self.taskDidComplete = block; +} + +#if AF_CAN_INCLUDE_SESSION_TASK_METRICS +- (void)setTaskDidFinishCollectingMetricsBlock:(void (^)(NSURLSession * _Nonnull, NSURLSessionTask * _Nonnull, NSURLSessionTaskMetrics * _Nullable))block AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10)) { + self.taskDidFinishCollectingMetrics = block; +} +#endif + +#pragma mark - + +- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block { + self.dataTaskDidReceiveResponse = block; +} + +- (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block { + self.dataTaskDidBecomeDownloadTask = block; +} + +- (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block { + self.dataTaskDidReceiveData = block; +} + +- (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block { + self.dataTaskWillCacheResponse = block; +} + +#pragma mark - + +- (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block { + self.downloadTaskDidFinishDownloading = block; +} + +- (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block { + self.downloadTaskDidWriteData = block; +} + +- (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block { + self.downloadTaskDidResume = block; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, self.session, self.operationQueue]; +} + +- (BOOL)respondsToSelector:(SEL)selector { + if (selector == @selector(URLSession:didReceiveChallenge:completionHandler:)) { + return self.sessionDidReceiveAuthenticationChallenge != nil; + } else if (selector == @selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)) { + return self.taskWillPerformHTTPRedirection != nil; + } else if (selector == @selector(URLSession:dataTask:didReceiveResponse:completionHandler:)) { + return self.dataTaskDidReceiveResponse != nil; + } else if (selector == @selector(URLSession:dataTask:willCacheResponse:completionHandler:)) { + return self.dataTaskWillCacheResponse != nil; + } +#if !TARGET_OS_OSX + else if (selector == @selector(URLSessionDidFinishEventsForBackgroundURLSession:)) { + return self.didFinishEventsForBackgroundURLSession != nil; + } +#endif + + return [[self class] instancesRespondToSelector:selector]; +} + +#pragma mark - NSURLSessionDelegate + +- (void)URLSession:(NSURLSession *)session +didBecomeInvalidWithError:(NSError *)error +{ + if (self.sessionDidBecomeInvalid) { + self.sessionDidBecomeInvalid(session, error); + } + + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDidInvalidateNotification object:session]; +} + +- (void)URLSession:(NSURLSession *)session +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSAssert(self.sessionDidReceiveAuthenticationChallenge != nil, @"`respondsToSelector:` implementation forces `URLSession:didReceiveChallenge:completionHandler:` to be called only if `self.sessionDidReceiveAuthenticationChallenge` is not nil"); + + NSURLCredential *credential = nil; + NSURLSessionAuthChallengeDisposition disposition = self.sessionDidReceiveAuthenticationChallenge(session, challenge, &credential); + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +willPerformHTTPRedirection:(NSHTTPURLResponse *)response + newRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLRequest *))completionHandler +{ + NSURLRequest *redirectRequest = request; + + if (self.taskWillPerformHTTPRedirection) { + redirectRequest = self.taskWillPerformHTTPRedirection(session, task, response, request); + } + + if (completionHandler) { + completionHandler(redirectRequest); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + BOOL evaluateServerTrust = NO; + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + NSURLCredential *credential = nil; + + if (self.authenticationChallengeHandler) { + id result = self.authenticationChallengeHandler(session, task, challenge, completionHandler); + if (result == nil) { + return; + } else if ([result isKindOfClass:NSError.class]) { + objc_setAssociatedObject(task, AuthenticationChallengeErrorKey, result, OBJC_ASSOCIATION_RETAIN); + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; + } else if ([result isKindOfClass:NSURLCredential.class]) { + credential = result; + disposition = NSURLSessionAuthChallengeUseCredential; + } else if ([result isKindOfClass:NSNumber.class]) { + disposition = [result integerValue]; + NSAssert(disposition == NSURLSessionAuthChallengePerformDefaultHandling || disposition == NSURLSessionAuthChallengeCancelAuthenticationChallenge || disposition == NSURLSessionAuthChallengeRejectProtectionSpace, @""); + evaluateServerTrust = disposition == NSURLSessionAuthChallengePerformDefaultHandling && [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]; + } else { + @throw [NSException exceptionWithName:@"Invalid Return Value" reason:@"The return value from the authentication challenge handler must be nil, an NSError, an NSURLCredential or an NSNumber." userInfo:nil]; + } + } else { + evaluateServerTrust = [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]; + } + + if (evaluateServerTrust) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + disposition = NSURLSessionAuthChallengeUseCredential; + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + } else { + objc_setAssociatedObject(task, AuthenticationChallengeErrorKey, + [self serverTrustErrorForServerTrust:challenge.protectionSpace.serverTrust url:task.currentRequest.URL], + OBJC_ASSOCIATION_RETAIN); + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +- (nonnull NSError *)serverTrustErrorForServerTrust:(nullable SecTrustRef)serverTrust url:(nullable NSURL *)url +{ + NSBundle *CFNetworkBundle = [NSBundle bundleWithIdentifier:@"com.apple.CFNetwork"]; + NSString *defaultValue = @"The certificate for this server is invalid. You might be connecting to a server that is pretending to be “%@” which could put your confidential information at risk."; + NSString *descriptionFormat = NSLocalizedStringWithDefaultValue(@"Err-1202.w", nil, CFNetworkBundle, defaultValue, @"") ?: defaultValue; + NSString *localizedDescription = [descriptionFormat componentsSeparatedByString:@"%@"].count <= 2 ? [NSString localizedStringWithFormat:descriptionFormat, url.host] : descriptionFormat; + NSMutableDictionary *userInfo = [@{ + NSLocalizedDescriptionKey: localizedDescription + } mutableCopy]; + + if (serverTrust) { + userInfo[NSURLErrorFailingURLPeerTrustErrorKey] = (__bridge id)serverTrust; + } + + if (url) { + userInfo[NSURLErrorFailingURLErrorKey] = url; + + if (url.absoluteString) { + userInfo[NSURLErrorFailingURLStringErrorKey] = url.absoluteString; + } + } + + return [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorServerCertificateUntrusted userInfo:userInfo]; +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler +{ + NSInputStream *inputStream = nil; + + if (self.taskNeedNewBodyStream) { + inputStream = self.taskNeedNewBodyStream(session, task); + } else if (task.originalRequest.HTTPBodyStream && [task.originalRequest.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { + inputStream = [task.originalRequest.HTTPBodyStream copy]; + } + + if (completionHandler) { + completionHandler(inputStream); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + didSendBodyData:(int64_t)bytesSent + totalBytesSent:(int64_t)totalBytesSent +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend +{ + + int64_t totalUnitCount = totalBytesExpectedToSend; + if (totalUnitCount == NSURLSessionTransferSizeUnknown) { + NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"]; + if (contentLength) { + totalUnitCount = (int64_t) [contentLength longLongValue]; + } + } + + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + + if (delegate) { + [delegate URLSession:session task:task didSendBodyData:bytesSent totalBytesSent:totalBytesSent totalBytesExpectedToSend:totalBytesExpectedToSend]; + } + + if (self.taskDidSendBodyData) { + self.taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalUnitCount); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + + // delegate may be nil when completing a task in the background + if (delegate) { + [delegate URLSession:session task:task didCompleteWithError:error]; + + [self removeDelegateForTask:task]; + } + + if (self.taskDidComplete) { + self.taskDidComplete(session, task, error); + } +} + +#if AF_CAN_INCLUDE_SESSION_TASK_METRICS +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didFinishCollectingMetrics:(NSURLSessionTaskMetrics *)metrics AF_API_AVAILABLE(ios(10), macosx(10.12), watchos(3), tvos(10)) +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + // Metrics may fire after URLSession:task:didCompleteWithError: is called, delegate may be nil + if (delegate) { + [delegate URLSession:session task:task didFinishCollectingMetrics:metrics]; + } + + if (self.taskDidFinishCollectingMetrics) { + self.taskDidFinishCollectingMetrics(session, task, metrics); + } +} +#endif + +#pragma mark - NSURLSessionDataDelegate + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didReceiveResponse:(NSURLResponse *)response + completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler +{ + NSURLSessionResponseDisposition disposition = NSURLSessionResponseAllow; + + if (self.dataTaskDidReceiveResponse) { + disposition = self.dataTaskDidReceiveResponse(session, dataTask, response); + } + + if (completionHandler) { + completionHandler(disposition); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + if (delegate) { + [self removeDelegateForTask:dataTask]; + [self setDelegate:delegate forTask:downloadTask]; + } + + if (self.dataTaskDidBecomeDownloadTask) { + self.dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + [delegate URLSession:session dataTask:dataTask didReceiveData:data]; + + if (self.dataTaskDidReceiveData) { + self.dataTaskDidReceiveData(session, dataTask, data); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + willCacheResponse:(NSCachedURLResponse *)proposedResponse + completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler +{ + NSCachedURLResponse *cachedResponse = proposedResponse; + + if (self.dataTaskWillCacheResponse) { + cachedResponse = self.dataTaskWillCacheResponse(session, dataTask, proposedResponse); + } + + if (completionHandler) { + completionHandler(cachedResponse); + } +} + +#if !TARGET_OS_OSX +- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session { + if (self.didFinishEventsForBackgroundURLSession) { + dispatch_async(dispatch_get_main_queue(), ^{ + self.didFinishEventsForBackgroundURLSession(session); + }); + } +} +#endif + +#pragma mark - NSURLSessionDownloadDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + if (self.downloadTaskDidFinishDownloading) { + NSURL *fileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (fileURL) { + delegate.downloadFileURL = fileURL; + NSError *error = nil; + + if (![[NSFileManager defaultManager] moveItemAtURL:location toURL:fileURL error:&error]) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:error.userInfo]; + } else { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidMoveFileSuccessfullyNotification object:downloadTask userInfo:nil]; + } + + return; + } + } + + if (delegate) { + [delegate URLSession:session downloadTask:downloadTask didFinishDownloadingToURL:location]; + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didWriteData:(int64_t)bytesWritten + totalBytesWritten:(int64_t)totalBytesWritten +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite +{ + + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + + if (delegate) { + [delegate URLSession:session downloadTask:downloadTask didWriteData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite]; + } + + if (self.downloadTaskDidWriteData) { + self.downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didResumeAtOffset:(int64_t)fileOffset +expectedTotalBytes:(int64_t)expectedTotalBytes +{ + + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + + if (delegate) { + [delegate URLSession:session downloadTask:downloadTask didResumeAtOffset:fileOffset expectedTotalBytes:expectedTotalBytes]; + } + + if (self.downloadTaskDidResume) { + self.downloadTaskDidResume(session, downloadTask, fileOffset, expectedTotalBytes); + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + + self = [self initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[[self class] allocWithZone:zone] initWithSessionConfiguration:self.session.configuration]; +} + +@end diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/LICENSE b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..f611f42f352ad9a5ab131c7051de38151c9d6d9a --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2011-2020 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/README.md b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d193dfe8d1e79850f407ca449207b5190ecac0d7 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/README.md @@ -0,0 +1,298 @@ +

+ AFNetworking +

+ +[![Build Status](https://github.com/AFNetworking/AFNetworking/workflows/AFNetworking%20CI/badge.svg?branch=master)](https://github.com/AFNetworking/AFNetworking/actions) +[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/AFNetworking.svg)](https://img.shields.io/cocoapods/v/AFNetworking.svg) +[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) +[![Platform](https://img.shields.io/cocoapods/p/AFNetworking.svg?style=flat)](http://cocoadocs.org/docsets/AFNetworking) +[![Twitter](https://img.shields.io/badge/twitter-@AFNetworking-blue.svg?style=flat)](http://twitter.com/AFNetworking) + +AFNetworking is a delightful networking library for iOS, macOS, watchOS, and tvOS. It's built on top of the [Foundation URL Loading System](https://developer.apple.com/documentation/foundation/url_loading_system), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. + +Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac. + +## How To Get Started + +- [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/archive/master.zip) and try out the included Mac and iPhone example apps +- Read the ["Getting Started" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles on the Wiki](https://github.com/AFNetworking/AFNetworking/wiki) + +## Communication + +- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). (Tag 'afnetworking') +- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). +- If you **found a bug**, _and can provide steps to reliably reproduce it_, open an issue. +- If you **have a feature request**, open an issue. +- If you **want to contribute**, submit a pull request. + +## Installation +AFNetworking supports multiple methods for installing the library in a project. + +## Installation with CocoaPods + +To integrate AFNetworking into your Xcode project using CocoaPods, specify it in your `Podfile`: + +```ruby +pod 'AFNetworking', '~> 4.0' +``` + +### Installation with Swift Package Manager + +Once you have your Swift package set up, adding AFNetworking as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. + +```swift +dependencies: [ + .package(url: "https://github.com/AFNetworking/AFNetworking.git", .upToNextMajor(from: "4.0.0")) +] +``` + +> Note: AFNetworking's Swift package does not include it's UIKit extensions. + +### Installation with Carthage + +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate AFNetworking, add the following to your `Cartfile`. + +```ogdl +github "AFNetworking/AFNetworking" ~> 4.0 +``` + +## Requirements + +| AFNetworking Version | Minimum iOS Target | Minimum macOS Target | Minimum watchOS Target | Minimum tvOS Target | Notes | +|:--------------------:|:---------------------------:|:----------------------------:|:----------------------------:|:----------------------------:|:-------------------------------------------------------------------------:| +| 4.x | iOS 9 | macOS 10.10 | watchOS 2.0 | tvOS 9.0 | Xcode 11+ is required. | +| 3.x | iOS 7 | OS X 10.9 | watchOS 2.0 | tvOS 9.0 | Xcode 7+ is required. `NSURLConnectionOperation` support has been removed. | +| 2.6 -> 2.6.3 | iOS 7 | OS X 10.9 | watchOS 2.0 | n/a | Xcode 7+ is required. | +| 2.0 -> 2.5.4 | iOS 6 | OS X 10.8 | n/a | n/a | Xcode 5+ is required. `NSURLSession` subspec requires iOS 7 or OS X 10.9. | +| 1.x | iOS 5 | Mac OS X 10.7 | n/a | n/a | +| 0.10.x | iOS 4 | Mac OS X 10.6 | n/a | n/a | + +(macOS projects must support [64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)). + +> Programming in Swift? Try [Alamofire](https://github.com/Alamofire/Alamofire) for a more conventional set of APIs. + +## Architecture + +### NSURLSession + +- `AFURLSessionManager` +- `AFHTTPSessionManager` + +### Serialization + +* `` + - `AFHTTPRequestSerializer` + - `AFJSONRequestSerializer` + - `AFPropertyListRequestSerializer` +* `` + - `AFHTTPResponseSerializer` + - `AFJSONResponseSerializer` + - `AFXMLParserResponseSerializer` + - `AFXMLDocumentResponseSerializer` _(macOS)_ + - `AFPropertyListResponseSerializer` + - `AFImageResponseSerializer` + - `AFCompoundResponseSerializer` + +### Additional Functionality + +- `AFSecurityPolicy` +- `AFNetworkReachabilityManager` + +## Usage + +### AFURLSessionManager + +`AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + +#### Creating a Download Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/download.zip"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) { + NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil]; + return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]]; +} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) { + NSLog(@"File downloaded to: %@", filePath); +}]; +[downloadTask resume]; +``` + +#### Creating an Upload Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"]; +NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithRequest:request fromFile:filePath progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"Success: %@ %@", response, responseObject); + } +}]; +[uploadTask resume]; +``` + +#### Creating an Upload Task for a Multi-Part Request, with Progress + +```objective-c +NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id formData) { + [formData appendPartWithFileURL:[NSURL fileURLWithPath:@"file://path/to/image.jpg"] name:@"file" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil]; + } error:nil]; + +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; + +NSURLSessionUploadTask *uploadTask; +uploadTask = [manager + uploadTaskWithStreamedRequest:request + progress:^(NSProgress * _Nonnull uploadProgress) { + // This is not called back on the main queue. + // You are responsible for dispatching to the main queue for UI updates + dispatch_async(dispatch_get_main_queue(), ^{ + //Update the progress view + [progressView setProgress:uploadProgress.fractionCompleted]; + }); + } + completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"%@ %@", response, responseObject); + } + }]; + +[uploadTask resume]; +``` + +#### Creating a Data Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/get"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"%@ %@", response, responseObject); + } +}]; +[dataTask resume]; +``` + +--- + +### Request Serialization + +Request serializers create requests from URL strings, encoding parameters as either a query string or HTTP body. + +```objective-c +NSString *URLString = @"http://example.com"; +NSDictionary *parameters = @{@"foo": @"bar", @"baz": @[@1, @2, @3]}; +``` + +#### Query String Parameter Encoding + +```objective-c +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:URLString parameters:parameters error:nil]; +``` + + GET http://example.com?foo=bar&baz[]=1&baz[]=2&baz[]=3 + +#### URL Form Parameter Encoding + +```objective-c +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil]; +``` + + POST http://example.com/ + Content-Type: application/x-www-form-urlencoded + + foo=bar&baz[]=1&baz[]=2&baz[]=3 + +#### JSON Parameter Encoding + +```objective-c +[[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil]; +``` + + POST http://example.com/ + Content-Type: application/json + + {"foo": "bar", "baz": [1,2,3]} + +--- + +### Network Reachability Manager + +`AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + +* Do not use Reachability to determine if the original request should be sent. + * You should try to send it. +* You can use Reachability to determine when a request should be automatically retried. + * Although it may still fail, a Reachability notification that the connectivity is available is a good time to retry something. +* Network reachability is a useful tool for determining why a request might have failed. + * After a network request has failed, telling the user they're offline is better than giving them a more technical but accurate error, such as "request timed out." + +See also [WWDC 2012 session 706, "Networking Best Practices."](https://developer.apple.com/videos/play/wwdc2012-706/). + +#### Shared Network Reachability + +```objective-c +[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status)); +}]; + +[[AFNetworkReachabilityManager sharedManager] startMonitoring]; +``` + +--- + +### Security Policy + +`AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + +Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. + +#### Allowing Invalid SSL Certificates + +```objective-c +AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; +manager.securityPolicy.allowInvalidCertificates = YES; // not recommended for production +``` + +--- + +## Unit Tests + +AFNetworking includes a suite of unit tests within the Tests subdirectory. These tests can be run simply be executed the test action on the platform framework you would like to test. + +## Credits + +AFNetworking is owned and maintained by the [Alamofire Software Foundation](http://alamofire.org). + +AFNetworking was originally created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](http://en.wikipedia.org/wiki/Gowalla). + +AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/). + +And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors). + +### Security Disclosure + +If you believe you have identified a security vulnerability with AFNetworking, you should report it as soon as possible via email to security@alamofire.org. Please do not post it to a public issue tracker. + +## License + +AFNetworking is released under the MIT license. See [LICENSE](https://github.com/AFNetworking/AFNetworking/blob/master/LICENSE) for details. diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h new file mode 100644 index 0000000000000000000000000000000000000000..1a27bb435f2771b24e3e63db45d2737e019b8851 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h @@ -0,0 +1,160 @@ +// AFAutoPurgingImageCache.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +#if TARGET_OS_IOS || TARGET_OS_TV +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + The `AFImageCache` protocol defines a set of APIs for adding, removing and fetching images from a cache synchronously. + */ +@protocol AFImageCache + +/** + Adds the image to the cache with the given identifier. + + @param image The image to cache. + @param identifier The unique identifier for the image in the cache. + */ +- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier; + +/** + Removes the image from the cache matching the given identifier. + + @param identifier The unique identifier for the image in the cache. + + @return A BOOL indicating whether or not the image was removed from the cache. + */ +- (BOOL)removeImageWithIdentifier:(NSString *)identifier; + +/** + Removes all images from the cache. + + @return A BOOL indicating whether or not all images were removed from the cache. + */ +- (BOOL)removeAllImages; + +/** + Returns the image in the cache associated with the given identifier. + + @param identifier The unique identifier for the image in the cache. + + @return An image for the matching identifier, or nil. + */ +- (nullable UIImage *)imageWithIdentifier:(NSString *)identifier; +@end + + +/** + The `ImageRequestCache` protocol extends the `ImageCache` protocol by adding methods for adding, removing and fetching images from a cache given an `NSURLRequest` and additional identifier. + */ +@protocol AFImageRequestCache + +/** + Asks if the image should be cached using an identifier created from the request and additional identifier. + + @param image The image to be cached. + @param request The unique URL request identifing the image asset. + @param identifier The additional identifier to apply to the URL request to identify the image. + + @return A BOOL indicating whether or not the image should be added to the cache. YES will cache, NO will prevent caching. + */ +- (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; + +/** + Adds the image to the cache using an identifier created from the request and additional identifier. + + @param image The image to cache. + @param request The unique URL request identifing the image asset. + @param identifier The additional identifier to apply to the URL request to identify the image. + */ +- (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; + +/** + Removes the image from the cache using an identifier created from the request and additional identifier. + + @param request The unique URL request identifing the image asset. + @param identifier The additional identifier to apply to the URL request to identify the image. + + @return A BOOL indicating whether or not all images were removed from the cache. + */ +- (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; + +/** + Returns the image from the cache associated with an identifier created from the request and additional identifier. + + @param request The unique URL request identifing the image asset. + @param identifier The additional identifier to apply to the URL request to identify the image. + + @return An image for the matching request and identifier, or nil. + */ +- (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; + +@end + +/** + The `AutoPurgingImageCache` in an in-memory image cache used to store images up to a given memory capacity. When the memory capacity is reached, the image cache is sorted by last access date, then the oldest image is continuously purged until the preferred memory usage after purge is met. Each time an image is accessed through the cache, the internal access date of the image is updated. + */ +@interface AFAutoPurgingImageCache : NSObject + +/** + The total memory capacity of the cache in bytes. + */ +@property (nonatomic, assign) UInt64 memoryCapacity; + +/** + The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit. + */ +@property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge; + +/** + The current total memory usage in bytes of all images stored within the cache. + */ +@property (nonatomic, assign, readonly) UInt64 memoryUsage; + +/** + Initialies the `AutoPurgingImageCache` instance with default values for memory capacity and preferred memory usage after purge limit. `memoryCapcity` defaults to `100 MB`. `preferredMemoryUsageAfterPurge` defaults to `60 MB`. + + @return The new `AutoPurgingImageCache` instance. + */ +- (instancetype)init; + +/** + Initialies the `AutoPurgingImageCache` instance with the given memory capacity and preferred memory usage + after purge limit. + + @param memoryCapacity The total memory capacity of the cache in bytes. + @param preferredMemoryCapacity The preferred memory usage after purge in bytes. + + @return The new `AutoPurgingImageCache` instance. + */ +- (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity; + +@end + +NS_ASSUME_NONNULL_END + +#endif + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m new file mode 100644 index 0000000000000000000000000000000000000000..a09e87c837359bfbd29a43ad014c9feb7f77a90c --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m @@ -0,0 +1,205 @@ +// AFAutoPurgingImageCache.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFAutoPurgingImageCache.h" + +@interface AFCachedImage : NSObject + +@property (nonatomic, strong) UIImage *image; +@property (nonatomic, copy) NSString *identifier; +@property (nonatomic, assign) UInt64 totalBytes; +@property (nonatomic, strong) NSDate *lastAccessDate; +@property (nonatomic, assign) UInt64 currentMemoryUsage; + +@end + +@implementation AFCachedImage + +- (instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier { + if (self = [self init]) { + self.image = image; + self.identifier = identifier; + + CGSize imageSize = CGSizeMake(image.size.width * image.scale, image.size.height * image.scale); + CGFloat bytesPerPixel = 4.0; + CGFloat bytesPerSize = imageSize.width * imageSize.height; + self.totalBytes = (UInt64)bytesPerPixel * (UInt64)bytesPerSize; + self.lastAccessDate = [NSDate date]; + } + return self; +} + +- (UIImage *)accessImage { + self.lastAccessDate = [NSDate date]; + return self.image; +} + +- (NSString *)description { + NSString *descriptionString = [NSString stringWithFormat:@"Idenfitier: %@ lastAccessDate: %@ ", self.identifier, self.lastAccessDate]; + return descriptionString; + +} + +@end + +@interface AFAutoPurgingImageCache () +@property (nonatomic, strong) NSMutableDictionary *cachedImages; +@property (nonatomic, assign) UInt64 currentMemoryUsage; +@property (nonatomic, strong) dispatch_queue_t synchronizationQueue; +@end + +@implementation AFAutoPurgingImageCache + +- (instancetype)init { + return [self initWithMemoryCapacity:100 * 1024 * 1024 preferredMemoryCapacity:60 * 1024 * 1024]; +} + +- (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity { + if (self = [super init]) { + self.memoryCapacity = memoryCapacity; + self.preferredMemoryUsageAfterPurge = preferredMemoryCapacity; + self.cachedImages = [[NSMutableDictionary alloc] init]; + + NSString *queueName = [NSString stringWithFormat:@"com.alamofire.autopurgingimagecache-%@", [[NSUUID UUID] UUIDString]]; + self.synchronizationQueue = dispatch_queue_create([queueName cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT); + + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(removeAllImages) + name:UIApplicationDidReceiveMemoryWarningNotification + object:nil]; + + } + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (UInt64)memoryUsage { + __block UInt64 result = 0; + dispatch_sync(self.synchronizationQueue, ^{ + result = self.currentMemoryUsage; + }); + return result; +} + +- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier { + dispatch_barrier_async(self.synchronizationQueue, ^{ + AFCachedImage *cacheImage = [[AFCachedImage alloc] initWithImage:image identifier:identifier]; + + AFCachedImage *previousCachedImage = self.cachedImages[identifier]; + if (previousCachedImage != nil) { + self.currentMemoryUsage -= previousCachedImage.totalBytes; + } + + self.cachedImages[identifier] = cacheImage; + self.currentMemoryUsage += cacheImage.totalBytes; + }); + + dispatch_barrier_async(self.synchronizationQueue, ^{ + if (self.currentMemoryUsage > self.memoryCapacity) { + UInt64 bytesToPurge = self.currentMemoryUsage - self.preferredMemoryUsageAfterPurge; + NSMutableArray *sortedImages = [NSMutableArray arrayWithArray:self.cachedImages.allValues]; + NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastAccessDate" + ascending:YES]; + [sortedImages sortUsingDescriptors:@[sortDescriptor]]; + + UInt64 bytesPurged = 0; + + for (AFCachedImage *cachedImage in sortedImages) { + [self.cachedImages removeObjectForKey:cachedImage.identifier]; + bytesPurged += cachedImage.totalBytes; + if (bytesPurged >= bytesToPurge) { + break; + } + } + self.currentMemoryUsage -= bytesPurged; + } + }); +} + +- (BOOL)removeImageWithIdentifier:(NSString *)identifier { + __block BOOL removed = NO; + dispatch_barrier_sync(self.synchronizationQueue, ^{ + AFCachedImage *cachedImage = self.cachedImages[identifier]; + if (cachedImage != nil) { + [self.cachedImages removeObjectForKey:identifier]; + self.currentMemoryUsage -= cachedImage.totalBytes; + removed = YES; + } + }); + return removed; +} + +- (BOOL)removeAllImages { + __block BOOL removed = NO; + dispatch_barrier_sync(self.synchronizationQueue, ^{ + if (self.cachedImages.count > 0) { + [self.cachedImages removeAllObjects]; + self.currentMemoryUsage = 0; + removed = YES; + } + }); + return removed; +} + +- (nullable UIImage *)imageWithIdentifier:(NSString *)identifier { + __block UIImage *image = nil; + dispatch_sync(self.synchronizationQueue, ^{ + AFCachedImage *cachedImage = self.cachedImages[identifier]; + image = [cachedImage accessImage]; + }); + return image; +} + +- (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { + [self addImage:image withIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]]; +} + +- (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { + return [self removeImageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]]; +} + +- (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { + return [self imageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]]; +} + +- (NSString *)imageCacheKeyFromURLRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)additionalIdentifier { + NSString *key = request.URL.absoluteString; + if (additionalIdentifier != nil) { + key = [key stringByAppendingString:additionalIdentifier]; + } + return key; +} + +- (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier { + return YES; +} + +@end + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h new file mode 100644 index 0000000000000000000000000000000000000000..3bf5a32025325d344140dc50a712b0c1aa433d27 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h @@ -0,0 +1,171 @@ +// AFImageDownloader.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import +#import "AFAutoPurgingImageCache.h" +#import "AFHTTPSessionManager.h" + +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, AFImageDownloadPrioritization) { + AFImageDownloadPrioritizationFIFO, + AFImageDownloadPrioritizationLIFO +}; + +/** + The `AFImageDownloadReceipt` is an object vended by the `AFImageDownloader` when starting a data task. It can be used to cancel active tasks running on the `AFImageDownloader` session. As a general rule, image data tasks should be cancelled using the `AFImageDownloadReceipt` instead of calling `cancel` directly on the `task` itself. The `AFImageDownloader` is optimized to handle duplicate task scenarios as well as pending versus active downloads. + */ +@interface AFImageDownloadReceipt : NSObject + +/** + The data task created by the `AFImageDownloader`. +*/ +@property (nonatomic, strong) NSURLSessionDataTask *task; + +/** + The unique identifier for the success and failure blocks when duplicate requests are made. + */ +@property (nonatomic, strong) NSUUID *receiptID; +@end + +/** The `AFImageDownloader` class is responsible for downloading images in parallel on a prioritized queue. Incoming downloads are added to the front or back of the queue depending on the download prioritization. Each downloaded image is cached in the underlying `NSURLCache` as well as the in-memory image cache. By default, any download request with a cached image equivalent in the image cache will automatically be served the cached image representation. + */ +@interface AFImageDownloader : NSObject + +/** + The image cache used to store all downloaded images in. `AFAutoPurgingImageCache` by default. + */ +@property (nonatomic, strong, nullable) id imageCache; + +/** + The `AFHTTPSessionManager` used to download images. By default, this is configured with an `AFImageResponseSerializer`, and a shared `NSURLCache` for all image downloads. + */ +@property (nonatomic, strong) AFHTTPSessionManager *sessionManager; + +/** + Defines the order prioritization of incoming download requests being inserted into the queue. `AFImageDownloadPrioritizationFIFO` by default. + */ +@property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritization; + +/** + The shared default instance of `AFImageDownloader` initialized with default values. + */ ++ (instancetype)defaultInstance; + +/** + Creates a default `NSURLCache` with common usage parameter values. + + @returns The default `NSURLCache` instance. + */ ++ (NSURLCache *)defaultURLCache; + +/** + The default `NSURLSessionConfiguration` with common usage parameter values. + */ ++ (NSURLSessionConfiguration *)defaultURLSessionConfiguration; + +/** + Default initializer + + @return An instance of `AFImageDownloader` initialized with default values. + */ +- (instancetype)init; + +/** + Initializer with specific `URLSessionConfiguration` + + @param configuration The `NSURLSessionConfiguration` to be be used + + @return An instance of `AFImageDownloader` initialized with default values and custom `NSURLSessionConfiguration` + */ +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration; + +/** + Initializes the `AFImageDownloader` instance with the given session manager, download prioritization, maximum active download count and image cache. + + @param sessionManager The session manager to use to download images. + @param downloadPrioritization The download prioritization of the download queue. + @param maximumActiveDownloads The maximum number of active downloads allowed at any given time. Recommend `4`. + @param imageCache The image cache used to store all downloaded images in. + + @return The new `AFImageDownloader` instance. + */ +- (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager + downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization + maximumActiveDownloads:(NSInteger)maximumActiveDownloads + imageCache:(nullable id )imageCache; + +/** + Creates a data task using the `sessionManager` instance for the specified URL request. + + If the same data task is already in the queue or currently being downloaded, the success and failure blocks are + appended to the already existing task. Once the task completes, all success or failure blocks attached to the + task are executed in the order they were added. + + @param request The URL request. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + + @return The image download receipt for the data task if available. `nil` if the image is stored in the cache. + cache and the URL request cache policy allows the cache to be used. + */ +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + +/** + Creates a data task using the `sessionManager` instance for the specified URL request. + + If the same data task is already in the queue or currently being downloaded, the success and failure blocks are + appended to the already existing task. Once the task completes, all success or failure blocks attached to the + task are executed in the order they were added. + + @param request The URL request. + @param receiptID The identifier to use for the download receipt that will be created for this request. This must be a unique identifier that does not represent any other request. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + + @return The image download receipt for the data task if available. `nil` if the image is stored in the cache. + cache and the URL request cache policy allows the cache to be used. + */ +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request + withReceiptID:(NSUUID *)receiptID + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + +/** + Cancels the data task in the receipt by removing the corresponding success and failure blocks and cancelling the data task if necessary. + + If the data task is pending in the queue, it will be cancelled if no other success and failure blocks are registered with the data task. If the data task is currently executing or is already completed, the success and failure blocks are removed and will not be called when the task finishes. + + @param imageDownloadReceipt The image download receipt to cancel. + */ +- (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt; + +@end + +#endif + +NS_ASSUME_NONNULL_END diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m new file mode 100644 index 0000000000000000000000000000000000000000..008a78286d7559ffed3c87355b03760d226da88c --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m @@ -0,0 +1,421 @@ +// AFImageDownloader.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFImageDownloader.h" +#import "AFHTTPSessionManager.h" + +@interface AFImageDownloaderResponseHandler : NSObject +@property (nonatomic, strong) NSUUID *uuid; +@property (nonatomic, copy) void (^successBlock)(NSURLRequest *, NSHTTPURLResponse *, UIImage *); +@property (nonatomic, copy) void (^failureBlock)(NSURLRequest *, NSHTTPURLResponse *, NSError *); +@end + +@implementation AFImageDownloaderResponseHandler + +- (instancetype)initWithUUID:(NSUUID *)uuid + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure { + if (self = [self init]) { + self.uuid = uuid; + self.successBlock = success; + self.failureBlock = failure; + } + return self; +} + +- (NSString *)description { + return [NSString stringWithFormat: @"UUID: %@", [self.uuid UUIDString]]; +} + +@end + +@interface AFImageDownloaderMergedTask : NSObject +@property (nonatomic, strong) NSString *URLIdentifier; +@property (nonatomic, strong) NSUUID *identifier; +@property (nonatomic, strong) NSURLSessionDataTask *task; +@property (nonatomic, strong) NSMutableArray *responseHandlers; + +@end + +@implementation AFImageDownloaderMergedTask + +- (instancetype)initWithURLIdentifier:(NSString *)URLIdentifier identifier:(NSUUID *)identifier task:(NSURLSessionDataTask *)task { + if (self = [self init]) { + self.URLIdentifier = URLIdentifier; + self.task = task; + self.identifier = identifier; + self.responseHandlers = [[NSMutableArray alloc] init]; + } + return self; +} + +- (void)addResponseHandler:(AFImageDownloaderResponseHandler *)handler { + [self.responseHandlers addObject:handler]; +} + +- (void)removeResponseHandler:(AFImageDownloaderResponseHandler *)handler { + [self.responseHandlers removeObject:handler]; +} + +@end + +@implementation AFImageDownloadReceipt + +- (instancetype)initWithReceiptID:(NSUUID *)receiptID task:(NSURLSessionDataTask *)task { + if (self = [self init]) { + self.receiptID = receiptID; + self.task = task; + } + return self; +} + +@end + +@interface AFImageDownloader () + +@property (nonatomic, strong) dispatch_queue_t synchronizationQueue; +@property (nonatomic, strong) dispatch_queue_t responseQueue; + +@property (nonatomic, assign) NSInteger maximumActiveDownloads; +@property (nonatomic, assign) NSInteger activeRequestCount; + +@property (nonatomic, strong) NSMutableArray *queuedMergedTasks; +@property (nonatomic, strong) NSMutableDictionary *mergedTasks; + +@end + +@implementation AFImageDownloader + ++ (NSURLCache *)defaultURLCache { + NSUInteger memoryCapacity = 20 * 1024 * 1024; // 20MB + NSUInteger diskCapacity = 150 * 1024 * 1024; // 150MB + NSURL *cacheURL = [[[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory + inDomain:NSUserDomainMask + appropriateForURL:nil + create:YES + error:nil] + URLByAppendingPathComponent:@"com.alamofire.imagedownloader"]; + +#if TARGET_OS_MACCATALYST + return [[NSURLCache alloc] initWithMemoryCapacity:memoryCapacity + diskCapacity:diskCapacity + directoryURL:cacheURL]; +#else + return [[NSURLCache alloc] initWithMemoryCapacity:memoryCapacity + diskCapacity:diskCapacity + diskPath:[cacheURL path]]; +#endif +} + ++ (NSURLSessionConfiguration *)defaultURLSessionConfiguration { + NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; + + //TODO set the default HTTP headers + + configuration.HTTPShouldSetCookies = YES; + configuration.HTTPShouldUsePipelining = NO; + + configuration.requestCachePolicy = NSURLRequestUseProtocolCachePolicy; + configuration.allowsCellularAccess = YES; + configuration.timeoutIntervalForRequest = 60.0; + configuration.URLCache = [AFImageDownloader defaultURLCache]; + + return configuration; +} + +- (instancetype)init { + NSURLSessionConfiguration *defaultConfiguration = [self.class defaultURLSessionConfiguration]; + return [self initWithSessionConfiguration:defaultConfiguration]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + AFHTTPSessionManager *sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:configuration]; + sessionManager.responseSerializer = [AFImageResponseSerializer serializer]; + + return [self initWithSessionManager:sessionManager + downloadPrioritization:AFImageDownloadPrioritizationFIFO + maximumActiveDownloads:4 + imageCache:[[AFAutoPurgingImageCache alloc] init]]; +} + +- (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager + downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization + maximumActiveDownloads:(NSInteger)maximumActiveDownloads + imageCache:(id )imageCache { + if (self = [super init]) { + self.sessionManager = sessionManager; + + self.downloadPrioritization = downloadPrioritization; + self.maximumActiveDownloads = maximumActiveDownloads; + self.imageCache = imageCache; + + self.queuedMergedTasks = [[NSMutableArray alloc] init]; + self.mergedTasks = [[NSMutableDictionary alloc] init]; + self.activeRequestCount = 0; + + NSString *name = [NSString stringWithFormat:@"com.alamofire.imagedownloader.synchronizationqueue-%@", [[NSUUID UUID] UUIDString]]; + self.synchronizationQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_SERIAL); + + name = [NSString stringWithFormat:@"com.alamofire.imagedownloader.responsequeue-%@", [[NSUUID UUID] UUIDString]]; + self.responseQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT); + } + + return self; +} + ++ (instancetype)defaultInstance { + static AFImageDownloader *sharedInstance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [[self alloc] init]; + }); + return sharedInstance; +} + +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request + success:(void (^)(NSURLRequest * _Nonnull, NSHTTPURLResponse * _Nullable, UIImage * _Nonnull))success + failure:(void (^)(NSURLRequest * _Nonnull, NSHTTPURLResponse * _Nullable, NSError * _Nonnull))failure { + return [self downloadImageForURLRequest:request withReceiptID:[NSUUID UUID] success:success failure:failure]; +} + +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request + withReceiptID:(nonnull NSUUID *)receiptID + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure { + __block NSURLSessionDataTask *task = nil; + dispatch_sync(self.synchronizationQueue, ^{ + NSString *URLIdentifier = request.URL.absoluteString; + if (URLIdentifier == nil) { + if (failure) { + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadURL userInfo:nil]; + dispatch_async(dispatch_get_main_queue(), ^{ + failure(request, nil, error); + }); + } + return; + } + + // 1) Append the success and failure blocks to a pre-existing request if it already exists + AFImageDownloaderMergedTask *existingMergedTask = self.mergedTasks[URLIdentifier]; + if (existingMergedTask != nil) { + AFImageDownloaderResponseHandler *handler = [[AFImageDownloaderResponseHandler alloc] initWithUUID:receiptID success:success failure:failure]; + [existingMergedTask addResponseHandler:handler]; + task = existingMergedTask.task; + return; + } + + // 2) Attempt to load the image from the image cache if the cache policy allows it + switch (request.cachePolicy) { + case NSURLRequestUseProtocolCachePolicy: + case NSURLRequestReturnCacheDataElseLoad: + case NSURLRequestReturnCacheDataDontLoad: { + UIImage *cachedImage = [self.imageCache imageforRequest:request withAdditionalIdentifier:nil]; + if (cachedImage != nil) { + if (success) { + dispatch_async(dispatch_get_main_queue(), ^{ + success(request, nil, cachedImage); + }); + } + return; + } + break; + } + default: + break; + } + + // 3) Create the request and set up authentication, validation and response serialization + NSUUID *mergedTaskIdentifier = [NSUUID UUID]; + NSURLSessionDataTask *createdTask; + __weak __typeof__(self) weakSelf = self; + + createdTask = [self.sessionManager + dataTaskWithRequest:request + uploadProgress:nil + downloadProgress:nil + completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { + dispatch_async(self.responseQueue, ^{ + __strong __typeof__(weakSelf) strongSelf = weakSelf; + AFImageDownloaderMergedTask *mergedTask = [strongSelf safelyGetMergedTask:URLIdentifier]; + if ([mergedTask.identifier isEqual:mergedTaskIdentifier]) { + mergedTask = [strongSelf safelyRemoveMergedTaskWithURLIdentifier:URLIdentifier]; + if (error) { + for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) { + if (handler.failureBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler.failureBlock(request, (NSHTTPURLResponse *)response, error); + }); + } + } + } else { + if ([strongSelf.imageCache shouldCacheImage:responseObject forRequest:request withAdditionalIdentifier:nil]) { + [strongSelf.imageCache addImage:responseObject forRequest:request withAdditionalIdentifier:nil]; + } + + for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) { + if (handler.successBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler.successBlock(request, (NSHTTPURLResponse *)response, responseObject); + }); + } + } + + } + } + [strongSelf safelyDecrementActiveTaskCount]; + [strongSelf safelyStartNextTaskIfNecessary]; + }); + }]; + + // 4) Store the response handler for use when the request completes + AFImageDownloaderResponseHandler *handler = [[AFImageDownloaderResponseHandler alloc] initWithUUID:receiptID + success:success + failure:failure]; + AFImageDownloaderMergedTask *mergedTask = [[AFImageDownloaderMergedTask alloc] + initWithURLIdentifier:URLIdentifier + identifier:mergedTaskIdentifier + task:createdTask]; + [mergedTask addResponseHandler:handler]; + self.mergedTasks[URLIdentifier] = mergedTask; + + // 5) Either start the request or enqueue it depending on the current active request count + if ([self isActiveRequestCountBelowMaximumLimit]) { + [self startMergedTask:mergedTask]; + } else { + [self enqueueMergedTask:mergedTask]; + } + + task = mergedTask.task; + }); + if (task) { + return [[AFImageDownloadReceipt alloc] initWithReceiptID:receiptID task:task]; + } else { + return nil; + } +} + +- (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt { + dispatch_sync(self.synchronizationQueue, ^{ + NSString *URLIdentifier = imageDownloadReceipt.task.originalRequest.URL.absoluteString; + AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier]; + NSUInteger index = [mergedTask.responseHandlers indexOfObjectPassingTest:^BOOL(AFImageDownloaderResponseHandler * _Nonnull handler, __unused NSUInteger idx, __unused BOOL * _Nonnull stop) { + return handler.uuid == imageDownloadReceipt.receiptID; + }]; + + if (index != NSNotFound) { + AFImageDownloaderResponseHandler *handler = mergedTask.responseHandlers[index]; + [mergedTask removeResponseHandler:handler]; + NSString *failureReason = [NSString stringWithFormat:@"ImageDownloader cancelled URL request: %@",imageDownloadReceipt.task.originalRequest.URL.absoluteString]; + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey:failureReason}; + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]; + if (handler.failureBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler.failureBlock(imageDownloadReceipt.task.originalRequest, nil, error); + }); + } + } + + if (mergedTask.responseHandlers.count == 0) { + [mergedTask.task cancel]; + [self removeMergedTaskWithURLIdentifier:URLIdentifier]; + } + }); +} + +- (AFImageDownloaderMergedTask *)safelyRemoveMergedTaskWithURLIdentifier:(NSString *)URLIdentifier { + __block AFImageDownloaderMergedTask *mergedTask = nil; + dispatch_sync(self.synchronizationQueue, ^{ + mergedTask = [self removeMergedTaskWithURLIdentifier:URLIdentifier]; + }); + return mergedTask; +} + +//This method should only be called from safely within the synchronizationQueue +- (AFImageDownloaderMergedTask *)removeMergedTaskWithURLIdentifier:(NSString *)URLIdentifier { + AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier]; + [self.mergedTasks removeObjectForKey:URLIdentifier]; + return mergedTask; +} + +- (void)safelyDecrementActiveTaskCount { + dispatch_sync(self.synchronizationQueue, ^{ + if (self.activeRequestCount > 0) { + self.activeRequestCount -= 1; + } + }); +} + +- (void)safelyStartNextTaskIfNecessary { + dispatch_sync(self.synchronizationQueue, ^{ + if ([self isActiveRequestCountBelowMaximumLimit]) { + while (self.queuedMergedTasks.count > 0) { + AFImageDownloaderMergedTask *mergedTask = [self dequeueMergedTask]; + if (mergedTask.task.state == NSURLSessionTaskStateSuspended) { + [self startMergedTask:mergedTask]; + break; + } + } + } + }); +} + +- (void)startMergedTask:(AFImageDownloaderMergedTask *)mergedTask { + [mergedTask.task resume]; + ++self.activeRequestCount; +} + +- (void)enqueueMergedTask:(AFImageDownloaderMergedTask *)mergedTask { + switch (self.downloadPrioritization) { + case AFImageDownloadPrioritizationFIFO: + [self.queuedMergedTasks addObject:mergedTask]; + break; + case AFImageDownloadPrioritizationLIFO: + [self.queuedMergedTasks insertObject:mergedTask atIndex:0]; + break; + } +} + +- (AFImageDownloaderMergedTask *)dequeueMergedTask { + AFImageDownloaderMergedTask *mergedTask = nil; + mergedTask = [self.queuedMergedTasks firstObject]; + [self.queuedMergedTasks removeObject:mergedTask]; + return mergedTask; +} + +- (BOOL)isActiveRequestCountBelowMaximumLimit { + return self.activeRequestCount < self.maximumActiveDownloads; +} + +- (AFImageDownloaderMergedTask *)safelyGetMergedTask:(NSString *)URLIdentifier { + __block AFImageDownloaderMergedTask *mergedTask; + dispatch_sync(self.synchronizationQueue, ^(){ + mergedTask = self.mergedTasks[URLIdentifier]; + }); + return mergedTask; +} + +@end + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h new file mode 100644 index 0000000000000000000000000000000000000000..3bcf2895622d0b2ce026d8731a0df32bcc66563f --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h @@ -0,0 +1,103 @@ +// AFNetworkActivityIndicatorManager.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a session task has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero. + + You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code: + + [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; + + By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. + + See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: + http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 + */ +NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.") +@interface AFNetworkActivityIndicatorManager : NSObject + +/** + A Boolean value indicating whether the manager is enabled. + + If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. + */ +@property (nonatomic, assign, getter = isEnabled) BOOL enabled; + +/** + A Boolean value indicating whether the network activity indicator manager is currently active. +*/ +@property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; + +/** + A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. The default value 1 second. If the network activity indicator should be displayed immediately when network activity occurs, this value should be set to 0 seconds. + + Apple's HIG describes the following: + + > Display the network activity indicator to provide feedback when your app accesses the network for more than a couple of seconds. If the operation finishes sooner than that, you don’t have to show the network activity indicator, because the indicator is likely to disappear before users notice its presence. + + */ +@property (nonatomic, assign) NSTimeInterval activationDelay; + +/** + A time interval indicating the duration of time of no networking activity required before the activity indicator is disabled. This allows for continuous display of the network activity indicator across multiple requests. The default value is 0.17 seconds. + */ + +@property (nonatomic, assign) NSTimeInterval completionDelay; + +/** + Returns the shared network activity indicator manager object for the system. + + @return The systemwide network activity indicator manager. + */ ++ (instancetype)sharedManager; + +/** + Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. + */ +- (void)incrementActivityCount; + +/** + Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. + */ +- (void)decrementActivityCount; + +/** + Set the a custom method to be executed when the network activity indicator manager should be hidden/shown. By default, this is null, and the UIApplication Network Activity Indicator will be managed automatically. If this block is set, it is the responsiblity of the caller to manager the network activity indicator going forward. + + @param block A block to be executed when the network activity indicator status changes. + */ +- (void)setNetworkingActivityActionWithBlock:(nullable void (^)(BOOL networkActivityIndicatorVisible))block; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m new file mode 100644 index 0000000000000000000000000000000000000000..8cb5677effe3ee5475988ef623bb7cb6df067fef --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m @@ -0,0 +1,239 @@ +// AFNetworkActivityIndicatorManager.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFNetworkActivityIndicatorManager.h" + +#if TARGET_OS_IOS +#import "AFURLSessionManager.h" + +typedef NS_ENUM(NSInteger, AFNetworkActivityManagerState) { + AFNetworkActivityManagerStateNotActive, + AFNetworkActivityManagerStateDelayingStart, + AFNetworkActivityManagerStateActive, + AFNetworkActivityManagerStateDelayingEnd +}; + +static NSTimeInterval const kDefaultAFNetworkActivityManagerActivationDelay = 1.0; +static NSTimeInterval const kDefaultAFNetworkActivityManagerCompletionDelay = 0.17; + +static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) { + if ([[notification object] respondsToSelector:@selector(originalRequest)]) { + return [(NSURLSessionTask *)[notification object] originalRequest]; + } else { + return nil; + } +} + +typedef void (^AFNetworkActivityActionBlock)(BOOL networkActivityIndicatorVisible); + +@interface AFNetworkActivityIndicatorManager () +@property (readwrite, nonatomic, assign) NSInteger activityCount; +@property (readwrite, nonatomic, strong) NSTimer *activationDelayTimer; +@property (readwrite, nonatomic, strong) NSTimer *completionDelayTimer; +@property (readonly, nonatomic, getter = isNetworkActivityOccurring) BOOL networkActivityOccurring; +@property (nonatomic, copy) AFNetworkActivityActionBlock networkActivityActionBlock; +@property (nonatomic, assign) AFNetworkActivityManagerState currentState; +@property (nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; + +- (void)updateCurrentStateForNetworkActivityChange; +@end + +@implementation AFNetworkActivityIndicatorManager + ++ (instancetype)sharedManager { + static AFNetworkActivityIndicatorManager *_sharedManager = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _sharedManager = [[self alloc] init]; + }); + + return _sharedManager; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + self.currentState = AFNetworkActivityManagerStateNotActive; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil]; + self.activationDelay = kDefaultAFNetworkActivityManagerActivationDelay; + self.completionDelay = kDefaultAFNetworkActivityManagerCompletionDelay; + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + [_activationDelayTimer invalidate]; + [_completionDelayTimer invalidate]; +} + +- (void)setEnabled:(BOOL)enabled { + _enabled = enabled; + if (enabled == NO) { + [self setCurrentState:AFNetworkActivityManagerStateNotActive]; + } +} + +- (void)setNetworkingActivityActionWithBlock:(void (^)(BOOL networkActivityIndicatorVisible))block { + self.networkActivityActionBlock = block; +} + +- (BOOL)isNetworkActivityOccurring { + @synchronized(self) { + return self.activityCount > 0; + } +} + +- (void)setNetworkActivityIndicatorVisible:(BOOL)networkActivityIndicatorVisible { + if (_networkActivityIndicatorVisible != networkActivityIndicatorVisible) { + @synchronized(self) { + _networkActivityIndicatorVisible = networkActivityIndicatorVisible; + } + if (self.networkActivityActionBlock) { + self.networkActivityActionBlock(networkActivityIndicatorVisible); + } else { + [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:networkActivityIndicatorVisible]; + } + } +} + + +- (void)incrementActivityCount { + @synchronized(self) { + self.activityCount++; + } + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateCurrentStateForNetworkActivityChange]; + }); +} + +- (void)decrementActivityCount { + @synchronized(self) { + self.activityCount = MAX(_activityCount - 1, 0); + } + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateCurrentStateForNetworkActivityChange]; + }); +} + +- (void)networkRequestDidStart:(NSNotification *)notification { + if ([AFNetworkRequestFromNotification(notification) URL]) { + [self incrementActivityCount]; + } +} + +- (void)networkRequestDidFinish:(NSNotification *)notification { + if ([AFNetworkRequestFromNotification(notification) URL]) { + [self decrementActivityCount]; + } +} + +#pragma mark - Internal State Management +- (void)setCurrentState:(AFNetworkActivityManagerState)currentState { + @synchronized(self) { + if (_currentState != currentState) { + _currentState = currentState; + switch (currentState) { + case AFNetworkActivityManagerStateNotActive: + [self cancelActivationDelayTimer]; + [self cancelCompletionDelayTimer]; + [self setNetworkActivityIndicatorVisible:NO]; + break; + case AFNetworkActivityManagerStateDelayingStart: + [self startActivationDelayTimer]; + break; + case AFNetworkActivityManagerStateActive: + [self cancelCompletionDelayTimer]; + [self setNetworkActivityIndicatorVisible:YES]; + break; + case AFNetworkActivityManagerStateDelayingEnd: + [self startCompletionDelayTimer]; + break; + } + } + } +} + +- (void)updateCurrentStateForNetworkActivityChange { + if (self.enabled) { + switch (self.currentState) { + case AFNetworkActivityManagerStateNotActive: + if (self.isNetworkActivityOccurring) { + [self setCurrentState:AFNetworkActivityManagerStateDelayingStart]; + } + break; + case AFNetworkActivityManagerStateDelayingStart: + //No op. Let the delay timer finish out. + break; + case AFNetworkActivityManagerStateActive: + if (!self.isNetworkActivityOccurring) { + [self setCurrentState:AFNetworkActivityManagerStateDelayingEnd]; + } + break; + case AFNetworkActivityManagerStateDelayingEnd: + if (self.isNetworkActivityOccurring) { + [self setCurrentState:AFNetworkActivityManagerStateActive]; + } + break; + } + } +} + +- (void)startActivationDelayTimer { + self.activationDelayTimer = [NSTimer + timerWithTimeInterval:self.activationDelay target:self selector:@selector(activationDelayTimerFired) userInfo:nil repeats:NO]; + [[NSRunLoop mainRunLoop] addTimer:self.activationDelayTimer forMode:NSRunLoopCommonModes]; +} + +- (void)activationDelayTimerFired { + if (self.networkActivityOccurring) { + [self setCurrentState:AFNetworkActivityManagerStateActive]; + } else { + [self setCurrentState:AFNetworkActivityManagerStateNotActive]; + } +} + +- (void)startCompletionDelayTimer { + [self.completionDelayTimer invalidate]; + self.completionDelayTimer = [NSTimer timerWithTimeInterval:self.completionDelay target:self selector:@selector(completionDelayTimerFired) userInfo:nil repeats:NO]; + [[NSRunLoop mainRunLoop] addTimer:self.completionDelayTimer forMode:NSRunLoopCommonModes]; +} + +- (void)completionDelayTimerFired { + [self setCurrentState:AFNetworkActivityManagerStateNotActive]; +} + +- (void)cancelActivationDelayTimer { + [self.activationDelayTimer invalidate]; +} + +- (void)cancelCompletionDelayTimer { + [self.completionDelayTimer invalidate]; +} + +@end + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h new file mode 100644 index 0000000000000000000000000000000000000000..d424c9b86c0b027347e32179169931c65c3f61ef --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h @@ -0,0 +1,48 @@ +// UIActivityIndicatorView+AFNetworking.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +/** + This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task. + */ +@interface UIActivityIndicatorView (AFNetworking) + +///---------------------------------- +/// @name Animating for Session Tasks +///---------------------------------- + +/** + Binds the animating state to the state of the specified task. + + @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +- (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task; + +@end + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m new file mode 100644 index 0000000000000000000000000000000000000000..602a72d07a41e2919fc846302530fea836adbe39 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m @@ -0,0 +1,114 @@ +// UIActivityIndicatorView+AFNetworking.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIActivityIndicatorView+AFNetworking.h" +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFURLSessionManager.h" + +@interface AFActivityIndicatorViewNotificationObserver : NSObject +@property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView; +- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView; + +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; + +@end + +@implementation UIActivityIndicatorView (AFNetworking) + +- (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver { + AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); + if (notificationObserver == nil) { + notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self]; + objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return notificationObserver; +} + +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { + [[self af_notificationObserver] setAnimatingWithStateOfTask:task]; +} + +@end + +@implementation AFActivityIndicatorViewNotificationObserver + +- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView +{ + self = [super init]; + if (self) { + _activityIndicatorView = activityIndicatorView; + } + return self; +} + +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + + if (task) { + if (task.state != NSURLSessionTaskStateCompleted) { + UIActivityIndicatorView *activityIndicatorView = self.activityIndicatorView; + if (task.state == NSURLSessionTaskStateRunning) { + [activityIndicatorView startAnimating]; + } else { + [activityIndicatorView stopAnimating]; + } + + [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; + } + } +} + +#pragma mark - + +- (void)af_startAnimating { + dispatch_async(dispatch_get_main_queue(), ^{ + [self.activityIndicatorView startAnimating]; + }); +} + +- (void)af_stopAnimating { + dispatch_async(dispatch_get_main_queue(), ^{ + [self.activityIndicatorView stopAnimating]; + }); +} + +#pragma mark - + +- (void)dealloc { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; +} + +@end + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h new file mode 100644 index 0000000000000000000000000000000000000000..d33e0d4a3b04d16d6fefda7d3d00a67096adc879 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h @@ -0,0 +1,175 @@ +// UIButton+AFNetworking.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFImageDownloader; + +/** + This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL. + + @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported. + */ +@interface UIButton (AFNetworking) + +///------------------------------------ +/// @name Accessing the Image Downloader +///------------------------------------ + +/** + Set the shared image downloader used to download images. + + @param imageDownloader The shared image downloader used to download images. +*/ ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader; + +/** + The shared image downloader used to download images. + */ ++ (AFImageDownloader *)sharedImageDownloader; + +///-------------------- +/// @name Setting Image +///-------------------- + +/** + Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the image request. + */ +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url; + +/** + Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. + */ +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied. + + @param state The control state. + @param urlRequest The URL request used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + */ +- (void)setImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + + +///------------------------------- +/// @name Setting Background Image +///------------------------------- + +/** + Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled. + + If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the background image request. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url; + +/** + Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the background image request. + @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setBackgroundImage:forState:` is applied. + + @param state The control state. + @param urlRequest The URL request used for the image request. + @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + + +///------------------------------ +/// @name Canceling Image Loading +///------------------------------ + +/** + Cancels any executing image task for the specified control state of the receiver, if one exists. + + @param state The control state. + */ +- (void)cancelImageDownloadTaskForState:(UIControlState)state; + +/** + Cancels any executing background image task for the specified control state of the receiver, if one exists. + + @param state The control state. + */ +- (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m new file mode 100644 index 0000000000000000000000000000000000000000..03aaf2a84e6a3795d196c9590a9036b56523fb0b --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m @@ -0,0 +1,302 @@ +// UIButton+AFNetworking.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIButton+AFNetworking.h" + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "UIImageView+AFNetworking.h" +#import "AFImageDownloader.h" + +@interface UIButton (_AFNetworking) +@end + +@implementation UIButton (_AFNetworking) + +#pragma mark - + +static char AFImageDownloadReceiptNormal; +static char AFImageDownloadReceiptHighlighted; +static char AFImageDownloadReceiptSelected; +static char AFImageDownloadReceiptDisabled; + +static const char * af_imageDownloadReceiptKeyForState(UIControlState state) { + switch (state) { + case UIControlStateHighlighted: + return &AFImageDownloadReceiptHighlighted; + case UIControlStateSelected: + return &AFImageDownloadReceiptSelected; + case UIControlStateDisabled: + return &AFImageDownloadReceiptDisabled; + case UIControlStateNormal: + default: + return &AFImageDownloadReceiptNormal; + } +} + +- (AFImageDownloadReceipt *)af_imageDownloadReceiptForState:(UIControlState)state { + return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_imageDownloadReceiptKeyForState(state)); +} + +- (void)af_setImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt + forState:(UIControlState)state +{ + objc_setAssociatedObject(self, af_imageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +static char AFBackgroundImageDownloadReceiptNormal; +static char AFBackgroundImageDownloadReceiptHighlighted; +static char AFBackgroundImageDownloadReceiptSelected; +static char AFBackgroundImageDownloadReceiptDisabled; + +static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState state) { + switch (state) { + case UIControlStateHighlighted: + return &AFBackgroundImageDownloadReceiptHighlighted; + case UIControlStateSelected: + return &AFBackgroundImageDownloadReceiptSelected; + case UIControlStateDisabled: + return &AFBackgroundImageDownloadReceiptDisabled; + case UIControlStateNormal: + default: + return &AFBackgroundImageDownloadReceiptNormal; + } +} + +- (AFImageDownloadReceipt *)af_backgroundImageDownloadReceiptForState:(UIControlState)state { + return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state)); +} + +- (void)af_setBackgroundImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt + forState:(UIControlState)state +{ + objc_setAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIButton (AFNetworking) + ++ (AFImageDownloader *)sharedImageDownloader { + + return objc_getAssociatedObject([UIButton class], @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance]; +} + ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader { + objc_setAssociatedObject([UIButton class], @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url +{ + [self setImageForState:state withURL:url placeholderImage:nil]; +} + +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure +{ + if ([self isActiveTaskURLEqualToURLRequest:urlRequest forState:state]) { + return; + } + + [self cancelImageDownloadTaskForState:state]; + + AFImageDownloader *downloader = [[self class] sharedImageDownloader]; + id imageCache = downloader.imageCache; + + //Use the image from the image cache if it exists + UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + [self setImage:cachedImage forState:state]; + } + [self af_setImageDownloadReceipt:nil forState:state]; + } else { + if (placeholderImage) { + [self setImage:placeholderImage forState:state]; + } + + __weak __typeof(self)weakSelf = self; + NSUUID *downloadID = [NSUUID UUID]; + AFImageDownloadReceipt *receipt; + receipt = [downloader + downloadImageForURLRequest:urlRequest + withReceiptID:downloadID + success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { + if (success) { + success(request, response, responseObject); + } else if (responseObject) { + [strongSelf setImage:responseObject forState:state]; + } + [strongSelf af_setImageDownloadReceipt:nil forState:state]; + } + + } + failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { + if (failure) { + failure(request, response, error); + } + [strongSelf af_setImageDownloadReceipt:nil forState:state]; + } + }]; + + [self af_setImageDownloadReceipt:receipt forState:state]; + } +} + +#pragma mark - + +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url +{ + [self setBackgroundImageForState:state withURL:url placeholderImage:nil]; +} + +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setBackgroundImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setBackgroundImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure +{ + if ([self isActiveBackgroundTaskURLEqualToURLRequest:urlRequest forState:state]) { + return; + } + + [self cancelBackgroundImageDownloadTaskForState:state]; + + AFImageDownloader *downloader = [[self class] sharedImageDownloader]; + id imageCache = downloader.imageCache; + + //Use the image from the image cache if it exists + UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + [self setBackgroundImage:cachedImage forState:state]; + } + [self af_setBackgroundImageDownloadReceipt:nil forState:state]; + } else { + if (placeholderImage) { + [self setBackgroundImage:placeholderImage forState:state]; + } + + __weak __typeof(self)weakSelf = self; + NSUUID *downloadID = [NSUUID UUID]; + AFImageDownloadReceipt *receipt; + receipt = [downloader + downloadImageForURLRequest:urlRequest + withReceiptID:downloadID + success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { + if (success) { + success(request, response, responseObject); + } else if (responseObject) { + [strongSelf setBackgroundImage:responseObject forState:state]; + } + [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state]; + } + + } + failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { + if (failure) { + failure(request, response, error); + } + [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state]; + } + }]; + + [self af_setBackgroundImageDownloadReceipt:receipt forState:state]; + } +} + +#pragma mark - + +- (void)cancelImageDownloadTaskForState:(UIControlState)state { + AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state]; + if (receipt != nil) { + [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt]; + [self af_setImageDownloadReceipt:nil forState:state]; + } +} + +- (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state { + AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state]; + if (receipt != nil) { + [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt]; + [self af_setBackgroundImageDownloadReceipt:nil forState:state]; + } +} + +- (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state { + AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state]; + return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString]; +} + +- (BOOL)isActiveBackgroundTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state { + AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state]; + return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString]; +} + + +@end + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h new file mode 100644 index 0000000000000000000000000000000000000000..8929252e5a2dd4179c35b5517c68ed5e9772e440 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h @@ -0,0 +1,109 @@ +// UIImageView+AFNetworking.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFImageDownloader; + +/** + This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL. + */ +@interface UIImageView (AFNetworking) + +///------------------------------------ +/// @name Accessing the Image Downloader +///------------------------------------ + +/** + Set the shared image downloader used to download images. + + @param imageDownloader The shared image downloader used to download images. + */ ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader; + +/** + The shared image downloader used to download images. + */ ++ (AFImageDownloader *)sharedImageDownloader; + +///-------------------- +/// @name Setting Image +///-------------------- + +/** + Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` + + @param url The URL used for the image request. + */ +- (void)setImageWithURL:(NSURL *)url; + +/** + Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` + + @param url The URL used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. + */ +- (void)setImageWithURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied. + + @param urlRequest The URL request used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + */ +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + +/** + Cancels any executing image operation for the receiver, if one exists. + */ +- (void)cancelImageDownloadTask; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m new file mode 100644 index 0000000000000000000000000000000000000000..8ae49509e1988b01b866768498a5a0346023a50d --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m @@ -0,0 +1,159 @@ +// UIImageView+AFNetworking.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIImageView+AFNetworking.h" + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFImageDownloader.h" + +@interface UIImageView (_AFNetworking) +@property (readwrite, nonatomic, strong, setter = af_setActiveImageDownloadReceipt:) AFImageDownloadReceipt *af_activeImageDownloadReceipt; +@end + +@implementation UIImageView (_AFNetworking) + +- (AFImageDownloadReceipt *)af_activeImageDownloadReceipt { + return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, @selector(af_activeImageDownloadReceipt)); +} + +- (void)af_setActiveImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt { + objc_setAssociatedObject(self, @selector(af_activeImageDownloadReceipt), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIImageView (AFNetworking) + ++ (AFImageDownloader *)sharedImageDownloader { + return objc_getAssociatedObject([UIImageView class], @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance]; +} + ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader { + objc_setAssociatedObject([UIImageView class], @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setImageWithURL:(NSURL *)url { + [self setImageWithURL:url placeholderImage:nil]; +} + +- (void)setImageWithURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(UIImage *)placeholderImage + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure +{ + if ([urlRequest URL] == nil) { + self.image = placeholderImage; + if (failure) { + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadURL userInfo:nil]; + failure(urlRequest, nil, error); + } + return; + } + + if ([self isActiveTaskURLEqualToURLRequest:urlRequest]) { + return; + } + + [self cancelImageDownloadTask]; + + AFImageDownloader *downloader = [[self class] sharedImageDownloader]; + id imageCache = downloader.imageCache; + + //Use the image from the image cache if it exists + UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + self.image = cachedImage; + } + [self clearActiveDownloadInformation]; + } else { + if (placeholderImage) { + self.image = placeholderImage; + } + + __weak __typeof(self)weakSelf = self; + NSUUID *downloadID = [NSUUID UUID]; + AFImageDownloadReceipt *receipt; + receipt = [downloader + downloadImageForURLRequest:urlRequest + withReceiptID:downloadID + success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) { + if (success) { + success(request, response, responseObject); + } else if (responseObject) { + strongSelf.image = responseObject; + } + [strongSelf clearActiveDownloadInformation]; + } + + } + failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) { + if (failure) { + failure(request, response, error); + } + [strongSelf clearActiveDownloadInformation]; + } + }]; + + self.af_activeImageDownloadReceipt = receipt; + } +} + +- (void)cancelImageDownloadTask { + if (self.af_activeImageDownloadReceipt != nil) { + [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:self.af_activeImageDownloadReceipt]; + [self clearActiveDownloadInformation]; + } +} + +- (void)clearActiveDownloadInformation { + self.af_activeImageDownloadReceipt = nil; +} + +- (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest { + return [self.af_activeImageDownloadReceipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString]; +} + +@end + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h new file mode 100644 index 0000000000000000000000000000000000000000..aa9c0b0281fd6a54b1c6372f013a21977914747f --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h @@ -0,0 +1,43 @@ +// UIKit+AFNetworking.h +// +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#ifndef _UIKIT_AFNETWORKING_ + #define _UIKIT_AFNETWORKING_ + +#if TARGET_OS_IOS || TARGET_OS_TV + #import "AFAutoPurgingImageCache.h" + #import "AFImageDownloader.h" + #import "UIActivityIndicatorView+AFNetworking.h" + #import "UIButton+AFNetworking.h" + #import "UIImageView+AFNetworking.h" + #import "UIProgressView+AFNetworking.h" +#endif + +#if TARGET_OS_IOS + #import "AFNetworkActivityIndicatorManager.h" + #import "UIRefreshControl+AFNetworking.h" + #import "WKWebView+AFNetworking.h" +#endif + +#endif /* _UIKIT_AFNETWORKING_ */ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h new file mode 100644 index 0000000000000000000000000000000000000000..8ea0a731d54fbcccd03c56edda7496be3c002a54 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h @@ -0,0 +1,64 @@ +// UIProgressView+AFNetworking.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +NS_ASSUME_NONNULL_BEGIN + + +/** + This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task. + */ +@interface UIProgressView (AFNetworking) + +///------------------------------------ +/// @name Setting Session Task Progress +///------------------------------------ + +/** + Binds the progress to the upload progress of the specified session task. + + @param task The session task. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task + animated:(BOOL)animated; + +/** + Binds the progress to the download progress of the specified session task. + + @param task The session task. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task + animated:(BOOL)animated; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m new file mode 100644 index 0000000000000000000000000000000000000000..2ae753eca5419197407a936b67e9d3f25e1c6537 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m @@ -0,0 +1,126 @@ +// UIProgressView+AFNetworking.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIProgressView+AFNetworking.h" + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFURLSessionManager.h" + +static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; +static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; + +#pragma mark - + +@implementation UIProgressView (AFNetworking) + +- (BOOL)af_uploadProgressAnimated { + return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; +} + +- (void)af_setUploadProgressAnimated:(BOOL)animated { + objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (BOOL)af_downloadProgressAnimated { + return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; +} + +- (void)af_setDownloadProgressAnimated:(BOOL)animated { + objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task + animated:(BOOL)animated +{ + if (task.state == NSURLSessionTaskStateCompleted) { + return; + } + + [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; + [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; + + [self af_setUploadProgressAnimated:animated]; +} + +- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task + animated:(BOOL)animated +{ + if (task.state == NSURLSessionTaskStateCompleted) { + return; + } + + [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; + [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; + + [self af_setDownloadProgressAnimated:animated]; +} + +#pragma mark - NSKeyValueObserving + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(__unused NSDictionary *)change + context:(void *)context +{ + if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { + if ([object countOfBytesExpectedToSend] > 0) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; + }); + } + } + + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { + if ([object countOfBytesExpectedToReceive] > 0) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; + }); + } + } + + if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { + if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { + @try { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; + + if (context == AFTaskCountOfBytesSentContext) { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; + } + + if (context == AFTaskCountOfBytesReceivedContext) { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; + } + } + @catch (NSException * __unused exception) {} + } + } + } +} + +@end + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h new file mode 100644 index 0000000000000000000000000000000000000000..215eafcf7422aad350583e810d9b035547afaf98 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h @@ -0,0 +1,53 @@ +// UIRefreshControl+AFNetworking.m +// +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a session task. + */ +@interface UIRefreshControl (AFNetworking) + +///----------------------------------- +/// @name Refreshing for Session Tasks +///----------------------------------- + +/** + Binds the refreshing state to the state of the specified task. + + @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m new file mode 100644 index 0000000000000000000000000000000000000000..cd46916a10a4621723e3fc7c039141532b58c238 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m @@ -0,0 +1,113 @@ +// UIRefreshControl+AFNetworking.m +// +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIRefreshControl+AFNetworking.h" +#import + +#if TARGET_OS_IOS + +#import "AFURLSessionManager.h" + +@interface AFRefreshControlNotificationObserver : NSObject +@property (readonly, nonatomic, weak) UIRefreshControl *refreshControl; +- (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl; + +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; + +@end + +@implementation UIRefreshControl (AFNetworking) + +- (AFRefreshControlNotificationObserver *)af_notificationObserver { + AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); + if (notificationObserver == nil) { + notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self]; + objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return notificationObserver; +} + +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { + [[self af_notificationObserver] setRefreshingWithStateOfTask:task]; +} + +@end + +@implementation AFRefreshControlNotificationObserver + +- (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl +{ + self = [super init]; + if (self) { + _refreshControl = refreshControl; + } + return self; +} + +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + + if (task) { + UIRefreshControl *refreshControl = self.refreshControl; + if (task.state == NSURLSessionTaskStateRunning) { + [refreshControl beginRefreshing]; + + [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; + } else { + [refreshControl endRefreshing]; + } + } +} + +#pragma mark - + +- (void)af_beginRefreshing { + dispatch_async(dispatch_get_main_queue(), ^{ + [self.refreshControl beginRefreshing]; + }); +} + +- (void)af_endRefreshing { + dispatch_async(dispatch_get_main_queue(), ^{ + [self.refreshControl endRefreshing]; + }); +} + +#pragma mark - + +- (void)dealloc { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; +} + +@end + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/WKWebView+AFNetworking.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/WKWebView+AFNetworking.h new file mode 100644 index 0000000000000000000000000000000000000000..680fedff806c53c98afcef425b38fbf2b13ed910 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/WKWebView+AFNetworking.h @@ -0,0 +1,80 @@ +// WkWebView+AFNetworking.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFHTTPSessionManager; + +@interface WKWebView (AFNetworking) + +/** + The session manager used to download all request + */ +@property (nonatomic, strong) AFHTTPSessionManager *sessionManager; + +/** + Asynchronously loads the specified request. + + @param request A URL request identifying the location of the content to load. This must not be `nil`. + @param navigation The WKNavigation object that containts information for tracking the loading progress of a webpage. This must not be `nil`. + @param progress A progress object monitoring the current download progress. + @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. + @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. + */ +- (void)loadRequest:(NSURLRequest *)request + navigation:(WKNavigation * _Nonnull)navigation + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress + success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success + failure:(nullable void (^)(NSError *error))failure; + +/** + Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. + + @param request A URL request identifying the location of the content to load. This must not be `nil`. + @param navigation The WKNavigation object that containts information for tracking the loading progress of a webpage. This must not be `nil`. + @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. + @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. + @param progress A progress object monitoring the current download progress. + @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. + @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. + */ +- (void)loadRequest:(NSURLRequest *)request + navigation:(WKNavigation * _Nonnull)navigation + MIMEType:(nullable NSString *)MIMEType + textEncodingName:(nullable NSString *)textEncodingName + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress + success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success + failure:(nullable void (^)(NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/WKWebView+AFNetworking.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/WKWebView+AFNetworking.m new file mode 100644 index 0000000000000000000000000000000000000000..6eca3c3a54b6a3bb57a7081115f482c8a07cc7e6 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/AFNetworking/UIKit+AFNetworking/WKWebView+AFNetworking.m @@ -0,0 +1,154 @@ +// WkWebView+AFNetworking.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "WKWebView+AFNetworking.h" + +#import + +#if TARGET_OS_IOS + +#import "AFHTTPSessionManager.h" +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" + +@interface WKWebView (_AFNetworking) +@property (readwrite, nonatomic, strong, setter = af_setURLSessionTask:) NSURLSessionDataTask *af_URLSessionTask; +@end + +@implementation WKWebView (_AFNetworking) + +- (NSURLSessionDataTask *)af_URLSessionTask { + return (NSURLSessionDataTask *)objc_getAssociatedObject(self, @selector(af_URLSessionTask)); +} + +- (void)af_setURLSessionTask:(NSURLSessionDataTask *)af_URLSessionTask { + objc_setAssociatedObject(self, @selector(af_URLSessionTask), af_URLSessionTask, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation WKWebView (AFNetworking) + +- (AFHTTPSessionManager *)sessionManager { + static AFHTTPSessionManager *_af_defaultHTTPSessionManager = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultHTTPSessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; + _af_defaultHTTPSessionManager.requestSerializer = [AFHTTPRequestSerializer serializer]; + _af_defaultHTTPSessionManager.responseSerializer = [AFHTTPResponseSerializer serializer]; + }); + + return objc_getAssociatedObject(self, @selector(sessionManager)) ?: _af_defaultHTTPSessionManager; +} + +- (void)setSessionManager:(AFHTTPSessionManager *)sessionManager { + objc_setAssociatedObject(self, @selector(sessionManager), sessionManager, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (AFHTTPResponseSerializer *)responseSerializer { + static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; + }); + + return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)loadRequest:(NSURLRequest *)request + navigation:(WKNavigation * _Nonnull)navigation + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress + success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success + failure:(nullable void (^)(NSError *error))failure { + [self loadRequest:request navigation:navigation MIMEType:nil textEncodingName:nil progress:progress success:^NSData * _Nonnull(NSHTTPURLResponse * _Nonnull response, NSData * _Nonnull data) { + NSStringEncoding stringEncoding = NSUTF8StringEncoding; + if (response.textEncodingName) { + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); + if (encoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); + } + } + + NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding]; + if (success) { + string = success(response, string); + } + + return [string dataUsingEncoding:stringEncoding]; + } failure:failure]; +} + +- (void)loadRequest:(NSURLRequest *)request + navigation:(WKNavigation * _Nonnull)navigation + MIMEType:(nullable NSString *)MIMEType + textEncodingName:(nullable NSString *)textEncodingName + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress + success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success + failure:(nullable void (^)(NSError *error))failure { + NSParameterAssert(request); + + if (self.af_URLSessionTask.state == NSURLSessionTaskStateRunning || self.af_URLSessionTask.state == NSURLSessionTaskStateSuspended) { + [self.af_URLSessionTask cancel]; + } + self.af_URLSessionTask = nil; + + __weak __typeof(self)weakSelf = self; + __block NSURLSessionDataTask *dataTask; + __strong __typeof(weakSelf) strongSelf = weakSelf; + __strong __typeof(weakSelf.navigationDelegate) strongSelfDelegate = strongSelf.navigationDelegate; + dataTask = [self.sessionManager dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { + if (error) { + if (failure) { + failure(error); + } + } else { + if (success) { + success((NSHTTPURLResponse *)response, responseObject); + } + [strongSelf loadData:responseObject MIMEType:MIMEType characterEncodingName:textEncodingName baseURL:[dataTask.currentRequest URL]]; + + if ([strongSelfDelegate respondsToSelector:@selector(webView:didFinishNavigation:)]) { + [strongSelfDelegate webView:strongSelf didFinishNavigation:navigation]; + } + } + }]; + self.af_URLSessionTask = dataTask; + if (progress != nil) { + *progress = [self.sessionManager downloadProgressForTask:dataTask]; + } + [self.af_URLSessionTask resume]; + + if ([strongSelfDelegate respondsToSelector:@selector(webView:didStartProvisionalNavigation:)]) { + [strongSelfDelegate webView:self didStartProvisionalNavigation:navigation]; + } +} + +@end + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Manifest.lock b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Manifest.lock new file mode 100644 index 0000000000000000000000000000000000000000..d30ede851e1cbfcf5c2910f3df4c76413d5b59d4 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Manifest.lock @@ -0,0 +1,34 @@ +PODS: + - AFNetworking (4.0.1): + - AFNetworking/NSURLSession (= 4.0.1) + - AFNetworking/Reachability (= 4.0.1) + - AFNetworking/Security (= 4.0.1) + - AFNetworking/Serialization (= 4.0.1) + - AFNetworking/UIKit (= 4.0.1) + - AFNetworking/NSURLSession (4.0.1): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (4.0.1) + - AFNetworking/Security (4.0.1) + - AFNetworking/Serialization (4.0.1) + - AFNetworking/UIKit (4.0.1): + - AFNetworking/NSURLSession + - SSZipArchive (2.4.3) + +DEPENDENCIES: + - AFNetworking + - SSZipArchive + +SPEC REPOS: + trunk: + - AFNetworking + - SSZipArchive + +SPEC CHECKSUMS: + AFNetworking: 3bd23d814e976cd148d7d44c3ab78017b744cd58 + SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef + +PODFILE CHECKSUM: 2206843f5bf8d13c4bb6ed97fc38d3ba27152b2e + +COCOAPODS: 1.14.3 diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Pods.xcodeproj/project.pbxproj b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000000000000000000000000000000..b998bf7a61939e106a1d58624c96ec903e4494c3 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,1083 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 02AD91C5250ED7D91B06BEAC91A5E507 /* mz_os.h in Headers */ = {isa = PBXBuildFile; fileRef = A63962B38329C162D320FD387112E271 /* mz_os.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 059332136CAAB8014F2099D6AC105162 /* mz_strm_split.h in Headers */ = {isa = PBXBuildFile; fileRef = E8EE6A6B117AA25CDE59B3CD94BAC37A /* mz_strm_split.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 065DE38BBF40CBDA59850BC39B8DAFC3 /* Pods-GJLocalDigitalDemo-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 8ADEDC0F0EADCF1BCC93E2224D939752 /* Pods-GJLocalDigitalDemo-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 0AE196DA421B10CE8EADF7027554CD5B /* mz_strm_split.c in Sources */ = {isa = PBXBuildFile; fileRef = B5893860225E985AAC9781368EECD7BA /* mz_strm_split.c */; }; + 0C524450F5579F35CF05958F488670A4 /* mz_zip_rw.c in Sources */ = {isa = PBXBuildFile; fileRef = 88E746748A91E3C108B0DFF6914ED21F /* mz_zip_rw.c */; }; + 0D87C4665F8AD43731710EBBD8CCFCF8 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3B2A0B779CE31153B2C0D8A7F8DC7FE /* Security.framework */; }; + 0EF3774AC45C05C24674C6F390E4B571 /* mz_strm_os.h in Headers */ = {isa = PBXBuildFile; fileRef = CCD5262CB72F38D0F5311CCB5FDAC479 /* mz_strm_os.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 0FC2C7300D3DE350BD73741888D9A1A8 /* AFSecurityPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = B33C044A2F84D3015C6595D0113FA9CF /* AFSecurityPolicy.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 138D5C92E017FCFC4671E77B7449EED9 /* mz_compat.c in Sources */ = {isa = PBXBuildFile; fileRef = B37DB566848FE68FEF80B707D215CA6B /* mz_compat.c */; }; + 18AEFCE986FB74A0B6B092B3BA2267C6 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = C1C985ECB036BD2F7AC199DC8EB78DB8 /* UIImageView+AFNetworking.m */; }; + 19FA9B07CD47A1A2A8299E63070210D2 /* mz_strm_mem.c in Sources */ = {isa = PBXBuildFile; fileRef = AF181D619A729A0C69C2EE4011BA8779 /* mz_strm_mem.c */; }; + 1BC5207ED5AA2B6956BB9CD10C71C1AA /* mz_strm_pkcrypt.h in Headers */ = {isa = PBXBuildFile; fileRef = EE1EC701848A2B150572580928DBBA7A /* mz_strm_pkcrypt.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 1C789E086190CB49AD3473DD4B26450B /* mz.h in Headers */ = {isa = PBXBuildFile; fileRef = 7164D13E99BE24AFD613873976B7F47A /* mz.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 22AD28E260EF21FECAAEF40B04E8E020 /* AFURLSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = DA3CF5FD159CBEE99EEA5F52D9EAFCFF /* AFURLSessionManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 23AEAF5E77D59B98AE79C57BAE746C1A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 952925E838A0DE4D7BDC4EE54022633D /* Foundation.framework */; }; + 255CB9700C81C0AACEF38F42E802272B /* mz_strm_wzaes.c in Sources */ = {isa = PBXBuildFile; fileRef = 15B3DA3DB79D2CE8E66695035E5267A4 /* mz_strm_wzaes.c */; }; + 27A1AA22D234973BA30D8493C546884C /* UIImageView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = BD83EAA1B8A0252DF5F20BF724FCEF63 /* UIImageView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 27AB52C7962046BC8963B2CD626F22BD /* AFNetworkReachabilityManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CFE4B61B29EFA0040448D8C63402A219 /* AFNetworkReachabilityManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 30D23C352773401AE1389972956969C4 /* SSZipArchive.h in Headers */ = {isa = PBXBuildFile; fileRef = 80E9D811D0967922C802D7B9A59BE8E6 /* SSZipArchive.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3101B010CE0AC3675F434497FD7748B9 /* Pods-GJLocalDigitalDemo-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = B52E99CD589FB7928D058922FF7BAB30 /* Pods-GJLocalDigitalDemo-dummy.m */; }; + 33B9A195FDB315F18465CB1BA24D74A9 /* AFHTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 530DBB2104908B74E98F817795E176C0 /* AFHTTPSessionManager.m */; }; + 347731E8D4C4F27FC53DDFAC590481D6 /* AFAutoPurgingImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 541F4A1D94A8F798B3843589044296ED /* AFAutoPurgingImageCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 38B9E9F82A988CAA21601B733C1E92B7 /* mz_strm_pkcrypt.c in Sources */ = {isa = PBXBuildFile; fileRef = 5472A3F4551ED1DCAD3BACCB63A9CBF7 /* mz_strm_pkcrypt.c */; }; + 3E7A25BCE5BAC256FBBA56106C3192CD /* UIKit+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = CED068D74C5143B975EDF6533BCB2B7D /* UIKit+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4DCB59DE84A69063E9485E4D8BF8C637 /* AFNetworking-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = C5FA8A1C38D5247F25A6A4B0BFB3DC46 /* AFNetworking-dummy.m */; }; + 52E68E9AFF4A9C20F05A07F3E55EAF59 /* AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 82308457874FA4047F40E76AA57A1B58 /* AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 534EDA976CDBE519C377D315BA3FD183 /* SSZipCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = BAC01D4D9933D5FB70E99472DCB4BD50 /* SSZipCommon.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 57744CA757400E7183DFC0D37EFB5214 /* WKWebView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 3FEAEF8F0CB111DB3B2B5788B2F8AF27 /* WKWebView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 584233A4CEC7C9AA382A1A43C26B87EE /* AFHTTPSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 3C35473A2ED0009959E81511C2F4C22F /* AFHTTPSessionManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 5BE27AF46E2DE81F61752081EDB7E52B /* AFSecurityPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = AF2B0B7F659B19369D247760609655F9 /* AFSecurityPolicy.m */; }; + 5F800E52E1FE0F1A5F624C09F5BF2FD6 /* mz_zip.c in Sources */ = {isa = PBXBuildFile; fileRef = 37940DAD6681C3750A227C435395FB6A /* mz_zip.c */; }; + 63419018E7222B414E161CD480398E20 /* AFNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D54C5D1CFE4AFEFE10126E77FFD76073 /* AFNetworkReachabilityManager.m */; }; + 637243EE5807271030AE4D9741392852 /* AFURLSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BC1B183ABCF5C73604CF7E6003EC506A /* AFURLSessionManager.m */; }; + 65163D7E6539C8A1D65F5FCBA0E6EFD2 /* UIRefreshControl+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = B0ED6634D97C08CAABB2FE72F0B4DA95 /* UIRefreshControl+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 657D596F7ED1260403D4E064E6BF8CD1 /* WKWebView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 9185C4BCF47C56D2E4895308449D79F7 /* WKWebView+AFNetworking.m */; }; + 6C239323DE74D9551EB571A31A24EC1E /* UIProgressView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = CB598C19E330C370F7A259BFC64D593B /* UIProgressView+AFNetworking.m */; }; + 6DB244706298D81730C5537279B7B635 /* AFNetworking-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BAFDCD3B56BB57D1785A0FF292B2373 /* AFNetworking-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7DB2C0596405DB863CF2B2A489AE2636 /* mz_zip.h in Headers */ = {isa = PBXBuildFile; fileRef = A208235A806E8C54E261A5612BC78640 /* mz_zip.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 7F58BE8838D03B2D5B30E68952FF1E4D /* SSZipArchive-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 386426F665395250825AA8AAF9B3BBD1 /* SSZipArchive-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 801724F329AA434F8BB6A11E96E5805A /* AFAutoPurgingImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CE98226E7AECF7C3FD821181BB71449 /* AFAutoPurgingImageCache.m */; }; + 81C76941D750B3F226E07AE600A67FC6 /* AFURLResponseSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 42CE348B1FC87FAC1A935359E027962B /* AFURLResponseSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 89AECD9F4931EA70C032C83AB105F415 /* mz_os.c in Sources */ = {isa = PBXBuildFile; fileRef = D932896D9D63E8B48C64011FEA26E7DB /* mz_os.c */; }; + 8AB091199F99F1C2E9E67030DAC50F6E /* mz_strm_mem.h in Headers */ = {isa = PBXBuildFile; fileRef = DFA78F2EED163C61145D744465DFC56E /* mz_strm_mem.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 8C4FBC2492C6DDE369B02AEE117ED2BF /* mz_strm.c in Sources */ = {isa = PBXBuildFile; fileRef = 52F9F12F04A69119CC892F1B2C78217C /* mz_strm.c */; }; + 90DF670DC21B9EFD8DFEFC5081073963 /* mz_strm_buf.h in Headers */ = {isa = PBXBuildFile; fileRef = 564DD026E5D646D05290859E33A832E8 /* mz_strm_buf.h */; settings = {ATTRIBUTES = (Project, ); }; }; + 918AD88A49B79CD1B13BAD5415FE5621 /* AFURLRequestSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 38804C173A9FEA10AE98A84B19365E9D /* AFURLRequestSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 97EB8976E78AA2C17544A6453BC1EF04 /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = BCEC46A38342E5D8F60DD118DB39B916 /* AFURLResponseSerialization.m */; }; + 9D420997871F24FEB04C2A77D881E6C9 /* SSZipArchive-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 89F474761D451589EB3780EA1C202D10 /* SSZipArchive-dummy.m */; }; + 9F5D472E0B58C95613C76C43148FC8B5 /* UIButton+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DA8E76D8C5FD7874542BC20E41EA4FC /* UIButton+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A4F447FA7122B13300BD80CE080444F7 /* mz_strm.h in Headers */ = {isa = PBXBuildFile; fileRef = E5D177C8C44AD7D39B6B9763CF3E3FEA /* mz_strm.h */; settings = {ATTRIBUTES = (Project, ); }; }; + A87F265168F263F2BB4361361BF616DF /* mz_crypt_apple.c in Sources */ = {isa = PBXBuildFile; fileRef = 7FE9B2E3582709D4494E405A4E044F3A /* mz_crypt_apple.c */; }; + AAB0384853C90088036B7501CA8ACFE0 /* mz_crypt.h in Headers */ = {isa = PBXBuildFile; fileRef = D3E6136E476BBE98B77415B878420E3C /* mz_crypt.h */; settings = {ATTRIBUTES = (Project, ); }; }; + AC29EE5318026D0BAF479C904536378F /* UIRefreshControl+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 6AFDBBF2F683E048076BE43453D334F2 /* UIRefreshControl+AFNetworking.m */; }; + AD6158AF5746E99C7136F3ECA9423C63 /* UIActivityIndicatorView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = DCE380D30326F673723A413967E4F45A /* UIActivityIndicatorView+AFNetworking.m */; }; + AF48F21F13058D4DA35F3BE185FE03D0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 952925E838A0DE4D7BDC4EE54022633D /* Foundation.framework */; }; + B7DA5AE2EE8808176A31F845A204C190 /* UIButton+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F3376740CD09A8129DCA6A0DDC33951A /* UIButton+AFNetworking.m */; }; + B8AD58C4501F99461CB07AC05DCB8705 /* UIActivityIndicatorView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 534FE7423E727CB2421A3E6A2D514891 /* UIActivityIndicatorView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + B8B4A245FEFA2CE20339CA8CA8BE68EC /* UIProgressView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 511C2BEF03B1CF751614928428ADC4A9 /* UIProgressView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BAB08D6748C698A6AA6DC7D6A2BFFE49 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 838E6D9EB8C10DCFC0F9200607A60E12 /* AFNetworkActivityIndicatorManager.m */; }; + BB4782EE1267513C3BA8E6D226D245E5 /* SSZipArchive.m in Sources */ = {isa = PBXBuildFile; fileRef = D859C22C499B6A93E2BCCDF881D178E6 /* SSZipArchive.m */; }; + BDCCA4A9A781026F988E16D64945E358 /* mz_strm_zlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 7B30A510F8ED4B722EAD18C04B1DD151 /* mz_strm_zlib.c */; }; + BEF4CC97D88ADCD73B93AA179F7E1802 /* mz_compat.h in Headers */ = {isa = PBXBuildFile; fileRef = A89E64DAC36F64C1D4B6B965535CD468 /* mz_compat.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C30DB8F46569FBD4D1C7D7DA0E4B67EC /* mz_zip_rw.h in Headers */ = {isa = PBXBuildFile; fileRef = 7501B012F60F560A69E91C666EC399E9 /* mz_zip_rw.h */; settings = {ATTRIBUTES = (Project, ); }; }; + C3D352F8B703F950FD32936D16968D12 /* mz_crypt.c in Sources */ = {isa = PBXBuildFile; fileRef = 541BDA977901B26F47895577A2C9F3FE /* mz_crypt.c */; }; + CDEF12A353FEBC8FE4E2EA0D3FFAC615 /* AFURLRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = AAFA63E5CEF90A4BACBFA79B2D5317CC /* AFURLRequestSerialization.m */; }; + D3340EC887ADD4CCC83BF67712BC883A /* mz_strm_buf.c in Sources */ = {isa = PBXBuildFile; fileRef = B6719614F0D93DC72F1A76EE74C2E08D /* mz_strm_buf.c */; }; + D9EED6FDF393033C942E5B2149E99B2F /* mz_os_posix.c in Sources */ = {isa = PBXBuildFile; fileRef = 6BDBC240B4D874F0100F7BD3FEC5033B /* mz_os_posix.c */; }; + E8372DA8FDA0830EF5FF160493C0B37A /* AFImageDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = 002B69D04A5DB998C92901A577DA0D4E /* AFImageDownloader.h */; settings = {ATTRIBUTES = (Public, ); }; }; + ED0B81FF1DEC0B138947EA93D22E5A4E /* AFNetworkActivityIndicatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D65888CF0A3A35A98D04F23C87C36CE4 /* AFNetworkActivityIndicatorManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + EDD49521097CC6C3EAF84FFADB04A6EB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 952925E838A0DE4D7BDC4EE54022633D /* Foundation.framework */; }; + EE3B8613CDD20D58260C22D21BC61F38 /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = C2EABE9172822E31698DD347A0AD35CF /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; + EE424ECE443C88A654B2CC271E9F4874 /* mz_strm_wzaes.h in Headers */ = {isa = PBXBuildFile; fileRef = 2082F57F74C699FB7398DE7BF12EAECE /* mz_strm_wzaes.h */; settings = {ATTRIBUTES = (Project, ); }; }; + EF9C00E340B33BA67D9CEF5A2262D15E /* mz_strm_zlib.h in Headers */ = {isa = PBXBuildFile; fileRef = 0E4727156A5D9A1D4BC923CEFFE40221 /* mz_strm_zlib.h */; settings = {ATTRIBUTES = (Project, ); }; }; + EFE936E5DBC6AEE0B47D92500218702C /* ZipArchive.h in Headers */ = {isa = PBXBuildFile; fileRef = 8F3FA9D8BF80F7D2241ACC088A4C9420 /* ZipArchive.h */; settings = {ATTRIBUTES = (Project, ); }; }; + FA57C7B9116769DBBCAEE173060683A3 /* AFImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 94FF0B5F3F71191124B8C967BF245ED1 /* AFImageDownloader.m */; }; + FE8BF7C7018EF47E97426B7D135691A3 /* mz_strm_os_posix.c in Sources */ = {isa = PBXBuildFile; fileRef = 1D1F75F7785646A91299104368A9CF70 /* mz_strm_os_posix.c */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 1DAA0C14BB8E6184F545FC40D1BBD1BE /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = BFDFE7DC352907FC980B868725387E98 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 0130B3724283586C0E9D2A112D4F2AA1; + remoteInfo = AFNetworking; + }; + 6678B88BA8E494D1D04C4BA6505C6E06 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = BFDFE7DC352907FC980B868725387E98 /* Project object */; + proxyType = 1; + remoteGlobalIDString = F60E38364AFF5E1349FF07415B944396; + remoteInfo = SSZipArchive; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 002B69D04A5DB998C92901A577DA0D4E /* AFImageDownloader.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFImageDownloader.h; path = "UIKit+AFNetworking/AFImageDownloader.h"; sourceTree = ""; }; + 0C3F59DC08FD1AEBC715818BF3FE9F00 /* Pods-GJLocalDigitalDemo-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-GJLocalDigitalDemo-acknowledgements.plist"; sourceTree = ""; }; + 0E4727156A5D9A1D4BC923CEFFE40221 /* mz_strm_zlib.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_strm_zlib.h; path = SSZipArchive/minizip/mz_strm_zlib.h; sourceTree = ""; }; + 15B3DA3DB79D2CE8E66695035E5267A4 /* mz_strm_wzaes.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_strm_wzaes.c; path = SSZipArchive/minizip/mz_strm_wzaes.c; sourceTree = ""; }; + 1D1F75F7785646A91299104368A9CF70 /* mz_strm_os_posix.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_strm_os_posix.c; path = SSZipArchive/minizip/mz_strm_os_posix.c; sourceTree = ""; }; + 2082F57F74C699FB7398DE7BF12EAECE /* mz_strm_wzaes.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_strm_wzaes.h; path = SSZipArchive/minizip/mz_strm_wzaes.h; sourceTree = ""; }; + 24B136F0EEABA34F41433F188351B5F2 /* AFNetworking-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "AFNetworking-Info.plist"; sourceTree = ""; }; + 346C98DA53D0BB14C98906AF76E3F718 /* SSZipArchive-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "SSZipArchive-Info.plist"; sourceTree = ""; }; + 37940DAD6681C3750A227C435395FB6A /* mz_zip.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_zip.c; path = SSZipArchive/minizip/mz_zip.c; sourceTree = ""; }; + 37EB579094DC46325006ED31D2D87370 /* Pods-GJLocalDigitalDemo-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-GJLocalDigitalDemo-acknowledgements.markdown"; sourceTree = ""; }; + 386426F665395250825AA8AAF9B3BBD1 /* SSZipArchive-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SSZipArchive-umbrella.h"; sourceTree = ""; }; + 38804C173A9FEA10AE98A84B19365E9D /* AFURLRequestSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLRequestSerialization.h; path = AFNetworking/AFURLRequestSerialization.h; sourceTree = ""; }; + 38903631890BD32509C295392668FBF8 /* SSZipArchive.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SSZipArchive.release.xcconfig; sourceTree = ""; }; + 3C35473A2ED0009959E81511C2F4C22F /* AFHTTPSessionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFHTTPSessionManager.h; path = AFNetworking/AFHTTPSessionManager.h; sourceTree = ""; }; + 3CE98226E7AECF7C3FD821181BB71449 /* AFAutoPurgingImageCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFAutoPurgingImageCache.m; path = "UIKit+AFNetworking/AFAutoPurgingImageCache.m"; sourceTree = ""; }; + 3FEAEF8F0CB111DB3B2B5788B2F8AF27 /* WKWebView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "WKWebView+AFNetworking.h"; path = "UIKit+AFNetworking/WKWebView+AFNetworking.h"; sourceTree = ""; }; + 42CE348B1FC87FAC1A935359E027962B /* AFURLResponseSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLResponseSerialization.h; path = AFNetworking/AFURLResponseSerialization.h; sourceTree = ""; }; + 482BFBB9F2B0C71C7BF96A6847943442 /* AFNetworking.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = AFNetworking.modulemap; sourceTree = ""; }; + 4DA8E76D8C5FD7874542BC20E41EA4FC /* UIButton+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIButton+AFNetworking.h"; path = "UIKit+AFNetworking/UIButton+AFNetworking.h"; sourceTree = ""; }; + 511C2BEF03B1CF751614928428ADC4A9 /* UIProgressView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIProgressView+AFNetworking.h"; path = "UIKit+AFNetworking/UIProgressView+AFNetworking.h"; sourceTree = ""; }; + 52F9F12F04A69119CC892F1B2C78217C /* mz_strm.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_strm.c; path = SSZipArchive/minizip/mz_strm.c; sourceTree = ""; }; + 530DBB2104908B74E98F817795E176C0 /* AFHTTPSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFHTTPSessionManager.m; path = AFNetworking/AFHTTPSessionManager.m; sourceTree = ""; }; + 534FE7423E727CB2421A3E6A2D514891 /* UIActivityIndicatorView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIActivityIndicatorView+AFNetworking.h"; path = "UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h"; sourceTree = ""; }; + 541BDA977901B26F47895577A2C9F3FE /* mz_crypt.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_crypt.c; path = SSZipArchive/minizip/mz_crypt.c; sourceTree = ""; }; + 541F4A1D94A8F798B3843589044296ED /* AFAutoPurgingImageCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFAutoPurgingImageCache.h; path = "UIKit+AFNetworking/AFAutoPurgingImageCache.h"; sourceTree = ""; }; + 5472A3F4551ED1DCAD3BACCB63A9CBF7 /* mz_strm_pkcrypt.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_strm_pkcrypt.c; path = SSZipArchive/minizip/mz_strm_pkcrypt.c; sourceTree = ""; }; + 564DD026E5D646D05290859E33A832E8 /* mz_strm_buf.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_strm_buf.h; path = SSZipArchive/minizip/mz_strm_buf.h; sourceTree = ""; }; + 59A91FBB6E34A560351C7C4608C78C7A /* Pods-GJLocalDigitalDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-GJLocalDigitalDemo.debug.xcconfig"; sourceTree = ""; }; + 5E15DC65DC5A5F2147681241BD82E388 /* AFNetworking-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "AFNetworking-prefix.pch"; sourceTree = ""; }; + 6AFDBBF2F683E048076BE43453D334F2 /* UIRefreshControl+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIRefreshControl+AFNetworking.m"; path = "UIKit+AFNetworking/UIRefreshControl+AFNetworking.m"; sourceTree = ""; }; + 6BDBC240B4D874F0100F7BD3FEC5033B /* mz_os_posix.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_os_posix.c; path = SSZipArchive/minizip/mz_os_posix.c; sourceTree = ""; }; + 7164D13E99BE24AFD613873976B7F47A /* mz.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz.h; path = SSZipArchive/minizip/mz.h; sourceTree = ""; }; + 746AA30ED80BE38061221E10D0FE545E /* AFNetworking.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = AFNetworking.release.xcconfig; sourceTree = ""; }; + 7501B012F60F560A69E91C666EC399E9 /* mz_zip_rw.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_zip_rw.h; path = SSZipArchive/minizip/mz_zip_rw.h; sourceTree = ""; }; + 7B30A510F8ED4B722EAD18C04B1DD151 /* mz_strm_zlib.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_strm_zlib.c; path = SSZipArchive/minizip/mz_strm_zlib.c; sourceTree = ""; }; + 7BAFDCD3B56BB57D1785A0FF292B2373 /* AFNetworking-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "AFNetworking-umbrella.h"; sourceTree = ""; }; + 7FE9B2E3582709D4494E405A4E044F3A /* mz_crypt_apple.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_crypt_apple.c; path = SSZipArchive/minizip/mz_crypt_apple.c; sourceTree = ""; }; + 80E9D811D0967922C802D7B9A59BE8E6 /* SSZipArchive.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SSZipArchive.h; path = SSZipArchive/SSZipArchive.h; sourceTree = ""; }; + 82308457874FA4047F40E76AA57A1B58 /* AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworking.h; path = AFNetworking/AFNetworking.h; sourceTree = ""; }; + 838E6D9EB8C10DCFC0F9200607A60E12 /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFNetworkActivityIndicatorManager.m; path = "UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m"; sourceTree = ""; }; + 88E746748A91E3C108B0DFF6914ED21F /* mz_zip_rw.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_zip_rw.c; path = SSZipArchive/minizip/mz_zip_rw.c; sourceTree = ""; }; + 89F474761D451589EB3780EA1C202D10 /* SSZipArchive-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SSZipArchive-dummy.m"; sourceTree = ""; }; + 8ADEDC0F0EADCF1BCC93E2224D939752 /* Pods-GJLocalDigitalDemo-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-GJLocalDigitalDemo-umbrella.h"; sourceTree = ""; }; + 8F3FA9D8BF80F7D2241ACC088A4C9420 /* ZipArchive.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = ZipArchive.h; path = SSZipArchive/include/ZipArchive.h; sourceTree = ""; }; + 9185C4BCF47C56D2E4895308449D79F7 /* WKWebView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "WKWebView+AFNetworking.m"; path = "UIKit+AFNetworking/WKWebView+AFNetworking.m"; sourceTree = ""; }; + 91B23470DEB9A986332BEB5034234BC7 /* SSZipArchive */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = SSZipArchive; path = SSZipArchive.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 94FF0B5F3F71191124B8C967BF245ED1 /* AFImageDownloader.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFImageDownloader.m; path = "UIKit+AFNetworking/AFImageDownloader.m"; sourceTree = ""; }; + 952925E838A0DE4D7BDC4EE54022633D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + 9CC7CF355B523E1B7117312765E17E4D /* SSZipArchive.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = SSZipArchive.modulemap; sourceTree = ""; }; + 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + A208235A806E8C54E261A5612BC78640 /* mz_zip.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_zip.h; path = SSZipArchive/minizip/mz_zip.h; sourceTree = ""; }; + A4FA15D44DF6BAC7550EDEED10862AA3 /* AFNetworking */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = AFNetworking; path = AFNetworking.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + A63962B38329C162D320FD387112E271 /* mz_os.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_os.h; path = SSZipArchive/minizip/mz_os.h; sourceTree = ""; }; + A89E64DAC36F64C1D4B6B965535CD468 /* mz_compat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_compat.h; path = SSZipArchive/minizip/mz_compat.h; sourceTree = ""; }; + AAFA63E5CEF90A4BACBFA79B2D5317CC /* AFURLRequestSerialization.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLRequestSerialization.m; path = AFNetworking/AFURLRequestSerialization.m; sourceTree = ""; }; + AF181D619A729A0C69C2EE4011BA8779 /* mz_strm_mem.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_strm_mem.c; path = SSZipArchive/minizip/mz_strm_mem.c; sourceTree = ""; }; + AF2B0B7F659B19369D247760609655F9 /* AFSecurityPolicy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFSecurityPolicy.m; path = AFNetworking/AFSecurityPolicy.m; sourceTree = ""; }; + B0ED6634D97C08CAABB2FE72F0B4DA95 /* UIRefreshControl+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIRefreshControl+AFNetworking.h"; path = "UIKit+AFNetworking/UIRefreshControl+AFNetworking.h"; sourceTree = ""; }; + B33C044A2F84D3015C6595D0113FA9CF /* AFSecurityPolicy.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFSecurityPolicy.h; path = AFNetworking/AFSecurityPolicy.h; sourceTree = ""; }; + B37DB566848FE68FEF80B707D215CA6B /* mz_compat.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_compat.c; path = SSZipArchive/minizip/mz_compat.c; sourceTree = ""; }; + B52E99CD589FB7928D058922FF7BAB30 /* Pods-GJLocalDigitalDemo-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-GJLocalDigitalDemo-dummy.m"; sourceTree = ""; }; + B5893860225E985AAC9781368EECD7BA /* mz_strm_split.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_strm_split.c; path = SSZipArchive/minizip/mz_strm_split.c; sourceTree = ""; }; + B6719614F0D93DC72F1A76EE74C2E08D /* mz_strm_buf.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_strm_buf.c; path = SSZipArchive/minizip/mz_strm_buf.c; sourceTree = ""; }; + BAC01D4D9933D5FB70E99472DCB4BD50 /* SSZipCommon.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SSZipCommon.h; path = SSZipArchive/SSZipCommon.h; sourceTree = ""; }; + BC1B183ABCF5C73604CF7E6003EC506A /* AFURLSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLSessionManager.m; path = AFNetworking/AFURLSessionManager.m; sourceTree = ""; }; + BCEC46A38342E5D8F60DD118DB39B916 /* AFURLResponseSerialization.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLResponseSerialization.m; path = AFNetworking/AFURLResponseSerialization.m; sourceTree = ""; }; + BD83EAA1B8A0252DF5F20BF724FCEF63 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+AFNetworking.h"; path = "UIKit+AFNetworking/UIImageView+AFNetworking.h"; sourceTree = ""; }; + BFC784238B8B1468C07FE70BA919F0FC /* Pods-GJLocalDigitalDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-GJLocalDigitalDemo.release.xcconfig"; sourceTree = ""; }; + C1C985ECB036BD2F7AC199DC8EB78DB8 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+AFNetworking.m"; path = "UIKit+AFNetworking/UIImageView+AFNetworking.m"; sourceTree = ""; }; + C1E1EF9E1E40104DBCDCCDF755E7EB77 /* Pods-GJLocalDigitalDemo-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-GJLocalDigitalDemo-frameworks.sh"; sourceTree = ""; }; + C2EABE9172822E31698DD347A0AD35CF /* AFCompatibilityMacros.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFCompatibilityMacros.h; path = AFNetworking/AFCompatibilityMacros.h; sourceTree = ""; }; + C3B2A0B779CE31153B2C0D8A7F8DC7FE /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; }; + C5FA8A1C38D5247F25A6A4B0BFB3DC46 /* AFNetworking-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "AFNetworking-dummy.m"; sourceTree = ""; }; + C6D4602CAF0FBEE83F9627517B48115F /* SSZipArchive.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SSZipArchive.debug.xcconfig; sourceTree = ""; }; + CAED24C3DDD681443B1E0DC1EBE0DE30 /* AFNetworking.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = AFNetworking.debug.xcconfig; sourceTree = ""; }; + CB598C19E330C370F7A259BFC64D593B /* UIProgressView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIProgressView+AFNetworking.m"; path = "UIKit+AFNetworking/UIProgressView+AFNetworking.m"; sourceTree = ""; }; + CCD5262CB72F38D0F5311CCB5FDAC479 /* mz_strm_os.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_strm_os.h; path = SSZipArchive/minizip/mz_strm_os.h; sourceTree = ""; }; + CED068D74C5143B975EDF6533BCB2B7D /* UIKit+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIKit+AFNetworking.h"; path = "UIKit+AFNetworking/UIKit+AFNetworking.h"; sourceTree = ""; }; + CF3EAB2EF98A68EF4292FCD9655DC844 /* Pods-GJLocalDigitalDemo.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Pods-GJLocalDigitalDemo.modulemap"; sourceTree = ""; }; + CFE4B61B29EFA0040448D8C63402A219 /* AFNetworkReachabilityManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworkReachabilityManager.h; path = AFNetworking/AFNetworkReachabilityManager.h; sourceTree = ""; }; + D196D712062B0835F09C6CC9333C3A05 /* SSZipArchive-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SSZipArchive-prefix.pch"; sourceTree = ""; }; + D3E6136E476BBE98B77415B878420E3C /* mz_crypt.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_crypt.h; path = SSZipArchive/minizip/mz_crypt.h; sourceTree = ""; }; + D54C5D1CFE4AFEFE10126E77FFD76073 /* AFNetworkReachabilityManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFNetworkReachabilityManager.m; path = AFNetworking/AFNetworkReachabilityManager.m; sourceTree = ""; }; + D65888CF0A3A35A98D04F23C87C36CE4 /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworkActivityIndicatorManager.h; path = "UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h"; sourceTree = ""; }; + D859C22C499B6A93E2BCCDF881D178E6 /* SSZipArchive.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SSZipArchive.m; path = SSZipArchive/SSZipArchive.m; sourceTree = ""; }; + D932896D9D63E8B48C64011FEA26E7DB /* mz_os.c */ = {isa = PBXFileReference; includeInIndex = 1; name = mz_os.c; path = SSZipArchive/minizip/mz_os.c; sourceTree = ""; }; + DA3CF5FD159CBEE99EEA5F52D9EAFCFF /* AFURLSessionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLSessionManager.h; path = AFNetworking/AFURLSessionManager.h; sourceTree = ""; }; + DCE380D30326F673723A413967E4F45A /* UIActivityIndicatorView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIActivityIndicatorView+AFNetworking.m"; path = "UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m"; sourceTree = ""; }; + DFA78F2EED163C61145D744465DFC56E /* mz_strm_mem.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_strm_mem.h; path = SSZipArchive/minizip/mz_strm_mem.h; sourceTree = ""; }; + E5D177C8C44AD7D39B6B9763CF3E3FEA /* mz_strm.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_strm.h; path = SSZipArchive/minizip/mz_strm.h; sourceTree = ""; }; + E8EE6A6B117AA25CDE59B3CD94BAC37A /* mz_strm_split.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_strm_split.h; path = SSZipArchive/minizip/mz_strm_split.h; sourceTree = ""; }; + EE1EC701848A2B150572580928DBBA7A /* mz_strm_pkcrypt.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = mz_strm_pkcrypt.h; path = SSZipArchive/minizip/mz_strm_pkcrypt.h; sourceTree = ""; }; + EECEA534AEA7F24A467594F4EF18C12E /* Pods-GJLocalDigitalDemo-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-GJLocalDigitalDemo-Info.plist"; sourceTree = ""; }; + F3376740CD09A8129DCA6A0DDC33951A /* UIButton+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIButton+AFNetworking.m"; path = "UIKit+AFNetworking/UIButton+AFNetworking.m"; sourceTree = ""; }; + F97958A768B25355D9E202ADF2890528 /* Pods-GJLocalDigitalDemo */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = "Pods-GJLocalDigitalDemo"; path = Pods_GJLocalDigitalDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8396498059831D50101D446B886BBC06 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + EDD49521097CC6C3EAF84FFADB04A6EB /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CBA59567B13F3EDBCCA091DDD3E51DD3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 23AEAF5E77D59B98AE79C57BAE746C1A /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D95EA27797B56D642F96334D2D40384C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + AF48F21F13058D4DA35F3BE185FE03D0 /* Foundation.framework in Frameworks */, + 0D87C4665F8AD43731710EBBD8CCFCF8 /* Security.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 03421E64000055CBA8D820EC039F959C /* Pods */ = { + isa = PBXGroup; + children = ( + 84857BCF8A3F6B2110DE968D7FAC3AA0 /* AFNetworking */, + AD53551128A20198C6E5C81B193C36D3 /* SSZipArchive */, + ); + name = Pods; + sourceTree = ""; + }; + 1628BF05B4CAFDCC3549A101F5A10A17 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 7CE426AC267333500FABE7BA0A5A42A0 /* iOS */, + ); + name = Frameworks; + sourceTree = ""; + }; + 274CDFF7E6F5D8BCC560A9A36FA230B7 /* Reachability */ = { + isa = PBXGroup; + children = ( + CFE4B61B29EFA0040448D8C63402A219 /* AFNetworkReachabilityManager.h */, + D54C5D1CFE4AFEFE10126E77FFD76073 /* AFNetworkReachabilityManager.m */, + ); + name = Reachability; + sourceTree = ""; + }; + 502E3B15B5EA7E899C6D876CA706807A /* Security */ = { + isa = PBXGroup; + children = ( + B33C044A2F84D3015C6595D0113FA9CF /* AFSecurityPolicy.h */, + AF2B0B7F659B19369D247760609655F9 /* AFSecurityPolicy.m */, + ); + name = Security; + sourceTree = ""; + }; + 510ECC046D90B7EC73A8C8826D80EEE5 /* Targets Support Files */ = { + isa = PBXGroup; + children = ( + FE90993A5C8E7AA3CF08FACF73B828E0 /* Pods-GJLocalDigitalDemo */, + ); + name = "Targets Support Files"; + sourceTree = ""; + }; + 5A911028063B4839853DC65355167CA0 /* UIKit */ = { + isa = PBXGroup; + children = ( + 541F4A1D94A8F798B3843589044296ED /* AFAutoPurgingImageCache.h */, + 3CE98226E7AECF7C3FD821181BB71449 /* AFAutoPurgingImageCache.m */, + 002B69D04A5DB998C92901A577DA0D4E /* AFImageDownloader.h */, + 94FF0B5F3F71191124B8C967BF245ED1 /* AFImageDownloader.m */, + D65888CF0A3A35A98D04F23C87C36CE4 /* AFNetworkActivityIndicatorManager.h */, + 838E6D9EB8C10DCFC0F9200607A60E12 /* AFNetworkActivityIndicatorManager.m */, + 534FE7423E727CB2421A3E6A2D514891 /* UIActivityIndicatorView+AFNetworking.h */, + DCE380D30326F673723A413967E4F45A /* UIActivityIndicatorView+AFNetworking.m */, + 4DA8E76D8C5FD7874542BC20E41EA4FC /* UIButton+AFNetworking.h */, + F3376740CD09A8129DCA6A0DDC33951A /* UIButton+AFNetworking.m */, + BD83EAA1B8A0252DF5F20BF724FCEF63 /* UIImageView+AFNetworking.h */, + C1C985ECB036BD2F7AC199DC8EB78DB8 /* UIImageView+AFNetworking.m */, + CED068D74C5143B975EDF6533BCB2B7D /* UIKit+AFNetworking.h */, + 511C2BEF03B1CF751614928428ADC4A9 /* UIProgressView+AFNetworking.h */, + CB598C19E330C370F7A259BFC64D593B /* UIProgressView+AFNetworking.m */, + B0ED6634D97C08CAABB2FE72F0B4DA95 /* UIRefreshControl+AFNetworking.h */, + 6AFDBBF2F683E048076BE43453D334F2 /* UIRefreshControl+AFNetworking.m */, + 3FEAEF8F0CB111DB3B2B5788B2F8AF27 /* WKWebView+AFNetworking.h */, + 9185C4BCF47C56D2E4895308449D79F7 /* WKWebView+AFNetworking.m */, + ); + name = UIKit; + sourceTree = ""; + }; + 6A8D039D0B6D36E410580006B0C24CC0 /* NSURLSession */ = { + isa = PBXGroup; + children = ( + C2EABE9172822E31698DD347A0AD35CF /* AFCompatibilityMacros.h */, + 3C35473A2ED0009959E81511C2F4C22F /* AFHTTPSessionManager.h */, + 530DBB2104908B74E98F817795E176C0 /* AFHTTPSessionManager.m */, + DA3CF5FD159CBEE99EEA5F52D9EAFCFF /* AFURLSessionManager.h */, + BC1B183ABCF5C73604CF7E6003EC506A /* AFURLSessionManager.m */, + ); + name = NSURLSession; + sourceTree = ""; + }; + 785BE43D3A2ABF52BA4C5C5E0C1CA75C /* Support Files */ = { + isa = PBXGroup; + children = ( + 9CC7CF355B523E1B7117312765E17E4D /* SSZipArchive.modulemap */, + 89F474761D451589EB3780EA1C202D10 /* SSZipArchive-dummy.m */, + 346C98DA53D0BB14C98906AF76E3F718 /* SSZipArchive-Info.plist */, + D196D712062B0835F09C6CC9333C3A05 /* SSZipArchive-prefix.pch */, + 386426F665395250825AA8AAF9B3BBD1 /* SSZipArchive-umbrella.h */, + C6D4602CAF0FBEE83F9627517B48115F /* SSZipArchive.debug.xcconfig */, + 38903631890BD32509C295392668FBF8 /* SSZipArchive.release.xcconfig */, + ); + name = "Support Files"; + path = "../Target Support Files/SSZipArchive"; + sourceTree = ""; + }; + 7CE426AC267333500FABE7BA0A5A42A0 /* iOS */ = { + isa = PBXGroup; + children = ( + 952925E838A0DE4D7BDC4EE54022633D /* Foundation.framework */, + C3B2A0B779CE31153B2C0D8A7F8DC7FE /* Security.framework */, + ); + name = iOS; + sourceTree = ""; + }; + 84857BCF8A3F6B2110DE968D7FAC3AA0 /* AFNetworking */ = { + isa = PBXGroup; + children = ( + 82308457874FA4047F40E76AA57A1B58 /* AFNetworking.h */, + 6A8D039D0B6D36E410580006B0C24CC0 /* NSURLSession */, + 274CDFF7E6F5D8BCC560A9A36FA230B7 /* Reachability */, + 502E3B15B5EA7E899C6D876CA706807A /* Security */, + BA8720B3E016527F5BE80D6A1D40DD60 /* Serialization */, + FB1943ADE18FAC29C5E30CC9679F6ADE /* Support Files */, + 5A911028063B4839853DC65355167CA0 /* UIKit */, + ); + name = AFNetworking; + path = AFNetworking; + sourceTree = ""; + }; + A851DC080746722EB8464723139BA021 /* Products */ = { + isa = PBXGroup; + children = ( + A4FA15D44DF6BAC7550EDEED10862AA3 /* AFNetworking */, + F97958A768B25355D9E202ADF2890528 /* Pods-GJLocalDigitalDemo */, + 91B23470DEB9A986332BEB5034234BC7 /* SSZipArchive */, + ); + name = Products; + sourceTree = ""; + }; + AD53551128A20198C6E5C81B193C36D3 /* SSZipArchive */ = { + isa = PBXGroup; + children = ( + 7164D13E99BE24AFD613873976B7F47A /* mz.h */, + B37DB566848FE68FEF80B707D215CA6B /* mz_compat.c */, + A89E64DAC36F64C1D4B6B965535CD468 /* mz_compat.h */, + 541BDA977901B26F47895577A2C9F3FE /* mz_crypt.c */, + D3E6136E476BBE98B77415B878420E3C /* mz_crypt.h */, + 7FE9B2E3582709D4494E405A4E044F3A /* mz_crypt_apple.c */, + D932896D9D63E8B48C64011FEA26E7DB /* mz_os.c */, + A63962B38329C162D320FD387112E271 /* mz_os.h */, + 6BDBC240B4D874F0100F7BD3FEC5033B /* mz_os_posix.c */, + 52F9F12F04A69119CC892F1B2C78217C /* mz_strm.c */, + E5D177C8C44AD7D39B6B9763CF3E3FEA /* mz_strm.h */, + B6719614F0D93DC72F1A76EE74C2E08D /* mz_strm_buf.c */, + 564DD026E5D646D05290859E33A832E8 /* mz_strm_buf.h */, + AF181D619A729A0C69C2EE4011BA8779 /* mz_strm_mem.c */, + DFA78F2EED163C61145D744465DFC56E /* mz_strm_mem.h */, + CCD5262CB72F38D0F5311CCB5FDAC479 /* mz_strm_os.h */, + 1D1F75F7785646A91299104368A9CF70 /* mz_strm_os_posix.c */, + 5472A3F4551ED1DCAD3BACCB63A9CBF7 /* mz_strm_pkcrypt.c */, + EE1EC701848A2B150572580928DBBA7A /* mz_strm_pkcrypt.h */, + B5893860225E985AAC9781368EECD7BA /* mz_strm_split.c */, + E8EE6A6B117AA25CDE59B3CD94BAC37A /* mz_strm_split.h */, + 15B3DA3DB79D2CE8E66695035E5267A4 /* mz_strm_wzaes.c */, + 2082F57F74C699FB7398DE7BF12EAECE /* mz_strm_wzaes.h */, + 7B30A510F8ED4B722EAD18C04B1DD151 /* mz_strm_zlib.c */, + 0E4727156A5D9A1D4BC923CEFFE40221 /* mz_strm_zlib.h */, + 37940DAD6681C3750A227C435395FB6A /* mz_zip.c */, + A208235A806E8C54E261A5612BC78640 /* mz_zip.h */, + 88E746748A91E3C108B0DFF6914ED21F /* mz_zip_rw.c */, + 7501B012F60F560A69E91C666EC399E9 /* mz_zip_rw.h */, + 80E9D811D0967922C802D7B9A59BE8E6 /* SSZipArchive.h */, + D859C22C499B6A93E2BCCDF881D178E6 /* SSZipArchive.m */, + BAC01D4D9933D5FB70E99472DCB4BD50 /* SSZipCommon.h */, + 8F3FA9D8BF80F7D2241ACC088A4C9420 /* ZipArchive.h */, + 785BE43D3A2ABF52BA4C5C5E0C1CA75C /* Support Files */, + ); + name = SSZipArchive; + path = SSZipArchive; + sourceTree = ""; + }; + BA8720B3E016527F5BE80D6A1D40DD60 /* Serialization */ = { + isa = PBXGroup; + children = ( + 38804C173A9FEA10AE98A84B19365E9D /* AFURLRequestSerialization.h */, + AAFA63E5CEF90A4BACBFA79B2D5317CC /* AFURLRequestSerialization.m */, + 42CE348B1FC87FAC1A935359E027962B /* AFURLResponseSerialization.h */, + BCEC46A38342E5D8F60DD118DB39B916 /* AFURLResponseSerialization.m */, + ); + name = Serialization; + sourceTree = ""; + }; + CF1408CF629C7361332E53B88F7BD30C = { + isa = PBXGroup; + children = ( + 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */, + 1628BF05B4CAFDCC3549A101F5A10A17 /* Frameworks */, + 03421E64000055CBA8D820EC039F959C /* Pods */, + A851DC080746722EB8464723139BA021 /* Products */, + 510ECC046D90B7EC73A8C8826D80EEE5 /* Targets Support Files */, + ); + sourceTree = ""; + }; + FB1943ADE18FAC29C5E30CC9679F6ADE /* Support Files */ = { + isa = PBXGroup; + children = ( + 482BFBB9F2B0C71C7BF96A6847943442 /* AFNetworking.modulemap */, + C5FA8A1C38D5247F25A6A4B0BFB3DC46 /* AFNetworking-dummy.m */, + 24B136F0EEABA34F41433F188351B5F2 /* AFNetworking-Info.plist */, + 5E15DC65DC5A5F2147681241BD82E388 /* AFNetworking-prefix.pch */, + 7BAFDCD3B56BB57D1785A0FF292B2373 /* AFNetworking-umbrella.h */, + CAED24C3DDD681443B1E0DC1EBE0DE30 /* AFNetworking.debug.xcconfig */, + 746AA30ED80BE38061221E10D0FE545E /* AFNetworking.release.xcconfig */, + ); + name = "Support Files"; + path = "../Target Support Files/AFNetworking"; + sourceTree = ""; + }; + FE90993A5C8E7AA3CF08FACF73B828E0 /* Pods-GJLocalDigitalDemo */ = { + isa = PBXGroup; + children = ( + CF3EAB2EF98A68EF4292FCD9655DC844 /* Pods-GJLocalDigitalDemo.modulemap */, + 37EB579094DC46325006ED31D2D87370 /* Pods-GJLocalDigitalDemo-acknowledgements.markdown */, + 0C3F59DC08FD1AEBC715818BF3FE9F00 /* Pods-GJLocalDigitalDemo-acknowledgements.plist */, + B52E99CD589FB7928D058922FF7BAB30 /* Pods-GJLocalDigitalDemo-dummy.m */, + C1E1EF9E1E40104DBCDCCDF755E7EB77 /* Pods-GJLocalDigitalDemo-frameworks.sh */, + EECEA534AEA7F24A467594F4EF18C12E /* Pods-GJLocalDigitalDemo-Info.plist */, + 8ADEDC0F0EADCF1BCC93E2224D939752 /* Pods-GJLocalDigitalDemo-umbrella.h */, + 59A91FBB6E34A560351C7C4608C78C7A /* Pods-GJLocalDigitalDemo.debug.xcconfig */, + BFC784238B8B1468C07FE70BA919F0FC /* Pods-GJLocalDigitalDemo.release.xcconfig */, + ); + name = "Pods-GJLocalDigitalDemo"; + path = "Target Support Files/Pods-GJLocalDigitalDemo"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 003396D637AF061D9B1B816CA9442B47 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 065DE38BBF40CBDA59850BC39B8DAFC3 /* Pods-GJLocalDigitalDemo-umbrella.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 611427CBC37B16A455BA30DDD0F9104D /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 347731E8D4C4F27FC53DDFAC590481D6 /* AFAutoPurgingImageCache.h in Headers */, + EE3B8613CDD20D58260C22D21BC61F38 /* AFCompatibilityMacros.h in Headers */, + 584233A4CEC7C9AA382A1A43C26B87EE /* AFHTTPSessionManager.h in Headers */, + E8372DA8FDA0830EF5FF160493C0B37A /* AFImageDownloader.h in Headers */, + ED0B81FF1DEC0B138947EA93D22E5A4E /* AFNetworkActivityIndicatorManager.h in Headers */, + 52E68E9AFF4A9C20F05A07F3E55EAF59 /* AFNetworking.h in Headers */, + 6DB244706298D81730C5537279B7B635 /* AFNetworking-umbrella.h in Headers */, + 27AB52C7962046BC8963B2CD626F22BD /* AFNetworkReachabilityManager.h in Headers */, + 0FC2C7300D3DE350BD73741888D9A1A8 /* AFSecurityPolicy.h in Headers */, + 918AD88A49B79CD1B13BAD5415FE5621 /* AFURLRequestSerialization.h in Headers */, + 81C76941D750B3F226E07AE600A67FC6 /* AFURLResponseSerialization.h in Headers */, + 22AD28E260EF21FECAAEF40B04E8E020 /* AFURLSessionManager.h in Headers */, + B8AD58C4501F99461CB07AC05DCB8705 /* UIActivityIndicatorView+AFNetworking.h in Headers */, + 9F5D472E0B58C95613C76C43148FC8B5 /* UIButton+AFNetworking.h in Headers */, + 27A1AA22D234973BA30D8493C546884C /* UIImageView+AFNetworking.h in Headers */, + 3E7A25BCE5BAC256FBBA56106C3192CD /* UIKit+AFNetworking.h in Headers */, + B8B4A245FEFA2CE20339CA8CA8BE68EC /* UIProgressView+AFNetworking.h in Headers */, + 65163D7E6539C8A1D65F5FCBA0E6EFD2 /* UIRefreshControl+AFNetworking.h in Headers */, + 57744CA757400E7183DFC0D37EFB5214 /* WKWebView+AFNetworking.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B54E98A0F78F689CE4DC8242F7B2A2DE /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 1C789E086190CB49AD3473DD4B26450B /* mz.h in Headers */, + BEF4CC97D88ADCD73B93AA179F7E1802 /* mz_compat.h in Headers */, + AAB0384853C90088036B7501CA8ACFE0 /* mz_crypt.h in Headers */, + 02AD91C5250ED7D91B06BEAC91A5E507 /* mz_os.h in Headers */, + A4F447FA7122B13300BD80CE080444F7 /* mz_strm.h in Headers */, + 90DF670DC21B9EFD8DFEFC5081073963 /* mz_strm_buf.h in Headers */, + 8AB091199F99F1C2E9E67030DAC50F6E /* mz_strm_mem.h in Headers */, + 0EF3774AC45C05C24674C6F390E4B571 /* mz_strm_os.h in Headers */, + 1BC5207ED5AA2B6956BB9CD10C71C1AA /* mz_strm_pkcrypt.h in Headers */, + 059332136CAAB8014F2099D6AC105162 /* mz_strm_split.h in Headers */, + EE424ECE443C88A654B2CC271E9F4874 /* mz_strm_wzaes.h in Headers */, + EF9C00E340B33BA67D9CEF5A2262D15E /* mz_strm_zlib.h in Headers */, + 7DB2C0596405DB863CF2B2A489AE2636 /* mz_zip.h in Headers */, + C30DB8F46569FBD4D1C7D7DA0E4B67EC /* mz_zip_rw.h in Headers */, + 30D23C352773401AE1389972956969C4 /* SSZipArchive.h in Headers */, + 7F58BE8838D03B2D5B30E68952FF1E4D /* SSZipArchive-umbrella.h in Headers */, + 534EDA976CDBE519C377D315BA3FD183 /* SSZipCommon.h in Headers */, + EFE936E5DBC6AEE0B47D92500218702C /* ZipArchive.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 0130B3724283586C0E9D2A112D4F2AA1 /* AFNetworking */ = { + isa = PBXNativeTarget; + buildConfigurationList = D5480C5D42AA8B0CF0C71E4D89BF03BF /* Build configuration list for PBXNativeTarget "AFNetworking" */; + buildPhases = ( + 611427CBC37B16A455BA30DDD0F9104D /* Headers */, + CAE03210FAC4855FA1090E525AB10480 /* Sources */, + CBA59567B13F3EDBCCA091DDD3E51DD3 /* Frameworks */, + 8A190A17F289F99ECE07124E97ED74B2 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AFNetworking; + productName = AFNetworking; + productReference = A4FA15D44DF6BAC7550EDEED10862AA3 /* AFNetworking */; + productType = "com.apple.product-type.framework"; + }; + E30A29F880FC8551F60AD0A67D4AA32C /* Pods-GJLocalDigitalDemo */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3A4707F1E8D68A127E999E5CDC24F313 /* Build configuration list for PBXNativeTarget "Pods-GJLocalDigitalDemo" */; + buildPhases = ( + 003396D637AF061D9B1B816CA9442B47 /* Headers */, + 301773D7DBA3DE1B41EAF8C5EABBD552 /* Sources */, + 8396498059831D50101D446B886BBC06 /* Frameworks */, + B2D2CF609DC96E49F734BD2AD9A11865 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 593DB7A7CAF08989268D4C751CC2EC13 /* PBXTargetDependency */, + 0964B6773E423050FD1E7639CB439948 /* PBXTargetDependency */, + ); + name = "Pods-GJLocalDigitalDemo"; + productName = Pods_GJLocalDigitalDemo; + productReference = F97958A768B25355D9E202ADF2890528 /* Pods-GJLocalDigitalDemo */; + productType = "com.apple.product-type.framework"; + }; + F60E38364AFF5E1349FF07415B944396 /* SSZipArchive */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5D0A1C5EC006615C1092F876C06EAF4D /* Build configuration list for PBXNativeTarget "SSZipArchive" */; + buildPhases = ( + B54E98A0F78F689CE4DC8242F7B2A2DE /* Headers */, + 5B98828D7A514D1398027374EC0F2A4A /* Sources */, + D95EA27797B56D642F96334D2D40384C /* Frameworks */, + A66CA23A56A2FF4A3BDDEDD5B1558478 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SSZipArchive; + productName = SSZipArchive; + productReference = 91B23470DEB9A986332BEB5034234BC7 /* SSZipArchive */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + BFDFE7DC352907FC980B868725387E98 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1500; + LastUpgradeCheck = 1500; + }; + buildConfigurationList = 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + Base, + en, + ); + mainGroup = CF1408CF629C7361332E53B88F7BD30C; + productRefGroup = A851DC080746722EB8464723139BA021 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 0130B3724283586C0E9D2A112D4F2AA1 /* AFNetworking */, + E30A29F880FC8551F60AD0A67D4AA32C /* Pods-GJLocalDigitalDemo */, + F60E38364AFF5E1349FF07415B944396 /* SSZipArchive */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8A190A17F289F99ECE07124E97ED74B2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A66CA23A56A2FF4A3BDDEDD5B1558478 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B2D2CF609DC96E49F734BD2AD9A11865 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 301773D7DBA3DE1B41EAF8C5EABBD552 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3101B010CE0AC3675F434497FD7748B9 /* Pods-GJLocalDigitalDemo-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5B98828D7A514D1398027374EC0F2A4A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 138D5C92E017FCFC4671E77B7449EED9 /* mz_compat.c in Sources */, + C3D352F8B703F950FD32936D16968D12 /* mz_crypt.c in Sources */, + A87F265168F263F2BB4361361BF616DF /* mz_crypt_apple.c in Sources */, + 89AECD9F4931EA70C032C83AB105F415 /* mz_os.c in Sources */, + D9EED6FDF393033C942E5B2149E99B2F /* mz_os_posix.c in Sources */, + 8C4FBC2492C6DDE369B02AEE117ED2BF /* mz_strm.c in Sources */, + D3340EC887ADD4CCC83BF67712BC883A /* mz_strm_buf.c in Sources */, + 19FA9B07CD47A1A2A8299E63070210D2 /* mz_strm_mem.c in Sources */, + FE8BF7C7018EF47E97426B7D135691A3 /* mz_strm_os_posix.c in Sources */, + 38B9E9F82A988CAA21601B733C1E92B7 /* mz_strm_pkcrypt.c in Sources */, + 0AE196DA421B10CE8EADF7027554CD5B /* mz_strm_split.c in Sources */, + 255CB9700C81C0AACEF38F42E802272B /* mz_strm_wzaes.c in Sources */, + BDCCA4A9A781026F988E16D64945E358 /* mz_strm_zlib.c in Sources */, + 5F800E52E1FE0F1A5F624C09F5BF2FD6 /* mz_zip.c in Sources */, + 0C524450F5579F35CF05958F488670A4 /* mz_zip_rw.c in Sources */, + BB4782EE1267513C3BA8E6D226D245E5 /* SSZipArchive.m in Sources */, + 9D420997871F24FEB04C2A77D881E6C9 /* SSZipArchive-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + CAE03210FAC4855FA1090E525AB10480 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 801724F329AA434F8BB6A11E96E5805A /* AFAutoPurgingImageCache.m in Sources */, + 33B9A195FDB315F18465CB1BA24D74A9 /* AFHTTPSessionManager.m in Sources */, + FA57C7B9116769DBBCAEE173060683A3 /* AFImageDownloader.m in Sources */, + BAB08D6748C698A6AA6DC7D6A2BFFE49 /* AFNetworkActivityIndicatorManager.m in Sources */, + 4DCB59DE84A69063E9485E4D8BF8C637 /* AFNetworking-dummy.m in Sources */, + 63419018E7222B414E161CD480398E20 /* AFNetworkReachabilityManager.m in Sources */, + 5BE27AF46E2DE81F61752081EDB7E52B /* AFSecurityPolicy.m in Sources */, + CDEF12A353FEBC8FE4E2EA0D3FFAC615 /* AFURLRequestSerialization.m in Sources */, + 97EB8976E78AA2C17544A6453BC1EF04 /* AFURLResponseSerialization.m in Sources */, + 637243EE5807271030AE4D9741392852 /* AFURLSessionManager.m in Sources */, + AD6158AF5746E99C7136F3ECA9423C63 /* UIActivityIndicatorView+AFNetworking.m in Sources */, + B7DA5AE2EE8808176A31F845A204C190 /* UIButton+AFNetworking.m in Sources */, + 18AEFCE986FB74A0B6B092B3BA2267C6 /* UIImageView+AFNetworking.m in Sources */, + 6C239323DE74D9551EB571A31A24EC1E /* UIProgressView+AFNetworking.m in Sources */, + AC29EE5318026D0BAF479C904536378F /* UIRefreshControl+AFNetworking.m in Sources */, + 657D596F7ED1260403D4E064E6BF8CD1 /* WKWebView+AFNetworking.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 0964B6773E423050FD1E7639CB439948 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = SSZipArchive; + target = F60E38364AFF5E1349FF07415B944396 /* SSZipArchive */; + targetProxy = 6678B88BA8E494D1D04C4BA6505C6E06 /* PBXContainerItemProxy */; + }; + 593DB7A7CAF08989268D4C751CC2EC13 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = AFNetworking; + target = 0130B3724283586C0E9D2A112D4F2AA1 /* AFNetworking */; + targetProxy = 1DAA0C14BB8E6184F545FC40D1BBD1BE /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 2B9E26EAE2CD392AD762421F663075A1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_DEBUG=1", + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + STRIP_INSTALLED_PRODUCT = NO; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Debug; + }; + 63FAF33E1C55B71A5F5A8B3CC8749F99 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "POD_CONFIGURATION_RELEASE=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + STRIP_INSTALLED_PRODUCT = NO; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_VERSION = 5.0; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Release; + }; + 66AE5BF3EB9BED21906F3969F27B408B /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C6D4602CAF0FBEE83F9627517B48115F /* SSZipArchive.debug.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/SSZipArchive/SSZipArchive-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/SSZipArchive/SSZipArchive-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MODULEMAP_FILE = "Target Support Files/SSZipArchive/SSZipArchive.modulemap"; + PRODUCT_MODULE_NAME = SSZipArchive; + PRODUCT_NAME = SSZipArchive; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 796DC4304ED75B409BD507C2856E9EBA /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 38903631890BD32509C295392668FBF8 /* SSZipArchive.release.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/SSZipArchive/SSZipArchive-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/SSZipArchive/SSZipArchive-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MODULEMAP_FILE = "Target Support Files/SSZipArchive/SSZipArchive.modulemap"; + PRODUCT_MODULE_NAME = SSZipArchive; + PRODUCT_NAME = SSZipArchive; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 80344A194E5B0B3EC11B1DFCF0360690 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 746AA30ED80BE38061221E10D0FE545E /* AFNetworking.release.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/AFNetworking/AFNetworking-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/AFNetworking/AFNetworking-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MODULEMAP_FILE = "Target Support Files/AFNetworking/AFNetworking.modulemap"; + PRODUCT_MODULE_NAME = AFNetworking; + PRODUCT_NAME = AFNetworking; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + C6297683104CC7AAF44E6D64FE93CE0D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = BFC784238B8B1468C07FE70BA919F0FC /* Pods-GJLocalDigitalDemo.release.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + CLANG_ENABLE_OBJC_WEAK = NO; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.modulemap"; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + CE82259E8755F62223B25EE70D0CEAB5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = CAED24C3DDD681443B1E0DC1EBE0DE30 /* AFNetworking.debug.xcconfig */; + buildSettings = { + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/AFNetworking/AFNetworking-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/AFNetworking/AFNetworking-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MODULEMAP_FILE = "Target Support Files/AFNetworking/AFNetworking.modulemap"; + PRODUCT_MODULE_NAME = AFNetworking; + PRODUCT_NAME = AFNetworking; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + CF311BD260EC19F2E08C1E316319EF44 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 59A91FBB6E34A560351C7C4608C78C7A /* Pods-GJLocalDigitalDemo.debug.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + CLANG_ENABLE_OBJC_WEAK = NO; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.modulemap"; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3A4707F1E8D68A127E999E5CDC24F313 /* Build configuration list for PBXNativeTarget "Pods-GJLocalDigitalDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CF311BD260EC19F2E08C1E316319EF44 /* Debug */, + C6297683104CC7AAF44E6D64FE93CE0D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2B9E26EAE2CD392AD762421F663075A1 /* Debug */, + 63FAF33E1C55B71A5F5A8B3CC8749F99 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 5D0A1C5EC006615C1092F876C06EAF4D /* Build configuration list for PBXNativeTarget "SSZipArchive" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 66AE5BF3EB9BED21906F3969F27B408B /* Debug */, + 796DC4304ED75B409BD507C2856E9EBA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D5480C5D42AA8B0CF0C71E4D89BF03BF /* Build configuration list for PBXNativeTarget "AFNetworking" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + CE82259E8755F62223B25EE70D0CEAB5 /* Debug */, + 80344A194E5B0B3EC11B1DFCF0360690 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = BFDFE7DC352907FC980B868725387E98 /* Project object */; +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Pods.xcodeproj/xcuserdata/guiji.xcuserdatad/xcschemes/AFNetworking.xcscheme b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Pods.xcodeproj/xcuserdata/guiji.xcuserdatad/xcschemes/AFNetworking.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..918e170e7bb2789340e81045c27c37654c0715b0 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Pods.xcodeproj/xcuserdata/guiji.xcuserdatad/xcschemes/AFNetworking.xcscheme @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Pods.xcodeproj/xcuserdata/guiji.xcuserdatad/xcschemes/Pods-GJLocalDigitalDemo.xcscheme b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Pods.xcodeproj/xcuserdata/guiji.xcuserdatad/xcschemes/Pods-GJLocalDigitalDemo.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..357192b5d17ea322acd177d540185066cd5f0df1 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Pods.xcodeproj/xcuserdata/guiji.xcuserdatad/xcschemes/Pods-GJLocalDigitalDemo.xcscheme @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Pods.xcodeproj/xcuserdata/guiji.xcuserdatad/xcschemes/SSZipArchive.xcscheme b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Pods.xcodeproj/xcuserdata/guiji.xcuserdatad/xcschemes/SSZipArchive.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..29dfb5496f553c63e56fb8bbf0dff8933f15962c --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Pods.xcodeproj/xcuserdata/guiji.xcuserdatad/xcschemes/SSZipArchive.xcscheme @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/LICENSE.txt b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..1cc4a4a90b5712ac07f0b32a72a69aa43d79392b --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/LICENSE.txt @@ -0,0 +1,20 @@ +Copyright (c) 2013-2021, ZipArchive, https://github.com/ZipArchive + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/README.md b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7e038c3b62c14c0bf251bad1f351572e70b45cab --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/README.md @@ -0,0 +1,88 @@ +[![CI](https://github.com/ZipArchive/ZipArchive/workflows/CI/badge.svg)](https://github.com/ZipArchive/ZipArchive/actions?query=workflow%3ACI) + +# SSZipArchive + +ZipArchive is a simple utility class for zipping and unzipping files on iOS, macOS and tvOS. + +- Unzip zip files; +- Unzip password protected zip files; +- Unzip AES encrypted zip files; +- Create zip files; +- Create large (> 4.3Gb) files; +- Create password protected zip files; +- Create AES encrypted zip files; +- Choose compression level; +- Zip-up NSData instances. (with a filename) + +## Installation and Setup + +*The main release branch is configured to support Objective-C and Swift 3+.* + +SSZipArchive works on Xcode 7 and above, iOS 9 and above, tvOS 9 and above, macOS 10.9 and above, watchOS 2 and above. + +### CocoaPods +In your Podfile: +`pod 'SSZipArchive'` + +You should define your minimum deployment target explicitly, like: +`platform :ios, '9.0'` + +Recommended CocoaPods version should be at least CocoaPods 1.7.5. + +### SPM +Add a Swift Package reference to https://github.com/ZipArchive/ZipArchive.git (SSZipArchive 2.4.2 and higher or master) + +### Carthage +In your Cartfile: +`github "ZipArchive/ZipArchive"` + +Note: We are no longer releasing a Carthage pre-built package as of 2.2.3. Developers are encouraged to build one themselves. + +### Manual + +1. Add the `SSZipArchive` and `minizip` folders to your project. +2. Add the `libz` and `libiconv` libraries to your target. +3. Add the `Security` framework to your target. +4. Add the following GCC_PREPROCESSOR_DEFINITIONS: `HAVE_INTTYPES_H HAVE_PKCRYPT HAVE_STDINT_H HAVE_WZAES HAVE_ZLIB $(inherited)`. + +SSZipArchive requires ARC. + +## Usage + +### Objective-C + +```objective-c + +//Import "#import " for SPM/Carthage, and "#import " for CocoaPods. + +// Create +[SSZipArchive createZipFileAtPath:zipPath withContentsOfDirectory:sampleDataPath]; + +// Unzip +[SSZipArchive unzipFileAtPath:zipPath toDestination:unzipPath]; +``` + +### Swift + +```swift +//Import "import ZipArchive" for SPM/Carthage, and "import SSZipArchive" for CocoaPods. + +// Create +SSZipArchive.createZipFileAtPath(zipPath, withContentsOfDirectory: sampleDataPath) + +// Unzip +SSZipArchive.unzipFileAtPath(zipPath, toDestination: unzipPath) +``` + +## License + +SSZipArchive is protected under the [MIT license](https://github.com/samsoffes/ssziparchive/raw/master/LICENSE) and our slightly modified version of [minizip-ng (formally minizip)](https://github.com/zlib-ng/minizip-ng) 3.0.2 is licensed under the [Zlib license](https://www.zlib.net/zlib_license.html). + +## Acknowledgments + +* Big thanks to *aish* for creating [ZipArchive](https://code.google.com/archive/p/ziparchive/). The project that inspired SSZipArchive. +* Thank you [@soffes](https://github.com/soffes) for the actual name of SSZipArchive. +* Thank you [@randomsequence](https://github.com/randomsequence) for implementing the creation support tech. +* Thank you [@johnezang](https://github.com/johnezang) for all his amazing help along the way. +* Thank you [@nmoinvaz](https://github.com/nmoinvaz) for minizip-ng (formally minizip), the core of ZipArchive. +* Thank you to [all the contributors](https://github.com/ZipArchive/ZipArchive/graphs/contributors). diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/SSZipArchive.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/SSZipArchive.h new file mode 100644 index 0000000000000000000000000000000000000000..242b9a7bb2afd958a9f78281137bb3ac4a98f521 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/SSZipArchive.h @@ -0,0 +1,165 @@ +// +// SSZipArchive.h +// SSZipArchive +// +// Created by Sam Soffes on 7/21/10. +// + +#ifndef _SSZIPARCHIVE_H +#define _SSZIPARCHIVE_H + +#import + +#import "SSZipCommon.h" + +NS_ASSUME_NONNULL_BEGIN + +extern NSString *const SSZipArchiveErrorDomain; +typedef NS_ENUM(NSInteger, SSZipArchiveErrorCode) { + SSZipArchiveErrorCodeFailedOpenZipFile = -1, + SSZipArchiveErrorCodeFailedOpenFileInZip = -2, + SSZipArchiveErrorCodeFileInfoNotLoadable = -3, + SSZipArchiveErrorCodeFileContentNotReadable = -4, + SSZipArchiveErrorCodeFailedToWriteFile = -5, + SSZipArchiveErrorCodeInvalidArguments = -6, +}; + +@protocol SSZipArchiveDelegate; + +@interface SSZipArchive : NSObject + +// Password check ++ (BOOL)isFilePasswordProtectedAtPath:(NSString *)path; ++ (BOOL)isPasswordValidForArchiveAtPath:(NSString *)path password:(NSString *)pw error:(NSError * _Nullable * _Nullable)error NS_SWIFT_NOTHROW; + +// Total payload size ++ (NSNumber *)payloadSizeForArchiveAtPath:(NSString *)path error:(NSError **)error; + +// Unzip ++ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination; ++ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination delegate:(nullable id)delegate; + ++ (BOOL)unzipFileAtPath:(NSString *)path + toDestination:(NSString *)destination + overwrite:(BOOL)overwrite + password:(nullable NSString *)password + error:(NSError * *)error; + ++ (BOOL)unzipFileAtPath:(NSString *)path + toDestination:(NSString *)destination + overwrite:(BOOL)overwrite + password:(nullable NSString *)password + error:(NSError * *)error + delegate:(nullable id)delegate NS_REFINED_FOR_SWIFT; + ++ (BOOL)unzipFileAtPath:(NSString *)path + toDestination:(NSString *)destination + preserveAttributes:(BOOL)preserveAttributes + overwrite:(BOOL)overwrite + password:(nullable NSString *)password + error:(NSError * *)error + delegate:(nullable id)delegate; + ++ (BOOL)unzipFileAtPath:(NSString *)path + toDestination:(NSString *)destination + progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler + completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler; + ++ (BOOL)unzipFileAtPath:(NSString *)path + toDestination:(NSString *)destination + overwrite:(BOOL)overwrite + password:(nullable NSString *)password + progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler + completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler; + ++ (BOOL)unzipFileAtPath:(NSString *)path + toDestination:(NSString *)destination + preserveAttributes:(BOOL)preserveAttributes + overwrite:(BOOL)overwrite + nestedZipLevel:(NSInteger)nestedZipLevel + password:(nullable NSString *)password + error:(NSError **)error + delegate:(nullable id)delegate + progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler + completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler; + +// Zip +// default compression level is Z_DEFAULT_COMPRESSION (from "zlib.h") +// keepParentDirectory: if YES, then unzipping will give `directoryName/fileName`. If NO, then unzipping will just give `fileName`. Default is NO. + +// without password ++ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths; ++ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath; + ++ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory; + +// with optional password, default encryption is AES +// don't use AES if you need compatibility with native macOS unzip and Archive Utility ++ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths withPassword:(nullable NSString *)password; ++ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths withPassword:(nullable NSString *)password progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler; ++ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath withPassword:(nullable NSString *)password; ++ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password; ++ (BOOL)createZipFileAtPath:(NSString *)path + withContentsOfDirectory:(NSString *)directoryPath + keepParentDirectory:(BOOL)keepParentDirectory + withPassword:(nullable NSString *)password + andProgressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler; ++ (BOOL)createZipFileAtPath:(NSString *)path + withContentsOfDirectory:(NSString *)directoryPath + keepParentDirectory:(BOOL)keepParentDirectory + compressionLevel:(int)compressionLevel + password:(nullable NSString *)password + AES:(BOOL)aes + progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler; +//suport symlink compress --file ++ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths withPassword:(nullable NSString *)password keepSymlinks:(BOOL)keeplinks; +//suport symlink compress --directory ++ (BOOL)createZipFileAtPath:(NSString *)path + withContentsOfDirectory:(NSString *)directoryPath + keepParentDirectory:(BOOL)keepParentDirectory + compressionLevel:(int)compressionLevel + password:(nullable NSString *)password + AES:(BOOL)aes + progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler + keepSymlinks:(BOOL)keeplinks; + +- (instancetype)init NS_UNAVAILABLE; +- (instancetype)initWithPath:(NSString *)path NS_DESIGNATED_INITIALIZER; +- (BOOL)open; +- (BOOL)openForAppending; + +/// write empty folder +- (BOOL)writeFolderAtPath:(NSString *)path withFolderName:(NSString *)folderName withPassword:(nullable NSString *)password; +/// write file +- (BOOL)writeFile:(NSString *)path withPassword:(nullable NSString *)password; +- (BOOL)writeFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName withPassword:(nullable NSString *)password; +- (BOOL)writeFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes; +///write symlink files +- (BOOL)writeSymlinkFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes; +/// write data +- (BOOL)writeData:(NSData *)data filename:(nullable NSString *)filename withPassword:(nullable NSString *)password; +- (BOOL)writeData:(NSData *)data filename:(nullable NSString *)filename compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes; + +- (BOOL)close; + +@end + +@protocol SSZipArchiveDelegate + +@optional + +- (void)zipArchiveWillUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo; +- (void)zipArchiveDidUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo unzippedPath:(NSString *)unzippedPath; + +- (BOOL)zipArchiveShouldUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo; +- (void)zipArchiveWillUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo; +- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo; +- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath unzippedFilePath:(NSString *)unzippedFilePath; + +- (void)zipArchiveProgressEvent:(unsigned long long)loaded total:(unsigned long long)total; + +@end + +NS_ASSUME_NONNULL_END + +#endif /* _SSZIPARCHIVE_H */ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/SSZipArchive.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/SSZipArchive.m new file mode 100644 index 0000000000000000000000000000000000000000..7184d107360baa9f8d2ab2a60251a04a9fc473cf --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/SSZipArchive.m @@ -0,0 +1,1433 @@ +// +// SSZipArchive.m +// SSZipArchive +// +// Created by Sam Soffes on 7/21/10. +// + +#import "SSZipArchive.h" +#include "minizip/mz_compat.h" +#include "minizip/mz_zip.h" +#include "minizip/mz_os.h" +#include +#include + +NSString *const SSZipArchiveErrorDomain = @"SSZipArchiveErrorDomain"; + +#define CHUNK 16384 + +int _zipOpenEntry(zipFile entry, NSString *name, const zip_fileinfo *zipfi, int level, NSString *password, BOOL aes); +BOOL _fileIsSymbolicLink(const unz_file_info *fileInfo); + +#ifndef API_AVAILABLE +// Xcode 7- compatibility +#define API_AVAILABLE(...) +#endif + +@interface NSData(SSZipArchive) +- (NSString *)_base64RFC4648 API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0)); +- (NSString *)_hexString; +@end + +@interface NSString (SSZipArchive) +- (NSString *)_sanitizedPath; +@end + +@interface SSZipArchive () +- (instancetype)init NS_DESIGNATED_INITIALIZER; +@end + +@implementation SSZipArchive +{ + /// path for zip file + NSString *_path; + zipFile _zip; +} + +#pragma mark - Password check + ++ (BOOL)isFilePasswordProtectedAtPath:(NSString *)path { + // Begin opening + zipFile zip = unzOpen(path.fileSystemRepresentation); + if (zip == NULL) { + return NO; + } + + BOOL passwordProtected = NO; + int ret = unzGoToFirstFile(zip); + if (ret == UNZ_OK) { + do { + ret = unzOpenCurrentFile(zip); + if (ret != UNZ_OK) { + // attempting with an arbitrary password to workaround `unzOpenCurrentFile` limitation on AES encrypted files + ret = unzOpenCurrentFilePassword(zip, ""); + unzCloseCurrentFile(zip); + if (ret == UNZ_OK || ret == MZ_PASSWORD_ERROR) { + passwordProtected = YES; + } + break; + } + unz_file_info fileInfo = {}; + ret = unzGetCurrentFileInfo(zip, &fileInfo, NULL, 0, NULL, 0, NULL, 0); + unzCloseCurrentFile(zip); + if (ret != UNZ_OK) { + break; + } else if ((fileInfo.flag & MZ_ZIP_FLAG_ENCRYPTED) == 1) { + passwordProtected = YES; + break; + } + + ret = unzGoToNextFile(zip); + } while (ret == UNZ_OK); + } + + unzClose(zip); + return passwordProtected; +} + ++ (BOOL)isPasswordValidForArchiveAtPath:(NSString *)path password:(NSString *)pw error:(NSError **)error { + if (error) { + *error = nil; + } + + zipFile zip = unzOpen(path.fileSystemRepresentation); + if (zip == NULL) { + if (error) { + *error = [NSError errorWithDomain:SSZipArchiveErrorDomain + code:SSZipArchiveErrorCodeFailedOpenZipFile + userInfo:@{NSLocalizedDescriptionKey: @"failed to open zip file"}]; + } + return NO; + } + + // Initialize passwordValid to YES (No password required) + BOOL passwordValid = YES; + int ret = unzGoToFirstFile(zip); + if (ret == UNZ_OK) { + do { + if (pw.length == 0) { + ret = unzOpenCurrentFile(zip); + } else { + ret = unzOpenCurrentFilePassword(zip, [pw cStringUsingEncoding:NSUTF8StringEncoding]); + } + if (ret != UNZ_OK) { + if (ret != MZ_PASSWORD_ERROR) { + if (error) { + *error = [NSError errorWithDomain:SSZipArchiveErrorDomain + code:SSZipArchiveErrorCodeFailedOpenFileInZip + userInfo:@{NSLocalizedDescriptionKey: @"failed to open file in zip archive"}]; + } + } + passwordValid = NO; + break; + } + unz_file_info fileInfo = {}; + ret = unzGetCurrentFileInfo(zip, &fileInfo, NULL, 0, NULL, 0, NULL, 0); + if (ret != UNZ_OK) { + if (error) { + *error = [NSError errorWithDomain:SSZipArchiveErrorDomain + code:SSZipArchiveErrorCodeFileInfoNotLoadable + userInfo:@{NSLocalizedDescriptionKey: @"failed to retrieve info for file"}]; + } + passwordValid = NO; + break; + } else if ((fileInfo.flag & 1) == 1) { + unsigned char buffer[10] = {0}; + int readBytes = unzReadCurrentFile(zip, buffer, (unsigned)MIN(10UL,fileInfo.uncompressed_size)); + if (readBytes < 0) { + // Let's assume error Z_DATA_ERROR is caused by an invalid password + // Let's assume other errors are caused by Content Not Readable + if (readBytes != Z_DATA_ERROR) { + if (error) { + *error = [NSError errorWithDomain:SSZipArchiveErrorDomain + code:SSZipArchiveErrorCodeFileContentNotReadable + userInfo:@{NSLocalizedDescriptionKey: @"failed to read contents of file entry"}]; + } + } + passwordValid = NO; + break; + } + passwordValid = YES; + break; + } + + unzCloseCurrentFile(zip); + ret = unzGoToNextFile(zip); + } while (ret == UNZ_OK); + } + + unzClose(zip); + return passwordValid; +} + ++ (NSNumber *)payloadSizeForArchiveAtPath:(NSString *)path error:(NSError **)error { + if (error) { + *error = nil; + } + + zipFile zip = unzOpen(path.fileSystemRepresentation); + if (zip == NULL) { + if (error) { + *error = [NSError errorWithDomain:SSZipArchiveErrorDomain + code:SSZipArchiveErrorCodeFailedOpenZipFile + userInfo:@{NSLocalizedDescriptionKey: @"failed to open zip file"}]; + } + return @0; + } + + unsigned long long totalSize = 0; + int ret = unzGoToFirstFile(zip); + if (ret == UNZ_OK) { + do { + ret = unzOpenCurrentFile(zip); + if (ret != UNZ_OK) { + if (error) { + *error = [NSError errorWithDomain:SSZipArchiveErrorDomain + code:SSZipArchiveErrorCodeFailedOpenFileInZip + userInfo:@{NSLocalizedDescriptionKey: @"failed to open file in zip archive"}]; + } + break; + } + unz_file_info fileInfo = {}; + ret = unzGetCurrentFileInfo(zip, &fileInfo, NULL, 0, NULL, 0, NULL, 0); + if (ret != UNZ_OK) { + if (error) { + *error = [NSError errorWithDomain:SSZipArchiveErrorDomain + code:SSZipArchiveErrorCodeFileInfoNotLoadable + userInfo:@{NSLocalizedDescriptionKey: @"failed to retrieve info for file"}]; + } + break; + } + + totalSize += fileInfo.uncompressed_size; + + unzCloseCurrentFile(zip); + ret = unzGoToNextFile(zip); + } while (ret == UNZ_OK); + } + + unzClose(zip); + + return [NSNumber numberWithUnsignedLongLong:totalSize]; +} + +#pragma mark - Unzipping + ++ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination +{ + return [self unzipFileAtPath:path toDestination:destination delegate:nil]; +} + ++ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination overwrite:(BOOL)overwrite password:(nullable NSString *)password error:(NSError **)error +{ + return [self unzipFileAtPath:path toDestination:destination preserveAttributes:YES overwrite:overwrite password:password error:error delegate:nil progressHandler:nil completionHandler:nil]; +} + ++ (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination delegate:(nullable id)delegate +{ + return [self unzipFileAtPath:path toDestination:destination preserveAttributes:YES overwrite:YES password:nil error:nil delegate:delegate progressHandler:nil completionHandler:nil]; +} + ++ (BOOL)unzipFileAtPath:(NSString *)path + toDestination:(NSString *)destination + overwrite:(BOOL)overwrite + password:(nullable NSString *)password + error:(NSError **)error + delegate:(nullable id)delegate +{ + return [self unzipFileAtPath:path toDestination:destination preserveAttributes:YES overwrite:overwrite password:password error:error delegate:delegate progressHandler:nil completionHandler:nil]; +} + ++ (BOOL)unzipFileAtPath:(NSString *)path + toDestination:(NSString *)destination + overwrite:(BOOL)overwrite + password:(NSString *)password + progressHandler:(void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler + completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler +{ + return [self unzipFileAtPath:path toDestination:destination preserveAttributes:YES overwrite:overwrite password:password error:nil delegate:nil progressHandler:progressHandler completionHandler:completionHandler]; +} + ++ (BOOL)unzipFileAtPath:(NSString *)path + toDestination:(NSString *)destination + progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler + completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler +{ + return [self unzipFileAtPath:path toDestination:destination preserveAttributes:YES overwrite:YES password:nil error:nil delegate:nil progressHandler:progressHandler completionHandler:completionHandler]; +} + ++ (BOOL)unzipFileAtPath:(NSString *)path + toDestination:(NSString *)destination + preserveAttributes:(BOOL)preserveAttributes + overwrite:(BOOL)overwrite + password:(nullable NSString *)password + error:(NSError * *)error + delegate:(nullable id)delegate +{ + return [self unzipFileAtPath:path toDestination:destination preserveAttributes:preserveAttributes overwrite:overwrite password:password error:error delegate:delegate progressHandler:nil completionHandler:nil]; +} + ++ (BOOL)unzipFileAtPath:(NSString *)path + toDestination:(NSString *)destination + preserveAttributes:(BOOL)preserveAttributes + overwrite:(BOOL)overwrite + password:(nullable NSString *)password + error:(NSError **)error + delegate:(nullable id)delegate + progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler + completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler +{ + return [self unzipFileAtPath:path toDestination:destination preserveAttributes:preserveAttributes overwrite:overwrite nestedZipLevel:0 password:password error:error delegate:delegate progressHandler:progressHandler completionHandler:completionHandler]; +} + ++ (BOOL)unzipFileAtPath:(NSString *)path + toDestination:(NSString *)destination + preserveAttributes:(BOOL)preserveAttributes + overwrite:(BOOL)overwrite + nestedZipLevel:(NSInteger)nestedZipLevel + password:(nullable NSString *)password + error:(NSError **)error + delegate:(nullable id)delegate + progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler + completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler +{ + // Guard against empty strings + if (path.length == 0 || destination.length == 0) + { + NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"received invalid argument(s)"}; + NSError *err = [NSError errorWithDomain:SSZipArchiveErrorDomain code:SSZipArchiveErrorCodeInvalidArguments userInfo:userInfo]; + if (error) + { + *error = err; + } + if (completionHandler) + { + completionHandler(nil, NO, err); + } + return NO; + } + + // Begin opening + zipFile zip = unzOpen(path.fileSystemRepresentation); + if (zip == NULL) + { + NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"failed to open zip file"}; + NSError *err = [NSError errorWithDomain:SSZipArchiveErrorDomain code:SSZipArchiveErrorCodeFailedOpenZipFile userInfo:userInfo]; + if (error) + { + *error = err; + } + if (completionHandler) + { + completionHandler(nil, NO, err); + } + return NO; + } + + NSDictionary * fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil]; + unsigned long long fileSize = [[fileAttributes objectForKey:NSFileSize] unsignedLongLongValue]; + unsigned long long currentPosition = 0; + + unz_global_info globalInfo = {}; + unzGetGlobalInfo(zip, &globalInfo); + + // Begin unzipping + int ret = 0; + ret = unzGoToFirstFile(zip); + if (ret != UNZ_OK && ret != MZ_END_OF_LIST) + { + NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"failed to open first file in zip file"}; + NSError *err = [NSError errorWithDomain:SSZipArchiveErrorDomain code:SSZipArchiveErrorCodeFailedOpenFileInZip userInfo:userInfo]; + if (error) + { + *error = err; + } + if (completionHandler) + { + completionHandler(nil, NO, err); + } + unzClose(zip); + return NO; + } + + BOOL success = YES; + BOOL canceled = NO; + int crc_ret = 0; + unsigned char buffer[4096] = {0}; + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSMutableArray *directoriesModificationDates = [[NSMutableArray alloc] init]; + + // Message delegate + if ([delegate respondsToSelector:@selector(zipArchiveWillUnzipArchiveAtPath:zipInfo:)]) { + [delegate zipArchiveWillUnzipArchiveAtPath:path zipInfo:globalInfo]; + } + if ([delegate respondsToSelector:@selector(zipArchiveProgressEvent:total:)]) { + [delegate zipArchiveProgressEvent:currentPosition total:fileSize]; + } + + NSInteger currentFileNumber = -1; + NSError *unzippingError; + do { + currentFileNumber++; + if (ret == MZ_END_OF_LIST) { + break; + } + @autoreleasepool { + if (password.length == 0) { + ret = unzOpenCurrentFile(zip); + } else { + ret = unzOpenCurrentFilePassword(zip, [password cStringUsingEncoding:NSUTF8StringEncoding]); + } + + if (ret != UNZ_OK) { + unzippingError = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:SSZipArchiveErrorCodeFailedOpenFileInZip userInfo:@{NSLocalizedDescriptionKey: @"failed to open file in zip file"}]; + success = NO; + break; + } + + // Reading data and write to file + unz_file_info fileInfo; + memset(&fileInfo, 0, sizeof(unz_file_info)); + + ret = unzGetCurrentFileInfo(zip, &fileInfo, NULL, 0, NULL, 0, NULL, 0); + if (ret != UNZ_OK) { + unzippingError = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:SSZipArchiveErrorCodeFileInfoNotLoadable userInfo:@{NSLocalizedDescriptionKey: @"failed to retrieve info for file"}]; + success = NO; + unzCloseCurrentFile(zip); + break; + } + + currentPosition += fileInfo.compressed_size; + + // Message delegate + if ([delegate respondsToSelector:@selector(zipArchiveShouldUnzipFileAtIndex:totalFiles:archivePath:fileInfo:)]) { + if (![delegate zipArchiveShouldUnzipFileAtIndex:currentFileNumber + totalFiles:(NSInteger)globalInfo.number_entry + archivePath:path + fileInfo:fileInfo]) { + success = NO; + canceled = YES; + break; + } + } + if ([delegate respondsToSelector:@selector(zipArchiveWillUnzipFileAtIndex:totalFiles:archivePath:fileInfo:)]) { + [delegate zipArchiveWillUnzipFileAtIndex:currentFileNumber totalFiles:(NSInteger)globalInfo.number_entry + archivePath:path fileInfo:fileInfo]; + } + if ([delegate respondsToSelector:@selector(zipArchiveProgressEvent:total:)]) { + [delegate zipArchiveProgressEvent:(NSInteger)currentPosition total:(NSInteger)fileSize]; + } + + char *filename = (char *)malloc(fileInfo.size_filename + 1); + if (filename == NULL) + { + success = NO; + break; + } + + unzGetCurrentFileInfo(zip, &fileInfo, filename, fileInfo.size_filename + 1, NULL, 0, NULL, 0); + filename[fileInfo.size_filename] = '\0'; + + BOOL fileIsSymbolicLink = _fileIsSymbolicLink(&fileInfo); + + NSString * strPath = [SSZipArchive _filenameStringWithCString:filename + version_made_by:fileInfo.version + general_purpose_flag:fileInfo.flag + size:fileInfo.size_filename]; + if ([strPath hasPrefix:@"__MACOSX/"]) { + // ignoring resource forks: https://superuser.com/questions/104500/what-is-macosx-folder + unzCloseCurrentFile(zip); + ret = unzGoToNextFile(zip); + free(filename); + continue; + } + + // Check if it contains directory + BOOL isDirectory = NO; + if (filename[fileInfo.size_filename-1] == '/' || filename[fileInfo.size_filename-1] == '\\') { + isDirectory = YES; + } + free(filename); + + // Sanitize paths in the file name. + strPath = [strPath _sanitizedPath]; + if (!strPath.length) { + // if filename data is unsalvageable, we default to currentFileNumber + strPath = @(currentFileNumber).stringValue; + } + + NSString *fullPath = [destination stringByAppendingPathComponent:strPath]; + NSError *err = nil; + NSDictionary *directoryAttr; + if (preserveAttributes) { + NSDate *modDate = [[self class] _dateWithMSDOSFormat:(UInt32)fileInfo.mz_dos_date]; + directoryAttr = @{NSFileCreationDate: modDate, NSFileModificationDate: modDate}; + [directoriesModificationDates addObject: @{@"path": fullPath, @"modDate": modDate}]; + } + if (isDirectory) { + [fileManager createDirectoryAtPath:fullPath withIntermediateDirectories:YES attributes:directoryAttr error:&err]; + } else { + [fileManager createDirectoryAtPath:fullPath.stringByDeletingLastPathComponent withIntermediateDirectories:YES attributes:directoryAttr error:&err]; + } + if (err != nil) { + if ([err.domain isEqualToString:NSCocoaErrorDomain] && + err.code == 640) { + unzippingError = err; + unzCloseCurrentFile(zip); + success = NO; + break; + } + NSLog(@"[SSZipArchive] Error: %@", err.localizedDescription); + } + + if ([fileManager fileExistsAtPath:fullPath] && !isDirectory && !overwrite) { + //FIXME: couldBe CRC Check? + unzCloseCurrentFile(zip); + ret = unzGoToNextFile(zip); + continue; + } + + if (isDirectory && !fileIsSymbolicLink) { + // nothing to read/write for a directory + } else if (!fileIsSymbolicLink) { + // ensure we are not creating stale file entries + int readBytes = unzReadCurrentFile(zip, buffer, 4096); + if (readBytes >= 0) { + FILE *fp = fopen(fullPath.fileSystemRepresentation, "wb"); + while (fp) { + if (readBytes > 0) { + if (0 == fwrite(buffer, readBytes, 1, fp)) { + if (ferror(fp)) { + NSString *message = [NSString stringWithFormat:@"Failed to write file (check your free space)"]; + NSLog(@"[SSZipArchive] %@", message); + success = NO; + unzippingError = [NSError errorWithDomain:@"SSZipArchiveErrorDomain" code:SSZipArchiveErrorCodeFailedToWriteFile userInfo:@{NSLocalizedDescriptionKey: message}]; + break; + } + } + } else { + break; + } + readBytes = unzReadCurrentFile(zip, buffer, 4096); + if (readBytes < 0) { + // Let's assume error Z_DATA_ERROR is caused by an invalid password + // Let's assume other errors are caused by Content Not Readable + success = NO; + } + } + + if (fp) { + fclose(fp); + + if (nestedZipLevel + && [fullPath.pathExtension.lowercaseString isEqualToString:@"zip"] + && [self unzipFileAtPath:fullPath + toDestination:fullPath.stringByDeletingLastPathComponent + preserveAttributes:preserveAttributes + overwrite:overwrite + nestedZipLevel:nestedZipLevel - 1 + password:password + error:nil + delegate:nil + progressHandler:nil + completionHandler:nil]) { + [directoriesModificationDates removeLastObject]; + [[NSFileManager defaultManager] removeItemAtPath:fullPath error:nil]; + } else if (preserveAttributes) { + + // Set the original datetime property + if (fileInfo.mz_dos_date != 0) { + NSDate *orgDate = [[self class] _dateWithMSDOSFormat:(UInt32)fileInfo.mz_dos_date]; + NSDictionary *attr = @{NSFileModificationDate: orgDate}; + + if (attr) { + if (![fileManager setAttributes:attr ofItemAtPath:fullPath error:nil]) { + // Can't set attributes + NSLog(@"[SSZipArchive] Failed to set attributes - whilst setting modification date"); + } + } + } + + // Set the original permissions on the file (+read/write to solve #293) + uLong permissions = fileInfo.external_fa >> 16 | 0b110000000; + if (permissions != 0) { + // Store it into a NSNumber + NSNumber *permissionsValue = @(permissions); + + // Retrieve any existing attributes + NSMutableDictionary *attrs = [[NSMutableDictionary alloc] initWithDictionary:[fileManager attributesOfItemAtPath:fullPath error:nil]]; + + // Set the value in the attributes dict + [attrs setObject:permissionsValue forKey:NSFilePosixPermissions]; + + // Update attributes + if (![fileManager setAttributes:attrs ofItemAtPath:fullPath error:nil]) { + // Unable to set the permissions attribute + NSLog(@"[SSZipArchive] Failed to set attributes - whilst setting permissions"); + } + } + } + } + else + { + // if we couldn't open file descriptor we can validate global errno to see the reason + int errnoSave = errno; + BOOL isSeriousError = NO; + switch (errnoSave) { + case EISDIR: + // Is a directory + // assumed case + break; + + case ENOSPC: + case EMFILE: + // No space left on device + // or + // Too many open files + isSeriousError = YES; + break; + + default: + // ignore case + // Just log the error + { + NSError *errorObject = [NSError errorWithDomain:NSPOSIXErrorDomain + code:errnoSave + userInfo:nil]; + NSLog(@"[SSZipArchive] Failed to open file on unzipping.(%@)", errorObject); + } + break; + } + + if (isSeriousError) { + // serious case + unzippingError = [NSError errorWithDomain:NSPOSIXErrorDomain + code:errnoSave + userInfo:nil]; + unzCloseCurrentFile(zip); + // Log the error + NSLog(@"[SSZipArchive] Failed to open file on unzipping.(%@)", unzippingError); + + // Break unzipping + success = NO; + break; + } + } + } else { + // Let's assume error Z_DATA_ERROR is caused by an invalid password + // Let's assume other errors are caused by Content Not Readable + success = NO; + break; + } + } + else + { + // Assemble the path for the symbolic link + NSMutableString *destinationPath = [NSMutableString string]; + int bytesRead = 0; + while ((bytesRead = unzReadCurrentFile(zip, buffer, 4096)) > 0) + { + buffer[bytesRead] = 0; + [destinationPath appendString:@((const char *)buffer)]; + } + if (bytesRead < 0) { + // Let's assume error Z_DATA_ERROR is caused by an invalid password + // Let's assume other errors are caused by Content Not Readable + success = NO; + break; + } + + // Check if the symlink exists and delete it if we're overwriting + if (overwrite) + { + if ([fileManager fileExistsAtPath:fullPath]) + { + NSError *localError = nil; + BOOL removeSuccess = [fileManager removeItemAtPath:fullPath error:&localError]; + if (!removeSuccess) + { + NSString *message = [NSString stringWithFormat:@"Failed to delete existing symbolic link at \"%@\"", localError.localizedDescription]; + NSLog(@"[SSZipArchive] %@", message); + success = NO; + unzippingError = [NSError errorWithDomain:SSZipArchiveErrorDomain code:localError.code userInfo:@{NSLocalizedDescriptionKey: message}]; + } + } + } + + // Create the symbolic link (making sure it stays relative if it was relative before) + int symlinkError = symlink([destinationPath cStringUsingEncoding:NSUTF8StringEncoding], + [fullPath cStringUsingEncoding:NSUTF8StringEncoding]); + + if (symlinkError != 0) + { + // Bubble the error up to the completion handler + NSString *message = [NSString stringWithFormat:@"Failed to create symbolic link at \"%@\" to \"%@\" - symlink() error code: %d", fullPath, destinationPath, errno]; + NSLog(@"[SSZipArchive] %@", message); + success = NO; + unzippingError = [NSError errorWithDomain:NSPOSIXErrorDomain code:symlinkError userInfo:@{NSLocalizedDescriptionKey: message}]; + } + } + + crc_ret = unzCloseCurrentFile(zip); + if (crc_ret == MZ_CRC_ERROR) { + // CRC ERROR + success = NO; + break; + } + ret = unzGoToNextFile(zip); + + // Message delegate + if ([delegate respondsToSelector:@selector(zipArchiveDidUnzipFileAtIndex:totalFiles:archivePath:fileInfo:)]) { + [delegate zipArchiveDidUnzipFileAtIndex:currentFileNumber totalFiles:(NSInteger)globalInfo.number_entry + archivePath:path fileInfo:fileInfo]; + } else if ([delegate respondsToSelector: @selector(zipArchiveDidUnzipFileAtIndex:totalFiles:archivePath:unzippedFilePath:)]) { + [delegate zipArchiveDidUnzipFileAtIndex: currentFileNumber totalFiles: (NSInteger)globalInfo.number_entry + archivePath:path unzippedFilePath: fullPath]; + } + + if (progressHandler) + { + progressHandler(strPath, fileInfo, currentFileNumber, globalInfo.number_entry); + } + } + } while (ret == UNZ_OK && success); + + // Close + unzClose(zip); + + // The process of decompressing the .zip archive causes the modification times on the folders + // to be set to the present time. So, when we are done, they need to be explicitly set. + // set the modification date on all of the directories. + if (success && preserveAttributes) { + NSError * err = nil; + for (NSDictionary * d in directoriesModificationDates) { + if (![[NSFileManager defaultManager] setAttributes:@{NSFileModificationDate: [d objectForKey:@"modDate"]} ofItemAtPath:[d objectForKey:@"path"] error:&err]) { + NSLog(@"[SSZipArchive] Set attributes failed for directory: %@.", [d objectForKey:@"path"]); + } + if (err) { + NSLog(@"[SSZipArchive] Error setting directory file modification date attribute: %@", err.localizedDescription); + } + } + } + + // Message delegate + if (success && [delegate respondsToSelector:@selector(zipArchiveDidUnzipArchiveAtPath:zipInfo:unzippedPath:)]) { + [delegate zipArchiveDidUnzipArchiveAtPath:path zipInfo:globalInfo unzippedPath:destination]; + } + // final progress event = 100% + if (!canceled && [delegate respondsToSelector:@selector(zipArchiveProgressEvent:total:)]) { + [delegate zipArchiveProgressEvent:fileSize total:fileSize]; + } + + NSError *retErr = nil; + if (crc_ret == MZ_CRC_ERROR) + { + NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"crc check failed for file"}; + retErr = [NSError errorWithDomain:SSZipArchiveErrorDomain code:SSZipArchiveErrorCodeFileInfoNotLoadable userInfo:userInfo]; + } + + if (error) { + if (unzippingError) { + *error = unzippingError; + } + else { + *error = retErr; + } + } + if (completionHandler) + { + if (unzippingError) { + completionHandler(path, success, unzippingError); + } + else + { + completionHandler(path, success, retErr); + } + } + return success; +} + +#pragma mark - Zipping ++ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths +{ + return [SSZipArchive createZipFileAtPath:path withFilesAtPaths:paths withPassword:nil]; +} ++ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath { + return [SSZipArchive createZipFileAtPath:path withContentsOfDirectory:directoryPath withPassword:nil]; +} + ++ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory { + return [SSZipArchive createZipFileAtPath:path withContentsOfDirectory:directoryPath keepParentDirectory:keepParentDirectory withPassword:nil]; +} + ++ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths withPassword:(NSString *)password { + return [self createZipFileAtPath:path withFilesAtPaths:paths withPassword:password progressHandler:nil]; +} + ++ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths withPassword:(NSString *)password progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler +{ + SSZipArchive *zipArchive = [[SSZipArchive alloc] initWithPath:path]; + BOOL success = [zipArchive open]; + if (success) { + NSUInteger total = paths.count, complete = 0; + for (NSString *filePath in paths) { + success &= [zipArchive writeFile:filePath withPassword:password]; + if (progressHandler) { + complete++; + progressHandler(complete, total); + } + } + success &= [zipArchive close]; + } + return success; +} + ++ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath withPassword:(nullable NSString *)password { + return [SSZipArchive createZipFileAtPath:path withContentsOfDirectory:directoryPath keepParentDirectory:NO withPassword:password]; +} + + ++ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password { + return [SSZipArchive createZipFileAtPath:path + withContentsOfDirectory:directoryPath + keepParentDirectory:keepParentDirectory + withPassword:password + andProgressHandler:nil + ]; +} + ++ (BOOL)createZipFileAtPath:(NSString *)path + withContentsOfDirectory:(NSString *)directoryPath + keepParentDirectory:(BOOL)keepParentDirectory + withPassword:(nullable NSString *)password + andProgressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler { + return [self createZipFileAtPath:path withContentsOfDirectory:directoryPath keepParentDirectory:keepParentDirectory compressionLevel:Z_DEFAULT_COMPRESSION password:password AES:YES progressHandler:progressHandler]; +} + ++ (BOOL)createZipFileAtPath:(NSString *)path + withContentsOfDirectory:(NSString *)directoryPath + keepParentDirectory:(BOOL)keepParentDirectory + compressionLevel:(int)compressionLevel + password:(nullable NSString *)password + AES:(BOOL)aes + progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler { + + SSZipArchive *zipArchive = [[SSZipArchive alloc] initWithPath:path]; + BOOL success = [zipArchive open]; + if (success) { + // use a local fileManager (queue/thread compatibility) + NSFileManager *fileManager = [[NSFileManager alloc] init]; + NSDirectoryEnumerator *dirEnumerator = [fileManager enumeratorAtPath:directoryPath]; + NSArray *allObjects = dirEnumerator.allObjects; + NSUInteger total = allObjects.count, complete = 0; + if (keepParentDirectory && !total) { + allObjects = @[@""]; + total = 1; + } + for (__strong NSString *fileName in allObjects) { + NSString *fullFilePath = [directoryPath stringByAppendingPathComponent:fileName]; + if ([fullFilePath isEqualToString:path]) { + NSLog(@"[SSZipArchive] the archive path and the file path: %@ are the same, which is forbidden.", fullFilePath); + continue; + } + + if (keepParentDirectory) { + fileName = [directoryPath.lastPathComponent stringByAppendingPathComponent:fileName]; + } + + BOOL isDir; + [fileManager fileExistsAtPath:fullFilePath isDirectory:&isDir]; + if (!isDir) { + // file + success &= [zipArchive writeFileAtPath:fullFilePath withFileName:fileName compressionLevel:compressionLevel password:password AES:aes]; + } else { + // directory + if (![fileManager enumeratorAtPath:fullFilePath].nextObject) { + // empty directory + success &= [zipArchive writeFolderAtPath:fullFilePath withFolderName:fileName withPassword:password]; + } + } + if (progressHandler) { + complete++; + progressHandler(complete, total); + } + } + success &= [zipArchive close]; + } + return success; +} + ++ (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths withPassword:(nullable NSString *)password keepSymlinks:(BOOL)keeplinks { + if (!keeplinks) { + return [SSZipArchive createZipFileAtPath:path withFilesAtPaths:paths withPassword:password]; + } else { + SSZipArchive *zipArchive = [[SSZipArchive alloc] initWithPath:path]; + BOOL success = [zipArchive open]; + if (success) { + for (NSString *filePath in paths) { + //is symlink + if (mz_os_is_symlink(filePath.fileSystemRepresentation) == MZ_OK) { + success &= [zipArchive writeSymlinkFileAtPath:filePath withFileName:nil compressionLevel:Z_DEFAULT_COMPRESSION password:password AES:YES]; + } else { + success &= [zipArchive writeFile:filePath withPassword:password]; + } + } + success &= [zipArchive close]; + } + return success; + } +} + ++ (BOOL)createZipFileAtPath:(NSString *)path + withContentsOfDirectory:(NSString *)directoryPath + keepParentDirectory:(BOOL)keepParentDirectory + compressionLevel:(int)compressionLevel + password:(nullable NSString *)password + AES:(BOOL)aes + progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler + keepSymlinks:(BOOL)keeplinks { + if (!keeplinks) { + return [SSZipArchive createZipFileAtPath:path + withContentsOfDirectory:directoryPath + keepParentDirectory:keepParentDirectory + compressionLevel:compressionLevel + password:password + AES:aes + progressHandler:progressHandler]; + } else { + SSZipArchive *zipArchive = [[SSZipArchive alloc] initWithPath:path]; + BOOL success = [zipArchive open]; + if (success) { + // use a local fileManager (queue/thread compatibility) + NSFileManager *fileManager = [[NSFileManager alloc] init]; + NSDirectoryEnumerator *dirEnumerator = [fileManager enumeratorAtPath:directoryPath]; + NSArray *allObjects = dirEnumerator.allObjects; + NSUInteger total = allObjects.count, complete = 0; + if (keepParentDirectory && !total) { + allObjects = @[@""]; + total = 1; + } + for (__strong NSString *fileName in allObjects) { + NSString *fullFilePath = [directoryPath stringByAppendingPathComponent:fileName]; + + if (keepParentDirectory) { + fileName = [directoryPath.lastPathComponent stringByAppendingPathComponent:fileName]; + } + //is symlink + BOOL isSymlink = NO; + if (mz_os_is_symlink(fullFilePath.fileSystemRepresentation) == MZ_OK) + isSymlink = YES; + BOOL isDir; + [fileManager fileExistsAtPath:fullFilePath isDirectory:&isDir]; + if (!isDir || isSymlink) { + // file or symlink + if (!isSymlink) { + success &= [zipArchive writeFileAtPath:fullFilePath withFileName:fileName compressionLevel:compressionLevel password:password AES:aes]; + } else { + success &= [zipArchive writeSymlinkFileAtPath:fullFilePath withFileName:fileName compressionLevel:compressionLevel password:password AES:aes]; + } + } else { + // directory + if (![fileManager enumeratorAtPath:fullFilePath].nextObject) { + // empty directory + success &= [zipArchive writeFolderAtPath:fullFilePath withFolderName:fileName withPassword:password]; + } + } + if (progressHandler) { + complete++; + progressHandler(complete, total); + } + } + success &= [zipArchive close]; + } + return success; + } +} + +- (BOOL)writeSymlinkFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes +{ + NSAssert((_zip != NULL), @"Attempting to write to an archive which was never opened"); + //read symlink + char link_path[1024]; + int32_t err = MZ_OK; + err = mz_os_read_symlink(path.fileSystemRepresentation, link_path, sizeof(link_path)); + if (err != MZ_OK) { + NSLog(@"[SSZipArchive] Failed to read sylink"); + return NO; + } + + if (!fileName) { + fileName = path.lastPathComponent; + } + + zip_fileinfo zipInfo = {}; + [SSZipArchive zipInfo:&zipInfo setAttributesOfItemAtPath:path]; + + //unpdate zipInfo.external_fa + uint32_t target_attrib = 0; + uint32_t src_attrib = 0; + uint32_t src_sys = 0; + mz_os_get_file_attribs(path.fileSystemRepresentation, &src_attrib); + src_sys = MZ_HOST_SYSTEM(MZ_VERSION_MADEBY); + + if ((src_sys != MZ_HOST_SYSTEM_MSDOS) && (src_sys != MZ_HOST_SYSTEM_WINDOWS_NTFS)) { + /* High bytes are OS specific attributes, low byte is always DOS attributes */ + if (mz_zip_attrib_convert(src_sys, src_attrib, MZ_HOST_SYSTEM_MSDOS, &target_attrib) == MZ_OK) + zipInfo.external_fa = target_attrib; + zipInfo.external_fa |= (src_attrib << 16); + } else { + zipInfo.external_fa = src_attrib; + } + + uint16_t version_madeby = 3 << 8;//UNIX + int error = zipOpenNewFileInZip5(_zip, fileName.fileSystemRepresentation, &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, compressionLevel, 0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, password.UTF8String, aes, version_madeby, 0, 0); + zipWriteInFileInZip(_zip, link_path, (uint32_t)strlen(link_path)); + zipCloseFileInZip(_zip); + return error == ZIP_OK; +} + +// disabling `init` because designated initializer is `initWithPath:` +- (instancetype)init { @throw nil; } + +// designated initializer +- (instancetype)initWithPath:(NSString *)path +{ + if ((self = [super init])) { + _path = [path copy]; + } + return self; +} + + +- (BOOL)open +{ + NSAssert((_zip == NULL), @"Attempting to open an archive which is already open"); + _zip = zipOpen(_path.fileSystemRepresentation, APPEND_STATUS_CREATE); + return (NULL != _zip); +} + +- (BOOL)openForAppending +{ + NSAssert((_zip == NULL), @"Attempting to open an archive which is already open"); + _zip = zipOpen(_path.fileSystemRepresentation, APPEND_STATUS_ADDINZIP); + return (NULL != _zip); +} + +- (BOOL)writeFolderAtPath:(NSString *)path withFolderName:(NSString *)folderName withPassword:(nullable NSString *)password +{ + NSAssert((_zip != NULL), @"Attempting to write to an archive which was never opened"); + + zip_fileinfo zipInfo = {}; + + [SSZipArchive zipInfo:&zipInfo setAttributesOfItemAtPath:path]; + + int error = _zipOpenEntry(_zip, [folderName stringByAppendingString:@"/"], &zipInfo, Z_NO_COMPRESSION, password, NO); + const void *buffer = NULL; + zipWriteInFileInZip(_zip, buffer, 0); + zipCloseFileInZip(_zip); + return error == ZIP_OK; +} + +- (BOOL)writeFile:(NSString *)path withPassword:(nullable NSString *)password +{ + return [self writeFileAtPath:path withFileName:nil withPassword:password]; +} + +- (BOOL)writeFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName withPassword:(nullable NSString *)password +{ + return [self writeFileAtPath:path withFileName:fileName compressionLevel:Z_DEFAULT_COMPRESSION password:password AES:YES]; +} + +// supports writing files with logical folder/directory structure +// *path* is the absolute path of the file that will be compressed +// *fileName* is the relative name of the file how it is stored within the zip e.g. /folder/subfolder/text1.txt +- (BOOL)writeFileAtPath:(NSString *)path withFileName:(nullable NSString *)fileName compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes +{ + NSAssert((_zip != NULL), @"Attempting to write to an archive which was never opened"); + + FILE *input = fopen(path.fileSystemRepresentation, "r"); + if (NULL == input) { + return NO; + } + + if (!fileName) { + fileName = path.lastPathComponent; + } + + zip_fileinfo zipInfo = {}; + + [SSZipArchive zipInfo:&zipInfo setAttributesOfItemAtPath:path]; + + void *buffer = malloc(CHUNK); + if (buffer == NULL) + { + fclose(input); + return NO; + } + + int error = _zipOpenEntry(_zip, fileName, &zipInfo, compressionLevel, password, aes); + + while (!feof(input) && !ferror(input)) + { + unsigned int len = (unsigned int) fread(buffer, 1, CHUNK, input); + zipWriteInFileInZip(_zip, buffer, len); + } + + zipCloseFileInZip(_zip); + free(buffer); + fclose(input); + return error == ZIP_OK; +} + +- (BOOL)writeData:(NSData *)data filename:(nullable NSString *)filename withPassword:(nullable NSString *)password +{ + return [self writeData:data filename:filename compressionLevel:Z_DEFAULT_COMPRESSION password:password AES:YES]; +} + +- (BOOL)writeData:(NSData *)data filename:(nullable NSString *)filename compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes +{ + if (!_zip) { + return NO; + } + if (!data) { + return NO; + } + zip_fileinfo zipInfo = {}; + [SSZipArchive zipInfo:&zipInfo setDate:[NSDate date]]; + + int error = _zipOpenEntry(_zip, filename, &zipInfo, compressionLevel, password, aes); + + zipWriteInFileInZip(_zip, data.bytes, (unsigned int)data.length); + + zipCloseFileInZip(_zip); + return error == ZIP_OK; +} + +- (BOOL)close +{ + NSAssert((_zip != NULL), @"[SSZipArchive] Attempting to close an archive which was never opened"); + int error = zipClose(_zip, NULL); + _zip = nil; + return error == ZIP_OK; +} + +#pragma mark - Private + ++ (NSString *)_filenameStringWithCString:(const char *)filename + version_made_by:(uint16_t)version_made_by + general_purpose_flag:(uint16_t)flag + size:(uint16_t)size_filename { + + // Respect Language encoding flag only reading filename as UTF-8 when this is set + // when file entry created on dos system. + // + // https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT + // Bit 11: Language encoding flag (EFS). If this bit is set, + // the filename and comment fields for this file + // MUST be encoded using UTF-8. (see APPENDIX D) + uint16_t made_by = version_made_by >> 8; + BOOL made_on_dos = made_by == 0; + BOOL languageEncoding = (flag & (1 << 11)) != 0; + if (!languageEncoding && made_on_dos) { + // APPNOTE.TXT D.1: + // D.2 If general purpose bit 11 is unset, the file name and comment should conform + // to the original ZIP character encoding. If general purpose bit 11 is set, the + // filename and comment must support The Unicode Standard, Version 4.1.0 or + // greater using the character encoding form defined by the UTF-8 storage + // specification. The Unicode Standard is published by the The Unicode + // Consortium (www.unicode.org). UTF-8 encoded data stored within ZIP files + // is expected to not include a byte order mark (BOM). + + // Code Page 437 corresponds to kCFStringEncodingDOSLatinUS + NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingDOSLatinUS); + NSString* strPath = [NSString stringWithCString:filename encoding:encoding]; + if (strPath) { + return strPath; + } + } + + // attempting unicode encoding + NSString * strPath = @(filename); + if (strPath) { + return strPath; + } + + // if filename is non-unicode, detect and transform Encoding + NSData *data = [NSData dataWithBytes:(const void *)filename length:sizeof(unsigned char) * size_filename]; +// Testing availability of @available (https://stackoverflow.com/a/46927445/1033581) +#if __clang_major__ < 9 + // Xcode 8- + if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_9_2) { +#else + // Xcode 9+ + if (@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)) { +#endif + // supported encodings are in [NSString availableStringEncodings] + [NSString stringEncodingForData:data encodingOptions:nil convertedString:&strPath usedLossyConversion:nil]; + } else { + // fallback to a simple manual detect for macOS 10.9 or older + NSArray *encodings = @[@(kCFStringEncodingGB_18030_2000), @(kCFStringEncodingShiftJIS)]; + for (NSNumber *encoding in encodings) { + strPath = [NSString stringWithCString:filename encoding:(NSStringEncoding)CFStringConvertEncodingToNSStringEncoding(encoding.unsignedIntValue)]; + if (strPath) { + break; + } + } + } + if (strPath) { + return strPath; + } + + // if filename encoding is non-detected, we default to something based on data + // _hexString is more readable than _base64RFC4648 for debugging unknown encodings + strPath = [data _hexString]; + return strPath; +} + ++ (void)zipInfo:(zip_fileinfo *)zipInfo setAttributesOfItemAtPath:(NSString *)path +{ + NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:path error: nil]; + if (attr) + { + NSDate *fileDate = (NSDate *)[attr objectForKey:NSFileModificationDate]; + if (fileDate) + { + [self zipInfo:zipInfo setDate:fileDate]; + } + + // Write permissions into the external attributes, for details on this see here: https://unix.stackexchange.com/a/14727 + // Get the permissions value from the files attributes + NSNumber *permissionsValue = (NSNumber *)[attr objectForKey:NSFilePosixPermissions]; + if (permissionsValue != nil) { + // Get the short value for the permissions + short permissionsShort = permissionsValue.shortValue; + + // Convert this into an octal by adding 010000, 010000 being the flag for a regular file + NSInteger permissionsOctal = 0100000 + permissionsShort; + + // Convert this into a long value + uLong permissionsLong = @(permissionsOctal).unsignedLongValue; + + // Store this into the external file attributes once it has been shifted 16 places left to form part of the second from last byte + + // Casted back to an unsigned int to match type of external_fa in minizip + zipInfo->external_fa = (unsigned int)(permissionsLong << 16L); + } + } +} + ++ (void)zipInfo:(zip_fileinfo *)zipInfo setDate:(NSDate *)date +{ + NSCalendar *currentCalendar = SSZipArchive._gregorian; + NSCalendarUnit flags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond; + NSDateComponents *components = [currentCalendar components:flags fromDate:date]; + struct tm tmz_date; + tmz_date.tm_sec = (unsigned int)components.second; + tmz_date.tm_min = (unsigned int)components.minute; + tmz_date.tm_hour = (unsigned int)components.hour; + tmz_date.tm_mday = (unsigned int)components.day; + // ISO/IEC 9899 struct tm is 0-indexed for January but NSDateComponents for gregorianCalendar is 1-indexed for January + tmz_date.tm_mon = (unsigned int)components.month - 1; + // ISO/IEC 9899 struct tm is 0-indexed for AD 1900 but NSDateComponents for gregorianCalendar is 1-indexed for AD 1 + tmz_date.tm_year = (unsigned int)components.year - 1900; + zipInfo->mz_dos_date = mz_zip_tm_to_dosdate(&tmz_date); +} + ++ (NSCalendar *)_gregorian +{ + static NSCalendar *gregorian; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; + }); + + return gregorian; +} + +// Format from http://newsgroups.derkeiler.com/Archive/Comp/comp.os.msdos.programmer/2009-04/msg00060.html +// Two consecutive words, or a longword, YYYYYYYMMMMDDDDD hhhhhmmmmmmsssss +// YYYYYYY is years from 1980 = 0 +// sssss is (seconds/2). +// +// 3658 = 0011 0110 0101 1000 = 0011011 0010 11000 = 27 2 24 = 2007-02-24 +// 7423 = 0111 0100 0010 0011 - 01110 100001 00011 = 14 33 3 = 14:33:06 ++ (NSDate *)_dateWithMSDOSFormat:(UInt32)msdosDateTime +{ + // the whole `_dateWithMSDOSFormat:` method is equivalent but faster than this one line, + // essentially because `mktime` is slow: + //NSDate *date = [NSDate dateWithTimeIntervalSince1970:dosdate_to_time_t(msdosDateTime)]; + static const UInt32 kYearMask = 0xFE000000; + static const UInt32 kMonthMask = 0x1E00000; + static const UInt32 kDayMask = 0x1F0000; + static const UInt32 kHourMask = 0xF800; + static const UInt32 kMinuteMask = 0x7E0; + static const UInt32 kSecondMask = 0x1F; + + NSAssert(0xFFFFFFFF == (kYearMask | kMonthMask | kDayMask | kHourMask | kMinuteMask | kSecondMask), @"[SSZipArchive] MSDOS date masks don't add up"); + + NSDateComponents *components = [[NSDateComponents alloc] init]; + components.year = 1980 + ((msdosDateTime & kYearMask) >> 25); + components.month = (msdosDateTime & kMonthMask) >> 21; + components.day = (msdosDateTime & kDayMask) >> 16; + components.hour = (msdosDateTime & kHourMask) >> 11; + components.minute = (msdosDateTime & kMinuteMask) >> 5; + components.second = (msdosDateTime & kSecondMask) * 2; + + NSDate *date = [self._gregorian dateFromComponents:components]; + return date; +} + +@end + +int _zipOpenEntry(zipFile entry, NSString *name, const zip_fileinfo *zipfi, int level, NSString *password, BOOL aes) +{ + // https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT + uint16_t made_on_darwin = 19 << 8; + //MZ_ZIP_FLAG_UTF8 + uint16_t flag_base = 1 << 11; + return zipOpenNewFileInZip5(entry, name.fileSystemRepresentation, zipfi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, level, 0, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, password.UTF8String, aes, made_on_darwin, flag_base, 1); +} + +#pragma mark - Private tools for file info + +BOOL _fileIsSymbolicLink(const unz_file_info *fileInfo) +{ + // + // Determine whether this is a symbolic link: + // - File is stored with 'version made by' value of UNIX (3), + // as per https://www.pkware.com/documents/casestudies/APPNOTE.TXT + // in the upper byte of the version field. + // - BSD4.4 st_mode constants are stored in the high 16 bits of the + // external file attributes (defacto standard, verified against libarchive) + // + // The original constants can be found here: + // https://minnie.tuhs.org/cgi-bin/utree.pl?file=4.4BSD/usr/include/sys/stat.h + // + const uLong ZipUNIXVersion = 3; + const uLong BSD_SFMT = 0170000; + const uLong BSD_IFLNK = 0120000; + + BOOL fileIsSymbolicLink = ((fileInfo->version >> 8) == ZipUNIXVersion) && BSD_IFLNK == (BSD_SFMT & (fileInfo->external_fa >> 16)); + return fileIsSymbolicLink; +} + +#pragma mark - Private tools for unreadable encodings + +@implementation NSData (SSZipArchive) + +// `base64EncodedStringWithOptions` uses a base64 alphabet with '+' and '/'. +// we got those alternatives to make it compatible with filenames: https://en.wikipedia.org/wiki/Base64 +// * modified Base64 encoding for IMAP mailbox names (RFC 3501): uses '+' and ',' +// * modified Base64 for URL and filenames (RFC 4648): uses '-' and '_' +- (NSString *)_base64RFC4648 +{ + NSString *strName = [self base64EncodedStringWithOptions:0]; + strName = [strName stringByReplacingOccurrencesOfString:@"+" withString:@"-"]; + strName = [strName stringByReplacingOccurrencesOfString:@"/" withString:@"_"]; + return strName; +} + +// initWithBytesNoCopy from NSProgrammer, Jan 25 '12: https://stackoverflow.com/a/9009321/1033581 +// hexChars from Peter, Aug 19 '14: https://stackoverflow.com/a/25378464/1033581 +// not implemented as too lengthy: a potential mapping improvement from Moose, Nov 3 '15: https://stackoverflow.com/a/33501154/1033581 +- (NSString *)_hexString +{ + const char *hexChars = "0123456789ABCDEF"; + NSUInteger length = self.length; + const unsigned char *bytes = self.bytes; + char *chars = malloc(length * 2); + if (chars == NULL) { + // we directly raise an exception instead of using NSAssert to make sure assertion is not disabled as this is irrecoverable + [NSException raise:@"NSInternalInconsistencyException" format:@"failed malloc" arguments:nil]; + return nil; + } + char *s = chars; + NSUInteger i = length; + while (i--) { + *s++ = hexChars[*bytes >> 4]; + *s++ = hexChars[*bytes & 0xF]; + bytes++; + } + NSString *str = [[NSString alloc] initWithBytesNoCopy:chars + length:length * 2 + encoding:NSASCIIStringEncoding + freeWhenDone:YES]; + return str; +} + +@end + +#pragma mark Private tools for security + +@implementation NSString (SSZipArchive) + +// One implementation alternative would be to use the algorithm found at mz_path_resolve from https://github.com/nmoinvaz/minizip/blob/dev/mz_os.c, +// but making sure to work with unichar values and not ascii values to avoid breaking Unicode characters containing 2E ('.') or 2F ('/') in their decomposition +/// Sanitize path traversal characters to prevent directory backtracking. Ignoring these characters mimicks the default behavior of the Unarchiving tool on macOS. +- (NSString *)_sanitizedPath +{ + // Change Windows paths to Unix paths: https://en.wikipedia.org/wiki/Path_(computing) + // Possible improvement: only do this if the archive was created on a non-Unix system + NSString *strPath = [self stringByReplacingOccurrencesOfString:@"\\" withString:@"/"]; + + // Percent-encode file path (where path is defined by https://tools.ietf.org/html/rfc8089) + // The key part is to allow characters "." and "/" and disallow "%". + // CharacterSet.urlPathAllowed seems to do the job +#if (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 || __WATCH_OS_VERSION_MIN_REQUIRED >= 20000 || __TV_OS_VERSION_MIN_REQUIRED >= 90000) + strPath = [strPath stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLPathAllowedCharacterSet]; +#else + // Testing availability of @available (https://stackoverflow.com/a/46927445/1033581) +#if __clang_major__ < 9 + // Xcode 8- + if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8_4) { +#else + // Xcode 9+ + if (@available(macOS 10.9, iOS 7.0, watchOS 2.0, tvOS 9.0, *)) { +#endif + strPath = [strPath stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLPathAllowedCharacterSet]; + } else { + strPath = [strPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + } +#endif + + // `NSString.stringByAddingPercentEncodingWithAllowedCharacters:` may theorically fail: https://stackoverflow.com/questions/33558933/ + // But because we auto-detect encoding using `NSString.stringEncodingForData:encodingOptions:convertedString:usedLossyConversion:`, + // we likely already prevent UTF-16, UTF-32 and invalid Unicode in the form of unpaired surrogate chars: https://stackoverflow.com/questions/53043876/ + // To be on the safe side, we will still perform a guard check. + if (strPath == nil) { + return nil; + } + + // Add scheme "file:///" to support sanitation on names with a colon like "file:a/../../../usr/bin" + strPath = [@"file:///" stringByAppendingString:strPath]; + + // Sanitize path traversal characters to prevent directory backtracking. Ignoring these characters mimicks the default behavior of the Unarchiving tool on macOS. + // "../../../../../../../../../../../tmp/test.txt" -> "tmp/test.txt" + // "a/b/../c.txt" -> "a/c.txt" + strPath = [NSURL URLWithString:strPath].standardizedURL.absoluteString; + + // Remove the "file:///" scheme + strPath = [strPath substringFromIndex:8]; + + // Remove the percent-encoding +#if (__MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 || __WATCH_OS_VERSION_MIN_REQUIRED >= 20000 || __TV_OS_VERSION_MIN_REQUIRED >= 90000) + strPath = strPath.stringByRemovingPercentEncoding; +#else + // Testing availability of @available (https://stackoverflow.com/a/46927445/1033581) +#if __clang_major__ < 9 + // Xcode 8- + if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8_4) { +#else + // Xcode 9+ + if (@available(macOS 10.9, iOS 7.0, watchOS 2.0, tvOS 9.0, *)) { +#endif + strPath = strPath.stringByRemovingPercentEncoding; + } else { + strPath = [strPath stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + } +#endif + + return strPath; +} + +@end diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/SSZipCommon.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/SSZipCommon.h new file mode 100644 index 0000000000000000000000000000000000000000..78fa282092383799851ecf93876e760a280b2818 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/SSZipCommon.h @@ -0,0 +1,68 @@ +#ifndef SSZipCommon +#define SSZipCommon + +// typedefs moved from mz_compat.h to here for public access + +/* unz_global_info structure contain global data about the ZIPfile + These data comes from the end of central dir */ +typedef struct unz_global_info64_s +{ + uint64_t number_entry; /* total number of entries in the central dir on this disk */ + uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP */ + uint16_t size_comment; /* size of the global comment of the zipfile */ +} unz_global_info64; + +typedef struct unz_global_info_s +{ + uint32_t number_entry; /* total number of entries in the central dir on this disk */ + uint32_t number_disk_with_CD; /* number the the disk with central dir, used for spanning ZIP */ + uint16_t size_comment; /* size of the global comment of the zipfile */ +} unz_global_info; + +/* unz_file_info contain information about a file in the zipfile */ +/* https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT */ +typedef struct unz_file_info64_s +{ + uint16_t version; /* version made by 2 bytes */ + uint16_t version_needed; /* version needed to extract 2 bytes */ + uint16_t flag; /* general purpose bit flag 2 bytes */ + uint16_t compression_method; /* compression method 2 bytes */ + uint32_t dos_date; /* last mod file date in Dos fmt 4 bytes */ + uint32_t crc; /* crc-32 4 bytes */ + uint64_t compressed_size; /* compressed size 8 bytes */ + uint64_t uncompressed_size; /* uncompressed size 8 bytes */ + uint16_t size_filename; /* filename length 2 bytes */ + uint16_t size_file_extra; /* extra field length 2 bytes */ + uint16_t size_file_comment; /* file comment length 2 bytes */ + + uint32_t disk_num_start; /* disk number start 4 bytes */ + uint16_t internal_fa; /* internal file attributes 2 bytes */ + uint32_t external_fa; /* external file attributes 4 bytes */ + + uint64_t disk_offset; + + uint16_t size_file_extra_internal; +} unz_file_info64; + +typedef struct unz_file_info_s +{ + uint16_t version; /* version made by 2 bytes */ + uint16_t version_needed; /* version needed to extract 2 bytes */ + uint16_t flag; /* general purpose bit flag 2 bytes */ + uint16_t compression_method; /* compression method 2 bytes */ + uint32_t dos_date; /* last mod file date in Dos fmt 4 bytes */ + uint32_t crc; /* crc-32 4 bytes */ + uint32_t compressed_size; /* compressed size 4 bytes */ + uint32_t uncompressed_size; /* uncompressed size 4 bytes */ + uint16_t size_filename; /* filename length 2 bytes */ + uint16_t size_file_extra; /* extra field length 2 bytes */ + uint16_t size_file_comment; /* file comment length 2 bytes */ + + uint16_t disk_num_start; /* disk number start 2 bytes */ + uint16_t internal_fa; /* internal file attributes 2 bytes */ + uint32_t external_fa; /* external file attributes 4 bytes */ + + uint64_t disk_offset; +} unz_file_info; + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/include/ZipArchive.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/include/ZipArchive.h new file mode 100644 index 0000000000000000000000000000000000000000..e81fc9b6e7207e61a798af813ad6722dfdc463ec --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/include/ZipArchive.h @@ -0,0 +1,25 @@ +// +// ZipArchive.h +// ZipArchive +// +// Created by Serhii Mumriak on 12/1/15. +// + +#import + +//! Project version number for ZipArchive. +FOUNDATION_EXPORT double ZipArchiveVersionNumber; + +//! Project version string for ZipArchive. +FOUNDATION_EXPORT const unsigned char ZipArchiveVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + +// This is to account for the many different ways this library gets imported. +#if __has_include() +#import +#elif __has_include("../SSZipArchive.h") +#import "../SSZipArchive.h" +#else +#import "SSZipArchive.h" +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz.h new file mode 100644 index 0000000000000000000000000000000000000000..82a14a23e0e26b0270613da589b6287254212d6a --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz.h @@ -0,0 +1,274 @@ +/* mz.h -- Errors codes, zip flags and magic + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_H +#define MZ_H + +/***************************************************************************/ + +/* MZ_VERSION */ +#define MZ_VERSION ("3.0.4") +#define MZ_VERSION_BUILD (030004) + +/* MZ_ERROR */ +#define MZ_OK (0) /* zlib */ +#define MZ_STREAM_ERROR (-1) /* zlib */ +#define MZ_DATA_ERROR (-3) /* zlib */ +#define MZ_MEM_ERROR (-4) /* zlib */ +#define MZ_BUF_ERROR (-5) /* zlib */ +#define MZ_VERSION_ERROR (-6) /* zlib */ + +#define MZ_END_OF_LIST (-100) +#define MZ_END_OF_STREAM (-101) + +#define MZ_PARAM_ERROR (-102) +#define MZ_FORMAT_ERROR (-103) +#define MZ_INTERNAL_ERROR (-104) +#define MZ_CRC_ERROR (-105) +#define MZ_CRYPT_ERROR (-106) +#define MZ_EXIST_ERROR (-107) +#define MZ_PASSWORD_ERROR (-108) +#define MZ_SUPPORT_ERROR (-109) +#define MZ_HASH_ERROR (-110) +#define MZ_OPEN_ERROR (-111) +#define MZ_CLOSE_ERROR (-112) +#define MZ_SEEK_ERROR (-113) +#define MZ_TELL_ERROR (-114) +#define MZ_READ_ERROR (-115) +#define MZ_WRITE_ERROR (-116) +#define MZ_SIGN_ERROR (-117) +#define MZ_SYMLINK_ERROR (-118) + +/* MZ_OPEN */ +#define MZ_OPEN_MODE_READ (0x01) +#define MZ_OPEN_MODE_WRITE (0x02) +#define MZ_OPEN_MODE_READWRITE (MZ_OPEN_MODE_READ | MZ_OPEN_MODE_WRITE) +#define MZ_OPEN_MODE_APPEND (0x04) +#define MZ_OPEN_MODE_CREATE (0x08) +#define MZ_OPEN_MODE_EXISTING (0x10) + +/* MZ_SEEK */ +#define MZ_SEEK_SET (0) +#define MZ_SEEK_CUR (1) +#define MZ_SEEK_END (2) + +/* MZ_COMPRESS */ +#define MZ_COMPRESS_METHOD_STORE (0) +#define MZ_COMPRESS_METHOD_DEFLATE (8) +#define MZ_COMPRESS_METHOD_BZIP2 (12) +#define MZ_COMPRESS_METHOD_LZMA (14) +#define MZ_COMPRESS_METHOD_ZSTD (93) +#define MZ_COMPRESS_METHOD_XZ (95) +#define MZ_COMPRESS_METHOD_AES (99) + +#define MZ_COMPRESS_LEVEL_DEFAULT (-1) +#define MZ_COMPRESS_LEVEL_FAST (2) +#define MZ_COMPRESS_LEVEL_NORMAL (6) +#define MZ_COMPRESS_LEVEL_BEST (9) + +/* MZ_ZIP_FLAG */ +#define MZ_ZIP_FLAG_ENCRYPTED (1 << 0) +#define MZ_ZIP_FLAG_LZMA_EOS_MARKER (1 << 1) +#define MZ_ZIP_FLAG_DEFLATE_MAX (1 << 1) +#define MZ_ZIP_FLAG_DEFLATE_NORMAL (0) +#define MZ_ZIP_FLAG_DEFLATE_FAST (1 << 2) +#define MZ_ZIP_FLAG_DEFLATE_SUPER_FAST (MZ_ZIP_FLAG_DEFLATE_FAST | \ + MZ_ZIP_FLAG_DEFLATE_MAX) +#define MZ_ZIP_FLAG_DATA_DESCRIPTOR (1 << 3) +#define MZ_ZIP_FLAG_UTF8 (1 << 11) +#define MZ_ZIP_FLAG_MASK_LOCAL_INFO (1 << 13) + +/* MZ_ZIP_EXTENSION */ +#define MZ_ZIP_EXTENSION_ZIP64 (0x0001) +#define MZ_ZIP_EXTENSION_NTFS (0x000a) +#define MZ_ZIP_EXTENSION_AES (0x9901) +#define MZ_ZIP_EXTENSION_UNIX1 (0x000d) +#define MZ_ZIP_EXTENSION_SIGN (0x10c5) +#define MZ_ZIP_EXTENSION_HASH (0x1a51) +#define MZ_ZIP_EXTENSION_CDCD (0xcdcd) + +/* MZ_ZIP64 */ +#define MZ_ZIP64_AUTO (0) +#define MZ_ZIP64_FORCE (1) +#define MZ_ZIP64_DISABLE (2) + +/* MZ_HOST_SYSTEM */ +#define MZ_HOST_SYSTEM(VERSION_MADEBY) ((uint8_t)(VERSION_MADEBY >> 8)) +#define MZ_HOST_SYSTEM_MSDOS (0) +#define MZ_HOST_SYSTEM_UNIX (3) +#define MZ_HOST_SYSTEM_WINDOWS_NTFS (10) +#define MZ_HOST_SYSTEM_RISCOS (13) +#define MZ_HOST_SYSTEM_OSX_DARWIN (19) + +/* MZ_PKCRYPT */ +#define MZ_PKCRYPT_HEADER_SIZE (12) + +/* MZ_AES */ +#define MZ_AES_VERSION (1) +#define MZ_AES_ENCRYPTION_MODE_128 (0x01) +#define MZ_AES_ENCRYPTION_MODE_192 (0x02) +#define MZ_AES_ENCRYPTION_MODE_256 (0x03) +#define MZ_AES_KEY_LENGTH(MODE) (8 * (MODE & 3) + 8) +#define MZ_AES_KEY_LENGTH_MAX (32) +#define MZ_AES_BLOCK_SIZE (16) +#define MZ_AES_HEADER_SIZE(MODE) ((4 * (MODE & 3) + 4) + 2) +#define MZ_AES_FOOTER_SIZE (10) + +/* MZ_HASH */ +#define MZ_HASH_MD5 (10) +#define MZ_HASH_MD5_SIZE (16) +#define MZ_HASH_SHA1 (20) +#define MZ_HASH_SHA1_SIZE (20) +#define MZ_HASH_SHA256 (23) +#define MZ_HASH_SHA256_SIZE (32) +#define MZ_HASH_MAX_SIZE (256) + +/* MZ_ENCODING */ +#define MZ_ENCODING_CODEPAGE_437 (437) +#define MZ_ENCODING_CODEPAGE_932 (932) +#define MZ_ENCODING_CODEPAGE_936 (936) +#define MZ_ENCODING_CODEPAGE_950 (950) +#define MZ_ENCODING_UTF8 (65001) + +/* MZ_UTILITY */ +#define MZ_UNUSED(SYMBOL) ((void)SYMBOL) + +#ifndef MZ_CUSTOM_ALLOC +#define MZ_ALLOC(SIZE) (malloc((SIZE))) +#endif +#ifndef MZ_CUSTOM_FREE +#define MZ_FREE(PTR) (free(PTR)) +#endif + +#if defined(_WIN32) && defined(MZ_EXPORTS) +#define MZ_EXPORT __declspec(dllexport) +#else +#define MZ_EXPORT +#endif + +/***************************************************************************/ + +#include /* size_t, NULL, malloc */ +#include /* time_t, time() */ +#include /* memset, strncpy, strlen */ +#include + +#if defined(HAVE_STDINT_H) +# include +#elif defined(__has_include) +# if __has_include() +# include +# endif +#endif + +#ifndef INT8_MAX +typedef signed char int8_t; +#endif +#ifndef INT16_MAX +typedef short int16_t; +#endif +#ifndef INT32_MAX +typedef int int32_t; +#endif +#ifndef INT64_MAX +typedef long long int64_t; +#endif +#ifndef UINT8_MAX +typedef unsigned char uint8_t; +#endif +#ifndef UINT16_MAX +typedef unsigned short uint16_t; +#endif +#ifndef UINT32_MAX +typedef unsigned int uint32_t; +#endif +#ifndef UINT64_MAX +typedef unsigned long long uint64_t; +#endif + +#if defined(HAVE_INTTYPES_H) +# include +#elif defined(__has_include) +# if __has_include() +# include +# endif +#endif + +#ifndef PRId8 +# define PRId8 "hhd" +#endif +#ifndef PRIu8 +# define PRIu8 "hhu" +#endif +#ifndef PRIx8 +# define PRIx8 "hhx" +#endif +#ifndef PRId16 +# define PRId16 "hd" +#endif +#ifndef PRIu16 +# define PRIu16 "hu" +#endif +#ifndef PRIx16 +# define PRIx16 "hx" +#endif +#ifndef PRId32 +# define PRId32 "d" +#endif +#ifndef PRIu32 +# define PRIu32 "u" +#endif +#ifndef PRIx32 +# define PRIx32 "x" +#endif +#if ULONG_MAX == 0xfffffffful +# ifndef PRId64 +# define PRId64 "ld" +# endif +# ifndef PRIu64 +# define PRIu64 "lu" +# endif +# ifndef PRIx64 +# define PRIx64 "lx" +# endif +#else +# ifndef PRId64 +# define PRId64 "lld" +# endif +# ifndef PRIu64 +# define PRIu64 "llu" +# endif +# ifndef PRIx64 +# define PRIx64 "llx" +# endif +#endif + +#ifndef INT16_MAX +# define INT16_MAX 32767 +#endif +#ifndef INT32_MAX +# define INT32_MAX 2147483647L +#endif +#ifndef INT64_MAX +# define INT64_MAX 9223372036854775807LL +#endif +#ifndef UINT16_MAX +# define UINT16_MAX 65535U +#endif +#ifndef UINT32_MAX +# define UINT32_MAX 4294967295UL +#endif +#ifndef UINT64_MAX +# define UINT64_MAX 18446744073709551615ULL +#endif + +/***************************************************************************/ + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_compat.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_compat.c new file mode 100644 index 0000000000000000000000000000000000000000..759e30bd7de4fb59cbad6feae9ce4def0db3c3fb --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_compat.c @@ -0,0 +1,991 @@ +/* mz_compat.c -- Backwards compatible interface for older versions + Version 2.8.9, July 4, 2019 + part of the MiniZip project + + Copyright (C) 2010-2019 Nathan Moinvaziri + https://github.com/nmoinvaz/minizip + Copyright (C) 1998-2010 Gilles Vollant + https://www.winimage.com/zLibDll/minizip.html + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + + +#include "mz.h" +#include "mz_os.h" +#include "mz_strm.h" +#include "mz_strm_mem.h" +#include "mz_strm_os.h" +#include "mz_strm_zlib.h" +#include "mz_zip.h" + +#include /* SEEK */ + +#include "mz_compat.h" + +/***************************************************************************/ + +typedef struct mz_compat_s { + void *stream; + void *handle; + uint64_t entry_index; + int64_t entry_pos; + int64_t total_out; +} mz_compat; + +/***************************************************************************/ + +static int32_t zipConvertAppendToStreamMode(int append) +{ + int32_t mode = MZ_OPEN_MODE_WRITE; + switch (append) + { + case APPEND_STATUS_CREATE: + mode |= MZ_OPEN_MODE_CREATE; + break; + case APPEND_STATUS_CREATEAFTER: + mode |= MZ_OPEN_MODE_CREATE | MZ_OPEN_MODE_APPEND; + break; + case APPEND_STATUS_ADDINZIP: + mode |= MZ_OPEN_MODE_READ | MZ_OPEN_MODE_APPEND; + break; + } + return mode; +} + +zipFile zipOpen(const char *path, int append) +{ + zlib_filefunc64_def pzlib = mz_stream_os_get_interface(); + return zipOpen2(path, append, NULL, &pzlib); +} + +zipFile zipOpen64(const void *path, int append) +{ + zlib_filefunc64_def pzlib = mz_stream_os_get_interface(); + return zipOpen2(path, append, NULL, &pzlib); +} + +zipFile zipOpen2(const char *path, int append, const char **globalcomment, + zlib_filefunc_def *pzlib_filefunc_def) +{ + return zipOpen2_64(path, append, globalcomment, pzlib_filefunc_def); +} + +zipFile zipOpen2_64(const void *path, int append, const char **globalcomment, + zlib_filefunc64_def *pzlib_filefunc_def) +{ + zipFile zip = NULL; + int32_t mode = zipConvertAppendToStreamMode(append); + void *stream = NULL; + + if (pzlib_filefunc_def) + { + if (mz_stream_create(&stream, (mz_stream_vtbl *)*pzlib_filefunc_def) == NULL) + return NULL; + } + else + { + if (mz_stream_os_create(&stream) == NULL) + return NULL; + } + + if (mz_stream_open(stream, path, mode) != MZ_OK) + { + mz_stream_delete(&stream); + return NULL; + } + + zip = zipOpen_MZ(stream, append, globalcomment); + + if (zip == NULL) + { + mz_stream_delete(&stream); + return NULL; + } + + return zip; +} + +zipFile zipOpen_MZ(void *stream, int append, const char **globalcomment) +{ + mz_compat *compat = NULL; + int32_t err = MZ_OK; + int32_t mode = zipConvertAppendToStreamMode(append); + void *handle = NULL; + + mz_zip_create(&handle); + err = mz_zip_open(handle, stream, mode); + + if (err != MZ_OK) + { + mz_zip_delete(&handle); + return NULL; + } + + if (globalcomment != NULL) + mz_zip_get_comment(handle, globalcomment); + + compat = (mz_compat *)MZ_ALLOC(sizeof(mz_compat)); + if (compat != NULL) + { + compat->handle = handle; + compat->stream = stream; + } + else + { + mz_zip_delete(&handle); + } + + return (zipFile)compat; +} + +int zipOpenNewFileInZip5(zipFile file, const char *filename, const zip_fileinfo *zipfi, + const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, + uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level, + int raw, int windowBits, int memLevel, int strategy, const char *password, + signed char aes, uint16_t version_madeby, uint16_t flag_base, int zip64) +{ + mz_compat *compat = (mz_compat *)file; + mz_zip_file file_info; + uint64_t dos_date = 0; + + MZ_UNUSED(strategy); + MZ_UNUSED(memLevel); + MZ_UNUSED(windowBits); + MZ_UNUSED(size_extrafield_local); + MZ_UNUSED(extrafield_local); + + if (compat == NULL) + return ZIP_PARAMERROR; + + memset(&file_info, 0, sizeof(file_info)); + + if (zipfi != NULL) + { + if (zipfi->mz_dos_date != 0) + dos_date = zipfi->mz_dos_date; + else + dos_date = mz_zip_tm_to_dosdate(&zipfi->tmz_date); + + file_info.modified_date = mz_zip_dosdate_to_time_t(dos_date); + file_info.external_fa = zipfi->external_fa; + file_info.internal_fa = zipfi->internal_fa; + } + + if (filename == NULL) + filename = "-"; + + file_info.compression_method = compression_method; + file_info.filename = filename; + /* file_info.extrafield_local = extrafield_local; */ + /* file_info.extrafield_local_size = size_extrafield_local; */ + file_info.extrafield = extrafield_global; + file_info.extrafield_size = size_extrafield_global; + file_info.version_madeby = version_madeby; + file_info.comment = comment; + file_info.flag = flag_base; + if (zip64) + file_info.zip64 = MZ_ZIP64_FORCE; + else + file_info.zip64 = MZ_ZIP64_DISABLE; +#ifdef HAVE_WZAES + if ((aes && password != NULL) || (raw && (file_info.flag & MZ_ZIP_FLAG_ENCRYPTED))) + file_info.aes_version = MZ_AES_VERSION; +#endif + + return mz_zip_entry_write_open(compat->handle, &file_info, (int16_t)level, (uint8_t)raw, password); +} + +int zipWriteInFileInZip(zipFile file, const void *buf, uint32_t len) +{ + mz_compat *compat = (mz_compat *)file; + int32_t written = 0; + if (compat == NULL || len >= INT32_MAX) + return ZIP_PARAMERROR; + written = mz_zip_entry_write(compat->handle, buf, (int32_t)len); + if ((written < 0) || ((uint32_t)written != len)) + return ZIP_ERRNO; + return ZIP_OK; +} + +int zipCloseFileInZipRaw(zipFile file, uint32_t uncompressed_size, uint32_t crc32) +{ + return zipCloseFileInZipRaw64(file, uncompressed_size, crc32); +} + +int zipCloseFileInZipRaw64(zipFile file, int64_t uncompressed_size, uint32_t crc32) +{ + mz_compat *compat = (mz_compat *)file; + if (compat == NULL) + return ZIP_PARAMERROR; + return mz_zip_entry_close_raw(compat->handle, uncompressed_size, crc32); +} + +int zipCloseFileInZip(zipFile file) +{ + return zipCloseFileInZip64(file); +} + +int zipCloseFileInZip64(zipFile file) +{ + mz_compat *compat = (mz_compat *)file; + if (compat == NULL) + return ZIP_PARAMERROR; + return mz_zip_entry_close(compat->handle); +} + +int zipClose(zipFile file, const char *global_comment) +{ + return zipClose_64(file, global_comment); +} + +int zipClose_64(zipFile file, const char *global_comment) +{ + return zipClose2_64(file, global_comment, MZ_VERSION_MADEBY); +} + +int zipClose2_64(zipFile file, const char *global_comment, uint16_t version_madeby) +{ + mz_compat *compat = (mz_compat *)file; + int32_t err = MZ_OK; + + if (compat->handle != NULL) + err = zipClose2_MZ(file, global_comment, version_madeby); + + if (compat->stream != NULL) + { + mz_stream_close(compat->stream); + mz_stream_delete(&compat->stream); + } + + MZ_FREE(compat); + + return err; +} + +/* Only closes the zip handle, does not close the stream */ +int zipClose_MZ(zipFile file, const char *global_comment) +{ + return zipClose2_MZ(file, global_comment, MZ_VERSION_MADEBY); +} + +/* Only closes the zip handle, does not close the stream */ +int zipClose2_MZ(zipFile file, const char *global_comment, uint16_t version_madeby) +{ + mz_compat *compat = (mz_compat *)file; + int32_t err = MZ_OK; + + if (compat == NULL) + return ZIP_PARAMERROR; + if (compat->handle == NULL) + return err; + + if (global_comment != NULL) + mz_zip_set_comment(compat->handle, global_comment); + + mz_zip_set_version_madeby(compat->handle, version_madeby); + err = mz_zip_close(compat->handle); + mz_zip_delete(&compat->handle); + + return err; +} + +void* zipGetStream(zipFile file) +{ + mz_compat *compat = (mz_compat *)file; + if (compat == NULL) + return NULL; + return (void *)compat->stream; +} + +/***************************************************************************/ + +unzFile unzOpen(const char *path) +{ + return unzOpen64(path); +} + +unzFile unzOpen64(const void *path) +{ + zlib_filefunc64_def pzlib = mz_stream_os_get_interface(); + return unzOpen2(path, &pzlib); +} + +unzFile unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc_def) +{ + return unzOpen2_64(path, pzlib_filefunc_def); +} + +unzFile unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def) +{ + unzFile unz = NULL; + void *stream = NULL; + + if (pzlib_filefunc_def) + { + if (mz_stream_create(&stream, (mz_stream_vtbl *)*pzlib_filefunc_def) == NULL) + return NULL; + } + else + { + if (mz_stream_os_create(&stream) == NULL) + return NULL; + } + + if (mz_stream_open(stream, path, MZ_OPEN_MODE_READ) != MZ_OK) + { + mz_stream_delete(&stream); + return NULL; + } + + unz = unzOpen_MZ(stream); + if (unz == NULL) + { + mz_stream_delete(&stream); + return NULL; + } + return unz; +} + +unzFile unzOpen_MZ(void *stream) +{ + mz_compat *compat = NULL; + int32_t err = MZ_OK; + void *handle = NULL; + + mz_zip_create(&handle); + err = mz_zip_open(handle, stream, MZ_OPEN_MODE_READ); + + if (err != MZ_OK) + { + mz_zip_delete(&handle); + return NULL; + } + + compat = (mz_compat *)MZ_ALLOC(sizeof(mz_compat)); + if (compat != NULL) + { + compat->handle = handle; + compat->stream = stream; + + mz_zip_goto_first_entry(compat->handle); + } + else + { + mz_zip_delete(&handle); + } + + return (unzFile)compat; +} + +int unzClose(unzFile file) +{ + mz_compat *compat = (mz_compat *)file; + int32_t err = MZ_OK; + + if (compat == NULL) + return UNZ_PARAMERROR; + + if (compat->handle != NULL) + err = unzClose_MZ(file); + + if (compat->stream != NULL) + { + mz_stream_close(compat->stream); + mz_stream_delete(&compat->stream); + } + + MZ_FREE(compat); + + return err; +} + +/* Only closes the zip handle, does not close the stream */ +int unzClose_MZ(unzFile file) +{ + mz_compat *compat = (mz_compat *)file; + int32_t err = MZ_OK; + + if (compat == NULL) + return UNZ_PARAMERROR; + + err = mz_zip_close(compat->handle); + mz_zip_delete(&compat->handle); + + return err; +} + +int unzGetGlobalInfo(unzFile file, unz_global_info* pglobal_info32) +{ + mz_compat *compat = (mz_compat *)file; + unz_global_info64 global_info64; + int32_t err = MZ_OK; + + memset(pglobal_info32, 0, sizeof(unz_global_info)); + if (compat == NULL) + return UNZ_PARAMERROR; + + err = unzGetGlobalInfo64(file, &global_info64); + if (err == MZ_OK) + { + pglobal_info32->number_entry = (uint32_t)global_info64.number_entry; + pglobal_info32->size_comment = global_info64.size_comment; + pglobal_info32->number_disk_with_CD = global_info64.number_disk_with_CD; + } + return err; +} + +int unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info) +{ + mz_compat *compat = (mz_compat *)file; + const char *comment_ptr = NULL; + int32_t err = MZ_OK; + + memset(pglobal_info, 0, sizeof(unz_global_info64)); + if (compat == NULL) + return UNZ_PARAMERROR; + err = mz_zip_get_comment(compat->handle, &comment_ptr); + if (err == MZ_OK) + pglobal_info->size_comment = (uint16_t)strlen(comment_ptr); + if ((err == MZ_OK) || (err == MZ_EXIST_ERROR)) + err = mz_zip_get_number_entry(compat->handle, &pglobal_info->number_entry); + if (err == MZ_OK) + err = mz_zip_get_disk_number_with_cd(compat->handle, &pglobal_info->number_disk_with_CD); + return err; +} + +int unzGetGlobalComment(unzFile file, char *comment, uint16_t comment_size) +{ + mz_compat *compat = (mz_compat *)file; + const char *comment_ptr = NULL; + int32_t err = MZ_OK; + + if (comment == NULL || comment_size == 0) + return UNZ_PARAMERROR; + err = mz_zip_get_comment(compat->handle, &comment_ptr); + if (err == MZ_OK) + { + strncpy(comment, comment_ptr, comment_size - 1); + comment[comment_size - 1] = 0; + } + return err; +} + +int unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password) +{ + mz_compat *compat = (mz_compat *)file; + mz_zip_file *file_info = NULL; + int32_t err = MZ_OK; + void *stream = NULL; + + if (compat == NULL) + return UNZ_PARAMERROR; + if (method != NULL) + *method = 0; + if (level != NULL) + *level = 0; + + compat->total_out = 0; + err = mz_zip_entry_read_open(compat->handle, (uint8_t)raw, password); + if (err == MZ_OK) + err = mz_zip_entry_get_info(compat->handle, &file_info); + if (err == MZ_OK) + { + if (method != NULL) + { + *method = file_info->compression_method; + } + + if (level != NULL) + { + *level = 6; + switch (file_info->flag & 0x06) + { + case MZ_ZIP_FLAG_DEFLATE_SUPER_FAST: + *level = 1; + break; + case MZ_ZIP_FLAG_DEFLATE_FAST: + *level = 2; + break; + case MZ_ZIP_FLAG_DEFLATE_MAX: + *level = 9; + break; + } + } + } + if (err == MZ_OK) + err = mz_zip_get_stream(compat->handle, &stream); + if (err == MZ_OK) + compat->entry_pos = mz_stream_tell(stream); + return err; +} + +int unzOpenCurrentFile(unzFile file) +{ + return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); +} + +int unzOpenCurrentFilePassword(unzFile file, const char *password) +{ + return unzOpenCurrentFile3(file, NULL, NULL, 0, password); +} + +int unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw) +{ + return unzOpenCurrentFile3(file, method, level, raw, NULL); +} + +int unzReadCurrentFile(unzFile file, void *buf, uint32_t len) +{ + mz_compat *compat = (mz_compat *)file; + int32_t err = MZ_OK; + if (compat == NULL || len >= INT32_MAX) + return UNZ_PARAMERROR; + err = mz_zip_entry_read(compat->handle, buf, (int32_t)len); + if (err > 0) + compat->total_out += (uint32_t)err; + return err; +} + +int unzCloseCurrentFile(unzFile file) +{ + mz_compat *compat = (mz_compat *)file; + int32_t err = MZ_OK; + if (compat == NULL) + return UNZ_PARAMERROR; + err = mz_zip_entry_close(compat->handle); + return err; +} + +int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *filename, + uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size) +{ + mz_compat *compat = (mz_compat *)file; + mz_zip_file *file_info = NULL; + uint16_t bytes_to_copy = 0; + int32_t err = MZ_OK; + + if (compat == NULL) + return UNZ_PARAMERROR; + + err = mz_zip_entry_get_info(compat->handle, &file_info); + + if ((err == MZ_OK) && (pfile_info != NULL)) + { + pfile_info->version = file_info->version_madeby; + pfile_info->version_needed = file_info->version_needed; + pfile_info->flag = file_info->flag; + pfile_info->compression_method = file_info->compression_method; + pfile_info->mz_dos_date = mz_zip_time_t_to_dos_date(file_info->modified_date); + //mz_zip_time_t_to_tm(file_info->modified_date, &pfile_info->tmu_date); + //pfile_info->tmu_date.tm_year += 1900; + pfile_info->crc = file_info->crc; + + pfile_info->size_filename = file_info->filename_size; + pfile_info->size_file_extra = file_info->extrafield_size; + pfile_info->size_file_comment = file_info->comment_size; + + pfile_info->disk_num_start = (uint16_t)file_info->disk_number; + pfile_info->internal_fa = file_info->internal_fa; + pfile_info->external_fa = file_info->external_fa; + + pfile_info->compressed_size = (uint32_t)file_info->compressed_size; + pfile_info->uncompressed_size = (uint32_t)file_info->uncompressed_size; + + if (filename_size > 0 && filename != NULL && file_info->filename != NULL) + { + bytes_to_copy = filename_size; + if (bytes_to_copy > file_info->filename_size) + bytes_to_copy = file_info->filename_size; + memcpy(filename, file_info->filename, bytes_to_copy); + if (bytes_to_copy < filename_size) + filename[bytes_to_copy] = 0; + } + if (extrafield_size > 0 && extrafield != NULL) + { + bytes_to_copy = extrafield_size; + if (bytes_to_copy > file_info->extrafield_size) + bytes_to_copy = file_info->extrafield_size; + memcpy(extrafield, file_info->extrafield, bytes_to_copy); + } + if (comment_size > 0 && comment != NULL && file_info->comment != NULL) + { + bytes_to_copy = comment_size; + if (bytes_to_copy > file_info->comment_size) + bytes_to_copy = file_info->comment_size; + memcpy(comment, file_info->comment, bytes_to_copy); + if (bytes_to_copy < comment_size) + comment[bytes_to_copy] = 0; + } + } + return err; +} + +int unzGetCurrentFileInfo64(unzFile file, unz_file_info64 * pfile_info, char *filename, + uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, uint16_t comment_size) +{ + mz_compat *compat = (mz_compat *)file; + mz_zip_file *file_info = NULL; + uint16_t bytes_to_copy = 0; + int32_t err = MZ_OK; + + if (compat == NULL) + return UNZ_PARAMERROR; + + err = mz_zip_entry_get_info(compat->handle, &file_info); + + if ((err == MZ_OK) && (pfile_info != NULL)) + { + pfile_info->version = file_info->version_madeby; + pfile_info->version_needed = file_info->version_needed; + pfile_info->flag = file_info->flag; + pfile_info->compression_method = file_info->compression_method; + pfile_info->mz_dos_date = mz_zip_time_t_to_dos_date(file_info->modified_date); + //mz_zip_time_t_to_tm(file_info->modified_date, &pfile_info->tmu_date); + //pfile_info->tmu_date.tm_year += 1900; + pfile_info->crc = file_info->crc; + + pfile_info->size_filename = file_info->filename_size; + pfile_info->size_file_extra = file_info->extrafield_size; + pfile_info->size_file_comment = file_info->comment_size; + + pfile_info->disk_num_start = file_info->disk_number; + pfile_info->internal_fa = file_info->internal_fa; + pfile_info->external_fa = file_info->external_fa; + + pfile_info->compressed_size = (uint64_t)file_info->compressed_size; + pfile_info->uncompressed_size = (uint64_t)file_info->uncompressed_size; + + if (filename_size > 0 && filename != NULL && file_info->filename != NULL) + { + bytes_to_copy = filename_size; + if (bytes_to_copy > file_info->filename_size) + bytes_to_copy = file_info->filename_size; + memcpy(filename, file_info->filename, bytes_to_copy); + if (bytes_to_copy < filename_size) + filename[bytes_to_copy] = 0; + } + + if (extrafield_size > 0 && extrafield != NULL) + { + bytes_to_copy = extrafield_size; + if (bytes_to_copy > file_info->extrafield_size) + bytes_to_copy = file_info->extrafield_size; + memcpy(extrafield, file_info->extrafield, bytes_to_copy); + } + + if (comment_size > 0 && comment != NULL && file_info->comment != NULL) + { + bytes_to_copy = comment_size; + if (bytes_to_copy > file_info->comment_size) + bytes_to_copy = file_info->comment_size; + memcpy(comment, file_info->comment, bytes_to_copy); + if (bytes_to_copy < comment_size) + comment[bytes_to_copy] = 0; + } + } + return err; +} + +int unzGoToFirstFile(unzFile file) +{ + mz_compat *compat = (mz_compat *)file; + if (compat == NULL) + return UNZ_PARAMERROR; + compat->entry_index = 0; + return mz_zip_goto_first_entry(compat->handle); +} + +int unzGoToNextFile(unzFile file) +{ + mz_compat *compat = (mz_compat *)file; + int32_t err = MZ_OK; + if (compat == NULL) + return UNZ_PARAMERROR; + err = mz_zip_goto_next_entry(compat->handle); + if (err != MZ_END_OF_LIST) + compat->entry_index += 1; + return err; +} + +int unzLocateFile(unzFile file, const char *filename, unzFileNameComparer filename_compare_func) +{ + mz_compat *compat = (mz_compat *)file; + mz_zip_file *file_info = NULL; + uint64_t preserve_index = 0; + int32_t err = MZ_OK; + int32_t result = 0; + + if (compat == NULL) + return UNZ_PARAMERROR; + + preserve_index = compat->entry_index; + + err = mz_zip_goto_first_entry(compat->handle); + while (err == MZ_OK) + { + err = mz_zip_entry_get_info(compat->handle, &file_info); + if (err != MZ_OK) + break; + + if (filename_compare_func != NULL) + result = filename_compare_func(file, filename, file_info->filename); + else + result = strcmp(filename, file_info->filename); + + if (result == 0) + return MZ_OK; + + err = mz_zip_goto_next_entry(compat->handle); + } + + compat->entry_index = preserve_index; + return err; +} + +/***************************************************************************/ + +int unzGetFilePos(unzFile file, unz_file_pos *file_pos) +{ + mz_compat *compat = (mz_compat *)file; + int32_t offset = 0; + + if (compat == NULL || file_pos == NULL) + return UNZ_PARAMERROR; + + offset = unzGetOffset(file); + if (offset < 0) + return offset; + + file_pos->pos_in_zip_directory = (uint32_t)offset; + file_pos->num_of_file = (uint32_t)compat->entry_index; + return MZ_OK; +} + +int unzGoToFilePos(unzFile file, unz_file_pos *file_pos) +{ + mz_compat *compat = (mz_compat *)file; + unz64_file_pos file_pos64; + + if (compat == NULL || file_pos == NULL) + return UNZ_PARAMERROR; + + file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory; + file_pos64.num_of_file = file_pos->num_of_file; + + return unzGoToFilePos64(file, &file_pos64); +} + +int unzGetFilePos64(unzFile file, unz64_file_pos *file_pos) +{ + mz_compat *compat = (mz_compat *)file; + int64_t offset = 0; + + if (compat == NULL || file_pos == NULL) + return UNZ_PARAMERROR; + + offset = unzGetOffset64(file); + if (offset < 0) + return (int)offset; + + file_pos->pos_in_zip_directory = offset; + file_pos->num_of_file = compat->entry_index; + return UNZ_OK; +} + +int unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos) +{ + mz_compat *compat = (mz_compat *)file; + int32_t err = MZ_OK; + + if (compat == NULL || file_pos == NULL) + return UNZ_PARAMERROR; + + err = mz_zip_goto_entry(compat->handle, file_pos->pos_in_zip_directory); + if (err == MZ_OK) + compat->entry_index = file_pos->num_of_file; + return err; +} + +int32_t unzGetOffset(unzFile file) +{ + return (int32_t)unzGetOffset64(file); +} + +int64_t unzGetOffset64(unzFile file) +{ + mz_compat *compat = (mz_compat *)file; + if (compat == NULL) + return UNZ_PARAMERROR; + return mz_zip_get_entry(compat->handle); +} + +int unzSetOffset(unzFile file, uint32_t pos) +{ + return unzSetOffset64(file, pos); +} + +int unzSetOffset64(unzFile file, int64_t pos) +{ + mz_compat *compat = (mz_compat *)file; + if (compat == NULL) + return UNZ_PARAMERROR; + return (int)mz_zip_goto_entry(compat->handle, pos); +} + +int unzGetLocalExtrafield(unzFile file, void *buf, unsigned int len) +{ + mz_compat *compat = (mz_compat *)file; + mz_zip_file *file_info = NULL; + int32_t err = MZ_OK; + int32_t bytes_to_copy = 0; + + if (compat == NULL || buf == NULL || len >= INT32_MAX) + return UNZ_PARAMERROR; + + err = mz_zip_entry_get_local_info(compat->handle, &file_info); + if (err != MZ_OK) + return err; + + bytes_to_copy = (int32_t)len; + if (bytes_to_copy > file_info->extrafield_size) + bytes_to_copy = file_info->extrafield_size; + + memcpy(buf, file_info->extrafield, bytes_to_copy); + return MZ_OK; +} + +int64_t unztell(unzFile file) +{ + mz_compat *compat = (mz_compat *)file; + if (compat == NULL) + return UNZ_PARAMERROR; + return (int64_t)compat->total_out; +} + +int32_t unzTell(unzFile file) +{ + mz_compat *compat = (mz_compat *)file; + if (compat == NULL) + return UNZ_PARAMERROR; + return (int32_t)compat->total_out; +} + +int64_t unzTell64(unzFile file) +{ + mz_compat *compat = (mz_compat *)file; + if (compat == NULL) + return UNZ_PARAMERROR; + return (int64_t)compat->total_out; +} + +int unzSeek(unzFile file, int32_t offset, int origin) +{ + return unzSeek64(file, offset, origin); +} + +int unzSeek64(unzFile file, int64_t offset, int origin) +{ + mz_compat *compat = (mz_compat *)file; + mz_zip_file *file_info = NULL; + int64_t position = 0; + int32_t err = MZ_OK; + void *stream = NULL; + + if (compat == NULL) + return UNZ_PARAMERROR; + err = mz_zip_entry_get_info(compat->handle, &file_info); + if (err != MZ_OK) + return err; + if (file_info->compression_method != MZ_COMPRESS_METHOD_STORE) + return UNZ_ERRNO; + + if (origin == SEEK_SET) + position = offset; + else if (origin == SEEK_CUR) + position = compat->total_out + offset; + else if (origin == SEEK_END) + position = (int64_t)file_info->compressed_size + offset; + else + return UNZ_PARAMERROR; + + if (position > (int64_t)file_info->compressed_size) + return UNZ_PARAMERROR; + + err = mz_zip_get_stream(compat->handle, &stream); + if (err == MZ_OK) + err = mz_stream_seek(stream, compat->entry_pos + position, MZ_SEEK_SET); + if (err == MZ_OK) + compat->total_out = position; + return err; +} + +int unzEndOfFile(unzFile file) +{ + mz_compat *compat = (mz_compat *)file; + mz_zip_file *file_info = NULL; + int32_t err = MZ_OK; + + if (compat == NULL) + return UNZ_PARAMERROR; + err = mz_zip_entry_get_info(compat->handle, &file_info); + if (err != MZ_OK) + return err; + if (compat->total_out == (int64_t)file_info->uncompressed_size) + return 1; + return 0; +} + +void* unzGetStream(unzFile file) +{ + mz_compat *compat = (mz_compat *)file; + if (compat == NULL) + return NULL; + return (void *)compat->stream; +} + +/***************************************************************************/ + +void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def) +{ + if (pzlib_filefunc_def != NULL) + *pzlib_filefunc_def = mz_stream_os_get_interface(); +} + +void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def) +{ + if (pzlib_filefunc_def != NULL) + *pzlib_filefunc_def = mz_stream_os_get_interface(); +} + +void fill_win32_filefunc(zlib_filefunc_def *pzlib_filefunc_def) +{ + if (pzlib_filefunc_def != NULL) + *pzlib_filefunc_def = mz_stream_os_get_interface(); +} + +void fill_win32_filefunc64(zlib_filefunc64_def *pzlib_filefunc_def) +{ + if (pzlib_filefunc_def != NULL) + *pzlib_filefunc_def = mz_stream_os_get_interface(); +} + +void fill_win32_filefunc64A(zlib_filefunc64_def *pzlib_filefunc_def) +{ + if (pzlib_filefunc_def != NULL) + *pzlib_filefunc_def = mz_stream_os_get_interface(); +} + +void fill_win32_filefunc64W(zlib_filefunc64_def *pzlib_filefunc_def) +{ + /* NOTE: You should no longer pass in widechar string to open function */ + if (pzlib_filefunc_def != NULL) + *pzlib_filefunc_def = mz_stream_os_get_interface(); +} + +void fill_memory_filefunc(zlib_filefunc_def *pzlib_filefunc_def) +{ + if (pzlib_filefunc_def != NULL) + *pzlib_filefunc_def = mz_stream_mem_get_interface(); +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_compat.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_compat.h new file mode 100644 index 0000000000000000000000000000000000000000..3253eb9e60b781349bf9107a7a07bfb62c735277 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_compat.h @@ -0,0 +1,250 @@ +/* mz_compat.h -- Backwards compatible interface for older versions + Version 2.8.6, April 8, 2019 + part of the MiniZip project + + Copyright (C) 2010-2019 Nathan Moinvaziri + https://github.com/nmoinvaz/minizip + Copyright (C) 1998-2010 Gilles Vollant + https://www.winimage.com/zLibDll/minizip.html + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_COMPAT_H +#define MZ_COMPAT_H + +#include "mz.h" +#include "../SSZipCommon.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +#if defined(HAVE_ZLIB) && defined(MAX_MEM_LEVEL) +#ifndef DEF_MEM_LEVEL +# if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +# else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +# endif +#endif +#endif +#ifndef MAX_WBITS +#define MAX_WBITS 15 +#endif +#ifndef DEF_MEM_LEVEL +#define DEF_MEM_LEVEL 8 +#endif + +#ifndef ZEXPORT +# define ZEXPORT MZ_EXPORT +#endif + +/***************************************************************************/ + +#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagzipFile__ { int unused; } zip_file__; +typedef zip_file__ *zipFile; +#else +typedef void *zipFile; +#endif + +/***************************************************************************/ + +typedef void *zlib_filefunc_def; +typedef void *zlib_filefunc64_def; +typedef const char *zipcharpc; + +typedef struct tm tm_unz; +typedef struct tm tm_zip; + +typedef uint64_t ZPOS64_T; + +/***************************************************************************/ + +// ZipArchive 2.x uses dos_date +#define MZ_COMPAT_VERSION 120 + +#if MZ_COMPAT_VERSION <= 110 +#define mz_dos_date dosDate +#else +#define mz_dos_date dos_date +#endif + +typedef struct +{ + uint32_t mz_dos_date; + struct tm tmz_date; + uint16_t internal_fa; /* internal file attributes 2 bytes */ + uint32_t external_fa; /* external file attributes 4 bytes */ +} zip_fileinfo; + +/***************************************************************************/ + +#define ZIP_OK (0) +#define ZIP_EOF (0) +#define ZIP_ERRNO (-1) +#define ZIP_PARAMERROR (-102) +#define ZIP_BADZIPFILE (-103) +#define ZIP_INTERNALERROR (-104) + +#define Z_BZIP2ED (12) + +#define APPEND_STATUS_CREATE (0) +#define APPEND_STATUS_CREATEAFTER (1) +#define APPEND_STATUS_ADDINZIP (2) + +/***************************************************************************/ +/* Writing a zip file */ + +ZEXPORT zipFile zipOpen(const char *path, int append); +ZEXPORT zipFile zipOpen64(const void *path, int append); +ZEXPORT zipFile zipOpen2(const char *path, int append, const char **globalcomment, + zlib_filefunc_def *pzlib_filefunc_def); +ZEXPORT zipFile zipOpen2_64(const void *path, int append, const char **globalcomment, + zlib_filefunc64_def *pzlib_filefunc_def); + zipFile zipOpen_MZ(void *stream, int append, const char **globalcomment); + +ZEXPORT int zipOpenNewFileInZip5(zipFile file, const char *filename, const zip_fileinfo *zipfi, + const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, + uint16_t size_extrafield_global, const char *comment, uint16_t compression_method, int level, + int raw, int windowBits, int memLevel, int strategy, const char *password, + signed char aes, uint16_t version_madeby, uint16_t flag_base, int zip64); + +ZEXPORT int zipWriteInFileInZip(zipFile file, const void *buf, uint32_t len); + +ZEXPORT int zipCloseFileInZipRaw(zipFile file, uint32_t uncompressed_size, uint32_t crc32); +ZEXPORT int zipCloseFileInZipRaw64(zipFile file, int64_t uncompressed_size, uint32_t crc32); +ZEXPORT int zipCloseFileInZip(zipFile file); +ZEXPORT int zipCloseFileInZip64(zipFile file); + +ZEXPORT int zipClose(zipFile file, const char *global_comment); +ZEXPORT int zipClose_64(zipFile file, const char *global_comment); +ZEXPORT int zipClose2_64(zipFile file, const char *global_comment, uint16_t version_madeby); + int zipClose_MZ(zipFile file, const char *global_comment); + int zipClose2_MZ(zipFile file, const char *global_comment, uint16_t version_madeby); +ZEXPORT void* zipGetStream(zipFile file); + +/***************************************************************************/ + +#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagunzFile__ { int unused; } unz_file__; +typedef unz_file__ *unzFile; +#else +typedef void *unzFile; +#endif + +/***************************************************************************/ + +#define UNZ_OK (0) +#define UNZ_END_OF_LIST_OF_FILE (-100) +#define UNZ_ERRNO (-1) +#define UNZ_EOF (0) +#define UNZ_PARAMERROR (-102) +#define UNZ_BADZIPFILE (-103) +#define UNZ_INTERNALERROR (-104) +#define UNZ_CRCERROR (-105) +#define UNZ_BADPASSWORD (-106) + +/***************************************************************************/ + +typedef int (*unzFileNameComparer)(unzFile file, const char *filename1, const char *filename2); +typedef int (*unzIteratorFunction)(unzFile file); +typedef int (*unzIteratorFunction2)(unzFile file, unz_file_info64 *pfile_info, char *filename, + uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, + uint16_t comment_size); + +/***************************************************************************/ +/* Reading a zip file */ + +ZEXPORT unzFile unzOpen(const char *path); +ZEXPORT unzFile unzOpen64(const void *path); +ZEXPORT unzFile unzOpen2(const char *path, zlib_filefunc_def *pzlib_filefunc_def); +ZEXPORT unzFile unzOpen2_64(const void *path, zlib_filefunc64_def *pzlib_filefunc_def); + unzFile unzOpen_MZ(void *stream); + +ZEXPORT int unzClose(unzFile file); + int unzClose_MZ(unzFile file); + +ZEXPORT int unzGetGlobalInfo(unzFile file, unz_global_info* pglobal_info32); +ZEXPORT int unzGetGlobalInfo64(unzFile file, unz_global_info64 *pglobal_info); +ZEXPORT int unzGetGlobalComment(unzFile file, char *comment, uint16_t comment_size); + +ZEXPORT int unzOpenCurrentFile(unzFile file); +ZEXPORT int unzOpenCurrentFilePassword(unzFile file, const char *password); +ZEXPORT int unzOpenCurrentFile2(unzFile file, int *method, int *level, int raw); +ZEXPORT int unzOpenCurrentFile3(unzFile file, int *method, int *level, int raw, const char *password); +ZEXPORT int unzReadCurrentFile(unzFile file, void *buf, uint32_t len); +ZEXPORT int unzCloseCurrentFile(unzFile file); + + +ZEXPORT int unzGetCurrentFileInfo(unzFile file, unz_file_info *pfile_info, char *filename, + uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, + uint16_t comment_size); +ZEXPORT int unzGetCurrentFileInfo64(unzFile file, unz_file_info64 * pfile_info, char *filename, + uint16_t filename_size, void *extrafield, uint16_t extrafield_size, char *comment, + uint16_t comment_size); + +ZEXPORT int unzGoToFirstFile(unzFile file); +ZEXPORT int unzGoToNextFile(unzFile file); +ZEXPORT int unzLocateFile(unzFile file, const char *filename, unzFileNameComparer filename_compare_func); + +ZEXPORT int unzGetLocalExtrafield(unzFile file, void *buf, unsigned int len); + +/***************************************************************************/ +/* Raw access to zip file */ + +typedef struct unz_file_pos_s +{ + uint32_t pos_in_zip_directory; /* offset in zip file directory */ + uint32_t num_of_file; /* # of file */ +} unz_file_pos; + +ZEXPORT int unzGetFilePos(unzFile file, unz_file_pos *file_pos); +ZEXPORT int unzGoToFilePos(unzFile file, unz_file_pos *file_pos); + +typedef struct unz64_file_pos_s +{ + int64_t pos_in_zip_directory; /* offset in zip file directory */ + uint64_t num_of_file; /* # of file */ +} unz64_file_pos; + +ZEXPORT int unzGetFilePos64(unzFile file, unz64_file_pos *file_pos); +ZEXPORT int unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos); + +ZEXPORT int64_t unzGetOffset64(unzFile file); +ZEXPORT int32_t unzGetOffset(unzFile file); +ZEXPORT int unzSetOffset64(unzFile file, int64_t pos); +ZEXPORT int unzSetOffset(unzFile file, uint32_t pos); +ZEXPORT int64_t unztell(unzFile file); +ZEXPORT int32_t unzTell(unzFile file); +ZEXPORT int64_t unzTell64(unzFile file); +ZEXPORT int unzSeek(unzFile file, int32_t offset, int origin); +ZEXPORT int unzSeek64(unzFile file, int64_t offset, int origin); +ZEXPORT int unzEndOfFile(unzFile file); +ZEXPORT void* unzGetStream(unzFile file); + +/***************************************************************************/ + +ZEXPORT void fill_fopen_filefunc(zlib_filefunc_def *pzlib_filefunc_def); +ZEXPORT void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def); +ZEXPORT void fill_win32_filefunc(zlib_filefunc_def *pzlib_filefunc_def); +ZEXPORT void fill_win32_filefunc64(zlib_filefunc64_def *pzlib_filefunc_def); +ZEXPORT void fill_win32_filefunc64A(zlib_filefunc64_def *pzlib_filefunc_def); +ZEXPORT void fill_win32_filefunc64W(zlib_filefunc64_def *pzlib_filefunc_def); +ZEXPORT void fill_memory_filefunc(zlib_filefunc_def *pzlib_filefunc_def); + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_crypt.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_crypt.c new file mode 100644 index 0000000000000000000000000000000000000000..dd2cd427c86c37904ab478b5ff9ef59f4cb663e4 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_crypt.c @@ -0,0 +1,196 @@ +/* mz_crypt.c -- Crypto/hash functions + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + + +#include "mz.h" +#include "mz_os.h" +#include "mz_crypt.h" + +#if defined(HAVE_ZLIB) +# include "zlib.h" +# if defined(ZLIBNG_VERNUM) && !defined(ZLIB_COMPAT) +# include "zlib-ng.h" +# endif +#elif defined(HAVE_LZMA) +# include "lzma.h" +#endif + +/***************************************************************************/ +/* Define z_crc_t in zlib 1.2.5 and less or if using zlib-ng */ + +#if defined(HAVE_ZLIB) && defined(ZLIBNG_VERNUM) +# if defined(ZLIB_COMPAT) +# define ZLIB_PREFIX(x) x +# else +# define ZLIB_PREFIX(x) zng_ ## x +# endif + typedef uint32_t z_crc_t; +#elif defined(HAVE_ZLIB) +# define ZLIB_PREFIX(x) x +# if (ZLIB_VERNUM < 0x1270) + typedef unsigned long z_crc_t; +# endif +#endif + +/***************************************************************************/ + +#if defined(MZ_ZIP_NO_CRYPTO) +int32_t mz_crypt_rand(uint8_t *buf, int32_t size) { + return mz_os_rand(buf, size); +} +#endif + +uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size) { +#if defined(HAVE_ZLIB) + return (uint32_t)ZLIB_PREFIX(crc32)((z_crc_t)value, buf, (uInt)size); +#elif defined(HAVE_LZMA) + return (uint32_t)lzma_crc32(buf, (size_t)size, (uint32_t)value); +#else + static uint32_t crc32_table[256] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, + 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, + 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, + 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, + 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, + 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, + 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, + 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, + 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, + 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, + 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, + 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, + 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, + 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d + }; + value = ~value; + + while (size > 0) { + value = (value >> 8) ^ crc32_table[(value ^ *buf) & 0xFF]; + + buf += 1; + size -= 1; + } + + return ~value; +#endif +} + +#if defined(HAVE_WZAES) +int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *salt, + int32_t salt_length, int32_t iteration_count, uint8_t *key, int32_t key_length) { + void *hmac1 = NULL; + void *hmac2 = NULL; + void *hmac3 = NULL; + int32_t err = MZ_OK; + uint16_t i = 0; + uint16_t j = 0; + uint16_t k = 0; + uint16_t block_count = 0; + uint8_t uu[MZ_HASH_SHA1_SIZE]; + uint8_t ux[MZ_HASH_SHA1_SIZE]; + + if (password == NULL || salt == NULL || key == NULL) + return MZ_PARAM_ERROR; + + memset(key, 0, key_length); + + mz_crypt_hmac_create(&hmac1); + mz_crypt_hmac_create(&hmac2); + mz_crypt_hmac_create(&hmac3); + + mz_crypt_hmac_set_algorithm(hmac1, MZ_HASH_SHA1); + mz_crypt_hmac_set_algorithm(hmac2, MZ_HASH_SHA1); + mz_crypt_hmac_set_algorithm(hmac3, MZ_HASH_SHA1); + + err = mz_crypt_hmac_init(hmac1, password, password_length); + if (err == MZ_OK) + err = mz_crypt_hmac_init(hmac2, password, password_length); + if (err == MZ_OK) + err = mz_crypt_hmac_update(hmac2, salt, salt_length); + + block_count = 1 + ((uint16_t)key_length - 1) / MZ_HASH_SHA1_SIZE; + + for (i = 0; (err == MZ_OK) && (i < block_count); i += 1) { + memset(ux, 0, sizeof(ux)); + + err = mz_crypt_hmac_copy(hmac2, hmac3); + if (err != MZ_OK) + break; + + uu[0] = (uint8_t)((i + 1) >> 24); + uu[1] = (uint8_t)((i + 1) >> 16); + uu[2] = (uint8_t)((i + 1) >> 8); + uu[3] = (uint8_t)(i + 1); + + for (j = 0, k = 4; j < iteration_count; j += 1) { + err = mz_crypt_hmac_update(hmac3, uu, k); + if (err == MZ_OK) + err = mz_crypt_hmac_end(hmac3, uu, sizeof(uu)); + if (err != MZ_OK) + break; + + for(k = 0; k < MZ_HASH_SHA1_SIZE; k += 1) + ux[k] ^= uu[k]; + + err = mz_crypt_hmac_copy(hmac1, hmac3); + if (err != MZ_OK) + break; + } + + if (err != MZ_OK) + break; + + j = 0; + k = i * MZ_HASH_SHA1_SIZE; + + while (j < MZ_HASH_SHA1_SIZE && k < key_length) + key[k++] = ux[j++]; + } + + /* hmac3 uses the same provider as hmac2, so it must be deleted + before the context is destroyed. */ + mz_crypt_hmac_delete(&hmac3); + mz_crypt_hmac_delete(&hmac1); + mz_crypt_hmac_delete(&hmac2); + + return err; +} +#endif + +/***************************************************************************/ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_crypt.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_crypt.h new file mode 100644 index 0000000000000000000000000000000000000000..59a193c02b795bb2e6135f69dc533a194194e7d1 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_crypt.h @@ -0,0 +1,65 @@ +/* mz_crypt.h -- Crypto/hash functions + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_CRYPT_H +#define MZ_CRYPT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size); + +int32_t mz_crypt_pbkdf2(uint8_t *password, int32_t password_length, uint8_t *salt, + int32_t salt_length, int32_t iteration_count, uint8_t *key, int32_t key_length); + +/***************************************************************************/ + +int32_t mz_crypt_rand(uint8_t *buf, int32_t size); + +void mz_crypt_sha_reset(void *handle); +int32_t mz_crypt_sha_begin(void *handle); +int32_t mz_crypt_sha_update(void *handle, const void *buf, int32_t size); +int32_t mz_crypt_sha_end(void *handle, uint8_t *digest, int32_t digest_size); +void mz_crypt_sha_set_algorithm(void *handle, uint16_t algorithm); +void* mz_crypt_sha_create(void **handle); +void mz_crypt_sha_delete(void **handle); + +void mz_crypt_aes_reset(void *handle); +int32_t mz_crypt_aes_encrypt(void *handle, uint8_t *buf, int32_t size); +int32_t mz_crypt_aes_decrypt(void *handle, uint8_t *buf, int32_t size); +int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_length); +int32_t mz_crypt_aes_set_decrypt_key(void *handle, const void *key, int32_t key_length); +void mz_crypt_aes_set_mode(void *handle, int32_t mode); +void* mz_crypt_aes_create(void **handle); +void mz_crypt_aes_delete(void **handle); + +void mz_crypt_hmac_reset(void *handle); +int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length); +int32_t mz_crypt_hmac_update(void *handle, const void *buf, int32_t size); +int32_t mz_crypt_hmac_end(void *handle, uint8_t *digest, int32_t digest_size); +int32_t mz_crypt_hmac_copy(void *src_handle, void *target_handle); +void mz_crypt_hmac_set_algorithm(void *handle, uint16_t algorithm); +void* mz_crypt_hmac_create(void **handle); +void mz_crypt_hmac_delete(void **handle); + +int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size, + const char *cert_pwd, uint8_t **signature, int32_t *signature_size); +int32_t mz_crypt_sign_verify(uint8_t *message, int32_t message_size, uint8_t *signature, int32_t signature_size); + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_crypt_apple.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_crypt_apple.c new file mode 100644 index 0000000000000000000000000000000000000000..4519753fa4b8c8f4fb4775b051659184cd725f59 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_crypt_apple.c @@ -0,0 +1,487 @@ +/* mz_crypt_apple.c -- Crypto/hash functions for Apple + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + + +#include "mz.h" + +#include +#include +#include +#include +#include +#include + +/***************************************************************************/ + +int32_t mz_crypt_rand(uint8_t *buf, int32_t size) { + if (SecRandomCopyBytes(kSecRandomDefault, size, buf) != errSecSuccess) + return 0; + return size; +} + +/***************************************************************************/ + +typedef struct mz_crypt_sha_s { + CC_SHA1_CTX ctx1; + CC_SHA256_CTX ctx256; + int32_t error; + int32_t initialized; + uint16_t algorithm; +} mz_crypt_sha; + +/***************************************************************************/ + +void mz_crypt_sha_reset(void *handle) { + mz_crypt_sha *sha = (mz_crypt_sha *)handle; + + sha->error = 0; + sha->initialized = 0; +} + +int32_t mz_crypt_sha_begin(void *handle) { + mz_crypt_sha *sha = (mz_crypt_sha *)handle; + + if (sha == NULL) + return MZ_PARAM_ERROR; + + mz_crypt_sha_reset(handle); + + if (sha->algorithm == MZ_HASH_SHA1) + sha->error = CC_SHA1_Init(&sha->ctx1); + else if (sha->algorithm == MZ_HASH_SHA256) + sha->error = CC_SHA256_Init(&sha->ctx256); + else + return MZ_PARAM_ERROR; + + if (!sha->error) + return MZ_HASH_ERROR; + + sha->initialized = 1; + return MZ_OK; +} + +int32_t mz_crypt_sha_update(void *handle, const void *buf, int32_t size) { + mz_crypt_sha *sha = (mz_crypt_sha *)handle; + + if (sha == NULL || buf == NULL || !sha->initialized) + return MZ_PARAM_ERROR; + + if (sha->algorithm == MZ_HASH_SHA1) + sha->error = CC_SHA1_Update(&sha->ctx1, buf, size); + else + sha->error = CC_SHA256_Update(&sha->ctx256, buf, size); + + if (!sha->error) + return MZ_HASH_ERROR; + + return size; +} + +int32_t mz_crypt_sha_end(void *handle, uint8_t *digest, int32_t digest_size) { + mz_crypt_sha *sha = (mz_crypt_sha *)handle; + + if (sha == NULL || digest == NULL || !sha->initialized) + return MZ_PARAM_ERROR; + + if (sha->algorithm == MZ_HASH_SHA1) { + if (digest_size < MZ_HASH_SHA1_SIZE) + return MZ_BUF_ERROR; + sha->error = CC_SHA1_Final(digest, &sha->ctx1); + } else { + if (digest_size < MZ_HASH_SHA256_SIZE) + return MZ_BUF_ERROR; + sha->error = CC_SHA256_Final(digest, &sha->ctx256); + } + + if (!sha->error) + return MZ_HASH_ERROR; + + return MZ_OK; +} + +void mz_crypt_sha_set_algorithm(void *handle, uint16_t algorithm) { + mz_crypt_sha *sha = (mz_crypt_sha *)handle; + sha->algorithm = algorithm; +} + +void *mz_crypt_sha_create(void **handle) { + mz_crypt_sha *sha = NULL; + + sha = (mz_crypt_sha *)MZ_ALLOC(sizeof(mz_crypt_sha)); + if (sha != NULL) { + memset(sha, 0, sizeof(mz_crypt_sha)); + sha->algorithm = MZ_HASH_SHA256; + } + if (handle != NULL) + *handle = sha; + + return sha; +} + +void mz_crypt_sha_delete(void **handle) { + mz_crypt_sha *sha = NULL; + if (handle == NULL) + return; + sha = (mz_crypt_sha *)*handle; + if (sha != NULL) { + mz_crypt_sha_reset(*handle); + MZ_FREE(sha); + } + *handle = NULL; +} + +/***************************************************************************/ + +typedef struct mz_crypt_aes_s { + CCCryptorRef crypt; + int32_t mode; + int32_t error; +} mz_crypt_aes; + +/***************************************************************************/ + +void mz_crypt_aes_reset(void *handle) { + mz_crypt_aes *aes = (mz_crypt_aes *)handle; + + if (aes->crypt != NULL) + CCCryptorRelease(aes->crypt); + aes->crypt = NULL; +} + +int32_t mz_crypt_aes_encrypt(void *handle, uint8_t *buf, int32_t size) { + mz_crypt_aes *aes = (mz_crypt_aes *)handle; + size_t data_moved = 0; + + if (aes == NULL || buf == NULL) + return MZ_PARAM_ERROR; + if (size != MZ_AES_BLOCK_SIZE) + return MZ_PARAM_ERROR; + + aes->error = CCCryptorUpdate(aes->crypt, buf, size, buf, size, &data_moved); + + if (aes->error != kCCSuccess) + return MZ_HASH_ERROR; + + return size; +} + +int32_t mz_crypt_aes_decrypt(void *handle, uint8_t *buf, int32_t size) { + mz_crypt_aes *aes = (mz_crypt_aes *)handle; + size_t data_moved = 0; + + if (aes == NULL || buf == NULL) + return MZ_PARAM_ERROR; + if (size != MZ_AES_BLOCK_SIZE) + return MZ_PARAM_ERROR; + + aes->error = CCCryptorUpdate(aes->crypt, buf, size, buf, size, &data_moved); + + if (aes->error != kCCSuccess) + return MZ_HASH_ERROR; + + return size; +} + +int32_t mz_crypt_aes_set_encrypt_key(void *handle, const void *key, int32_t key_length) { + mz_crypt_aes *aes = (mz_crypt_aes *)handle; + + + if (aes == NULL || key == NULL || key_length == 0) + return MZ_PARAM_ERROR; + + mz_crypt_aes_reset(handle); + + aes->error = CCCryptorCreate(kCCEncrypt, kCCAlgorithmAES, kCCOptionECBMode, + key, key_length, NULL, &aes->crypt); + + if (aes->error != kCCSuccess) + return MZ_HASH_ERROR; + + return MZ_OK; +} + +int32_t mz_crypt_aes_set_decrypt_key(void *handle, const void *key, int32_t key_length) { + mz_crypt_aes *aes = (mz_crypt_aes *)handle; + + + if (aes == NULL || key == NULL || key_length == 0) + return MZ_PARAM_ERROR; + + mz_crypt_aes_reset(handle); + + aes->error = CCCryptorCreate(kCCDecrypt, kCCAlgorithmAES, kCCOptionECBMode, + key, key_length, NULL, &aes->crypt); + + if (aes->error != kCCSuccess) + return MZ_HASH_ERROR; + + return MZ_OK; +} + +void mz_crypt_aes_set_mode(void *handle, int32_t mode) { + mz_crypt_aes *aes = (mz_crypt_aes *)handle; + aes->mode = mode; +} + +void *mz_crypt_aes_create(void **handle) { + mz_crypt_aes *aes = NULL; + + aes = (mz_crypt_aes *)MZ_ALLOC(sizeof(mz_crypt_aes)); + if (aes != NULL) + memset(aes, 0, sizeof(mz_crypt_aes)); + if (handle != NULL) + *handle = aes; + + return aes; +} + +void mz_crypt_aes_delete(void **handle) { + mz_crypt_aes *aes = NULL; + if (handle == NULL) + return; + aes = (mz_crypt_aes *)*handle; + if (aes != NULL) { + mz_crypt_aes_reset(*handle); + MZ_FREE(aes); + } + *handle = NULL; +} + +/***************************************************************************/ + +typedef struct mz_crypt_hmac_s { + CCHmacContext ctx; + int32_t initialized; + int32_t error; + uint16_t algorithm; +} mz_crypt_hmac; + +/***************************************************************************/ + +static void mz_crypt_hmac_free(void *handle) { + mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle; + memset(&hmac->ctx, 0, sizeof(hmac->ctx)); +} + +void mz_crypt_hmac_reset(void *handle) { + mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle; + mz_crypt_hmac_free(handle); + hmac->error = 0; +} + +int32_t mz_crypt_hmac_init(void *handle, const void *key, int32_t key_length) { + mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle; + CCHmacAlgorithm algorithm = 0; + + if (hmac == NULL || key == NULL) + return MZ_PARAM_ERROR; + + mz_crypt_hmac_reset(handle); + + if (hmac->algorithm == MZ_HASH_SHA1) + algorithm = kCCHmacAlgSHA1; + else if (hmac->algorithm == MZ_HASH_SHA256) + algorithm = kCCHmacAlgSHA256; + else + return MZ_PARAM_ERROR; + + CCHmacInit(&hmac->ctx, algorithm, key, key_length); + return MZ_OK; +} + +int32_t mz_crypt_hmac_update(void *handle, const void *buf, int32_t size) { + mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle; + + if (hmac == NULL || buf == NULL) + return MZ_PARAM_ERROR; + + CCHmacUpdate(&hmac->ctx, buf, size); + return MZ_OK; +} + +int32_t mz_crypt_hmac_end(void *handle, uint8_t *digest, int32_t digest_size) { + mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle; + + if (hmac == NULL || digest == NULL) + return MZ_PARAM_ERROR; + + if (hmac->algorithm == MZ_HASH_SHA1) { + if (digest_size < MZ_HASH_SHA1_SIZE) + return MZ_BUF_ERROR; + CCHmacFinal(&hmac->ctx, digest); + } else { + if (digest_size < MZ_HASH_SHA256_SIZE) + return MZ_BUF_ERROR; + CCHmacFinal(&hmac->ctx, digest); + } + + return MZ_OK; +} + +void mz_crypt_hmac_set_algorithm(void *handle, uint16_t algorithm) { + mz_crypt_hmac *hmac = (mz_crypt_hmac *)handle; + hmac->algorithm = algorithm; +} + +int32_t mz_crypt_hmac_copy(void *src_handle, void *target_handle) { + mz_crypt_hmac *source = (mz_crypt_hmac *)src_handle; + mz_crypt_hmac *target = (mz_crypt_hmac *)target_handle; + + if (source == NULL || target == NULL) + return MZ_PARAM_ERROR; + + memcpy(&target->ctx, &source->ctx, sizeof(CCHmacContext)); + return MZ_OK; +} + +void *mz_crypt_hmac_create(void **handle) { + mz_crypt_hmac *hmac = NULL; + + hmac = (mz_crypt_hmac *)MZ_ALLOC(sizeof(mz_crypt_hmac)); + if (hmac != NULL) { + memset(hmac, 0, sizeof(mz_crypt_hmac)); + hmac->algorithm = MZ_HASH_SHA256; + } + if (handle != NULL) + *handle = hmac; + + return hmac; +} + +void mz_crypt_hmac_delete(void **handle) { + mz_crypt_hmac *hmac = NULL; + if (handle == NULL) + return; + hmac = (mz_crypt_hmac *)*handle; + if (hmac != NULL) { + mz_crypt_hmac_free(*handle); + MZ_FREE(hmac); + } + *handle = NULL; +} + +/***************************************************************************/ + +#if defined(MZ_ZIP_SIGNING) +int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size, + const char *cert_pwd, uint8_t **signature, int32_t *signature_size) { + CFStringRef password_ref = NULL; + CFDictionaryRef options_dict = NULL; + CFDictionaryRef identity_trust = NULL; + CFDataRef signature_out = NULL; + CFDataRef pkcs12_data = NULL; + CFArrayRef items = 0; + SecIdentityRef identity = NULL; + SecTrustRef trust = NULL; + OSStatus status = noErr; + const void *options_key[2] = { kSecImportExportPassphrase, kSecReturnRef }; + const void *options_values[2] = { 0, kCFBooleanTrue }; + int32_t err = MZ_SIGN_ERROR; + + + if (message == NULL || cert_data == NULL || signature == NULL || signature_size == NULL) + return MZ_PARAM_ERROR; + + *signature = NULL; + *signature_size = 0; + + password_ref = CFStringCreateWithCString(0, cert_pwd, kCFStringEncodingUTF8); + options_values[0] = password_ref; + + options_dict = CFDictionaryCreate(0, options_key, options_values, 2, 0, 0); + if (options_dict) + pkcs12_data = CFDataCreate(0, cert_data, cert_data_size); + if (pkcs12_data) + status = SecPKCS12Import(pkcs12_data, options_dict, &items); + if (status == noErr) + identity_trust = CFArrayGetValueAtIndex(items, 0); + if (identity_trust) + identity = (SecIdentityRef)CFDictionaryGetValue(identity_trust, kSecImportItemIdentity); + if (identity) + trust = (SecTrustRef)CFDictionaryGetValue(identity_trust, kSecImportItemTrust); + if (trust) { + status = CMSEncodeContent(identity, NULL, NULL, FALSE, 0, message, message_size, &signature_out); + + if (status == errSecSuccess) { + *signature_size = CFDataGetLength(signature_out); + *signature = (uint8_t *)MZ_ALLOC(*signature_size); + + memcpy(*signature, CFDataGetBytePtr(signature_out), *signature_size); + + err = MZ_OK; + } + } + + if (signature_out) + CFRelease(signature_out); + if (items) + CFRelease(items); + if (pkcs12_data) + CFRelease(pkcs12_data); + if (options_dict) + CFRelease(options_dict); + if (password_ref) + CFRelease(password_ref); + + return err; +} + +int32_t mz_crypt_sign_verify(uint8_t *message, int32_t message_size, uint8_t *signature, int32_t signature_size) { + CMSDecoderRef decoder = NULL; + CMSSignerStatus signer_status = 0; + CFDataRef message_out = NULL; + SecPolicyRef trust_policy = NULL; + OSStatus status = noErr; + OSStatus verify_status = noErr; + size_t signer_count = 0; + size_t i = 0; + int32_t err = MZ_SIGN_ERROR; + + if (message == NULL || signature == NULL) + return MZ_PARAM_ERROR; + + status = CMSDecoderCreate(&decoder); + if (status == errSecSuccess) + status = CMSDecoderUpdateMessage(decoder, signature, signature_size); + if (status == errSecSuccess) + status = CMSDecoderFinalizeMessage(decoder); + if (status == errSecSuccess) + trust_policy = SecPolicyCreateBasicX509(); + + if (status == errSecSuccess && trust_policy) { + CMSDecoderGetNumSigners(decoder, &signer_count); + if (signer_count > 0) + err = MZ_OK; + for (i = 0; i < signer_count; i += 1) { + status = CMSDecoderCopySignerStatus(decoder, i, trust_policy, TRUE, &signer_status, NULL, &verify_status); + if (status != errSecSuccess || verify_status != 0 || signer_status != kCMSSignerValid) { + err = MZ_SIGN_ERROR; + break; + } + } + } + + if (err == MZ_OK) { + status = CMSDecoderCopyContent(decoder, &message_out); + if ((status != errSecSuccess) || + (CFDataGetLength(message_out) != message_size) || + (memcmp(message, CFDataGetBytePtr(message_out), message_size) != 0)) + err = MZ_SIGN_ERROR; + } + + if (trust_policy) + CFRelease(trust_policy); + if (decoder) + CFRelease(decoder); + + return err; +} + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_os.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_os.c new file mode 100644 index 0000000000000000000000000000000000000000..f96befe64c1bf732e9db5e145e7515ee74ebaa6c --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_os.c @@ -0,0 +1,354 @@ +/* mz_os.c -- System functions + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + Copyright (C) 1998-2010 Gilles Vollant + https://www.winimage.com/zLibDll/minizip.html + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#include "mz.h" +#include "mz_crypt.h" +#include "mz_os.h" +#include "mz_strm.h" +#include "mz_strm_os.h" + +#include /* tolower */ + +/***************************************************************************/ + +int32_t mz_path_combine(char *path, const char *join, int32_t max_path) { + int32_t path_len = 0; + + if (path == NULL || join == NULL || max_path == 0) + return MZ_PARAM_ERROR; + + path_len = (int32_t)strlen(path); + + if (path_len == 0) { + strncpy(path, join, max_path - 1); + path[max_path - 1] = 0; + } else { + mz_path_append_slash(path, max_path, MZ_PATH_SLASH_PLATFORM); + strncat(path, join, max_path - path_len); + } + + return MZ_OK; +} + +int32_t mz_path_append_slash(char *path, int32_t max_path, char slash) { + int32_t path_len = (int32_t)strlen(path); + if ((path_len + 2) >= max_path) + return MZ_BUF_ERROR; + if (path[path_len - 1] != '\\' && path[path_len - 1] != '/') { + path[path_len] = slash; + path[path_len + 1] = 0; + } + return MZ_OK; +} + +int32_t mz_path_remove_slash(char *path) { + int32_t path_len = (int32_t)strlen(path); + while (path_len > 0) { + if (path[path_len - 1] == '\\' || path[path_len - 1] == '/') + path[path_len - 1] = 0; + else + break; + + path_len -= 1; + } + return MZ_OK; +} + +int32_t mz_path_has_slash(const char *path) { + int32_t path_len = (int32_t)strlen(path); + if (path[path_len - 1] != '\\' && path[path_len - 1] != '/') + return MZ_EXIST_ERROR; + return MZ_OK; +} + +int32_t mz_path_convert_slashes(char *path, char slash) { + int32_t i = 0; + + for (i = 0; i < (int32_t)strlen(path); i += 1) { + if (path[i] == '\\' || path[i] == '/') + path[i] = slash; + } + return MZ_OK; +} + +int32_t mz_path_compare_wc(const char *path, const char *wildcard, uint8_t ignore_case) { + while (*path != 0) { + switch (*wildcard) { + case '*': + + if (*(wildcard + 1) == 0) + return MZ_OK; + + while (*path != 0) { + if (mz_path_compare_wc(path, (wildcard + 1), ignore_case) == MZ_OK) + return MZ_OK; + + path += 1; + } + + return MZ_EXIST_ERROR; + + default: + /* Ignore differences in path slashes on platforms */ + if ((*path == '\\' && *wildcard == '/') || (*path == '/' && *wildcard == '\\')) + break; + + if (ignore_case) { + if (tolower(*path) != tolower(*wildcard)) + return MZ_EXIST_ERROR; + } else { + if (*path != *wildcard) + return MZ_EXIST_ERROR; + } + + break; + } + + path += 1; + wildcard += 1; + } + + if ((*wildcard != 0) && (*wildcard != '*')) + return MZ_EXIST_ERROR; + + return MZ_OK; +} + +int32_t mz_path_resolve(const char *path, char *output, int32_t max_output) { + const char *source = path; + const char *check = output; + char *target = output; + + + if (max_output <= 0) + return MZ_PARAM_ERROR; + + while (*source != 0 && max_output > 1) { + check = source; + if ((*check == '\\') || (*check == '/')) + check += 1; + + if ((source == path) || (target == output) || (check != source)) { + /* Skip double paths */ + if ((*check == '\\') || (*check == '/')) { + source += 1; + continue; + } + if (*check == '.') { + check += 1; + + /* Remove . if at end of string and not at the beginning */ + if ((*check == 0) && (source != path && target != output)) { + /* Copy last slash */ + *target = *source; + target += 1; + max_output -= 1; + source += (check - source); + continue; + } + /* Remove . if not at end of string */ + else if ((*check == '\\') || (*check == '/')) { + source += (check - source); + /* Skip slash if at beginning of string */ + if (target == output && *source != 0) + source += 1; + continue; + } + /* Go to parent directory .. */ + else if (*check == '.') { + check += 1; + if ((*check == 0) || (*check == '\\' || *check == '/')) { + source += (check - source); + + /* Search backwards for previous slash */ + if (target != output) { + target -= 1; + do { + if ((*target == '\\') || (*target == '/')) + break; + + target -= 1; + max_output += 1; + } while (target > output); + } + + if ((target == output) && (*source != 0)) + source += 1; + if ((*target == '\\' || *target == '/') && (*source == 0)) + target += 1; + + *target = 0; + continue; + } + } + } + } + + *target = *source; + + source += 1; + target += 1; + max_output -= 1; + } + + *target = 0; + + if (*path == 0) + return MZ_INTERNAL_ERROR; + + return MZ_OK; +} + +int32_t mz_path_remove_filename(char *path) { + char *path_ptr = NULL; + + if (path == NULL) + return MZ_PARAM_ERROR; + + path_ptr = path + strlen(path) - 1; + + while (path_ptr > path) { + if ((*path_ptr == '/') || (*path_ptr == '\\')) { + *path_ptr = 0; + break; + } + + path_ptr -= 1; + } + + if (path_ptr == path) + *path_ptr = 0; + + return MZ_OK; +} + +int32_t mz_path_remove_extension(char *path) { + char *path_ptr = NULL; + + if (path == NULL) + return MZ_PARAM_ERROR; + + path_ptr = path + strlen(path) - 1; + + while (path_ptr > path) { + if ((*path_ptr == '/') || (*path_ptr == '\\')) + break; + if (*path_ptr == '.') { + *path_ptr = 0; + break; + } + + path_ptr -= 1; + } + + if (path_ptr == path) + *path_ptr = 0; + + return MZ_OK; +} + +int32_t mz_path_get_filename(const char *path, const char **filename) { + const char *match = NULL; + + if (path == NULL || filename == NULL) + return MZ_PARAM_ERROR; + + *filename = NULL; + + for (match = path; *match != 0; match += 1) { + if ((*match == '\\') || (*match == '/')) + *filename = match + 1; + } + + if (*filename == NULL) + return MZ_EXIST_ERROR; + + return MZ_OK; +} + +int32_t mz_dir_make(const char *path) { + int32_t err = MZ_OK; + int16_t len = 0; + char *current_dir = NULL; + char *match = NULL; + char hold = 0; + + + len = (int16_t)strlen(path); + if (len <= 0) + return 0; + + current_dir = (char *)MZ_ALLOC((uint16_t)len + 1); + if (current_dir == NULL) + return MZ_MEM_ERROR; + + strcpy(current_dir, path); + mz_path_remove_slash(current_dir); + + err = mz_os_make_dir(current_dir); + if (err != MZ_OK) { + match = current_dir + 1; + while (1) { + while (*match != 0 && *match != '\\' && *match != '/') + match += 1; + hold = *match; + *match = 0; + + err = mz_os_make_dir(current_dir); + if (err != MZ_OK) + break; + if (hold == 0) + break; + + *match = hold; + match += 1; + } + } + + MZ_FREE(current_dir); + return err; +} + +int32_t mz_file_get_crc(const char *path, uint32_t *result_crc) { + void *stream = NULL; + uint32_t crc32 = 0; + int32_t read = 0; + int32_t err = MZ_OK; + uint8_t buf[16384]; + + mz_stream_os_create(&stream); + + err = mz_stream_os_open(stream, path, MZ_OPEN_MODE_READ); + + if (err == MZ_OK) { + do { + read = mz_stream_os_read(stream, buf, sizeof(buf)); + + if (read < 0) { + err = read; + break; + } + + crc32 = mz_crypt_crc32_update(crc32, buf, read); + } while ((err == MZ_OK) && (read > 0)); + + mz_stream_os_close(stream); + } + + *result_crc = crc32; + + mz_stream_os_delete(&stream); + + return err; +} + +/***************************************************************************/ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_os.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_os.h new file mode 100644 index 0000000000000000000000000000000000000000..b3e2a58c1966b94f64257f86409b1edf12516ca5 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_os.h @@ -0,0 +1,175 @@ +/* mz_os.h -- System functions + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_OS_H +#define MZ_OS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +#if defined(__APPLE__) +# define MZ_VERSION_MADEBY_HOST_SYSTEM (MZ_HOST_SYSTEM_OSX_DARWIN) +#elif defined(__riscos__) +# define MZ_VERSION_MADEBY_HOST_SYSTEM (MZ_HOST_SYSTEM_RISCOS) +#elif defined(_WIN32) +# define MZ_VERSION_MADEBY_HOST_SYSTEM (MZ_HOST_SYSTEM_WINDOWS_NTFS) +#else +# define MZ_VERSION_MADEBY_HOST_SYSTEM (MZ_HOST_SYSTEM_UNIX) +#endif + +#if defined(HAVE_LZMA) || defined(HAVE_LIBCOMP) +# define MZ_VERSION_MADEBY_ZIP_VERSION (63) +#elif defined(HAVE_WZAES) +# define MZ_VERSION_MADEBY_ZIP_VERSION (51) +#elif defined(HAVE_BZIP2) +# define MZ_VERSION_MADEBY_ZIP_VERSION (46) +#else +# define MZ_VERSION_MADEBY_ZIP_VERSION (45) +#endif + +#define MZ_VERSION_MADEBY ((MZ_VERSION_MADEBY_HOST_SYSTEM << 8) | \ + (MZ_VERSION_MADEBY_ZIP_VERSION)) + +#define MZ_PATH_SLASH_UNIX ('/') +#if defined(_WIN32) +# define MZ_PATH_SLASH_PLATFORM ('\\') +#else +# define MZ_PATH_SLASH_PLATFORM (MZ_PATH_SLASH_UNIX) +#endif + +/***************************************************************************/ + +#if defined(_WIN32) +struct dirent { + char d_name[256]; +}; +typedef void* DIR; +#else +#include +#endif + +/***************************************************************************/ +/* Shared functions */ + +int32_t mz_path_combine(char *path, const char *join, int32_t max_path); +/* Combines two paths */ + +int32_t mz_path_append_slash(char *path, int32_t max_path, char slash); +/* Appends a path slash on to the end of the path */ + +int32_t mz_path_remove_slash(char *path); +/* Removes a path slash from the end of the path */ + +int32_t mz_path_has_slash(const char *path); +/* Returns whether or not the path ends with slash */ + +int32_t mz_path_convert_slashes(char *path, char slash); +/* Converts the slashes in a path */ + +int32_t mz_path_compare_wc(const char *path, const char *wildcard, uint8_t ignore_case); +/* Compare two paths with wildcard */ + +int32_t mz_path_resolve(const char *path, char *target, int32_t max_target); +/* Resolves path */ + +int32_t mz_path_remove_filename(char *path); +/* Remove the filename from a path */ + +int32_t mz_path_remove_extension(char *path); +/* Remove the extension from a path */ + +int32_t mz_path_get_filename(const char *path, const char **filename); +/* Get the filename from a path */ + +int32_t mz_dir_make(const char *path); +/* Creates a directory recursively */ + +int32_t mz_file_get_crc(const char *path, uint32_t *result_crc); +/* Gets the crc32 hash of a file */ + +/***************************************************************************/ +/* Platform specific functions */ + +wchar_t *mz_os_unicode_string_create(const char *string, int32_t encoding); +/* Create unicode string from a utf8 string */ + +void mz_os_unicode_string_delete(wchar_t **string); +/* Delete a unicode string that was created */ + +uint8_t *mz_os_utf8_string_create(const char *string, int32_t encoding); +/* Create a utf8 string from a string with another encoding */ + +void mz_os_utf8_string_delete(uint8_t **string); +/* Delete a utf8 string that was created */ + +int32_t mz_os_rand(uint8_t *buf, int32_t size); +/* Random number generator (not cryptographically secure) */ + +int32_t mz_os_rename(const char *source_path, const char *target_path); +/* Rename a file */ + +int32_t mz_os_unlink(const char *path); +/* Delete an existing file */ + +int32_t mz_os_file_exists(const char *path); +/* Check to see if a file exists */ + +int64_t mz_os_get_file_size(const char *path); +/* Gets the length of a file */ + +int32_t mz_os_get_file_date(const char *path, time_t *modified_date, time_t *accessed_date, time_t *creation_date); +/* Gets a file's modified, access, and creation dates if supported */ + +int32_t mz_os_set_file_date(const char *path, time_t modified_date, time_t accessed_date, time_t creation_date); +/* Sets a file's modified, access, and creation dates if supported */ + +int32_t mz_os_get_file_attribs(const char *path, uint32_t *attributes); +/* Gets a file's attributes */ + +int32_t mz_os_set_file_attribs(const char *path, uint32_t attributes); +/* Sets a file's attributes */ + +int32_t mz_os_make_dir(const char *path); +/* Recursively creates a directory */ + +DIR* mz_os_open_dir(const char *path); +/* Opens a directory for listing */ +struct +dirent* mz_os_read_dir(DIR *dir); +/* Reads a directory listing entry */ + +int32_t mz_os_close_dir(DIR *dir); +/* Closes a directory that has been opened for listing */ + +int32_t mz_os_is_dir(const char *path); +/* Checks to see if path is a directory */ + +int32_t mz_os_is_symlink(const char *path); +/* Checks to see if path is a symbolic link */ + +int32_t mz_os_make_symlink(const char *path, const char *target_path); +/* Creates a symbolic link pointing to a target */ + +int32_t mz_os_read_symlink(const char *path, char *target_path, int32_t max_target_path); +/* Gets the target path for a symbolic link */ + +uint64_t mz_os_ms_time(void); +/* Gets the time in milliseconds */ + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_os_posix.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_os_posix.c new file mode 100644 index 0000000000000000000000000000000000000000..576943d16206ae7e516f5e13be09e9101240009e --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_os_posix.c @@ -0,0 +1,367 @@ +/* mz_os_posix.c -- System functions for posix + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#include "mz.h" +#include "mz_strm.h" +#include "mz_os.h" + +#include /* rename */ +#include +#if defined(HAVE_ICONV) +#include +#endif + +#include +#include + +#ifndef _WIN32 +# include +# include +#endif +#if defined(__APPLE__) +# include +# include +#endif + +#if defined(HAVE_GETRANDOM) +# include +#endif +#if defined(HAVE_LIBBSD) +# include +# ifndef __u_char_defined + typedef unsigned char u_char; +# endif +# include /* arc4random_buf */ +#endif + +/***************************************************************************/ + +#if defined(HAVE_ICONV) +uint8_t *mz_os_utf8_string_create(const char *string, int32_t encoding) { + iconv_t cd; + const char *from_encoding = NULL; + size_t result = 0; + size_t string_length = 0; + size_t string_utf8_size = 0; + uint8_t *string_utf8 = NULL; + uint8_t *string_utf8_ptr = NULL; + + if (string == NULL) + return NULL; + + if (encoding == MZ_ENCODING_CODEPAGE_437) + from_encoding = "CP437"; + else if (encoding == MZ_ENCODING_CODEPAGE_932) + from_encoding = "CP932"; + else if (encoding == MZ_ENCODING_CODEPAGE_936) + from_encoding = "CP936"; + else if (encoding == MZ_ENCODING_CODEPAGE_950) + from_encoding = "CP950"; + else if (encoding == MZ_ENCODING_UTF8) + from_encoding = "UTF-8"; + else + return NULL; + + cd = iconv_open("UTF-8", from_encoding); + if (cd == (iconv_t)-1) + return NULL; + + string_length = strlen(string); + string_utf8_size = string_length * 2; + string_utf8 = (uint8_t *)MZ_ALLOC((int32_t)(string_utf8_size + 1)); + string_utf8_ptr = string_utf8; + + if (string_utf8) { + memset(string_utf8, 0, string_utf8_size + 1); + + result = iconv(cd, (char **)&string, &string_length, + (char **)&string_utf8_ptr, &string_utf8_size); + } + + iconv_close(cd); + + if (result == (size_t)-1) { + MZ_FREE(string_utf8); + string_utf8 = NULL; + } + + return string_utf8; +} +#else +uint8_t *mz_os_utf8_string_create(const char *string, int32_t encoding) { + size_t string_length = 0; + uint8_t *string_copy = NULL; + + string_length = strlen(string); + string_copy = (uint8_t *)MZ_ALLOC((int32_t)(string_length + 1)); + strncpy((char *)string_copy, string, string_length); + string_copy[string_length] = 0; + + return string_copy; +} +#endif + +void mz_os_utf8_string_delete(uint8_t **string) { + if (string != NULL) { + MZ_FREE(*string); + *string = NULL; + } +} + +/***************************************************************************/ + +#if defined(HAVE_ARC4RANDOM_BUF) +int32_t mz_os_rand(uint8_t *buf, int32_t size) { + if (size < 0) + return 0; + arc4random_buf(buf, (uint32_t)size); + return size; +} +#elif defined(HAVE_ARC4RANDOM) +int32_t mz_os_rand(uint8_t *buf, int32_t size) { + int32_t left = size; + for (; left > 2; left -= 3, buf += 3) { + uint32_t val = arc4random(); + + buf[0] = (val) & 0xFF; + buf[1] = (val >> 8) & 0xFF; + buf[2] = (val >> 16) & 0xFF; + } + for (; left > 0; left--, buf++) { + *buf = arc4random() & 0xFF; + } + return size - left; +} +#elif defined(HAVE_GETRANDOM) +int32_t mz_os_rand(uint8_t *buf, int32_t size) { + int32_t left = size; + int32_t written = 0; + + while (left > 0) { + written = getrandom(buf, left, 0); + if (written < 0) + return MZ_INTERNAL_ERROR; + + buf += written; + left -= written; + } + return size - left; +} +#else +int32_t mz_os_rand(uint8_t *buf, int32_t size) { + static unsigned calls = 0; + int32_t i = 0; + + /* Ensure different random header each time */ + if (++calls == 1) { + #define PI_SEED 3141592654UL + srand((unsigned)(time(NULL) ^ PI_SEED)); + } + + while (i < size) + buf[i++] = (rand() >> 7) & 0xff; + + return size; +} +#endif + +int32_t mz_os_rename(const char *source_path, const char *target_path) { + if (rename(source_path, target_path) == -1) + return MZ_EXIST_ERROR; + + return MZ_OK; +} + +int32_t mz_os_unlink(const char *path) { + if (unlink(path) == -1) + return MZ_EXIST_ERROR; + + return MZ_OK; +} + +int32_t mz_os_file_exists(const char *path) { + struct stat path_stat; + + memset(&path_stat, 0, sizeof(path_stat)); + if (stat(path, &path_stat) == 0) + return MZ_OK; + return MZ_EXIST_ERROR; +} + +int64_t mz_os_get_file_size(const char *path) { + struct stat path_stat; + + memset(&path_stat, 0, sizeof(path_stat)); + if (stat(path, &path_stat) == 0) { + /* Stat returns size taken up by directory entry, so return 0 */ + if (S_ISDIR(path_stat.st_mode)) + return 0; + + return path_stat.st_size; + } + + return 0; +} + +int32_t mz_os_get_file_date(const char *path, time_t *modified_date, time_t *accessed_date, time_t *creation_date) { + struct stat path_stat; + char *name = NULL; + size_t len = 0; + int32_t err = MZ_INTERNAL_ERROR; + + memset(&path_stat, 0, sizeof(path_stat)); + + if (strcmp(path, "-") != 0) { + /* Not all systems allow stat'ing a file with / appended */ + len = strlen(path); + name = (char *)malloc(len + 1); + strncpy(name, path, len + 1); + mz_path_remove_slash(name); + + if (stat(name, &path_stat) == 0) { + if (modified_date != NULL) + *modified_date = path_stat.st_mtime; + if (accessed_date != NULL) + *accessed_date = path_stat.st_atime; + /* Creation date not supported */ + if (creation_date != NULL) + *creation_date = 0; + + err = MZ_OK; + } + + free(name); + } + + return err; +} + +int32_t mz_os_set_file_date(const char *path, time_t modified_date, time_t accessed_date, time_t creation_date) { + struct utimbuf ut; + + ut.actime = accessed_date; + ut.modtime = modified_date; + + /* Creation date not supported */ + MZ_UNUSED(creation_date); + + if (utime(path, &ut) != 0) + return MZ_INTERNAL_ERROR; + + return MZ_OK; +} + +int32_t mz_os_get_file_attribs(const char *path, uint32_t *attributes) { + struct stat path_stat; + int32_t err = MZ_OK; + + memset(&path_stat, 0, sizeof(path_stat)); + if (lstat(path, &path_stat) == -1) + err = MZ_INTERNAL_ERROR; + *attributes = path_stat.st_mode; + return err; +} + +int32_t mz_os_set_file_attribs(const char *path, uint32_t attributes) { + int32_t err = MZ_OK; + + if (chmod(path, (mode_t)attributes) == -1) + err = MZ_INTERNAL_ERROR; + + return err; +} + +int32_t mz_os_make_dir(const char *path) { + int32_t err = 0; + + err = mkdir(path, 0755); + + if (err != 0 && errno != EEXIST) + return MZ_INTERNAL_ERROR; + + return MZ_OK; +} + +DIR* mz_os_open_dir(const char *path) { + return opendir(path); +} + +struct dirent* mz_os_read_dir(DIR *dir) { + if (dir == NULL) + return NULL; + return readdir(dir); +} + +int32_t mz_os_close_dir(DIR *dir) { + if (dir == NULL) + return MZ_PARAM_ERROR; + if (closedir(dir) == -1) + return MZ_INTERNAL_ERROR; + return MZ_OK; +} + +int32_t mz_os_is_dir(const char *path) { + struct stat path_stat; + + memset(&path_stat, 0, sizeof(path_stat)); + stat(path, &path_stat); + if (S_ISDIR(path_stat.st_mode)) + return MZ_OK; + + return MZ_EXIST_ERROR; +} + +int32_t mz_os_is_symlink(const char *path) { + struct stat path_stat; + + memset(&path_stat, 0, sizeof(path_stat)); + lstat(path, &path_stat); + if (S_ISLNK(path_stat.st_mode)) + return MZ_OK; + + return MZ_EXIST_ERROR; +} + +int32_t mz_os_make_symlink(const char *path, const char *target_path) { + if (symlink(target_path, path) != 0) + return MZ_INTERNAL_ERROR; + return MZ_OK; +} + +int32_t mz_os_read_symlink(const char *path, char *target_path, int32_t max_target_path) { + size_t length = 0; + + length = (size_t)readlink(path, target_path, max_target_path - 1); + if (length == (size_t)-1) + return MZ_EXIST_ERROR; + + target_path[length] = 0; + return MZ_OK; +} + +uint64_t mz_os_ms_time(void) { + struct timespec ts; + +#if defined(__APPLE__) + clock_serv_t cclock; + mach_timespec_t mts; + + host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); + clock_get_time(cclock, &mts); + mach_port_deallocate(mach_task_self(), cclock); + + ts.tv_sec = mts.tv_sec; + ts.tv_nsec = mts.tv_nsec; +#else + clock_gettime(CLOCK_MONOTONIC, &ts); +#endif + + return ((uint64_t)ts.tv_sec * 1000) + ((uint64_t)ts.tv_nsec / 1000000); +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm.c new file mode 100644 index 0000000000000000000000000000000000000000..da7d5872d61ad64fb45c18b47b47fea1983bc753 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm.c @@ -0,0 +1,560 @@ +/* mz_strm.c -- Stream interface + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#include "mz.h" +#include "mz_strm.h" + +/***************************************************************************/ + +#define MZ_STREAM_FIND_SIZE (1024) + +/***************************************************************************/ + +int32_t mz_stream_open(void *stream, const char *path, int32_t mode) { + mz_stream *strm = (mz_stream *)stream; + if (strm == NULL || strm->vtbl == NULL || strm->vtbl->open == NULL) + return MZ_STREAM_ERROR; + return strm->vtbl->open(strm, path, mode); +} + +int32_t mz_stream_is_open(void *stream) { + mz_stream *strm = (mz_stream *)stream; + if (strm == NULL || strm->vtbl == NULL || strm->vtbl->is_open == NULL) + return MZ_STREAM_ERROR; + return strm->vtbl->is_open(strm); +} + +int32_t mz_stream_read(void *stream, void *buf, int32_t size) { + mz_stream *strm = (mz_stream *)stream; + if (strm == NULL || strm->vtbl == NULL || strm->vtbl->read == NULL) + return MZ_PARAM_ERROR; + if (mz_stream_is_open(stream) != MZ_OK) + return MZ_STREAM_ERROR; + return strm->vtbl->read(strm, buf, size); +} + +static int32_t mz_stream_read_value(void *stream, uint64_t *value, int32_t len) { + uint8_t buf[8]; + int32_t n = 0; + int32_t i = 0; + + *value = 0; + if (mz_stream_read(stream, buf, len) == len) { + for (n = 0; n < len; n += 1, i += 8) + *value += ((uint64_t)buf[n]) << i; + } else if (mz_stream_error(stream)) + return MZ_STREAM_ERROR; + else + return MZ_END_OF_STREAM; + + return MZ_OK; +} + +int32_t mz_stream_read_uint8(void *stream, uint8_t *value) { + int32_t err = MZ_OK; + uint64_t value64 = 0; + + *value = 0; + err = mz_stream_read_value(stream, &value64, sizeof(uint8_t)); + if (err == MZ_OK) + *value = (uint8_t)value64; + return err; +} + +int32_t mz_stream_read_uint16(void *stream, uint16_t *value) { + int32_t err = MZ_OK; + uint64_t value64 = 0; + + *value = 0; + err = mz_stream_read_value(stream, &value64, sizeof(uint16_t)); + if (err == MZ_OK) + *value = (uint16_t)value64; + return err; +} + +int32_t mz_stream_read_uint32(void *stream, uint32_t *value) { + int32_t err = MZ_OK; + uint64_t value64 = 0; + + *value = 0; + err = mz_stream_read_value(stream, &value64, sizeof(uint32_t)); + if (err == MZ_OK) + *value = (uint32_t)value64; + return err; +} + +int32_t mz_stream_read_int64(void *stream, int64_t *value) { + return mz_stream_read_value(stream, (uint64_t *)value, sizeof(uint64_t)); +} + +int32_t mz_stream_read_uint64(void *stream, uint64_t *value) { + return mz_stream_read_value(stream, value, sizeof(uint64_t)); +} + +int32_t mz_stream_write(void *stream, const void *buf, int32_t size) { + mz_stream *strm = (mz_stream *)stream; + if (size == 0) + return size; + if (strm == NULL || strm->vtbl == NULL || strm->vtbl->write == NULL) + return MZ_PARAM_ERROR; + if (mz_stream_is_open(stream) != MZ_OK) + return MZ_STREAM_ERROR; + return strm->vtbl->write(strm, buf, size); +} + +static int32_t mz_stream_write_value(void *stream, uint64_t value, int32_t len) { + uint8_t buf[8]; + int32_t n = 0; + + for (n = 0; n < len; n += 1) { + buf[n] = (uint8_t)(value & 0xff); + value >>= 8; + } + + if (value != 0) { + /* Data overflow - hack for ZIP64 (X Roche) */ + for (n = 0; n < len; n += 1) + buf[n] = 0xff; + } + + if (mz_stream_write(stream, buf, len) != len) + return MZ_STREAM_ERROR; + + return MZ_OK; +} + +int32_t mz_stream_write_uint8(void *stream, uint8_t value) { + return mz_stream_write_value(stream, value, sizeof(uint8_t)); +} + +int32_t mz_stream_write_uint16(void *stream, uint16_t value) { + return mz_stream_write_value(stream, value, sizeof(uint16_t)); +} + +int32_t mz_stream_write_uint32(void *stream, uint32_t value) { + return mz_stream_write_value(stream, value, sizeof(uint32_t)); +} + +int32_t mz_stream_write_int64(void *stream, int64_t value) { + return mz_stream_write_value(stream, (uint64_t)value, sizeof(uint64_t)); +} + +int32_t mz_stream_write_uint64(void *stream, uint64_t value) { + return mz_stream_write_value(stream, value, sizeof(uint64_t)); +} + +int32_t mz_stream_copy(void *target, void *source, int32_t len) { + return mz_stream_copy_stream(target, NULL, source, NULL, len); +} + +int32_t mz_stream_copy_to_end(void *target, void *source) { + return mz_stream_copy_stream_to_end(target, NULL, source, NULL); +} + +int32_t mz_stream_copy_stream(void *target, mz_stream_write_cb write_cb, void *source, + mz_stream_read_cb read_cb, int32_t len) { + uint8_t buf[16384]; + int32_t bytes_to_copy = 0; + int32_t read = 0; + int32_t written = 0; + + if (write_cb == NULL) + write_cb = mz_stream_write; + if (read_cb == NULL) + read_cb = mz_stream_read; + + while (len > 0) { + bytes_to_copy = len; + if (bytes_to_copy > (int32_t)sizeof(buf)) + bytes_to_copy = sizeof(buf); + read = read_cb(source, buf, bytes_to_copy); + if (read <= 0) + return MZ_STREAM_ERROR; + written = write_cb(target, buf, read); + if (written != read) + return MZ_STREAM_ERROR; + len -= read; + } + + return MZ_OK; +} + +int32_t mz_stream_copy_stream_to_end(void *target, mz_stream_write_cb write_cb, void *source, + mz_stream_read_cb read_cb) { + uint8_t buf[16384]; + int32_t read = 0; + int32_t written = 0; + + if (write_cb == NULL) + write_cb = mz_stream_write; + if (read_cb == NULL) + read_cb = mz_stream_read; + + read = read_cb(source, buf, sizeof(buf)); + while (read > 0) { + written = write_cb(target, buf, read); + if (written != read) + return MZ_STREAM_ERROR; + read = read_cb(source, buf, sizeof(buf)); + } + + if (read < 0) + return MZ_STREAM_ERROR; + + return MZ_OK; +} + +int64_t mz_stream_tell(void *stream) { + mz_stream *strm = (mz_stream *)stream; + if (strm == NULL || strm->vtbl == NULL || strm->vtbl->tell == NULL) + return MZ_PARAM_ERROR; + if (mz_stream_is_open(stream) != MZ_OK) + return MZ_STREAM_ERROR; + return strm->vtbl->tell(strm); +} + +int32_t mz_stream_seek(void *stream, int64_t offset, int32_t origin) { + mz_stream *strm = (mz_stream *)stream; + if (strm == NULL || strm->vtbl == NULL || strm->vtbl->seek == NULL) + return MZ_PARAM_ERROR; + if (mz_stream_is_open(stream) != MZ_OK) + return MZ_STREAM_ERROR; + if (origin == MZ_SEEK_SET && offset < 0) + return MZ_SEEK_ERROR; + return strm->vtbl->seek(strm, offset, origin); +} + +int32_t mz_stream_find(void *stream, const void *find, int32_t find_size, int64_t max_seek, int64_t *position) { + uint8_t buf[MZ_STREAM_FIND_SIZE]; + int32_t buf_pos = 0; + int32_t read_size = sizeof(buf); + int32_t read = 0; + int64_t read_pos = 0; + int64_t start_pos = 0; + int64_t disk_pos = 0; + int32_t i = 0; + uint8_t first = 1; + int32_t err = MZ_OK; + + if (stream == NULL || find == NULL || position == NULL) + return MZ_PARAM_ERROR; + if (find_size < 0 || find_size >= (int32_t)sizeof(buf)) + return MZ_PARAM_ERROR; + + *position = -1; + + start_pos = mz_stream_tell(stream); + + while (read_pos < max_seek) { + if (read_size > (int32_t)(max_seek - read_pos - buf_pos) && (max_seek - read_pos - buf_pos) < (int64_t)sizeof(buf)) + read_size = (int32_t)(max_seek - read_pos - buf_pos); + + read = mz_stream_read(stream, buf + buf_pos, read_size); + if ((read <= 0) || (read + buf_pos < find_size)) + break; + + for (i = 0; i <= read + buf_pos - find_size; i += 1) { + if (memcmp(&buf[i], find, find_size) != 0) + continue; + + disk_pos = mz_stream_tell(stream); + + /* Seek to position on disk where the data was found */ + err = mz_stream_seek(stream, disk_pos - ((int64_t)read + buf_pos - i), MZ_SEEK_SET); + if (err != MZ_OK) + return MZ_EXIST_ERROR; + + *position = start_pos + read_pos + i; + return MZ_OK; + } + + if (first) { + read -= find_size; + read_size -= find_size; + buf_pos = find_size; + first = 0; + } + + memmove(buf, buf + read, find_size); + read_pos += read; + } + + return MZ_EXIST_ERROR; +} + +int32_t mz_stream_find_reverse(void *stream, const void *find, int32_t find_size, int64_t max_seek, int64_t *position) { + uint8_t buf[MZ_STREAM_FIND_SIZE]; + int32_t buf_pos = 0; + int32_t read_size = MZ_STREAM_FIND_SIZE; + int64_t read_pos = 0; + int32_t read = 0; + int64_t start_pos = 0; + int64_t disk_pos = 0; + uint8_t first = 1; + int32_t i = 0; + int32_t err = MZ_OK; + + if (stream == NULL || find == NULL || position == NULL) + return MZ_PARAM_ERROR; + if (find_size < 0 || find_size >= (int32_t)sizeof(buf)) + return MZ_PARAM_ERROR; + + *position = -1; + + start_pos = mz_stream_tell(stream); + + while (read_pos < max_seek) { + if (read_size > (int32_t)(max_seek - read_pos) && (max_seek - read_pos) < (int64_t)sizeof(buf)) + read_size = (int32_t)(max_seek - read_pos); + + if (mz_stream_seek(stream, start_pos - (read_pos + read_size), MZ_SEEK_SET) != MZ_OK) + break; + read = mz_stream_read(stream, buf, read_size); + if ((read <= 0) || (read + buf_pos < find_size)) + break; + if (read + buf_pos < MZ_STREAM_FIND_SIZE) + memmove(buf + MZ_STREAM_FIND_SIZE - (read + buf_pos), buf, read); + + for (i = find_size; i <= (read + buf_pos); i += 1) { + if (memcmp(&buf[MZ_STREAM_FIND_SIZE - i], find, find_size) != 0) + continue; + + disk_pos = mz_stream_tell(stream); + + /* Seek to position on disk where the data was found */ + err = mz_stream_seek(stream, disk_pos + buf_pos - i, MZ_SEEK_SET); + if (err != MZ_OK) + return MZ_EXIST_ERROR; + + *position = start_pos - (read_pos - buf_pos + i); + return MZ_OK; + } + + if (first) { + read -= find_size; + read_size -= find_size; + buf_pos = find_size; + first = 0; + } + + if (read == 0) + break; + + memmove(buf + read_size, buf, find_size); + read_pos += read; + } + + return MZ_EXIST_ERROR; +} + +int32_t mz_stream_close(void *stream) { + mz_stream *strm = (mz_stream *)stream; + if (strm == NULL || strm->vtbl == NULL || strm->vtbl->close == NULL) + return MZ_PARAM_ERROR; + if (mz_stream_is_open(stream) != MZ_OK) + return MZ_STREAM_ERROR; + return strm->vtbl->close(strm); +} + +int32_t mz_stream_error(void *stream) { + mz_stream *strm = (mz_stream *)stream; + if (strm == NULL || strm->vtbl == NULL || strm->vtbl->error == NULL) + return MZ_PARAM_ERROR; + return strm->vtbl->error(strm); +} + +int32_t mz_stream_set_base(void *stream, void *base) { + mz_stream *strm = (mz_stream *)stream; + strm->base = (mz_stream *)base; + return MZ_OK; +} + +void* mz_stream_get_interface(void *stream) { + mz_stream *strm = (mz_stream *)stream; + if (strm == NULL || strm->vtbl == NULL) + return NULL; + return (void *)strm->vtbl; +} + +int32_t mz_stream_get_prop_int64(void *stream, int32_t prop, int64_t *value) { + mz_stream *strm = (mz_stream *)stream; + if (strm == NULL || strm->vtbl == NULL || strm->vtbl->get_prop_int64 == NULL) + return MZ_PARAM_ERROR; + return strm->vtbl->get_prop_int64(stream, prop, value); +} + +int32_t mz_stream_set_prop_int64(void *stream, int32_t prop, int64_t value) { + mz_stream *strm = (mz_stream *)stream; + if (strm == NULL || strm->vtbl == NULL || strm->vtbl->set_prop_int64 == NULL) + return MZ_PARAM_ERROR; + return strm->vtbl->set_prop_int64(stream, prop, value); +} + +void *mz_stream_create(void **stream, mz_stream_vtbl *vtbl) { + if (stream == NULL) + return NULL; + if (vtbl == NULL || vtbl->create == NULL) + return NULL; + return vtbl->create(stream); +} + +void mz_stream_delete(void **stream) { + mz_stream *strm = NULL; + if (stream == NULL) + return; + strm = (mz_stream *)*stream; + if (strm != NULL && strm->vtbl != NULL && strm->vtbl->destroy != NULL) + strm->vtbl->destroy(stream); + *stream = NULL; +} + +/***************************************************************************/ + +typedef struct mz_stream_raw_s { + mz_stream stream; + int64_t total_in; + int64_t total_out; + int64_t max_total_in; +} mz_stream_raw; + +/***************************************************************************/ + +int32_t mz_stream_raw_open(void *stream, const char *path, int32_t mode) { + MZ_UNUSED(stream); + MZ_UNUSED(path); + MZ_UNUSED(mode); + + return MZ_OK; +} + +int32_t mz_stream_raw_is_open(void *stream) { + mz_stream_raw *raw = (mz_stream_raw *)stream; + return mz_stream_is_open(raw->stream.base); +} + +int32_t mz_stream_raw_read(void *stream, void *buf, int32_t size) { + mz_stream_raw *raw = (mz_stream_raw *)stream; + int32_t bytes_to_read = size; + int32_t read = 0; + + if (raw->max_total_in > 0) { + if ((int64_t)bytes_to_read > (raw->max_total_in - raw->total_in)) + bytes_to_read = (int32_t)(raw->max_total_in - raw->total_in); + } + + read = mz_stream_read(raw->stream.base, buf, bytes_to_read); + + if (read > 0) { + raw->total_in += read; + raw->total_out += read; + } + + return read; +} + +int32_t mz_stream_raw_write(void *stream, const void *buf, int32_t size) { + mz_stream_raw *raw = (mz_stream_raw *)stream; + int32_t written = 0; + + written = mz_stream_write(raw->stream.base, buf, size); + + if (written > 0) { + raw->total_out += written; + raw->total_in += written; + } + + return written; +} + +int64_t mz_stream_raw_tell(void *stream) { + mz_stream_raw *raw = (mz_stream_raw *)stream; + return mz_stream_tell(raw->stream.base); +} + +int32_t mz_stream_raw_seek(void *stream, int64_t offset, int32_t origin) { + mz_stream_raw *raw = (mz_stream_raw *)stream; + return mz_stream_seek(raw->stream.base, offset, origin); +} + +int32_t mz_stream_raw_close(void *stream) { + MZ_UNUSED(stream); + return MZ_OK; +} + +int32_t mz_stream_raw_error(void *stream) { + mz_stream_raw *raw = (mz_stream_raw *)stream; + return mz_stream_error(raw->stream.base); +} + +int32_t mz_stream_raw_get_prop_int64(void *stream, int32_t prop, int64_t *value) { + mz_stream_raw *raw = (mz_stream_raw *)stream; + switch (prop) { + case MZ_STREAM_PROP_TOTAL_IN: + *value = raw->total_in; + return MZ_OK; + case MZ_STREAM_PROP_TOTAL_OUT: + *value = raw->total_out; + return MZ_OK; + } + return MZ_EXIST_ERROR; +} + +int32_t mz_stream_raw_set_prop_int64(void *stream, int32_t prop, int64_t value) { + mz_stream_raw *raw = (mz_stream_raw *)stream; + switch (prop) { + case MZ_STREAM_PROP_TOTAL_IN_MAX: + raw->max_total_in = value; + return MZ_OK; + } + return MZ_EXIST_ERROR; +} + +/***************************************************************************/ + +static mz_stream_vtbl mz_stream_raw_vtbl = { + mz_stream_raw_open, + mz_stream_raw_is_open, + mz_stream_raw_read, + mz_stream_raw_write, + mz_stream_raw_tell, + mz_stream_raw_seek, + mz_stream_raw_close, + mz_stream_raw_error, + mz_stream_raw_create, + mz_stream_raw_delete, + mz_stream_raw_get_prop_int64, + mz_stream_raw_set_prop_int64 +}; + +/***************************************************************************/ + +void *mz_stream_raw_create(void **stream) { + mz_stream_raw *raw = NULL; + + raw = (mz_stream_raw *)MZ_ALLOC(sizeof(mz_stream_raw)); + if (raw != NULL) { + memset(raw, 0, sizeof(mz_stream_raw)); + raw->stream.vtbl = &mz_stream_raw_vtbl; + } + if (stream != NULL) + *stream = raw; + + return raw; +} + +void mz_stream_raw_delete(void **stream) { + mz_stream_raw *raw = NULL; + if (stream == NULL) + return; + raw = (mz_stream_raw *)*stream; + if (raw != NULL) + MZ_FREE(raw); + *stream = NULL; +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm.h new file mode 100644 index 0000000000000000000000000000000000000000..8b0027cf50387e9fc4bae3cd85546d9520cf0f9e --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm.h @@ -0,0 +1,132 @@ +/* mz_strm.h -- Stream interface + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_STREAM_H +#define MZ_STREAM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +#define MZ_STREAM_PROP_TOTAL_IN (1) +#define MZ_STREAM_PROP_TOTAL_IN_MAX (2) +#define MZ_STREAM_PROP_TOTAL_OUT (3) +#define MZ_STREAM_PROP_TOTAL_OUT_MAX (4) +#define MZ_STREAM_PROP_HEADER_SIZE (5) +#define MZ_STREAM_PROP_FOOTER_SIZE (6) +#define MZ_STREAM_PROP_DISK_SIZE (7) +#define MZ_STREAM_PROP_DISK_NUMBER (8) +#define MZ_STREAM_PROP_COMPRESS_LEVEL (9) +#define MZ_STREAM_PROP_COMPRESS_METHOD (10) +#define MZ_STREAM_PROP_COMPRESS_WINDOW (11) + +/***************************************************************************/ + +typedef int32_t (*mz_stream_open_cb) (void *stream, const char *path, int32_t mode); +typedef int32_t (*mz_stream_is_open_cb) (void *stream); +typedef int32_t (*mz_stream_read_cb) (void *stream, void *buf, int32_t size); +typedef int32_t (*mz_stream_write_cb) (void *stream, const void *buf, int32_t size); +typedef int64_t (*mz_stream_tell_cb) (void *stream); +typedef int32_t (*mz_stream_seek_cb) (void *stream, int64_t offset, int32_t origin); +typedef int32_t (*mz_stream_close_cb) (void *stream); +typedef int32_t (*mz_stream_error_cb) (void *stream); +typedef void* (*mz_stream_create_cb) (void **stream); +typedef void (*mz_stream_destroy_cb) (void **stream); + +typedef int32_t (*mz_stream_get_prop_int64_cb) (void *stream, int32_t prop, int64_t *value); +typedef int32_t (*mz_stream_set_prop_int64_cb) (void *stream, int32_t prop, int64_t value); + +typedef int32_t (*mz_stream_find_cb) (void *stream, const void *find, int32_t find_size, + int64_t max_seek, int64_t *position); + +/***************************************************************************/ + +typedef struct mz_stream_vtbl_s { + mz_stream_open_cb open; + mz_stream_is_open_cb is_open; + mz_stream_read_cb read; + mz_stream_write_cb write; + mz_stream_tell_cb tell; + mz_stream_seek_cb seek; + mz_stream_close_cb close; + mz_stream_error_cb error; + mz_stream_create_cb create; + mz_stream_destroy_cb destroy; + + mz_stream_get_prop_int64_cb get_prop_int64; + mz_stream_set_prop_int64_cb set_prop_int64; +} mz_stream_vtbl; + +typedef struct mz_stream_s { + mz_stream_vtbl *vtbl; + struct mz_stream_s *base; +} mz_stream; + +/***************************************************************************/ + +int32_t mz_stream_open(void *stream, const char *path, int32_t mode); +int32_t mz_stream_is_open(void *stream); +int32_t mz_stream_read(void *stream, void *buf, int32_t size); +int32_t mz_stream_read_uint8(void *stream, uint8_t *value); +int32_t mz_stream_read_uint16(void *stream, uint16_t *value); +int32_t mz_stream_read_uint32(void *stream, uint32_t *value); +int32_t mz_stream_read_int64(void *stream, int64_t *value); +int32_t mz_stream_read_uint64(void *stream, uint64_t *value); +int32_t mz_stream_write(void *stream, const void *buf, int32_t size); +int32_t mz_stream_write_uint8(void *stream, uint8_t value); +int32_t mz_stream_write_uint16(void *stream, uint16_t value); +int32_t mz_stream_write_uint32(void *stream, uint32_t value); +int32_t mz_stream_write_int64(void *stream, int64_t value); +int32_t mz_stream_write_uint64(void *stream, uint64_t value); +int32_t mz_stream_copy(void *target, void *source, int32_t len); +int32_t mz_stream_copy_to_end(void *target, void *source); +int32_t mz_stream_copy_stream(void *target, mz_stream_write_cb write_cb, void *source, mz_stream_read_cb read_cb, int32_t len); +int32_t mz_stream_copy_stream_to_end(void *target, mz_stream_write_cb write_cb, void *source, mz_stream_read_cb read_cb); +int64_t mz_stream_tell(void *stream); +int32_t mz_stream_seek(void *stream, int64_t offset, int32_t origin); +int32_t mz_stream_find(void *stream, const void *find, int32_t find_size, int64_t max_seek, int64_t *position); +int32_t mz_stream_find_reverse(void *stream, const void *find, int32_t find_size, int64_t max_seek, int64_t *position); +int32_t mz_stream_close(void *stream); +int32_t mz_stream_error(void *stream); + +int32_t mz_stream_set_base(void *stream, void *base); +void* mz_stream_get_interface(void *stream); +int32_t mz_stream_get_prop_int64(void *stream, int32_t prop, int64_t *value); +int32_t mz_stream_set_prop_int64(void *stream, int32_t prop, int64_t value); + +void* mz_stream_create(void **stream, mz_stream_vtbl *vtbl); +void mz_stream_delete(void **stream); + +/***************************************************************************/ + +int32_t mz_stream_raw_open(void *stream, const char *filename, int32_t mode); +int32_t mz_stream_raw_is_open(void *stream); +int32_t mz_stream_raw_read(void *stream, void *buf, int32_t size); +int32_t mz_stream_raw_write(void *stream, const void *buf, int32_t size); +int64_t mz_stream_raw_tell(void *stream); +int32_t mz_stream_raw_seek(void *stream, int64_t offset, int32_t origin); +int32_t mz_stream_raw_close(void *stream); +int32_t mz_stream_raw_error(void *stream); + +int32_t mz_stream_raw_get_prop_int64(void *stream, int32_t prop, int64_t *value); +int32_t mz_stream_raw_set_prop_int64(void *stream, int32_t prop, int64_t value); + +void* mz_stream_raw_create(void **stream); +void mz_stream_raw_delete(void **stream); + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_buf.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_buf.c new file mode 100644 index 0000000000000000000000000000000000000000..1dfdfdf5fd8c4bef8964a20f49b529375ad39b04 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_buf.c @@ -0,0 +1,385 @@ +/* mz_strm_buf.c -- Stream for buffering reads/writes + part of the minizip-ng project + + This version of ioapi is designed to buffer IO. + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#include "mz.h" +#include "mz_strm.h" +#include "mz_strm_buf.h" + +/***************************************************************************/ + +static mz_stream_vtbl mz_stream_buffered_vtbl = { + mz_stream_buffered_open, + mz_stream_buffered_is_open, + mz_stream_buffered_read, + mz_stream_buffered_write, + mz_stream_buffered_tell, + mz_stream_buffered_seek, + mz_stream_buffered_close, + mz_stream_buffered_error, + mz_stream_buffered_create, + mz_stream_buffered_delete, + NULL, + NULL +}; + +/***************************************************************************/ + +typedef struct mz_stream_buffered_s { + mz_stream stream; + int32_t error; + char readbuf[INT16_MAX]; + int32_t readbuf_len; + int32_t readbuf_pos; + int32_t readbuf_hits; + int32_t readbuf_misses; + char writebuf[INT16_MAX]; + int32_t writebuf_len; + int32_t writebuf_pos; + int32_t writebuf_hits; + int32_t writebuf_misses; + int64_t position; +} mz_stream_buffered; + +/***************************************************************************/ + +#if 0 +# define mz_stream_buffered_print printf +#else +# define mz_stream_buffered_print(fmt,...) +#endif + +/***************************************************************************/ + +static int32_t mz_stream_buffered_reset(void *stream) { + mz_stream_buffered *buffered = (mz_stream_buffered *)stream; + + buffered->readbuf_len = 0; + buffered->readbuf_pos = 0; + buffered->writebuf_len = 0; + buffered->writebuf_pos = 0; + buffered->position = 0; + + return MZ_OK; +} + +int32_t mz_stream_buffered_open(void *stream, const char *path, int32_t mode) { + mz_stream_buffered *buffered = (mz_stream_buffered *)stream; + mz_stream_buffered_print("Buffered - Open (mode %" PRId32 ")\n", mode); + mz_stream_buffered_reset(buffered); + return mz_stream_open(buffered->stream.base, path, mode); +} + +int32_t mz_stream_buffered_is_open(void *stream) { + mz_stream_buffered *buffered = (mz_stream_buffered *)stream; + return mz_stream_is_open(buffered->stream.base); +} + +static int32_t mz_stream_buffered_flush(void *stream, int32_t *written) { + mz_stream_buffered *buffered = (mz_stream_buffered *)stream; + int32_t total_bytes_written = 0; + int32_t bytes_to_write = buffered->writebuf_len; + int32_t bytes_left_to_write = buffered->writebuf_len; + int32_t bytes_written = 0; + + *written = 0; + + while (bytes_left_to_write > 0) { + bytes_written = mz_stream_write(buffered->stream.base, + buffered->writebuf + (bytes_to_write - bytes_left_to_write), bytes_left_to_write); + + if (bytes_written != bytes_left_to_write) + return MZ_WRITE_ERROR; + + buffered->writebuf_misses += 1; + + mz_stream_buffered_print("Buffered - Write flush (%" PRId32 ":%" PRId32 " len %" PRId32 ")\n", + bytes_to_write, bytes_left_to_write, buffered->writebuf_len); + + total_bytes_written += bytes_written; + bytes_left_to_write -= bytes_written; + buffered->position += bytes_written; + } + + buffered->writebuf_len = 0; + buffered->writebuf_pos = 0; + + *written = total_bytes_written; + return MZ_OK; +} + +int32_t mz_stream_buffered_read(void *stream, void *buf, int32_t size) { + mz_stream_buffered *buffered = (mz_stream_buffered *)stream; + int32_t buf_len = 0; + int32_t bytes_to_read = 0; + int32_t bytes_to_copy = 0; + int32_t bytes_left_to_read = size; + int32_t bytes_read = 0; + int32_t bytes_flushed = 0; + + mz_stream_buffered_print("Buffered - Read (size %" PRId32 " pos %" PRId64 ")\n", size, buffered->position); + + if (buffered->writebuf_len > 0) { + int64_t position = buffered->position + buffered->writebuf_pos + + mz_stream_buffered_print("Buffered - Switch from write to read, flushing (pos %" PRId64 ")\n", position); + + mz_stream_buffered_flush(stream, &bytes_flushed); + mz_stream_buffered_seek(stream, position, MZ_SEEK_SET); + } + + while (bytes_left_to_read > 0) { + if ((buffered->readbuf_len == 0) || (buffered->readbuf_pos == buffered->readbuf_len)) { + if (buffered->readbuf_len == sizeof(buffered->readbuf)) { + buffered->readbuf_pos = 0; + buffered->readbuf_len = 0; + } + + bytes_to_read = (int32_t)sizeof(buffered->readbuf) - (buffered->readbuf_len - buffered->readbuf_pos); + bytes_read = mz_stream_read(buffered->stream.base, buffered->readbuf + buffered->readbuf_pos, bytes_to_read); + if (bytes_read < 0) + return bytes_read; + + buffered->readbuf_misses += 1; + buffered->readbuf_len += bytes_read; + buffered->position += bytes_read; + + mz_stream_buffered_print("Buffered - Filled (read %" PRId32 "/%" PRId32 " buf %" PRId32 ":%" PRId32 " pos %" PRId64 ")\n", + bytes_read, bytes_to_read, buffered->readbuf_pos, buffered->readbuf_len, buffered->position); + + if (bytes_read == 0) + break; + } + + if ((buffered->readbuf_len - buffered->readbuf_pos) > 0) { + bytes_to_copy = buffered->readbuf_len - buffered->readbuf_pos; + if (bytes_to_copy > bytes_left_to_read) + bytes_to_copy = bytes_left_to_read; + + memcpy((char *)buf + buf_len, buffered->readbuf + buffered->readbuf_pos, bytes_to_copy); + + buf_len += bytes_to_copy; + bytes_left_to_read -= bytes_to_copy; + + buffered->readbuf_hits += 1; + buffered->readbuf_pos += bytes_to_copy; + + mz_stream_buffered_print("Buffered - Emptied (copied %" PRId32 " remaining %" PRId32 " buf %" PRId32 ":%" PRId32 " pos %" PRId64 ")\n", + bytes_to_copy, bytes_left_to_read, buffered->readbuf_pos, buffered->readbuf_len, buffered->position); + } + } + + return size - bytes_left_to_read; +} + +int32_t mz_stream_buffered_write(void *stream, const void *buf, int32_t size) { + mz_stream_buffered *buffered = (mz_stream_buffered *)stream; + int32_t bytes_to_write = size; + int32_t bytes_left_to_write = size; + int32_t bytes_to_copy = 0; + int32_t bytes_used = 0; + int32_t bytes_flushed = 0; + int32_t err = MZ_OK; + + + mz_stream_buffered_print("Buffered - Write (size %" PRId32 " len %" PRId32 " pos %" PRId64 ")\n", + size, buffered->writebuf_len, buffered->position); + + if (buffered->readbuf_len > 0) { + buffered->position -= buffered->readbuf_len; + buffered->position += buffered->readbuf_pos; + + buffered->readbuf_len = 0; + buffered->readbuf_pos = 0; + + mz_stream_buffered_print("Buffered - Switch from read to write (pos %" PRId64 ")\n", buffered->position); + + err = mz_stream_seek(buffered->stream.base, buffered->position, MZ_SEEK_SET); + if (err != MZ_OK) + return err; + } + + while (bytes_left_to_write > 0) { + bytes_used = buffered->writebuf_len; + if (bytes_used > buffered->writebuf_pos) + bytes_used = buffered->writebuf_pos; + bytes_to_copy = (int32_t)sizeof(buffered->writebuf) - bytes_used; + if (bytes_to_copy > bytes_left_to_write) + bytes_to_copy = bytes_left_to_write; + + if (bytes_to_copy == 0) { + err = mz_stream_buffered_flush(stream, &bytes_flushed); + if (err != MZ_OK) + return err; + if (bytes_flushed == 0) + return 0; + + continue; + } + + memcpy(buffered->writebuf + buffered->writebuf_pos, + (const char *)buf + (bytes_to_write - bytes_left_to_write), bytes_to_copy); + + mz_stream_buffered_print("Buffered - Write copy (remaining %" PRId32 " write %" PRId32 ":%" PRId32 " len %" PRId32 ")\n", + bytes_to_copy, bytes_to_write, bytes_left_to_write, buffered->writebuf_len); + + bytes_left_to_write -= bytes_to_copy; + + buffered->writebuf_pos += bytes_to_copy; + buffered->writebuf_hits += 1; + if (buffered->writebuf_pos > buffered->writebuf_len) + buffered->writebuf_len += buffered->writebuf_pos - buffered->writebuf_len; + } + + return size - bytes_left_to_write; +} + +int64_t mz_stream_buffered_tell(void *stream) { + mz_stream_buffered *buffered = (mz_stream_buffered *)stream; + int64_t position = mz_stream_tell(buffered->stream.base); + + buffered->position = position; + + mz_stream_buffered_print("Buffered - Tell (pos %" PRId64 " readpos %" PRId32 " writepos %" PRId32 ")\n", + buffered->position, buffered->readbuf_pos, buffered->writebuf_pos); + + if (buffered->readbuf_len > 0) + position -= ((int64_t)buffered->readbuf_len - buffered->readbuf_pos); + if (buffered->writebuf_len > 0) + position += buffered->writebuf_pos; + return position; +} + +int32_t mz_stream_buffered_seek(void *stream, int64_t offset, int32_t origin) { + mz_stream_buffered *buffered = (mz_stream_buffered *)stream; + int32_t bytes_flushed = 0; + int32_t err = MZ_OK; + + mz_stream_buffered_print("Buffered - Seek (origin %" PRId32 " offset %" PRId64 " pos %" PRId64 ")\n", + origin, offset, buffered->position); + + switch (origin) { + case MZ_SEEK_SET: + + if ((buffered->readbuf_len > 0) && (offset < buffered->position) && + (offset >= buffered->position - buffered->readbuf_len)) { + buffered->readbuf_pos = (int32_t)(offset - (buffered->position - buffered->readbuf_len)); + return MZ_OK; + } + if (buffered->writebuf_len > 0) { + if ((offset >= buffered->position) && (offset <= buffered->position + buffered->writebuf_len)) { + buffered->writebuf_pos = (int32_t)(offset - buffered->position); + return MZ_OK; + } + } + + err = mz_stream_buffered_flush(stream, &bytes_flushed); + if (err != MZ_OK) + return err; + + buffered->position = offset; + break; + + case MZ_SEEK_CUR: + + if (buffered->readbuf_len > 0) { + if (offset <= ((int64_t)buffered->readbuf_len - buffered->readbuf_pos)) { + buffered->readbuf_pos += (uint32_t)offset; + return MZ_OK; + } + offset -= ((int64_t)buffered->readbuf_len - buffered->readbuf_pos); + buffered->position += offset; + } + if (buffered->writebuf_len > 0) { + if (offset <= ((int64_t)buffered->writebuf_len - buffered->writebuf_pos)) { + buffered->writebuf_pos += (uint32_t)offset; + return MZ_OK; + } + /* offset -= (buffered->writebuf_len - buffered->writebuf_pos); */ + } + + err = mz_stream_buffered_flush(stream, &bytes_flushed); + if (err != MZ_OK) + return err; + + break; + + case MZ_SEEK_END: + + if (buffered->writebuf_len > 0) { + buffered->writebuf_pos = buffered->writebuf_len; + return MZ_OK; + } + break; + } + + buffered->readbuf_len = 0; + buffered->readbuf_pos = 0; + buffered->writebuf_len = 0; + buffered->writebuf_pos = 0; + + return mz_stream_seek(buffered->stream.base, offset, origin); +} + +int32_t mz_stream_buffered_close(void *stream) { + mz_stream_buffered *buffered = (mz_stream_buffered *)stream; + int32_t bytes_flushed = 0; + + mz_stream_buffered_flush(stream, &bytes_flushed); + mz_stream_buffered_print("Buffered - Close (flushed %" PRId32 ")\n", bytes_flushed); + + if (buffered->readbuf_hits + buffered->readbuf_misses > 0) { + mz_stream_buffered_print("Buffered - Read efficiency %.02f%%\n", + (buffered->readbuf_hits / ((float)buffered->readbuf_hits + buffered->readbuf_misses)) * 100); + } + + if (buffered->writebuf_hits + buffered->writebuf_misses > 0) { + mz_stream_buffered_print("Buffered - Write efficiency %.02f%%\n", + (buffered->writebuf_hits / ((float)buffered->writebuf_hits + buffered->writebuf_misses)) * 100); + } + + mz_stream_buffered_reset(buffered); + + return mz_stream_close(buffered->stream.base); +} + +int32_t mz_stream_buffered_error(void *stream) { + mz_stream_buffered *buffered = (mz_stream_buffered *)stream; + return mz_stream_error(buffered->stream.base); +} + +void *mz_stream_buffered_create(void **stream) { + mz_stream_buffered *buffered = NULL; + + buffered = (mz_stream_buffered *)MZ_ALLOC(sizeof(mz_stream_buffered)); + if (buffered != NULL) { + memset(buffered, 0, sizeof(mz_stream_buffered)); + buffered->stream.vtbl = &mz_stream_buffered_vtbl; + } + if (stream != NULL) + *stream = buffered; + + return buffered; +} + +void mz_stream_buffered_delete(void **stream) { + mz_stream_buffered *buffered = NULL; + if (stream == NULL) + return; + buffered = (mz_stream_buffered *)*stream; + if (buffered != NULL) + MZ_FREE(buffered); + *stream = NULL; +} + +void *mz_stream_buffered_get_interface(void) { + return (void *)&mz_stream_buffered_vtbl; +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_buf.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_buf.h new file mode 100644 index 0000000000000000000000000000000000000000..b71e6e4e920003b79b5688f53c9c6cdd2bb2c24e --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_buf.h @@ -0,0 +1,42 @@ +/* mz_strm_buf.h -- Stream for buffering reads/writes + part of the minizip-ng project + + This version of ioapi is designed to buffer IO. + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_STREAM_BUFFERED_H +#define MZ_STREAM_BUFFERED_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +int32_t mz_stream_buffered_open(void *stream, const char *path, int32_t mode); +int32_t mz_stream_buffered_is_open(void *stream); +int32_t mz_stream_buffered_read(void *stream, void *buf, int32_t size); +int32_t mz_stream_buffered_write(void *stream, const void *buf, int32_t size); +int64_t mz_stream_buffered_tell(void *stream); +int32_t mz_stream_buffered_seek(void *stream, int64_t offset, int32_t origin); +int32_t mz_stream_buffered_close(void *stream); +int32_t mz_stream_buffered_error(void *stream); + +void* mz_stream_buffered_create(void **stream); +void mz_stream_buffered_delete(void **stream); + +void* mz_stream_buffered_get_interface(void); + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_mem.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_mem.c new file mode 100644 index 0000000000000000000000000000000000000000..f4a882d928b9aea56ea9bb28accf71a9d12fd7e8 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_mem.c @@ -0,0 +1,272 @@ +/* mz_strm_mem.c -- Stream for memory access + part of the minizip-ng project + + This interface is designed to access memory rather than files. + We do use a region of memory to put data in to and take it out of. + + Based on Unzip ioapi.c version 0.22, May 19th, 2003 + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + Copyright (C) 2003 Justin Fletcher + Copyright (C) 1998-2003 Gilles Vollant + https://www.winimage.com/zLibDll/minizip.html + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + + +#include "mz.h" +#include "mz_strm.h" +#include "mz_strm_mem.h" + +/***************************************************************************/ + +static mz_stream_vtbl mz_stream_mem_vtbl = { + mz_stream_mem_open, + mz_stream_mem_is_open, + mz_stream_mem_read, + mz_stream_mem_write, + mz_stream_mem_tell, + mz_stream_mem_seek, + mz_stream_mem_close, + mz_stream_mem_error, + mz_stream_mem_create, + mz_stream_mem_delete, + NULL, + NULL +}; + +/***************************************************************************/ + +typedef struct mz_stream_mem_s { + mz_stream stream; + int32_t mode; + uint8_t *buffer; /* Memory buffer pointer */ + int32_t size; /* Size of the memory buffer */ + int32_t limit; /* Furthest we've written */ + int32_t position; /* Current position in the memory */ + int32_t grow_size; /* Size to grow when full */ +} mz_stream_mem; + +/***************************************************************************/ + +static int32_t mz_stream_mem_set_size(void *stream, int32_t size) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + int32_t new_size = size; + uint8_t *new_buf = NULL; + + + new_buf = (uint8_t *)MZ_ALLOC((uint32_t)new_size); + if (new_buf == NULL) + return MZ_BUF_ERROR; + + if (mem->buffer) { + memcpy(new_buf, mem->buffer, mem->size); + MZ_FREE(mem->buffer); + } + + mem->buffer = new_buf; + mem->size = new_size; + return MZ_OK; +} + +int32_t mz_stream_mem_open(void *stream, const char *path, int32_t mode) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + int32_t err = MZ_OK; + + MZ_UNUSED(path); + + mem->mode = mode; + mem->limit = 0; + mem->position = 0; + + if (mem->mode & MZ_OPEN_MODE_CREATE) + err = mz_stream_mem_set_size(stream, mem->grow_size); + else + mem->limit = mem->size; + + return err; +} + +int32_t mz_stream_mem_is_open(void *stream) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + if (mem->buffer == NULL) + return MZ_OPEN_ERROR; + return MZ_OK; +} + +int32_t mz_stream_mem_read(void *stream, void *buf, int32_t size) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + + if (size > mem->size - mem->position) + size = mem->size - mem->position; + if (mem->position + size > mem->limit) + size = mem->limit - mem->position; + + if (size <= 0) + return 0; + + memcpy(buf, mem->buffer + mem->position, size); + mem->position += size; + + return size; +} + +int32_t mz_stream_mem_write(void *stream, const void *buf, int32_t size) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + int32_t new_size = 0; + int32_t err = MZ_OK; + + if (size == 0) + return size; + + if (size > mem->size - mem->position) { + if (mem->mode & MZ_OPEN_MODE_CREATE) { + new_size = mem->size; + if (size < mem->grow_size) + new_size += mem->grow_size; + else + new_size += size; + + err = mz_stream_mem_set_size(stream, new_size); + if (err != MZ_OK) + return err; + } else { + size = mem->size - mem->position; + } + } + + memcpy(mem->buffer + mem->position, buf, size); + + mem->position += size; + if (mem->position > mem->limit) + mem->limit = mem->position; + + return size; +} + +int64_t mz_stream_mem_tell(void *stream) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + return mem->position; +} + +int32_t mz_stream_mem_seek(void *stream, int64_t offset, int32_t origin) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + int64_t new_pos = 0; + int32_t err = MZ_OK; + + switch (origin) { + case MZ_SEEK_CUR: + new_pos = mem->position + offset; + break; + case MZ_SEEK_END: + new_pos = mem->limit + offset; + break; + case MZ_SEEK_SET: + new_pos = offset; + break; + default: + return MZ_SEEK_ERROR; + } + + if (new_pos > mem->size) { + if ((mem->mode & MZ_OPEN_MODE_CREATE) == 0) + return MZ_SEEK_ERROR; + + err = mz_stream_mem_set_size(stream, (int32_t)new_pos); + if (err != MZ_OK) + return err; + } else if (new_pos < 0) { + return MZ_SEEK_ERROR; + } + + mem->position = (int32_t)new_pos; + return MZ_OK; +} + +int32_t mz_stream_mem_close(void *stream) { + MZ_UNUSED(stream); + + /* We never return errors */ + return MZ_OK; +} + +int32_t mz_stream_mem_error(void *stream) { + MZ_UNUSED(stream); + + /* We never return errors */ + return MZ_OK; +} + +void mz_stream_mem_set_buffer(void *stream, void *buf, int32_t size) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + mem->buffer = (uint8_t *)buf; + mem->size = size; + mem->limit = size; +} + +int32_t mz_stream_mem_get_buffer(void *stream, const void **buf) { + return mz_stream_mem_get_buffer_at(stream, 0, buf); +} + +int32_t mz_stream_mem_get_buffer_at(void *stream, int64_t position, const void **buf) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + if (buf == NULL || position < 0 || mem->size < position || mem->buffer == NULL) + return MZ_SEEK_ERROR; + *buf = mem->buffer + position; + return MZ_OK; +} + +int32_t mz_stream_mem_get_buffer_at_current(void *stream, const void **buf) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + return mz_stream_mem_get_buffer_at(stream, mem->position, buf); +} + +void mz_stream_mem_get_buffer_length(void *stream, int32_t *length) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + *length = mem->limit; +} + +void mz_stream_mem_set_buffer_limit(void *stream, int32_t limit) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + mem->limit = limit; +} + +void mz_stream_mem_set_grow_size(void *stream, int32_t grow_size) { + mz_stream_mem *mem = (mz_stream_mem *)stream; + mem->grow_size = grow_size; +} + +void *mz_stream_mem_create(void **stream) { + mz_stream_mem *mem = NULL; + + mem = (mz_stream_mem *)MZ_ALLOC(sizeof(mz_stream_mem)); + if (mem != NULL) { + memset(mem, 0, sizeof(mz_stream_mem)); + mem->stream.vtbl = &mz_stream_mem_vtbl; + mem->grow_size = 4096; + } + if (stream != NULL) + *stream = mem; + + return mem; +} + +void mz_stream_mem_delete(void **stream) { + mz_stream_mem *mem = NULL; + if (stream == NULL) + return; + mem = (mz_stream_mem *)*stream; + if (mem != NULL) { + if ((mem->mode & MZ_OPEN_MODE_CREATE) && (mem->buffer != NULL)) + MZ_FREE(mem->buffer); + MZ_FREE(mem); + } + *stream = NULL; +} + +void *mz_stream_mem_get_interface(void) { + return (void *)&mz_stream_mem_vtbl; +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_mem.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_mem.h new file mode 100644 index 0000000000000000000000000000000000000000..5bfa13d8a652c747286baa19532976b5a771beeb --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_mem.h @@ -0,0 +1,48 @@ +/* mz_strm_mem.h -- Stream for memory access + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_STREAM_MEM_H +#define MZ_STREAM_MEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +int32_t mz_stream_mem_open(void *stream, const char *filename, int32_t mode); +int32_t mz_stream_mem_is_open(void *stream); +int32_t mz_stream_mem_read(void *stream, void *buf, int32_t size); +int32_t mz_stream_mem_write(void *stream, const void *buf, int32_t size); +int64_t mz_stream_mem_tell(void *stream); +int32_t mz_stream_mem_seek(void *stream, int64_t offset, int32_t origin); +int32_t mz_stream_mem_close(void *stream); +int32_t mz_stream_mem_error(void *stream); + +void mz_stream_mem_set_buffer(void *stream, void *buf, int32_t size); +int32_t mz_stream_mem_get_buffer(void *stream, const void **buf); +int32_t mz_stream_mem_get_buffer_at(void *stream, int64_t position, const void **buf); +int32_t mz_stream_mem_get_buffer_at_current(void *stream, const void **buf); +void mz_stream_mem_get_buffer_length(void *stream, int32_t *length); +void mz_stream_mem_set_buffer_limit(void *stream, int32_t limit); +void mz_stream_mem_set_grow_size(void *stream, int32_t grow_size); + +void* mz_stream_mem_create(void **stream); +void mz_stream_mem_delete(void **stream); + +void* mz_stream_mem_get_interface(void); + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_os.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_os.h new file mode 100644 index 0000000000000000000000000000000000000000..614e2552074f6bca8905126a4d3a7c63f1bbbb74 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_os.h @@ -0,0 +1,40 @@ +/* mz_sstrm_os.h -- Stream for filesystem access + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_STREAM_OS_H +#define MZ_STREAM_OS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +int32_t mz_stream_os_open(void *stream, const char *path, int32_t mode); +int32_t mz_stream_os_is_open(void *stream); +int32_t mz_stream_os_read(void *stream, void *buf, int32_t size); +int32_t mz_stream_os_write(void *stream, const void *buf, int32_t size); +int64_t mz_stream_os_tell(void *stream); +int32_t mz_stream_os_seek(void *stream, int64_t offset, int32_t origin); +int32_t mz_stream_os_close(void *stream); +int32_t mz_stream_os_error(void *stream); + +void* mz_stream_os_create(void **stream); +void mz_stream_os_delete(void **stream); + +void* mz_stream_os_get_interface(void); + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_os_posix.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_os_posix.c new file mode 100644 index 0000000000000000000000000000000000000000..f0b5bd335179475f55dfd85b9f4e92ba158957ea --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_os_posix.c @@ -0,0 +1,206 @@ +/* mz_strm_posix.c -- Stream for filesystem access for posix/linux + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + Modifications for Zip64 support + Copyright (C) 2009-2010 Mathias Svensson + http://result42.com + Copyright (C) 1998-2010 Gilles Vollant + https://www.winimage.com/zLibDll/minizip.html + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + + +#include "mz.h" +#include "mz_strm.h" +#include "mz_strm_os.h" + +#include /* fopen, fread.. */ +#include + +/***************************************************************************/ + +#define fopen64 fopen +#ifndef MZ_FILE32_API +# ifndef NO_FSEEKO +# define ftello64 ftello +# define fseeko64 fseeko +# elif defined(_MSC_VER) && (_MSC_VER >= 1400) +# define ftello64 _ftelli64 +# define fseeko64 _fseeki64 +# endif +#endif +#ifndef ftello64 +# define ftello64 ftell +#endif +#ifndef fseeko64 +# define fseeko64 fseek +#endif + +/***************************************************************************/ + +static mz_stream_vtbl mz_stream_os_vtbl = { + mz_stream_os_open, + mz_stream_os_is_open, + mz_stream_os_read, + mz_stream_os_write, + mz_stream_os_tell, + mz_stream_os_seek, + mz_stream_os_close, + mz_stream_os_error, + mz_stream_os_create, + mz_stream_os_delete, + NULL, + NULL +}; + +/***************************************************************************/ + +typedef struct mz_stream_posix_s { + mz_stream stream; + int32_t error; + FILE *handle; +} mz_stream_posix; + +/***************************************************************************/ + +int32_t mz_stream_os_open(void *stream, const char *path, int32_t mode) { + mz_stream_posix *posix = (mz_stream_posix *)stream; + const char *mode_fopen = NULL; + + if (path == NULL) + return MZ_PARAM_ERROR; + + if ((mode & MZ_OPEN_MODE_READWRITE) == MZ_OPEN_MODE_READ) + mode_fopen = "rb"; + else if (mode & MZ_OPEN_MODE_APPEND) + mode_fopen = "r+b"; + else if (mode & MZ_OPEN_MODE_CREATE) + mode_fopen = "wb"; + else + return MZ_OPEN_ERROR; + + posix->handle = fopen64(path, mode_fopen); + if (posix->handle == NULL) { + posix->error = errno; + return MZ_OPEN_ERROR; + } + + if (mode & MZ_OPEN_MODE_APPEND) + return mz_stream_os_seek(stream, 0, MZ_SEEK_END); + + return MZ_OK; +} + +int32_t mz_stream_os_is_open(void *stream) { + mz_stream_posix *posix = (mz_stream_posix*)stream; + if (posix->handle == NULL) + return MZ_OPEN_ERROR; + return MZ_OK; +} + +int32_t mz_stream_os_read(void *stream, void *buf, int32_t size) { + mz_stream_posix *posix = (mz_stream_posix*)stream; + int32_t read = (int32_t)fread(buf, 1, (size_t)size, posix->handle); + if (read < size && ferror(posix->handle)) { + posix->error = errno; + return MZ_READ_ERROR; + } + return read; +} + +int32_t mz_stream_os_write(void *stream, const void *buf, int32_t size) { + mz_stream_posix *posix = (mz_stream_posix*)stream; + int32_t written = (int32_t)fwrite(buf, 1, (size_t)size, posix->handle); + if (written < size && ferror(posix->handle)) { + posix->error = errno; + return MZ_WRITE_ERROR; + } + return written; +} + +int64_t mz_stream_os_tell(void *stream) { + mz_stream_posix *posix = (mz_stream_posix*)stream; + int64_t position = ftello64(posix->handle); + if (position == -1) { + posix->error = errno; + return MZ_TELL_ERROR; + } + return position; +} + +int32_t mz_stream_os_seek(void *stream, int64_t offset, int32_t origin) { + mz_stream_posix *posix = (mz_stream_posix*)stream; + int32_t fseek_origin = 0; + + switch (origin) { + case MZ_SEEK_CUR: + fseek_origin = SEEK_CUR; + break; + case MZ_SEEK_END: + fseek_origin = SEEK_END; + break; + case MZ_SEEK_SET: + fseek_origin = SEEK_SET; + break; + default: + return MZ_SEEK_ERROR; + } + + if (fseeko64(posix->handle, offset, fseek_origin) != 0) { + posix->error = errno; + return MZ_SEEK_ERROR; + } + + return MZ_OK; +} + +int32_t mz_stream_os_close(void *stream) { + mz_stream_posix *posix = (mz_stream_posix*)stream; + int32_t closed = 0; + if (posix->handle != NULL) { + closed = fclose(posix->handle); + posix->handle = NULL; + } + if (closed != 0) { + posix->error = errno; + return MZ_CLOSE_ERROR; + } + return MZ_OK; +} + +int32_t mz_stream_os_error(void *stream) { + mz_stream_posix *posix = (mz_stream_posix*)stream; + return posix->error; +} + +void *mz_stream_os_create(void **stream) { + mz_stream_posix *posix = NULL; + + posix = (mz_stream_posix *)MZ_ALLOC(sizeof(mz_stream_posix)); + if (posix != NULL) { + memset(posix, 0, sizeof(mz_stream_posix)); + posix->stream.vtbl = &mz_stream_os_vtbl; + } + if (stream != NULL) + *stream = posix; + + return posix; +} + +void mz_stream_os_delete(void **stream) { + mz_stream_posix *posix = NULL; + if (stream == NULL) + return; + posix = (mz_stream_posix *)*stream; + if (posix != NULL) + MZ_FREE(posix); + *stream = NULL; +} + +void *mz_stream_os_get_interface(void) { + return (void *)&mz_stream_os_vtbl; +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_pkcrypt.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_pkcrypt.c new file mode 100644 index 0000000000000000000000000000000000000000..41c762f9c0f6c64af1e4eb15436307c1aeaf9cd8 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_pkcrypt.c @@ -0,0 +1,338 @@ +/* mz_strm_pkcrypt.c -- Code for traditional PKWARE encryption + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + Copyright (C) 1998-2005 Gilles Vollant + Modifications for Info-ZIP crypting + https://www.winimage.com/zLibDll/minizip.html + Copyright (C) 2003 Terry Thorsen + + This code is a modified version of crypting code in Info-ZIP distribution + + Copyright (C) 1990-2000 Info-ZIP. All rights reserved. + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. + + This encryption code is a direct transcription of the algorithm from + Roger Schlafly, described by Phil Katz in the file appnote.txt. This + file (appnote.txt) is distributed with the PKZIP program (even in the + version without encryption capabilities). +*/ + + +#include "mz.h" +#include "mz_crypt.h" +#include "mz_strm.h" +#include "mz_strm_pkcrypt.h" + +/***************************************************************************/ + +static mz_stream_vtbl mz_stream_pkcrypt_vtbl = { + mz_stream_pkcrypt_open, + mz_stream_pkcrypt_is_open, + mz_stream_pkcrypt_read, + mz_stream_pkcrypt_write, + mz_stream_pkcrypt_tell, + mz_stream_pkcrypt_seek, + mz_stream_pkcrypt_close, + mz_stream_pkcrypt_error, + mz_stream_pkcrypt_create, + mz_stream_pkcrypt_delete, + mz_stream_pkcrypt_get_prop_int64, + mz_stream_pkcrypt_set_prop_int64 +}; + +/***************************************************************************/ + +typedef struct mz_stream_pkcrypt_s { + mz_stream stream; + int32_t error; + int16_t initialized; + uint8_t buffer[UINT16_MAX]; + int64_t total_in; + int64_t max_total_in; + int64_t total_out; + uint32_t keys[3]; /* keys defining the pseudo-random sequence */ + uint8_t verify1; + uint8_t verify2; + const char *password; +} mz_stream_pkcrypt; + +/***************************************************************************/ + +#define mz_stream_pkcrypt_decode(strm, c) \ + (mz_stream_pkcrypt_update_keys(strm, \ + c ^= mz_stream_pkcrypt_decrypt_byte(strm))) + +#define mz_stream_pkcrypt_encode(strm, c, t) \ + (t = mz_stream_pkcrypt_decrypt_byte(strm), \ + mz_stream_pkcrypt_update_keys(strm, (uint8_t)c), (uint8_t)(t^(c))) + +/***************************************************************************/ + +static uint8_t mz_stream_pkcrypt_decrypt_byte(void *stream) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + + unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an */ + /* unpredictable manner on 16-bit systems; not a problem */ + /* with any known compiler so far, though. */ + + temp = pkcrypt->keys[2] | 2; + return (uint8_t)(((temp * (temp ^ 1)) >> 8) & 0xff); +} + +static uint8_t mz_stream_pkcrypt_update_keys(void *stream, uint8_t c) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + uint8_t buf = c; + + pkcrypt->keys[0] = (uint32_t)~mz_crypt_crc32_update(~pkcrypt->keys[0], &buf, 1); + + pkcrypt->keys[1] += pkcrypt->keys[0] & 0xff; + pkcrypt->keys[1] *= 134775813L; + pkcrypt->keys[1] += 1; + + buf = (uint8_t)(pkcrypt->keys[1] >> 24); + pkcrypt->keys[2] = (uint32_t)~mz_crypt_crc32_update(~pkcrypt->keys[2], &buf, 1); + + return (uint8_t)c; +} + +static void mz_stream_pkcrypt_init_keys(void *stream, const char *password) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + + pkcrypt->keys[0] = 305419896L; + pkcrypt->keys[1] = 591751049L; + pkcrypt->keys[2] = 878082192L; + + while (*password != 0) { + mz_stream_pkcrypt_update_keys(stream, (uint8_t)*password); + password += 1; + } +} + +/***************************************************************************/ + +int32_t mz_stream_pkcrypt_open(void *stream, const char *path, int32_t mode) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + uint16_t t = 0; + int16_t i = 0; + uint8_t verify1 = 0; + uint8_t verify2 = 0; + uint8_t header[MZ_PKCRYPT_HEADER_SIZE]; + const char *password = path; + + pkcrypt->total_in = 0; + pkcrypt->total_out = 0; + pkcrypt->initialized = 0; + + if (mz_stream_is_open(pkcrypt->stream.base) != MZ_OK) + return MZ_OPEN_ERROR; + + if (password == NULL) + password = pkcrypt->password; + if (password == NULL) + return MZ_PARAM_ERROR; + + mz_stream_pkcrypt_init_keys(stream, password); + + if (mode & MZ_OPEN_MODE_WRITE) { + /* First generate RAND_HEAD_LEN - 2 random bytes. */ + mz_crypt_rand(header, MZ_PKCRYPT_HEADER_SIZE - 2); + + /* Encrypt random header (last two bytes is high word of crc) */ + for (i = 0; i < MZ_PKCRYPT_HEADER_SIZE - 2; i++) + header[i] = mz_stream_pkcrypt_encode(stream, header[i], t); + + header[i++] = mz_stream_pkcrypt_encode(stream, pkcrypt->verify1, t); + header[i++] = mz_stream_pkcrypt_encode(stream, pkcrypt->verify2, t); + + if (mz_stream_write(pkcrypt->stream.base, header, sizeof(header)) != sizeof(header)) + return MZ_WRITE_ERROR; + + pkcrypt->total_out += MZ_PKCRYPT_HEADER_SIZE; + } else if (mode & MZ_OPEN_MODE_READ) { + if (mz_stream_read(pkcrypt->stream.base, header, sizeof(header)) != sizeof(header)) + return MZ_READ_ERROR; + + for (i = 0; i < MZ_PKCRYPT_HEADER_SIZE - 2; i++) + header[i] = mz_stream_pkcrypt_decode(stream, header[i]); + + verify1 = mz_stream_pkcrypt_decode(stream, header[i++]); + verify2 = mz_stream_pkcrypt_decode(stream, header[i++]); + + /* Older versions used 2 byte check, newer versions use 1 byte check. */ + MZ_UNUSED(verify1); + if ((verify2 != 0) && (verify2 != pkcrypt->verify2)) + return MZ_PASSWORD_ERROR; + + pkcrypt->total_in += MZ_PKCRYPT_HEADER_SIZE; + } + + pkcrypt->initialized = 1; + return MZ_OK; +} + +int32_t mz_stream_pkcrypt_is_open(void *stream) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + if (pkcrypt->initialized == 0) + return MZ_OPEN_ERROR; + return MZ_OK; +} + +int32_t mz_stream_pkcrypt_read(void *stream, void *buf, int32_t size) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + uint8_t *buf_ptr = (uint8_t *)buf; + int32_t bytes_to_read = size; + int32_t read = 0; + int32_t i = 0; + + + if ((int64_t)bytes_to_read > (pkcrypt->max_total_in - pkcrypt->total_in)) + bytes_to_read = (int32_t)(pkcrypt->max_total_in - pkcrypt->total_in); + + read = mz_stream_read(pkcrypt->stream.base, buf, bytes_to_read); + + for (i = 0; i < read; i++) + buf_ptr[i] = mz_stream_pkcrypt_decode(stream, buf_ptr[i]); + + if (read > 0) + pkcrypt->total_in += read; + + return read; +} + +int32_t mz_stream_pkcrypt_write(void *stream, const void *buf, int32_t size) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + const uint8_t *buf_ptr = (const uint8_t *)buf; + int32_t bytes_to_write = sizeof(pkcrypt->buffer); + int32_t total_written = 0; + int32_t written = 0; + int32_t i = 0; + uint16_t t = 0; + + if (size < 0) + return MZ_PARAM_ERROR; + + do { + if (bytes_to_write > (size - total_written)) + bytes_to_write = (size - total_written); + + for (i = 0; i < bytes_to_write; i += 1) { + pkcrypt->buffer[i] = mz_stream_pkcrypt_encode(stream, *buf_ptr, t); + buf_ptr += 1; + } + + written = mz_stream_write(pkcrypt->stream.base, pkcrypt->buffer, bytes_to_write); + if (written < 0) + return written; + + total_written += written; + } while (total_written < size && written > 0); + + pkcrypt->total_out += total_written; + return total_written; +} + +int64_t mz_stream_pkcrypt_tell(void *stream) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + return mz_stream_tell(pkcrypt->stream.base); +} + +int32_t mz_stream_pkcrypt_seek(void *stream, int64_t offset, int32_t origin) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + return mz_stream_seek(pkcrypt->stream.base, offset, origin); +} + +int32_t mz_stream_pkcrypt_close(void *stream) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + pkcrypt->initialized = 0; + return MZ_OK; +} + +int32_t mz_stream_pkcrypt_error(void *stream) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + return pkcrypt->error; +} + +void mz_stream_pkcrypt_set_password(void *stream, const char *password) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + pkcrypt->password = password; +} + +void mz_stream_pkcrypt_set_verify(void *stream, uint8_t verify1, uint8_t verify2) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + pkcrypt->verify1 = verify1; + pkcrypt->verify2 = verify2; +} + +void mz_stream_pkcrypt_get_verify(void *stream, uint8_t *verify1, uint8_t *verify2) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + *verify1 = pkcrypt->verify1; + *verify2 = pkcrypt->verify2; +} + +int32_t mz_stream_pkcrypt_get_prop_int64(void *stream, int32_t prop, int64_t *value) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + switch (prop) { + case MZ_STREAM_PROP_TOTAL_IN: + *value = pkcrypt->total_in; + break; + case MZ_STREAM_PROP_TOTAL_OUT: + *value = pkcrypt->total_out; + break; + case MZ_STREAM_PROP_TOTAL_IN_MAX: + *value = pkcrypt->max_total_in; + break; + case MZ_STREAM_PROP_HEADER_SIZE: + *value = MZ_PKCRYPT_HEADER_SIZE; + break; + case MZ_STREAM_PROP_FOOTER_SIZE: + *value = 0; + break; + default: + return MZ_EXIST_ERROR; + } + return MZ_OK; +} + +int32_t mz_stream_pkcrypt_set_prop_int64(void *stream, int32_t prop, int64_t value) { + mz_stream_pkcrypt *pkcrypt = (mz_stream_pkcrypt *)stream; + switch (prop) { + case MZ_STREAM_PROP_TOTAL_IN_MAX: + pkcrypt->max_total_in = value; + break; + default: + return MZ_EXIST_ERROR; + } + return MZ_OK; +} + +void *mz_stream_pkcrypt_create(void **stream) { + mz_stream_pkcrypt *pkcrypt = NULL; + + pkcrypt = (mz_stream_pkcrypt *)MZ_ALLOC(sizeof(mz_stream_pkcrypt)); + if (pkcrypt != NULL) { + memset(pkcrypt, 0, sizeof(mz_stream_pkcrypt)); + pkcrypt->stream.vtbl = &mz_stream_pkcrypt_vtbl; + } + + if (stream != NULL) + *stream = pkcrypt; + return pkcrypt; +} + +void mz_stream_pkcrypt_delete(void **stream) { + mz_stream_pkcrypt *pkcrypt = NULL; + if (stream == NULL) + return; + pkcrypt = (mz_stream_pkcrypt *)*stream; + if (pkcrypt != NULL) + MZ_FREE(pkcrypt); + *stream = NULL; +} + +void *mz_stream_pkcrypt_get_interface(void) { + return (void *)&mz_stream_pkcrypt_vtbl; +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_pkcrypt.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_pkcrypt.h new file mode 100644 index 0000000000000000000000000000000000000000..453f1f994851f96ddd8d2e51fc38d56c98cdaf11 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_pkcrypt.h @@ -0,0 +1,46 @@ +/* mz_strm_pkcrypt.h -- Code for traditional PKWARE encryption + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_STREAM_PKCRYPT_H +#define MZ_STREAM_PKCRYPT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +int32_t mz_stream_pkcrypt_open(void *stream, const char *filename, int32_t mode); +int32_t mz_stream_pkcrypt_is_open(void *stream); +int32_t mz_stream_pkcrypt_read(void *stream, void *buf, int32_t size); +int32_t mz_stream_pkcrypt_write(void *stream, const void *buf, int32_t size); +int64_t mz_stream_pkcrypt_tell(void *stream); +int32_t mz_stream_pkcrypt_seek(void *stream, int64_t offset, int32_t origin); +int32_t mz_stream_pkcrypt_close(void *stream); +int32_t mz_stream_pkcrypt_error(void *stream); + +void mz_stream_pkcrypt_set_password(void *stream, const char *password); +void mz_stream_pkcrypt_set_verify(void *stream, uint8_t verify1, uint8_t verify2); +void mz_stream_pkcrypt_get_verify(void *stream, uint8_t *verify1, uint8_t *verify2); +int32_t mz_stream_pkcrypt_get_prop_int64(void *stream, int32_t prop, int64_t *value); +int32_t mz_stream_pkcrypt_set_prop_int64(void *stream, int32_t prop, int64_t value); + +void* mz_stream_pkcrypt_create(void **stream); +void mz_stream_pkcrypt_delete(void **stream); + +void* mz_stream_pkcrypt_get_interface(void); + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_split.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_split.c new file mode 100644 index 0000000000000000000000000000000000000000..12c8bda303965ece47430ee0db46f02909f0293f --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_split.c @@ -0,0 +1,438 @@ +/* mz_strm_split.c -- Stream for split files + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + + +#include "mz.h" +#include "mz_os.h" +#include "mz_strm.h" +#include "mz_strm_split.h" + +#include /* snprintf */ + +#if defined(_MSC_VER) && (_MSC_VER < 1900) +# define snprintf _snprintf +#endif + +/***************************************************************************/ + +#define MZ_ZIP_MAGIC_DISKHEADER (0x08074b50) + +/***************************************************************************/ + +static mz_stream_vtbl mz_stream_split_vtbl = { + mz_stream_split_open, + mz_stream_split_is_open, + mz_stream_split_read, + mz_stream_split_write, + mz_stream_split_tell, + mz_stream_split_seek, + mz_stream_split_close, + mz_stream_split_error, + mz_stream_split_create, + mz_stream_split_delete, + mz_stream_split_get_prop_int64, + mz_stream_split_set_prop_int64 +}; + +/***************************************************************************/ + +typedef struct mz_stream_split_s { + mz_stream stream; + int32_t is_open; + int64_t disk_size; + int64_t total_in; + int64_t total_in_disk; + int64_t total_out; + int64_t total_out_disk; + int32_t mode; + char *path_cd; + uint32_t path_cd_size; + char *path_disk; + uint32_t path_disk_size; + int32_t number_disk; + int32_t current_disk; + int64_t current_disk_size; + int32_t reached_end; +} mz_stream_split; + +/***************************************************************************/ + +#if 0 +# define mz_stream_split_print printf +#else +# define mz_stream_split_print(fmt,...) +#endif + +/***************************************************************************/ + +static int32_t mz_stream_split_open_disk(void *stream, int32_t number_disk) { + mz_stream_split *split = (mz_stream_split *)stream; + uint32_t magic = 0; + int64_t position = 0; + int32_t i = 0; + int32_t err = MZ_OK; + int16_t disk_part = 0; + + + /* Check if we are reading or writing a disk part or the cd disk */ + if (number_disk >= 0) { + if ((split->mode & MZ_OPEN_MODE_WRITE) == 0) + disk_part = MZ_OPEN_MODE_READ; + else if (split->disk_size > 0) + disk_part = MZ_OPEN_MODE_WRITE; + } + + /* Construct disk path */ + if (disk_part > 0) { + for (i = (int32_t)strlen(split->path_disk) - 1; i >= 0; i -= 1) { + if (split->path_disk[i] != '.') + continue; + snprintf(&split->path_disk[i], split->path_disk_size - (uint32_t)i, + ".z%02" PRId32, number_disk + 1); + break; + } + } else { + strncpy(split->path_disk, split->path_cd, split->path_disk_size - 1); + split->path_disk[split->path_disk_size - 1] = 0; + } + + mz_stream_split_print("Split - Goto disk - %s (disk %" PRId32 ")\n", split->path_disk, number_disk); + + /* If disk part doesn't exist during reading then return MZ_EXIST_ERROR */ + if (disk_part == MZ_OPEN_MODE_READ) + err = mz_os_file_exists(split->path_disk); + + if (err == MZ_OK) + err = mz_stream_open(split->stream.base, split->path_disk, split->mode); + + if (err == MZ_OK) { + split->total_in_disk = 0; + split->total_out_disk = 0; + split->current_disk = number_disk; + + if (split->mode & MZ_OPEN_MODE_WRITE) { + if ((split->current_disk == 0) && (split->disk_size > 0)) { + err = mz_stream_write_uint32(split->stream.base, MZ_ZIP_MAGIC_DISKHEADER); + + split->total_out_disk += 4; + split->total_out += split->total_out_disk; + } + } else if (split->mode & MZ_OPEN_MODE_READ) { + if (split->current_disk == 0) { + err = mz_stream_read_uint32(split->stream.base, &magic); + if (magic != MZ_ZIP_MAGIC_DISKHEADER) + err = MZ_FORMAT_ERROR; + } + } + } + + if (err == MZ_OK) { + /* Get the size of the current disk we are on */ + position = mz_stream_tell(split->stream.base); + mz_stream_seek(split->stream.base, 0, MZ_SEEK_END); + split->current_disk_size = mz_stream_tell(split->stream.base); + mz_stream_seek(split->stream.base, position, MZ_SEEK_SET); + + split->is_open = 1; + } + + return err; +} + +static int32_t mz_stream_split_close_disk(void *stream) { + mz_stream_split *split = (mz_stream_split *)stream; + + if (mz_stream_is_open(split->stream.base) != MZ_OK) + return MZ_OK; + + mz_stream_split_print("Split - Close disk\n"); + return mz_stream_close(split->stream.base); +} + +static int32_t mz_stream_split_goto_disk(void *stream, int32_t number_disk) { + mz_stream_split *split = (mz_stream_split *)stream; + int32_t err = MZ_OK; + int32_t err_is_open = MZ_OK; + + err_is_open = mz_stream_is_open(split->stream.base); + + if ((split->disk_size == 0) && (split->mode & MZ_OPEN_MODE_WRITE)) { + if (err_is_open != MZ_OK) + err = mz_stream_split_open_disk(stream, number_disk); + } else if ((number_disk != split->current_disk) || (err_is_open != MZ_OK)) { + err = mz_stream_split_close_disk(stream); + if (err == MZ_OK) { + err = mz_stream_split_open_disk(stream, number_disk); + if (err == MZ_OK) + split->number_disk = number_disk; + } + } + + return err; +} + +int32_t mz_stream_split_open(void *stream, const char *path, int32_t mode) { + mz_stream_split *split = (mz_stream_split *)stream; + int32_t number_disk = 0; + + split->mode = mode; + + split->path_cd_size = (uint32_t)strlen(path) + 1; + split->path_cd = (char *)MZ_ALLOC(split->path_cd_size); + + if (split->path_cd == NULL) + return MZ_MEM_ERROR; + + strncpy(split->path_cd, path, split->path_cd_size - 1); + split->path_cd[split->path_cd_size - 1] = 0; + + mz_stream_split_print("Split - Open - %s (disk %" PRId32 ")\n", split->path_cd, number_disk); + + split->path_disk_size = (uint32_t)strlen(path) + 10; + split->path_disk = (char *)MZ_ALLOC(split->path_disk_size); + + if (split->path_disk == NULL) { + MZ_FREE(split->path_cd); + return MZ_MEM_ERROR; + } + + strncpy(split->path_disk, path, split->path_disk_size - 1); + split->path_disk[split->path_disk_size - 1] = 0; + + if ((mode & MZ_OPEN_MODE_WRITE) && ((mode & MZ_OPEN_MODE_APPEND) == 0)) { + number_disk = 0; + split->current_disk = -1; + } else { + number_disk = -1; + split->current_disk = 0; + } + + return mz_stream_split_goto_disk(stream, number_disk); +} + +int32_t mz_stream_split_is_open(void *stream) { + mz_stream_split *split = (mz_stream_split *)stream; + if (split->is_open != 1) + return MZ_OPEN_ERROR; + return MZ_OK; +} + +int32_t mz_stream_split_read(void *stream, void *buf, int32_t size) { + mz_stream_split *split = (mz_stream_split *)stream; + int32_t bytes_left = size; + int32_t read = 0; + int32_t err = MZ_OK; + uint8_t *buf_ptr = (uint8_t *)buf; + + err = mz_stream_split_goto_disk(stream, split->number_disk); + if (err != MZ_OK) + return err; + + while (bytes_left > 0) { + read = mz_stream_read(split->stream.base, buf_ptr, bytes_left); + + mz_stream_split_print("Split - Read disk - %" PRId32 "\n", read); + + if (read < 0) + return read; + if (read == 0) { + if (split->current_disk < 0) /* No more disks to goto */ + break; + err = mz_stream_split_goto_disk(stream, split->current_disk + 1); + if (err == MZ_EXIST_ERROR) { + split->current_disk = -1; + break; + } + if (err != MZ_OK) + return err; + } + + bytes_left -= read; + buf_ptr += read; + split->total_in += read; + split->total_in_disk += read; + } + return size - bytes_left; +} + +int32_t mz_stream_split_write(void *stream, const void *buf, int32_t size) { + mz_stream_split *split = (mz_stream_split *)stream; + int64_t position = 0; + int32_t written = 0; + int32_t bytes_left = size; + int32_t bytes_to_write = 0; + int32_t bytes_avail = 0; + int32_t number_disk = -1; + int32_t err = MZ_OK; + const uint8_t *buf_ptr = (const uint8_t *)buf; + + position = mz_stream_tell(split->stream.base); + + while (bytes_left > 0) { + bytes_to_write = bytes_left; + + if (split->disk_size > 0) { + if ((split->total_out_disk == split->disk_size && split->total_out > 0) || + (split->number_disk == -1 && split->number_disk != split->current_disk)) { + if (split->number_disk != -1) + number_disk = split->current_disk + 1; + + err = mz_stream_split_goto_disk(stream, number_disk); + if (err != MZ_OK) + return err; + } + + if (split->number_disk != -1) { + bytes_avail = (int32_t)(split->disk_size - split->total_out_disk); + if (bytes_to_write > bytes_avail) + bytes_to_write = bytes_avail; + } + } + + written = mz_stream_write(split->stream.base, buf_ptr, bytes_to_write); + if (written != bytes_to_write) + return MZ_WRITE_ERROR; + + mz_stream_split_print("Split - Write disk - %" PRId32 "\n", written); + + bytes_left -= written; + buf_ptr += written; + + split->total_out += written; + split->total_out_disk += written; + + if (position == split->current_disk_size) { + split->current_disk_size += written; + position = split->current_disk_size; + } + } + + return size - bytes_left; +} + +int64_t mz_stream_split_tell(void *stream) { + mz_stream_split *split = (mz_stream_split *)stream; + int32_t err = MZ_OK; + err = mz_stream_split_goto_disk(stream, split->number_disk); + if (err != MZ_OK) + return err; + return mz_stream_tell(split->stream.base); +} + +int32_t mz_stream_split_seek(void *stream, int64_t offset, int32_t origin) { + mz_stream_split *split = (mz_stream_split *)stream; + int64_t disk_left = 0; + int64_t position = 0; + int32_t err = MZ_OK; + + err = mz_stream_split_goto_disk(stream, split->number_disk); + + if (err != MZ_OK) + return err; + + mz_stream_split_print("Split - Seek disk - %" PRId64 " (origin %" PRId32 ")\n", offset, origin); + + if ((origin == MZ_SEEK_CUR) && (split->number_disk != -1)) { + position = mz_stream_tell(split->stream.base); + disk_left = split->current_disk_size - position; + + while (offset > disk_left) { + err = mz_stream_split_goto_disk(stream, split->current_disk + 1); + if (err != MZ_OK) + return err; + + offset -= disk_left; + disk_left = split->current_disk_size; + } + } + + return mz_stream_seek(split->stream.base, offset, origin); +} + +int32_t mz_stream_split_close(void *stream) { + mz_stream_split *split = (mz_stream_split *)stream; + int32_t err = MZ_OK; + + err = mz_stream_split_close_disk(stream); + split->is_open = 0; + return err; +} + +int32_t mz_stream_split_error(void *stream) { + mz_stream_split *split = (mz_stream_split *)stream; + return mz_stream_error(split->stream.base); +} + +int32_t mz_stream_split_get_prop_int64(void *stream, int32_t prop, int64_t *value) { + mz_stream_split *split = (mz_stream_split *)stream; + switch (prop) { + case MZ_STREAM_PROP_TOTAL_OUT: + *value = split->total_out; + break; + case MZ_STREAM_PROP_DISK_NUMBER: + *value = split->number_disk; + break; + case MZ_STREAM_PROP_DISK_SIZE: + *value = split->disk_size; + break; + default: + return MZ_EXIST_ERROR; + } + return MZ_OK; +} + +int32_t mz_stream_split_set_prop_int64(void *stream, int32_t prop, int64_t value) { + mz_stream_split *split = (mz_stream_split *)stream; + switch (prop) { + case MZ_STREAM_PROP_DISK_NUMBER: + split->number_disk = (int32_t)value; + break; + case MZ_STREAM_PROP_DISK_SIZE: + split->disk_size = value; + break; + default: + return MZ_EXIST_ERROR; + } + return MZ_OK; +} + +void *mz_stream_split_create(void **stream) { + mz_stream_split *split = NULL; + + split = (mz_stream_split *)MZ_ALLOC(sizeof(mz_stream_split)); + if (split != NULL) { + memset(split, 0, sizeof(mz_stream_split)); + split->stream.vtbl = &mz_stream_split_vtbl; + } + if (stream != NULL) + *stream = split; + + return split; +} + +void mz_stream_split_delete(void **stream) { + mz_stream_split *split = NULL; + if (stream == NULL) + return; + split = (mz_stream_split *)*stream; + if (split != NULL) { + if (split->path_cd) + MZ_FREE(split->path_cd); + if (split->path_disk) + MZ_FREE(split->path_disk); + + MZ_FREE(split); + } + *stream = NULL; +} + +void *mz_stream_split_get_interface(void) { + return (void *)&mz_stream_split_vtbl; +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_split.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_split.h new file mode 100644 index 0000000000000000000000000000000000000000..da404dae2aaaae32a374e91cadeaa92ac3d576a5 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_split.h @@ -0,0 +1,43 @@ +/* mz_strm_split.h -- Stream for split files + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_STREAM_SPLIT_H +#define MZ_STREAM_SPLIT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +int32_t mz_stream_split_open(void *stream, const char *filename, int32_t mode); +int32_t mz_stream_split_is_open(void *stream); +int32_t mz_stream_split_read(void *stream, void *buf, int32_t size); +int32_t mz_stream_split_write(void *stream, const void *buf, int32_t size); +int64_t mz_stream_split_tell(void *stream); +int32_t mz_stream_split_seek(void *stream, int64_t offset, int32_t origin); +int32_t mz_stream_split_close(void *stream); +int32_t mz_stream_split_error(void *stream); + +int32_t mz_stream_split_get_prop_int64(void *stream, int32_t prop, int64_t *value); +int32_t mz_stream_split_set_prop_int64(void *stream, int32_t prop, int64_t value); + +void* mz_stream_split_create(void **stream); +void mz_stream_split_delete(void **stream); + +void* mz_stream_split_get_interface(void); + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_wzaes.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_wzaes.c new file mode 100644 index 0000000000000000000000000000000000000000..fd0119991a9b550ee9fa5673fdf72772f097df12 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_wzaes.c @@ -0,0 +1,362 @@ +/* mz_strm_wzaes.c -- Stream for WinZip AES encryption + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + Copyright (C) 1998-2010 Brian Gladman, Worcester, UK + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + + +#include "mz.h" +#include "mz_crypt.h" +#include "mz_strm.h" +#include "mz_strm_wzaes.h" + +/***************************************************************************/ + +#define MZ_AES_KEYING_ITERATIONS (1000) +#define MZ_AES_SALT_LENGTH(MODE) (4 * (MODE & 3) + 4) +#define MZ_AES_SALT_LENGTH_MAX (16) +#define MZ_AES_PW_LENGTH_MAX (128) +#define MZ_AES_PW_VERIFY_SIZE (2) +#define MZ_AES_AUTHCODE_SIZE (10) + +/***************************************************************************/ + +static mz_stream_vtbl mz_stream_wzaes_vtbl = { + mz_stream_wzaes_open, + mz_stream_wzaes_is_open, + mz_stream_wzaes_read, + mz_stream_wzaes_write, + mz_stream_wzaes_tell, + mz_stream_wzaes_seek, + mz_stream_wzaes_close, + mz_stream_wzaes_error, + mz_stream_wzaes_create, + mz_stream_wzaes_delete, + mz_stream_wzaes_get_prop_int64, + mz_stream_wzaes_set_prop_int64 +}; + +/***************************************************************************/ + +typedef struct mz_stream_wzaes_s { + mz_stream stream; + int32_t mode; + int32_t error; + int16_t initialized; + uint8_t buffer[UINT16_MAX]; + int64_t total_in; + int64_t max_total_in; + int64_t total_out; + int16_t encryption_mode; + const char *password; + void *aes; + uint32_t crypt_pos; + uint8_t crypt_block[MZ_AES_BLOCK_SIZE]; + void *hmac; + uint8_t nonce[MZ_AES_BLOCK_SIZE]; +} mz_stream_wzaes; + +/***************************************************************************/ + +int32_t mz_stream_wzaes_open(void *stream, const char *path, int32_t mode) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + uint16_t salt_length = 0; + uint16_t password_length = 0; + uint16_t key_length = 0; + uint8_t kbuf[2 * MZ_AES_KEY_LENGTH_MAX + MZ_AES_PW_VERIFY_SIZE]; + uint8_t verify[MZ_AES_PW_VERIFY_SIZE]; + uint8_t verify_expected[MZ_AES_PW_VERIFY_SIZE]; + uint8_t salt_value[MZ_AES_SALT_LENGTH_MAX]; + const char *password = path; + + wzaes->total_in = 0; + wzaes->total_out = 0; + wzaes->initialized = 0; + + if (mz_stream_is_open(wzaes->stream.base) != MZ_OK) + return MZ_OPEN_ERROR; + + if (password == NULL) + password = wzaes->password; + if (password == NULL) + return MZ_PARAM_ERROR; + password_length = (uint16_t)strlen(password); + if (password_length > MZ_AES_PW_LENGTH_MAX) + return MZ_PARAM_ERROR; + + if (wzaes->encryption_mode < 1 || wzaes->encryption_mode > 3) + return MZ_PARAM_ERROR; + + salt_length = MZ_AES_SALT_LENGTH(wzaes->encryption_mode); + + if (mode & MZ_OPEN_MODE_WRITE) { + mz_crypt_rand(salt_value, salt_length); + } else if (mode & MZ_OPEN_MODE_READ) { + if (mz_stream_read(wzaes->stream.base, salt_value, salt_length) != salt_length) + return MZ_READ_ERROR; + } + + key_length = MZ_AES_KEY_LENGTH(wzaes->encryption_mode); + + /* Derive the encryption and authentication keys and the password verifier */ + mz_crypt_pbkdf2((uint8_t *)password, password_length, salt_value, salt_length, + MZ_AES_KEYING_ITERATIONS, kbuf, 2 * key_length + MZ_AES_PW_VERIFY_SIZE); + + /* Initialize the encryption nonce and buffer pos */ + wzaes->crypt_pos = MZ_AES_BLOCK_SIZE; + memset(wzaes->nonce, 0, sizeof(wzaes->nonce)); + + /* Initialize for encryption using key 1 */ + mz_crypt_aes_reset(wzaes->aes); + mz_crypt_aes_set_mode(wzaes->aes, wzaes->encryption_mode); + mz_crypt_aes_set_encrypt_key(wzaes->aes, kbuf, key_length); + + /* Initialize for authentication using key 2 */ + mz_crypt_hmac_reset(wzaes->hmac); + mz_crypt_hmac_set_algorithm(wzaes->hmac, MZ_HASH_SHA1); + mz_crypt_hmac_init(wzaes->hmac, kbuf + key_length, key_length); + + memcpy(verify, kbuf + (2 * key_length), MZ_AES_PW_VERIFY_SIZE); + + if (mode & MZ_OPEN_MODE_WRITE) { + if (mz_stream_write(wzaes->stream.base, salt_value, salt_length) != salt_length) + return MZ_WRITE_ERROR; + + wzaes->total_out += salt_length; + + if (mz_stream_write(wzaes->stream.base, verify, MZ_AES_PW_VERIFY_SIZE) != MZ_AES_PW_VERIFY_SIZE) + return MZ_WRITE_ERROR; + + wzaes->total_out += MZ_AES_PW_VERIFY_SIZE; + } else if (mode & MZ_OPEN_MODE_READ) { + wzaes->total_in += salt_length; + + if (mz_stream_read(wzaes->stream.base, verify_expected, MZ_AES_PW_VERIFY_SIZE) != MZ_AES_PW_VERIFY_SIZE) + return MZ_READ_ERROR; + + wzaes->total_in += MZ_AES_PW_VERIFY_SIZE; + + if (memcmp(verify_expected, verify, MZ_AES_PW_VERIFY_SIZE) != 0) + return MZ_PASSWORD_ERROR; + } + + wzaes->mode = mode; + wzaes->initialized = 1; + + return MZ_OK; +} + +int32_t mz_stream_wzaes_is_open(void *stream) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + if (wzaes->initialized == 0) + return MZ_OPEN_ERROR; + return MZ_OK; +} + +static int32_t mz_stream_wzaes_ctr_encrypt(void *stream, uint8_t *buf, int32_t size) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + uint32_t pos = wzaes->crypt_pos; + uint32_t i = 0; + int32_t err = MZ_OK; + + while (i < (uint32_t)size) { + if (pos == MZ_AES_BLOCK_SIZE) { + uint32_t j = 0; + + /* Increment encryption nonce */ + while (j < 8 && !++wzaes->nonce[j]) + j += 1; + + /* Encrypt the nonce to form next xor buffer */ + memcpy(wzaes->crypt_block, wzaes->nonce, MZ_AES_BLOCK_SIZE); + mz_crypt_aes_encrypt(wzaes->aes, wzaes->crypt_block, sizeof(wzaes->crypt_block)); + pos = 0; + } + + buf[i++] ^= wzaes->crypt_block[pos++]; + } + + wzaes->crypt_pos = pos; + return err; +} + +int32_t mz_stream_wzaes_read(void *stream, void *buf, int32_t size) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + int64_t max_total_in = 0; + int32_t bytes_to_read = size; + int32_t read = 0; + + max_total_in = wzaes->max_total_in - MZ_AES_FOOTER_SIZE; + if ((int64_t)bytes_to_read > (max_total_in - wzaes->total_in)) + bytes_to_read = (int32_t)(max_total_in - wzaes->total_in); + + read = mz_stream_read(wzaes->stream.base, buf, bytes_to_read); + + if (read > 0) { + mz_crypt_hmac_update(wzaes->hmac, (uint8_t *)buf, read); + mz_stream_wzaes_ctr_encrypt(stream, (uint8_t *)buf, read); + + wzaes->total_in += read; + } + + return read; +} + +int32_t mz_stream_wzaes_write(void *stream, const void *buf, int32_t size) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + const uint8_t *buf_ptr = (const uint8_t *)buf; + int32_t bytes_to_write = sizeof(wzaes->buffer); + int32_t total_written = 0; + int32_t written = 0; + + if (size < 0) + return MZ_PARAM_ERROR; + + do { + if (bytes_to_write > (size - total_written)) + bytes_to_write = (size - total_written); + + memcpy(wzaes->buffer, buf_ptr, bytes_to_write); + buf_ptr += bytes_to_write; + + mz_stream_wzaes_ctr_encrypt(stream, (uint8_t *)wzaes->buffer, bytes_to_write); + mz_crypt_hmac_update(wzaes->hmac, wzaes->buffer, bytes_to_write); + + written = mz_stream_write(wzaes->stream.base, wzaes->buffer, bytes_to_write); + if (written < 0) + return written; + + total_written += written; + } while (total_written < size && written > 0); + + wzaes->total_out += total_written; + return total_written; +} + +int64_t mz_stream_wzaes_tell(void *stream) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + return mz_stream_tell(wzaes->stream.base); +} + +int32_t mz_stream_wzaes_seek(void *stream, int64_t offset, int32_t origin) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + return mz_stream_seek(wzaes->stream.base, offset, origin); +} + +int32_t mz_stream_wzaes_close(void *stream) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + uint8_t expected_hash[MZ_AES_AUTHCODE_SIZE]; + uint8_t computed_hash[MZ_HASH_SHA1_SIZE]; + + mz_crypt_hmac_end(wzaes->hmac, computed_hash, sizeof(computed_hash)); + + if (wzaes->mode & MZ_OPEN_MODE_WRITE) { + if (mz_stream_write(wzaes->stream.base, computed_hash, MZ_AES_AUTHCODE_SIZE) != MZ_AES_AUTHCODE_SIZE) + return MZ_WRITE_ERROR; + + wzaes->total_out += MZ_AES_AUTHCODE_SIZE; + } else if (wzaes->mode & MZ_OPEN_MODE_READ) { + if (mz_stream_read(wzaes->stream.base, expected_hash, MZ_AES_AUTHCODE_SIZE) != MZ_AES_AUTHCODE_SIZE) + return MZ_READ_ERROR; + + wzaes->total_in += MZ_AES_AUTHCODE_SIZE; + + /* If entire entry was not read this will fail */ + if (memcmp(computed_hash, expected_hash, MZ_AES_AUTHCODE_SIZE) != 0) + return MZ_CRC_ERROR; + } + + wzaes->initialized = 0; + return MZ_OK; +} + +int32_t mz_stream_wzaes_error(void *stream) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + return wzaes->error; +} + +void mz_stream_wzaes_set_password(void *stream, const char *password) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + wzaes->password = password; +} + +void mz_stream_wzaes_set_encryption_mode(void *stream, int16_t encryption_mode) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + wzaes->encryption_mode = encryption_mode; +} + +int32_t mz_stream_wzaes_get_prop_int64(void *stream, int32_t prop, int64_t *value) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + switch (prop) { + case MZ_STREAM_PROP_TOTAL_IN: + *value = wzaes->total_in; + break; + case MZ_STREAM_PROP_TOTAL_OUT: + *value = wzaes->total_out; + break; + case MZ_STREAM_PROP_TOTAL_IN_MAX: + *value = wzaes->max_total_in; + break; + case MZ_STREAM_PROP_HEADER_SIZE: + *value = MZ_AES_SALT_LENGTH((int64_t)wzaes->encryption_mode) + MZ_AES_PW_VERIFY_SIZE; + break; + case MZ_STREAM_PROP_FOOTER_SIZE: + *value = MZ_AES_AUTHCODE_SIZE; + break; + default: + return MZ_EXIST_ERROR; + } + return MZ_OK; +} + +int32_t mz_stream_wzaes_set_prop_int64(void *stream, int32_t prop, int64_t value) { + mz_stream_wzaes *wzaes = (mz_stream_wzaes *)stream; + switch (prop) { + case MZ_STREAM_PROP_TOTAL_IN_MAX: + wzaes->max_total_in = value; + break; + default: + return MZ_EXIST_ERROR; + } + return MZ_OK; +} + +void *mz_stream_wzaes_create(void **stream) { + mz_stream_wzaes *wzaes = NULL; + + wzaes = (mz_stream_wzaes *)MZ_ALLOC(sizeof(mz_stream_wzaes)); + if (wzaes != NULL) { + memset(wzaes, 0, sizeof(mz_stream_wzaes)); + wzaes->stream.vtbl = &mz_stream_wzaes_vtbl; + wzaes->encryption_mode = MZ_AES_ENCRYPTION_MODE_256; + + mz_crypt_hmac_create(&wzaes->hmac); + mz_crypt_aes_create(&wzaes->aes); + } + if (stream != NULL) + *stream = wzaes; + + return wzaes; +} + +void mz_stream_wzaes_delete(void **stream) { + mz_stream_wzaes *wzaes = NULL; + if (stream == NULL) + return; + wzaes = (mz_stream_wzaes *)*stream; + if (wzaes != NULL) { + mz_crypt_aes_delete(&wzaes->aes); + mz_crypt_hmac_delete(&wzaes->hmac); + MZ_FREE(wzaes); + } + *stream = NULL; +} + +void *mz_stream_wzaes_get_interface(void) { + return (void *)&mz_stream_wzaes_vtbl; +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_wzaes.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_wzaes.h new file mode 100644 index 0000000000000000000000000000000000000000..e27f11203f0e6c7464c56ab1c97fd26806359915 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_wzaes.h @@ -0,0 +1,46 @@ +/* mz_strm_wzaes.h -- Stream for WinZIP AES encryption + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_STREAM_WZAES_SHA1_H +#define MZ_STREAM_WZAES_SHA1_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +int32_t mz_stream_wzaes_open(void *stream, const char *filename, int32_t mode); +int32_t mz_stream_wzaes_is_open(void *stream); +int32_t mz_stream_wzaes_read(void *stream, void *buf, int32_t size); +int32_t mz_stream_wzaes_write(void *stream, const void *buf, int32_t size); +int64_t mz_stream_wzaes_tell(void *stream); +int32_t mz_stream_wzaes_seek(void *stream, int64_t offset, int32_t origin); +int32_t mz_stream_wzaes_close(void *stream); +int32_t mz_stream_wzaes_error(void *stream); + +void mz_stream_wzaes_set_password(void *stream, const char *password); +void mz_stream_wzaes_set_encryption_mode(void *stream, int16_t encryption_mode); + +int32_t mz_stream_wzaes_get_prop_int64(void *stream, int32_t prop, int64_t *value); +int32_t mz_stream_wzaes_set_prop_int64(void *stream, int32_t prop, int64_t value); + +void* mz_stream_wzaes_create(void **stream); +void mz_stream_wzaes_delete(void **stream); + +void* mz_stream_wzaes_get_interface(void); + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_zlib.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_zlib.c new file mode 100644 index 0000000000000000000000000000000000000000..e83bbac91a6f17a30bddef067958f0704ee3b76f --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_zlib.c @@ -0,0 +1,393 @@ +/* mz_strm_zlib.c -- Stream for zlib inflate/deflate + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + + +#include "mz.h" +#include "mz_strm.h" +#include "mz_strm_zlib.h" + +#include "zlib.h" +#if defined(ZLIBNG_VERNUM) && !defined(ZLIB_COMPAT) +# include "zlib-ng.h" +#endif + +/***************************************************************************/ + +#if defined(ZLIBNG_VERNUM) && !defined(ZLIB_COMPAT) +# define ZLIB_PREFIX(x) zng_ ## x + typedef zng_stream zlib_stream; +#else +# define ZLIB_PREFIX(x) x + typedef z_stream zlib_stream; +#endif + +#if !defined(DEF_MEM_LEVEL) +# if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +# else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +# endif +#endif + +/***************************************************************************/ + +static mz_stream_vtbl mz_stream_zlib_vtbl = { + mz_stream_zlib_open, + mz_stream_zlib_is_open, + mz_stream_zlib_read, + mz_stream_zlib_write, + mz_stream_zlib_tell, + mz_stream_zlib_seek, + mz_stream_zlib_close, + mz_stream_zlib_error, + mz_stream_zlib_create, + mz_stream_zlib_delete, + mz_stream_zlib_get_prop_int64, + mz_stream_zlib_set_prop_int64 +}; + +/***************************************************************************/ + +typedef struct mz_stream_zlib_s { + mz_stream stream; + zlib_stream zstream; + uint8_t buffer[INT16_MAX]; + int32_t buffer_len; + int64_t total_in; + int64_t total_out; + int64_t max_total_in; + int8_t initialized; + int16_t level; + int32_t window_bits; + int32_t mode; + int32_t error; +} mz_stream_zlib; + +/***************************************************************************/ + +int32_t mz_stream_zlib_open(void *stream, const char *path, int32_t mode) { + mz_stream_zlib *zlib = (mz_stream_zlib *)stream; + + MZ_UNUSED(path); + + zlib->zstream.data_type = Z_BINARY; + zlib->zstream.zalloc = Z_NULL; + zlib->zstream.zfree = Z_NULL; + zlib->zstream.opaque = Z_NULL; + zlib->zstream.total_in = 0; + zlib->zstream.total_out = 0; + + zlib->total_in = 0; + zlib->total_out = 0; + + if (mode & MZ_OPEN_MODE_WRITE) { +#ifdef MZ_ZIP_NO_COMPRESSION + return MZ_SUPPORT_ERROR; +#else + zlib->zstream.next_out = zlib->buffer; + zlib->zstream.avail_out = sizeof(zlib->buffer); + + zlib->error = ZLIB_PREFIX(deflateInit2)(&zlib->zstream, (int8_t)zlib->level, Z_DEFLATED, + zlib->window_bits, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); +#endif + } else if (mode & MZ_OPEN_MODE_READ) { +#ifdef MZ_ZIP_NO_DECOMPRESSION + return MZ_SUPPORT_ERROR; +#else + zlib->zstream.next_in = zlib->buffer; + zlib->zstream.avail_in = 0; + + zlib->error = ZLIB_PREFIX(inflateInit2)(&zlib->zstream, zlib->window_bits); +#endif + } + + if (zlib->error != Z_OK) + return MZ_OPEN_ERROR; + + zlib->initialized = 1; + zlib->mode = mode; + return MZ_OK; +} + +int32_t mz_stream_zlib_is_open(void *stream) { + mz_stream_zlib *zlib = (mz_stream_zlib *)stream; + if (zlib->initialized != 1) + return MZ_OPEN_ERROR; + return MZ_OK; +} + +int32_t mz_stream_zlib_read(void *stream, void *buf, int32_t size) { +#ifdef MZ_ZIP_NO_DECOMPRESSION + MZ_UNUSED(stream); + MZ_UNUSED(buf); + MZ_UNUSED(size); + return MZ_SUPPORT_ERROR; +#else + mz_stream_zlib *zlib = (mz_stream_zlib *)stream; + uint64_t total_in_before = 0; + uint64_t total_in_after = 0; + uint64_t total_out_before = 0; + uint64_t total_out_after = 0; + uint32_t total_in = 0; + uint32_t total_out = 0; + uint32_t in_bytes = 0; + uint32_t out_bytes = 0; + int32_t bytes_to_read = sizeof(zlib->buffer); + int32_t read = 0; + int32_t err = Z_OK; + + + zlib->zstream.next_out = (Bytef*)buf; + zlib->zstream.avail_out = (uInt)size; + + do { + if (zlib->zstream.avail_in == 0) { + if (zlib->max_total_in > 0) { + if ((int64_t)bytes_to_read > (zlib->max_total_in - zlib->total_in)) + bytes_to_read = (int32_t)(zlib->max_total_in - zlib->total_in); + } + + read = mz_stream_read(zlib->stream.base, zlib->buffer, bytes_to_read); + + if (read < 0) + return read; + + zlib->zstream.next_in = zlib->buffer; + zlib->zstream.avail_in = read; + } + + total_in_before = zlib->zstream.avail_in; + total_out_before = zlib->zstream.total_out; + + err = ZLIB_PREFIX(inflate)(&zlib->zstream, Z_SYNC_FLUSH); + if ((err >= Z_OK) && (zlib->zstream.msg != NULL)) { + zlib->error = Z_DATA_ERROR; + break; + } + + total_in_after = zlib->zstream.avail_in; + total_out_after = zlib->zstream.total_out; + + in_bytes = (uint32_t)(total_in_before - total_in_after); + out_bytes = (uint32_t)(total_out_after - total_out_before); + + total_in += in_bytes; + total_out += out_bytes; + + zlib->total_in += in_bytes; + zlib->total_out += out_bytes; + + if (err == Z_STREAM_END) + break; + if (err != Z_OK) { + zlib->error = err; + break; + } + } while (zlib->zstream.avail_out > 0); + + if (zlib->error != 0) { + /* Zlib errors are compatible with MZ */ + return zlib->error; + } + + return total_out; +#endif +} + +#ifndef MZ_ZIP_NO_COMPRESSION +static int32_t mz_stream_zlib_flush(void *stream) { + mz_stream_zlib *zlib = (mz_stream_zlib *)stream; + if (mz_stream_write(zlib->stream.base, zlib->buffer, zlib->buffer_len) != zlib->buffer_len) + return MZ_WRITE_ERROR; + return MZ_OK; +} + +static int32_t mz_stream_zlib_deflate(void *stream, int flush) { + mz_stream_zlib *zlib = (mz_stream_zlib *)stream; + uint64_t total_out_before = 0; + uint64_t total_out_after = 0; + int32_t out_bytes = 0; + int32_t err = Z_OK; + + + do { + if (zlib->zstream.avail_out == 0) { + err = mz_stream_zlib_flush(zlib); + if (err != MZ_OK) + return err; + + zlib->zstream.avail_out = sizeof(zlib->buffer); + zlib->zstream.next_out = zlib->buffer; + + zlib->buffer_len = 0; + } + + total_out_before = zlib->zstream.total_out; + err = ZLIB_PREFIX(deflate)(&zlib->zstream, flush); + total_out_after = zlib->zstream.total_out; + + out_bytes = (uint32_t)(total_out_after - total_out_before); + + zlib->buffer_len += out_bytes; + zlib->total_out += out_bytes; + + if (err == Z_STREAM_END) + break; + if (err != Z_OK) { + zlib->error = err; + return MZ_DATA_ERROR; + } + } while ((zlib->zstream.avail_in > 0) || (flush == Z_FINISH && err == Z_OK)); + + return MZ_OK; +} +#endif + +int32_t mz_stream_zlib_write(void *stream, const void *buf, int32_t size) { +#ifdef MZ_ZIP_NO_COMPRESSION + MZ_UNUSED(stream); + MZ_UNUSED(buf); + MZ_UNUSED(size); + return MZ_SUPPORT_ERROR; +#else + mz_stream_zlib *zlib = (mz_stream_zlib *)stream; + int32_t err = MZ_OK; + + zlib->zstream.next_in = (Bytef*)(intptr_t)buf; + zlib->zstream.avail_in = (uInt)size; + + err = mz_stream_zlib_deflate(stream, Z_NO_FLUSH); + if (err != MZ_OK) { + return err; + } + + zlib->total_in += size; + return size; +#endif +} + +int64_t mz_stream_zlib_tell(void *stream) { + MZ_UNUSED(stream); + + return MZ_TELL_ERROR; +} + +int32_t mz_stream_zlib_seek(void *stream, int64_t offset, int32_t origin) { + MZ_UNUSED(stream); + MZ_UNUSED(offset); + MZ_UNUSED(origin); + + return MZ_SEEK_ERROR; +} + +int32_t mz_stream_zlib_close(void *stream) { + mz_stream_zlib *zlib = (mz_stream_zlib *)stream; + + + if (zlib->mode & MZ_OPEN_MODE_WRITE) { +#ifdef MZ_ZIP_NO_COMPRESSION + return MZ_SUPPORT_ERROR; +#else + mz_stream_zlib_deflate(stream, Z_FINISH); + mz_stream_zlib_flush(stream); + + ZLIB_PREFIX(deflateEnd)(&zlib->zstream); +#endif + } else if (zlib->mode & MZ_OPEN_MODE_READ) { +#ifdef MZ_ZIP_NO_DECOMPRESSION + return MZ_SUPPORT_ERROR; +#else + ZLIB_PREFIX(inflateEnd)(&zlib->zstream); +#endif + } + + zlib->initialized = 0; + + if (zlib->error != Z_OK) + return MZ_CLOSE_ERROR; + return MZ_OK; +} + +int32_t mz_stream_zlib_error(void *stream) { + mz_stream_zlib *zlib = (mz_stream_zlib *)stream; + return zlib->error; +} + +int32_t mz_stream_zlib_get_prop_int64(void *stream, int32_t prop, int64_t *value) { + mz_stream_zlib *zlib = (mz_stream_zlib *)stream; + switch (prop) { + case MZ_STREAM_PROP_TOTAL_IN: + *value = zlib->total_in; + break; + case MZ_STREAM_PROP_TOTAL_IN_MAX: + *value = zlib->max_total_in; + break; + case MZ_STREAM_PROP_TOTAL_OUT: + *value = zlib->total_out; + break; + case MZ_STREAM_PROP_HEADER_SIZE: + *value = 0; + break; + case MZ_STREAM_PROP_COMPRESS_WINDOW: + *value = zlib->window_bits; + break; + default: + return MZ_EXIST_ERROR; + } + return MZ_OK; +} + +int32_t mz_stream_zlib_set_prop_int64(void *stream, int32_t prop, int64_t value) { + mz_stream_zlib *zlib = (mz_stream_zlib *)stream; + switch (prop) { + case MZ_STREAM_PROP_COMPRESS_LEVEL: + zlib->level = (int16_t)value; + break; + case MZ_STREAM_PROP_TOTAL_IN_MAX: + zlib->max_total_in = value; + break; + case MZ_STREAM_PROP_COMPRESS_WINDOW: + zlib->window_bits = (int32_t)value; + break; + default: + return MZ_EXIST_ERROR; + } + return MZ_OK; +} + +void *mz_stream_zlib_create(void **stream) { + mz_stream_zlib *zlib = NULL; + + zlib = (mz_stream_zlib *)MZ_ALLOC(sizeof(mz_stream_zlib)); + if (zlib != NULL) { + memset(zlib, 0, sizeof(mz_stream_zlib)); + zlib->stream.vtbl = &mz_stream_zlib_vtbl; + zlib->level = Z_DEFAULT_COMPRESSION; + zlib->window_bits = -MAX_WBITS; + } + if (stream != NULL) + *stream = zlib; + + return zlib; +} + +void mz_stream_zlib_delete(void **stream) { + mz_stream_zlib *zlib = NULL; + if (stream == NULL) + return; + zlib = (mz_stream_zlib *)*stream; + if (zlib != NULL) + MZ_FREE(zlib); + *stream = NULL; +} + +void *mz_stream_zlib_get_interface(void) { + return (void *)&mz_stream_zlib_vtbl; +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_zlib.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_zlib.h new file mode 100644 index 0000000000000000000000000000000000000000..47f74804fb4563f5dbe6e639eecc448147ee44a4 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_strm_zlib.h @@ -0,0 +1,43 @@ +/* mz_strm_zlib.h -- Stream for zlib inflate/deflate + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_STREAM_ZLIB_H +#define MZ_STREAM_ZLIB_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +int32_t mz_stream_zlib_open(void *stream, const char *filename, int32_t mode); +int32_t mz_stream_zlib_is_open(void *stream); +int32_t mz_stream_zlib_read(void *stream, void *buf, int32_t size); +int32_t mz_stream_zlib_write(void *stream, const void *buf, int32_t size); +int64_t mz_stream_zlib_tell(void *stream); +int32_t mz_stream_zlib_seek(void *stream, int64_t offset, int32_t origin); +int32_t mz_stream_zlib_close(void *stream); +int32_t mz_stream_zlib_error(void *stream); + +int32_t mz_stream_zlib_get_prop_int64(void *stream, int32_t prop, int64_t *value); +int32_t mz_stream_zlib_set_prop_int64(void *stream, int32_t prop, int64_t value); + +void* mz_stream_zlib_create(void **stream); +void mz_stream_zlib_delete(void **stream); + +void* mz_stream_zlib_get_interface(void); + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_zip.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_zip.c new file mode 100644 index 0000000000000000000000000000000000000000..cc4f57d0b38cc41d4e5983f477467b0ee388cd60 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_zip.c @@ -0,0 +1,2771 @@ +/* zip.c -- Zip manipulation + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + Copyright (C) 2009-2010 Mathias Svensson + Modifications for Zip64 support + http://result42.com + Copyright (C) 2007-2008 Even Rouault + Modifications of Unzip for Zip64 + Copyright (C) 1998-2010 Gilles Vollant + https://www.winimage.com/zLibDll/minizip.html + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + + +#include "mz.h" +#include "mz_crypt.h" +#include "mz_strm.h" +#ifdef HAVE_BZIP2 +# include "mz_strm_bzip.h" +#endif +#ifdef HAVE_LIBCOMP +# include "mz_strm_libcomp.h" +#endif +#ifdef HAVE_LZMA +# include "mz_strm_lzma.h" +#endif +#include "mz_strm_mem.h" +#ifdef HAVE_PKCRYPT +# include "mz_strm_pkcrypt.h" +#endif +#ifdef HAVE_WZAES +# include "mz_strm_wzaes.h" +#endif +#ifdef HAVE_ZLIB +# include "mz_strm_zlib.h" +#endif +#ifdef HAVE_ZSTD +# include "mz_strm_zstd.h" +#endif + +#include "mz_zip.h" + +#include /* tolower */ +#include /* snprintf */ + +#if defined(_MSC_VER) || defined(__MINGW32__) +# define localtime_r(t1,t2) (localtime_s(t2,t1) == 0 ? t1 : NULL) +#endif +#if defined(_MSC_VER) && (_MSC_VER < 1900) +# define snprintf _snprintf +#endif + +/***************************************************************************/ + +#define MZ_ZIP_MAGIC_LOCALHEADER (0x04034b50) +#define MZ_ZIP_MAGIC_LOCALHEADERU8 { 0x50, 0x4b, 0x03, 0x04 } +#define MZ_ZIP_MAGIC_CENTRALHEADER (0x02014b50) +#define MZ_ZIP_MAGIC_CENTRALHEADERU8 { 0x50, 0x4b, 0x01, 0x02 } +#define MZ_ZIP_MAGIC_ENDHEADER (0x06054b50) +#define MZ_ZIP_MAGIC_ENDHEADERU8 { 0x50, 0x4b, 0x05, 0x06 } +#define MZ_ZIP_MAGIC_ENDHEADER64 (0x06064b50) +#define MZ_ZIP_MAGIC_ENDLOCHEADER64 (0x07064b50) +#define MZ_ZIP_MAGIC_DATADESCRIPTOR (0x08074b50) +#define MZ_ZIP_MAGIC_DATADESCRIPTORU8 { 0x50, 0x4b, 0x07, 0x08 } + +#define MZ_ZIP_SIZE_LD_ITEM (30) +#define MZ_ZIP_SIZE_CD_ITEM (46) +#define MZ_ZIP_SIZE_CD_LOCATOR64 (20) +#define MZ_ZIP_SIZE_MAX_DATA_DESCRIPTOR (24) + +#define MZ_ZIP_OFFSET_CRC_SIZES (14) +#define MZ_ZIP_UNCOMPR_SIZE64_CUSHION (2 * 1024 * 1024) + +#ifndef MZ_ZIP_EOCD_MAX_BACK +#define MZ_ZIP_EOCD_MAX_BACK (1 << 20) +#endif + +/***************************************************************************/ + +typedef struct mz_zip_s { + mz_zip_file file_info; + mz_zip_file local_file_info; + + void *stream; /* main stream */ + void *cd_stream; /* pointer to the stream with the cd */ + void *cd_mem_stream; /* memory stream for central directory */ + void *compress_stream; /* compression stream */ + void *crypt_stream; /* encryption stream */ + void *file_info_stream; /* memory stream for storing file info */ + void *local_file_info_stream; /* memory stream for storing local file info */ + + int32_t open_mode; + uint8_t recover; + uint8_t data_descriptor; + + uint32_t disk_number_with_cd; /* number of the disk with the central dir */ + int64_t disk_offset_shift; /* correction for zips that have wrong offset start of cd */ + + int64_t cd_start_pos; /* pos of the first file in the central dir stream */ + int64_t cd_current_pos; /* pos of the current file in the central dir */ + int64_t cd_offset; /* offset of start of central directory */ + int64_t cd_size; /* size of the central directory */ + uint32_t cd_signature; /* signature of central directory */ + + uint8_t entry_scanned; /* entry header information read ok */ + uint8_t entry_opened; /* entry is open for read/write */ + uint8_t entry_raw; /* entry opened with raw mode */ + uint32_t entry_crc32; /* entry crc32 */ + + uint64_t number_entry; + + uint16_t version_madeby; + char *comment; +} mz_zip; + +/***************************************************************************/ + +#if 0 +# define mz_zip_print printf +#else +# define mz_zip_print(fmt,...) +#endif + +/***************************************************************************/ + +/* Locate the end of central directory */ +static int32_t mz_zip_search_eocd(void *stream, int64_t *central_pos) { + int64_t file_size = 0; + int64_t max_back = MZ_ZIP_EOCD_MAX_BACK; + uint8_t find[4] = MZ_ZIP_MAGIC_ENDHEADERU8; + int32_t err = MZ_OK; + + err = mz_stream_seek(stream, 0, MZ_SEEK_END); + if (err != MZ_OK) + return err; + + file_size = mz_stream_tell(stream); + + if (max_back <= 0 || max_back > file_size) + max_back = file_size; + + return mz_stream_find_reverse(stream, (const void *)find, sizeof(find), max_back, central_pos); +} + +/* Locate the end of central directory 64 of a zip file */ +static int32_t mz_zip_search_zip64_eocd(void *stream, const int64_t end_central_offset, int64_t *central_pos) { + int64_t offset = 0; + uint32_t value32 = 0; + int32_t err = MZ_OK; + + + *central_pos = 0; + + /* Zip64 end of central directory locator */ + err = mz_stream_seek(stream, end_central_offset - MZ_ZIP_SIZE_CD_LOCATOR64, MZ_SEEK_SET); + /* Read locator signature */ + if (err == MZ_OK) { + err = mz_stream_read_uint32(stream, &value32); + if (value32 != MZ_ZIP_MAGIC_ENDLOCHEADER64) + err = MZ_FORMAT_ERROR; + } + /* Number of the disk with the start of the zip64 end of central directory */ + if (err == MZ_OK) + err = mz_stream_read_uint32(stream, &value32); + /* Relative offset of the zip64 end of central directory record8 */ + if (err == MZ_OK) + err = mz_stream_read_uint64(stream, (uint64_t *)&offset); + /* Total number of disks */ + if (err == MZ_OK) + err = mz_stream_read_uint32(stream, &value32); + /* Goto end of central directory record */ + if (err == MZ_OK) + err = mz_stream_seek(stream, (int64_t)offset, MZ_SEEK_SET); + /* The signature */ + if (err == MZ_OK) { + err = mz_stream_read_uint32(stream, &value32); + if (value32 != MZ_ZIP_MAGIC_ENDHEADER64) + err = MZ_FORMAT_ERROR; + } + + if (err == MZ_OK) + *central_pos = offset; + + return err; +} + +/* Get PKWARE traditional encryption verifier */ +static uint16_t mz_zip_get_pk_verify(uint32_t dos_date, uint64_t crc, uint16_t flag) +{ + /* Info-ZIP modification to ZipCrypto format: if bit 3 of the general + * purpose bit flag is set, it uses high byte of 16-bit File Time. */ + if (flag & MZ_ZIP_FLAG_DATA_DESCRIPTOR) + return ((dos_date >> 16) & 0xff) << 8 | ((dos_date >> 8) & 0xff); + return ((crc >> 16) & 0xff) << 8 | ((crc >> 24) & 0xff); +} + +/* Get info about the current file in the zip file */ +static int32_t mz_zip_entry_read_header(void *stream, uint8_t local, mz_zip_file *file_info, void *file_extra_stream) { + uint64_t ntfs_time = 0; + uint32_t reserved = 0; + uint32_t magic = 0; + uint32_t dos_date = 0; + uint32_t field_pos = 0; + uint16_t field_type = 0; + uint16_t field_length = 0; + uint32_t field_length_read = 0; + uint16_t ntfs_attrib_id = 0; + uint16_t ntfs_attrib_size = 0; + uint16_t linkname_size; + uint16_t value16 = 0; + uint32_t value32 = 0; + int64_t extrafield_pos = 0; + int64_t comment_pos = 0; + int64_t linkname_pos = 0; + int64_t saved_pos = 0; + int32_t err = MZ_OK; + char *linkname = NULL; + + + memset(file_info, 0, sizeof(mz_zip_file)); + + /* Check the magic */ + err = mz_stream_read_uint32(stream, &magic); + if (err == MZ_END_OF_STREAM) + err = MZ_END_OF_LIST; + else if (magic == MZ_ZIP_MAGIC_ENDHEADER || magic == MZ_ZIP_MAGIC_ENDHEADER64) + err = MZ_END_OF_LIST; + else if ((local) && (magic != MZ_ZIP_MAGIC_LOCALHEADER)) + err = MZ_FORMAT_ERROR; + else if ((!local) && (magic != MZ_ZIP_MAGIC_CENTRALHEADER)) + err = MZ_FORMAT_ERROR; + + /* Read header fields */ + if (err == MZ_OK) { + if (!local) + err = mz_stream_read_uint16(stream, &file_info->version_madeby); + if (err == MZ_OK) + err = mz_stream_read_uint16(stream, &file_info->version_needed); + if (err == MZ_OK) + err = mz_stream_read_uint16(stream, &file_info->flag); + if (err == MZ_OK) + err = mz_stream_read_uint16(stream, &file_info->compression_method); + if (err == MZ_OK) { + err = mz_stream_read_uint32(stream, &dos_date); + file_info->modified_date = mz_zip_dosdate_to_time_t(dos_date); + } + if (err == MZ_OK) + err = mz_stream_read_uint32(stream, &file_info->crc); +#ifdef HAVE_PKCRYPT + if (err == MZ_OK && file_info->flag & MZ_ZIP_FLAG_ENCRYPTED) { + /* Use dos_date from header instead of derived from time in zip extensions */ + file_info->pk_verify = mz_zip_get_pk_verify(dos_date, file_info->crc, file_info->flag); + } +#endif + if (err == MZ_OK) { + err = mz_stream_read_uint32(stream, &value32); + file_info->compressed_size = value32; + } + if (err == MZ_OK) { + err = mz_stream_read_uint32(stream, &value32); + file_info->uncompressed_size = value32; + } + if (err == MZ_OK) + err = mz_stream_read_uint16(stream, &file_info->filename_size); + if (err == MZ_OK) + err = mz_stream_read_uint16(stream, &file_info->extrafield_size); + if (!local) { + if (err == MZ_OK) + err = mz_stream_read_uint16(stream, &file_info->comment_size); + if (err == MZ_OK) { + err = mz_stream_read_uint16(stream, &value16); + file_info->disk_number = value16; + } + if (err == MZ_OK) + err = mz_stream_read_uint16(stream, &file_info->internal_fa); + if (err == MZ_OK) + err = mz_stream_read_uint32(stream, &file_info->external_fa); + if (err == MZ_OK) { + err = mz_stream_read_uint32(stream, &value32); + file_info->disk_offset = value32; + } + } + } + + if (err == MZ_OK) + err = mz_stream_seek(file_extra_stream, 0, MZ_SEEK_SET); + + /* Copy variable length data to memory stream for later retrieval */ + if ((err == MZ_OK) && (file_info->filename_size > 0)) + err = mz_stream_copy(file_extra_stream, stream, file_info->filename_size); + mz_stream_write_uint8(file_extra_stream, 0); + extrafield_pos = mz_stream_tell(file_extra_stream); + + if ((err == MZ_OK) && (file_info->extrafield_size > 0)) + err = mz_stream_copy(file_extra_stream, stream, file_info->extrafield_size); + mz_stream_write_uint8(file_extra_stream, 0); + + comment_pos = mz_stream_tell(file_extra_stream); + if ((err == MZ_OK) && (file_info->comment_size > 0)) + err = mz_stream_copy(file_extra_stream, stream, file_info->comment_size); + mz_stream_write_uint8(file_extra_stream, 0); + + linkname_pos = mz_stream_tell(file_extra_stream); + /* Overwrite if we encounter UNIX1 extra block */ + mz_stream_write_uint8(file_extra_stream, 0); + + if ((err == MZ_OK) && (file_info->extrafield_size > 0)) { + /* Seek to and parse the extra field */ + err = mz_stream_seek(file_extra_stream, extrafield_pos, MZ_SEEK_SET); + + while ((err == MZ_OK) && (field_pos + 4 <= file_info->extrafield_size)) { + err = mz_zip_extrafield_read(file_extra_stream, &field_type, &field_length); + if (err != MZ_OK) + break; + field_pos += 4; + + /* Don't allow field length to exceed size of remaining extrafield */ + if (field_length > (file_info->extrafield_size - field_pos)) + field_length = (uint16_t)(file_info->extrafield_size - field_pos); + + /* Read ZIP64 extra field */ + if ((field_type == MZ_ZIP_EXTENSION_ZIP64) && (field_length >= 8)) { + if ((err == MZ_OK) && (file_info->uncompressed_size == UINT32_MAX)) { + err = mz_stream_read_int64(file_extra_stream, &file_info->uncompressed_size); + if (file_info->uncompressed_size < 0) + err = MZ_FORMAT_ERROR; + } + if ((err == MZ_OK) && (file_info->compressed_size == UINT32_MAX)) { + err = mz_stream_read_int64(file_extra_stream, &file_info->compressed_size); + if (file_info->compressed_size < 0) + err = MZ_FORMAT_ERROR; + } + if ((err == MZ_OK) && (file_info->disk_offset == UINT32_MAX)) { + err = mz_stream_read_int64(file_extra_stream, &file_info->disk_offset); + if (file_info->disk_offset < 0) + err = MZ_FORMAT_ERROR; + } + if ((err == MZ_OK) && (file_info->disk_number == UINT16_MAX)) + err = mz_stream_read_uint32(file_extra_stream, &file_info->disk_number); + } + /* Read NTFS extra field */ + else if ((field_type == MZ_ZIP_EXTENSION_NTFS) && (field_length > 4)) { + if (err == MZ_OK) + err = mz_stream_read_uint32(file_extra_stream, &reserved); + field_length_read = 4; + + while ((err == MZ_OK) && (field_length_read + 4 <= field_length)) { + err = mz_stream_read_uint16(file_extra_stream, &ntfs_attrib_id); + if (err == MZ_OK) + err = mz_stream_read_uint16(file_extra_stream, &ntfs_attrib_size); + field_length_read += 4; + + if ((err == MZ_OK) && (ntfs_attrib_id == 0x01) && (ntfs_attrib_size == 24)) { + err = mz_stream_read_uint64(file_extra_stream, &ntfs_time); + mz_zip_ntfs_to_unix_time(ntfs_time, &file_info->modified_date); + + if (err == MZ_OK) { + err = mz_stream_read_uint64(file_extra_stream, &ntfs_time); + mz_zip_ntfs_to_unix_time(ntfs_time, &file_info->accessed_date); + } + if (err == MZ_OK) { + err = mz_stream_read_uint64(file_extra_stream, &ntfs_time); + mz_zip_ntfs_to_unix_time(ntfs_time, &file_info->creation_date); + } + } else if ((err == MZ_OK) && (field_length_read + ntfs_attrib_size <= field_length)) { + err = mz_stream_seek(file_extra_stream, ntfs_attrib_size, MZ_SEEK_CUR); + } + + field_length_read += ntfs_attrib_size; + } + } + /* Read UNIX1 extra field */ + else if ((field_type == MZ_ZIP_EXTENSION_UNIX1) && (field_length >= 12)) { + if (err == MZ_OK) { + err = mz_stream_read_uint32(file_extra_stream, &value32); + if (err == MZ_OK && file_info->accessed_date == 0) + file_info->accessed_date = value32; + } + if (err == MZ_OK) { + err = mz_stream_read_uint32(file_extra_stream, &value32); + if (err == MZ_OK && file_info->modified_date == 0) + file_info->modified_date = value32; + } + if (err == MZ_OK) + err = mz_stream_read_uint16(file_extra_stream, &value16); /* User id */ + if (err == MZ_OK) + err = mz_stream_read_uint16(file_extra_stream, &value16); /* Group id */ + + /* Copy linkname to end of file extra stream so we can return null + terminated string */ + linkname_size = field_length - 12; + if ((err == MZ_OK) && (linkname_size > 0)) { + linkname = (char *)MZ_ALLOC(linkname_size); + if (linkname != NULL) { + if (mz_stream_read(file_extra_stream, linkname, linkname_size) != linkname_size) + err = MZ_READ_ERROR; + if (err == MZ_OK) { + saved_pos = mz_stream_tell(file_extra_stream); + + mz_stream_seek(file_extra_stream, linkname_pos, MZ_SEEK_SET); + mz_stream_write(file_extra_stream, linkname, linkname_size); + mz_stream_write_uint8(file_extra_stream, 0); + + mz_stream_seek(file_extra_stream, saved_pos, MZ_SEEK_SET); + } + MZ_FREE(linkname); + } + } + } +#ifdef HAVE_WZAES + /* Read AES extra field */ + else if ((field_type == MZ_ZIP_EXTENSION_AES) && (field_length == 7)) { + uint8_t value8 = 0; + /* Verify version info */ + err = mz_stream_read_uint16(file_extra_stream, &value16); + /* Support AE-1 and AE-2 */ + if (value16 != 1 && value16 != 2) + err = MZ_FORMAT_ERROR; + file_info->aes_version = value16; + if (err == MZ_OK) + err = mz_stream_read_uint8(file_extra_stream, &value8); + if ((char)value8 != 'A') + err = MZ_FORMAT_ERROR; + if (err == MZ_OK) + err = mz_stream_read_uint8(file_extra_stream, &value8); + if ((char)value8 != 'E') + err = MZ_FORMAT_ERROR; + /* Get AES encryption strength and actual compression method */ + if (err == MZ_OK) { + err = mz_stream_read_uint8(file_extra_stream, &value8); + file_info->aes_encryption_mode = value8; + } + if (err == MZ_OK) { + err = mz_stream_read_uint16(file_extra_stream, &value16); + file_info->compression_method = value16; + } + } +#endif + else if (field_length > 0) { + err = mz_stream_seek(file_extra_stream, field_length, MZ_SEEK_CUR); + } + + field_pos += field_length; + } + } + + /* Get pointers to variable length data */ + mz_stream_mem_get_buffer(file_extra_stream, (const void **)&file_info->filename); + mz_stream_mem_get_buffer_at(file_extra_stream, extrafield_pos, (const void **)&file_info->extrafield); + mz_stream_mem_get_buffer_at(file_extra_stream, comment_pos, (const void **)&file_info->comment); + mz_stream_mem_get_buffer_at(file_extra_stream, linkname_pos, (const void **)&file_info->linkname); + + /* Set to empty string just in-case */ + if (file_info->filename == NULL) + file_info->filename = ""; + if (file_info->extrafield == NULL) + file_info->extrafield_size = 0; + if (file_info->comment == NULL) + file_info->comment = ""; + if (file_info->linkname == NULL) + file_info->linkname = ""; + + if (err == MZ_OK) { + mz_zip_print("Zip - Entry - Read header - %s (local %" PRId8 ")\n", + file_info->filename, local); + mz_zip_print("Zip - Entry - Read header compress (ucs %" PRId64 " cs %" PRId64 " crc 0x%08" PRIx32 ")\n", + file_info->uncompressed_size, file_info->compressed_size, file_info->crc); + if (!local) { + mz_zip_print("Zip - Entry - Read header disk (disk %" PRIu32 " offset %" PRId64 ")\n", + file_info->disk_number, file_info->disk_offset); + } + mz_zip_print("Zip - Entry - Read header variable (fnl %" PRId32 " efs %" PRId32 " cms %" PRId32 ")\n", + file_info->filename_size, file_info->extrafield_size, file_info->comment_size); + } + + return err; +} + +static int32_t mz_zip_entry_read_descriptor(void *stream, uint8_t zip64, uint32_t *crc32, int64_t *compressed_size, int64_t *uncompressed_size) { + uint32_t value32 = 0; + int64_t value64 = 0; + int32_t err = MZ_OK; + + + err = mz_stream_read_uint32(stream, &value32); + if (value32 != MZ_ZIP_MAGIC_DATADESCRIPTOR) + err = MZ_FORMAT_ERROR; + if (err == MZ_OK) + err = mz_stream_read_uint32(stream, &value32); + if ((err == MZ_OK) && (crc32 != NULL)) + *crc32 = value32; + if (err == MZ_OK) { + /* If zip 64 extension is enabled then read as 8 byte */ + if (!zip64) { + err = mz_stream_read_uint32(stream, &value32); + value64 = value32; + } else { + err = mz_stream_read_int64(stream, &value64); + if (value64 < 0) + err = MZ_FORMAT_ERROR; + } + if ((err == MZ_OK) && (compressed_size != NULL)) + *compressed_size = value64; + } + if (err == MZ_OK) { + if (!zip64) { + err = mz_stream_read_uint32(stream, &value32); + value64 = value32; + } else { + err = mz_stream_read_int64(stream, &value64); + if (value64 < 0) + err = MZ_FORMAT_ERROR; + } + if ((err == MZ_OK) && (uncompressed_size != NULL)) + *uncompressed_size = value64; + } + + return err; +} + +static int32_t mz_zip_entry_write_crc_sizes(void *stream, uint8_t zip64, uint8_t mask, mz_zip_file *file_info) { + int32_t err = MZ_OK; + + if (mask) + err = mz_stream_write_uint32(stream, 0); + else + err = mz_stream_write_uint32(stream, file_info->crc); /* crc */ + + /* For backwards-compatibility with older zip applications we set all sizes to UINT32_MAX + * when zip64 is needed, instead of only setting sizes larger than UINT32_MAX. */ + + if (err == MZ_OK) { + if (zip64) /* compr size */ + err = mz_stream_write_uint32(stream, UINT32_MAX); + else + err = mz_stream_write_uint32(stream, (uint32_t)file_info->compressed_size); + } + if (err == MZ_OK) { + if (mask) /* uncompr size */ + err = mz_stream_write_uint32(stream, 0); + else if (zip64) + err = mz_stream_write_uint32(stream, UINT32_MAX); + else + err = mz_stream_write_uint32(stream, (uint32_t)file_info->uncompressed_size); + } + return err; +} + +static int32_t mz_zip_entry_needs_zip64(mz_zip_file *file_info, uint8_t local, uint8_t *zip64) { + uint32_t max_uncompressed_size = UINT32_MAX; + uint8_t needs_zip64 = 0; + + if (zip64 == NULL) + return MZ_PARAM_ERROR; + + *zip64 = 0; + + if (local) { + /* At local header we might not know yet whether compressed size will overflow unsigned + 32-bit integer which might happen for high entropy data so we give it some cushion */ + + max_uncompressed_size -= MZ_ZIP_UNCOMPR_SIZE64_CUSHION; + } + + needs_zip64 = (file_info->uncompressed_size >= max_uncompressed_size) || + (file_info->compressed_size >= UINT32_MAX); + + if (!local) { + /* Disk offset and number only used in central directory header */ + needs_zip64 |= (file_info->disk_offset >= UINT32_MAX) || + (file_info->disk_number >= UINT16_MAX); + } + + if (file_info->zip64 == MZ_ZIP64_AUTO) { + /* If uncompressed size is unknown, assume zip64 for 64-bit data descriptors */ + if (local && file_info->uncompressed_size == 0) { + /* Don't use zip64 for local header directory entries */ + if (mz_zip_attrib_is_dir(file_info->external_fa, file_info->version_madeby) != MZ_OK) { + *zip64 = 1; + } + } + *zip64 |= needs_zip64; + } else if (file_info->zip64 == MZ_ZIP64_FORCE) { + *zip64 = 1; + } else if (file_info->zip64 == MZ_ZIP64_DISABLE) { + /* Zip64 extension is required to zip file */ + if (needs_zip64) + return MZ_PARAM_ERROR; + } + + return MZ_OK; +} + +static int32_t mz_zip_entry_write_header(void *stream, uint8_t local, mz_zip_file *file_info) { + uint64_t ntfs_time = 0; + uint32_t reserved = 0; + uint32_t dos_date = 0; + uint16_t extrafield_size = 0; + uint16_t field_type = 0; + uint16_t field_length = 0; + uint16_t field_length_zip64 = 0; + uint16_t field_length_ntfs = 0; + uint16_t field_length_aes = 0; + uint16_t field_length_unix1 = 0; + uint16_t filename_size = 0; + uint16_t filename_length = 0; + uint16_t linkname_size = 0; + uint16_t version_needed = 0; + int32_t comment_size = 0; + int32_t err = MZ_OK; + int32_t err_mem = MZ_OK; + uint8_t zip64 = 0; + uint8_t skip_aes = 0; + uint8_t mask = 0; + uint8_t write_end_slash = 0; + const char *filename = NULL; + char masked_name[64]; + void *file_extra_stream = NULL; + + if (file_info == NULL) + return MZ_PARAM_ERROR; + + if ((local) && (file_info->flag & MZ_ZIP_FLAG_MASK_LOCAL_INFO)) + mask = 1; + + /* Determine if zip64 extra field is necessary */ + err = mz_zip_entry_needs_zip64(file_info, local, &zip64); + if (err != MZ_OK) + return err; + + /* Start calculating extra field sizes */ + if (zip64) { + /* Both compressed and uncompressed sizes must be included (at least in local header) */ + field_length_zip64 = 8 + 8; + if ((!local) && (file_info->disk_offset >= UINT32_MAX)) + field_length_zip64 += 8; + + extrafield_size += 4; + extrafield_size += field_length_zip64; + } + + /* Calculate extra field size and check for duplicates */ + if (file_info->extrafield_size > 0) { + mz_stream_mem_create(&file_extra_stream); + mz_stream_mem_set_buffer(file_extra_stream, (void *)file_info->extrafield, + file_info->extrafield_size); + + do { + err_mem = mz_stream_read_uint16(file_extra_stream, &field_type); + if (err_mem == MZ_OK) + err_mem = mz_stream_read_uint16(file_extra_stream, &field_length); + if (err_mem != MZ_OK) + break; + + /* Prefer incoming aes extensions over ours */ + if (field_type == MZ_ZIP_EXTENSION_AES) + skip_aes = 1; + + /* Prefer our zip64, ntfs, unix1 extension over incoming */ + if (field_type != MZ_ZIP_EXTENSION_ZIP64 && field_type != MZ_ZIP_EXTENSION_NTFS && + field_type != MZ_ZIP_EXTENSION_UNIX1) + extrafield_size += 4 + field_length; + + if (err_mem == MZ_OK) + err_mem = mz_stream_seek(file_extra_stream, field_length, MZ_SEEK_CUR); + } while (err_mem == MZ_OK); + } + +#ifdef HAVE_WZAES + if (!skip_aes) { + if ((file_info->flag & MZ_ZIP_FLAG_ENCRYPTED) && (file_info->aes_version)) { + field_length_aes = 1 + 1 + 1 + 2 + 2; + extrafield_size += 4 + field_length_aes; + } + } +#else + MZ_UNUSED(field_length_aes); + MZ_UNUSED(skip_aes); +#endif + /* NTFS timestamps */ + if ((file_info->modified_date != 0) && + (file_info->accessed_date != 0) && + (file_info->creation_date != 0) && (!mask)) { + field_length_ntfs = 8 + 8 + 8 + 4 + 2 + 2; + extrafield_size += 4 + field_length_ntfs; + } + + /* Unix1 symbolic links */ + if (file_info->linkname != NULL && *file_info->linkname != 0) { + linkname_size = (uint16_t)strlen(file_info->linkname); + field_length_unix1 = 12 + linkname_size; + extrafield_size += 4 + field_length_unix1; + } + + if (local) + err = mz_stream_write_uint32(stream, MZ_ZIP_MAGIC_LOCALHEADER); + else { + err = mz_stream_write_uint32(stream, MZ_ZIP_MAGIC_CENTRALHEADER); + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, file_info->version_madeby); + } + + /* Calculate version needed to extract */ + if (err == MZ_OK) { + version_needed = file_info->version_needed; + if (version_needed == 0) { + version_needed = 20; + if (zip64) + version_needed = 45; +#ifdef HAVE_WZAES + if ((file_info->flag & MZ_ZIP_FLAG_ENCRYPTED) && (file_info->aes_version)) + version_needed = 51; +#endif +#if defined(HAVE_LZMA) || defined(HAVE_LIBCOMP) + if ((file_info->compression_method == MZ_COMPRESS_METHOD_LZMA) || + (file_info->compression_method == MZ_COMPRESS_METHOD_XZ)) + version_needed = 63; +#endif + } + err = mz_stream_write_uint16(stream, version_needed); + } + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, file_info->flag); + if (err == MZ_OK) { +#ifdef HAVE_WZAES + if ((file_info->flag & MZ_ZIP_FLAG_ENCRYPTED) && (file_info->aes_version)) + err = mz_stream_write_uint16(stream, MZ_COMPRESS_METHOD_AES); + else +#endif + err = mz_stream_write_uint16(stream, file_info->compression_method); + } + if (err == MZ_OK) { + if (file_info->modified_date != 0 && !mask) + dos_date = mz_zip_time_t_to_dos_date(file_info->modified_date); + err = mz_stream_write_uint32(stream, dos_date); + } + + if (err == MZ_OK) + err = mz_zip_entry_write_crc_sizes(stream, zip64, mask, file_info); + + if (mask) { + snprintf(masked_name, sizeof(masked_name), "%" PRIx32 "_%" PRIx64, + file_info->disk_number, file_info->disk_offset); + filename = masked_name; + } else { + filename = file_info->filename; + } + + filename_length = (uint16_t)strlen(filename); + filename_size += filename_length; + + if ((mz_zip_attrib_is_dir(file_info->external_fa, file_info->version_madeby) == MZ_OK) && + ((filename[filename_length - 1] != '/') && (filename[filename_length - 1] != '\\'))) { + filename_size += 1; + write_end_slash = 1; + } + + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, filename_size); + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, extrafield_size); + + if (!local) { + if (file_info->comment != NULL) { + comment_size = (int32_t)strlen(file_info->comment); + if (comment_size > UINT16_MAX) + comment_size = UINT16_MAX; + } + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, (uint16_t)comment_size); + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, (uint16_t)file_info->disk_number); + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, file_info->internal_fa); + if (err == MZ_OK) + err = mz_stream_write_uint32(stream, file_info->external_fa); + if (err == MZ_OK) { + if (file_info->disk_offset >= UINT32_MAX) + err = mz_stream_write_uint32(stream, UINT32_MAX); + else + err = mz_stream_write_uint32(stream, (uint32_t)file_info->disk_offset); + } + } + + if (err == MZ_OK) { + if (mz_stream_write(stream, filename, filename_length) != filename_length) + err = MZ_WRITE_ERROR; + + /* Ensure that directories have a slash appended to them for compatibility */ + if (err == MZ_OK && write_end_slash) + err = mz_stream_write_uint8(stream, '/'); + } + + /* Write ZIP64 extra field first so we can update sizes later if data descriptor not used */ + if ((err == MZ_OK) && (zip64)) { + err = mz_zip_extrafield_write(stream, MZ_ZIP_EXTENSION_ZIP64, field_length_zip64); + if (err == MZ_OK) { + if (mask) + err = mz_stream_write_int64(stream, 0); + else + err = mz_stream_write_int64(stream, file_info->uncompressed_size); + } + if (err == MZ_OK) + err = mz_stream_write_int64(stream, file_info->compressed_size); + if ((err == MZ_OK) && (!local) && (file_info->disk_offset >= UINT32_MAX)) + err = mz_stream_write_int64(stream, file_info->disk_offset); + if ((err == MZ_OK) && (!local) && (file_info->disk_number >= UINT16_MAX)) + err = mz_stream_write_uint32(stream, file_info->disk_number); + } + /* Write NTFS extra field */ + if ((err == MZ_OK) && (field_length_ntfs > 0)) { + err = mz_zip_extrafield_write(stream, MZ_ZIP_EXTENSION_NTFS, field_length_ntfs); + if (err == MZ_OK) + err = mz_stream_write_uint32(stream, reserved); + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, 0x01); + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, field_length_ntfs - 8); + if (err == MZ_OK) { + mz_zip_unix_to_ntfs_time(file_info->modified_date, &ntfs_time); + err = mz_stream_write_uint64(stream, ntfs_time); + } + if (err == MZ_OK) { + mz_zip_unix_to_ntfs_time(file_info->accessed_date, &ntfs_time); + err = mz_stream_write_uint64(stream, ntfs_time); + } + if (err == MZ_OK) { + mz_zip_unix_to_ntfs_time(file_info->creation_date, &ntfs_time); + err = mz_stream_write_uint64(stream, ntfs_time); + } + } + /* Write UNIX extra block extra field */ + if ((err == MZ_OK) && (field_length_unix1 > 0)) { + err = mz_zip_extrafield_write(stream, MZ_ZIP_EXTENSION_UNIX1, field_length_unix1); + if (err == MZ_OK) + err = mz_stream_write_uint32(stream, (uint32_t)file_info->accessed_date); + if (err == MZ_OK) + err = mz_stream_write_uint32(stream, (uint32_t)file_info->modified_date); + if (err == MZ_OK) /* User id */ + err = mz_stream_write_uint16(stream, 0); + if (err == MZ_OK) /* Group id */ + err = mz_stream_write_uint16(stream, 0); + if (err == MZ_OK && linkname_size > 0) { + if (mz_stream_write(stream, file_info->linkname, linkname_size) != linkname_size) + err = MZ_WRITE_ERROR; + } + } +#ifdef HAVE_WZAES + /* Write AES extra field */ + if ((err == MZ_OK) && (!skip_aes) && (file_info->flag & MZ_ZIP_FLAG_ENCRYPTED) && (file_info->aes_version)) { + err = mz_zip_extrafield_write(stream, MZ_ZIP_EXTENSION_AES, field_length_aes); + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, file_info->aes_version); + if (err == MZ_OK) + err = mz_stream_write_uint8(stream, 'A'); + if (err == MZ_OK) + err = mz_stream_write_uint8(stream, 'E'); + if (err == MZ_OK) + err = mz_stream_write_uint8(stream, file_info->aes_encryption_mode); + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, file_info->compression_method); + } +#endif + + if (file_info->extrafield_size > 0) { + err_mem = mz_stream_mem_seek(file_extra_stream, 0, MZ_SEEK_SET); + while (err == MZ_OK && err_mem == MZ_OK) { + err_mem = mz_stream_read_uint16(file_extra_stream, &field_type); + if (err_mem == MZ_OK) + err_mem = mz_stream_read_uint16(file_extra_stream, &field_length); + if (err_mem != MZ_OK) + break; + + /* Prefer our zip 64, ntfs, unix1 extensions over incoming */ + if (field_type == MZ_ZIP_EXTENSION_ZIP64 || field_type == MZ_ZIP_EXTENSION_NTFS || + field_type == MZ_ZIP_EXTENSION_UNIX1) { + err_mem = mz_stream_seek(file_extra_stream, field_length, MZ_SEEK_CUR); + continue; + } + + err = mz_stream_write_uint16(stream, field_type); + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, field_length); + if (err == MZ_OK) + err = mz_stream_copy(stream, file_extra_stream, field_length); + } + + mz_stream_mem_delete(&file_extra_stream); + } + + if ((err == MZ_OK) && (!local) && (file_info->comment != NULL)) { + if (mz_stream_write(stream, file_info->comment, file_info->comment_size) != file_info->comment_size) + err = MZ_WRITE_ERROR; + } + + return err; +} + +static int32_t mz_zip_entry_write_descriptor(void *stream, uint8_t zip64, uint32_t crc32, int64_t compressed_size, int64_t uncompressed_size) { + int32_t err = MZ_OK; + + err = mz_stream_write_uint32(stream, MZ_ZIP_MAGIC_DATADESCRIPTOR); + if (err == MZ_OK) + err = mz_stream_write_uint32(stream, crc32); + + /* Store data descriptor as 8 bytes if zip 64 extension enabled */ + if (err == MZ_OK) { + /* Zip 64 extension is enabled when uncompressed size is > UINT32_MAX */ + if (!zip64) + err = mz_stream_write_uint32(stream, (uint32_t)compressed_size); + else + err = mz_stream_write_int64(stream, compressed_size); + } + if (err == MZ_OK) { + if (!zip64) + err = mz_stream_write_uint32(stream, (uint32_t)uncompressed_size); + else + err = mz_stream_write_int64(stream, uncompressed_size); + } + + return err; +} + +static int32_t mz_zip_read_cd(void *handle) { + mz_zip *zip = (mz_zip *)handle; + uint64_t number_entry_cd64 = 0; + uint64_t number_entry_cd = 0; + int64_t eocd_pos = 0; + int64_t eocd_pos64 = 0; + int64_t value64i = 0; + uint16_t value16 = 0; + uint32_t value32 = 0; + uint64_t value64 = 0; + uint16_t comment_size = 0; + int32_t comment_read = 0; + int32_t err = MZ_OK; + + + if (zip == NULL) + return MZ_PARAM_ERROR; + + /* Read and cache central directory records */ + err = mz_zip_search_eocd(zip->stream, &eocd_pos); + if (err == MZ_OK) { + /* The signature, already checked */ + err = mz_stream_read_uint32(zip->stream, &value32); + /* Number of this disk */ + if (err == MZ_OK) + err = mz_stream_read_uint16(zip->stream, &value16); + /* Number of the disk with the start of the central directory */ + if (err == MZ_OK) + err = mz_stream_read_uint16(zip->stream, &value16); + zip->disk_number_with_cd = value16; + /* Total number of entries in the central dir on this disk */ + if (err == MZ_OK) + err = mz_stream_read_uint16(zip->stream, &value16); + zip->number_entry = value16; + /* Total number of entries in the central dir */ + if (err == MZ_OK) + err = mz_stream_read_uint16(zip->stream, &value16); + number_entry_cd = value16; + if (number_entry_cd != zip->number_entry) + err = MZ_FORMAT_ERROR; + /* Size of the central directory */ + if (err == MZ_OK) + err = mz_stream_read_uint32(zip->stream, &value32); + if (err == MZ_OK) + zip->cd_size = value32; + /* Offset of start of central directory with respect to the starting disk number */ + if (err == MZ_OK) + err = mz_stream_read_uint32(zip->stream, &value32); + if (err == MZ_OK) + zip->cd_offset = value32; + /* Zip file global comment length */ + if (err == MZ_OK) + err = mz_stream_read_uint16(zip->stream, &comment_size); + if ((err == MZ_OK) && (comment_size > 0)) { + zip->comment = (char *)MZ_ALLOC(comment_size + 1); + if (zip->comment != NULL) { + comment_read = mz_stream_read(zip->stream, zip->comment, comment_size); + /* Don't fail if incorrect comment length read, not critical */ + if (comment_read < 0) + comment_read = 0; + zip->comment[comment_read] = 0; + } + } + + if ((err == MZ_OK) && ((number_entry_cd == UINT16_MAX) || (zip->cd_offset == UINT32_MAX))) { + /* Format should be Zip64, as the central directory or file size is too large */ + if (mz_zip_search_zip64_eocd(zip->stream, eocd_pos, &eocd_pos64) == MZ_OK) { + eocd_pos = eocd_pos64; + + err = mz_stream_seek(zip->stream, eocd_pos, MZ_SEEK_SET); + /* The signature, already checked */ + if (err == MZ_OK) + err = mz_stream_read_uint32(zip->stream, &value32); + /* Size of zip64 end of central directory record */ + if (err == MZ_OK) + err = mz_stream_read_uint64(zip->stream, &value64); + /* Version made by */ + if (err == MZ_OK) + err = mz_stream_read_uint16(zip->stream, &zip->version_madeby); + /* Version needed to extract */ + if (err == MZ_OK) + err = mz_stream_read_uint16(zip->stream, &value16); + /* Number of this disk */ + if (err == MZ_OK) + err = mz_stream_read_uint32(zip->stream, &value32); + /* Number of the disk with the start of the central directory */ + if (err == MZ_OK) + err = mz_stream_read_uint32(zip->stream, &zip->disk_number_with_cd); + /* Total number of entries in the central directory on this disk */ + if (err == MZ_OK) + err = mz_stream_read_uint64(zip->stream, &zip->number_entry); + /* Total number of entries in the central directory */ + if (err == MZ_OK) + err = mz_stream_read_uint64(zip->stream, &number_entry_cd64); + if (zip->number_entry != number_entry_cd64) + err = MZ_FORMAT_ERROR; + /* Size of the central directory */ + if (err == MZ_OK) { + err = mz_stream_read_int64(zip->stream, &zip->cd_size); + if (zip->cd_size < 0) + err = MZ_FORMAT_ERROR; + } + /* Offset of start of central directory with respect to the starting disk number */ + if (err == MZ_OK) { + err = mz_stream_read_int64(zip->stream, &zip->cd_offset); + if (zip->cd_offset < 0) + err = MZ_FORMAT_ERROR; + } + } else if ((zip->number_entry == UINT16_MAX) || (number_entry_cd != zip->number_entry) || + (zip->cd_size == UINT16_MAX) || (zip->cd_offset == UINT32_MAX)) { + err = MZ_FORMAT_ERROR; + } + } + } + + if (err == MZ_OK) { + mz_zip_print("Zip - Read cd (disk %" PRId32 " entries %" PRId64 " offset %" PRId64 " size %" PRId64 ")\n", + zip->disk_number_with_cd, zip->number_entry, zip->cd_offset, zip->cd_size); + + /* Verify central directory signature exists at offset */ + err = mz_stream_seek(zip->stream, zip->cd_offset, MZ_SEEK_SET); + if (err == MZ_OK) + err = mz_stream_read_uint32(zip->stream, &zip->cd_signature); + if ((err == MZ_OK) && (zip->cd_signature != MZ_ZIP_MAGIC_CENTRALHEADER)) { + /* If cd exists in large file and no zip-64 support, error for recover */ + if (eocd_pos > UINT32_MAX && eocd_pos64 == 0) + err = MZ_FORMAT_ERROR; + /* If cd not found attempt to seek backward to find it */ + if (err == MZ_OK) + err = mz_stream_seek(zip->stream, eocd_pos - zip->cd_size, MZ_SEEK_SET); + if (err == MZ_OK) + err = mz_stream_read_uint32(zip->stream, &zip->cd_signature); + if ((err == MZ_OK) && (zip->cd_signature == MZ_ZIP_MAGIC_CENTRALHEADER)) { + + /* If found compensate for incorrect locations */ + value64i = zip->cd_offset; + zip->cd_offset = eocd_pos - zip->cd_size; + /* Assume disk has prepended data */ + zip->disk_offset_shift = zip->cd_offset - value64i; + } + } + } + + if (err == MZ_OK) { + if (eocd_pos < zip->cd_offset) { + /* End of central dir should always come after central dir */ + err = MZ_FORMAT_ERROR; + } else if ((uint64_t)eocd_pos < (uint64_t)zip->cd_offset + zip->cd_size) { + /* Truncate size of cd if incorrect size or offset provided */ + zip->cd_size = eocd_pos - zip->cd_offset; + } + } + + return err; +} + +static int32_t mz_zip_write_cd(void *handle) { + mz_zip *zip = (mz_zip *)handle; + int64_t zip64_eocd_pos_inzip = 0; + int64_t disk_number = 0; + int64_t disk_size = 0; + int32_t comment_size = 0; + int32_t err = MZ_OK; + + + if (zip == NULL) + return MZ_PARAM_ERROR; + + if (mz_stream_get_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, &disk_number) == MZ_OK) + zip->disk_number_with_cd = (uint32_t)disk_number; + if (mz_stream_get_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_SIZE, &disk_size) == MZ_OK && disk_size > 0) + zip->disk_number_with_cd += 1; + mz_stream_set_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, -1); + if ((zip->disk_number_with_cd > 0) && (zip->open_mode & MZ_OPEN_MODE_APPEND)) { + // Overwrite existing central directory if using split disks + mz_stream_seek(zip->stream, 0, MZ_SEEK_SET); + } + + zip->cd_offset = mz_stream_tell(zip->stream); + mz_stream_seek(zip->cd_mem_stream, 0, MZ_SEEK_END); + zip->cd_size = (uint32_t)mz_stream_tell(zip->cd_mem_stream); + mz_stream_seek(zip->cd_mem_stream, 0, MZ_SEEK_SET); + + err = mz_stream_copy(zip->stream, zip->cd_mem_stream, (int32_t)zip->cd_size); + + mz_zip_print("Zip - Write cd (disk %" PRId32 " entries %" PRId64 " offset %" PRId64 " size %" PRId64 ")\n", + zip->disk_number_with_cd, zip->number_entry, zip->cd_offset, zip->cd_size); + + if (zip->cd_size == 0 && zip->number_entry > 0) { + // Zip does not contain central directory, open with recovery option + return MZ_FORMAT_ERROR; + } + + /* Write the ZIP64 central directory header */ + if (zip->cd_offset >= UINT32_MAX || zip->number_entry >= UINT16_MAX) { + zip64_eocd_pos_inzip = mz_stream_tell(zip->stream); + + err = mz_stream_write_uint32(zip->stream, MZ_ZIP_MAGIC_ENDHEADER64); + + /* Size of this 'zip64 end of central directory' */ + if (err == MZ_OK) + err = mz_stream_write_uint64(zip->stream, (uint64_t)44); + /* Version made by */ + if (err == MZ_OK) + err = mz_stream_write_uint16(zip->stream, zip->version_madeby); + /* Version needed */ + if (err == MZ_OK) + err = mz_stream_write_uint16(zip->stream, (uint16_t)45); + /* Number of this disk */ + if (err == MZ_OK) + err = mz_stream_write_uint32(zip->stream, zip->disk_number_with_cd); + /* Number of the disk with the start of the central directory */ + if (err == MZ_OK) + err = mz_stream_write_uint32(zip->stream, zip->disk_number_with_cd); + /* Total number of entries in the central dir on this disk */ + if (err == MZ_OK) + err = mz_stream_write_uint64(zip->stream, zip->number_entry); + /* Total number of entries in the central dir */ + if (err == MZ_OK) + err = mz_stream_write_uint64(zip->stream, zip->number_entry); + /* Size of the central directory */ + if (err == MZ_OK) + err = mz_stream_write_int64(zip->stream, zip->cd_size); + /* Offset of start of central directory with respect to the starting disk number */ + if (err == MZ_OK) + err = mz_stream_write_int64(zip->stream, zip->cd_offset); + if (err == MZ_OK) + err = mz_stream_write_uint32(zip->stream, MZ_ZIP_MAGIC_ENDLOCHEADER64); + + /* Number of the disk with the start of the central directory */ + if (err == MZ_OK) + err = mz_stream_write_uint32(zip->stream, zip->disk_number_with_cd); + /* Relative offset to the end of zip64 central directory */ + if (err == MZ_OK) + err = mz_stream_write_int64(zip->stream, zip64_eocd_pos_inzip); + /* Number of the disk with the start of the central directory */ + if (err == MZ_OK) + err = mz_stream_write_uint32(zip->stream, zip->disk_number_with_cd + 1); + } + + /* Write the central directory header */ + + /* Signature */ + if (err == MZ_OK) + err = mz_stream_write_uint32(zip->stream, MZ_ZIP_MAGIC_ENDHEADER); + /* Number of this disk */ + if (err == MZ_OK) + err = mz_stream_write_uint16(zip->stream, (uint16_t)zip->disk_number_with_cd); + /* Number of the disk with the start of the central directory */ + if (err == MZ_OK) + err = mz_stream_write_uint16(zip->stream, (uint16_t)zip->disk_number_with_cd); + /* Total number of entries in the central dir on this disk */ + if (err == MZ_OK) { + if (zip->number_entry >= UINT16_MAX) + err = mz_stream_write_uint16(zip->stream, UINT16_MAX); + else + err = mz_stream_write_uint16(zip->stream, (uint16_t)zip->number_entry); + } + /* Total number of entries in the central dir */ + if (err == MZ_OK) { + if (zip->number_entry >= UINT16_MAX) + err = mz_stream_write_uint16(zip->stream, UINT16_MAX); + else + err = mz_stream_write_uint16(zip->stream, (uint16_t)zip->number_entry); + } + /* Size of the central directory */ + if (err == MZ_OK) + err = mz_stream_write_uint32(zip->stream, (uint32_t)zip->cd_size); + /* Offset of start of central directory with respect to the starting disk number */ + if (err == MZ_OK) { + if (zip->cd_offset >= UINT32_MAX) + err = mz_stream_write_uint32(zip->stream, UINT32_MAX); + else + err = mz_stream_write_uint32(zip->stream, (uint32_t)zip->cd_offset); + } + + /* Write global comment */ + if (zip->comment != NULL) { + comment_size = (int32_t)strlen(zip->comment); + if (comment_size > UINT16_MAX) + comment_size = UINT16_MAX; + } + if (err == MZ_OK) + err = mz_stream_write_uint16(zip->stream, (uint16_t)comment_size); + if (err == MZ_OK) { + if (mz_stream_write(zip->stream, zip->comment, comment_size) != comment_size) + err = MZ_READ_ERROR; + } + return err; +} + +static int32_t mz_zip_recover_cd(void *handle) { + mz_zip *zip = (mz_zip *)handle; + mz_zip_file local_file_info; + void *local_file_info_stream = NULL; + void *cd_mem_stream = NULL; + uint64_t number_entry = 0; + int64_t descriptor_pos = 0; + int64_t next_header_pos = 0; + int64_t disk_offset = 0; + int64_t disk_number = 0; + int64_t compressed_pos = 0; + int64_t compressed_end_pos = 0; + int64_t compressed_size = 0; + int64_t uncompressed_size = 0; + uint8_t descriptor_magic[4] = MZ_ZIP_MAGIC_DATADESCRIPTORU8; + uint8_t local_header_magic[4] = MZ_ZIP_MAGIC_LOCALHEADERU8; + uint8_t central_header_magic[4] = MZ_ZIP_MAGIC_CENTRALHEADERU8; + uint32_t crc32 = 0; + int32_t disk_number_with_cd = 0; + int32_t err = MZ_OK; + uint8_t zip64 = 0; + uint8_t eof = 0; + + + mz_zip_print("Zip - Recover - Start\n"); + + mz_zip_get_cd_mem_stream(handle, &cd_mem_stream); + + /* Determine if we are on a split disk or not */ + mz_stream_set_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, 0); + if (mz_stream_tell(zip->stream) < 0) { + mz_stream_set_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, -1); + mz_stream_seek(zip->stream, 0, MZ_SEEK_SET); + } else + disk_number_with_cd = 1; + + if (mz_stream_is_open(cd_mem_stream) != MZ_OK) + err = mz_stream_mem_open(cd_mem_stream, NULL, MZ_OPEN_MODE_CREATE); + + mz_stream_mem_create(&local_file_info_stream); + mz_stream_mem_open(local_file_info_stream, NULL, MZ_OPEN_MODE_CREATE); + + if (err == MZ_OK) { + err = mz_stream_find(zip->stream, (const void *)local_header_magic, sizeof(local_header_magic), + INT64_MAX, &next_header_pos); + } + + while (err == MZ_OK && !eof) { + /* Get current offset and disk number for central dir record */ + disk_offset = mz_stream_tell(zip->stream); + mz_stream_get_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, &disk_number); + + /* Read local headers */ + memset(&local_file_info, 0, sizeof(local_file_info)); + err = mz_zip_entry_read_header(zip->stream, 1, &local_file_info, local_file_info_stream); + if (err != MZ_OK) + break; + + local_file_info.disk_offset = disk_offset; + if (disk_number < 0) + disk_number = 0; + local_file_info.disk_number = (uint32_t)disk_number; + + compressed_pos = mz_stream_tell(zip->stream); + + if ((err == MZ_OK) && (local_file_info.compressed_size > 0)) { + mz_stream_seek(zip->stream, local_file_info.compressed_size, MZ_SEEK_CUR); + } + + for (;;) { + /* Search for the next local header */ + err = mz_stream_find(zip->stream, (const void *)local_header_magic, sizeof(local_header_magic), + INT64_MAX, &next_header_pos); + + if (err == MZ_EXIST_ERROR) { + mz_stream_seek(zip->stream, compressed_pos, MZ_SEEK_SET); + + /* Search for central dir if no local header found */ + err = mz_stream_find(zip->stream, (const void *)central_header_magic, sizeof(central_header_magic), + INT64_MAX, &next_header_pos); + + if (err == MZ_EXIST_ERROR) { + /* Get end of stream if no central header found */ + mz_stream_seek(zip->stream, 0, MZ_SEEK_END); + next_header_pos = mz_stream_tell(zip->stream); + } + + eof = 1; + } + + if (local_file_info.flag & MZ_ZIP_FLAG_DATA_DESCRIPTOR || local_file_info.compressed_size == 0) { + /* Search backwards for the descriptor, seeking too far back will be incorrect if compressed size is small */ + err = mz_stream_find_reverse(zip->stream, (const void *)descriptor_magic, sizeof(descriptor_magic), + MZ_ZIP_SIZE_MAX_DATA_DESCRIPTOR, &descriptor_pos); + if (err == MZ_OK) { + if (mz_zip_extrafield_contains(local_file_info.extrafield, + local_file_info.extrafield_size, MZ_ZIP_EXTENSION_ZIP64, NULL) == MZ_OK) + zip64 = 1; + + err = mz_zip_entry_read_descriptor(zip->stream, zip64, &crc32, + &compressed_size, &uncompressed_size); + + if (err == MZ_OK) { + if (local_file_info.crc == 0) + local_file_info.crc = crc32; + if (local_file_info.compressed_size == 0) + local_file_info.compressed_size = compressed_size; + if (local_file_info.uncompressed_size == 0) + local_file_info.uncompressed_size = uncompressed_size; + } + + compressed_end_pos = descriptor_pos; + } else if (eof) { + compressed_end_pos = next_header_pos; + } else if (local_file_info.flag & MZ_ZIP_FLAG_DATA_DESCRIPTOR) { + /* Wrong local file entry found, keep searching */ + next_header_pos += 1; + mz_stream_seek(zip->stream, next_header_pos, MZ_SEEK_SET); + continue; + } + } else { + compressed_end_pos = next_header_pos; + } + + break; + } + + compressed_size = compressed_end_pos - compressed_pos; + + if (compressed_size > UINT32_MAX) { + /* Update sizes if 4GB file is written with no ZIP64 support */ + if (local_file_info.uncompressed_size < UINT32_MAX) { + local_file_info.compressed_size = compressed_size; + local_file_info.uncompressed_size = 0; + } + } + + mz_zip_print("Zip - Recover - Entry %s (csize %" PRId64 " usize %" PRId64 " flags 0x%" PRIx16 ")\n", + local_file_info.filename, local_file_info.compressed_size, local_file_info.uncompressed_size, + local_file_info.flag); + + /* Rewrite central dir with local headers and offsets */ + err = mz_zip_entry_write_header(cd_mem_stream, 0, &local_file_info); + if (err == MZ_OK) + number_entry += 1; + + err = mz_stream_seek(zip->stream, next_header_pos, MZ_SEEK_SET); + } + + mz_stream_mem_delete(&local_file_info_stream); + + mz_zip_print("Zip - Recover - Complete (cddisk %" PRId32 " entries %" PRId64 ")\n", + disk_number_with_cd, number_entry); + + if (number_entry == 0) + return err; + + /* Set new upper seek boundary for central dir mem stream */ + disk_offset = mz_stream_tell(cd_mem_stream); + mz_stream_mem_set_buffer_limit(cd_mem_stream, (int32_t)disk_offset); + + /* Set new central directory info */ + mz_zip_set_cd_stream(handle, 0, cd_mem_stream); + mz_zip_set_number_entry(handle, number_entry); + mz_zip_set_disk_number_with_cd(handle, disk_number_with_cd); + + return MZ_OK; +} + +void *mz_zip_create(void **handle) { + mz_zip *zip = NULL; + + zip = (mz_zip *)MZ_ALLOC(sizeof(mz_zip)); + if (zip != NULL) { + memset(zip, 0, sizeof(mz_zip)); + zip->data_descriptor = 1; + } + if (handle != NULL) + *handle = zip; + + return zip; +} + +void mz_zip_delete(void **handle) { + mz_zip *zip = NULL; + if (handle == NULL) + return; + zip = (mz_zip *)*handle; + if (zip != NULL) { + MZ_FREE(zip); + } + *handle = NULL; +} + +int32_t mz_zip_open(void *handle, void *stream, int32_t mode) { + mz_zip *zip = (mz_zip *)handle; + int32_t err = MZ_OK; + + + if (zip == NULL) + return MZ_PARAM_ERROR; + + mz_zip_print("Zip - Open\n"); + + zip->stream = stream; + + mz_stream_mem_create(&zip->cd_mem_stream); + + if (mode & MZ_OPEN_MODE_WRITE) { + mz_stream_mem_open(zip->cd_mem_stream, NULL, MZ_OPEN_MODE_CREATE); + zip->cd_stream = zip->cd_mem_stream; + } else { + zip->cd_stream = stream; + } + + if ((mode & MZ_OPEN_MODE_READ) || (mode & MZ_OPEN_MODE_APPEND)) { + if ((mode & MZ_OPEN_MODE_CREATE) == 0) { + err = mz_zip_read_cd(zip); + if (err != MZ_OK) { + mz_zip_print("Zip - Error detected reading cd (%" PRId32 ")\n", err); + if (zip->recover && mz_zip_recover_cd(zip) == MZ_OK) + err = MZ_OK; + } + } + + if ((err == MZ_OK) && (mode & MZ_OPEN_MODE_APPEND)) { + if (zip->cd_size > 0) { + /* Store central directory in memory */ + err = mz_stream_seek(zip->stream, zip->cd_offset, MZ_SEEK_SET); + if (err == MZ_OK) + err = mz_stream_copy(zip->cd_mem_stream, zip->stream, (int32_t)zip->cd_size); + if (err == MZ_OK) + err = mz_stream_seek(zip->stream, zip->cd_offset, MZ_SEEK_SET); + } else { + if (zip->cd_signature == MZ_ZIP_MAGIC_ENDHEADER) { + /* If tiny zip then overwrite end header */ + err = mz_stream_seek(zip->stream, zip->cd_offset, MZ_SEEK_SET); + } else { + /* If no central directory, append new zip to end of file */ + err = mz_stream_seek(zip->stream, 0, MZ_SEEK_END); + } + } + + if (zip->disk_number_with_cd > 0) { + /* Move to last disk to begin appending */ + mz_stream_set_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, zip->disk_number_with_cd - 1); + } + } else { + zip->cd_start_pos = zip->cd_offset; + } + } + + if (err != MZ_OK) { + mz_zip_close(zip); + return err; + } + + /* Memory streams used to store variable length file info data */ + mz_stream_mem_create(&zip->file_info_stream); + mz_stream_mem_open(zip->file_info_stream, NULL, MZ_OPEN_MODE_CREATE); + + mz_stream_mem_create(&zip->local_file_info_stream); + mz_stream_mem_open(zip->local_file_info_stream, NULL, MZ_OPEN_MODE_CREATE); + + zip->open_mode = mode; + + return err; +} + +int32_t mz_zip_close(void *handle) { + mz_zip *zip = (mz_zip *)handle; + int32_t err = MZ_OK; + + if (zip == NULL) + return MZ_PARAM_ERROR; + + mz_zip_print("Zip - Close\n"); + + if (mz_zip_entry_is_open(handle) == MZ_OK) + err = mz_zip_entry_close(handle); + + if ((err == MZ_OK) && (zip->open_mode & MZ_OPEN_MODE_WRITE)) + err = mz_zip_write_cd(handle); + + if (zip->cd_mem_stream != NULL) { + mz_stream_close(zip->cd_mem_stream); + mz_stream_delete(&zip->cd_mem_stream); + } + + if (zip->file_info_stream != NULL) { + mz_stream_mem_close(zip->file_info_stream); + mz_stream_mem_delete(&zip->file_info_stream); + } + if (zip->local_file_info_stream != NULL) { + mz_stream_mem_close(zip->local_file_info_stream); + mz_stream_mem_delete(&zip->local_file_info_stream); + } + + if (zip->comment) { + MZ_FREE(zip->comment); + zip->comment = NULL; + } + + zip->stream = NULL; + zip->cd_stream = NULL; + + return err; +} + +int32_t mz_zip_get_comment(void *handle, const char **comment) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL || comment == NULL) + return MZ_PARAM_ERROR; + if (zip->comment == NULL) + return MZ_EXIST_ERROR; + *comment = zip->comment; + return MZ_OK; +} + +int32_t mz_zip_set_comment(void *handle, const char *comment) { + mz_zip *zip = (mz_zip *)handle; + int32_t comment_size = 0; + if (zip == NULL || comment == NULL) + return MZ_PARAM_ERROR; + if (zip->comment != NULL) + MZ_FREE(zip->comment); + comment_size = (int32_t)strlen(comment); + if (comment_size > UINT16_MAX) + return MZ_PARAM_ERROR; + zip->comment = (char *)MZ_ALLOC(comment_size+1); + if (zip->comment == NULL) + return MZ_MEM_ERROR; + memset(zip->comment, 0, comment_size+1); + strncpy(zip->comment, comment, comment_size); + return MZ_OK; +} + +int32_t mz_zip_get_version_madeby(void *handle, uint16_t *version_madeby) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL || version_madeby == NULL) + return MZ_PARAM_ERROR; + *version_madeby = zip->version_madeby; + return MZ_OK; +} + +int32_t mz_zip_set_version_madeby(void *handle, uint16_t version_madeby) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL) + return MZ_PARAM_ERROR; + zip->version_madeby = version_madeby; + return MZ_OK; +} + +int32_t mz_zip_set_recover(void *handle, uint8_t recover) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL) + return MZ_PARAM_ERROR; + zip->recover = recover; + return MZ_OK; +} + +int32_t mz_zip_set_data_descriptor(void *handle, uint8_t data_descriptor) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL) + return MZ_PARAM_ERROR; + zip->data_descriptor = data_descriptor; + return MZ_OK; +} + +int32_t mz_zip_get_stream(void *handle, void **stream) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL || stream == NULL) + return MZ_PARAM_ERROR; + *stream = zip->stream; + if (*stream == NULL) + return MZ_EXIST_ERROR; + return MZ_OK; +} + +int32_t mz_zip_set_cd_stream(void *handle, int64_t cd_start_pos, void *cd_stream) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL || cd_stream == NULL) + return MZ_PARAM_ERROR; + zip->cd_offset = 0; + zip->cd_stream = cd_stream; + zip->cd_start_pos = cd_start_pos; + return MZ_OK; +} + +int32_t mz_zip_get_cd_mem_stream(void *handle, void **cd_mem_stream) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL || cd_mem_stream == NULL) + return MZ_PARAM_ERROR; + *cd_mem_stream = zip->cd_mem_stream; + if (*cd_mem_stream == NULL) + return MZ_EXIST_ERROR; + return MZ_OK; +} + +int32_t mz_zip_set_number_entry(void *handle, uint64_t number_entry) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL) + return MZ_PARAM_ERROR; + zip->number_entry = number_entry; + return MZ_OK; +} + +int32_t mz_zip_get_number_entry(void *handle, uint64_t *number_entry) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL || number_entry == NULL) + return MZ_PARAM_ERROR; + *number_entry = zip->number_entry; + return MZ_OK; +} + +int32_t mz_zip_set_disk_number_with_cd(void *handle, uint32_t disk_number_with_cd) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL) + return MZ_PARAM_ERROR; + zip->disk_number_with_cd = disk_number_with_cd; + return MZ_OK; +} + +int32_t mz_zip_get_disk_number_with_cd(void *handle, uint32_t *disk_number_with_cd) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL || disk_number_with_cd == NULL) + return MZ_PARAM_ERROR; + *disk_number_with_cd = zip->disk_number_with_cd; + return MZ_OK; +} + +static int32_t mz_zip_entry_close_int(void *handle) { + mz_zip *zip = (mz_zip *)handle; + + if (zip->crypt_stream != NULL) + mz_stream_delete(&zip->crypt_stream); + zip->crypt_stream = NULL; + if (zip->compress_stream != NULL) + mz_stream_delete(&zip->compress_stream); + zip->compress_stream = NULL; + + zip->entry_opened = 0; + + return MZ_OK; +} + +static int32_t mz_zip_entry_open_int(void *handle, uint8_t raw, int16_t compress_level, const char *password) { + mz_zip *zip = (mz_zip *)handle; + int64_t max_total_in = 0; + int64_t header_size = 0; + int64_t footer_size = 0; + int32_t err = MZ_OK; + uint8_t use_crypt = 0; + + if (zip == NULL) + return MZ_PARAM_ERROR; + + switch (zip->file_info.compression_method) { + case MZ_COMPRESS_METHOD_STORE: + case MZ_COMPRESS_METHOD_DEFLATE: +#ifdef HAVE_BZIP2 + case MZ_COMPRESS_METHOD_BZIP2: +#endif +#ifdef HAVE_LZMA + case MZ_COMPRESS_METHOD_LZMA: +#endif +#if defined(HAVE_LZMA) || defined(HAVE_LIBCOMP) + case MZ_COMPRESS_METHOD_XZ: +#endif +#ifdef HAVE_ZSTD + case MZ_COMPRESS_METHOD_ZSTD: +#endif + err = MZ_OK; + break; + default: + return MZ_SUPPORT_ERROR; + } + +#ifndef HAVE_WZAES + if (zip->file_info.aes_version) + return MZ_SUPPORT_ERROR; +#endif + + zip->entry_raw = raw; + + if ((zip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED) && (password != NULL)) { + if (zip->open_mode & MZ_OPEN_MODE_WRITE) { + /* Encrypt only when we are not trying to write raw and password is supplied. */ + if (!zip->entry_raw) + use_crypt = 1; + } else if (zip->open_mode & MZ_OPEN_MODE_READ) { + /* Decrypt only when password is supplied. Don't error when password */ + /* is not supplied as we may want to read the raw encrypted data. */ + use_crypt = 1; + } + } + + if ((err == MZ_OK) && (use_crypt)) { +#ifdef HAVE_WZAES + if (zip->file_info.aes_version) { + mz_stream_wzaes_create(&zip->crypt_stream); + mz_stream_wzaes_set_password(zip->crypt_stream, password); + mz_stream_wzaes_set_encryption_mode(zip->crypt_stream, zip->file_info.aes_encryption_mode); + } else +#endif + { +#ifdef HAVE_PKCRYPT + uint8_t verify1 = (uint8_t)((zip->file_info.pk_verify >> 8) & 0xff); + uint8_t verify2 = (uint8_t)((zip->file_info.pk_verify) & 0xff); + + mz_stream_pkcrypt_create(&zip->crypt_stream); + mz_stream_pkcrypt_set_password(zip->crypt_stream, password); + mz_stream_pkcrypt_set_verify(zip->crypt_stream, verify1, verify2); +#endif + } + } + + if (err == MZ_OK) { + if (zip->crypt_stream == NULL) + mz_stream_raw_create(&zip->crypt_stream); + + mz_stream_set_base(zip->crypt_stream, zip->stream); + + err = mz_stream_open(zip->crypt_stream, NULL, zip->open_mode); + } + + if (err == MZ_OK) { + if (zip->entry_raw || zip->file_info.compression_method == MZ_COMPRESS_METHOD_STORE) + mz_stream_raw_create(&zip->compress_stream); +#ifdef HAVE_ZLIB + else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_DEFLATE) + mz_stream_zlib_create(&zip->compress_stream); +#endif +#ifdef HAVE_BZIP2 + else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_BZIP2) + mz_stream_bzip_create(&zip->compress_stream); +#endif +#ifdef HAVE_LIBCOMP + else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_DEFLATE || + zip->file_info.compression_method == MZ_COMPRESS_METHOD_XZ) { + mz_stream_libcomp_create(&zip->compress_stream); + mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_COMPRESS_METHOD, + zip->file_info.compression_method); + } +#endif +#ifdef HAVE_LZMA + else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_LZMA || + zip->file_info.compression_method == MZ_COMPRESS_METHOD_XZ) { + mz_stream_lzma_create(&zip->compress_stream); + mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_COMPRESS_METHOD, + zip->file_info.compression_method); + } +#endif +#ifdef HAVE_ZSTD + else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_ZSTD) + mz_stream_zstd_create(&zip->compress_stream); +#endif + else + err = MZ_PARAM_ERROR; + } + + if (err == MZ_OK) { + if (zip->open_mode & MZ_OPEN_MODE_WRITE) { + mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_COMPRESS_LEVEL, compress_level); + } else { + int32_t set_end_of_stream = 0; + +#ifndef HAVE_LIBCOMP + if (zip->entry_raw || + zip->file_info.compression_method == MZ_COMPRESS_METHOD_STORE || + zip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED) +#endif + { + max_total_in = zip->file_info.compressed_size; + mz_stream_set_prop_int64(zip->crypt_stream, MZ_STREAM_PROP_TOTAL_IN_MAX, max_total_in); + + if (mz_stream_get_prop_int64(zip->crypt_stream, MZ_STREAM_PROP_HEADER_SIZE, &header_size) == MZ_OK) + max_total_in -= header_size; + if (mz_stream_get_prop_int64(zip->crypt_stream, MZ_STREAM_PROP_FOOTER_SIZE, &footer_size) == MZ_OK) + max_total_in -= footer_size; + + mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN_MAX, max_total_in); + } + + switch (zip->file_info.compression_method) { + case MZ_COMPRESS_METHOD_LZMA: + case MZ_COMPRESS_METHOD_XZ: + set_end_of_stream = (zip->file_info.flag & MZ_ZIP_FLAG_LZMA_EOS_MARKER); + break; + case MZ_COMPRESS_METHOD_ZSTD: + set_end_of_stream = 1; + break; + } + + if (set_end_of_stream) { + mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN_MAX, zip->file_info.compressed_size); + mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_OUT_MAX, zip->file_info.uncompressed_size); + } + } + + mz_stream_set_base(zip->compress_stream, zip->crypt_stream); + + err = mz_stream_open(zip->compress_stream, NULL, zip->open_mode); + } + + if (err == MZ_OK) { + zip->entry_opened = 1; + zip->entry_crc32 = 0; + } else { + mz_zip_entry_close_int(handle); + } + + return err; +} + +int32_t mz_zip_entry_is_open(void *handle) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL) + return MZ_PARAM_ERROR; + if (zip->entry_opened == 0) + return MZ_EXIST_ERROR; + return MZ_OK; +} + +int32_t mz_zip_entry_read_open(void *handle, uint8_t raw, const char *password) { + mz_zip *zip = (mz_zip *)handle; + int32_t err = MZ_OK; + int32_t err_shift = MZ_OK; + +#if defined(MZ_ZIP_NO_ENCRYPTION) + if (password != NULL) + return MZ_SUPPORT_ERROR; +#endif + if (zip == NULL) + return MZ_PARAM_ERROR; + if ((zip->open_mode & MZ_OPEN_MODE_READ) == 0) + return MZ_PARAM_ERROR; + if (zip->entry_scanned == 0) + return MZ_PARAM_ERROR; + + mz_zip_print("Zip - Entry - Read open (raw %" PRId32 ")\n", raw); + + err = mz_zip_entry_seek_local_header(handle); + if (err == MZ_OK) + err = mz_zip_entry_read_header(zip->stream, 1, &zip->local_file_info, zip->local_file_info_stream); + + if (err == MZ_FORMAT_ERROR && zip->disk_offset_shift > 0) { + /* Perhaps we didn't compensated correctly for incorrect cd offset */ + err_shift = mz_stream_seek(zip->stream, zip->file_info.disk_offset, MZ_SEEK_SET); + if (err_shift == MZ_OK) + err_shift = mz_zip_entry_read_header(zip->stream, 1, &zip->local_file_info, zip->local_file_info_stream); + if (err_shift == MZ_OK) { + zip->disk_offset_shift = 0; + err = err_shift; + } + } + +#ifdef MZ_ZIP_NO_DECOMPRESSION + if (!raw && zip->file_info.compression_method != MZ_COMPRESS_METHOD_STORE) + err = MZ_SUPPORT_ERROR; +#endif + if (err == MZ_OK) + err = mz_zip_entry_open_int(handle, raw, 0, password); + + return err; +} + +int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, int16_t compress_level, uint8_t raw, const char *password) { + mz_zip *zip = (mz_zip *)handle; + int64_t filename_pos = -1; + int64_t extrafield_pos = 0; + int64_t comment_pos = 0; + int64_t linkname_pos = 0; + int64_t disk_number = 0; + uint8_t is_dir = 0; + int32_t err = MZ_OK; + +#if defined(MZ_ZIP_NO_ENCRYPTION) + if (password != NULL) + return MZ_SUPPORT_ERROR; +#endif + if (zip == NULL || file_info == NULL || file_info->filename == NULL) + return MZ_PARAM_ERROR; + + if (mz_zip_entry_is_open(handle) == MZ_OK) { + err = mz_zip_entry_close(handle); + if (err != MZ_OK) + return err; + } + + memcpy(&zip->file_info, file_info, sizeof(mz_zip_file)); + + mz_zip_print("Zip - Entry - Write open - %s (level %" PRId16 " raw %" PRId8 ")\n", + zip->file_info.filename, compress_level, raw); + + mz_stream_seek(zip->file_info_stream, 0, MZ_SEEK_SET); + mz_stream_write(zip->file_info_stream, file_info, sizeof(mz_zip_file)); + + /* Copy filename, extrafield, and comment internally */ + filename_pos = mz_stream_tell(zip->file_info_stream); + if (file_info->filename != NULL) + mz_stream_write(zip->file_info_stream, file_info->filename, (int32_t)strlen(file_info->filename)); + mz_stream_write_uint8(zip->file_info_stream, 0); + + extrafield_pos = mz_stream_tell(zip->file_info_stream); + if (file_info->extrafield != NULL) + mz_stream_write(zip->file_info_stream, file_info->extrafield, file_info->extrafield_size); + mz_stream_write_uint8(zip->file_info_stream, 0); + + comment_pos = mz_stream_tell(zip->file_info_stream); + if (file_info->comment != NULL) + mz_stream_write(zip->file_info_stream, file_info->comment, file_info->comment_size); + mz_stream_write_uint8(zip->file_info_stream, 0); + + linkname_pos = mz_stream_tell(zip->file_info_stream); + if (file_info->linkname != NULL) + mz_stream_write(zip->file_info_stream, file_info->linkname, (int32_t)strlen(file_info->linkname)); + mz_stream_write_uint8(zip->file_info_stream, 0); + + mz_stream_mem_get_buffer_at(zip->file_info_stream, filename_pos, (const void **)&zip->file_info.filename); + mz_stream_mem_get_buffer_at(zip->file_info_stream, extrafield_pos, (const void **)&zip->file_info.extrafield); + mz_stream_mem_get_buffer_at(zip->file_info_stream, comment_pos, (const void **)&zip->file_info.comment); + mz_stream_mem_get_buffer_at(zip->file_info_stream, linkname_pos, (const void **)&zip->file_info.linkname); + + if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_DEFLATE) { + if ((compress_level == 8) || (compress_level == 9)) + zip->file_info.flag |= MZ_ZIP_FLAG_DEFLATE_MAX; + if (compress_level == 2) + zip->file_info.flag |= MZ_ZIP_FLAG_DEFLATE_FAST; + if (compress_level == 1) + zip->file_info.flag |= MZ_ZIP_FLAG_DEFLATE_SUPER_FAST; + } +#if defined(HAVE_LZMA) || defined(HAVE_LIBCOMP) + else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_LZMA || + zip->file_info.compression_method == MZ_COMPRESS_METHOD_XZ) + zip->file_info.flag |= MZ_ZIP_FLAG_LZMA_EOS_MARKER; +#endif + + if (mz_zip_attrib_is_dir(zip->file_info.external_fa, zip->file_info.version_madeby) == MZ_OK) + is_dir = 1; + + if (!is_dir) { + if (zip->data_descriptor) + zip->file_info.flag |= MZ_ZIP_FLAG_DATA_DESCRIPTOR; + if (password != NULL) + zip->file_info.flag |= MZ_ZIP_FLAG_ENCRYPTED; + } + + mz_stream_get_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, &disk_number); + zip->file_info.disk_number = (uint32_t)disk_number; + zip->file_info.disk_offset = mz_stream_tell(zip->stream); + + if (zip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED) { +#ifdef HAVE_PKCRYPT + /* Pre-calculated CRC value is required for PKWARE traditional encryption */ + uint32_t dos_date = mz_zip_time_t_to_dos_date(zip->file_info.modified_date); + zip->file_info.pk_verify = mz_zip_get_pk_verify(dos_date, zip->file_info.crc, zip->file_info.flag); +#endif +#ifdef HAVE_WZAES + if (zip->file_info.aes_version && zip->file_info.aes_encryption_mode == 0) + zip->file_info.aes_encryption_mode = MZ_AES_ENCRYPTION_MODE_256; +#endif + } + + zip->file_info.crc = 0; + zip->file_info.compressed_size = 0; + + if ((compress_level == 0) || (is_dir)) + zip->file_info.compression_method = MZ_COMPRESS_METHOD_STORE; + +#ifdef MZ_ZIP_NO_COMPRESSION + if (zip->file_info.compression_method != MZ_COMPRESS_METHOD_STORE) + err = MZ_SUPPORT_ERROR; +#endif + if (err == MZ_OK) + err = mz_zip_entry_write_header(zip->stream, 1, &zip->file_info); + if (err == MZ_OK) + err = mz_zip_entry_open_int(handle, raw, compress_level, password); + + return err; +} + +int32_t mz_zip_entry_read(void *handle, void *buf, int32_t len) { + mz_zip *zip = (mz_zip *)handle; + int32_t read = 0; + + if (zip == NULL || mz_zip_entry_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + if (UINT_MAX == UINT16_MAX && len > UINT16_MAX) /* zlib limitation */ + return MZ_PARAM_ERROR; + if (len == 0) + return MZ_PARAM_ERROR; + + if (zip->file_info.compressed_size == 0) + return 0; + + /* Read entire entry even if uncompressed_size = 0, otherwise */ + /* aes encryption validation will fail if compressed_size > 0 */ + read = mz_stream_read(zip->compress_stream, buf, len); + if (read > 0) + zip->entry_crc32 = mz_crypt_crc32_update(zip->entry_crc32, buf, read); + + mz_zip_print("Zip - Entry - Read - %" PRId32 " (max %" PRId32 ")\n", read, len); + + return read; +} + +int32_t mz_zip_entry_write(void *handle, const void *buf, int32_t len) { + mz_zip *zip = (mz_zip *)handle; + int32_t written = 0; + + if (zip == NULL || mz_zip_entry_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + written = mz_stream_write(zip->compress_stream, buf, len); + if (written > 0) + zip->entry_crc32 = mz_crypt_crc32_update(zip->entry_crc32, buf, written); + + mz_zip_print("Zip - Entry - Write - %" PRId32 " (max %" PRId32 ")\n", written, len); + + return written; +} + +int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compressed_size, + int64_t *uncompressed_size) { + mz_zip *zip = (mz_zip *)handle; + int64_t total_in = 0; + int32_t err = MZ_OK; + uint8_t zip64 = 0; + + if (zip == NULL || mz_zip_entry_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + + mz_stream_close(zip->compress_stream); + + mz_zip_print("Zip - Entry - Read Close\n"); + + if (crc32 != NULL) + *crc32 = zip->file_info.crc; + if (compressed_size != NULL) + *compressed_size = zip->file_info.compressed_size; + if (uncompressed_size != NULL) + *uncompressed_size = zip->file_info.uncompressed_size; + + mz_stream_get_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN, &total_in); + + if ((zip->file_info.flag & MZ_ZIP_FLAG_DATA_DESCRIPTOR) && + ((zip->file_info.flag & MZ_ZIP_FLAG_MASK_LOCAL_INFO) == 0) && + (crc32 != NULL || compressed_size != NULL || uncompressed_size != NULL)) { + /* Check to see if data descriptor is zip64 bit format or not */ + if (mz_zip_extrafield_contains(zip->local_file_info.extrafield, + zip->local_file_info.extrafield_size, MZ_ZIP_EXTENSION_ZIP64, NULL) == MZ_OK) + zip64 = 1; + + err = mz_zip_entry_seek_local_header(handle); + + /* Seek to end of compressed stream since we might have over-read during compression */ + if (err == MZ_OK) + err = mz_stream_seek(zip->stream, MZ_ZIP_SIZE_LD_ITEM + + (int64_t)zip->local_file_info.filename_size + + (int64_t)zip->local_file_info.extrafield_size + + total_in, MZ_SEEK_CUR); + + /* Read data descriptor */ + if (err == MZ_OK) + err = mz_zip_entry_read_descriptor(zip->stream, zip64, + crc32, compressed_size, uncompressed_size); + } + + /* If entire entry was not read verification will fail */ + if ((err == MZ_OK) && (total_in > 0) && (!zip->entry_raw)) { +#ifdef HAVE_WZAES + /* AES zip version AE-1 will expect a valid crc as well */ + if (zip->file_info.aes_version <= 0x0001) +#endif + { + if (zip->entry_crc32 != zip->file_info.crc) { + mz_zip_print("Zip - Entry - Crc failed (actual 0x%08" PRIx32 " expected 0x%08" PRIx32 ")\n", + zip->entry_crc32, zip->file_info.crc); + + err = MZ_CRC_ERROR; + } + } + } + + mz_zip_entry_close_int(handle); + + return err; +} + +int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compressed_size, + int64_t uncompressed_size) { + mz_zip *zip = (mz_zip *)handle; + int64_t end_disk_number = 0; + int32_t err = MZ_OK; + uint8_t zip64 = 0; + + if (zip == NULL || mz_zip_entry_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + + mz_stream_close(zip->compress_stream); + + if (!zip->entry_raw) + crc32 = zip->entry_crc32; + + mz_zip_print("Zip - Entry - Write Close (crc 0x%08" PRIx32 " cs %" PRId64 " ucs %" PRId64 ")\n", + crc32, compressed_size, uncompressed_size); + + /* If sizes are not set, then read them from the compression stream */ + if (compressed_size < 0) + mz_stream_get_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_OUT, &compressed_size); + if (uncompressed_size < 0) + mz_stream_get_prop_int64(zip->compress_stream, MZ_STREAM_PROP_TOTAL_IN, &uncompressed_size); + + if (zip->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED) { + mz_stream_set_base(zip->crypt_stream, zip->stream); + err = mz_stream_close(zip->crypt_stream); + + mz_stream_get_prop_int64(zip->crypt_stream, MZ_STREAM_PROP_TOTAL_OUT, &compressed_size); + } + + mz_zip_entry_needs_zip64(&zip->file_info, 1, &zip64); + + if ((err == MZ_OK) && (zip->file_info.flag & MZ_ZIP_FLAG_DATA_DESCRIPTOR)) { + /* Determine if we need to write data descriptor in zip64 format, + if local extrafield was saved with zip64 extrafield */ + + if (zip->file_info.flag & MZ_ZIP_FLAG_MASK_LOCAL_INFO) + err = mz_zip_entry_write_descriptor(zip->stream, + zip64, 0, compressed_size, 0); + else + err = mz_zip_entry_write_descriptor(zip->stream, + zip64, crc32, compressed_size, uncompressed_size); + } + + /* Write file info to central directory */ + + mz_zip_print("Zip - Entry - Write cd (ucs %" PRId64 " cs %" PRId64 " crc 0x%08" PRIx32 ")\n", + uncompressed_size, compressed_size, crc32); + + zip->file_info.crc = crc32; + zip->file_info.compressed_size = compressed_size; + zip->file_info.uncompressed_size = uncompressed_size; + + if (err == MZ_OK) + err = mz_zip_entry_write_header(zip->cd_mem_stream, 0, &zip->file_info); + + /* Update local header with crc32 and sizes */ + if ((err == MZ_OK) && ((zip->file_info.flag & MZ_ZIP_FLAG_DATA_DESCRIPTOR) == 0) && + ((zip->file_info.flag & MZ_ZIP_FLAG_MASK_LOCAL_INFO) == 0)) { + /* Save the disk number and position we are to seek back after updating local header */ + int64_t end_pos = mz_stream_tell(zip->stream); + mz_stream_get_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, &end_disk_number); + + err = mz_zip_entry_seek_local_header(handle); + + if (err == MZ_OK) { + /* Seek to crc32 and sizes offset in local header */ + err = mz_stream_seek(zip->stream, MZ_ZIP_OFFSET_CRC_SIZES, MZ_SEEK_CUR); + } + + if (err == MZ_OK) + err = mz_zip_entry_write_crc_sizes(zip->stream, zip64, 0, &zip->file_info); + + /* Seek to and update zip64 extension sizes */ + if ((err == MZ_OK) && (zip64)) { + int64_t filename_size = zip->file_info.filename_size; + + if (filename_size == 0) + filename_size = strlen(zip->file_info.filename); + + /* Since we write zip64 extension first we know its offset */ + err = mz_stream_seek(zip->stream, 2 + 2 + filename_size + 4, MZ_SEEK_CUR); + + if (err == MZ_OK) + err = mz_stream_write_uint64(zip->stream, zip->file_info.uncompressed_size); + if (err == MZ_OK) + err = mz_stream_write_uint64(zip->stream, zip->file_info.compressed_size); + } + + mz_stream_set_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, end_disk_number); + mz_stream_seek(zip->stream, end_pos, MZ_SEEK_SET); + } + + zip->number_entry += 1; + + mz_zip_entry_close_int(handle); + + return err; +} + +int32_t mz_zip_entry_seek_local_header(void *handle) { + mz_zip *zip = (mz_zip *)handle; + int64_t disk_size = 0; + uint32_t disk_number = zip->file_info.disk_number; + + if (disk_number == zip->disk_number_with_cd) { + mz_stream_get_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_SIZE, &disk_size); + if ((disk_size == 0) || ((zip->open_mode & MZ_OPEN_MODE_WRITE) == 0)) + disk_number = (uint32_t)-1; + } + + mz_stream_set_prop_int64(zip->stream, MZ_STREAM_PROP_DISK_NUMBER, disk_number); + + mz_zip_print("Zip - Entry - Seek local (disk %" PRId32 " offset %" PRId64 ")\n", + disk_number, zip->file_info.disk_offset); + + /* Guard against seek overflows */ + if ((zip->disk_offset_shift > 0) && + (zip->file_info.disk_offset > (INT64_MAX - zip->disk_offset_shift))) + return MZ_FORMAT_ERROR; + + return mz_stream_seek(zip->stream, zip->file_info.disk_offset + zip->disk_offset_shift, MZ_SEEK_SET); +} + +int32_t mz_zip_entry_close(void *handle) { + return mz_zip_entry_close_raw(handle, UINT64_MAX, 0); +} + +int32_t mz_zip_entry_close_raw(void *handle, int64_t uncompressed_size, uint32_t crc32) { + mz_zip *zip = (mz_zip *)handle; + int32_t err = MZ_OK; + + if (zip == NULL || mz_zip_entry_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + + if (zip->open_mode & MZ_OPEN_MODE_WRITE) + err = mz_zip_entry_write_close(handle, crc32, UINT64_MAX, uncompressed_size); + else + err = mz_zip_entry_read_close(handle, NULL, NULL, NULL); + + return err; +} + +int32_t mz_zip_entry_is_dir(void *handle) { + mz_zip *zip = (mz_zip *)handle; + int32_t filename_length = 0; + + if (zip == NULL) + return MZ_PARAM_ERROR; + if (zip->entry_scanned == 0) + return MZ_PARAM_ERROR; + if (mz_zip_attrib_is_dir(zip->file_info.external_fa, zip->file_info.version_madeby) == MZ_OK) + return MZ_OK; + + filename_length = (int32_t)strlen(zip->file_info.filename); + if (filename_length > 0) { + if ((zip->file_info.filename[filename_length - 1] == '/') || + (zip->file_info.filename[filename_length - 1] == '\\')) + return MZ_OK; + } + return MZ_EXIST_ERROR; +} + +int32_t mz_zip_entry_is_symlink(void *handle) { + mz_zip *zip = (mz_zip *)handle; + + if (zip == NULL) + return MZ_PARAM_ERROR; + if (zip->entry_scanned == 0) + return MZ_PARAM_ERROR; + if (mz_zip_attrib_is_symlink(zip->file_info.external_fa, zip->file_info.version_madeby) != MZ_OK) + return MZ_EXIST_ERROR; + if (zip->file_info.linkname == NULL || *zip->file_info.linkname == 0) + return MZ_EXIST_ERROR; + + return MZ_OK; +} + +int32_t mz_zip_entry_get_info(void *handle, mz_zip_file **file_info) { + mz_zip *zip = (mz_zip *)handle; + + if (zip == NULL) + return MZ_PARAM_ERROR; + + if ((zip->open_mode & MZ_OPEN_MODE_WRITE) == 0) { + if (!zip->entry_scanned) + return MZ_PARAM_ERROR; + } + + *file_info = &zip->file_info; + return MZ_OK; +} + +int32_t mz_zip_entry_get_local_info(void *handle, mz_zip_file **local_file_info) { + mz_zip *zip = (mz_zip *)handle; + if (zip == NULL || mz_zip_entry_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + *local_file_info = &zip->local_file_info; + return MZ_OK; +} + +int32_t mz_zip_entry_set_extrafield(void *handle, const uint8_t *extrafield, uint16_t extrafield_size) { + mz_zip *zip = (mz_zip *)handle; + + if (zip == NULL || mz_zip_entry_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + + zip->file_info.extrafield = extrafield; + zip->file_info.extrafield_size = extrafield_size; + return MZ_OK; +} + +static int32_t mz_zip_goto_next_entry_int(void *handle) { + mz_zip *zip = (mz_zip *)handle; + int32_t err = MZ_OK; + + if (zip == NULL) + return MZ_PARAM_ERROR; + + zip->entry_scanned = 0; + + mz_stream_set_prop_int64(zip->cd_stream, MZ_STREAM_PROP_DISK_NUMBER, -1); + + err = mz_stream_seek(zip->cd_stream, zip->cd_current_pos, MZ_SEEK_SET); + if (err == MZ_OK) + err = mz_zip_entry_read_header(zip->cd_stream, 0, &zip->file_info, zip->file_info_stream); + if (err == MZ_OK) + zip->entry_scanned = 1; + return err; +} + +int64_t mz_zip_get_entry(void *handle) { + mz_zip *zip = (mz_zip *)handle; + + if (zip == NULL) + return MZ_PARAM_ERROR; + + return zip->cd_current_pos; +} + +int32_t mz_zip_goto_entry(void *handle, int64_t cd_pos) { + mz_zip *zip = (mz_zip *)handle; + + if (zip == NULL) + return MZ_PARAM_ERROR; + + if (cd_pos < zip->cd_start_pos || cd_pos > zip->cd_start_pos + zip->cd_size) + return MZ_PARAM_ERROR; + + zip->cd_current_pos = cd_pos; + + return mz_zip_goto_next_entry_int(handle); +} + +int32_t mz_zip_goto_first_entry(void *handle) { + mz_zip *zip = (mz_zip *)handle; + + if (zip == NULL) + return MZ_PARAM_ERROR; + + zip->cd_current_pos = zip->cd_start_pos; + + return mz_zip_goto_next_entry_int(handle); +} + +int32_t mz_zip_goto_next_entry(void *handle) { + mz_zip *zip = (mz_zip *)handle; + + if (zip == NULL) + return MZ_PARAM_ERROR; + + zip->cd_current_pos += (int64_t)MZ_ZIP_SIZE_CD_ITEM + zip->file_info.filename_size + + zip->file_info.extrafield_size + zip->file_info.comment_size; + + return mz_zip_goto_next_entry_int(handle); +} + +int32_t mz_zip_locate_entry(void *handle, const char *filename, uint8_t ignore_case) { + mz_zip *zip = (mz_zip *)handle; + int32_t err = MZ_OK; + int32_t result = 0; + + if (zip == NULL || filename == NULL) + return MZ_PARAM_ERROR; + + /* If we are already on the current entry, no need to search */ + if ((zip->entry_scanned) && (zip->file_info.filename != NULL)) { + result = mz_zip_path_compare(zip->file_info.filename, filename, ignore_case); + if (result == 0) + return MZ_OK; + } + + /* Search all entries starting at the first */ + err = mz_zip_goto_first_entry(handle); + while (err == MZ_OK) { + result = mz_zip_path_compare(zip->file_info.filename, filename, ignore_case); + if (result == 0) + return MZ_OK; + + err = mz_zip_goto_next_entry(handle); + } + + return err; +} + +int32_t mz_zip_locate_first_entry(void *handle, void *userdata, mz_zip_locate_entry_cb cb) { + mz_zip *zip = (mz_zip *)handle; + int32_t err = MZ_OK; + int32_t result = 0; + + /* Search first entry looking for match */ + err = mz_zip_goto_first_entry(handle); + if (err != MZ_OK) + return err; + + result = cb(handle, userdata, &zip->file_info); + if (result == 0) + return MZ_OK; + + return mz_zip_locate_next_entry(handle, userdata, cb); +} + +int32_t mz_zip_locate_next_entry(void *handle, void *userdata, mz_zip_locate_entry_cb cb) { + mz_zip *zip = (mz_zip *)handle; + int32_t err = MZ_OK; + int32_t result = 0; + + /* Search next entries looking for match */ + err = mz_zip_goto_next_entry(handle); + while (err == MZ_OK) { + result = cb(handle, userdata, &zip->file_info); + if (result == 0) + return MZ_OK; + + err = mz_zip_goto_next_entry(handle); + } + + return err; +} + +/***************************************************************************/ + +int32_t mz_zip_attrib_is_dir(uint32_t attrib, int32_t version_madeby) { + uint32_t posix_attrib = 0; + uint8_t system = MZ_HOST_SYSTEM(version_madeby); + int32_t err = MZ_OK; + + err = mz_zip_attrib_convert(system, attrib, MZ_HOST_SYSTEM_UNIX, &posix_attrib); + if (err == MZ_OK) { + if ((posix_attrib & 0170000) == 0040000) /* S_ISDIR */ + return MZ_OK; + } + + return MZ_EXIST_ERROR; +} + +int32_t mz_zip_attrib_is_symlink(uint32_t attrib, int32_t version_madeby) { + uint32_t posix_attrib = 0; + uint8_t system = MZ_HOST_SYSTEM(version_madeby); + int32_t err = MZ_OK; + + err = mz_zip_attrib_convert(system, attrib, MZ_HOST_SYSTEM_UNIX, &posix_attrib); + if (err == MZ_OK) { + if ((posix_attrib & 0170000) == 0120000) /* S_ISLNK */ + return MZ_OK; + } + + return MZ_EXIST_ERROR; +} + +int32_t mz_zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t target_sys, uint32_t *target_attrib) { + if (target_attrib == NULL) + return MZ_PARAM_ERROR; + + *target_attrib = 0; + + if ((src_sys == MZ_HOST_SYSTEM_MSDOS) || (src_sys == MZ_HOST_SYSTEM_WINDOWS_NTFS)) { + if ((target_sys == MZ_HOST_SYSTEM_MSDOS) || (target_sys == MZ_HOST_SYSTEM_WINDOWS_NTFS)) { + *target_attrib = src_attrib; + return MZ_OK; + } + if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS)) + return mz_zip_attrib_win32_to_posix(src_attrib, target_attrib); + } else if ((src_sys == MZ_HOST_SYSTEM_UNIX) || (src_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (src_sys == MZ_HOST_SYSTEM_RISCOS)) { + if ((target_sys == MZ_HOST_SYSTEM_UNIX) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWIN) || (target_sys == MZ_HOST_SYSTEM_RISCOS)) { + /* If high bytes are set, it contains unix specific attributes */ + if ((src_attrib >> 16) != 0) + src_attrib >>= 16; + + *target_attrib = src_attrib; + return MZ_OK; + } + if ((target_sys == MZ_HOST_SYSTEM_MSDOS) || (target_sys == MZ_HOST_SYSTEM_WINDOWS_NTFS)) + return mz_zip_attrib_posix_to_win32(src_attrib, target_attrib); + } + + return MZ_SUPPORT_ERROR; +} + +int32_t mz_zip_attrib_posix_to_win32(uint32_t posix_attrib, uint32_t *win32_attrib) { + if (win32_attrib == NULL) + return MZ_PARAM_ERROR; + + *win32_attrib = 0; + + /* S_IWUSR | S_IWGRP | S_IWOTH | S_IXUSR | S_IXGRP | S_IXOTH */ + if ((posix_attrib & 0000333) == 0 && (posix_attrib & 0000444) != 0) + *win32_attrib |= 0x01; /* FILE_ATTRIBUTE_READONLY */ + /* S_IFLNK */ + if ((posix_attrib & 0170000) == 0120000) + *win32_attrib |= 0x400; /* FILE_ATTRIBUTE_REPARSE_POINT */ + /* S_IFDIR */ + else if ((posix_attrib & 0170000) == 0040000) + *win32_attrib |= 0x10; /* FILE_ATTRIBUTE_DIRECTORY */ + /* S_IFREG */ + else + *win32_attrib |= 0x80; /* FILE_ATTRIBUTE_NORMAL */ + + return MZ_OK; +} + +int32_t mz_zip_attrib_win32_to_posix(uint32_t win32_attrib, uint32_t *posix_attrib) { + if (posix_attrib == NULL) + return MZ_PARAM_ERROR; + + *posix_attrib = 0000444; /* S_IRUSR | S_IRGRP | S_IROTH */ + /* FILE_ATTRIBUTE_READONLY */ + if ((win32_attrib & 0x01) == 0) + *posix_attrib |= 0000222; /* S_IWUSR | S_IWGRP | S_IWOTH */ + /* FILE_ATTRIBUTE_REPARSE_POINT */ + if ((win32_attrib & 0x400) == 0x400) + *posix_attrib |= 0120000; /* S_IFLNK */ + /* FILE_ATTRIBUTE_DIRECTORY */ + else if ((win32_attrib & 0x10) == 0x10) + *posix_attrib |= 0040111; /* S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH */ + else + *posix_attrib |= 0100000; /* S_IFREG */ + + return MZ_OK; +} + +/***************************************************************************/ + +int32_t mz_zip_extrafield_find(void *stream, uint16_t type, int32_t max_seek, uint16_t *length) { + int32_t err = MZ_OK; + uint16_t field_type = 0; + uint16_t field_length = 0; + + + if (max_seek < 4) + return MZ_EXIST_ERROR; + + do { + err = mz_stream_read_uint16(stream, &field_type); + if (err == MZ_OK) + err = mz_stream_read_uint16(stream, &field_length); + if (err != MZ_OK) + break; + + if (type == field_type) { + if (length != NULL) + *length = field_length; + return MZ_OK; + } + + max_seek -= field_length - 4; + if (max_seek < 0) + return MZ_EXIST_ERROR; + + err = mz_stream_seek(stream, field_length, MZ_SEEK_CUR); + } while (err == MZ_OK); + + return MZ_EXIST_ERROR; +} + +int32_t mz_zip_extrafield_contains(const uint8_t *extrafield, int32_t extrafield_size, + uint16_t type, uint16_t *length) { + void *file_extra_stream = NULL; + int32_t err = MZ_OK; + + if (extrafield == NULL || extrafield_size == 0) + return MZ_PARAM_ERROR; + + mz_stream_mem_create(&file_extra_stream); + mz_stream_mem_set_buffer(file_extra_stream, (void *)extrafield, extrafield_size); + + err = mz_zip_extrafield_find(file_extra_stream, type, extrafield_size, length); + + mz_stream_mem_delete(&file_extra_stream); + + return err; +} + +int32_t mz_zip_extrafield_read(void *stream, uint16_t *type, uint16_t *length) { + int32_t err = MZ_OK; + if (type == NULL || length == NULL) + return MZ_PARAM_ERROR; + err = mz_stream_read_uint16(stream, type); + if (err == MZ_OK) + err = mz_stream_read_uint16(stream, length); + return err; +} + +int32_t mz_zip_extrafield_write(void *stream, uint16_t type, uint16_t length) { + int32_t err = MZ_OK; + err = mz_stream_write_uint16(stream, type); + if (err == MZ_OK) + err = mz_stream_write_uint16(stream, length); + return err; +} + +/***************************************************************************/ + +static int32_t mz_zip_invalid_date(const struct tm *ptm) { +#define datevalue_in_range(min, max, value) ((min) <= (value) && (value) <= (max)) + return (!datevalue_in_range(0, 127 + 80, ptm->tm_year) || /* 1980-based year, allow 80 extra */ + !datevalue_in_range(0, 11, ptm->tm_mon) || + !datevalue_in_range(1, 31, ptm->tm_mday) || + !datevalue_in_range(0, 23, ptm->tm_hour) || + !datevalue_in_range(0, 59, ptm->tm_min) || + !datevalue_in_range(0, 59, ptm->tm_sec)); +#undef datevalue_in_range +} + +static void mz_zip_dosdate_to_raw_tm(uint64_t dos_date, struct tm *ptm) { + uint64_t date = (uint64_t)(dos_date >> 16); + + ptm->tm_mday = (uint16_t)(date & 0x1f); + ptm->tm_mon = (uint16_t)(((date & 0x1E0) / 0x20) - 1); + ptm->tm_year = (uint16_t)(((date & 0x0FE00) / 0x0200) + 80); + ptm->tm_hour = (uint16_t)((dos_date & 0xF800) / 0x800); + ptm->tm_min = (uint16_t)((dos_date & 0x7E0) / 0x20); + ptm->tm_sec = (uint16_t)(2 * (dos_date & 0x1f)); + ptm->tm_isdst = -1; +} + +int32_t mz_zip_dosdate_to_tm(uint64_t dos_date, struct tm *ptm) { + if (ptm == NULL) + return MZ_PARAM_ERROR; + + mz_zip_dosdate_to_raw_tm(dos_date, ptm); + + if (mz_zip_invalid_date(ptm)) { + /* Invalid date stored, so don't return it */ + memset(ptm, 0, sizeof(struct tm)); + return MZ_FORMAT_ERROR; + } + return MZ_OK; +} + +time_t mz_zip_dosdate_to_time_t(uint64_t dos_date) { + struct tm ptm; + mz_zip_dosdate_to_raw_tm(dos_date, &ptm); + return mktime(&ptm); +} + +int32_t mz_zip_time_t_to_tm(time_t unix_time, struct tm *ptm) { + struct tm ltm; + if (ptm == NULL) + return MZ_PARAM_ERROR; + if (localtime_r(&unix_time, <m) == NULL) { /* Returns a 1900-based year */ + /* Invalid date stored, so don't return it */ + memset(ptm, 0, sizeof(struct tm)); + return MZ_INTERNAL_ERROR; + } + memcpy(ptm, <m, sizeof(struct tm)); + return MZ_OK; +} + +uint32_t mz_zip_time_t_to_dos_date(time_t unix_time) { + struct tm ptm; + mz_zip_time_t_to_tm(unix_time, &ptm); + return mz_zip_tm_to_dosdate((const struct tm *)&ptm); +} + +uint32_t mz_zip_tm_to_dosdate(const struct tm *ptm) { + struct tm fixed_tm; + + /* Years supported: */ + + /* [00, 79] (assumed to be between 2000 and 2079) */ + /* [80, 207] (assumed to be between 1980 and 2107, typical output of old */ + /* software that does 'year-1900' to get a double digit year) */ + /* [1980, 2107] (due to format limitations, only years 1980-2107 can be stored.) */ + + memcpy(&fixed_tm, ptm, sizeof(struct tm)); + if (fixed_tm.tm_year >= 1980) /* range [1980, 2107] */ + fixed_tm.tm_year -= 1980; + else if (fixed_tm.tm_year >= 80) /* range [80, 207] */ + fixed_tm.tm_year -= 80; + else /* range [00, 79] */ + fixed_tm.tm_year += 20; + + if (mz_zip_invalid_date(&fixed_tm)) + return 0; + + return (((uint32_t)fixed_tm.tm_mday + (32 * ((uint32_t)fixed_tm.tm_mon + 1)) + (512 * (uint32_t)fixed_tm.tm_year)) << 16) | + (((uint32_t)fixed_tm.tm_sec / 2) + (32 * (uint32_t)fixed_tm.tm_min) + (2048 * (uint32_t)fixed_tm.tm_hour)); +} + +int32_t mz_zip_ntfs_to_unix_time(uint64_t ntfs_time, time_t *unix_time) { + *unix_time = (time_t)((ntfs_time - 116444736000000000LL) / 10000000); + return MZ_OK; +} + +int32_t mz_zip_unix_to_ntfs_time(time_t unix_time, uint64_t *ntfs_time) { + *ntfs_time = ((uint64_t)unix_time * 10000000) + 116444736000000000LL; + return MZ_OK; +} + +/***************************************************************************/ + +int32_t mz_zip_path_compare(const char *path1, const char *path2, uint8_t ignore_case) { + do { + if ((*path1 == '\\' && *path2 == '/') || + (*path2 == '\\' && *path1 == '/')) { + /* Ignore comparison of path slashes */ + } else if (ignore_case) { + if (tolower(*path1) != tolower(*path2)) + break; + } else if (*path1 != *path2) { + break; + } + + path1 += 1; + path2 += 1; + } while (*path1 != 0 && *path2 != 0); + + if (ignore_case) + return (int32_t)(tolower(*path1) - tolower(*path2)); + + return (int32_t)(*path1 - *path2); +} + +/***************************************************************************/ + +const char* mz_zip_get_compression_method_string(int32_t compression_method) +{ + const char *method = "?"; + switch (compression_method) { + case MZ_COMPRESS_METHOD_STORE: + method = "stored"; + break; + case MZ_COMPRESS_METHOD_DEFLATE: + method = "deflate"; + break; + case MZ_COMPRESS_METHOD_BZIP2: + method = "bzip2"; + break; + case MZ_COMPRESS_METHOD_LZMA: + method = "lzma"; + break; + case MZ_COMPRESS_METHOD_XZ: + method = "xz"; + break; + case MZ_COMPRESS_METHOD_ZSTD: + method = "zstd"; + break; + } + return method; +} + +/***************************************************************************/ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_zip.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_zip.h new file mode 100644 index 0000000000000000000000000000000000000000..e3d1fbd52347ce228e1fc49a9d3377a02698ca68 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_zip.h @@ -0,0 +1,259 @@ +/* mz_zip.h -- Zip manipulation + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + Copyright (C) 2009-2010 Mathias Svensson + Modifications for Zip64 support + http://result42.com + Copyright (C) 1998-2010 Gilles Vollant + https://www.winimage.com/zLibDll/minizip.html + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_ZIP_H +#define MZ_ZIP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +typedef struct mz_zip_file_s { + uint16_t version_madeby; /* version made by */ + uint16_t version_needed; /* version needed to extract */ + uint16_t flag; /* general purpose bit flag */ + uint16_t compression_method; /* compression method */ + time_t modified_date; /* last modified date in unix time */ + time_t accessed_date; /* last accessed date in unix time */ + time_t creation_date; /* creation date in unix time */ + uint32_t crc; /* crc-32 */ + int64_t compressed_size; /* compressed size */ + int64_t uncompressed_size; /* uncompressed size */ + uint16_t filename_size; /* filename length */ + uint16_t extrafield_size; /* extra field length */ + uint16_t comment_size; /* file comment length */ + uint32_t disk_number; /* disk number start */ + int64_t disk_offset; /* relative offset of local header */ + uint16_t internal_fa; /* internal file attributes */ + uint32_t external_fa; /* external file attributes */ + + const char *filename; /* filename utf8 null-terminated string */ + const uint8_t *extrafield; /* extrafield data */ + const char *comment; /* comment utf8 null-terminated string */ + const char *linkname; /* sym-link filename utf8 null-terminated string */ + + uint16_t zip64; /* zip64 extension mode */ + uint16_t aes_version; /* winzip aes extension if not 0 */ + uint8_t aes_encryption_mode; /* winzip aes encryption mode */ + uint16_t pk_verify; /* pkware encryption verifier */ + +} mz_zip_file, mz_zip_entry; + +/***************************************************************************/ + +typedef int32_t (*mz_zip_locate_entry_cb)(void *handle, void *userdata, mz_zip_file *file_info); + +/***************************************************************************/ + +void * mz_zip_create(void **handle); +/* Create zip instance for opening */ + +void mz_zip_delete(void **handle); +/* Delete zip object */ + +int32_t mz_zip_open(void *handle, void *stream, int32_t mode); +/* Create a zip file, no delete file in zip functionality */ + +int32_t mz_zip_close(void *handle); +/* Close the zip file */ + +int32_t mz_zip_get_comment(void *handle, const char **comment); +/* Get a pointer to the global comment */ + +int32_t mz_zip_set_comment(void *handle, const char *comment); +/* Sets the global comment used for writing zip file */ + +int32_t mz_zip_get_version_madeby(void *handle, uint16_t *version_madeby); +/* Get the version made by */ + +int32_t mz_zip_set_version_madeby(void *handle, uint16_t version_madeby); +/* Sets the version made by used for writing zip file */ + +int32_t mz_zip_set_recover(void *handle, uint8_t recover); +/* Sets the ability to recover the central dir by reading local file headers */ + +int32_t mz_zip_set_data_descriptor(void *handle, uint8_t data_descriptor); +/* Sets the use of data descriptor flag when writing zip entries */ + +int32_t mz_zip_get_stream(void *handle, void **stream); +/* Get a pointer to the stream used to open */ + +int32_t mz_zip_set_cd_stream(void *handle, int64_t cd_start_pos, void *cd_stream); +/* Sets the stream to use for reading the central dir */ + +int32_t mz_zip_get_cd_mem_stream(void *handle, void **cd_mem_stream); +/* Get a pointer to the stream used to store the central dir in memory */ + +int32_t mz_zip_set_number_entry(void *handle, uint64_t number_entry); +/* Sets the total number of entries */ + +int32_t mz_zip_get_number_entry(void *handle, uint64_t *number_entry); +/* Get the total number of entries */ + +int32_t mz_zip_set_disk_number_with_cd(void *handle, uint32_t disk_number_with_cd); +/* Sets the disk number containing the central directory record */ + +int32_t mz_zip_get_disk_number_with_cd(void *handle, uint32_t *disk_number_with_cd); +/* Get the disk number containing the central directory record */ + +/***************************************************************************/ + +int32_t mz_zip_entry_is_open(void *handle); +/* Check to see if entry is open for read/write */ + +int32_t mz_zip_entry_read_open(void *handle, uint8_t raw, const char *password); +/* Open for reading the current file in the zip file */ + +int32_t mz_zip_entry_read(void *handle, void *buf, int32_t len); +/* Read bytes from the current file in the zip file */ + +int32_t mz_zip_entry_read_close(void *handle, uint32_t *crc32, int64_t *compressed_size, + int64_t *uncompressed_size); +/* Close the current file for reading and get data descriptor values */ + +int32_t mz_zip_entry_write_open(void *handle, const mz_zip_file *file_info, + int16_t compress_level, uint8_t raw, const char *password); +/* Open for writing the current file in the zip file */ + +int32_t mz_zip_entry_write(void *handle, const void *buf, int32_t len); +/* Write bytes from the current file in the zip file */ + +int32_t mz_zip_entry_write_close(void *handle, uint32_t crc32, int64_t compressed_size, + int64_t uncompressed_size); +/* Close the current file for writing and set data descriptor values */ + +int32_t mz_zip_entry_seek_local_header(void *handle); +/* Seeks to the local header for the entry */ + +int32_t mz_zip_entry_close_raw(void *handle, int64_t uncompressed_size, uint32_t crc32); +/* Close the current file in the zip file where raw is compressed data */ + +int32_t mz_zip_entry_close(void *handle); +/* Close the current file in the zip file */ + +/***************************************************************************/ + +int32_t mz_zip_entry_is_dir(void *handle); +/* Checks to see if the entry is a directory */ + +int32_t mz_zip_entry_is_symlink(void *handle); +/* Checks to see if the entry is a symbolic link */ + +int32_t mz_zip_entry_get_info(void *handle, mz_zip_file **file_info); +/* Get info about the current file, only valid while current entry is open */ + +int32_t mz_zip_entry_get_local_info(void *handle, mz_zip_file **local_file_info); +/* Get local info about the current file, only valid while current entry is being read */ + +int32_t mz_zip_entry_set_extrafield(void *handle, const uint8_t *extrafield, uint16_t extrafield_size); +/* Sets or updates the extra field for the entry to be used before writing cd */ + +int64_t mz_zip_get_entry(void *handle); +/* Return offset of the current entry in the zip file */ + +int32_t mz_zip_goto_entry(void *handle, int64_t cd_pos); +/* Go to specified entry in the zip file */ + +int32_t mz_zip_goto_first_entry(void *handle); +/* Go to the first entry in the zip file */ + +int32_t mz_zip_goto_next_entry(void *handle); +/* Go to the next entry in the zip file or MZ_END_OF_LIST if reaching the end */ + +int32_t mz_zip_locate_entry(void *handle, const char *filename, uint8_t ignore_case); +/* Locate the file with the specified name in the zip file or MZ_END_LIST if not found */ + +int32_t mz_zip_locate_first_entry(void *handle, void *userdata, mz_zip_locate_entry_cb cb); +/* Locate the first matching entry based on a match callback */ + +int32_t mz_zip_locate_next_entry(void *handle, void *userdata, mz_zip_locate_entry_cb cb); +/* Locate the next matching entry based on a match callback */ + +/***************************************************************************/ + +int32_t mz_zip_attrib_is_dir(uint32_t attrib, int32_t version_madeby); +/* Checks to see if the attribute is a directory based on platform */ + +int32_t mz_zip_attrib_is_symlink(uint32_t attrib, int32_t version_madeby); +/* Checks to see if the attribute is a symbolic link based on platform */ + +int32_t mz_zip_attrib_convert(uint8_t src_sys, uint32_t src_attrib, uint8_t target_sys, + uint32_t *target_attrib); +/* Converts file attributes from one host system to another */ + +int32_t mz_zip_attrib_posix_to_win32(uint32_t posix_attrib, uint32_t *win32_attrib); +/* Converts posix file attributes to win32 file attributes */ + +int32_t mz_zip_attrib_win32_to_posix(uint32_t win32_attrib, uint32_t *posix_attrib); +/* Converts win32 file attributes to posix file attributes */ + +/***************************************************************************/ + +int32_t mz_zip_extrafield_find(void *stream, uint16_t type, int32_t max_seek, uint16_t *length); +/* Seeks to extra field by its type and returns its length */ + +int32_t mz_zip_extrafield_contains(const uint8_t *extrafield, int32_t extrafield_size, + uint16_t type, uint16_t *length); +/* Gets whether an extrafield exists and its size */ + +int32_t mz_zip_extrafield_read(void *stream, uint16_t *type, uint16_t *length); +/* Reads an extrafield header from a stream */ + +int32_t mz_zip_extrafield_write(void *stream, uint16_t type, uint16_t length); +/* Writes an extrafield header to a stream */ + +/***************************************************************************/ + +int32_t mz_zip_dosdate_to_tm(uint64_t dos_date, struct tm *ptm); +/* Convert dos date/time format to struct tm */ + +time_t mz_zip_dosdate_to_time_t(uint64_t dos_date); +/* Convert dos date/time format to time_t */ + +int32_t mz_zip_time_t_to_tm(time_t unix_time, struct tm *ptm); +/* Convert time_t to time struct */ + +uint32_t mz_zip_time_t_to_dos_date(time_t unix_time); +/* Convert time_t to dos date/time format */ + +uint32_t mz_zip_tm_to_dosdate(const struct tm *ptm); +/* Convert struct tm to dos date/time format */ + +int32_t mz_zip_ntfs_to_unix_time(uint64_t ntfs_time, time_t *unix_time); +/* Convert ntfs time to unix time */ + +int32_t mz_zip_unix_to_ntfs_time(time_t unix_time, uint64_t *ntfs_time); +/* Convert unix time to ntfs time */ + +/***************************************************************************/ + +int32_t mz_zip_path_compare(const char *path1, const char *path2, uint8_t ignore_case); +/* Compare two paths without regard to slashes */ + +/***************************************************************************/ + +const +char* mz_zip_get_compression_method_string(int32_t compression_method); +/* Gets a string representing the compression method */ + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif /* _ZIP_H */ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_zip_rw.c b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_zip_rw.c new file mode 100644 index 0000000000000000000000000000000000000000..464e55905700f7bd8812693d5bf2c50c87263bda --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_zip_rw.c @@ -0,0 +1,1943 @@ +/* mz_zip_rw.c -- Zip reader/writer + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#include "mz.h" +#include "mz_crypt.h" +#include "mz_os.h" +#include "mz_strm.h" +#include "mz_strm_buf.h" +#include "mz_strm_mem.h" +#include "mz_strm_os.h" +#include "mz_strm_split.h" +#include "mz_strm_wzaes.h" +#include "mz_zip.h" + +#include "mz_zip_rw.h" + +/***************************************************************************/ + +#define MZ_DEFAULT_PROGRESS_INTERVAL (1000u) + +#define MZ_ZIP_CD_FILENAME ("__cdcd__") + +/***************************************************************************/ + +typedef struct mz_zip_reader_s { + void *zip_handle; + void *file_stream; + void *buffered_stream; + void *split_stream; + void *mem_stream; + void *hash; + uint16_t hash_algorithm; + uint16_t hash_digest_size; + mz_zip_file *file_info; + const char *pattern; + uint8_t pattern_ignore_case; + const char *password; + void *overwrite_userdata; + mz_zip_reader_overwrite_cb + overwrite_cb; + void *password_userdata; + mz_zip_reader_password_cb + password_cb; + void *progress_userdata; + mz_zip_reader_progress_cb + progress_cb; + uint32_t progress_cb_interval_ms; + void *entry_userdata; + mz_zip_reader_entry_cb + entry_cb; + uint8_t raw; + uint8_t buffer[UINT16_MAX]; + int32_t encoding; + uint8_t sign_required; + uint8_t cd_verified; + uint8_t cd_zipped; + uint8_t entry_verified; + uint8_t recover; +} mz_zip_reader; + +/***************************************************************************/ + +int32_t mz_zip_reader_is_open(void *handle) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + if (reader == NULL) + return MZ_PARAM_ERROR; + if (reader->zip_handle == NULL) + return MZ_PARAM_ERROR; + return MZ_OK; +} + +int32_t mz_zip_reader_open(void *handle, void *stream) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t err = MZ_OK; + + reader->cd_verified = 0; + reader->cd_zipped = 0; + + mz_zip_create(&reader->zip_handle); + mz_zip_set_recover(reader->zip_handle, reader->recover); + + err = mz_zip_open(reader->zip_handle, stream, MZ_OPEN_MODE_READ); + + if (err != MZ_OK) { + mz_zip_reader_close(handle); + return err; + } + + mz_zip_reader_unzip_cd(reader); + return MZ_OK; +} + +int32_t mz_zip_reader_open_file(void *handle, const char *path) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t err = MZ_OK; + + + mz_zip_reader_close(handle); + + mz_stream_os_create(&reader->file_stream); + mz_stream_buffered_create(&reader->buffered_stream); + mz_stream_split_create(&reader->split_stream); + + mz_stream_set_base(reader->buffered_stream, reader->file_stream); + mz_stream_set_base(reader->split_stream, reader->buffered_stream); + + err = mz_stream_open(reader->split_stream, path, MZ_OPEN_MODE_READ); + if (err == MZ_OK) + err = mz_zip_reader_open(handle, reader->split_stream); + return err; +} + +int32_t mz_zip_reader_open_file_in_memory(void *handle, const char *path) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + void *file_stream = NULL; + int64_t file_size = 0; + int32_t err = 0; + + + mz_zip_reader_close(handle); + + mz_stream_os_create(&file_stream); + + err = mz_stream_os_open(file_stream, path, MZ_OPEN_MODE_READ); + + if (err != MZ_OK) { + mz_stream_os_delete(&file_stream); + mz_zip_reader_close(handle); + return err; + } + + mz_stream_os_seek(file_stream, 0, MZ_SEEK_END); + file_size = mz_stream_os_tell(file_stream); + mz_stream_os_seek(file_stream, 0, MZ_SEEK_SET); + + if ((file_size <= 0) || (file_size > UINT32_MAX)) { + /* Memory size is too large or too small */ + + mz_stream_os_close(file_stream); + mz_stream_os_delete(&file_stream); + mz_zip_reader_close(handle); + return MZ_MEM_ERROR; + } + + mz_stream_mem_create(&reader->mem_stream); + mz_stream_mem_set_grow_size(reader->mem_stream, (int32_t)file_size); + mz_stream_mem_open(reader->mem_stream, NULL, MZ_OPEN_MODE_CREATE); + + err = mz_stream_copy(reader->mem_stream, file_stream, (int32_t)file_size); + + mz_stream_os_close(file_stream); + mz_stream_os_delete(&file_stream); + + if (err == MZ_OK) + err = mz_zip_reader_open(handle, reader->mem_stream); + if (err != MZ_OK) + mz_zip_reader_close(handle); + + return err; +} + +int32_t mz_zip_reader_open_buffer(void *handle, uint8_t *buf, int32_t len, uint8_t copy) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t err = MZ_OK; + + mz_zip_reader_close(handle); + + mz_stream_mem_create(&reader->mem_stream); + + if (copy) { + mz_stream_mem_set_grow_size(reader->mem_stream, len); + mz_stream_mem_open(reader->mem_stream, NULL, MZ_OPEN_MODE_CREATE); + mz_stream_mem_write(reader->mem_stream, buf, len); + mz_stream_mem_seek(reader->mem_stream, 0, MZ_SEEK_SET); + } else { + mz_stream_mem_open(reader->mem_stream, NULL, MZ_OPEN_MODE_READ); + mz_stream_mem_set_buffer(reader->mem_stream, buf, len); + } + + if (err == MZ_OK) + err = mz_zip_reader_open(handle, reader->mem_stream); + + return err; +} + +int32_t mz_zip_reader_close(void *handle) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t err = MZ_OK; + + if (reader->zip_handle != NULL) { + err = mz_zip_close(reader->zip_handle); + mz_zip_delete(&reader->zip_handle); + } + + if (reader->split_stream != NULL) { + mz_stream_split_close(reader->split_stream); + mz_stream_split_delete(&reader->split_stream); + } + + if (reader->buffered_stream != NULL) + mz_stream_buffered_delete(&reader->buffered_stream); + + if (reader->file_stream != NULL) + mz_stream_os_delete(&reader->file_stream); + + if (reader->mem_stream != NULL) { + mz_stream_mem_close(reader->mem_stream); + mz_stream_mem_delete(&reader->mem_stream); + } + + return err; +} + +/***************************************************************************/ + +int32_t mz_zip_reader_unzip_cd(void *handle) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + mz_zip_file *cd_info = NULL; + void *cd_mem_stream = NULL; + void *new_cd_stream = NULL; + void *file_extra_stream = NULL; + uint64_t number_entry = 0; + int32_t err = MZ_OK; + + + err = mz_zip_reader_goto_first_entry(handle); + if (err != MZ_OK) + return err; + err = mz_zip_reader_entry_get_info(handle, &cd_info); + if (err != MZ_OK) + return err; + + if (strcmp(cd_info->filename, MZ_ZIP_CD_FILENAME) != 0) + return mz_zip_reader_goto_first_entry(handle); + + err = mz_zip_reader_entry_open(handle); + if (err != MZ_OK) + return err; + + mz_stream_mem_create(&file_extra_stream); + mz_stream_mem_set_buffer(file_extra_stream, (void *)cd_info->extrafield, cd_info->extrafield_size); + + err = mz_zip_extrafield_find(file_extra_stream, MZ_ZIP_EXTENSION_CDCD, INT32_MAX, NULL); + if (err == MZ_OK) + err = mz_stream_read_uint64(file_extra_stream, &number_entry); + + mz_stream_mem_delete(&file_extra_stream); + + if (err != MZ_OK) + return err; + + mz_zip_get_cd_mem_stream(reader->zip_handle, &cd_mem_stream); + if (mz_stream_mem_is_open(cd_mem_stream) != MZ_OK) + mz_stream_mem_open(cd_mem_stream, NULL, MZ_OPEN_MODE_CREATE); + + err = mz_stream_seek(cd_mem_stream, 0, MZ_SEEK_SET); + if (err == MZ_OK) + err = mz_stream_copy_stream(cd_mem_stream, NULL, handle, mz_zip_reader_entry_read, + (int32_t)cd_info->uncompressed_size); + + if (err == MZ_OK) { + reader->cd_zipped = 1; + + mz_zip_set_cd_stream(reader->zip_handle, 0, cd_mem_stream); + mz_zip_set_number_entry(reader->zip_handle, number_entry); + + err = mz_zip_reader_goto_first_entry(handle); + } + + reader->cd_verified = reader->entry_verified; + + mz_stream_mem_delete(&new_cd_stream); + return err; +} + +/***************************************************************************/ + +static int32_t mz_zip_reader_locate_entry_cb(void *handle, void *userdata, mz_zip_file *file_info) { + mz_zip_reader *reader = (mz_zip_reader *)userdata; + int32_t result = 0; + MZ_UNUSED(handle); + result = mz_path_compare_wc(file_info->filename, reader->pattern, reader->pattern_ignore_case); + return result; +} + +int32_t mz_zip_reader_goto_first_entry(void *handle) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t err = MZ_OK; + + if (mz_zip_reader_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + + if (mz_zip_entry_is_open(reader->zip_handle) == MZ_OK) + mz_zip_reader_entry_close(handle); + + if (reader->pattern == NULL) + err = mz_zip_goto_first_entry(reader->zip_handle); + else + err = mz_zip_locate_first_entry(reader->zip_handle, reader, mz_zip_reader_locate_entry_cb); + + reader->file_info = NULL; + if (err == MZ_OK) + err = mz_zip_entry_get_info(reader->zip_handle, &reader->file_info); + + return err; +} + +int32_t mz_zip_reader_goto_next_entry(void *handle) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t err = MZ_OK; + + if (mz_zip_reader_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + + if (mz_zip_entry_is_open(reader->zip_handle) == MZ_OK) + mz_zip_reader_entry_close(handle); + + if (reader->pattern == NULL) + err = mz_zip_goto_next_entry(reader->zip_handle); + else + err = mz_zip_locate_next_entry(reader->zip_handle, reader, mz_zip_reader_locate_entry_cb); + + reader->file_info = NULL; + if (err == MZ_OK) + err = mz_zip_entry_get_info(reader->zip_handle, &reader->file_info); + + return err; +} + +int32_t mz_zip_reader_locate_entry(void *handle, const char *filename, uint8_t ignore_case) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t err = MZ_OK; + + if (mz_zip_entry_is_open(reader->zip_handle) == MZ_OK) + mz_zip_reader_entry_close(handle); + + err = mz_zip_locate_entry(reader->zip_handle, filename, ignore_case); + + reader->file_info = NULL; + if (err == MZ_OK) + err = mz_zip_entry_get_info(reader->zip_handle, &reader->file_info); + + return err; +} + +/***************************************************************************/ + +int32_t mz_zip_reader_entry_open(void *handle) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t err = MZ_OK; + const char *password = NULL; + char password_buf[120]; + + + reader->entry_verified = 0; + + if (mz_zip_reader_is_open(reader) != MZ_OK) + return MZ_PARAM_ERROR; + if (reader->file_info == NULL) + return MZ_PARAM_ERROR; + + /* If the entry isn't open for reading, open it */ + if (mz_zip_entry_is_open(reader->zip_handle) == MZ_OK) + return MZ_OK; + + password = reader->password; + + /* Check if we need a password and ask for it if we need to */ + if ((reader->file_info->flag & MZ_ZIP_FLAG_ENCRYPTED) && (password == NULL) && + (reader->password_cb != NULL)) { + reader->password_cb(handle, reader->password_userdata, reader->file_info, + password_buf, sizeof(password_buf)); + + password = password_buf; + } + + err = mz_zip_entry_read_open(reader->zip_handle, reader->raw, password); +#ifndef MZ_ZIP_NO_CRYPTO + if (err != MZ_OK) + return err; + + if (mz_zip_reader_entry_get_first_hash(handle, &reader->hash_algorithm, &reader->hash_digest_size) == MZ_OK) { + mz_crypt_sha_create(&reader->hash); + if (reader->hash_algorithm == MZ_HASH_SHA1) + mz_crypt_sha_set_algorithm(reader->hash, MZ_HASH_SHA1); + else if (reader->hash_algorithm == MZ_HASH_SHA256) + mz_crypt_sha_set_algorithm(reader->hash, MZ_HASH_SHA256); + else + err = MZ_SUPPORT_ERROR; + + if (err == MZ_OK) + mz_crypt_sha_begin(reader->hash); +#ifdef MZ_ZIP_SIGNING + if (err == MZ_OK) { + if (mz_zip_reader_entry_has_sign(handle) == MZ_OK) { + err = mz_zip_reader_entry_sign_verify(handle); + if (err == MZ_OK) + reader->entry_verified = 1; + } else if (reader->sign_required && !reader->cd_verified) + err = MZ_SIGN_ERROR; + } +#endif + } else if (reader->sign_required && !reader->cd_verified) + err = MZ_SIGN_ERROR; +#endif + + return err; +} + +int32_t mz_zip_reader_entry_close(void *handle) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t err = MZ_OK; + int32_t err_close = MZ_OK; +#ifndef MZ_ZIP_NO_CRYPTO + int32_t err_hash = MZ_OK; + uint8_t computed_hash[MZ_HASH_MAX_SIZE]; + uint8_t expected_hash[MZ_HASH_MAX_SIZE]; + + if (reader->hash != NULL) { + mz_crypt_sha_end(reader->hash, computed_hash, sizeof(computed_hash)); + mz_crypt_sha_delete(&reader->hash); + + err_hash = mz_zip_reader_entry_get_hash(handle, reader->hash_algorithm, expected_hash, + reader->hash_digest_size); + + if (err_hash == MZ_OK) { + /* Verify expected hash against computed hash */ + if (memcmp(computed_hash, expected_hash, reader->hash_digest_size) != 0) + err = MZ_CRC_ERROR; + } + } +#endif + + err_close = mz_zip_entry_close(reader->zip_handle); + if (err == MZ_OK) + err = err_close; + return err; +} + +int32_t mz_zip_reader_entry_read(void *handle, void *buf, int32_t len) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t read = 0; + read = mz_zip_entry_read(reader->zip_handle, buf, len); +#ifndef MZ_ZIP_NO_CRYPTO + if ((read > 0) && (reader->hash != NULL)) + mz_crypt_sha_update(reader->hash, buf, read); +#endif + return read; +} + +int32_t mz_zip_reader_entry_has_sign(void *handle) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + + if (reader == NULL || mz_zip_entry_is_open(reader->zip_handle) != MZ_OK) + return MZ_PARAM_ERROR; + + return mz_zip_extrafield_contains(reader->file_info->extrafield, + reader->file_info->extrafield_size, MZ_ZIP_EXTENSION_SIGN, NULL); +} + +#if !defined(MZ_ZIP_NO_CRYPTO) && defined(MZ_ZIP_SIGNING) +int32_t mz_zip_reader_entry_sign_verify(void *handle) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + void *file_extra_stream = NULL; + int32_t err = MZ_OK; + uint8_t *signature = NULL; + uint16_t signature_size = 0; + uint8_t hash[MZ_HASH_MAX_SIZE]; + + if (reader == NULL || mz_zip_entry_is_open(reader->zip_handle) != MZ_OK) + return MZ_PARAM_ERROR; + + mz_stream_mem_create(&file_extra_stream); + mz_stream_mem_set_buffer(file_extra_stream, (void *)reader->file_info->extrafield, + reader->file_info->extrafield_size); + + err = mz_zip_extrafield_find(file_extra_stream, MZ_ZIP_EXTENSION_SIGN, INT32_MAX, &signature_size); + if ((err == MZ_OK) && (signature_size > 0)) { + signature = (uint8_t *)MZ_ALLOC(signature_size); + if (mz_stream_read(file_extra_stream, signature, signature_size) != signature_size) + err = MZ_READ_ERROR; + } + + mz_stream_mem_delete(&file_extra_stream); + + if (err == MZ_OK) { + /* Get most secure hash to verify signature against */ + err = mz_zip_reader_entry_get_hash(handle, reader->hash_algorithm, hash, reader->hash_digest_size); + } + + if (err == MZ_OK) { + /* Verify the pkcs signature */ + err = mz_crypt_sign_verify(hash, reader->hash_digest_size, signature, signature_size); + } + + if (signature != NULL) + MZ_FREE(signature); + + return err; +} +#endif + +int32_t mz_zip_reader_entry_get_hash(void *handle, uint16_t algorithm, uint8_t *digest, int32_t digest_size) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + void *file_extra_stream = NULL; + int32_t err = MZ_OK; + int32_t return_err = MZ_EXIST_ERROR; + uint16_t cur_algorithm = 0; + uint16_t cur_digest_size = 0; + + mz_stream_mem_create(&file_extra_stream); + mz_stream_mem_set_buffer(file_extra_stream, (void *)reader->file_info->extrafield, + reader->file_info->extrafield_size); + + do { + err = mz_zip_extrafield_find(file_extra_stream, MZ_ZIP_EXTENSION_HASH, INT32_MAX, NULL); + if (err != MZ_OK) + break; + + err = mz_stream_read_uint16(file_extra_stream, &cur_algorithm); + if (err == MZ_OK) + err = mz_stream_read_uint16(file_extra_stream, &cur_digest_size); + if ((err == MZ_OK) && (cur_algorithm == algorithm) && (cur_digest_size <= digest_size) && + (cur_digest_size <= MZ_HASH_MAX_SIZE)) { + /* Read hash digest */ + if (mz_stream_read(file_extra_stream, digest, digest_size) == cur_digest_size) + return_err = MZ_OK; + break; + } else { + err = mz_stream_seek(file_extra_stream, cur_digest_size, MZ_SEEK_CUR); + } + } while (err == MZ_OK); + + mz_stream_mem_delete(&file_extra_stream); + + return return_err; +} + +int32_t mz_zip_reader_entry_get_first_hash(void *handle, uint16_t *algorithm, uint16_t *digest_size) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + void *file_extra_stream = NULL; + int32_t err = MZ_OK; + uint16_t cur_algorithm = 0; + uint16_t cur_digest_size = 0; + + if (reader == NULL || algorithm == NULL) + return MZ_PARAM_ERROR; + + mz_stream_mem_create(&file_extra_stream); + mz_stream_mem_set_buffer(file_extra_stream, (void *)reader->file_info->extrafield, + reader->file_info->extrafield_size); + + err = mz_zip_extrafield_find(file_extra_stream, MZ_ZIP_EXTENSION_HASH, INT32_MAX, NULL); + if (err == MZ_OK) + err = mz_stream_read_uint16(file_extra_stream, &cur_algorithm); + if (err == MZ_OK) + err = mz_stream_read_uint16(file_extra_stream, &cur_digest_size); + + if (algorithm != NULL) + *algorithm = cur_algorithm; + if (digest_size != NULL) + *digest_size = cur_digest_size; + + mz_stream_mem_delete(&file_extra_stream); + + return err; +} + +int32_t mz_zip_reader_entry_get_info(void *handle, mz_zip_file **file_info) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t err = MZ_OK; + if (file_info == NULL || mz_zip_reader_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + *file_info = reader->file_info; + if (*file_info == NULL) + return MZ_EXIST_ERROR; + return err; +} + +int32_t mz_zip_reader_entry_is_dir(void *handle) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + if (mz_zip_reader_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + return mz_zip_entry_is_dir(reader->zip_handle); +} + +int32_t mz_zip_reader_entry_save_process(void *handle, void *stream, mz_stream_write_cb write_cb) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t err = MZ_OK; + int32_t read = 0; + int32_t written = 0; + + + if (mz_zip_reader_is_open(reader) != MZ_OK) + return MZ_PARAM_ERROR; + if (reader->file_info == NULL) + return MZ_PARAM_ERROR; + if (write_cb == NULL) + return MZ_PARAM_ERROR; + + /* If the entry isn't open for reading, open it */ + if (mz_zip_entry_is_open(reader->zip_handle) != MZ_OK) + err = mz_zip_reader_entry_open(handle); + + if (err != MZ_OK) + return err; + + /* Unzip entry in zip file */ + read = mz_zip_reader_entry_read(handle, reader->buffer, sizeof(reader->buffer)); + + if (read == 0) { + /* If we are done close the entry */ + err = mz_zip_reader_entry_close(handle); + if (err != MZ_OK) + return err; + + return MZ_END_OF_STREAM; + } + + if (read > 0) { + /* Write the data to the specified stream */ + written = write_cb(stream, reader->buffer, read); + if (written != read) + return MZ_WRITE_ERROR; + } + + return read; +} + +int32_t mz_zip_reader_entry_save(void *handle, void *stream, mz_stream_write_cb write_cb) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + uint64_t current_time = 0; + uint64_t update_time = 0; + int64_t current_pos = 0; + int64_t update_pos = 0; + int32_t err = MZ_OK; + int32_t written = 0; + + if (mz_zip_reader_is_open(reader) != MZ_OK) + return MZ_PARAM_ERROR; + if (reader->file_info == NULL) + return MZ_PARAM_ERROR; + + /* Update the progress at the beginning */ + if (reader->progress_cb != NULL) + reader->progress_cb(handle, reader->progress_userdata, reader->file_info, current_pos); + + /* Write data to stream until done */ + while (err == MZ_OK) { + written = mz_zip_reader_entry_save_process(handle, stream, write_cb); + if (written == MZ_END_OF_STREAM) + break; + if (written > 0) + current_pos += written; + if (written < 0) + err = written; + + /* Update progress if enough time have passed */ + current_time = mz_os_ms_time(); + if ((current_time - update_time) > reader->progress_cb_interval_ms) { + if (reader->progress_cb != NULL) + reader->progress_cb(handle, reader->progress_userdata, reader->file_info, current_pos); + + update_pos = current_pos; + update_time = current_time; + } + } + + /* Update the progress at the end */ + if (reader->progress_cb != NULL && update_pos != current_pos) + reader->progress_cb(handle, reader->progress_userdata, reader->file_info, current_pos); + + return err; +} + +int32_t mz_zip_reader_entry_save_file(void *handle, const char *path) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + void *stream = NULL; + uint32_t target_attrib = 0; + int32_t err_attrib = 0; + int32_t err = MZ_OK; + int32_t err_cb = MZ_OK; + char pathwfs[512]; + char directory[512]; + + if (mz_zip_reader_is_open(reader) != MZ_OK) + return MZ_PARAM_ERROR; + if (reader->file_info == NULL || path == NULL) + return MZ_PARAM_ERROR; + + /* Convert to forward slashes for unix which doesn't like backslashes */ + strncpy(pathwfs, path, sizeof(pathwfs) - 1); + pathwfs[sizeof(pathwfs) - 1] = 0; + mz_path_convert_slashes(pathwfs, MZ_PATH_SLASH_UNIX); + + if (reader->entry_cb != NULL) + reader->entry_cb(handle, reader->entry_userdata, reader->file_info, pathwfs); + + strncpy(directory, pathwfs, sizeof(directory) - 1); + directory[sizeof(directory) - 1] = 0; + mz_path_remove_filename(directory); + + /* If it is a directory entry then create a directory instead of writing file */ + if ((mz_zip_entry_is_dir(reader->zip_handle) == MZ_OK) && + (mz_zip_entry_is_symlink(reader->zip_handle) != MZ_OK)) { + err = mz_dir_make(directory); + return err; + } + + /* Check if file exists and ask if we want to overwrite */ + if ((mz_os_file_exists(pathwfs) == MZ_OK) && (reader->overwrite_cb != NULL)) { + err_cb = reader->overwrite_cb(handle, reader->overwrite_userdata, reader->file_info, pathwfs); + if (err_cb != MZ_OK) + return err; + /* We want to overwrite the file so we delete the existing one */ + mz_os_unlink(pathwfs); + } + + /* If symbolic link then properly construct destination path and link path */ + if (mz_zip_entry_is_symlink(reader->zip_handle) == MZ_OK) { + mz_path_remove_slash(pathwfs); + mz_path_remove_filename(directory); + } + + /* Create the output directory if it doesn't already exist */ + if (mz_os_is_dir(directory) != MZ_OK) { + err = mz_dir_make(directory); + if (err != MZ_OK) + return err; + } + + /* If it is a symbolic link then create symbolic link instead of writing file */ + if (mz_zip_entry_is_symlink(reader->zip_handle) == MZ_OK) { + mz_os_make_symlink(pathwfs, reader->file_info->linkname); + /* Don't check return value because we aren't validating symbolic link target */ + return err; + } + + /* Create the file on disk so we can save to it */ + mz_stream_os_create(&stream); + err = mz_stream_os_open(stream, pathwfs, MZ_OPEN_MODE_CREATE); + + if (err == MZ_OK) + err = mz_zip_reader_entry_save(handle, stream, mz_stream_write); + + mz_stream_close(stream); + mz_stream_delete(&stream); + + if (err == MZ_OK) { + /* Set the time of the file that has been created */ + mz_os_set_file_date(pathwfs, reader->file_info->modified_date, + reader->file_info->accessed_date, reader->file_info->creation_date); + } + + if (err == MZ_OK) { + /* Set file attributes for the correct system */ + err_attrib = mz_zip_attrib_convert(MZ_HOST_SYSTEM(reader->file_info->version_madeby), + reader->file_info->external_fa, MZ_VERSION_MADEBY_HOST_SYSTEM, &target_attrib); + + if (err_attrib == MZ_OK) + mz_os_set_file_attribs(pathwfs, target_attrib); + } + + return err; +} + +int32_t mz_zip_reader_entry_save_buffer(void *handle, void *buf, int32_t len) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + void *mem_stream = NULL; + int32_t err = MZ_OK; + + if (mz_zip_reader_is_open(reader) != MZ_OK) + return MZ_PARAM_ERROR; + if (reader->file_info == NULL) + return MZ_PARAM_ERROR; + if (reader->file_info->uncompressed_size > INT32_MAX) + return MZ_PARAM_ERROR; + if (len != (int32_t)reader->file_info->uncompressed_size) + return MZ_BUF_ERROR; + + /* Create a memory stream backed by our buffer and save to it */ + mz_stream_mem_create(&mem_stream); + mz_stream_mem_set_buffer(mem_stream, buf, len); + + err = mz_stream_mem_open(mem_stream, NULL, MZ_OPEN_MODE_READ); + if (err == MZ_OK) + err = mz_zip_reader_entry_save(handle, mem_stream, mz_stream_mem_write); + + mz_stream_mem_delete(&mem_stream); + return err; +} + +int32_t mz_zip_reader_entry_save_buffer_length(void *handle) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + + if (mz_zip_reader_is_open(reader) != MZ_OK) + return MZ_PARAM_ERROR; + if (reader->file_info == NULL) + return MZ_PARAM_ERROR; + if (reader->file_info->uncompressed_size > INT32_MAX) + return MZ_PARAM_ERROR; + + /* Get the maximum size required for the save buffer */ + return (int32_t)reader->file_info->uncompressed_size; +} + +/***************************************************************************/ + +int32_t mz_zip_reader_save_all(void *handle, const char *destination_dir) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + int32_t err = MZ_OK; + uint8_t *utf8_string = NULL; + char path[512]; + char utf8_name[256]; + char resolved_name[256]; + + err = mz_zip_reader_goto_first_entry(handle); + + if (err == MZ_END_OF_LIST) + return err; + + while (err == MZ_OK) { + /* Construct output path */ + path[0] = 0; + + strncpy(utf8_name, reader->file_info->filename, sizeof(utf8_name) - 1); + utf8_name[sizeof(utf8_name) - 1] = 0; + + if ((reader->encoding > 0) && (reader->file_info->flag & MZ_ZIP_FLAG_UTF8) == 0) { + utf8_string = mz_os_utf8_string_create(reader->file_info->filename, reader->encoding); + if (utf8_string) { + strncpy(utf8_name, (char *)utf8_string, sizeof(utf8_name) - 1); + utf8_name[sizeof(utf8_name) - 1] = 0; + mz_os_utf8_string_delete(&utf8_string); + } + } + + err = mz_path_resolve(utf8_name, resolved_name, sizeof(resolved_name)); + if (err != MZ_OK) + break; + + if (destination_dir != NULL) + mz_path_combine(path, destination_dir, sizeof(path)); + + mz_path_combine(path, resolved_name, sizeof(path)); + + /* Save file to disk */ + err = mz_zip_reader_entry_save_file(handle, path); + + if (err == MZ_OK) + err = mz_zip_reader_goto_next_entry(handle); + } + + if (err == MZ_END_OF_LIST) + return MZ_OK; + + return err; +} + +/***************************************************************************/ + +void mz_zip_reader_set_pattern(void *handle, const char *pattern, uint8_t ignore_case) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + reader->pattern = pattern; + reader->pattern_ignore_case = ignore_case; +} + +void mz_zip_reader_set_password(void *handle, const char *password) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + reader->password = password; +} + +void mz_zip_reader_set_raw(void *handle, uint8_t raw) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + reader->raw = raw; +} + +int32_t mz_zip_reader_get_raw(void *handle, uint8_t *raw) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + if (raw == NULL) + return MZ_PARAM_ERROR; + *raw = reader->raw; + return MZ_OK; +} + +int32_t mz_zip_reader_get_zip_cd(void *handle, uint8_t *zip_cd) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + if (zip_cd == NULL) + return MZ_PARAM_ERROR; + *zip_cd = reader->cd_zipped; + return MZ_OK; +} + +int32_t mz_zip_reader_get_comment(void *handle, const char **comment) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + if (mz_zip_reader_is_open(reader) != MZ_OK) + return MZ_PARAM_ERROR; + if (comment == NULL) + return MZ_PARAM_ERROR; + return mz_zip_get_comment(reader->zip_handle, comment); +} + +int32_t mz_zip_reader_set_recover(void *handle, uint8_t recover) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + if (reader == NULL) + return MZ_PARAM_ERROR; + reader->recover = recover; + return MZ_OK; +} + +void mz_zip_reader_set_encoding(void *handle, int32_t encoding) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + reader->encoding = encoding; +} + +void mz_zip_reader_set_sign_required(void *handle, uint8_t sign_required) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + reader->sign_required = sign_required; +} + +void mz_zip_reader_set_overwrite_cb(void *handle, void *userdata, mz_zip_reader_overwrite_cb cb) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + reader->overwrite_cb = cb; + reader->overwrite_userdata = userdata; +} + +void mz_zip_reader_set_password_cb(void *handle, void *userdata, mz_zip_reader_password_cb cb) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + reader->password_cb = cb; + reader->password_userdata = userdata; +} + +void mz_zip_reader_set_progress_cb(void *handle, void *userdata, mz_zip_reader_progress_cb cb) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + reader->progress_cb = cb; + reader->progress_userdata = userdata; +} + +void mz_zip_reader_set_progress_interval(void *handle, uint32_t milliseconds) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + reader->progress_cb_interval_ms = milliseconds; +} + +void mz_zip_reader_set_entry_cb(void *handle, void *userdata, mz_zip_reader_entry_cb cb) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + reader->entry_cb = cb; + reader->entry_userdata = userdata; +} + +int32_t mz_zip_reader_get_zip_handle(void *handle, void **zip_handle) { + mz_zip_reader *reader = (mz_zip_reader *)handle; + if (zip_handle == NULL) + return MZ_PARAM_ERROR; + *zip_handle = reader->zip_handle; + if (*zip_handle == NULL) + return MZ_EXIST_ERROR; + return MZ_OK; +} + +/***************************************************************************/ + +void *mz_zip_reader_create(void **handle) { + mz_zip_reader *reader = NULL; + + reader = (mz_zip_reader *)MZ_ALLOC(sizeof(mz_zip_reader)); + if (reader != NULL) { + memset(reader, 0, sizeof(mz_zip_reader)); + reader->recover = 1; + reader->progress_cb_interval_ms = MZ_DEFAULT_PROGRESS_INTERVAL; + } + if (handle != NULL) + *handle = reader; + + return reader; +} + +void mz_zip_reader_delete(void **handle) { + mz_zip_reader *reader = NULL; + if (handle == NULL) + return; + reader = (mz_zip_reader *)*handle; + if (reader != NULL) { + mz_zip_reader_close(reader); + MZ_FREE(reader); + } + *handle = NULL; +} + +/***************************************************************************/ + +typedef struct mz_zip_writer_s { + void *zip_handle; + void *file_stream; + void *buffered_stream; + void *split_stream; + void *sha256; + void *mem_stream; + void *file_extra_stream; + mz_zip_file file_info; + void *overwrite_userdata; + mz_zip_writer_overwrite_cb + overwrite_cb; + void *password_userdata; + mz_zip_writer_password_cb + password_cb; + void *progress_userdata; + mz_zip_writer_progress_cb + progress_cb; + uint32_t progress_cb_interval_ms; + void *entry_userdata; + mz_zip_writer_entry_cb + entry_cb; + const char *password; + const char *comment; + uint8_t *cert_data; + int32_t cert_data_size; + const char *cert_pwd; + uint16_t compress_method; + int16_t compress_level; + uint8_t follow_links; + uint8_t store_links; + uint8_t zip_cd; + uint8_t aes; + uint8_t raw; + uint8_t buffer[UINT16_MAX]; +} mz_zip_writer; + +/***************************************************************************/ + +int32_t mz_zip_writer_zip_cd(void *handle) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + mz_zip_file cd_file; + uint64_t number_entry = 0; + int64_t cd_mem_length = 0; + int32_t err = MZ_OK; + int32_t extrafield_size = 0; + void *file_extra_stream = NULL; + void *cd_mem_stream = NULL; + + + memset(&cd_file, 0, sizeof(cd_file)); + + mz_zip_get_number_entry(writer->zip_handle, &number_entry); + mz_zip_get_cd_mem_stream(writer->zip_handle, &cd_mem_stream); + mz_stream_seek(cd_mem_stream, 0, MZ_SEEK_END); + cd_mem_length = (uint32_t)mz_stream_tell(cd_mem_stream); + mz_stream_seek(cd_mem_stream, 0, MZ_SEEK_SET); + + cd_file.filename = MZ_ZIP_CD_FILENAME; + cd_file.modified_date = time(NULL); + cd_file.version_madeby = MZ_VERSION_MADEBY; + cd_file.compression_method = writer->compress_method; + cd_file.uncompressed_size = (int32_t)cd_mem_length; + cd_file.flag = MZ_ZIP_FLAG_UTF8; + + if (writer->password != NULL) + cd_file.flag |= MZ_ZIP_FLAG_ENCRYPTED; + + mz_stream_mem_create(&file_extra_stream); + mz_stream_mem_open(file_extra_stream, NULL, MZ_OPEN_MODE_CREATE); + + mz_zip_extrafield_write(file_extra_stream, MZ_ZIP_EXTENSION_CDCD, 8); + + mz_stream_write_uint64(file_extra_stream, number_entry); + + mz_stream_mem_get_buffer(file_extra_stream, (const void **)&cd_file.extrafield); + mz_stream_mem_get_buffer_length(file_extra_stream, &extrafield_size); + cd_file.extrafield_size = (uint16_t)extrafield_size; + + err = mz_zip_writer_entry_open(handle, &cd_file); + if (err == MZ_OK) { + mz_stream_copy_stream(handle, mz_zip_writer_entry_write, cd_mem_stream, + NULL, (int32_t)cd_mem_length); + + mz_stream_seek(cd_mem_stream, 0, MZ_SEEK_SET); + mz_stream_mem_set_buffer_limit(cd_mem_stream, 0); + + err = mz_zip_writer_entry_close(writer); + } + + mz_stream_mem_delete(&file_extra_stream); + + return err; +} + +/***************************************************************************/ + +int32_t mz_zip_writer_is_open(void *handle) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + if (writer == NULL) + return MZ_PARAM_ERROR; + if (writer->zip_handle == NULL) + return MZ_PARAM_ERROR; + return MZ_OK; +} + +static int32_t mz_zip_writer_open_int(void *handle, void *stream, int32_t mode) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + int32_t err = MZ_OK; + + mz_zip_create(&writer->zip_handle); + err = mz_zip_open(writer->zip_handle, stream, mode); + + if (err != MZ_OK) { + mz_zip_writer_close(handle); + return err; + } + + return MZ_OK; +} + +int32_t mz_zip_writer_open(void *handle, void *stream, uint8_t append) { + int32_t mode = MZ_OPEN_MODE_WRITE; + + if (append) { + mode |= MZ_OPEN_MODE_APPEND; + } else { + mode |= MZ_OPEN_MODE_CREATE; + } + + return mz_zip_writer_open_int(handle, stream, mode); +} + +int32_t mz_zip_writer_open_file(void *handle, const char *path, int64_t disk_size, uint8_t append) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + int32_t mode = MZ_OPEN_MODE_READWRITE; + int32_t err = MZ_OK; + int32_t err_cb = 0; + char directory[320]; + + mz_zip_writer_close(handle); + + if (mz_os_file_exists(path) != MZ_OK) { + /* If the file doesn't exist, we don't append file */ + mode |= MZ_OPEN_MODE_CREATE; + + /* Create destination directory if it doesn't already exist */ + if (strchr(path, '/') != NULL || strrchr(path, '\\') != NULL) { + strncpy(directory, path, sizeof(directory)); + mz_path_remove_filename(directory); + if (mz_os_file_exists(directory) != MZ_OK) + mz_dir_make(directory); + } + } else if (append) { + mode |= MZ_OPEN_MODE_APPEND; + } else { + if (writer->overwrite_cb != NULL) + err_cb = writer->overwrite_cb(handle, writer->overwrite_userdata, path); + + if (err_cb == MZ_INTERNAL_ERROR) + return err; + + if (err_cb == MZ_OK) + mode |= MZ_OPEN_MODE_CREATE; + else + mode |= MZ_OPEN_MODE_APPEND; + } + + mz_stream_os_create(&writer->file_stream); + mz_stream_buffered_create(&writer->buffered_stream); + mz_stream_split_create(&writer->split_stream); + + mz_stream_set_base(writer->buffered_stream, writer->file_stream); + mz_stream_set_base(writer->split_stream, writer->buffered_stream); + + mz_stream_split_set_prop_int64(writer->split_stream, MZ_STREAM_PROP_DISK_SIZE, disk_size); + + err = mz_stream_open(writer->split_stream, path, mode); + if (err == MZ_OK) + err = mz_zip_writer_open_int(handle, writer->split_stream, mode); + + return err; +} + +int32_t mz_zip_writer_open_file_in_memory(void *handle, const char *path) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + void *file_stream = NULL; + int64_t file_size = 0; + int32_t err = 0; + + + mz_zip_writer_close(handle); + + mz_stream_os_create(&file_stream); + + err = mz_stream_os_open(file_stream, path, MZ_OPEN_MODE_READ); + + if (err != MZ_OK) { + mz_stream_os_delete(&file_stream); + mz_zip_writer_close(handle); + return err; + } + + mz_stream_os_seek(file_stream, 0, MZ_SEEK_END); + file_size = mz_stream_os_tell(file_stream); + mz_stream_os_seek(file_stream, 0, MZ_SEEK_SET); + + if ((file_size <= 0) || (file_size > UINT32_MAX)) { + /* Memory size is too large or too small */ + + mz_stream_os_close(file_stream); + mz_stream_os_delete(&file_stream); + mz_zip_writer_close(handle); + return MZ_MEM_ERROR; + } + + mz_stream_mem_create(&writer->mem_stream); + mz_stream_mem_set_grow_size(writer->mem_stream, (int32_t)file_size); + mz_stream_mem_open(writer->mem_stream, NULL, MZ_OPEN_MODE_CREATE); + + err = mz_stream_copy(writer->mem_stream, file_stream, (int32_t)file_size); + + mz_stream_os_close(file_stream); + mz_stream_os_delete(&file_stream); + + if (err == MZ_OK) + err = mz_zip_writer_open(handle, writer->mem_stream, 1); + if (err != MZ_OK) + mz_zip_writer_close(handle); + + return err; +} + +int32_t mz_zip_writer_close(void *handle) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + int32_t err = MZ_OK; + + + if (writer->zip_handle != NULL) { + mz_zip_set_version_madeby(writer->zip_handle, MZ_VERSION_MADEBY); + if (writer->comment) + mz_zip_set_comment(writer->zip_handle, writer->comment); + if (writer->zip_cd) + mz_zip_writer_zip_cd(writer); + + err = mz_zip_close(writer->zip_handle); + mz_zip_delete(&writer->zip_handle); + } + + if (writer->split_stream != NULL) { + mz_stream_split_close(writer->split_stream); + mz_stream_split_delete(&writer->split_stream); + } + + if (writer->buffered_stream != NULL) + mz_stream_buffered_delete(&writer->buffered_stream); + + if (writer->file_stream != NULL) + mz_stream_os_delete(&writer->file_stream); + + if (writer->mem_stream != NULL) { + mz_stream_mem_close(writer->mem_stream); + mz_stream_mem_delete(&writer->mem_stream); + } + + return err; +} + +/***************************************************************************/ + +int32_t mz_zip_writer_entry_open(void *handle, mz_zip_file *file_info) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + int32_t err = MZ_OK; + const char *password = NULL; + char password_buf[120]; + + /* Copy file info to access data upon close */ + memcpy(&writer->file_info, file_info, sizeof(mz_zip_file)); + + if (writer->entry_cb != NULL) + writer->entry_cb(handle, writer->entry_userdata, &writer->file_info); + + password = writer->password; + + /* Check if we need a password and ask for it if we need to */ + if ((writer->file_info.flag & MZ_ZIP_FLAG_ENCRYPTED) && (password == NULL) && + (writer->password_cb != NULL)) { + writer->password_cb(handle, writer->password_userdata, &writer->file_info, + password_buf, sizeof(password_buf)); + password = password_buf; + } + +#ifndef MZ_ZIP_NO_CRYPTO + if (mz_zip_attrib_is_dir(writer->file_info.external_fa, writer->file_info.version_madeby) != MZ_OK) { + /* Start calculating sha256 */ + mz_crypt_sha_create(&writer->sha256); + mz_crypt_sha_set_algorithm(writer->sha256, MZ_HASH_SHA256); + mz_crypt_sha_begin(writer->sha256); + } +#endif + + /* Open entry in zip */ + err = mz_zip_entry_write_open(writer->zip_handle, &writer->file_info, writer->compress_level, + writer->raw, password); + + return err; +} + +#if !defined(MZ_ZIP_NO_CRYPTO) && defined(MZ_ZIP_SIGNING) +int32_t mz_zip_writer_entry_sign(void *handle, uint8_t *message, int32_t message_size, + uint8_t *cert_data, int32_t cert_data_size, const char *cert_pwd) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + int32_t err = MZ_OK; + int32_t signature_size = 0; + uint8_t *signature = NULL; + + + if (writer == NULL || cert_data == NULL || cert_data_size <= 0) + return MZ_PARAM_ERROR; + if (mz_zip_entry_is_open(writer->zip_handle) != MZ_OK) + return MZ_PARAM_ERROR; + + /* Sign message with certificate */ + err = mz_crypt_sign(message, message_size, cert_data, cert_data_size, cert_pwd, + &signature, &signature_size); + + if ((err == MZ_OK) && (signature != NULL)) { + /* Write signature zip extra field */ + err = mz_zip_extrafield_write(writer->file_extra_stream, MZ_ZIP_EXTENSION_SIGN, + (uint16_t)signature_size); + + if (err == MZ_OK) { + if (mz_stream_write(writer->file_extra_stream, signature, signature_size) != signature_size) + err = MZ_WRITE_ERROR; + } + + MZ_FREE(signature); + } + + return err; +} +#endif + +int32_t mz_zip_writer_entry_close(void *handle) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + int32_t err = MZ_OK; +#ifndef MZ_ZIP_NO_CRYPTO + const uint8_t *extrafield = NULL; + int32_t extrafield_size = 0; + int16_t field_length_hash = 0; + uint8_t sha256[MZ_HASH_SHA256_SIZE]; + + + if (writer->sha256 != NULL) { + mz_crypt_sha_end(writer->sha256, sha256, sizeof(sha256)); + mz_crypt_sha_delete(&writer->sha256); + + /* Copy extrafield so we can append our own fields before close */ + mz_stream_mem_create(&writer->file_extra_stream); + mz_stream_mem_open(writer->file_extra_stream, NULL, MZ_OPEN_MODE_CREATE); + + /* Write sha256 hash to extrafield */ + field_length_hash = 4 + MZ_HASH_SHA256_SIZE; + err = mz_zip_extrafield_write(writer->file_extra_stream, MZ_ZIP_EXTENSION_HASH, field_length_hash); + if (err == MZ_OK) + err = mz_stream_write_uint16(writer->file_extra_stream, MZ_HASH_SHA256); + if (err == MZ_OK) + err = mz_stream_write_uint16(writer->file_extra_stream, MZ_HASH_SHA256_SIZE); + if (err == MZ_OK) { + if (mz_stream_write(writer->file_extra_stream, sha256, sizeof(sha256)) != MZ_HASH_SHA256_SIZE) + err = MZ_WRITE_ERROR; + } + +#ifdef MZ_ZIP_SIGNING + if ((err == MZ_OK) && (writer->cert_data != NULL) && (writer->cert_data_size > 0)) { + /* Sign entry if not zipping cd or if it is cd being zipped */ + if (!writer->zip_cd || strcmp(writer->file_info.filename, MZ_ZIP_CD_FILENAME) == 0) { + err = mz_zip_writer_entry_sign(handle, sha256, sizeof(sha256), + writer->cert_data, writer->cert_data_size, writer->cert_pwd); + } + } +#endif + + if ((writer->file_info.extrafield != NULL) && (writer->file_info.extrafield_size > 0)) + mz_stream_mem_write(writer->file_extra_stream, writer->file_info.extrafield, + writer->file_info.extrafield_size); + + /* Update extra field for central directory after adding extra fields */ + mz_stream_mem_get_buffer(writer->file_extra_stream, (const void **)&extrafield); + mz_stream_mem_get_buffer_length(writer->file_extra_stream, &extrafield_size); + + mz_zip_entry_set_extrafield(writer->zip_handle, extrafield, (uint16_t)extrafield_size); + } +#endif + + if (err == MZ_OK) { + if (writer->raw) + err = mz_zip_entry_close_raw(writer->zip_handle, writer->file_info.uncompressed_size, + writer->file_info.crc); + else + err = mz_zip_entry_close(writer->zip_handle); + } + + if (writer->file_extra_stream != NULL) + mz_stream_mem_delete(&writer->file_extra_stream); + + return err; +} + +int32_t mz_zip_writer_entry_write(void *handle, const void *buf, int32_t len) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + int32_t written = 0; + written = mz_zip_entry_write(writer->zip_handle, buf, len); +#ifndef MZ_ZIP_NO_CRYPTO + if ((written > 0) && (writer->sha256 != NULL)) + mz_crypt_sha_update(writer->sha256, buf, written); +#endif + return written; +} +/***************************************************************************/ + +int32_t mz_zip_writer_add_process(void *handle, void *stream, mz_stream_read_cb read_cb) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + int32_t read = 0; + int32_t written = 0; + int32_t err = MZ_OK; + + if (mz_zip_writer_is_open(writer) != MZ_OK) + return MZ_PARAM_ERROR; + /* If the entry isn't open for writing, open it */ + if (mz_zip_entry_is_open(writer->zip_handle) != MZ_OK) + return MZ_PARAM_ERROR; + if (read_cb == NULL) + return MZ_PARAM_ERROR; + + read = read_cb(stream, writer->buffer, sizeof(writer->buffer)); + if (read == 0) + return MZ_END_OF_STREAM; + if (read < 0) { + err = read; + return err; + } + + written = mz_zip_writer_entry_write(handle, writer->buffer, read); + if (written != read) + return MZ_WRITE_ERROR; + + return written; +} + +int32_t mz_zip_writer_add(void *handle, void *stream, mz_stream_read_cb read_cb) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + uint64_t current_time = 0; + uint64_t update_time = 0; + int64_t current_pos = 0; + int64_t update_pos = 0; + int32_t err = MZ_OK; + int32_t written = 0; + + /* Update the progress at the beginning */ + if (writer->progress_cb != NULL) + writer->progress_cb(handle, writer->progress_userdata, &writer->file_info, current_pos); + + /* Write data to stream until done */ + while (err == MZ_OK) { + written = mz_zip_writer_add_process(handle, stream, read_cb); + if (written == MZ_END_OF_STREAM) + break; + if (written > 0) + current_pos += written; + if (written < 0) + err = written; + + /* Update progress if enough time have passed */ + current_time = mz_os_ms_time(); + if ((current_time - update_time) > writer->progress_cb_interval_ms) { + if (writer->progress_cb != NULL) + writer->progress_cb(handle, writer->progress_userdata, &writer->file_info, current_pos); + + update_pos = current_pos; + update_time = current_time; + } + } + + /* Update the progress at the end */ + if (writer->progress_cb != NULL && update_pos != current_pos) + writer->progress_cb(handle, writer->progress_userdata, &writer->file_info, current_pos); + + return err; +} + +int32_t mz_zip_writer_add_info(void *handle, void *stream, mz_stream_read_cb read_cb, mz_zip_file *file_info) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + int32_t err = MZ_OK; + + + if (mz_zip_writer_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + if (file_info == NULL) + return MZ_PARAM_ERROR; + + /* Add to zip */ + err = mz_zip_writer_entry_open(handle, file_info); + if (err != MZ_OK) + return err; + + if (stream != NULL) { + if (mz_zip_attrib_is_dir(writer->file_info.external_fa, writer->file_info.version_madeby) != MZ_OK) { + err = mz_zip_writer_add(handle, stream, read_cb); + if (err != MZ_OK) + return err; + } + } + + err = mz_zip_writer_entry_close(handle); + + return err; +} + +int32_t mz_zip_writer_add_buffer(void *handle, void *buf, int32_t len, mz_zip_file *file_info) { + void *mem_stream = NULL; + int32_t err = MZ_OK; + + if (mz_zip_writer_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + if (buf == NULL) + return MZ_PARAM_ERROR; + + /* Create a memory stream backed by our buffer and add from it */ + mz_stream_mem_create(&mem_stream); + mz_stream_mem_set_buffer(mem_stream, buf, len); + + err = mz_stream_mem_open(mem_stream, NULL, MZ_OPEN_MODE_READ); + if (err == MZ_OK) + err = mz_zip_writer_add_info(handle, mem_stream, mz_stream_mem_read, file_info); + + mz_stream_mem_delete(&mem_stream); + return err; +} + +int32_t mz_zip_writer_add_file(void *handle, const char *path, const char *filename_in_zip) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + mz_zip_file file_info; + uint32_t target_attrib = 0; + uint32_t src_attrib = 0; + int32_t err = MZ_OK; + uint8_t src_sys = 0; + void *stream = NULL; + char link_path[1024]; + const char *filename = filename_in_zip; + + + if (mz_zip_writer_is_open(handle) != MZ_OK) + return MZ_PARAM_ERROR; + if (path == NULL) + return MZ_PARAM_ERROR; + + if (filename == NULL) { + err = mz_path_get_filename(path, &filename); + if (err != MZ_OK) + return err; + } + + memset(&file_info, 0, sizeof(file_info)); + + /* The path name saved, should not include a leading slash. */ + /* If it did, windows/xp and dynazip couldn't read the zip file. */ + + while (filename[0] == '\\' || filename[0] == '/') + filename += 1; + + /* Get information about the file on disk so we can store it in zip */ + + file_info.version_madeby = MZ_VERSION_MADEBY; + file_info.compression_method = writer->compress_method; + file_info.filename = filename; + file_info.uncompressed_size = mz_os_get_file_size(path); + file_info.flag = MZ_ZIP_FLAG_UTF8; + + if (writer->zip_cd) + file_info.flag |= MZ_ZIP_FLAG_MASK_LOCAL_INFO; + if (writer->aes) + file_info.aes_version = MZ_AES_VERSION; + + mz_os_get_file_date(path, &file_info.modified_date, &file_info.accessed_date, + &file_info.creation_date); + mz_os_get_file_attribs(path, &src_attrib); + + src_sys = MZ_HOST_SYSTEM(file_info.version_madeby); + + if ((src_sys != MZ_HOST_SYSTEM_MSDOS) && (src_sys != MZ_HOST_SYSTEM_WINDOWS_NTFS)) { + /* High bytes are OS specific attributes, low byte is always DOS attributes */ + if (mz_zip_attrib_convert(src_sys, src_attrib, MZ_HOST_SYSTEM_MSDOS, &target_attrib) == MZ_OK) + file_info.external_fa = target_attrib; + file_info.external_fa |= (src_attrib << 16); + } else { + file_info.external_fa = src_attrib; + } + + if (writer->store_links && mz_os_is_symlink(path) == MZ_OK) { + err = mz_os_read_symlink(path, link_path, sizeof(link_path)); + if (err == MZ_OK) + file_info.linkname = link_path; + } else if (mz_os_is_dir(path) != MZ_OK) { + mz_stream_os_create(&stream); + err = mz_stream_os_open(stream, path, MZ_OPEN_MODE_READ); + } + + if (err == MZ_OK) + err = mz_zip_writer_add_info(handle, stream, mz_stream_read, &file_info); + + if (stream != NULL) { + mz_stream_close(stream); + mz_stream_delete(&stream); + } + + return err; +} + +int32_t mz_zip_writer_add_path(void *handle, const char *path, const char *root_path, + uint8_t include_path, uint8_t recursive) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + DIR *dir = NULL; + struct dirent *entry = NULL; + int32_t err = MZ_OK; + int16_t is_dir = 0; + const char *filename = NULL; + const char *filenameinzip = path; + char *wildcard_ptr = NULL; + char full_path[1024]; + char path_dir[1024]; + + + if (strrchr(path, '*') != NULL) { + strncpy(path_dir, path, sizeof(path_dir) - 1); + path_dir[sizeof(path_dir) - 1] = 0; + mz_path_remove_filename(path_dir); + wildcard_ptr = path_dir + strlen(path_dir) + 1; + root_path = path = path_dir; + } else { + if (mz_os_is_dir(path) == MZ_OK) + is_dir = 1; + + /* Construct the filename that our file will be stored in the zip as */ + if (root_path == NULL) + root_path = path; + + /* Should the file be stored with any path info at all? */ + if (!include_path) { + if (!is_dir && root_path == path) { + if (mz_path_get_filename(filenameinzip, &filename) == MZ_OK) + filenameinzip = filename; + } else { + filenameinzip += strlen(root_path); + } + } + + if (!writer->store_links && !writer->follow_links) { + if (mz_os_is_symlink(path) == MZ_OK) + return err; + } + + if (*filenameinzip != 0) + err = mz_zip_writer_add_file(handle, path, filenameinzip); + + if (!is_dir) + return err; + + if (writer->store_links) { + if (mz_os_is_symlink(path) == MZ_OK) + return err; + } + } + + dir = mz_os_open_dir(path); + + if (dir == NULL) + return MZ_EXIST_ERROR; + + while ((entry = mz_os_read_dir(dir)) != NULL) { + if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) + continue; + + full_path[0] = 0; + mz_path_combine(full_path, path, sizeof(full_path)); + mz_path_combine(full_path, entry->d_name, sizeof(full_path)); + + if (!recursive && mz_os_is_dir(full_path) == MZ_OK) + continue; + + if ((wildcard_ptr != NULL) && (mz_path_compare_wc(entry->d_name, wildcard_ptr, 1) != MZ_OK)) + continue; + + err = mz_zip_writer_add_path(handle, full_path, root_path, include_path, recursive); + if (err != MZ_OK) + break; + } + + mz_os_close_dir(dir); + return err; +} + +int32_t mz_zip_writer_copy_from_reader(void *handle, void *reader) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + mz_zip_file *file_info = NULL; + int64_t compressed_size = 0; + int64_t uncompressed_size = 0; + uint32_t crc32 = 0; + int32_t err = MZ_OK; + uint8_t original_raw = 0; + void *reader_zip_handle = NULL; + void *writer_zip_handle = NULL; + + + if (mz_zip_reader_is_open(reader) != MZ_OK) + return MZ_PARAM_ERROR; + if (mz_zip_writer_is_open(writer) != MZ_OK) + return MZ_PARAM_ERROR; + + err = mz_zip_reader_entry_get_info(reader, &file_info); + + if (err != MZ_OK) + return err; + + mz_zip_reader_get_zip_handle(reader, &reader_zip_handle); + mz_zip_writer_get_zip_handle(writer, &writer_zip_handle); + + /* Open entry for raw reading */ + err = mz_zip_entry_read_open(reader_zip_handle, 1, NULL); + + if (err == MZ_OK) { + /* Write entry raw, save original raw value */ + original_raw = writer->raw; + writer->raw = 1; + + err = mz_zip_writer_entry_open(writer, file_info); + + if ((err == MZ_OK) && + (mz_zip_attrib_is_dir(writer->file_info.external_fa, writer->file_info.version_madeby) != MZ_OK)) { + err = mz_zip_writer_add(writer, reader_zip_handle, mz_zip_entry_read); + } + + if (err == MZ_OK) { + err = mz_zip_entry_read_close(reader_zip_handle, &crc32, &compressed_size, &uncompressed_size); + if (err == MZ_OK) + err = mz_zip_entry_write_close(writer_zip_handle, crc32, compressed_size, uncompressed_size); + } + + if (mz_zip_entry_is_open(reader_zip_handle) == MZ_OK) + mz_zip_entry_close(reader_zip_handle); + + if (mz_zip_entry_is_open(writer_zip_handle) == MZ_OK) + mz_zip_entry_close(writer_zip_handle); + + writer->raw = original_raw; + } + + return err; +} + +/***************************************************************************/ + +void mz_zip_writer_set_password(void *handle, const char *password) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->password = password; +} + +void mz_zip_writer_set_comment(void *handle, const char *comment) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->comment = comment; +} + +void mz_zip_writer_set_raw(void *handle, uint8_t raw) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->raw = raw; +} + +int32_t mz_zip_writer_get_raw(void *handle, uint8_t *raw) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + if (raw == NULL) + return MZ_PARAM_ERROR; + *raw = writer->raw; + return MZ_OK; +} + +void mz_zip_writer_set_aes(void *handle, uint8_t aes) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->aes = aes; +} + +void mz_zip_writer_set_compress_method(void *handle, uint16_t compress_method) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->compress_method = compress_method; +} + +void mz_zip_writer_set_compress_level(void *handle, int16_t compress_level) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->compress_level = compress_level; +} + +void mz_zip_writer_set_follow_links(void *handle, uint8_t follow_links) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->follow_links = follow_links; +} + +void mz_zip_writer_set_store_links(void *handle, uint8_t store_links) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->store_links = store_links; +} + +void mz_zip_writer_set_zip_cd(void *handle, uint8_t zip_cd) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->zip_cd = zip_cd; +} + +int32_t mz_zip_writer_set_certificate(void *handle, const char *cert_path, const char *cert_pwd) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + void *cert_stream = NULL; + uint8_t *cert_data = NULL; + int32_t cert_data_size = 0; + int32_t err = MZ_OK; + + if (cert_path == NULL) + return MZ_PARAM_ERROR; + + cert_data_size = (int32_t)mz_os_get_file_size(cert_path); + + if (cert_data_size == 0) + return MZ_PARAM_ERROR; + + if (writer->cert_data != NULL) { + MZ_FREE(writer->cert_data); + writer->cert_data = NULL; + } + + cert_data = (uint8_t *)MZ_ALLOC(cert_data_size); + + /* Read pkcs12 certificate from disk */ + mz_stream_os_create(&cert_stream); + err = mz_stream_os_open(cert_stream, cert_path, MZ_OPEN_MODE_READ); + if (err == MZ_OK) { + if (mz_stream_os_read(cert_stream, cert_data, cert_data_size) != cert_data_size) + err = MZ_READ_ERROR; + mz_stream_os_close(cert_stream); + } + mz_stream_os_delete(&cert_stream); + + if (err == MZ_OK) { + writer->cert_data = cert_data; + writer->cert_data_size = cert_data_size; + writer->cert_pwd = cert_pwd; + } else { + MZ_FREE(cert_data); + } + + return err; +} + +void mz_zip_writer_set_overwrite_cb(void *handle, void *userdata, mz_zip_writer_overwrite_cb cb) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->overwrite_cb = cb; + writer->overwrite_userdata = userdata; +} + +void mz_zip_writer_set_password_cb(void *handle, void *userdata, mz_zip_writer_password_cb cb) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->password_cb = cb; + writer->password_userdata = userdata; +} + +void mz_zip_writer_set_progress_cb(void *handle, void *userdata, mz_zip_writer_progress_cb cb) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->progress_cb = cb; + writer->progress_userdata = userdata; +} + +void mz_zip_writer_set_progress_interval(void *handle, uint32_t milliseconds) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->progress_cb_interval_ms = milliseconds; +} + +void mz_zip_writer_set_entry_cb(void *handle, void *userdata, mz_zip_writer_entry_cb cb) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + writer->entry_cb = cb; + writer->entry_userdata = userdata; +} + +int32_t mz_zip_writer_get_zip_handle(void *handle, void **zip_handle) { + mz_zip_writer *writer = (mz_zip_writer *)handle; + if (zip_handle == NULL) + return MZ_PARAM_ERROR; + *zip_handle = writer->zip_handle; + if (*zip_handle == NULL) + return MZ_EXIST_ERROR; + return MZ_OK; +} + +/***************************************************************************/ + +void *mz_zip_writer_create(void **handle) { + mz_zip_writer *writer = NULL; + + writer = (mz_zip_writer *)MZ_ALLOC(sizeof(mz_zip_writer)); + if (writer != NULL) { + memset(writer, 0, sizeof(mz_zip_writer)); +#if defined(HAVE_WZAES) + writer->aes = 1; +#endif +#if defined(HAVE_ZLIB) || defined(HAVE_LIBCOMP) + writer->compress_method = MZ_COMPRESS_METHOD_DEFLATE; +#elif defined(HAVE_BZIP2) + writer->compress_method = MZ_COMPRESS_METHOD_BZIP2; +#elif defined(HAVE_LZMA) + writer->compress_method = MZ_COMPRESS_METHOD_LZMA; +#else + writer->compress_method = MZ_COMPRESS_METHOD_STORE; +#endif + writer->compress_level = MZ_COMPRESS_LEVEL_BEST; + writer->progress_cb_interval_ms = MZ_DEFAULT_PROGRESS_INTERVAL; + } + if (handle != NULL) + *handle = writer; + + return writer; +} + +void mz_zip_writer_delete(void **handle) { + mz_zip_writer *writer = NULL; + if (handle == NULL) + return; + writer = (mz_zip_writer *)*handle; + if (writer != NULL) { + mz_zip_writer_close(writer); + + if (writer->cert_data != NULL) + MZ_FREE(writer->cert_data); + + writer->cert_data = NULL; + writer->cert_data_size = 0; + + MZ_FREE(writer); + } + *handle = NULL; +} + +/***************************************************************************/ diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_zip_rw.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_zip_rw.h new file mode 100644 index 0000000000000000000000000000000000000000..e507f94a5a5f6d6788db41711e72a282a80c4ec0 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/SSZipArchive/SSZipArchive/minizip/mz_zip_rw.h @@ -0,0 +1,285 @@ +/* mz_zip_rw.h -- Zip reader/writer + part of the minizip-ng project + + Copyright (C) 2010-2021 Nathan Moinvaziri + https://github.com/zlib-ng/minizip-ng + + This program is distributed under the terms of the same license as zlib. + See the accompanying LICENSE file for the full text of the license. +*/ + +#ifndef MZ_ZIP_RW_H +#define MZ_ZIP_RW_H + +#ifdef __cplusplus +extern "C" { +#endif + +/***************************************************************************/ + +typedef int32_t (*mz_zip_reader_overwrite_cb)(void *handle, void *userdata, mz_zip_file *file_info, const char *path); +typedef int32_t (*mz_zip_reader_password_cb)(void *handle, void *userdata, mz_zip_file *file_info, char *password, int32_t max_password); +typedef int32_t (*mz_zip_reader_progress_cb)(void *handle, void *userdata, mz_zip_file *file_info, int64_t position); +typedef int32_t (*mz_zip_reader_entry_cb)(void *handle, void *userdata, mz_zip_file *file_info, const char *path); + +/***************************************************************************/ + +int32_t mz_zip_reader_is_open(void *handle); +/* Checks to see if the zip file is open */ + +int32_t mz_zip_reader_open(void *handle, void *stream); +/* Opens zip file from stream */ + +int32_t mz_zip_reader_open_file(void *handle, const char *path); +/* Opens zip file from a file path */ + +int32_t mz_zip_reader_open_file_in_memory(void *handle, const char *path); +/* Opens zip file from a file path into memory for faster access */ + +int32_t mz_zip_reader_open_buffer(void *handle, uint8_t *buf, int32_t len, uint8_t copy); +/* Opens zip file from memory buffer */ + +int32_t mz_zip_reader_close(void *handle); +/* Closes the zip file */ + +/***************************************************************************/ + +int32_t mz_zip_reader_unzip_cd(void *handle); +/* Unzip the central directory */ + +/***************************************************************************/ + +int32_t mz_zip_reader_goto_first_entry(void *handle); +/* Goto the first entry in the zip file that matches the pattern */ + +int32_t mz_zip_reader_goto_next_entry(void *handle); +/* Goto the next entry in the zip file that matches the pattern */ + +int32_t mz_zip_reader_locate_entry(void *handle, const char *filename, uint8_t ignore_case); +/* Locates an entry by filename */ + +int32_t mz_zip_reader_entry_open(void *handle); +/* Opens an entry for reading */ + +int32_t mz_zip_reader_entry_close(void *handle); +/* Closes an entry */ + +int32_t mz_zip_reader_entry_read(void *handle, void *buf, int32_t len); +/* Reads and entry after being opened */ + +int32_t mz_zip_reader_entry_has_sign(void *handle); +/* Checks to see if the entry has a signature */ + +int32_t mz_zip_reader_entry_sign_verify(void *handle); +/* Verifies a signature stored with the entry */ + +int32_t mz_zip_reader_entry_get_hash(void *handle, uint16_t algorithm, uint8_t *digest, int32_t digest_size); +/* Gets a hash algorithm from the entry's extra field */ + +int32_t mz_zip_reader_entry_get_first_hash(void *handle, uint16_t *algorithm, uint16_t *digest_size); +/* Gets the most secure hash algorithm from the entry's extra field */ + +int32_t mz_zip_reader_entry_get_info(void *handle, mz_zip_file **file_info); +/* Gets the current entry file info */ + +int32_t mz_zip_reader_entry_is_dir(void *handle); +/* Gets the current entry is a directory */ + +int32_t mz_zip_reader_entry_save(void *handle, void *stream, mz_stream_write_cb write_cb); +/* Save the current entry to a stream */ + +int32_t mz_zip_reader_entry_save_process(void *handle, void *stream, mz_stream_write_cb write_cb); +/* Saves a portion of the current entry to a stream callback */ + +int32_t mz_zip_reader_entry_save_file(void *handle, const char *path); +/* Save the current entry to a file */ + +int32_t mz_zip_reader_entry_save_buffer(void *handle, void *buf, int32_t len); +/* Save the current entry to a memory buffer */ + +int32_t mz_zip_reader_entry_save_buffer_length(void *handle); +/* Gets the length of the buffer required to save */ + +/***************************************************************************/ + +int32_t mz_zip_reader_save_all(void *handle, const char *destination_dir); +/* Save all files into a directory */ + +/***************************************************************************/ + +void mz_zip_reader_set_pattern(void *handle, const char *pattern, uint8_t ignore_case); +/* Sets the match pattern for entries in the zip file, if null all entries are matched */ + +void mz_zip_reader_set_password(void *handle, const char *password); +/* Sets the password required for extraction */ + +void mz_zip_reader_set_raw(void *handle, uint8_t raw); +/* Sets whether or not it should save the entry raw */ + +int32_t mz_zip_reader_get_raw(void *handle, uint8_t *raw); +/* Gets whether or not it should save the entry raw */ + +int32_t mz_zip_reader_get_zip_cd(void *handle, uint8_t *zip_cd); +/* Gets whether or not the archive has a zipped central directory */ + +int32_t mz_zip_reader_get_comment(void *handle, const char **comment); +/* Gets the comment for the central directory */ + +int32_t mz_zip_reader_set_recover(void *handle, uint8_t recover); +/* Sets the ability to recover the central dir by reading local file headers */ + +void mz_zip_reader_set_encoding(void *handle, int32_t encoding); +/* Sets whether or not it should support a special character encoding in zip file names. */ + +void mz_zip_reader_set_sign_required(void *handle, uint8_t sign_required); +/* Sets whether or not it a signature is required */ + +void mz_zip_reader_set_overwrite_cb(void *handle, void *userdata, mz_zip_reader_overwrite_cb cb); +/* Callback for what to do when a file is being overwritten */ + +void mz_zip_reader_set_password_cb(void *handle, void *userdata, mz_zip_reader_password_cb cb); +/* Callback for when a password is required and hasn't been set */ + +void mz_zip_reader_set_progress_cb(void *handle, void *userdata, mz_zip_reader_progress_cb cb); +/* Callback for extraction progress */ + +void mz_zip_reader_set_progress_interval(void *handle, uint32_t milliseconds); +/* Let at least milliseconds pass between calls to progress callback */ + +void mz_zip_reader_set_entry_cb(void *handle, void *userdata, mz_zip_reader_entry_cb cb); +/* Callback for zip file entries */ + +int32_t mz_zip_reader_get_zip_handle(void *handle, void **zip_handle); +/* Gets the underlying zip instance handle */ + +void* mz_zip_reader_create(void **handle); +/* Create new instance of zip reader */ + +void mz_zip_reader_delete(void **handle); +/* Delete instance of zip reader */ + +/***************************************************************************/ + +typedef int32_t (*mz_zip_writer_overwrite_cb)(void *handle, void *userdata, const char *path); +typedef int32_t (*mz_zip_writer_password_cb)(void *handle, void *userdata, mz_zip_file *file_info, char *password, int32_t max_password); +typedef int32_t (*mz_zip_writer_progress_cb)(void *handle, void *userdata, mz_zip_file *file_info, int64_t position); +typedef int32_t (*mz_zip_writer_entry_cb)(void *handle, void *userdata, mz_zip_file *file_info); + +/***************************************************************************/ + +int32_t mz_zip_writer_is_open(void *handle); +/* Checks to see if the zip file is open */ + +int32_t mz_zip_writer_open(void *handle, void *stream, uint8_t append); +/* Opens zip file from stream */ + +int32_t mz_zip_writer_open_file(void *handle, const char *path, int64_t disk_size, uint8_t append); +/* Opens zip file from a file path */ + +int32_t mz_zip_writer_open_file_in_memory(void *handle, const char *path); +/* Opens zip file from a file path into memory for faster access */ + +int32_t mz_zip_writer_close(void *handle); +/* Closes the zip file */ + +/***************************************************************************/ + +int32_t mz_zip_writer_entry_open(void *handle, mz_zip_file *file_info); +/* Opens an entry in the zip file for writing */ + +int32_t mz_zip_writer_entry_close(void *handle); +/* Closes entry in zip file */ + +int32_t mz_zip_writer_entry_write(void *handle, const void *buf, int32_t len); +/* Writes data into entry for zip */ + +/***************************************************************************/ + +int32_t mz_zip_writer_add(void *handle, void *stream, mz_stream_read_cb read_cb); +/* Writes all data to the currently open entry in the zip */ + +int32_t mz_zip_writer_add_process(void *handle, void *stream, mz_stream_read_cb read_cb); +/* Writes a portion of data to the currently open entry in the zip */ + +int32_t mz_zip_writer_add_info(void *handle, void *stream, mz_stream_read_cb read_cb, mz_zip_file *file_info); +/* Adds an entry to the zip based on the info */ + +int32_t mz_zip_writer_add_buffer(void *handle, void *buf, int32_t len, mz_zip_file *file_info); +/* Adds an entry to the zip with a memory buffer */ + +int32_t mz_zip_writer_add_file(void *handle, const char *path, const char *filename_in_zip); +/* Adds an entry to the zip from a file */ + +int32_t mz_zip_writer_add_path(void *handle, const char *path, const char *root_path, uint8_t include_path, + uint8_t recursive); +/* Enumerates a directory or pattern and adds entries to the zip */ + +int32_t mz_zip_writer_copy_from_reader(void *handle, void *reader); +/* Adds an entry from a zip reader instance */ + +/***************************************************************************/ + +void mz_zip_writer_set_password(void *handle, const char *password); +/* Password to use for encrypting files in the zip */ + +void mz_zip_writer_set_comment(void *handle, const char *comment); +/* Comment to use for the archive */ + +void mz_zip_writer_set_raw(void *handle, uint8_t raw); +/* Sets whether or not we should write the entry raw */ + +int32_t mz_zip_writer_get_raw(void *handle, uint8_t *raw); +/* Gets whether or not we should write the entry raw */ + +void mz_zip_writer_set_aes(void *handle, uint8_t aes); +/* Use aes encryption when adding files in zip */ + +void mz_zip_writer_set_compress_method(void *handle, uint16_t compress_method); +/* Sets the compression method when adding files in zip */ + +void mz_zip_writer_set_compress_level(void *handle, int16_t compress_level); +/* Sets the compression level when adding files in zip */ + +void mz_zip_writer_set_follow_links(void *handle, uint8_t follow_links); +/* Follow symbolic links when traversing directories and files to add */ + +void mz_zip_writer_set_store_links(void *handle, uint8_t store_links); +/* Store symbolic links in zip file */ + +void mz_zip_writer_set_zip_cd(void *handle, uint8_t zip_cd); +/* Sets whether or not central directory should be zipped */ + +int32_t mz_zip_writer_set_certificate(void *handle, const char *cert_path, const char *cert_pwd); +/* Sets the certificate and timestamp url to use for signing when adding files in zip */ + +void mz_zip_writer_set_overwrite_cb(void *handle, void *userdata, mz_zip_writer_overwrite_cb cb); +/* Callback for what to do when zip file already exists */ + +void mz_zip_writer_set_password_cb(void *handle, void *userdata, mz_zip_writer_password_cb cb); +/* Callback for ask if a password is required for adding */ + +void mz_zip_writer_set_progress_cb(void *handle, void *userdata, mz_zip_writer_progress_cb cb); +/* Callback for compression progress */ + +void mz_zip_writer_set_progress_interval(void *handle, uint32_t milliseconds); +/* Let at least milliseconds pass between calls to progress callback */ + +void mz_zip_writer_set_entry_cb(void *handle, void *userdata, mz_zip_writer_entry_cb cb); +/* Callback for zip file entries */ + +int32_t mz_zip_writer_get_zip_handle(void *handle, void **zip_handle); +/* Gets the underlying zip handle */ + +void* mz_zip_writer_create(void **handle); +/* Create new instance of zip writer */ + +void mz_zip_writer_delete(void **handle); +/* Delete instance of zip writer */ + +/***************************************************************************/ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking-Info.plist b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking-Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..5ce460e825232b607348864ca8514dfdf725cb33 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking-Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + ${PODS_DEVELOPMENT_LANGUAGE} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 4.0.1 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m new file mode 100644 index 0000000000000000000000000000000000000000..6a29cf8dadbd7ec6b4deff9662ebbfcf660f6f63 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_AFNetworking : NSObject +@end +@implementation PodsDummy_AFNetworking +@end diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch new file mode 100644 index 0000000000000000000000000000000000000000..beb2a2441835aeaf9ee2ba30c557a8f2b6e4363f --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking-umbrella.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking-umbrella.h new file mode 100644 index 0000000000000000000000000000000000000000..dee8b6ea42c0c3758fd6b166f2041f0319cafa84 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking-umbrella.h @@ -0,0 +1,34 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + +#import "AFNetworking.h" +#import "AFHTTPSessionManager.h" +#import "AFURLSessionManager.h" +#import "AFCompatibilityMacros.h" +#import "AFNetworkReachabilityManager.h" +#import "AFSecurityPolicy.h" +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" +#import "AFAutoPurgingImageCache.h" +#import "AFImageDownloader.h" +#import "AFNetworkActivityIndicatorManager.h" +#import "UIActivityIndicatorView+AFNetworking.h" +#import "UIButton+AFNetworking.h" +#import "UIImageView+AFNetworking.h" +#import "UIKit+AFNetworking.h" +#import "UIProgressView+AFNetworking.h" +#import "UIRefreshControl+AFNetworking.h" +#import "WKWebView+AFNetworking.h" + +FOUNDATION_EXPORT double AFNetworkingVersionNumber; +FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[]; + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking.debug.xcconfig b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking.debug.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..1300513f33520b295b82cb90d12e887ab2848706 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking.debug.xcconfig @@ -0,0 +1,12 @@ +CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO +CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE} +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/AFNetworking +PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates +PRODUCT_BUNDLE_IDENTIFIER = com.alamofire.AFNetworking +SKIP_INSTALL = YES +USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking.modulemap b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking.modulemap new file mode 100644 index 0000000000000000000000000000000000000000..5892cd30c97384ebfd1fcf406cab019ecfce06d1 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking.modulemap @@ -0,0 +1,6 @@ +framework module AFNetworking { + umbrella header "AFNetworking-umbrella.h" + + export * + module * { export * } +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking.release.xcconfig b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking.release.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..1300513f33520b295b82cb90d12e887ab2848706 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/AFNetworking/AFNetworking.release.xcconfig @@ -0,0 +1,12 @@ +CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO +CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE} +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/AFNetworking +PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates +PRODUCT_BUNDLE_IDENTIFIER = com.alamofire.AFNetworking +SKIP_INSTALL = YES +USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-Info.plist b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..19cf209d21ec5e4913848c36a3b5687ad901f05e --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + ${PODS_DEVELOPMENT_LANGUAGE} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-acknowledgements.markdown b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-acknowledgements.markdown new file mode 100644 index 0000000000000000000000000000000000000000..3b2159be250c8e8a2c3f31a19a77bb7827247df0 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-acknowledgements.markdown @@ -0,0 +1,50 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## AFNetworking + +Copyright (c) 2011-2020 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +## SSZipArchive + +Copyright (c) 2013-2021, ZipArchive, https://github.com/ZipArchive + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Generated by CocoaPods - https://cocoapods.org diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-acknowledgements.plist b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-acknowledgements.plist new file mode 100644 index 0000000000000000000000000000000000000000..7cec7f8b285cb3960cf43fecde56279d67326584 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-acknowledgements.plist @@ -0,0 +1,88 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2011-2020 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + License + MIT + Title + AFNetworking + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2013-2021, ZipArchive, https://github.com/ZipArchive + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + License + MIT + Title + SSZipArchive + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - https://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-dummy.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-dummy.m new file mode 100644 index 0000000000000000000000000000000000000000..a80ff3f255a67dcfdaec92bcd4d5dc9e518fe1de --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods_GJLocalDigitalDemo : NSObject +@end +@implementation PodsDummy_Pods_GJLocalDigitalDemo +@end diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-Debug-input-files.xcfilelist b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-Debug-input-files.xcfilelist new file mode 100644 index 0000000000000000000000000000000000000000..25ba343634516779e6ac58dc8bd207c2ae0b56d9 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-Debug-input-files.xcfilelist @@ -0,0 +1,3 @@ +${PODS_ROOT}/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks.sh +${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework +${BUILT_PRODUCTS_DIR}/SSZipArchive/SSZipArchive.framework \ No newline at end of file diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-Debug-output-files.xcfilelist b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-Debug-output-files.xcfilelist new file mode 100644 index 0000000000000000000000000000000000000000..4c10f5420bdaf37e7f2fbd57835519e5405f793e --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-Debug-output-files.xcfilelist @@ -0,0 +1,2 @@ +${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework +${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SSZipArchive.framework \ No newline at end of file diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-Release-input-files.xcfilelist b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-Release-input-files.xcfilelist new file mode 100644 index 0000000000000000000000000000000000000000..25ba343634516779e6ac58dc8bd207c2ae0b56d9 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-Release-input-files.xcfilelist @@ -0,0 +1,3 @@ +${PODS_ROOT}/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks.sh +${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework +${BUILT_PRODUCTS_DIR}/SSZipArchive/SSZipArchive.framework \ No newline at end of file diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-Release-output-files.xcfilelist b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-Release-output-files.xcfilelist new file mode 100644 index 0000000000000000000000000000000000000000..4c10f5420bdaf37e7f2fbd57835519e5405f793e --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks-Release-output-files.xcfilelist @@ -0,0 +1,2 @@ +${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AFNetworking.framework +${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SSZipArchive.framework \ No newline at end of file diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks.sh b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks.sh new file mode 100644 index 0000000000000000000000000000000000000000..2513b37176b1a30c3de4a17b6f5d301f8786d298 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-frameworks.sh @@ -0,0 +1,188 @@ +#!/bin/sh +set -e +set -u +set -o pipefail + +function on_error { + echo "$(realpath -mq "${0}"):$1: error: Unexpected failure" +} +trap 'on_error $LINENO' ERR + +if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then + # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy + # frameworks to, so exit 0 (signalling the script phase was successful). + exit 0 +fi + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}" +SWIFT_STDLIB_PATH="${TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" +BCSYMBOLMAP_DIR="BCSymbolMaps" + + +# This protects against multiple targets copying the same framework dependency at the same time. The solution +# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html +RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") + +# Copies and strips a vendored framework +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink -f "${source}")" + fi + + if [ -d "${source}/${BCSYMBOLMAP_DIR}" ]; then + # Locate and install any .bcsymbolmaps if present, and remove them from the .framework before the framework is copied + find "${source}/${BCSYMBOLMAP_DIR}" -name "*.bcsymbolmap"|while read f; do + echo "Installing $f" + install_bcsymbolmap "$f" "$destination" + rm "$f" + done + rmdir "${source}/${BCSYMBOLMAP_DIR}" + fi + + # Use filter instead of exclude so missing patterns don't throw errors. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + elif [ -L "${binary}" ]; then + echo "Destination binary is symlinked..." + dirname="$(dirname "${binary}")" + binary="${dirname}/$(readlink "${binary}")" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} +# Copies and strips a vendored dSYM +install_dsym() { + local source="$1" + warn_missing_arch=${2:-true} + if [ -r "$source" ]; then + # Copy the dSYM into the targets temp dir. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" + + local basename + basename="$(basename -s .dSYM "$source")" + binary_name="$(ls "$source/Contents/Resources/DWARF")" + binary="${DERIVED_FILES_DIR}/${basename}.dSYM/Contents/Resources/DWARF/${binary_name}" + + # Strip invalid architectures from the dSYM. + if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then + strip_invalid_archs "$binary" "$warn_missing_arch" + fi + if [[ $STRIP_BINARY_RETVAL == 0 ]]; then + # Move the stripped file into its final destination. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.dSYM" "${DWARF_DSYM_FOLDER_PATH}" + else + # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. + mkdir -p "${DWARF_DSYM_FOLDER_PATH}" + touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.dSYM" + fi + fi +} + +# Used as a return value for each invocation of `strip_invalid_archs` function. +STRIP_BINARY_RETVAL=0 + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + warn_missing_arch=${2:-true} + # Get architectures for current target binary + binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" + # Intersect them with the architectures we are building for + intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" + # If there are no archs supported by this binary then warn the user + if [[ -z "$intersected_archs" ]]; then + if [[ "$warn_missing_arch" == "true" ]]; then + echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." + fi + STRIP_BINARY_RETVAL=1 + return + fi + stripped="" + for arch in $binary_archs; do + if ! [[ "${ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi + STRIP_BINARY_RETVAL=0 +} + +# Copies the bcsymbolmap files of a vendored framework +install_bcsymbolmap() { + local bcsymbolmap_path="$1" + local destination="${BUILT_PRODUCTS_DIR}" + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}" +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identity + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'" + + if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + code_sign_cmd="$code_sign_cmd &" + fi + echo "$code_sign_cmd" + eval "$code_sign_cmd" + fi +} + +if [[ "$CONFIGURATION" == "Debug" ]]; then + install_framework "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework" + install_framework "${BUILT_PRODUCTS_DIR}/SSZipArchive/SSZipArchive.framework" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_framework "${BUILT_PRODUCTS_DIR}/AFNetworking/AFNetworking.framework" + install_framework "${BUILT_PRODUCTS_DIR}/SSZipArchive/SSZipArchive.framework" +fi +if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + wait +fi diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-umbrella.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-umbrella.h new file mode 100644 index 0000000000000000000000000000000000000000..d74d5e4da2622a560bc134b255b08cc939295593 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo-umbrella.h @@ -0,0 +1,16 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + + +FOUNDATION_EXPORT double Pods_GJLocalDigitalDemoVersionNumber; +FOUNDATION_EXPORT const unsigned char Pods_GJLocalDigitalDemoVersionString[]; + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.debug.xcconfig b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.debug.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..f12e3725dac8d970ad65075ca15f9e3ec3f1454f --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.debug.xcconfig @@ -0,0 +1,12 @@ +CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive/SSZipArchive.framework/Headers" +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_LDFLAGS = $(inherited) -l"iconv" -l"z" -framework "AFNetworking" -framework "SSZipArchive" -framework "Security" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods +PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates +USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.modulemap b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.modulemap new file mode 100644 index 0000000000000000000000000000000000000000..cb6fb0ad1c908311388e9367a7d796c2342408a1 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.modulemap @@ -0,0 +1,6 @@ +framework module Pods_GJLocalDigitalDemo { + umbrella header "Pods-GJLocalDigitalDemo-umbrella.h" + + export * + module * { export * } +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.release.xcconfig b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.release.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..f12e3725dac8d970ad65075ca15f9e3ec3f1454f --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/Pods-GJLocalDigitalDemo/Pods-GJLocalDigitalDemo.release.xcconfig @@ -0,0 +1,12 @@ +CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking" "${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive/SSZipArchive.framework/Headers" +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_LDFLAGS = $(inherited) -l"iconv" -l"z" -framework "AFNetworking" -framework "SSZipArchive" -framework "Security" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods +PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates +USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive-Info.plist b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive-Info.plist new file mode 100644 index 0000000000000000000000000000000000000000..746c5fffd645a444af55ef114c3c26368add234c --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive-Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + ${PODS_DEVELOPMENT_LANGUAGE} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 2.4.3 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive-dummy.m b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive-dummy.m new file mode 100644 index 0000000000000000000000000000000000000000..9fabf7927ad65369bfd07bf64e943f237db542b2 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_SSZipArchive : NSObject +@end +@implementation PodsDummy_SSZipArchive +@end diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive-prefix.pch b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive-prefix.pch new file mode 100644 index 0000000000000000000000000000000000000000..beb2a2441835aeaf9ee2ba30c557a8f2b6e4363f --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive-umbrella.h b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive-umbrella.h new file mode 100644 index 0000000000000000000000000000000000000000..332a149b2119e8a10fd901fa220298d70e10bb7e --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive-umbrella.h @@ -0,0 +1,18 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + +#import "SSZipArchive.h" +#import "SSZipCommon.h" + +FOUNDATION_EXPORT double SSZipArchiveVersionNumber; +FOUNDATION_EXPORT const unsigned char SSZipArchiveVersionString[]; + diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive.debug.xcconfig b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive.debug.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..c388ad9b16078d07ce63d302fbf08311152e52ce --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive.debug.xcconfig @@ -0,0 +1,14 @@ +CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO +CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive +DEFINES_MODULE = YES +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 HAVE_INTTYPES_H HAVE_PKCRYPT HAVE_STDINT_H HAVE_WZAES HAVE_ZLIB +OTHER_LDFLAGS = $(inherited) -l"iconv" -l"z" -framework "Security" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE} +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/SSZipArchive +PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES +USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive.modulemap b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive.modulemap new file mode 100644 index 0000000000000000000000000000000000000000..c30b5197c88da707863dfe6518cdb7901538d045 --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive.modulemap @@ -0,0 +1,6 @@ +framework module SSZipArchive { + umbrella header "SSZipArchive-umbrella.h" + + export * + module * { export * } +} diff --git a/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive.release.xcconfig b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive.release.xcconfig new file mode 100644 index 0000000000000000000000000000000000000000..c388ad9b16078d07ce63d302fbf08311152e52ce --- /dev/null +++ b/GJLocalDigitalDemo/GJLocalDigitalDemo/Pods/Target Support Files/SSZipArchive/SSZipArchive.release.xcconfig @@ -0,0 +1,14 @@ +CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO +CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive +DEFINES_MODULE = YES +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 HAVE_INTTYPES_H HAVE_PKCRYPT HAVE_STDINT_H HAVE_WZAES HAVE_ZLIB +OTHER_LDFLAGS = $(inherited) -l"iconv" -l"z" -framework "Security" +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_DEVELOPMENT_LANGUAGE = ${DEVELOPMENT_LANGUAGE} +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/SSZipArchive +PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES +USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES