Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/src/pkgcli.h
2065 views
1
/*-
2
* Copyright (c) 2011-2024 Baptiste Daroussin <[email protected]>
3
* Copyright (c) 2013 Matthew Seaman <[email protected]>
4
*
5
* SPDX-License-Identifier: BSD-2-Clause
6
*/
7
8
#ifndef _PKGCLI_H
9
#define _PKGCLI_H
10
11
#include <search.h>
12
#include <stdbool.h>
13
#include <stdint.h>
14
#include <string.h>
15
#include <xstring.h>
16
#include <bsd_compat.h>
17
#include <pkg/vec.h>
18
19
#define pkg_warnx(fmt, ...) pkg_fprintf(stderr, "%S: " fmt, getprogname(), __VA_ARGS__, -1)
20
#define ll_foreach(head, el) for (el=head; el != NULL; el = (el)->next)
21
22
extern bool quiet;
23
extern bool newpkgversion;
24
extern int nbtodl;
25
26
/* pkg add */
27
int exec_add(int, char **);
28
void usage_add(void);
29
30
/* pkg alias */
31
int exec_alias(int, char **);
32
void usage_alias(void);
33
34
/* pkg annotate */
35
int exec_annotate(int, char **);
36
void usage_annotate(void);
37
38
/* pkg audit */
39
int exec_audit(int, char **);
40
void usage_audit(void);
41
42
/* pkg autoremove */
43
int exec_autoremove(int, char **);
44
void usage_autoremove(void);
45
46
/* pkg check */
47
int exec_check(int, char **);
48
void usage_check(void);
49
50
/* pkg clean */
51
int exec_clean(int, char **);
52
void usage_clean(void);
53
54
/* pkg create */
55
int exec_create(int, char **);
56
void usage_create(void);
57
58
/* pkg delete */
59
void usage_delete(void);
60
int exec_delete(int, char **);
61
62
/* pkg info */
63
64
int exec_info(int, char **);
65
void usage_info(void);
66
67
/* pkg install */
68
int exec_install(int, char **);
69
void usage_install(void);
70
71
/* pkg plugins */
72
int exec_plugins(int, char **);
73
void usage_plugins(void);
74
75
/* pkg key */
76
int exec_key(int, char **);
77
void usage_key(void);
78
79
/* pkg lock */
80
int exec_lock(int, char **);
81
int exec_unlock(int, char **);
82
void usage_lock(void);
83
84
/* pkg query */
85
int exec_query(int, char **);
86
void usage_query(void);
87
88
/* pkg register */
89
void usage_register(void);
90
int exec_register(int argc, char **argv);
91
92
/* pkg repo */
93
int exec_repo(int, char **);
94
void usage_repo(void);
95
96
/* pkg repo */
97
int exec_repositories(int, char **);
98
void usage_repositories(void);
99
100
/* pkg rquery */
101
int exec_rquery(int, char **);
102
void usage_rquery(void);
103
104
/* pkg set */
105
int exec_set(int, char **);
106
void usage_set(void);
107
108
/* pkg search */
109
int exec_search(int, char **);
110
void usage_search(void);
111
112
/* pkg shlib */
113
int exec_shlib(int, char **);
114
void usage_shlib(void);
115
char *sanitize(char *, const char *, size_t);
116
117
/* pkg stats */
118
#define STATS_LOCAL (1<<0)
119
#define STATS_REMOTE (1<<1)
120
121
int exec_stats(int, char **);
122
void usage_stats(void);
123
124
/* pkg triggers */
125
int exec_triggers(int, char **);
126
void usage_triggers(void);
127
128
/* pkg update */
129
int exec_update(int, char **);
130
void usage_update(void);
131
int pkgcli_update(bool, bool, c_charv_t *);
132
133
/* pkg updating */
134
int exec_updating(int, char **);
135
void usage_updating(void);
136
137
/* pkg upgrade */
138
int exec_upgrade(int, char **);
139
void usage_upgrade(void);
140
141
/* pkg fetch */
142
int exec_fetch(int, char **);
143
void usage_fetch(void);
144
145
/* pkg shell */
146
int exec_shell(int, char **);
147
void usage_shell(void);
148
149
/* pkg version */
150
#define VERSION_SOURCE_INDEX (1U<<0)
151
#define VERSION_ORIGIN (1U<<1)
152
#define VERSION_QUIET (1U<<2)
153
#define VERSION_VERBOSE (1U<<3)
154
#define VERSION_STATUS (1U<<4)
155
#define VERSION_NOSTATUS (1U<<5)
156
#define VERSION_WITHORIGIN (1U<<7)
157
#define VERSION_TESTVERSION (1U<<8)
158
#define VERSION_TESTPATTERN (1U<<9)
159
#define VERSION_SOURCE_PORTS (1U<<10)
160
#define VERSION_SOURCE_REMOTE (1U<<11)
161
#define VERSION_INDEX_FILE_NAME (1U<<12)
162
#define VERSION_WITHNAME (1U<<13)
163
164
#define VERSION_SOURCES (VERSION_SOURCE_PORTS | \
165
VERSION_SOURCE_INDEX | \
166
VERSION_SOURCE_REMOTE)
167
168
int exec_version(int, char **);
169
void usage_version(void);
170
171
/* pkg which */
172
int exec_which(int, char **);
173
void usage_which(void);
174
175
/* pkg ssh */
176
int exec_ssh(int, char **);
177
void usage_ssh(void);
178
179
/* pkg config */
180
int exec_config(int, char **);
181
void usage_config(void);
182
183
/* utils */
184
185
/* These are the fields of the Full output, in order */
186
#define INFO_NAME (1LL<<0)
187
#define INFO_VERSION (1LL<<1)
188
#define INFO_INSTALLED (1LL<<2)
189
#define INFO_ORIGIN (1LL<<3)
190
#define INFO_ARCH (1LL<<4)
191
#define INFO_PREFIX (1LL<<5)
192
#define INFO_REPOSITORY (1LL<<6)
193
#define INFO_CATEGORIES (1LL<<7)
194
#define INFO_LICENSES (1LL<<8)
195
#define INFO_MAINTAINER (1LL<<9)
196
#define INFO_WWW (1LL<<10)
197
#define INFO_COMMENT (1LL<<11)
198
#define INFO_OPTIONS (1LL<<12)
199
#define INFO_SHLIBS_REQUIRED (1LL<<13)
200
#define INFO_SHLIBS_PROVIDED (1LL<<14)
201
#define INFO_ANNOTATIONS (1LL<<15)
202
#define INFO_FLATSIZE (1LL<<16)
203
#define INFO_PKGSIZE (1LL<<17)
204
#define INFO_DESCR (1LL<<18)
205
#define INFO_PROVIDED (1LL<<19)
206
#define INFO_REQUIRED (1LL<<20)
207
208
/* Other fields not part of the Full output */
209
#define INFO_MESSAGE (1LL<<21)
210
#define INFO_DEPS (1LL<<22)
211
#define INFO_RDEPS (1LL<<23)
212
#define INFO_FILES (1LL<<24)
213
#define INFO_DIRS (1LL<<25)
214
#define INFO_USERS (1LL<<26)
215
#define INFO_GROUPS (1LL<<27)
216
#define INFO_REPOURL (1LL<<28)
217
#define INFO_LOCKED (1LL<<29)
218
#define INFO_OPTION_DEFAULTS (1LL<<30)
219
#define INFO_OPTION_DESCRIPTIONS (1LL<<31)
220
221
#define INFO_LASTFIELD INFO_LOCKED
222
#define INFO_ALL (((INFO_LASTFIELD) << 1) - 1)
223
224
/* Identifying tags */
225
#define INFO_TAG_NAME (1LL<<32)
226
#define INFO_TAG_ORIGIN (1LL<<33)
227
#define INFO_TAG_NAMEVER (1LL<<34)
228
229
/* Output YAML format */
230
#define INFO_RAW (1LL<<35)
231
#define INFO_RAW_YAML (1LL<<36)
232
#define INFO_RAW_JSON (1LL<<37)
233
#define INFO_RAW_JSON_COMPACT (1LL<<38)
234
#define INFO_RAW_UCL (1LL<<39)
235
236
/* Everything in the 'full' package output */
237
#define INFO_FULL (INFO_NAME|INFO_VERSION|INFO_INSTALLED|INFO_ORIGIN| \
238
INFO_ARCH|INFO_PREFIX|INFO_REPOSITORY| \
239
INFO_CATEGORIES|INFO_LICENSES|INFO_MAINTAINER| \
240
INFO_WWW|INFO_COMMENT|INFO_OPTIONS| \
241
INFO_SHLIBS_REQUIRED|INFO_SHLIBS_PROVIDED| \
242
INFO_ANNOTATIONS|INFO_FLATSIZE|INFO_PKGSIZE| \
243
INFO_DESCR|INFO_PROVIDED|INFO_REQUIRED)
244
245
/* Everything that can take more than one line to print */
246
#define INFO_MULTILINE (INFO_OPTIONS|INFO_SHLIBS_REQUIRED| \
247
INFO_SHLIBS_PROVIDED|INFO_ANNOTATIONS| \
248
INFO_DESCR|INFO_MESSAGE|INFO_DEPS|INFO_RDEPS| \
249
INFO_FILES|INFO_DIRS)
250
251
bool query_yesno(bool deft, const char *msg, ...);
252
int query_select(const char *msg, const char **opts, int ncnt, int deft);
253
bool query_tty_yesno(bool deft, const char *msg, ...);
254
int info_flags(uint64_t opt, bool remote);
255
void print_info(struct pkgdb *db, struct pkg * const pkg, uint64_t opt);
256
int print_jobs_summary(struct pkg_jobs *j, const char *msg, ...);
257
258
void job_status_begin(xstring *);
259
void job_status_end(xstring *);
260
261
int event_callback(void *data, struct pkg_event *ev);
262
int print_pkg(struct pkg *p, void *ctx);
263
void print_repository(struct pkg_repo *repo, bool pad);
264
void progressbar_start(const char *pmsg);
265
void progressbar_tick(int64_t current, int64_t total);
266
void progressbar_stop(void);
267
268
extern xstring *messages;
269
270
271
/* pkg-query / pkg-rquery */
272
struct query_flags {
273
const char flag;
274
const char *options;
275
const unsigned multiline;
276
const int dbflags;
277
};
278
279
void print_query(struct pkg *pkg, char *qstr, char multiline);
280
int format_sql_condition(const char *str, xstring *sqlcond,
281
bool for_remote);
282
int analyse_query_string(char *qstr, struct query_flags *q_flags,
283
const unsigned int q_flags_len, int *flags,
284
char *multiline);
285
int password_cb(char *buf, int size, int rwflag, void *key);
286
287
extern int default_yes;
288
extern int yes;
289
extern int dry_run;
290
extern bool auto_update;
291
extern int case_sensitive;
292
extern int force;
293
extern bool quiet;
294
extern bool newpkgversion;
295
void set_globals(void);
296
297
#endif
298
299