build: Check whether HAVE_* macros for headers are defined
[dpkg.git] / dselect / pkglist.h
blob0816d4ba9b7cd9d1d597bdebe3bec43b31831f37
1 /*
2 * dselect - Debian package maintenance user interface
3 * pkglist.h - external definitions for package list handling
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>
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.
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.
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/>.
23 #ifndef PKGLIST_H
24 #define PKGLIST_H
26 #include <regex.h>
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
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
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,
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,
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.
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;
86 void free(bool recursive);
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;
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;
107 // Table of packages
108 struct perpackagestate *datatable;
109 struct perpackagestate **table;
111 // Misc.
112 int nallocated;
113 bool recursive, verbose;
114 enum {
115 so_unsorted,
116 so_section,
117 so_priority,
118 so_alpha,
119 } sortorder;
120 enum {
121 sso_unsorted,
122 sso_avail,
123 sso_state,
124 } statsortorder;
125 enum {
126 ado_none,
127 ado_available,
128 ado_both,
129 } archdisplayopt;
130 enum {
131 vdo_none,
132 vdo_available,
133 vdo_both,
134 } versiondisplayopt;
135 bool calcssadone, calcsssdone;
136 struct perpackagestate *headings;
138 // Package searching flags
139 bool searchdescr;
140 regex_t searchfsm;
142 // Information displays
143 struct infotype {
144 bool (packagelist::*relevant)(); // null means always relevant
145 void (packagelist::*display)(); // null means end of table
147 const infotype *currentinfo;
148 static const infotype infoinfos[];
149 static const infotype *const baseinfo;
150 bool itr_recursive();
151 bool itr_nonrecursive();
152 void severalinfoblurb();
153 void itd_mainwelcome();
154 void itd_explaindisplay();
155 void itd_recurwelcome();
156 void itd_relations();
157 void itd_description();
158 void itd_statuscontrol();
159 void itd_availablecontrol();
161 // Dependency and sublist processing
162 struct doneent { doneent *next; void *dep; } *depsdone, *unavdone;
163 bool alreadydone(doneent **, void *);
164 int resolvedepcon(dependency*);
165 int checkdependers(pkginfo*, int changemade); // returns new changemade
166 int deselect_one_of(pkginfo *er, pkginfo *ed, dependency *dep);
168 // Define these virtuals
169 bool checksearch(char *str) override;
170 bool matchsearch(int index) override;
171 void redraw1itemsel(int index, int selected) override;
172 void redrawcolheads() override;
173 void redrawthisstate() override;
174 void redrawinfo() override;
175 void redrawtitle() override;
176 void setwidths() override;
177 const char *itemname(int index) override;
178 const struct helpmenuentry *helpmenulist() override;
180 // Miscellaneous internal routines
182 void redraw1package(int index, int selected);
183 int compareentries(const struct perpackagestate *a, const struct perpackagestate *b);
184 friend int qsort_compareentries(const void *a, const void *b);
185 pkgwant reallywant(pkgwant, struct perpackagestate *);
186 int describemany(char buf[], const char *prioritystring, const char *section,
187 const struct perpackagestate *pps);
188 bool deppossatisfied(deppossi *possi, perpackagestate **fixbyupgrade);
190 void sortmakeheads();
191 void resortredisplay();
192 void movecursorafter(int ncursor);
193 void initialsetup();
194 void finalsetup();
195 void ensurestatsortinfo();
197 // To do with building the list, with heading lines in it
198 void discardheadings();
199 void addheading(enum ssavailval, enum ssstateval,
200 pkgpriority, const char *, const char *section);
201 void sortinplace();
202 bool affectedmatches(struct pkginfo *pkg, struct pkginfo *comparewith);
203 void affectedrange(int *startp, int *endp);
204 void setwant(pkgwant nw);
205 void sethold(int hold);
207 public:
209 // Keybinding functions */
210 void kd_quit_noop();
211 void kd_revert_abort();
212 void kd_revertsuggest();
213 void kd_revertdirect();
214 void kd_revertinstalled();
215 void kd_morespecific();
216 void kd_lessspecific();
217 void kd_swaporder();
218 void kd_swapstatorder();
219 void kd_select();
220 void kd_deselect();
221 void kd_purge();
222 void kd_hold();
223 void kd_unhold();
224 void kd_info();
225 void kd_toggleinfo();
226 void kd_verbose();
227 void kd_archdisplay();
228 void kd_versiondisplay();
230 explicit packagelist(keybindings *kb); // nonrecursive
231 packagelist(keybindings *kb, pkginfo **pkgltab); // recursive
232 void add(pkginfo **array) { while (*array) add(*array++); }
233 void add(pkginfo*);
234 void add(pkginfo *, pkgwant);
235 void add(pkginfo*, const char *extrainfo, showpriority displayimportance);
236 bool add(dependency *, showpriority displayimportance);
237 void addunavailable(deppossi*);
238 bool useavailable(pkginfo *);
239 pkgbin *find_pkgbin(pkginfo *);
241 int resolvesuggest();
242 int deletelessimp_anyleft(showpriority than);
243 pkginfo **display();
244 ~packagelist();
247 void repeatedlydisplay(packagelist *sub, showpriority,
248 packagelist *unredisplay = nullptr);
249 int would_like_to_install(pkgwant, pkginfo *pkg);
251 extern const char *const wantstrings[];
252 extern const char *const eflagstrings[];
253 extern const char *const statusstrings[];
254 extern const char *const prioritystrings[];
255 extern const char *const priorityabbrevs[];
256 extern const char *const relatestrings[];
257 extern const char *const ssastrings[], *const ssaabbrevs[];
258 extern const char *const sssstrings[], *const sssabbrevs[];
259 extern const char statuschars[];
260 extern const char eflagchars[];
261 extern const char wantchars[];
263 #endif /* PKGLIST_H */