pkglist.h 8.4 KB

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