pkglist.h 8.4 KB

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