+
+ size_t size;
+
+ sysctlbyname("kern.osversion", NULL, &size, NULL, 0);
+ char *osversion = new char[size];
+ if (sysctlbyname("kern.osversion", osversion, &size, NULL, 0) == -1)
+ perror("sysctlbyname(\"kern.osversion\", ?)");
+ else
+ System_ = osversion;
+
+ sysctlbyname("hw.machine", NULL, &size, NULL, 0);
+ char *machine = new char[size];
+ if (sysctlbyname("hw.machine", machine, &size, NULL, 0) == -1)
+ perror("sysctlbyname(\"hw.machine\", ?)");
+ else
+ Machine_ = machine;
+
+ _H<NSString> product;
+ _H<NSString> safari;
+
+ if (NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:@"/Applications/MobileSafari.app/Info.plist"]) {
+ product = [info objectForKey:@"SafariProductVersion"] ?: [info objectForKey:@"CFBundleShortVersionString"];
+ safari = [info objectForKey:@"CFBundleVersion"];
+ }
+
+ NSString *agent([NSString stringWithFormat:@"%@/%@ CyF/%.2f", app, version, kCFCoreFoundationVersionNumber]);
+
+ if (RegEx match = RegEx("([0-9]+(\\.[0-9]+)+).*", safari))
+ agent = [NSString stringWithFormat:@"Safari/%@ %@", match[1], agent];
+ if (RegEx match = RegEx("([0-9]+[A-Z][0-9]+[a-z]?).*", System_))
+ agent = [NSString stringWithFormat:@"Mobile/%@ %@", match[1], agent];
+ if (RegEx match = RegEx("([0-9]+(\\.[0-9]+)+).*", product))
+ agent = [NSString stringWithFormat:@"Version/%@ %@", match[1], agent];
+
+ [CyteWebViewController setApplicationNameForUserAgent:agent];