summaryrefslogtreecommitdiff
path: root/CyteKit/extern.mm
diff options
context:
space:
mode:
Diffstat (limited to 'CyteKit/extern.mm')
-rw-r--r--CyteKit/extern.mm22
1 files changed, 22 insertions, 0 deletions
diff --git a/CyteKit/extern.mm b/CyteKit/extern.mm
index c1dc806..cb8927a 100644
--- a/CyteKit/extern.mm
+++ b/CyteKit/extern.mm
@@ -20,11 +20,33 @@
/* }}} */
#include <CyteKit/extern.h>
+
+#include <SystemConfiguration/SystemConfiguration.h>
#include <UIKit/UIKit.h>
bool IsWildcat_;
CGFloat ScreenScale_;
+bool CyteIsReachable(const char *name) {
+ SCNetworkReachabilityFlags flags; {
+ SCNetworkReachabilityRef reachability(SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, name));
+ SCNetworkReachabilityGetFlags(reachability, &flags);
+ CFRelease(reachability);
+ }
+
+ // XXX: this elaborate mess is what Apple is using to determine this? :(
+ // XXX: do we care if the user has to intervene? maybe that's ok?
+ return
+ (flags & kSCNetworkReachabilityFlagsReachable) != 0 && (
+ (flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0 || (
+ (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0 ||
+ (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0
+ ) && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0 ||
+ (flags & kSCNetworkReachabilityFlagsIsWWAN) != 0
+ )
+ ;
+}
+
__attribute__((__constructor__))
void CyteKit_extern() {
UIScreen *screen([UIScreen mainScreen]);