1 /* 2 * handle.h 3 * 4 * Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@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 30 #ifdef HAVE_LIBCURL 31 #include <curl/curl.h> 32 #endif 33 34 #define EVENT(h, e) \ 35 do { \ 36 if((h)->eventcb) { \ 37 (h)->eventcb((alpm_event_t *) (e)); \ 38 } \ 39 } while(0) 40 #define QUESTION(h, q) \ 41 do { \ 42 if((h)->questioncb) { \ 43 (h)->questioncb((alpm_question_t *) (q)); \ 44 } \ 45 } while(0) 46 #define PROGRESS(h, e, p, per, n, r) \ 47 do { \ 48 if((h)->progresscb) { \ 49 (h)->progresscb(e, p, per, n, r); \ 50 } \ 51 } while(0) 52 53 struct __alpm_handle_t { 54 /* internal usage */ 55 alpm_db_t *db_local; /* local db pointer */ 56 alpm_list_t *dbs_sync; /* List of (alpm_db_t *) */ 57 FILE *logstream; /* log file stream pointer */ 58 alpm_trans_t *trans; 59 60 #ifdef HAVE_LIBCURL 61 /* libcurl handle */ 62 CURL *curl; /* reusable curl_easy handle */ 63 unsigned short disable_dl_timeout; 64 #endif 65 66 #ifdef HAVE_LIBGPGME 67 alpm_list_t *known_keys; /* keys verified to be in our keychain */ 68 #endif 69 70 /* callback functions */ 71 alpm_cb_log logcb; /* Log callback function */ 72 alpm_cb_download dlcb; /* Download callback function */ 73 alpm_cb_totaldl totaldlcb; /* Total download callback function */ 74 alpm_cb_fetch fetchcb; /* Download file callback function */ 75 alpm_cb_event eventcb; 76 alpm_cb_question questioncb; 77 alpm_cb_progress progresscb; 78 79 /* filesystem paths */ 80 char *root; /* Root path, default '/' */ 81 char *dbpath; /* Base path to pacman's DBs */ 82 char *logfile; /* Name of the log file */ 83 char *lockfile; /* Name of the lock file */ 84 char *gpgdir; /* Directory where GnuPG files are stored */ 85 alpm_list_t *cachedirs; /* Paths to pacman cache directories */ 86 alpm_list_t *hookdirs; /* Paths to hook directories */ 87 alpm_list_t *overwrite_files; /* Paths that may be overwritten */ 88 89 /* package lists */ 90 alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */ 91 alpm_list_t *noextract; /* List of files NOT to extract */ 92 alpm_list_t *ignorepkg; /* List of packages to ignore */ 93 alpm_list_t *ignoregroup; /* List of groups to ignore */ 94 alpm_list_t *assumeinstalled; /* List of virtual packages used to satisfy dependencies */ 95 96 /* options */ 97 char *arch; /* Architecture of packages we should allow */ 98 double deltaratio; /* Download deltas if possible; a ratio value */ 99 int usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */ 100 int checkspace; /* Check disk space before installing */ 101 char *dbext; /* Sync DB extension */ 102 int siglevel; /* Default signature verification level */ 103 int localfilesiglevel; /* Signature verification level for local file 104 upgrade operations */ 105 int remotefilesiglevel; /* Signature verification level for remote file 106 upgrade operations */ 107 108 /* error code */ 109 alpm_errno_t pm_errno; 110 111 /* lock file descriptor */ 112 int lockfd; 113 114 /* for delta parsing efficiency */ 115 int delta_regex_compiled; 116 regex_t delta_regex; 117 }; 118 119 alpm_handle_t *_alpm_handle_new(void); 120 void _alpm_handle_free(alpm_handle_t *handle); 121 122 int _alpm_handle_lock(alpm_handle_t *handle); 123 int _alpm_handle_unlock(alpm_handle_t *handle); 124 125 alpm_errno_t _alpm_set_directory_option(const char *value, 126 char **storage, int must_exist); 127 128 #endif /* ALPM_HANDLE_H */ 129