1 /* 2 * Copyright (C) 2017 Red Hat, Inc. 3 * 4 * Licensed under the GNU Lesser General Public License Version 2.1 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef HY_IUTIL_PRIVATE_HPP 22 #define HY_IUTIL_PRIVATE_HPP 23 24 #include "hy-iutil.h" 25 #include "hy-types.h" 26 #include "sack/packageset.hpp" 27 28 /* crypto utils */ 29 int checksum_cmp(const unsigned char *cs1, const unsigned char *cs2); 30 int checksum_fp(unsigned char *out, FILE *fp); 31 int checksum_read(unsigned char *csout, FILE *fp); 32 int checksum_stat(unsigned char *out, FILE *fp); 33 int checksum_write(const unsigned char *cs, FILE *fp); 34 int checksumt_l2h(int type); 35 const char *pool_checksum_str(Pool *pool, const unsigned char *chksum); 36 37 const char *id2nevra(Pool *pool, Id id); 38 39 /* filesystem utils */ 40 char *abspath(const char *path); 41 int is_readable_rpm(const char *fn); 42 int mkcachedir(char *path); 43 gboolean mv(const char *old_path, const char *new_path, GError **error); 44 gboolean dnf_remove_recursive_v2(const gchar *path, GError **error); 45 gboolean dnf_copy_file(const std::string & srcPath, const std::string & dstPath, GError ** error); 46 gboolean dnf_copy_recursive(const std::string & srcPath, const std::string & dstPath, GError ** error); 47 gboolean dnf_move_recursive(const gchar *src_dir, const gchar *dst_dir, GError **error); 48 char *this_username(void); 49 50 /* misc utils */ 51 char *read_whole_file(const char *path); 52 Id running_kernel(DnfSack *sack); 53 54 /* libsolv utils */ 55 Repo *repo_by_name(DnfSack *sack, const char *name); 56 HyRepo hrepo_by_name(DnfSack *sack, const char *name); 57 Id str2archid(Pool *pool, const char *s); 58 Id what_upgrades(Pool *pool, Id p); 59 Id what_downgrades(Pool *pool, Id p); 60 Map *free_map_fully(Map *m); 61 int is_package(const Pool *pool, const Solvable *s); 62 63 /* package version utils */ 64 unsigned long pool_get_epoch(Pool *pool, const char *evr); 65 void pool_split_evr(Pool *pool, const char *evr, char **epoch, char **version, char **release); 66 67 /* reldep utils */ 68 int parse_reldep_str(const char *nevra, char **name, char **evr, int *cmp_type); 69 GPtrArray * packageSet2GPtrArray(libdnf::PackageSet * pset); 70 71 /* loop over all package providers of d */ 72 #define FOR_PKG_PROVIDES(v, vp, d) \ 73 FOR_PROVIDES(v, vp, d) \ 74 if (!is_package(pool, pool_id2solvable(pool, v))) \ 75 continue; \ 76 else 77 78 /* loop over all package solvables */ 79 #define FOR_PKG_SOLVABLES(p) \ 80 FOR_POOL_SOLVABLES(p) \ 81 if (!is_package(pool, pool_id2solvable(pool, p))) \ 82 continue; \ 83 else 84 85 86 #endif 87