diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2011-02-20 02:12:22 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2011-02-20 02:12:22 -0800 |
commit | 2cd1afd9692214352f439b52dbb225b0a83ebb6a (patch) | |
tree | a1a36d91b28e8d1e95fbf8eab3022d230c3bb773 /MobileCydia.mm | |
parent | 9a60abe5e5246fda79175bd857c1cf9dfc46c9df (diff) |
Add package.getField(name).
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r-- | MobileCydia.mm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index 24d9066..48163b0 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -2217,6 +2217,8 @@ struct PackageNameOrdering : if (false); else if (selector == @selector(clear)) return @"clear"; + else if (selector == @selector(getField:)) + return @"getField"; else if (selector == @selector(hasTag:)) return @"hasTag"; else if (selector == @selector(install)) @@ -2277,6 +2279,20 @@ struct PackageNameOrdering : return relations; } } +- (NSString *) getField:(NSString *)name { +@synchronized (database_) { + if ([database_ era] != era_ || file_.end()) + return nil; + + pkgRecords::Parser &parser([database_ records]->Lookup(file_)); + + const char *start, *end; + if (!parser.Find([name UTF8String], start, end)) + return (NSString *) [NSNull null]; + + return [(NSString *) CYStringCreate(start, end - start) autorelease]; +} } + - (void) parse { if (parsed_ != NULL) return; |