pkglist.h 8.1 KB

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