public:
Pcre() :
code_(NULL),
- study_(NULL)
+ study_(NULL),
+ data_(NULL)
{
}
- Pcre(const char *regex) :
+ Pcre(const char *regex, NSString *data = nil) :
code_(NULL),
- study_(NULL)
+ study_(NULL),
+ data_(NULL)
{
this->operator =(regex);
+
+ if (data != nil)
+ this->operator ()(data);
}
void operator =(const char *regex) {
}
bool operator ()(const char *data, size_t size) {
- data_ = data;
- return pcre_exec(code_, study_, data, size, 0, 0, matches_, (capture_ + 1) * 3) >= 0;
+ if (pcre_exec(code_, study_, data, size, 0, 0, matches_, (capture_ + 1) * 3) >= 0) {
+ data_ = data;
+ return true;
+ } else {
+ data_ = NULL;
+ return false;
+ }
+ }
+
+ operator bool() const {
+ return data_ != NULL;
}
NSString *operator ->*(NSString *format) const {
static _H<UIFont> Font22Bold_;
static const char *Machine_ = NULL;
-_H<NSString> System_;
+static _H<NSString> System_;
static NSString *SerialNumber_ = nil;
static NSString *ChipID_ = nil;
static NSString *BBSNum_ = nil;
static _H<NSString> Token_;
static NSString *UniqueID_ = nil;
-static NSString *Product_ = nil;
-static NSString *Safari_ = nil;
+static _H<NSString> UserAgent_;
+static _H<NSString> Product_;
+static _H<NSString> Safari_;
static CFLocaleRef Locale_;
static NSArray *Languages_;
+ (NSArray *) _attributeKeys {
return [NSArray arrayWithObjects:
@"bbsnum",
+ @"build",
+ @"coreFoundationVersionNumber",
@"device",
@"ecid",
@"firmware",
return Cydia_;
}
+- (NSString *) build {
+ return System_;
+}
+
+- (NSString *) coreFoundationVersionNumber {
+ return [NSString stringWithFormat:@"%.2f", kCFCoreFoundationVersionNumber];
+}
+
- (NSString *) device {
return [[UIDevice currentDevice] uniqueIdentifier];
}
NSMutableURLRequest *copy([[super webView:view resource:resource willSendRequest:request redirectResponse:response fromDataSource:source] mutableCopy]);
+ if ([copy valueForHTTPHeaderField:@"X-Cydia-Cf-Version"] == nil)
+ [copy setValue:[NSString stringWithFormat:@"%.2f", kCFCoreFoundationVersionNumber] forHTTPHeaderField:@"X-Cydia-Cf-Version"];
if (Machine_ != NULL && [copy valueForHTTPHeaderField:@"X-Machine"] == nil)
[copy setValue:[NSString stringWithUTF8String:Machine_] forHTTPHeaderField:@"X-Machine"];
}
- (NSString *) applicationNameForUserAgent {
- NSString *application([NSString stringWithFormat:@"Cydia/%@", Cydia_]);
-
- if (Safari_ != nil)
- application = [NSString stringWithFormat:@"Safari/%@ %@", Safari_, application];
- if (System_ != nil)
- application = [NSString stringWithFormat:@"Mobile/%@ %@", (id) System_, application];
- if (Product_ != nil)
- application = [NSString stringWithFormat:@"Version/%@ %@", Product_, application];
-
- return application;
+ return UserAgent_;
}
- (id) init {
Product_ = [info objectForKey:@"SafariProductVersion"];
Safari_ = [info objectForKey:@"CFBundleVersion"];
}
+
+ NSString *agent([NSString stringWithFormat:@"Cydia/%@ CF/%.2f", Cydia_, kCFCoreFoundationVersionNumber]);
+
+ if (Pcre match = Pcre("^[0-9]+(\\.[0-9]+)+", Safari_))
+ agent = [NSString stringWithFormat:@"Safari/%@ %@", match[0], agent];
+ if (Pcre match = Pcre("^[0-9]+[A-Z][0-9]+[a-z]?", System_))
+ agent = [NSString stringWithFormat:@"Mobile/%@ %@", match[0], agent];
+ if (Pcre match = Pcre("^[0-9]+(\\.[0-9]+)+", Product_))
+ agent = [NSString stringWithFormat:@"Version/%@ %@", match[0], agent];
+
+ UserAgent_ = agent;
/* }}} */
/* Load Database {{{ */
_trace();
if (access("/tmp/.cydia.fw", F_OK) == 0) {
unlink("/tmp/.cydia.fw");
goto firmware;
- } else if (access("/User", F_OK) != 0 || version < 4) {
+ } else if (access("/User", F_OK) != 0 || version < 5) {
firmware:
_trace();
system("/usr/libexec/cydia/firmware.sh");
#include <cstdio>
extern _H<NSMutableDictionary> Sources_;
-extern _H<NSString> System_;
extern bool Changed_;
void CydiaWriteSources() {
FILE *file(fopen("/etc/apt/sources.list.d/cydia.list", "w"));
_assert(file != NULL);
- NSString *distribution(@"ios");
- if (System_ != nil)
- distribution = [distribution stringByAppendingString:[NSString stringWithFormat:@"/%@", (id) System_]];
-
- fprintf(file, "deb http://apt.saurik.com/ %s main\n", [distribution UTF8String]);
+ fprintf(file, "deb http://apt.saurik.com/ ios/%.2f main\n", kCFCoreFoundationVersionNumber);
for (NSString *key in [Sources_ allKeys]) {
NSDictionary *source([Sources_ objectForKey:key]);
CydiaAppliance: CydiaAppliance.mm
$(cycc) $(filter %.mm,$^) $(flags) -bundle $(link) $(backrow)
+cfversion: cfversion.mm
+ $(cycc) $(filter %.mm,$^) $(flags) -framework CoreFoundation
+ @ldid -T0 -S $@
+
postinst: postinst.mm Sources.mm Sources.h CyteKit/stringWithUTF8Bytes.mm CyteKit/stringWithUTF8Bytes.h CyteKit/UCPlatform.h
$(cycc) $(filter %.mm,$^) $(flags) -framework CoreFoundation -framework Foundation -framework UIKit -lpcre
@ldid -T0 -S $@
-debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst $(images) $(shell find MobileCydia.app) cydia.control
+debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst cfversion $(images) $(shell find MobileCydia.app) cydia.control Library/firmware.sh
sudo rm -rf _
mkdir -p _/var/lib/cydia
mkdir -p _/usr/libexec
cp -a Library _/usr/libexec/cydia
cp -a sysroot/usr/bin/du _/usr/libexec/cydia
+ cp -a cfversion _/usr/libexec/cydia
mkdir -p _/System/Library
cp -a LaunchDaemons _/System/Library/LaunchDaemons