forked from freebsd/pkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpkgcli.h
272 lines (221 loc) · 7.17 KB
/
pkgcli.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
/*-
* Copyright (c) 2011-2012 Baptiste Daroussin <[email protected]>
* Copyright (c) 2013 Matthew Seaman <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer
* in this position and unchanged.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _PKGCLI_H
#define _PKGCLI_H
extern bool quiet;
extern int nbactions;
int nbactions;
extern int nbdone;
extern bool newpkgversion;
int nbdone;
/* pkg add */
int exec_add(int, char **);
void usage_add(void);
/* pkg annotate */
int exec_annotate(int, char **);
void usage_annotate(void);
/* pkg audit */
int exec_audit(int, char **);
void usage_audit(void);
/* pkg autoremove */
int exec_autoremove(int, char **);
void usage_autoremove(void);
/* pkg backup */
int exec_backup(int, char **);
void usage_backup(void);
/* pkg check */
int exec_check(int, char **);
void usage_check(void);
/* pkg clean */
int exec_clean(int, char **);
void usage_clean(void);
/* pkg create */
int exec_create(int, char **);
void usage_create(void);
/* pkg delete */
void usage_delete(void);
int exec_delete(int, char **);
/* pkg info */
int exec_info(int, char **);
void usage_info(void);
/* pkg install */
int exec_install(int, char **);
void usage_install(void);
/* pkg plugins */
int exec_plugins(int, char **);
void usage_plugins(void);
/* pkg lock */
int exec_lock(int, char **);
int exec_unlock(int, char **);
void usage_lock(void);
/* pkg query */
int exec_query(int, char **);
void usage_query(void);
/* pkg register */
void usage_register(void);
int exec_register(int argc, char **argv);
/* pkg repo */
int exec_repo(int, char **);
void usage_repo(void);
/* pkg rquery */
int exec_rquery(int, char **);
void usage_rquery(void);
/* pkg set */
int exec_set(int, char **);
void usage_set(void);
/* pkg search */
int exec_search(int, char **);
void usage_search(void);
/* pkg shlib */
int exec_shlib(int, char **);
void usage_shlib(void);
char *sanitize(char *, const char *, size_t);
/* pkg stats */
#define STATS_LOCAL (1<<0)
#define STATS_REMOTE (1<<1)
int exec_stats(int, char **);
void usage_stats(void);
/* pkg update */
int exec_update(int, char **);
void usage_update(void);
int pkgcli_update(bool);
/* pkg updating */
int exec_updating(int, char **);
void usage_updating(void);
/* pkg upgrade */
int exec_upgrade(int, char **);
void usage_upgrade(void);
/* pkg fetch */
int exec_fetch(int, char **);
void usage_fetch(void);
/* pkg shell */
int exec_shell(int, char **);
void usage_shell(void);
/* pkg version */
#define VERSION_SOURCE_INDEX (1<<0)
#define VERSION_ORIGIN (1<<1)
#define VERSION_QUIET (1<<2)
#define VERSION_VERBOSE (1<<3)
#define VERSION_STATUS (1<<4)
#define VERSION_NOSTATUS (1<<5)
#define VERSION_WITHORIGIN (1<<7)
#define VERSION_TESTVERSION (1<<8)
#define VERSION_TESTPATTERN (1<<9)
#define VERSION_SOURCE_PORTS (1<<10)
#define VERSION_SOURCE_REMOTE (1<<11)
int exec_version(int, char **);
void usage_version(void);
/* pkg which */
int exec_which(int, char **);
void usage_which(void);
/* pkg convert */
int exec_convert(int, char **);
void usage_convert(void);
/* pkg ssh */
int exec_ssh(int, char **);
void usage_ssh(void);
/* pkg config */
int exec_config(int, char **);
void usage_config(void);
/* utils */
/* These are the fields of the Full output, in order */
#define INFO_NAME (1LL<<0)
#define INFO_VERSION (1LL<<1)
#define INFO_INSTALLED (1LL<<2)
#define INFO_ORIGIN (1LL<<3)
#define INFO_ARCH (1LL<<4)
#define INFO_PREFIX (1LL<<5)
#define INFO_REPOSITORY (1LL<<6)
#define INFO_CATEGORIES (1LL<<7)
#define INFO_LICENSES (1LL<<8)
#define INFO_MAINTAINER (1LL<<9)
#define INFO_WWW (1LL<<10)
#define INFO_COMMENT (1LL<<11)
#define INFO_OPTIONS (1LL<<12)
#define INFO_SHLIBS_REQUIRED (1LL<<13)
#define INFO_SHLIBS_PROVIDED (1LL<<14)
#define INFO_ANNOTATIONS (1LL<<15)
#define INFO_FLATSIZE (1LL<<16)
#define INFO_PKGSIZE (1LL<<17)
#define INFO_DESCR (1LL<<18)
/* Other fields not part of the Full output */
#define INFO_MESSAGE (1LL<<19)
#define INFO_DEPS (1LL<<20)
#define INFO_RDEPS (1LL<<21)
#define INFO_FILES (1LL<<22)
#define INFO_DIRS (1LL<<23)
#define INFO_USERS (1LL<<24)
#define INFO_GROUPS (1LL<<25)
#define INFO_REPOURL (1LL<<26)
#define INFO_LOCKED (1LL<<27)
#define INFO_OPTION_DEFAULTS (1LL<<28)
#define INFO_OPTION_DESCRIPTIONS (1LL<<29)
#define INFO_LASTFIELD INFO_LOCKED
#define INFO_ALL (((INFO_LASTFIELD) << 1) - 1)
/* Identifying tags */
#define INFO_TAG_NAME (1LL<<60)
#define INFO_TAG_ORIGIN (1LL<<61)
#define INFO_TAG_NAMEVER (1LL<<62)
/* Output YAML format */
#define INFO_RAW (-1LL<<63)
/* Everything in the 'full' package output */
#define INFO_FULL (INFO_NAME|INFO_VERSION|INFO_INSTALLED|INFO_ORIGIN| \
INFO_ARCH|INFO_PREFIX|INFO_REPOSITORY| \
INFO_CATEGORIES|INFO_LICENSES|INFO_MAINTAINER| \
INFO_WWW|INFO_COMMENT|INFO_OPTIONS| \
INFO_SHLIBS_REQUIRED|INFO_SHLIBS_PROVIDED| \
INFO_ANNOTATIONS|INFO_FLATSIZE|INFO_PKGSIZE| \
INFO_DESCR)
/* Everything that can take more than one line to print */
#define INFO_MULTILINE (INFO_OPTIONS|INFO_SHLIBS_REQUIRED| \
INFO_SHLIBS_PROVIDED|INFO_ANNOTATIONS| \
INFO_DESCR|INFO_MESSAGE|INFO_DEPS|INFO_RDEPS| \
INFO_FILES|INFO_DIRS)
bool query_yesno(const char *msg, ...);
bool query_tty_yesno(const char *msg, ...);
int info_flags(uint64_t opt, bool remote);
void print_info(struct pkg * const pkg, uint64_t opt);
char *absolutepath(const char *src, char *dest, size_t dest_len);
void print_jobs_summary(struct pkg_jobs *j, const char *msg, ...);
struct sbuf *exec_buf(const char *cmd);
int hash_file(const char *, char[SHA256_DIGEST_LENGTH * 2 +1]);
int event_callback(void *data, struct pkg_event *ev);
extern struct sbuf *messages;
/* pkg-query / pkg-rquery */
struct query_flags {
const char flag;
const char *options;
const unsigned multiline;
const int dbflags;
};
void print_query(struct pkg *pkg, char *qstr, char multiline);
int format_sql_condition(const char *str, struct sbuf *sqlcond,
bool for_remote);
int analyse_query_string(char *qstr, struct query_flags *q_flags,
const unsigned int q_flags_len, int *flags,
char *multiline);
#endif