Skip to content

Commit 0265a6f

Browse files
yu.zuoyu.zuo
yu.zuo
authored and
yu.zuo
committed
1.update ios test demo; 2.ios openssl test success.
1 parent f299278 commit 0265a6f

File tree

6 files changed

+210
-136
lines changed

6 files changed

+210
-136
lines changed

example/ios/test_cpphttplib_by_app.xcodeproj/project.pbxproj

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
37342F342314C5CE00913D9A /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 37342F322314C5CD00913D9A /* libssl.a */; };
1818
37342F352314C5CE00913D9A /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 37342F332314C5CD00913D9A /* libcrypto.a */; };
1919
37342F832314C61E00913D9A /* test_http.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37342F812314C61E00913D9A /* test_http.cpp */; };
20-
37342F852314C68A00913D9A /* ca-bundle.crt in Resources */ = {isa = PBXBuildFile; fileRef = 37342F842314C68A00913D9A /* ca-bundle.crt */; };
20+
3734307C23160F0B00913D9A /* ca-bundle.crt in Resources */ = {isa = PBXBuildFile; fileRef = 37342F842314C68A00913D9A /* ca-bundle.crt */; };
2121
/* End PBXBuildFile section */
2222

2323
/* Begin PBXContainerItemProxy section */
@@ -30,6 +30,18 @@
3030
};
3131
/* End PBXContainerItemProxy section */
3232

33+
/* Begin PBXCopyFilesBuildPhase section */
34+
3734307923160E4C00913D9A /* CopyFiles */ = {
35+
isa = PBXCopyFilesBuildPhase;
36+
buildActionMask = 2147483647;
37+
dstPath = "";
38+
dstSubfolderSpec = 7;
39+
files = (
40+
);
41+
runOnlyForDeploymentPostprocessing = 0;
42+
};
43+
/* End PBXCopyFilesBuildPhase section */
44+
3345
/* Begin PBXFileReference section */
3446
37342EAE2314C45F00913D9A /* test_cpphttplib_by_app.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = test_cpphttplib_by_app.app; sourceTree = BUILT_PRODUCTS_DIR; };
3547
37342EB12314C45F00913D9A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -301,6 +313,7 @@
301313
37342EAA2314C45F00913D9A /* Sources */,
302314
37342EAB2314C45F00913D9A /* Frameworks */,
303315
37342EAC2314C45F00913D9A /* Resources */,
316+
3734307923160E4C00913D9A /* CopyFiles */,
304317
);
305318
buildRules = (
306319
);
@@ -374,7 +387,7 @@
374387
37342EBE2314C46900913D9A /* LaunchScreen.storyboard in Resources */,
375388
37342EBB2314C46900913D9A /* Assets.xcassets in Resources */,
376389
37342EB92314C46000913D9A /* Main.storyboard in Resources */,
377-
37342F852314C68A00913D9A /* ca-bundle.crt in Resources */,
390+
3734307C23160F0B00913D9A /* ca-bundle.crt in Resources */,
378391
);
379392
runOnlyForDeploymentPostprocessing = 0;
380393
};
@@ -561,6 +574,7 @@
561574
CPPHTTPLIB_OPENSSL_SUPPORT,
562575
);
563576
INFOPLIST_FILE = test_cpphttplib_by_app/Info.plist;
577+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
564578
LD_RUNPATH_SEARCH_PATHS = (
565579
"$(inherited)",
566580
"@executable_path/Frameworks",
@@ -573,7 +587,7 @@
573587
PRODUCT_NAME = "$(TARGET_NAME)";
574588
PROVISIONING_PROFILE_SPECIFIER = "iOS Free Development";
575589
SYSTEM_HEADER_SEARCH_PATHS = "\"$(SRCROOT)/test_cpphttplib_by_app/http\"";
576-
TARGETED_DEVICE_FAMILY = "1,2";
590+
TARGETED_DEVICE_FAMILY = 1;
577591
};
578592
name = Debug;
579593
};
@@ -584,6 +598,7 @@
584598
CODE_SIGN_STYLE = Manual;
585599
DEVELOPMENT_TEAM = "";
586600
INFOPLIST_FILE = test_cpphttplib_by_app/Info.plist;
601+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
587602
LD_RUNPATH_SEARCH_PATHS = (
588603
"$(inherited)",
589604
"@executable_path/Frameworks",
@@ -596,7 +611,7 @@
596611
PRODUCT_NAME = "$(TARGET_NAME)";
597612
PROVISIONING_PROFILE_SPECIFIER = "";
598613
SYSTEM_HEADER_SEARCH_PATHS = "\"$(SRCROOT)/test_cpphttplib_by_app/http\"";
599-
TARGETED_DEVICE_FAMILY = "1,2";
614+
TARGETED_DEVICE_FAMILY = 1;
600615
};
601616
name = Release;
602617
};

example/ios/test_cpphttplib_by_app.xcodeproj/xcuserdata/yu.zuo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -2,134 +2,4 @@
22
<Bucket
33
type = "1"
44
version = "2.0">
5-
<Breakpoints>
6-
<BreakpointProxy
7-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
8-
<BreakpointContent
9-
shouldBeEnabled = "Yes"
10-
ignoreCount = "0"
11-
continueAfterRunningActions = "No"
12-
filePath = "test_cpphttplib_by_app/http/test_http.cpp"
13-
timestampString = "588590778.553136"
14-
startingColumnNumber = "9223372036854775807"
15-
endingColumnNumber = "9223372036854775807"
16-
startingLineNumber = "31"
17-
endingLineNumber = "31"
18-
landmarkName = "test_https()"
19-
landmarkType = "9">
20-
</BreakpointContent>
21-
</BreakpointProxy>
22-
<BreakpointProxy
23-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
24-
<BreakpointContent
25-
shouldBeEnabled = "Yes"
26-
ignoreCount = "0"
27-
continueAfterRunningActions = "No"
28-
filePath = "test_cpphttplib_by_app/http/test_http.cpp"
29-
timestampString = "588590778.5538239"
30-
startingColumnNumber = "9223372036854775807"
31-
endingColumnNumber = "9223372036854775807"
32-
startingLineNumber = "30"
33-
endingLineNumber = "30"
34-
landmarkName = "test_https()"
35-
landmarkType = "9">
36-
</BreakpointContent>
37-
</BreakpointProxy>
38-
<BreakpointProxy
39-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
40-
<BreakpointContent
41-
shouldBeEnabled = "Yes"
42-
ignoreCount = "0"
43-
continueAfterRunningActions = "No"
44-
filePath = "test_cpphttplib_by_app/http/httplib.h"
45-
timestampString = "588588506.116456"
46-
startingColumnNumber = "9223372036854775807"
47-
endingColumnNumber = "9223372036854775807"
48-
startingLineNumber = "3183"
49-
endingLineNumber = "3183"
50-
landmarkName = "SSLClient::read_and_close_socket(socket_t sock, Request &amp;req, Response &amp;res)"
51-
landmarkType = "7">
52-
</BreakpointContent>
53-
</BreakpointProxy>
54-
<BreakpointProxy
55-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
56-
<BreakpointContent
57-
shouldBeEnabled = "Yes"
58-
ignoreCount = "0"
59-
continueAfterRunningActions = "No"
60-
filePath = "test_cpphttplib_by_app/http/httplib.h"
61-
timestampString = "588588506.1166"
62-
startingColumnNumber = "9223372036854775807"
63-
endingColumnNumber = "9223372036854775807"
64-
startingLineNumber = "2944"
65-
endingLineNumber = "2944"
66-
landmarkName = "read_and_close_socket_ssl(socket_t sock, size_t keep_alive_max_count, SSL_CTX *ctx, std::mutex &amp;ctx_mutex, U SSL_connect_or_accept, V setup, T callback)"
67-
landmarkType = "9">
68-
</BreakpointContent>
69-
</BreakpointProxy>
70-
<BreakpointProxy
71-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
72-
<BreakpointContent
73-
shouldBeEnabled = "Yes"
74-
ignoreCount = "0"
75-
continueAfterRunningActions = "No"
76-
filePath = "test_cpphttplib_by_app/http/httplib.h"
77-
timestampString = "588588554.9209239"
78-
startingColumnNumber = "9223372036854775807"
79-
endingColumnNumber = "9223372036854775807"
80-
startingLineNumber = "1019"
81-
endingLineNumber = "1019"
82-
landmarkName = "create_socket(const char *host, int port, Fn fn, int socket_flags = 0)"
83-
landmarkType = "9">
84-
</BreakpointContent>
85-
</BreakpointProxy>
86-
<BreakpointProxy
87-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
88-
<BreakpointContent
89-
shouldBeEnabled = "Yes"
90-
ignoreCount = "0"
91-
continueAfterRunningActions = "No"
92-
filePath = "test_cpphttplib_by_app/http/httplib.h"
93-
timestampString = "588588555.5761679"
94-
startingColumnNumber = "9223372036854775807"
95-
endingColumnNumber = "9223372036854775807"
96-
startingLineNumber = "1022"
97-
endingLineNumber = "1022"
98-
landmarkName = "create_socket(const char *host, int port, Fn fn, int socket_flags = 0)"
99-
landmarkType = "9">
100-
</BreakpointContent>
101-
</BreakpointProxy>
102-
<BreakpointProxy
103-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
104-
<BreakpointContent
105-
shouldBeEnabled = "Yes"
106-
ignoreCount = "0"
107-
continueAfterRunningActions = "No"
108-
filePath = "test_cpphttplib_by_app/http/httplib.h"
109-
timestampString = "588588561.160187"
110-
startingColumnNumber = "9223372036854775807"
111-
endingColumnNumber = "9223372036854775807"
112-
startingLineNumber = "1017"
113-
endingLineNumber = "1017"
114-
landmarkName = "create_socket(const char *host, int port, Fn fn, int socket_flags = 0)"
115-
landmarkType = "9">
116-
</BreakpointContent>
117-
</BreakpointProxy>
118-
<BreakpointProxy
119-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
120-
<BreakpointContent
121-
shouldBeEnabled = "Yes"
122-
ignoreCount = "0"
123-
continueAfterRunningActions = "No"
124-
filePath = "test_cpphttplib_by_app/http/test_http.cpp"
125-
timestampString = "588590778.5541199"
126-
startingColumnNumber = "9223372036854775807"
127-
endingColumnNumber = "9223372036854775807"
128-
startingLineNumber = "133"
129-
endingLineNumber = "133"
130-
landmarkName = "test_ssl()"
131-
landmarkType = "9">
132-
</BreakpointContent>
133-
</BreakpointProxy>
134-
</Breakpoints>
1355
</Bucket>

example/ios/test_cpphttplib_by_app/ViewController.mm

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "ViewController.h"
1010
#include "http/test_http.hpp"
1111

12+
#define OC_CA_CERT_FILE @"ca-bundle.crt"
1213

1314
@interface ViewController ()
1415

@@ -19,8 +20,107 @@ @implementation ViewController
1920
- (void)viewDidLoad {
2021
[super viewDidLoad];
2122
// Do any additional setup after loading the view, typically from a nib.
22-
test_ssl();
23+
// test_file_op_on_c();
24+
// [self getAllDirs];
25+
NSString* fileName = [self getAppPackageResourcePath:OC_CA_CERT_FILE];
26+
// test_file_op_on_c2([fileName UTF8String]);
27+
test_https([fileName UTF8String]);
2328
}
2429

2530

31+
//ref: https://www.jianshu.com/p/be80c46ab731
32+
//ref: https://blog.csdn.net/kwuwei/article/details/38421247
33+
- (void)getAllDirs {
34+
//==============================================================================
35+
36+
// 资源目录
37+
38+
NSString *resourceDir = [[NSBundle mainBundle] resourcePath];
39+
NSLog(@"resourceDir = %@\n", resourceDir);
40+
41+
NSFileManager *fileManager = [NSFileManager defaultManager];
42+
NSDirectoryEnumerator *enumerator = [fileManager enumeratorAtPath:resourceDir];
43+
//遍历属性
44+
NSString *fileName;
45+
//下面这个方法最为关键 可以给fileName赋值,获得文件名(带文件后缀)。
46+
while (fileName = [enumerator nextObject]) {
47+
//跳过子路径
48+
[enumerator skipDescendants];
49+
//获取文件属性
50+
//enumerator.fileAttributes 的后面可以用点语法点出许多许多的属性。
51+
NSLog(@"%@",enumerator.fileAttributes);
52+
NSLog(@"%@",enumerator.directoryAttributes);
53+
}
54+
NSArray* fileList = [fileManager contentsOfDirectoryAtPath:resourceDir error:nil];
55+
NSLog(@"fileList = %@\n", fileList);
56+
//==============================================================================
57+
58+
// 获取程序Documents目录路径
59+
// 目录列表
60+
61+
NSArray *docDir = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
62+
NSLog(@"docDir = %@\n", docDir);
63+
// 根目录
64+
65+
NSString *docRootDir = [docDir objectAtIndex:0];
66+
NSLog(@"docRootDir = %@\n", docRootDir);
67+
//==============================================================================
68+
69+
// 获取程序Library目录路径
70+
// 目录列表
71+
72+
NSArray *libDir = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
73+
NSLog(@"libDir = %@\n", libDir);
74+
// 根目录
75+
76+
NSString *libRootDir = [libDir objectAtIndex:0];
77+
NSLog(@"libRootDir = %@\n", libRootDir);
78+
79+
//==============================================================================
80+
81+
// 获取程序caches目录
82+
NSArray *cacheDir = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
83+
NSLog(@"cacheDir = %@\n", cacheDir);
84+
NSString *cacheRootDir = [cacheDir objectAtIndex:0] ;
85+
NSLog(@"cacheRootDir = %@\n", cacheRootDir);
86+
//==============================================================================
87+
88+
89+
90+
//==============================================================================
91+
// 获取程序app文件所在目录路径
92+
93+
NSString *homeDir = NSHomeDirectory();
94+
NSLog(@"homeDir = %@\n", homeDir);
95+
//==============================================================================
96+
97+
// 获取程序tmp目录路径
98+
99+
NSString *tempDir = NSTemporaryDirectory();
100+
NSLog(@"tempDir = %@\n", tempDir);
101+
102+
//==============================================================================
103+
104+
// 获取程序应用包路径
105+
106+
NSString * path = [[NSBundle mainBundle] resourcePath];
107+
NSLog(@"path = %@\n", path);
108+
//
109+
110+
NSString * path2 = [[NSBundle mainBundle] pathForResource: @"info" ofType: @"txt"];
111+
NSLog(@"path2 = %@\n", path2);
112+
//==============================================================================
113+
//==============================================================================
114+
//==============================================================================
115+
}
116+
117+
- (NSString*)getAppPackageResourcePath:(NSString*)resourceName
118+
{
119+
NSString *resourceDir = [[NSBundle mainBundle] resourcePath];
120+
NSLog(@"resourceDir = %@\n", resourceDir);
121+
NSString* path = [NSString stringWithFormat:@"%@/%@", resourceDir, resourceName];
122+
NSLog(@"path = %@\n", path);
123+
return path;
124+
}
125+
26126
@end

0 commit comments

Comments
 (0)