diff -Nru apt-0.7.25.3/apt-pkg/contrib/md5.cc apt-0.7.25.3+iPhone/apt-pkg/contrib/md5.cc --- apt-0.7.25.3/apt-pkg/contrib/md5.cc 2010-02-01 19:44:40.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/contrib/md5.cc 2010-02-24 08:11:38.000000000 +0000 @@ -173,6 +173,12 @@ memset(Sum,0,sizeof(Sum)); Set(Str); } + +MD5SumValue::MD5SumValue(const srkString &Str) +{ + memset(Sum, 0, sizeof(Sum)); + Set(Str); +} /*}}}*/ // MD5SumValue::MD5SumValue - Default constructor /*{{{*/ // --------------------------------------------------------------------- @@ -189,6 +195,11 @@ { return Hex2Num(Str,Sum,sizeof(Sum)); } + +bool MD5SumValue::Set(const srkString &Str) +{ + return Hex2Num(Str,Sum,sizeof(Sum)); +} /*}}}*/ // MD5SumValue::Value - Convert the number into a string /*{{{*/ // --------------------------------------------------------------------- diff -Nru apt-0.7.25.3/apt-pkg/contrib/md5.h apt-0.7.25.3+iPhone/apt-pkg/contrib/md5.h --- apt-0.7.25.3/apt-pkg/contrib/md5.h 2010-02-01 19:44:40.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/contrib/md5.h 2010-02-24 08:09:10.000000000 +0000 @@ -29,6 +29,8 @@ #include #include +#include + using std::string; using std::min; @@ -48,10 +50,12 @@ {for (int I = 0; I != sizeof(Sum); I++) S[I] = Sum[I];}; inline operator string() const {return Value();}; bool Set(string Str); + bool Set(const srkString &Str); inline void Set(unsigned char S[16]) {for (int I = 0; I != sizeof(Sum); I++) Sum[I] = S[I];}; MD5SumValue(string Str); + MD5SumValue(const srkString &Str); MD5SumValue(); }; diff -Nru apt-0.7.25.3/apt-pkg/contrib/strutl.cc apt-0.7.25.3+iPhone/apt-pkg/contrib/strutl.cc --- apt-0.7.25.3/apt-pkg/contrib/strutl.cc 2010-02-01 19:44:40.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/contrib/strutl.cc 2010-02-24 08:13:39.000000000 +0000 @@ -943,12 +943,17 @@ /* The length of the buffer must be exactly 1/2 the length of the string. */ bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length) { + return Hex2Num(srkString(Str), Num, Length); +} + +bool Hex2Num(const srkString &Str,unsigned char *Num,unsigned int Length) +{ if (Str.length() != Length*2) return false; // Convert each digit. We store it in the same order as the string int J = 0; - for (string::const_iterator I = Str.begin(); I != Str.end();J++, I += 2) + for (srkString::const_iterator I = Str.begin(); I != Str.end();J++, I += 2) { if (isxdigit(*I) == 0 || isxdigit(I[1]) == 0) return false; diff -Nru apt-0.7.25.3/apt-pkg/contrib/strutl.h apt-0.7.25.3+iPhone/apt-pkg/contrib/strutl.h --- apt-0.7.25.3/apt-pkg/contrib/strutl.h 2010-02-01 19:44:40.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/contrib/strutl.h 2010-02-24 08:10:45.000000000 +0000 @@ -25,6 +25,8 @@ #include #include +#include + using std::string; using std::vector; using std::ostream; @@ -57,6 +59,7 @@ bool ReadMessages(int Fd, vector &List); bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0); bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length); +bool Hex2Num(const srkString &Str,unsigned char *Num,unsigned int Length); bool TokSplitString(char Tok,char *Input,char **List, unsigned long ListMax); void ioprintf(ostream &out,const char *format,...) APT_FORMAT2; @@ -66,6 +69,7 @@ int tolower_ascii(int c); #define APT_MKSTRCMP(name,func) \ +inline int name(const srkString &A,const char *B) {return func(A.Start,A.Start+A.Size,B,B+strlen(B));}; \ inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));}; \ inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \ inline int name(const string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; \ @@ -77,6 +77,7 @@ inline int name(const string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);}; #define APT_MKSTRCMP2(name,func) \ +inline int name(const srkString &A,const char *B) {return func(A.Start,A.Start+A.Size,B,B+strlen(B));}; \ inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \ inline int name(const string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));}; \ inline int name(const string& A,const string& B) {return func(A.begin(),A.end(),B.begin(),B.end());}; \ diff -Nru apt-0.7.25.3/apt-pkg/deb/deblistparser.cc apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc --- apt-0.7.25.3/apt-pkg/deb/deblistparser.cc 2010-02-24 08:53:52.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.cc 2010-02-24 08:51:50.000000000 +0000 @@ -106,7 +106,7 @@ const char *Stop; if (Section.Find("Priority",Start,Stop) == true) { - if (GrabWord(string(Start,Stop-Start),PrioList,Ver->Priority) == false) + if (GrabWord(srkString(Start,Stop-Start),PrioList,Ver->Priority) == false) Ver->Priority = pkgCache::State::Extra; } @@ -144,10 +144,19 @@ only describe package properties */ string debListParser::Description() { - if (DescriptionLanguage().empty()) - return Section.FindS("Description"); - else - return Section.FindS(("Description-" + pkgIndexFile::LanguageCode()).c_str()); + srkString description; + Description(description); + return description; +} + +void debListParser::Description(srkString &Str) { + const char *Start, *Stop; + if (!Section.Find("Description", Start, Stop)) + if (!Section.Find(("Description-" + pkgIndexFile::LanguageCode()).c_str(), Start, Stop)) { + Start = NULL; + Stop = NULL; + } + Str.assign(Start, Stop); } /*}}}*/ // ListParser::DescriptionLanguage - Return the description lang string /*{{{*/ @@ -157,7 +166,8 @@ assumed to describe original description. */ string debListParser::DescriptionLanguage() { - return Section.FindS("Description").empty() ? pkgIndexFile::LanguageCode() : ""; + const char *Start, *Stop; + return Section.Find("Description", Start, Stop) ? std::string() : pkgIndexFile::LanguageCode(); } /*}}}*/ // ListParser::Description - Return the description_md5 MD5SumValue /*{{{*/ @@ -168,15 +178,18 @@ */ MD5SumValue debListParser::Description_md5() { - string value = Section.FindS("Description-md5"); - - if (value.empty()) + const char *Start; + const char *Stop; + if (!Section.Find("Description-md5", Start, Stop)) { MD5Summation md5; - md5.Add((Description() + "\n").c_str()); + srkString description; + Description(description); + md5.Add((const unsigned char *) description.Start, description.Size); + md5.Add("\n"); return md5.Result(); } else - return MD5SumValue(value); + return MD5SumValue(srkString(Start, Stop)); } /*}}}*/ // ListParser::UsePackage - Update a package structure /*{{{*/ @@ -286,7 +299,7 @@ {"deinstall",pkgCache::State::DeInstall}, {"purge",pkgCache::State::Purge}, {}}; - if (GrabWord(string(Start,I-Start),WantList,Pkg->SelectedState) == false) + if (GrabWord(srkString(Start,I-Start),WantList,Pkg->SelectedState) == false) return _error->Error("Malformed 1st word in the Status line"); // Isloate the next word @@ -302,7 +315,7 @@ {"hold",pkgCache::State::HoldInst}, {"hold-reinstreq",pkgCache::State::HoldReInstReq}, {}}; - if (GrabWord(string(Start,I-Start),FlagList,Pkg->InstState) == false) + if (GrabWord(srkString(Start,I-Start),FlagList,Pkg->InstState) == false) return _error->Error("Malformed 2nd word in the Status line"); // Isloate the last word @@ -324,7 +337,7 @@ {"post-inst-failed",pkgCache::State::HalfConfigured}, {"removal-failed",pkgCache::State::HalfInstalled}, {}}; - if (GrabWord(string(Start,I-Start),StatusList,Pkg->CurrentState) == false) + if (GrabWord(srkString(Start,I-Start),StatusList,Pkg->CurrentState) == false) return _error->Error("Malformed 3rd word in the Status line"); /* A Status line marks the package as indicating the current @@ -410,6 +423,17 @@ string &Package,string &Ver, unsigned int &Op, bool ParseArchFlags) { + srkString cPackage, cVer; + const char *Value = ParseDepends(Start, Stop, cPackage, cVer, Op, ParseArchFlags); + Package = cPackage; + Ver = cVer; + return Value; +} + +const char *debListParser::ParseDepends(const char *Start,const char *Stop, + srkString &Package,srkString &Ver, + unsigned int &Op, bool ParseArchFlags) +{ // Strip off leading space for (;Start != Stop && isspace(*Start) != 0; Start++); @@ -509,7 +533,7 @@ Found = !Found; if (Found == false) - Package = ""; /* not for this arch */ + Package.clear(); /* not for this arch */ } // Skip whitespace @@ -541,8 +565,8 @@ if (Section.Find(Tag,Start,Stop) == false) return true; - string Package; - string Version; + srkString Package; + srkString Version; unsigned int Op; while (1) @@ -569,8 +593,8 @@ if (Section.Find("Provides",Start,Stop) == false) return true; - string Package; - string Version; + srkString Package; + srkString Version; unsigned int Op; while (1) @@ -579,7 +603,7 @@ if (Start == 0) return _error->Error("Problem parsing Provides line"); if (Op != pkgCache::Dep::NoOp) { - _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str()); + _error->Warning("Ignoring Provides line with DepCompareOp for package %s", std::string(Package).c_str()); } else { if (NewProvides(Ver,Package,Version) == false) return false; @@ -637,9 +661,14 @@ /* Looks for a word in a list of words - for ParseStatus */ bool debListParser::GrabWord(string Word,WordList *List,unsigned char &Out) { + return GrabWord(srkString(Word), List, Out); +} + +bool debListParser::GrabWord(const srkString &Word,WordList *List,unsigned char &Out) +{ for (unsigned int C = 0; List[C].Str != 0; C++) { - if (strcasecmp(Word.c_str(),List[C].Str) == 0) + if (strncasecmp(Word.Start,List[C].Str,Word.Size) == 0) { Out = List[C].Val; return true; diff -Nru apt-0.7.25.3/apt-pkg/deb/deblistparser.h apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.h --- apt-0.7.25.3/apt-pkg/deb/deblistparser.h 2010-02-24 08:53:52.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/deb/deblistparser.h 2010-02-24 08:43:20.000000000 +0000 @@ -41,9 +41,22 @@ bool ParseProvides(pkgCache::VerIterator Ver); bool ParseTag(pkgCache::PkgIterator Pkg); static bool GrabWord(string Word,WordList *List,unsigned char &Out); + static bool GrabWord(const srkString &Word,WordList *List,unsigned char &Out); public: + srkString Find(const char *Tag) { + srkString S; + const char *Stop; + if (Section.Find(Tag, S.Start, Stop)) + S.Size = Stop - S.Start; + else { + S.Start = NULL; + S.Size = 0; + } + return S; + } + static unsigned char GetPrio(string Str); // These all operate against the current section @@ -51,6 +64,7 @@ virtual string Version(); virtual bool NewVersion(pkgCache::VerIterator Ver); virtual string Description(); + void Description(srkString &Str); virtual string DescriptionLanguage(); virtual MD5SumValue Description_md5(); virtual unsigned short VersionHash(); @@ -67,6 +81,9 @@ static const char *ParseDepends(const char *Start,const char *Stop, string &Package,string &Ver,unsigned int &Op, bool ParseArchFlags = false); + static const char *ParseDepends(const char *Start,const char *Stop, + srkString &Package,srkString &Ver,unsigned int &Op, + bool ParseArchFlags = false); static const char *ConvertRelation(const char *I,unsigned int &Op); debListParser(FileFd *File); diff -Nru apt-0.7.25.3/apt-pkg/makefile apt-0.7.25.3+iPhone/apt-pkg/makefile --- apt-0.7.25.3/apt-pkg/makefile 2010-02-24 08:53:52.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/makefile 2010-02-24 07:57:37.000000000 +0000 @@ -42,7 +42,7 @@ acquire.h acquire-worker.h acquire-item.h acquire-method.h \ clean.h srcrecords.h cachefile.h versionmatch.h policy.h \ pkgsystem.h indexfile.h metaindex.h indexrecords.h vendor.h \ - vendorlist.h cdrom.h indexcopy.h aptconfiguration.h + vendorlist.h cdrom.h indexcopy.h aptconfiguration.h srkstring.h # Source code for the debian specific components # In theory the deb headers do not need to be exported.. diff -Nru apt-0.7.25.3/apt-pkg/pkgcache.cc apt-0.7.25.3+iPhone/apt-pkg/pkgcache.cc --- apt-0.7.25.3/apt-pkg/pkgcache.cc 2010-02-24 08:53:52.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/pkgcache.cc 2010-02-24 08:51:28.000000000 +0000 @@ -176,12 +176,25 @@ return Hash % _count(HeaderP->HashTable); } +unsigned long pkgCache::sHash(const srkString &Str) const +{ + unsigned long Hash = 0; + for (const char *I = Str.Start, *E = I + Str.Size; I != E; I++) + Hash = 5*Hash + tolower_ascii(*I); + return Hash % _count(HeaderP->HashTable); +} + /*}}}*/ // Cache::FindPkg - Locate a package by name /*{{{*/ // --------------------------------------------------------------------- /* Returns 0 on error, pointer to the package otherwise */ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) { + return FindPkg(srkString(Name)); +} + +pkgCache::PkgIterator pkgCache::FindPkg(const srkString &Name) +{ // Look at the hash bucket Package *Pkg = PkgP + HeaderP->HashTable[Hash(Name)]; for (; Pkg != PkgP; Pkg = PkgP + Pkg->NextPackage) diff -Nru apt-0.7.25.3/apt-pkg/pkgcachegen.cc apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.cc --- apt-0.7.25.3/apt-pkg/pkgcachegen.cc 2010-02-24 08:53:52.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.cc 2010-02-24 08:50:06.000000000 +0000 @@ -33,6 +33,8 @@ #include #include #include + +#include /*}}}*/ typedef vector::iterator FileIterator; @@ -103,26 +105,37 @@ pkgCache::VerIterator *OutVer) { List.Owner = this; + debListParser *debian(dynamic_cast(&List)); unsigned int Counter = 0; while (List.Step() == true) { // Get a pointer to the package structure - string PackageName = List.Package(); + srkString PackageName; + if (debian != NULL) + PackageName = debian->Find("Package"); + else + PackageName = List.Package(); if (PackageName.empty() == true) return false; pkgCache::PkgIterator Pkg; if (NewPackage(Pkg,PackageName) == false) - return _error->Error(_("Error occurred while processing %s (NewPackage)"),PackageName.c_str()); + return _error->Error(_("Error occurred while processing %s (NewPackage)"),std::string(PackageName).c_str()); Counter++; if (Counter % 100 == 0 && Progress != 0) Progress->Progress(List.Offset()); + string language(List.DescriptionLanguage()); + /* Get a pointer to the version structure. We know the list is sorted so we use that fact in the search. Insertion of new versions is done with correct sorting */ - string Version = List.Version(); + srkString Version; + if (debian != NULL) + Version = debian->Find("Version"); + else + Version = List.Version(); if (Version.empty() == true) { // we first process the package, then the descriptions @@ -130,7 +143,7 @@ // of MMap space) if (List.UsePackage(Pkg,pkgCache::VerIterator(Cache)) == false) return _error->Error(_("Error occurred while processing %s (UsePackage1)"), - PackageName.c_str()); + std::string(PackageName).c_str()); // Find the right version to write the description MD5SumValue CurMd5 = List.Description_md5(); @@ -147,7 +160,7 @@ // md5 && language for ( ; Desc.end() == false; Desc++) if (MD5SumValue(Desc.md5()) == CurMd5 && - Desc.LanguageCode() == List.DescriptionLanguage()) + Desc.LanguageCode() == language) duplicate=true; if(duplicate) continue; @@ -159,11 +172,11 @@ if (MD5SumValue(Desc.md5()) == CurMd5) { // Add new description - *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc); + *LastDesc = NewDescription(Desc, language, CurMd5, *LastDesc); Desc->ParentPkg = Pkg.Index(); if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) - return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"),PackageName.c_str()); + return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"),std::string(PackageName).c_str()); break; } } @@ -189,11 +202,11 @@ { if (List.UsePackage(Pkg,Ver) == false) return _error->Error(_("Error occurred while processing %s (UsePackage2)"), - PackageName.c_str()); + std::string(PackageName).c_str()); if (NewFileVer(Ver,List) == false) return _error->Error(_("Error occurred while processing %s (NewFileVer1)"), - PackageName.c_str()); + std::string(PackageName).c_str()); // Read only a single record and return if (OutVer != 0) @@ -224,15 +237,15 @@ if ((*LastVer == 0 && _error->PendingError()) || List.NewVersion(Ver) == false) return _error->Error(_("Error occurred while processing %s (NewVersion1)"), - PackageName.c_str()); + std::string(PackageName).c_str()); if (List.UsePackage(Pkg,Ver) == false) return _error->Error(_("Error occurred while processing %s (UsePackage3)"), - PackageName.c_str()); + std::string(PackageName).c_str()); if (NewFileVer(Ver,List) == false) return _error->Error(_("Error occurred while processing %s (NewVersion2)"), - PackageName.c_str()); + std::string(PackageName).c_str()); // Read only a single record and return if (OutVer != 0) @@ -251,11 +264,11 @@ for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++); // Add new description - *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc); + *LastDesc = NewDescription(Desc, language, List.Description_md5(), *LastDesc); Desc->ParentPkg = Pkg.Index(); if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) - return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),PackageName.c_str()); + return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),std::string(PackageName).c_str()); } FoundFileDeps |= List.HasFileDeps(); @@ -328,6 +341,11 @@ /* This creates a new package structure and adds it to the hash table */ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name) { + return NewPackage(Pkg, srkString(Name)); +} + +bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const srkString &Name) +{ Pkg = Cache.FindPkg(Name); if (Pkg.end() == false) return true; @@ -345,7 +363,7 @@ Cache.HeaderP->HashTable[Hash] = Package; // Set the name and the ID - Pkg->Name = Map.WriteString(Name); + Pkg->Name = Map.WriteString(Name.Start,Name.Size); if (Pkg->Name == 0) return false; Pkg->ID = Cache.HeaderP->PackageCount++; @@ -393,6 +411,13 @@ const string &VerStr, unsigned long Next) { + return NewVersion(Ver, srkString(VerStr), Next); +} + +unsigned long pkgCacheGenerator::NewVersion(pkgCache::VerIterator &Ver, + const srkString &VerStr, + unsigned long Next) +{ // Get a structure unsigned long Version = Map.Allocate(sizeof(pkgCache::Version)); if (Version == 0) @@ -402,7 +427,7 @@ Ver = pkgCache::VerIterator(Cache,Cache.VerP + Version); Ver->NextVer = Next; Ver->ID = Cache.HeaderP->VersionCount++; - Ver->VerStr = Map.WriteString(VerStr); + Ver->VerStr = Map.WriteString(VerStr.Start, VerStr.Size); if (Ver->VerStr == 0) return 0; @@ -478,6 +503,15 @@ unsigned int Op, unsigned int Type) { + return NewDepends(Ver, srkString(PackageName), srkString(Version), Op, Type); +} + +bool pkgCacheGenerator::ListParser::NewDepends(pkgCache::VerIterator Ver, + const srkString &PackageName, + const srkString &Version, + unsigned int Op, + unsigned int Type) +{ pkgCache &Cache = Owner->Cache; // Get a structure @@ -541,6 +575,13 @@ const string &PackageName, const string &Version) { + return NewProvides(Ver, srkString(PackageName), srkString(Version)); +} + +bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator Ver, + const srkString &PackageName, + const srkString &Version) +{ pkgCache &Cache = Owner->Cache; // We do not add self referencing provides diff -Nru apt-0.7.25.3/apt-pkg/pkgcachegen.h apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.h --- apt-0.7.25.3/apt-pkg/pkgcachegen.h 2010-02-24 08:53:52.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/pkgcachegen.h 2010-02-24 08:49:18.000000000 +0000 @@ -52,9 +52,11 @@ bool FoundFileDeps; bool NewPackage(pkgCache::PkgIterator &Pkg,const string &PkgName); + bool NewPackage(pkgCache::PkgIterator &Pkg,const srkString &PkgName); bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List); bool NewFileDesc(pkgCache::DescIterator &Desc,ListParser &List); unsigned long NewVersion(pkgCache::VerIterator &Ver,const string &VerStr,unsigned long Next); + unsigned long NewVersion(pkgCache::VerIterator &Ver,const srkString &VerStr,unsigned long Next); map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const string &Lang,const MD5SumValue &md5sum,map_ptrloc Next); public: @@ -96,11 +98,17 @@ inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);}; inline unsigned long WriteString(const string &S) {return Owner->Map.WriteString(S);}; inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);}; + inline unsigned long WriteString(const srkString &S) {return Owner->Map.WriteString(S.Start,S.Size);}; bool NewDepends(pkgCache::VerIterator Ver,const string &Package, const string &Version,unsigned int Op, unsigned int Type); + bool NewDepends(pkgCache::VerIterator Ver,const srkString &Package, + const srkString &Version,unsigned int Op, + unsigned int Type); bool NewProvides(pkgCache::VerIterator Ver,const string &Package, const string &Version); + bool NewProvides(pkgCache::VerIterator Ver,const srkString &Package, + const srkString &Version); bool NewTag(pkgCache::PkgIterator Pkg,const char *NameStart,unsigned int NameSize); public: diff -Nru apt-0.7.25.3/apt-pkg/pkgcache.h apt-0.7.25.3+iPhone/apt-pkg/pkgcache.h --- apt-0.7.25.3/apt-pkg/pkgcache.h 2010-02-24 08:53:52.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/pkgcache.h 2010-02-24 07:57:37.000000000 +0000 @@ -23,9 +23,10 @@ #include #include #include +#include using std::string; - + class pkgVersioningSystem; class pkgCache /*{{{*/ { @@ -102,6 +103,7 @@ unsigned long sHash(const string &S) const; unsigned long sHash(const char *S) const; + unsigned long sHash(const srkString &S) const; public: @@ -127,12 +129,14 @@ // String hashing function (512 range) inline unsigned long Hash(const string &S) const {return sHash(S);}; inline unsigned long Hash(const char *S) const {return sHash(S);}; + inline unsigned long Hash(const srkString &S) const {return sHash(S);}; // Usefull transformation things const char *Priority(unsigned char Priority); // Accessors PkgIterator FindPkg(const string &Name); + PkgIterator FindPkg(const srkString &Name); Header &Head() {return *HeaderP;}; inline PkgIterator PkgBegin(); inline PkgIterator PkgEnd(); diff -Nru apt-0.7.25.3/apt-pkg/srkstring.h apt-0.7.25.3+iPhone/apt-pkg/srkstring.h --- apt-0.7.25.3/apt-pkg/srkstring.h 1970-01-01 00:00:00.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/srkstring.h 2010-02-24 08:37:27.000000000 +0000 @@ -0,0 +1,59 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +// $Id: pkgcache.h,v 1.25 2001/07/01 22:28:24 jgg Exp $ +/* ###################################################################### + + Cache - Structure definitions for the cache file + + Please see doc/apt-pkg/cache.sgml for a more detailed description of + this format. Also be sure to keep that file up-to-date!! + + Clients should always use the CacheIterators classes for access to the + cache. They provide a simple STL-like method for traversing the links + of the datastructure. + + See pkgcachegen.h for information about generating cache structures. + + ##################################################################### */ + /*}}}*/ +#ifndef PKGLIB_PKGSTRING_H +#define PKGLIB_PKGSTRING_H + +#include + +class srkString +{ + public: + const char *Start; + size_t Size; + + srkString() : Start(NULL), Size(0) {} + + srkString(const char *Start, size_t Size) : Start(Start), Size(Size) {} + srkString(const char *Start, const char *Stop) : Start(Start), Size(Stop - Start) {} + srkString(const std::string &string) : Start(string.c_str()), Size(string.size()) {} + + bool empty() const { return Size == 0; } + void clear() { Start = NULL; Size = 0; } + + void assign(const char *nStart, const char *nStop) { Start = nStart; Size = nStop - nStart; } + void assign(const char *nStart, size_t nSize) { Start = nStart; Size = nSize; } + + size_t length() const { return Size; } + size_t size() const { return Size; } + + typedef const char *const_iterator; + const char *begin() const { return Start; } + const char *end() const { return Start + Size; } + + char operator [](size_t index) const { return Start[index]; } + + operator std::string() { std::string Str; Str.assign(Start, Size); return Str; } +}; + +int stringcmp(const std::string &lhs, const char *rhsb, const char *rhse); +inline bool operator ==(const std::string &lhs, const srkString &rhs) { + return stringcmp(lhs, rhs.begin(), rhs.end()) == 0; +} + +#endif diff -Nru apt-0.7.25.3/apt-pkg/version.h apt-0.7.25.3+iPhone/apt-pkg/version.h --- apt-0.7.25.3/apt-pkg/version.h 2010-02-01 19:44:40.000000000 +0000 +++ apt-0.7.25.3+iPhone/apt-pkg/version.h 2010-02-24 07:57:37.000000000 +0000 @@ -20,7 +20,7 @@ #ifndef PKGLIB_VERSION_H #define PKGLIB_VERSION_H - +#include #include #include