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