libalpm
Arch Linux Package Manager Library
handle.h
Go to the documentation of this file.
1/*
2 * handle.h
3 *
4 * Copyright (c) 2006-2024 Pacman Development Team <pacman-dev@lists.archlinux.org>
5 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20#ifndef ALPM_HANDLE_H
21#define ALPM_HANDLE_H
22
23#include <stdio.h>
24#include <sys/types.h>
25#include <regex.h>
26
27#include "alpm_list.h"
28#include "alpm.h"
29#include "trans.h"
30
31#ifdef HAVE_LIBCURL
32#include <curl/curl.h>
33#endif
34
35#define EVENT(h, e) \
36do { \
37 if((h)->eventcb) { \
38 (h)->eventcb((h)->eventcb_ctx, (alpm_event_t *) (e)); \
39 } \
40} while(0)
41#define QUESTION(h, q) \
42do { \
43 if((h)->questioncb) { \
44 (h)->questioncb((h)->questioncb_ctx, (alpm_question_t *) (q)); \
45 } \
46} while(0)
47#define PROGRESS(h, e, p, per, n, r) \
48do { \
49 if((h)->progresscb) { \
50 (h)->progresscb((h)->progresscb_ctx, e, p, per, n, r); \
51 } \
52} while(0)
53
54struct _alpm_handle_t {
55 /* internal usage */
56 alpm_db_t *db_local; /* local db pointer */
57 alpm_list_t *dbs_sync; /* List of (alpm_db_t *) */
58 FILE *logstream; /* log file stream pointer */
59 alpm_trans_t *trans;
60
61#ifdef HAVE_LIBCURL
62 /* libcurl handle */
63 CURLM *curlm;
64 alpm_list_t *server_errors;
65#endif
66
67 unsigned short disable_dl_timeout;
68 unsigned short disable_sandbox;
69 unsigned int parallel_downloads; /* number of download streams */
70
71#ifdef HAVE_LIBGPGME
72 alpm_list_t *known_keys; /* keys verified to be in our keychain */
73#endif
74
75 /* callback functions */
76 alpm_cb_log logcb; /* Log callback function */
77 void *logcb_ctx;
78 alpm_cb_download dlcb; /* Download callback function */
79 void *dlcb_ctx;
80 alpm_cb_fetch fetchcb; /* Download file callback function */
81 void *fetchcb_ctx;
82 alpm_cb_event eventcb;
83 void *eventcb_ctx;
84 alpm_cb_question questioncb;
85 void *questioncb_ctx;
86 alpm_cb_progress progresscb;
87 void *progresscb_ctx;
88
89 /* filesystem paths */
90 char *root; /* Root path, default '/' */
91 char *dbpath; /* Base path to pacman's DBs */
92 char *logfile; /* Name of the log file */
93 char *lockfile; /* Name of the lock file */
94 char *gpgdir; /* Directory where GnuPG files are stored */
95 char *sandboxuser; /* User to switch to for sensitive operations */
96 alpm_list_t *cachedirs; /* Paths to pacman cache directories */
97 alpm_list_t *hookdirs; /* Paths to hook directories */
98 alpm_list_t *overwrite_files; /* Paths that may be overwritten */
99
100 /* package lists */
101 alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
102 alpm_list_t *noextract; /* List of files NOT to extract */
103 alpm_list_t *ignorepkg; /* List of packages to ignore */
104 alpm_list_t *ignoregroup; /* List of groups to ignore */
105 alpm_list_t *assumeinstalled; /* List of virtual packages used to satisfy dependencies */
106
107 /* options */
108 alpm_list_t *architectures; /* Architectures of packages we should allow */
109 int usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */
110 int checkspace; /* Check disk space before installing */
111 char *dbext; /* Sync DB extension */
112 int siglevel; /* Default signature verification level */
113 int localfilesiglevel; /* Signature verification level for local file
114 upgrade operations */
115 int remotefilesiglevel; /* Signature verification level for remote file
116 upgrade operations */
117
118 /* error code */
119 alpm_errno_t pm_errno;
120
121 /* lock file descriptor */
122 int lockfd;
123};
124
125alpm_handle_t *_alpm_handle_new(void);
126void _alpm_handle_free(alpm_handle_t *handle);
127
128int _alpm_handle_lock(alpm_handle_t *handle);
129int _alpm_handle_unlock(alpm_handle_t *handle);
130
131alpm_errno_t _alpm_set_directory_option(const char *value,
132 char **storage, int must_exist);
133
134#endif /* ALPM_HANDLE_H */
void(* alpm_cb_question)(void *ctx, alpm_question_t *question)
Question callback.
Definition alpm.h:1119
int(* alpm_cb_fetch)(void *ctx, const char *url, const char *localpath, int force)
A callback for downloading files.
Definition alpm.h:1229
void(* alpm_cb_event)(void *ctx, alpm_event_t *event)
Event callback.
Definition alpm.h:972
void(* alpm_cb_progress)(void *ctx, alpm_progress_t progress, const char *pkg, int percent, size_t howmany, size_t current)
Progress callback.
Definition alpm.h:1158
void(* alpm_cb_download)(void *ctx, const char *filename, alpm_download_event_type_t event, void *data)
Type of download progress callbacks.
Definition alpm.h:1217
alpm_errno_t
libalpm's error type
Definition alpm.h:205
A doubly linked list.
Definition alpm_list.h:51
void(* alpm_cb_log)(void *ctx, alpm_loglevel_t level, const char *fmt, va_list args)
The callback type for logging.
Definition alpm.h:1516
Definition trans.h:39