Open SCAP Library
rpm-helper.h
1 /*
2  * Copyright 2016 Red Hat Inc., Durham, North Carolina.
3  * All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  */
20 #ifndef __RPM_HELPER__
21 #define __RPM_HELPER__
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include <rpm/rpmdb.h>
28 #include <rpm/rpmfi.h>
29 #include <rpm/rpmlib.h>
30 #include <rpm/rpmts.h>
31 #include <rpm/rpmmacro.h>
32 #include <rpm/rpmlog.h>
33 #include <rpm/rpmpgp.h>
34 #include <rpm/header.h>
35 
36 #include <pthread.h>
37 #include "common/util.h"
38 #include "common/debug_priv.h"
39 #include "pthread.h"
40 
42  rpmts rpmts;
43  pthread_mutex_t mutex;
44 };
45 
46 #ifndef HAVE_HEADERFORMAT
47 # define HAVE_LIBRPM44 1 /* hack */
48 # define headerFormat(_h, _fmt, _emsg) headerSprintf((_h),( _fmt), rpmTagTable, rpmHeaderFormats, (_emsg))
49 #endif
50 
51 #ifndef HAVE_RPMFREECRYPTO
52 # define rpmFreeCrypto() while(0)
53 #endif
54 
55 #ifndef HAVE_RPMFREEFILESYSTEMS
56 # define rpmFreeFilesystems() while(0)
57 #endif
58 
59 #define RPM_MUTEX_LOCK(mutex_ptr) \
60  do { \
61  int prev_cancel_state = -1; \
62  if (pthread_mutex_lock(mutex_ptr) != 0) { \
63  dE("Can't lock mutex"); \
64  return (-1); \
65  } \
66  pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &prev_cancel_state); \
67  } while(0)
68 
69 #define RPM_MUTEX_UNLOCK(mutex_ptr) \
70  do { \
71  int prev_cancel_state = -1; \
72  if (pthread_mutex_unlock(mutex_ptr) != 0) { \
73  dE("Can't unlock mutex. Aborting..."); \
74  abort(); \
75  } \
76  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &prev_cancel_state); \
77  } while(0)
78 
79 #ifdef RPM46_FOUND
80 int rpmErrorCb (rpmlogRec rec, rpmlogCallbackData data);
81 #endif
82 
83 // todo: HAVE_RPM412 needs to be set by configure,
84 // although fallback solution should have same result
85 #ifdef HAVE_RPM412
86 #define DISABLE_PLUGINS(ts) rpmtsSetFlags(ts, RPMTRANS_FLAG_NOPLUGINS)
87 #else
88 #define DISABLE_PLUGINS(ts) rpmDefineMacro(NULL,"__plugindir \"\"", 0);
89 #endif
90 
91 #ifndef HAVE_RPMVERIFYFILE
92 int rpmVerifyFile(const rpmts ts, const rpmfi fi,
93  rpmVerifyAttrs * res, rpmVerifyAttrs omitMask);
94 #endif
95 
100 void rpmLibsPreload(void);
101 
102 #endif
oscap debug helpers private header
Definition: rpm-helper.h:41