-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
229 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by CW Lee on 26/09/2023. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
func selectedServerToPointer (selectedServers: [UInt32]?) throws -> UnsafeMutablePointer<Int8>? { | ||
guard let selectedServers = selectedServers else { | ||
return nil | ||
} | ||
var serversPointer: UnsafeMutablePointer<Int8>? | ||
|
||
let selected_servers_json = try JSONSerialization.data(withJSONObject: selectedServers as Any) | ||
let selected_servers_str = String(data: selected_servers_json, encoding: .utf8)! | ||
print(selected_servers_str) | ||
serversPointer = UnsafeMutablePointer<Int8>(mutating: (selected_servers_str as NSString).utf8String) | ||
|
||
guard let serversPointer = serversPointer else { | ||
throw RuntimeError("convert error") | ||
} | ||
return serversPointer | ||
} | ||
|
||
func authSignaturesToPointer ( authSignatures : [String]?) throws -> UnsafeMutablePointer<Int8>? { | ||
guard let authSignatures = authSignatures else { | ||
return nil | ||
} | ||
let auth_signatures_json = try JSONSerialization.data(withJSONObject: authSignatures) | ||
guard let auth_signatures_str = String(data: auth_signatures_json, encoding: .utf8) else { | ||
throw RuntimeError("auth signatures error") | ||
} | ||
print(authSignatures) | ||
print(auth_signatures_str.count) | ||
|
||
let authSignaturesPointer = UnsafeMutablePointer<Int8>(mutating: (auth_signatures_str as NSString).utf8String) | ||
|
||
|
||
return authSignaturesPointer | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.