xref: /minix3/external/bsd/pkg_install/dist/lib/lib.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /* $NetBSD: lib.h,v 1.7 2014/01/07 02:15:27 joerg Exp $ */
2a824f5a1SJean-Baptiste Boric 
3a824f5a1SJean-Baptiste Boric /* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
4a824f5a1SJean-Baptiste Boric 
5a824f5a1SJean-Baptiste Boric /*
6a824f5a1SJean-Baptiste Boric  * FreeBSD install - a package for the installation and maintainance
7a824f5a1SJean-Baptiste Boric  * of non-core utilities.
8a824f5a1SJean-Baptiste Boric  *
9a824f5a1SJean-Baptiste Boric  * Redistribution and use in source and binary forms, with or without
10a824f5a1SJean-Baptiste Boric  * modification, are permitted provided that the following conditions
11a824f5a1SJean-Baptiste Boric  * are met:
12a824f5a1SJean-Baptiste Boric  * 1. Redistributions of source code must retain the above copyright
13a824f5a1SJean-Baptiste Boric  *    notice, this list of conditions and the following disclaimer.
14a824f5a1SJean-Baptiste Boric  * 2. Redistributions in binary form must reproduce the above copyright
15a824f5a1SJean-Baptiste Boric  *    notice, this list of conditions and the following disclaimer in the
16a824f5a1SJean-Baptiste Boric  *    documentation and/or other materials provided with the distribution.
17a824f5a1SJean-Baptiste Boric  *
18a824f5a1SJean-Baptiste Boric  * Jordan K. Hubbard
19a824f5a1SJean-Baptiste Boric  * 18 July 1993
20a824f5a1SJean-Baptiste Boric  *
21a824f5a1SJean-Baptiste Boric  * Include and define various things wanted by the library routines.
22a824f5a1SJean-Baptiste Boric  *
23a824f5a1SJean-Baptiste Boric  */
24a824f5a1SJean-Baptiste Boric 
25a824f5a1SJean-Baptiste Boric #ifndef _INST_LIB_LIB_H_
26a824f5a1SJean-Baptiste Boric #define _INST_LIB_LIB_H_
27a824f5a1SJean-Baptiste Boric 
28a824f5a1SJean-Baptiste Boric #if HAVE_CONFIG_H
29a824f5a1SJean-Baptiste Boric #include "config.h"
30a824f5a1SJean-Baptiste Boric #endif
31a824f5a1SJean-Baptiste Boric #include <nbcompat.h>
32a824f5a1SJean-Baptiste Boric #if HAVE_SYS_PARAM_H
33a824f5a1SJean-Baptiste Boric #include <sys/param.h>
34a824f5a1SJean-Baptiste Boric #endif
35a824f5a1SJean-Baptiste Boric #if HAVE_SYS_STAT_H
36a824f5a1SJean-Baptiste Boric #include <sys/stat.h>
37a824f5a1SJean-Baptiste Boric #endif
38a824f5a1SJean-Baptiste Boric #if HAVE_SYS_FILE_H
39a824f5a1SJean-Baptiste Boric #include <sys/file.h>
40a824f5a1SJean-Baptiste Boric #endif
41a824f5a1SJean-Baptiste Boric #if HAVE_SYS_QUEUE_H
42a824f5a1SJean-Baptiste Boric #include <sys/queue.h>
43a824f5a1SJean-Baptiste Boric #endif
44a824f5a1SJean-Baptiste Boric 
45a824f5a1SJean-Baptiste Boric #if HAVE_CTYPE_H
46a824f5a1SJean-Baptiste Boric #include <ctype.h>
47a824f5a1SJean-Baptiste Boric #endif
48a824f5a1SJean-Baptiste Boric #if HAVE_DIRENT_H
49a824f5a1SJean-Baptiste Boric #include <dirent.h>
50a824f5a1SJean-Baptiste Boric #endif
51a824f5a1SJean-Baptiste Boric #if HAVE_STDIO_H
52a824f5a1SJean-Baptiste Boric #include <stdio.h>
53a824f5a1SJean-Baptiste Boric #endif
54a824f5a1SJean-Baptiste Boric #if HAVE_STDLIB_H
55a824f5a1SJean-Baptiste Boric #include <stdlib.h>
56a824f5a1SJean-Baptiste Boric #endif
57a824f5a1SJean-Baptiste Boric #if HAVE_STDARG_H
58a824f5a1SJean-Baptiste Boric #include <stdarg.h>
59a824f5a1SJean-Baptiste Boric #endif
60a824f5a1SJean-Baptiste Boric #if HAVE_STRING_H
61a824f5a1SJean-Baptiste Boric #include <string.h>
62a824f5a1SJean-Baptiste Boric #endif
63a824f5a1SJean-Baptiste Boric #if HAVE_UNISTD_H
64a824f5a1SJean-Baptiste Boric #include <unistd.h>
65a824f5a1SJean-Baptiste Boric #endif
66a824f5a1SJean-Baptiste Boric 
67a824f5a1SJean-Baptiste Boric /* Macros */
68a824f5a1SJean-Baptiste Boric #ifndef __UNCONST
69a824f5a1SJean-Baptiste Boric #define __UNCONST(a)	((void *)(unsigned long)(const void *)(a))
70a824f5a1SJean-Baptiste Boric #endif
71a824f5a1SJean-Baptiste Boric 
72a824f5a1SJean-Baptiste Boric #define SUCCESS	(0)
73a824f5a1SJean-Baptiste Boric #define	FAIL	(-1)
74a824f5a1SJean-Baptiste Boric 
75a824f5a1SJean-Baptiste Boric #ifndef TRUE
76a824f5a1SJean-Baptiste Boric #define TRUE	(1)
77a824f5a1SJean-Baptiste Boric #endif
78a824f5a1SJean-Baptiste Boric 
79a824f5a1SJean-Baptiste Boric #ifndef FALSE
80a824f5a1SJean-Baptiste Boric #define FALSE	(0)
81a824f5a1SJean-Baptiste Boric #endif
82a824f5a1SJean-Baptiste Boric 
83a824f5a1SJean-Baptiste Boric #ifndef OPSYS_NAME
84a824f5a1SJean-Baptiste Boric #define OPSYS_NAME "NetBSD"
85a824f5a1SJean-Baptiste Boric #endif
86a824f5a1SJean-Baptiste Boric 
87a824f5a1SJean-Baptiste Boric #ifndef DEF_UMASK
88a824f5a1SJean-Baptiste Boric #define DEF_UMASK 022
89a824f5a1SJean-Baptiste Boric #endif
90a824f5a1SJean-Baptiste Boric 
91a824f5a1SJean-Baptiste Boric #ifndef	PATH_MAX
92a824f5a1SJean-Baptiste Boric #  ifdef MAXPATHLEN
93a824f5a1SJean-Baptiste Boric #    define PATH_MAX	MAXPATHLEN
94a824f5a1SJean-Baptiste Boric #  else
95a824f5a1SJean-Baptiste Boric #    define PATH_MAX	1024
96a824f5a1SJean-Baptiste Boric #  endif
97a824f5a1SJean-Baptiste Boric #endif
98a824f5a1SJean-Baptiste Boric 
99a824f5a1SJean-Baptiste Boric enum {
100a824f5a1SJean-Baptiste Boric 	MaxPathSize = PATH_MAX
101a824f5a1SJean-Baptiste Boric };
102a824f5a1SJean-Baptiste Boric 
103a824f5a1SJean-Baptiste Boric /* The names of our "special" files */
104a824f5a1SJean-Baptiste Boric #define CONTENTS_FNAME		"+CONTENTS"
105a824f5a1SJean-Baptiste Boric #define COMMENT_FNAME		"+COMMENT"
106a824f5a1SJean-Baptiste Boric #define DESC_FNAME		"+DESC"
107a824f5a1SJean-Baptiste Boric #define INSTALL_FNAME		"+INSTALL"
108a824f5a1SJean-Baptiste Boric #define DEINSTALL_FNAME		"+DEINSTALL"
109a824f5a1SJean-Baptiste Boric #define REQUIRED_BY_FNAME	"+REQUIRED_BY"
110a824f5a1SJean-Baptiste Boric #define REQUIRED_BY_FNAME_TMP	"+REQUIRED_BY.tmp"
111a824f5a1SJean-Baptiste Boric #define DISPLAY_FNAME		"+DISPLAY"
112a824f5a1SJean-Baptiste Boric #define MTREE_FNAME		"+MTREE_DIRS"
113a824f5a1SJean-Baptiste Boric #define BUILD_VERSION_FNAME	"+BUILD_VERSION"
114a824f5a1SJean-Baptiste Boric #define BUILD_INFO_FNAME	"+BUILD_INFO"
115a824f5a1SJean-Baptiste Boric #define INSTALLED_INFO_FNAME	"+INSTALLED_INFO"
116a824f5a1SJean-Baptiste Boric #define SIZE_PKG_FNAME		"+SIZE_PKG"
117a824f5a1SJean-Baptiste Boric #define SIZE_ALL_FNAME		"+SIZE_ALL"
118a824f5a1SJean-Baptiste Boric #define PRESERVE_FNAME		"+PRESERVE"
119a824f5a1SJean-Baptiste Boric #define VIEWS_FNAME		"+VIEWS"
120a824f5a1SJean-Baptiste Boric #define VIEWS_FNAME_TMP		"+VIEWS.tmp"
121a824f5a1SJean-Baptiste Boric #define DEPOT_FNAME		"+DEPOT"
122a824f5a1SJean-Baptiste Boric 
123a824f5a1SJean-Baptiste Boric /* The names of special variables */
124a824f5a1SJean-Baptiste Boric #define AUTOMATIC_VARNAME	"automatic"
125a824f5a1SJean-Baptiste Boric 
126a824f5a1SJean-Baptiste Boric /* Prefix for extended PLIST cmd */
127a824f5a1SJean-Baptiste Boric #define CMD_CHAR		'@'
128a824f5a1SJean-Baptiste Boric 
129a824f5a1SJean-Baptiste Boric /* The name of the "prefix" environment variable given to scripts */
130a824f5a1SJean-Baptiste Boric #define PKG_PREFIX_VNAME	"PKG_PREFIX"
131a824f5a1SJean-Baptiste Boric 
132a824f5a1SJean-Baptiste Boric /* The name of the "destdir" environment variable given to scripts */
133a824f5a1SJean-Baptiste Boric #define PKG_DESTDIR_VNAME	"PKG_DESTDIR"
134a824f5a1SJean-Baptiste Boric 
135a824f5a1SJean-Baptiste Boric /*
136a824f5a1SJean-Baptiste Boric  * The name of the "metadatadir" environment variable given to scripts.
137a824f5a1SJean-Baptiste Boric  * This variable holds the location of the +-files for this package.
138a824f5a1SJean-Baptiste Boric  */
139a824f5a1SJean-Baptiste Boric #define PKG_METADATA_DIR_VNAME	"PKG_METADATA_DIR"
140a824f5a1SJean-Baptiste Boric 
141a824f5a1SJean-Baptiste Boric /*
142a824f5a1SJean-Baptiste Boric  * The name of the environment variable holding the location to the
143a824f5a1SJean-Baptiste Boric  * reference-counts database directory.
144a824f5a1SJean-Baptiste Boric  */
145a824f5a1SJean-Baptiste Boric #define PKG_REFCOUNT_DBDIR_VNAME	"PKG_REFCOUNT_DBDIR"
146a824f5a1SJean-Baptiste Boric 
147a824f5a1SJean-Baptiste Boric #define	PKG_PATTERN_MAX	MaxPathSize	/* max length of pattern, including nul */
148a824f5a1SJean-Baptiste Boric #define	PKG_SUFFIX_MAX	10	/* max length of suffix, including nul */
149a824f5a1SJean-Baptiste Boric 
150a824f5a1SJean-Baptiste Boric enum {
151a824f5a1SJean-Baptiste Boric 	ReadWrite,
152a824f5a1SJean-Baptiste Boric 	ReadOnly
153a824f5a1SJean-Baptiste Boric };
154a824f5a1SJean-Baptiste Boric 
155a824f5a1SJean-Baptiste Boric 
156a824f5a1SJean-Baptiste Boric /* Enumerated constants for plist entry types */
157a824f5a1SJean-Baptiste Boric typedef enum pl_ent_t {
158a824f5a1SJean-Baptiste Boric 	PLIST_SHOW_ALL = -1,
159a824f5a1SJean-Baptiste Boric 	PLIST_FILE,		/*  0 */
160a824f5a1SJean-Baptiste Boric 	PLIST_CWD,		/*  1 */
161a824f5a1SJean-Baptiste Boric 	PLIST_CMD,		/*  2 */
162a824f5a1SJean-Baptiste Boric 	PLIST_CHMOD,		/*  3 */
163a824f5a1SJean-Baptiste Boric 	PLIST_CHOWN,		/*  4 */
164a824f5a1SJean-Baptiste Boric 	PLIST_CHGRP,		/*  5 */
165a824f5a1SJean-Baptiste Boric 	PLIST_COMMENT,		/*  6 */
166a824f5a1SJean-Baptiste Boric 	PLIST_IGNORE,		/*  7 */
167a824f5a1SJean-Baptiste Boric 	PLIST_NAME,		/*  8 */
168a824f5a1SJean-Baptiste Boric 	PLIST_UNEXEC,		/*  9 */
169a824f5a1SJean-Baptiste Boric 	PLIST_SRC,		/* 10 */
170a824f5a1SJean-Baptiste Boric 	PLIST_DISPLAY,		/* 11 */
171a824f5a1SJean-Baptiste Boric 	PLIST_PKGDEP,		/* 12 */
172a824f5a1SJean-Baptiste Boric 	PLIST_DIR_RM,		/* 13 */
173a824f5a1SJean-Baptiste Boric 	PLIST_OPTION,		/* 14 */
174a824f5a1SJean-Baptiste Boric 	PLIST_PKGCFL,		/* 15 */
175a824f5a1SJean-Baptiste Boric 	PLIST_BLDDEP,		/* 16 */
176a824f5a1SJean-Baptiste Boric 	PLIST_PKGDIR		/* 17 */
177a824f5a1SJean-Baptiste Boric }       pl_ent_t;
178a824f5a1SJean-Baptiste Boric 
179a824f5a1SJean-Baptiste Boric /* Enumerated constants for build info */
180a824f5a1SJean-Baptiste Boric typedef enum bi_ent_t {
181a824f5a1SJean-Baptiste Boric 	BI_OPSYS,		/*  0 */
182a824f5a1SJean-Baptiste Boric 	BI_OS_VERSION,		/*  1 */
183a824f5a1SJean-Baptiste Boric 	BI_MACHINE_ARCH,	/*  2 */
184a824f5a1SJean-Baptiste Boric 	BI_IGNORE_RECOMMENDED,	/*  3 */
185a824f5a1SJean-Baptiste Boric 	BI_USE_ABI_DEPENDS,	/*  4 */
186a824f5a1SJean-Baptiste Boric 	BI_LICENSE,		/*  5 */
187a824f5a1SJean-Baptiste Boric 	BI_PKGTOOLS_VERSION,	/*  6 */
188a824f5a1SJean-Baptiste Boric 	BI_ENUM_COUNT		/*  7 */
189a824f5a1SJean-Baptiste Boric }	bi_ent_t;
190a824f5a1SJean-Baptiste Boric 
191a824f5a1SJean-Baptiste Boric /* Types */
192a824f5a1SJean-Baptiste Boric typedef unsigned int Boolean;
193a824f5a1SJean-Baptiste Boric 
194a824f5a1SJean-Baptiste Boric /* This structure describes a packing list entry */
195a824f5a1SJean-Baptiste Boric typedef struct plist_t {
196a824f5a1SJean-Baptiste Boric 	struct plist_t *prev;	/* previous entry */
197a824f5a1SJean-Baptiste Boric 	struct plist_t *next;	/* next entry */
198a824f5a1SJean-Baptiste Boric 	char   *name;		/* name of entry */
199a824f5a1SJean-Baptiste Boric 	Boolean marked;		/* whether entry has been marked */
200a824f5a1SJean-Baptiste Boric 	pl_ent_t type;		/* type of entry */
201a824f5a1SJean-Baptiste Boric }       plist_t;
202a824f5a1SJean-Baptiste Boric 
203a824f5a1SJean-Baptiste Boric /* This structure describes a package's complete packing list */
204a824f5a1SJean-Baptiste Boric typedef struct package_t {
205a824f5a1SJean-Baptiste Boric 	plist_t *head;		/* head of list */
206a824f5a1SJean-Baptiste Boric 	plist_t *tail;		/* tail of list */
207a824f5a1SJean-Baptiste Boric }       package_t;
208a824f5a1SJean-Baptiste Boric 
209a824f5a1SJean-Baptiste Boric #define SYMLINK_HEADER	"Symlink:"
210a824f5a1SJean-Baptiste Boric #define CHECKSUM_HEADER	"MD5:"
211a824f5a1SJean-Baptiste Boric 
212a824f5a1SJean-Baptiste Boric enum {
213a824f5a1SJean-Baptiste Boric 	ChecksumHeaderLen = 4,	/* strlen(CHECKSUM_HEADER) */
214a824f5a1SJean-Baptiste Boric 	SymlinkHeaderLen = 8,	/* strlen(SYMLINK_HEADER) */
215a824f5a1SJean-Baptiste Boric 	ChecksumLen = 16,
216a824f5a1SJean-Baptiste Boric 	LegibleChecksumLen = 33
217a824f5a1SJean-Baptiste Boric };
218a824f5a1SJean-Baptiste Boric 
219a824f5a1SJean-Baptiste Boric /* List of files */
220a824f5a1SJean-Baptiste Boric typedef struct _lfile_t {
221a824f5a1SJean-Baptiste Boric         TAILQ_ENTRY(_lfile_t) lf_link;
222a824f5a1SJean-Baptiste Boric         char *lf_name;
223a824f5a1SJean-Baptiste Boric } lfile_t;
224a824f5a1SJean-Baptiste Boric TAILQ_HEAD(_lfile_head_t, _lfile_t);
225a824f5a1SJean-Baptiste Boric typedef struct _lfile_head_t lfile_head_t;
226a824f5a1SJean-Baptiste Boric #define	LFILE_ADD(lfhead,lfp,str) do {		\
227a824f5a1SJean-Baptiste Boric 	lfp = xmalloc(sizeof(lfile_t));		\
228a824f5a1SJean-Baptiste Boric 	lfp->lf_name = str;			\
229a824f5a1SJean-Baptiste Boric 	TAILQ_INSERT_TAIL(lfhead,lfp,lf_link);	\
230a824f5a1SJean-Baptiste Boric 	} while(0)
231a824f5a1SJean-Baptiste Boric 
232a824f5a1SJean-Baptiste Boric /* List of packages */
233a824f5a1SJean-Baptiste Boric typedef struct _lpkg_t {
234a824f5a1SJean-Baptiste Boric 	TAILQ_ENTRY(_lpkg_t) lp_link;
235a824f5a1SJean-Baptiste Boric 	char   *lp_name;
236a824f5a1SJean-Baptiste Boric }       lpkg_t;
237a824f5a1SJean-Baptiste Boric TAILQ_HEAD(_lpkg_head_t, _lpkg_t);
238a824f5a1SJean-Baptiste Boric typedef struct _lpkg_head_t lpkg_head_t;
239a824f5a1SJean-Baptiste Boric 
240a824f5a1SJean-Baptiste Boric struct pkg_vulnerabilities {
241a824f5a1SJean-Baptiste Boric 	size_t	entries;
242a824f5a1SJean-Baptiste Boric 	char	**vulnerability;
243a824f5a1SJean-Baptiste Boric 	char	**classification;
244a824f5a1SJean-Baptiste Boric 	char	**advisory;
245a824f5a1SJean-Baptiste Boric };
246a824f5a1SJean-Baptiste Boric 
247a824f5a1SJean-Baptiste Boric /* If URLlength()>0, then there is a ftp:// or http:// in the string,
248a824f5a1SJean-Baptiste Boric  * and this must be an URL. Hide this behind a more obvious name. */
249a824f5a1SJean-Baptiste Boric #define IS_URL(str)	(URLlength(str) > 0)
250a824f5a1SJean-Baptiste Boric 
251a824f5a1SJean-Baptiste Boric #define IS_STDIN(str)	((str) != NULL && !strcmp((str), "-"))
252a824f5a1SJean-Baptiste Boric #define IS_FULLPATH(str)	((str) != NULL && (str)[0] == '/')
253a824f5a1SJean-Baptiste Boric 
254a824f5a1SJean-Baptiste Boric /* Conflict handling (conflicts.c) */
255a824f5a1SJean-Baptiste Boric int	some_installed_package_conflicts_with(const char *, const char *, char **, char **);
256a824f5a1SJean-Baptiste Boric 
257a824f5a1SJean-Baptiste Boric 
258a824f5a1SJean-Baptiste Boric /* Prototypes */
259a824f5a1SJean-Baptiste Boric /* Misc */
260a824f5a1SJean-Baptiste Boric void    show_version(void);
261a824f5a1SJean-Baptiste Boric int	fexec(const char *, ...);
262a824f5a1SJean-Baptiste Boric int	fexec_skipempty(const char *, ...);
263a824f5a1SJean-Baptiste Boric int	fcexec(const char *, const char *, ...);
264a824f5a1SJean-Baptiste Boric int	pfcexec(const char *, const char *, const char **);
265a824f5a1SJean-Baptiste Boric 
266a824f5a1SJean-Baptiste Boric /* variables file handling */
267a824f5a1SJean-Baptiste Boric 
268a824f5a1SJean-Baptiste Boric char   *var_get(const char *, const char *);
269a824f5a1SJean-Baptiste Boric char   *var_get_memory(const char *, const char *);
270a824f5a1SJean-Baptiste Boric int	var_set(const char *, const char *, const char *);
271a824f5a1SJean-Baptiste Boric int     var_copy_list(const char *, const char **);
272a824f5a1SJean-Baptiste Boric 
273a824f5a1SJean-Baptiste Boric /* automatically installed as dependency */
274a824f5a1SJean-Baptiste Boric 
275a824f5a1SJean-Baptiste Boric Boolean	is_automatic_installed(const char *);
276a824f5a1SJean-Baptiste Boric int	mark_as_automatic_installed(const char *, int);
277a824f5a1SJean-Baptiste Boric 
278a824f5a1SJean-Baptiste Boric /* String */
279a824f5a1SJean-Baptiste Boric const char *basename_of(const char *);
280a824f5a1SJean-Baptiste Boric const char *dirname_of(const char *);
281a824f5a1SJean-Baptiste Boric const char *suffix_of(const char *);
282a824f5a1SJean-Baptiste Boric int     pkg_match(const char *, const char *);
283a824f5a1SJean-Baptiste Boric int	pkg_order(const char *, const char *, const char *);
284a824f5a1SJean-Baptiste Boric int     ispkgpattern(const char *);
285a824f5a1SJean-Baptiste Boric int	quick_pkg_match(const char *, const char *);
286a824f5a1SJean-Baptiste Boric 
287a824f5a1SJean-Baptiste Boric /* Iterator functions */
288a824f5a1SJean-Baptiste Boric int	iterate_pkg_generic_src(int (*)(const char *, void *), void *,
289a824f5a1SJean-Baptiste Boric 				const char *(*)(void *),void *);
290a824f5a1SJean-Baptiste Boric int	iterate_local_pkg_dir(const char *, int, int, int (*)(const char *, void *),
291a824f5a1SJean-Baptiste Boric 			      void *);
292a824f5a1SJean-Baptiste Boric int	iterate_pkg_db(int (*)(const char *, void *), void *);
293a824f5a1SJean-Baptiste Boric 
294a824f5a1SJean-Baptiste Boric int	add_installed_pkgs_by_basename(const char *, lpkg_head_t *);
295a824f5a1SJean-Baptiste Boric int	add_installed_pkgs_by_pattern(const char *, lpkg_head_t *);
296a824f5a1SJean-Baptiste Boric char	*find_best_matching_installed_pkg(const char *);
297a824f5a1SJean-Baptiste Boric char	*find_best_matching_file(const char *, const char *, int, int);
298a824f5a1SJean-Baptiste Boric int	match_installed_pkgs(const char *, int (*)(const char *, void *), void *);
299a824f5a1SJean-Baptiste Boric int	match_local_files(const char *, int, int, const char *, int (*cb)(const char *, void *), void *);
300a824f5a1SJean-Baptiste Boric 
301a824f5a1SJean-Baptiste Boric /* File */
302a824f5a1SJean-Baptiste Boric Boolean fexists(const char *);
303a824f5a1SJean-Baptiste Boric Boolean isdir(const char *);
304a824f5a1SJean-Baptiste Boric Boolean islinktodir(const char *);
305a824f5a1SJean-Baptiste Boric Boolean isemptydir(const char *);
306a824f5a1SJean-Baptiste Boric Boolean isemptyfile(const char *);
307a824f5a1SJean-Baptiste Boric Boolean isfile(const char *);
308a824f5a1SJean-Baptiste Boric Boolean isbrokenlink(const char *);
309a824f5a1SJean-Baptiste Boric Boolean isempty(const char *);
310a824f5a1SJean-Baptiste Boric int     URLlength(const char *);
311a824f5a1SJean-Baptiste Boric Boolean make_preserve_name(char *, size_t, const char *, const char *);
312a824f5a1SJean-Baptiste Boric void    remove_files(const char *, const char *);
313a824f5a1SJean-Baptiste Boric int     format_cmd(char *, size_t, const char *, const char *, const char *);
314a824f5a1SJean-Baptiste Boric 
315a824f5a1SJean-Baptiste Boric int	recursive_remove(const char *, int);
316a824f5a1SJean-Baptiste Boric 
317a824f5a1SJean-Baptiste Boric void	add_pkgdir(const char *, const char *, const char *);
318a824f5a1SJean-Baptiste Boric void	delete_pkgdir(const char *, const char *, const char *);
319a824f5a1SJean-Baptiste Boric int	has_pkgdir(const char *);
320a824f5a1SJean-Baptiste Boric 
321a824f5a1SJean-Baptiste Boric /* pkg_io.c: Local and remote archive handling */
322a824f5a1SJean-Baptiste Boric struct archive;
323a824f5a1SJean-Baptiste Boric struct archive_entry;
324a824f5a1SJean-Baptiste Boric 
325a824f5a1SJean-Baptiste Boric struct archive *open_archive(const char *, char **);
326a824f5a1SJean-Baptiste Boric struct archive *find_archive(const char *, int, char **);
327a824f5a1SJean-Baptiste Boric void	process_pkg_path(void);
328a824f5a1SJean-Baptiste Boric struct url *find_best_package(const char *, const char *, int);
329a824f5a1SJean-Baptiste Boric 
330a824f5a1SJean-Baptiste Boric /* Packing list */
331a824f5a1SJean-Baptiste Boric plist_t *new_plist_entry(void);
332a824f5a1SJean-Baptiste Boric plist_t *last_plist(package_t *);
333a824f5a1SJean-Baptiste Boric plist_t *find_plist(package_t *, pl_ent_t);
334a824f5a1SJean-Baptiste Boric char   *find_plist_option(package_t *, const char *);
335a824f5a1SJean-Baptiste Boric void    plist_delete(package_t *, Boolean, pl_ent_t, char *);
336a824f5a1SJean-Baptiste Boric void    free_plist(package_t *);
337a824f5a1SJean-Baptiste Boric void    mark_plist(package_t *);
338a824f5a1SJean-Baptiste Boric void    csum_plist_entry(char *, plist_t *);
339a824f5a1SJean-Baptiste Boric void    add_plist(package_t *, pl_ent_t, const char *);
340a824f5a1SJean-Baptiste Boric void    add_plist_top(package_t *, pl_ent_t, const char *);
341a824f5a1SJean-Baptiste Boric void    delete_plist(package_t *, Boolean, pl_ent_t, char *);
342a824f5a1SJean-Baptiste Boric void    write_plist(package_t *, FILE *, char *);
343a824f5a1SJean-Baptiste Boric void	stringify_plist(package_t *, char **, size_t *, const char *);
344a824f5a1SJean-Baptiste Boric void	parse_plist(package_t *, const char *);
345a824f5a1SJean-Baptiste Boric void    read_plist(package_t *, FILE *);
346a824f5a1SJean-Baptiste Boric void    append_plist(package_t *, FILE *);
347a824f5a1SJean-Baptiste Boric int     delete_package(Boolean, package_t *, Boolean, const char *);
348a824f5a1SJean-Baptiste Boric 
349a824f5a1SJean-Baptiste Boric /* Package Database */
350a824f5a1SJean-Baptiste Boric int     pkgdb_open(int);
351a824f5a1SJean-Baptiste Boric void    pkgdb_close(void);
352a824f5a1SJean-Baptiste Boric int     pkgdb_store(const char *, const char *);
353a824f5a1SJean-Baptiste Boric char   *pkgdb_retrieve(const char *);
354a824f5a1SJean-Baptiste Boric int	pkgdb_dump(void);
355a824f5a1SJean-Baptiste Boric int     pkgdb_remove(const char *);
356a824f5a1SJean-Baptiste Boric int	pkgdb_remove_pkg(const char *);
357a824f5a1SJean-Baptiste Boric char   *pkgdb_refcount_dir(void);
358a824f5a1SJean-Baptiste Boric char   *pkgdb_get_database(void);
359a824f5a1SJean-Baptiste Boric const char   *pkgdb_get_dir(void);
360a824f5a1SJean-Baptiste Boric /*
361a824f5a1SJean-Baptiste Boric  * Priorities:
362a824f5a1SJean-Baptiste Boric  * 0 builtin default
363a824f5a1SJean-Baptiste Boric  * 1 config file
364a824f5a1SJean-Baptiste Boric  * 2 environment
365a824f5a1SJean-Baptiste Boric  * 3 command line
366a824f5a1SJean-Baptiste Boric  * 4 destdir/views reset
367a824f5a1SJean-Baptiste Boric  */
368a824f5a1SJean-Baptiste Boric void	pkgdb_set_dir(const char *, int);
369a824f5a1SJean-Baptiste Boric char   *pkgdb_pkg_dir(const char *);
370a824f5a1SJean-Baptiste Boric char   *pkgdb_pkg_file(const char *, const char *);
371a824f5a1SJean-Baptiste Boric 
372a824f5a1SJean-Baptiste Boric /* List of packages functions */
373a824f5a1SJean-Baptiste Boric lpkg_t *alloc_lpkg(const char *);
374a824f5a1SJean-Baptiste Boric lpkg_t *find_on_queue(lpkg_head_t *, const char *);
375a824f5a1SJean-Baptiste Boric void    free_lpkg(lpkg_t *);
376a824f5a1SJean-Baptiste Boric 
377a824f5a1SJean-Baptiste Boric /* Read pkg_vulnerabilities from file */
378a824f5a1SJean-Baptiste Boric struct pkg_vulnerabilities *read_pkg_vulnerabilities_file(const char *, int, int);
379a824f5a1SJean-Baptiste Boric /* Read pkg_vulnerabilities from memory */
380a824f5a1SJean-Baptiste Boric struct pkg_vulnerabilities *read_pkg_vulnerabilities_memory(void *, size_t, int);
381a824f5a1SJean-Baptiste Boric void free_pkg_vulnerabilities(struct pkg_vulnerabilities *);
382a824f5a1SJean-Baptiste Boric int audit_package(struct pkg_vulnerabilities *, const char *, const char *,
383a824f5a1SJean-Baptiste Boric     int);
384a824f5a1SJean-Baptiste Boric 
385a824f5a1SJean-Baptiste Boric /* Parse configuration file */
386a824f5a1SJean-Baptiste Boric void pkg_install_config(void);
387a824f5a1SJean-Baptiste Boric /* Print configuration variable */
388a824f5a1SJean-Baptiste Boric void pkg_install_show_variable(const char *);
389a824f5a1SJean-Baptiste Boric 
390a824f5a1SJean-Baptiste Boric /* Package signature creation and validation */
391a824f5a1SJean-Baptiste Boric int pkg_verify_signature(const char *, struct archive **, struct archive_entry **, char **);
392a824f5a1SJean-Baptiste Boric int pkg_full_signature_check(const char *, struct archive **);
393a824f5a1SJean-Baptiste Boric #ifdef HAVE_SSL
394a824f5a1SJean-Baptiste Boric void pkg_sign_x509(const char *, const char *, const char *, const char *);
395a824f5a1SJean-Baptiste Boric #endif
396a824f5a1SJean-Baptiste Boric 
397a824f5a1SJean-Baptiste Boric void pkg_sign_gpg(const char *, const char *);
398a824f5a1SJean-Baptiste Boric 
399a824f5a1SJean-Baptiste Boric #ifdef HAVE_SSL
400a824f5a1SJean-Baptiste Boric /* PKCS7 signing/verification */
401a824f5a1SJean-Baptiste Boric int easy_pkcs7_verify(const char *, size_t, const char *, size_t,
402a824f5a1SJean-Baptiste Boric     const char *, int);
403a824f5a1SJean-Baptiste Boric int easy_pkcs7_sign(const char *, size_t, char **, size_t *, const char *,
404a824f5a1SJean-Baptiste Boric     const char *);
405a824f5a1SJean-Baptiste Boric #endif
406a824f5a1SJean-Baptiste Boric 
407a824f5a1SJean-Baptiste Boric int inline_gpg_verify(const char *, size_t, const char *);
408a824f5a1SJean-Baptiste Boric int detached_gpg_verify(const char *, size_t, const char *, size_t,
409a824f5a1SJean-Baptiste Boric     const char *);
410a824f5a1SJean-Baptiste Boric int detached_gpg_sign(const char *, size_t, char **, size_t *, const char *,
411a824f5a1SJean-Baptiste Boric     const char *);
412a824f5a1SJean-Baptiste Boric 
413a824f5a1SJean-Baptiste Boric /* License handling */
414a824f5a1SJean-Baptiste Boric int add_licenses(const char *);
415a824f5a1SJean-Baptiste Boric int acceptable_license(const char *);
416a824f5a1SJean-Baptiste Boric int acceptable_pkg_license(const char *);
417a824f5a1SJean-Baptiste Boric void load_license_lists(void);
418a824f5a1SJean-Baptiste Boric 
419a824f5a1SJean-Baptiste Boric /* Helper functions for memory allocation */
420a824f5a1SJean-Baptiste Boric char *xstrdup(const char *);
421a824f5a1SJean-Baptiste Boric void *xrealloc(void *, size_t);
422a824f5a1SJean-Baptiste Boric void *xcalloc(size_t, size_t);
423a824f5a1SJean-Baptiste Boric void *xmalloc(size_t);
424*0a6a1f1dSLionel Sambuc char *xasprintf(const char *, ...) __printflike(1, 2);
425a824f5a1SJean-Baptiste Boric 
426a824f5a1SJean-Baptiste Boric /* Externs */
427a824f5a1SJean-Baptiste Boric extern Boolean Verbose;
428a824f5a1SJean-Baptiste Boric extern Boolean Fake;
429a824f5a1SJean-Baptiste Boric extern Boolean Force;
430a824f5a1SJean-Baptiste Boric extern const char *cert_chain_file;
431a824f5a1SJean-Baptiste Boric extern const char *certs_packages;
432a824f5a1SJean-Baptiste Boric extern const char *certs_pkg_vulnerabilities;
433a824f5a1SJean-Baptiste Boric extern const char *check_eol;
434a824f5a1SJean-Baptiste Boric extern const char *check_vulnerabilities;
435a824f5a1SJean-Baptiste Boric extern const char *config_file;
436a824f5a1SJean-Baptiste Boric extern const char *config_pkg_dbdir;
437a824f5a1SJean-Baptiste Boric extern const char *config_pkg_path;
438a824f5a1SJean-Baptiste Boric extern const char *config_pkg_refcount_dbdir;
439a824f5a1SJean-Baptiste Boric extern const char *do_license_check;
440a824f5a1SJean-Baptiste Boric extern const char *verified_installation;
441a824f5a1SJean-Baptiste Boric extern const char *gpg_cmd;
442a824f5a1SJean-Baptiste Boric extern const char *gpg_keyring_pkgvuln;
443a824f5a1SJean-Baptiste Boric extern const char *gpg_keyring_sign;
444a824f5a1SJean-Baptiste Boric extern const char *gpg_keyring_verify;
445a824f5a1SJean-Baptiste Boric extern const char *gpg_sign_as;
446a824f5a1SJean-Baptiste Boric extern char fetch_flags[];
447a824f5a1SJean-Baptiste Boric 
448a824f5a1SJean-Baptiste Boric extern const char *pkg_vulnerabilities_dir;
449a824f5a1SJean-Baptiste Boric extern const char *pkg_vulnerabilities_file;
450a824f5a1SJean-Baptiste Boric extern const char *pkg_vulnerabilities_url;
451a824f5a1SJean-Baptiste Boric extern const char *ignore_advisories;
452a824f5a1SJean-Baptiste Boric extern const char tnf_vulnerability_base[];
453a824f5a1SJean-Baptiste Boric 
454a824f5a1SJean-Baptiste Boric extern const char *acceptable_licenses;
455a824f5a1SJean-Baptiste Boric extern const char *default_acceptable_licenses;
456a824f5a1SJean-Baptiste Boric 
457a824f5a1SJean-Baptiste Boric #endif				/* _INST_LIB_LIB_H_ */
458