pkglist.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /* -*- c++ -*-
  2. * dselect - selection of Debian packages
  3. * pkglist.h - external definitions for package list handling
  4. *
  5. * Copyright (C) 1994,1995 Ian Jackson <iwj10@cus.cam.ac.uk>
  6. *
  7. * This is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2,
  10. * or (at your option) any later version.
  11. *
  12. * This is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public
  18. * License along with dpkg; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #ifndef PKGLIST_H
  22. #define PKGLIST_H
  23. enum showpriority {
  24. dp_none, // has not been involved in any unsatisfied things
  25. dp_may, // has been involved in an unsatisfied Suggests
  26. dp_should, // has been involved in an unsatisfied Recommends
  27. dp_must // has been involved in an unsatisfied Depends/Conflicts
  28. };
  29. enum selpriority {
  30. // where did the currently suggested value come from, and how important
  31. // is it to display this package ?
  32. // low
  33. sp_inherit, // inherited from our parent list
  34. sp_selecting, // propagating a selection
  35. sp_deselecting, // propagating a deselection
  36. sp_fixed // it came from the `status' file and we're not a recursive list
  37. // high
  38. };
  39. enum ssavailval { // Availability sorting order, first to last:
  40. ssa_broken, // Brokenly-installed and nothing available
  41. ssa_notinst_unseen, // Entirely new packages (available but not deselected yet)
  42. ssa_installed_newer, // Installed, newer version available
  43. ssa_installed_gone, // Installed but no longer available
  44. ssa_installed_sameold, // Same or older version available as installed
  45. ssa_notinst_seen, // Available but not installed
  46. ssa_notinst_gone, // Not available, and only config files left
  47. ssa_none=-1
  48. };
  49. enum ssstateval { // State sorting order, first to last:
  50. sss_broken, // In some way brokenly installed
  51. sss_installed, // Installed
  52. sss_configfiles, // Config files only
  53. sss_notinstalled, // Not installed
  54. sss_none=-1
  55. };
  56. struct perpackagestate {
  57. struct pkginfo *pkg;
  58. /* The `heading' entries in the list, for `all packages of type foo',
  59. * point to a made-up pkginfo, which has pkg->name==0.
  60. * pkg->priority and pkg->section are set to the values if appropriate, or to
  61. * pri_unset resp. null if the heading refers to all priorities resp. sections.
  62. * uprec is used when constructing the list initially and when tearing it
  63. * down and should not otherwise be used; other fields are undefined.
  64. */
  65. pkginfo::pkgwant original; // set by caller
  66. pkginfo::pkgwant direct; // set by caller
  67. pkginfo::pkgwant suggested; // set by caller, modified by resolvesuggest
  68. pkginfo::pkgwant selected; // not set by caller, will be set by packagelist
  69. selpriority spriority; // monotonically increases (used by sublists)
  70. showpriority dpriority; // monotonically increases (used by sublists)
  71. struct perpackagestate *uprec; // 0 if this is not part of a recursive list
  72. ssavailval ssavail;
  73. ssstateval ssstate;
  74. varbuf relations;
  75. void free(int recursive);
  76. };
  77. class packagelist : public baselist {
  78. int status_width, gap_width, section_width, priority_width;
  79. int package_width, versioninstalled_width, versionavailable_width, description_width;
  80. int section_column, priority_column, versioninstalled_column;
  81. int versionavailable_column, package_column, description_column;
  82. // Only used when `verbose' is set
  83. int status_hold_width, status_status_width, status_want_width;
  84. // Table of packages
  85. struct perpackagestate *datatable;
  86. struct perpackagestate **table;
  87. // Misc.
  88. int recursive, nallocated, verbose;
  89. enum { so_unsorted, so_section, so_priority, so_alpha } sortorder;
  90. enum { sso_unsorted, sso_avail, sso_state } statsortorder;
  91. enum { vdo_none, vdo_available, vdo_both } versiondisplayopt;
  92. int calcssadone, calcsssdone;
  93. struct perpackagestate *headings;
  94. // Information displays
  95. struct infotype {
  96. int (packagelist::*relevant)(); // null means always relevant
  97. void (packagelist::*display)(); // null means end of table
  98. };
  99. const infotype *currentinfo;
  100. static const infotype infoinfos[];
  101. static const infotype *const baseinfo;
  102. int itr_recursive();
  103. int itr_nonrecursive();
  104. void severalinfoblurb(const char *whatinfoline);
  105. void itd_mainwelcome();
  106. void itd_explaindisplay();
  107. void itd_recurwelcome();
  108. void itd_relations();
  109. void itd_description();
  110. void itd_statuscontrol();
  111. void itd_availablecontrol();
  112. // Dependency and sublist processing
  113. struct doneent { doneent *next; void *dep; } *depsdone, *unavdone;
  114. int alreadydone(doneent**, void*);
  115. int resolvedepcon(dependency*);
  116. int checkdependers(pkginfo*, int changemade); // returns new changemade
  117. int deselect_one_of(pkginfo *er, pkginfo *ed, dependency *display);
  118. // Define these virtuals
  119. void redraw1itemsel(int index, int selected);
  120. void redrawcolheads();
  121. void redrawthisstate();
  122. void redrawinfo();
  123. void redrawtitle();
  124. void setwidths();
  125. const char *itemname(int index);
  126. const struct helpmenuentry *helpmenulist();
  127. // Miscellaneous internal routines
  128. void redraw1package(int index, int selected);
  129. int compareentries(const struct perpackagestate *a, const struct perpackagestate *b);
  130. friend int qsort_compareentries(const void *a, const void *b);
  131. pkginfo::pkgwant reallywant(pkginfo::pkgwant, struct perpackagestate*);
  132. int describemany(char buf[], const char *prioritystring, const char *section,
  133. const struct perpackagestate *pps);
  134. int deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade);
  135. void sortmakeheads();
  136. void resortredisplay();
  137. void movecursorafter(int ncursor);
  138. void initialsetup();
  139. void finalsetup();
  140. void ensurestatsortinfo();
  141. // To do with building the list, with heading lines in it
  142. void discardheadings();
  143. void addheading(enum ssavailval, enum ssstateval,
  144. pkginfo::pkgpriority, const char*, const char *section);
  145. void sortinplace();
  146. int affectedmatches(struct pkginfo *pkg, struct pkginfo *comparewith);
  147. void affectedrange(int *startp, int *endp);
  148. void setwant(pkginfo::pkgwant nw);
  149. void sethold(int hold);
  150. public:
  151. // Keybinding functions */
  152. void kd_quit_noop();
  153. void kd_revert_abort();
  154. void kd_revertsuggest();
  155. void kd_revertdirect();
  156. void kd_morespecific();
  157. void kd_lessspecific();
  158. void kd_swaporder();
  159. void kd_swapstatorder();
  160. void kd_select();
  161. void kd_deselect();
  162. void kd_purge();
  163. void kd_hold();
  164. void kd_unhold();
  165. void kd_info();
  166. void kd_toggleinfo();
  167. void kd_verbose();
  168. void kd_versiondisplay();
  169. packagelist(keybindings *kb); // nonrecursive
  170. packagelist(keybindings *kb, pkginfo **pkgltab); // recursive
  171. void add(pkginfo **arry) { while (*arry) add(*arry++); }
  172. void add(pkginfo*);
  173. void add(pkginfo*, pkginfo::pkgwant);
  174. void add(pkginfo*, const char *extrainfo, showpriority displayimportance);
  175. int add(dependency*, showpriority displayimportance);
  176. void addunavailable(deppossi*);
  177. int useavailable(pkginfo*);
  178. pkginfoperfile *findinfo(pkginfo*);
  179. int resolvesuggest();
  180. int deletelessimp_anyleft(showpriority than);
  181. pkginfo **display();
  182. ~packagelist();
  183. };
  184. void repeatedlydisplay(packagelist *sub, showpriority, packagelist *unredisplay =0);
  185. int would_like_to_install(pkginfo::pkgwant, pkginfo *pkg);
  186. extern const char *const wantstrings[];
  187. extern const char *const eflagstrings[];
  188. extern const char *const statusstrings[];
  189. extern const char *const prioritystrings[];
  190. extern const char *const priorityabbrevs[];
  191. extern const char *const relatestrings[];
  192. extern const char *const ssastrings[], *const ssaabbrevs[];
  193. extern const char *const sssstrings[], *const sssabbrevs[];
  194. extern const char statuschars[];
  195. extern const char eflagchars[];
  196. extern const char wantchars[];
  197. const struct pkginfoperfile *i2info(struct pkginfo *pkg);
  198. extern modstatdb_rw readwrite;
  199. #endif /* PKGLIST_H */