121
if (debug) fprintf(debug,"packagelist[%p]::addheading(%d,%d,%d,%s,%s)\n",
122
this,ssavail,ssstate,priority,
123
otherpriority ? otherpriority : "<null>",
124
section ? section : "<null>");
121
debug(dbg_general, "packagelist[%p]::addheading(%d,%d,%d,%s,%s)",
122
this, ssavail, ssstate, priority,
123
otherpriority ? otherpriority : "<null>",
124
section ? section : "<null>");
126
126
struct pkginfo *newhead= new pkginfo;
127
127
newhead->name= 0;
150
150
void packagelist::sortinplace() {
151
151
sortpackagelist= this;
153
if (debug) fprintf(debug,"packagelist[%p]::sortinplace()\n",this);
154
qsort(table,nitems,sizeof(struct pkginfoperfile*),qsort_compareentries);
153
debug(dbg_general, "packagelist[%p]::sortinplace()", this);
154
qsort(table, nitems, sizeof(struct pkgbin *), qsort_compareentries);
157
157
void packagelist::ensurestatsortinfo() {
159
159
const struct versionrevision *vera;
160
160
struct pkginfo *pkg;
163
if (debug) fprintf(debug,"packagelist[%p]::ensurestatsortinfos() "
164
"sortorder=%d nitems=%d\n",this,statsortorder,nitems);
164
"packagelist[%p]::ensurestatsortinfos() sortorder=%d nitems=%d",
165
this, statsortorder, nitems);
166
167
switch (statsortorder) {
167
168
case sso_unsorted:
168
if (debug) fprintf(debug,"packagelist[%p]::ensurestatsortinfos() unsorted\n",this);
169
debug(dbg_general, "packagelist[%p]::ensurestatsortinfos() unsorted", this);
171
if (debug) fprintf(debug,"packagelist[%p]::ensurestatsortinfos() calcssadone=%d\n",
172
debug(dbg_general, "packagelist[%p]::ensurestatsortinfos() calcssadone=%d",
173
174
if (calcssadone) return;
174
175
for (index=0; index < nitems; index++) {
176
fprintf(debug,"packagelist[%p]::ensurestatsortinfos() i=%d pkg=%s\n",
177
this,index,table[index]->pkg->name);
176
debug(dbg_general, "packagelist[%p]::ensurestatsortinfos() i=%d pkg=%s",
177
this, index, table[index]->pkg->name);
178
178
pkg= table[index]->pkg;
179
179
switch (pkg->status) {
180
180
case pkginfo::stat_unpacked:
213
213
internerr("unknown stat in ensurestatsortinfo sso_avail");
216
fprintf(debug,"packagelist[%p]::ensurestatsortinfos() i=%d ssavail=%d\n",
217
this,index,table[index]->ssavail);
216
"packagelist[%p]::ensurestatsortinfos() i=%d ssavail=%d",
217
this, index, table[index]->ssavail);
223
if (debug) fprintf(debug,"packagelist[%p]::ensurestatsortinfos() calcsssdone=%d\n",
222
debug(dbg_general, "packagelist[%p]::ensurestatsortinfos() calcsssdone=%d",
225
224
if (calcsssdone) return;
226
225
for (index=0; index < nitems; index++) {
228
fprintf(debug,"packagelist[%p]::ensurestatsortinfos() i=%d pkg=%s\n",
229
this,index,table[index]->pkg->name);
226
debug(dbg_general, "packagelist[%p]::ensurestatsortinfos() i=%d pkg=%s",
227
this, index, table[index]->pkg->name);
230
228
switch (table[index]->pkg->status) {
231
229
case pkginfo::stat_unpacked:
232
230
case pkginfo::stat_halfconfigured:
248
246
internerr("unknown stat in ensurestatsortinfo sso_state");
251
fprintf(debug,"packagelist[%p]::ensurestatsortinfos() i=%d ssstate=%d\n",
252
this,index,table[index]->ssstate);
249
"packagelist[%p]::ensurestatsortinfos() i=%d ssstate=%d",
250
this, index, table[index]->ssstate);
268
if (debug) fprintf(debug,"packagelist[%p]::sortmakeheads() "
269
"sortorder=%d statsortorder=%d\n",this,sortorder,statsortorder);
266
"packagelist[%p]::sortmakeheads() sortorder=%d statsortorder=%d",
267
this, sortorder, statsortorder);
271
269
int nrealitems= nitems;
272
270
addheading(ssa_none,sss_none,pkginfo::pri_unset,0,0);
310
308
strcasecmp(thispkg->section ? thispkg->section : "",
311
309
lastpkg->section ? lastpkg->section : ""));
313
if (debug) fprintf(debug,"packagelist[%p]::sortmakeheads()"
314
" pkg=%s state=%d avail=%d %s priority=%d"
315
" otherpriority=%s %s section=%s %s\n",
317
thispkg->clientdata->ssavail,
318
thispkg->clientdata->ssstate,
319
ssdiff ? "*diff" : "same",
321
thispkg->priority != pkginfo::pri_other ? "<none>"
322
: thispkg->otherpriority ? thispkg->otherpriority
324
prioritydiff ? "*diff*" : "same",
325
thispkg->section ? thispkg->section : "<null>",
326
sectiondiff ? "*diff*" : "same");
312
"packagelist[%p]::sortmakeheads() pkg=%s state=%d avail=%d %s "
313
"priority=%d otherpriority=%s %s section=%s %s",
315
thispkg->clientdata->ssavail, thispkg->clientdata->ssstate,
316
ssdiff ? "*diff" : "same",
318
thispkg->priority != pkginfo::pri_other ? "<none>" :
319
thispkg->otherpriority ? thispkg->otherpriority : "<null>",
320
prioritydiff ? "*diff*" : "same",
321
thispkg->section ? thispkg->section : "<null>",
322
sectiondiff ? "*diff*" : "same");
329
325
addheading(ssavail,ssstate,
330
326
pkginfo::pri_unset,0, 0);
332
328
if (sortorder == so_section && sectiondiff)
333
329
addheading(ssavail,ssstate,
334
330
pkginfo::pri_unset,0, thispkg->section ? thispkg->section : "");
336
332
if (sortorder == so_priority && prioritydiff)
337
333
addheading(ssavail,ssstate,
338
334
thispkg->priority,thispkg->otherpriority, 0);
340
336
if (sortorder != so_alpha && (prioritydiff || sectiondiff))
341
337
addheading(ssavail,ssstate,
342
338
thispkg->priority,thispkg->otherpriority,
343
339
thispkg->section ? thispkg->section : "");
345
341
lastpkg= thispkg;
355
351
void packagelist::initialsetup() {
357
fprintf(debug,"packagelist[%p]::initialsetup()\n",this);
352
debug(dbg_general, "packagelist[%p]::initialsetup()", this);
359
int allpackages= countpackages();
354
int allpackages = pkg_db_count();
360
355
datatable= new struct perpackagestate[allpackages];
362
357
nallocated= allpackages+150; // will realloc if necessary, so 150 not critical
374
369
void packagelist::finalsetup() {
378
fprintf(debug,"packagelist[%p]::finalsetup done; recursive=%d nitems=%d\n",
379
this, recursive, nitems);
372
debug(dbg_general, "packagelist[%p]::finalsetup done; recursive=%d nitems=%d",
373
this, recursive, nitems);
382
376
packagelist::packagelist(keybindings *kb) : baselist(kb) {
467
462
packagelist::~packagelist() {
468
if (debug) fprintf(debug,"packagelist[%p]::~packagelist()\n",this);
463
debug(dbg_general, "packagelist[%p]::~packagelist()", this);
470
465
if (searchstring[0])
471
466
regfree(&searchfsm);
473
468
discardheadings();
476
471
for (index=0; index<nitems; index++) table[index]->free(recursive);
478
473
delete[] datatable;
479
if (debug) fprintf(debug,"packagelist[%p]::~packagelist() tables freed\n",this);
474
debug(dbg_general, "packagelist[%p]::~packagelist() tables freed", this);
481
476
doneent *search, *next;
482
477
for (search=depsdone; search; search=next) {
483
478
next= search->next;
487
if (debug) fprintf(debug,"packagelist[%p]::~packagelist() done\n",this);
482
debug(dbg_general, "packagelist[%p]::~packagelist() done", this);
586
581
if (response == ERR)
587
582
ohshite(_("getch failed"));
588
583
interp= (*bindings)(response);
590
fprintf(debug,"packagelist[%p]::display() response=%d interp=%s\n",
591
this,response, interp ? interp->action : "[none]");
584
debug(dbg_general, "packagelist[%p]::display() response=%d interp=%s",
585
this, response, interp ? interp->action : "[none]");
592
586
if (!interp) { beep(); continue; }
593
587
(this->*(interp->pfn))();
594
588
if (interp->qa != qa_noquit) break;
596
590
pop_cleanup(ehflag_normaltidy); // unset the SIGWINCH handler
599
593
if (interp->qa == qa_quitnochecksave || !readwrite) {
600
if (debug) fprintf(debug,"packagelist[%p]::display() done - quitNOcheck\n",this);
594
debug(dbg_general, "packagelist[%p]::display() done - quitNOcheck", this);
605
599
retl= new pkginfo*[nitems+1];
606
600
for (index=0; index<nitems; index++) retl[index]= table[index]->pkg;
608
if (debug) fprintf(debug,"packagelist[%p]::display() done, retl=%p\n",this,retl);
602
debug(dbg_general, "packagelist[%p]::display() done, retl=%p", this, retl);
611
605
packagelist *sub= new packagelist(bindings,0);