1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
|
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 <algorithm>
#include <stdint.h>
+#include <apt-pkg/srkstring.h>
+
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 <iostream>
#include <time.h>
+#include <apt-pkg/srkstring.h>
+
using std::string;
using std::vector;
using std::ostream;
@@ -57,6 +59,7 @@
bool ReadMessages(int Fd, vector<string> &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 <unistd.h>
#include <errno.h>
#include <stdio.h>
+
+#include <apt-pkg/deblistparser.h>
/*}}}*/
typedef vector<pkgIndexFile *>::iterator FileIterator;
@@ -103,26 +105,37 @@
pkgCache::VerIterator *OutVer)
{
List.Owner = this;
+ debListParser *debian(dynamic_cast<debListParser *>(&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 <string>
#include <time.h>
#include <apt-pkg/mmap.h>
+#include <apt-pkg/srkstring.h>
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 <string>
+
+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 <apt-pkg/srkstring.h>
#include <apt-pkg/strutl.h>
#include <string>
|