Open SCAP Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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/header.h>
34 
35 #include <pthread.h>
36 #include "common/util.h"
37 #include "common/debug_priv.h"
38 #include "pthread.h"
39 
41  rpmts rpmts;
42  pthread_mutex_t mutex;
43 };
44 
45 #ifndef HAVE_HEADERFORMAT
46 # define HAVE_LIBRPM44 1 /* hack */
47 # define headerFormat(_h, _fmt, _emsg) headerSprintf((_h),( _fmt), rpmTagTable, rpmHeaderFormats, (_emsg))
48 #endif
49 
50 #ifndef HAVE_RPMFREECRYPTO
51 # define rpmFreeCrypto() while(0)
52 #endif
53 
54 #ifndef HAVE_RPMFREEFILESYSTEMS
55 # define rpmFreeFilesystems() while(0)
56 #endif
57 
58 #define RPM_MUTEX_LOCK(mutex_ptr) \
59  do { \
60  int prev_cancel_state = -1; \
61  if (pthread_mutex_lock(mutex_ptr) != 0) { \
62  dE("Can't lock mutex"); \
63  return (-1); \
64  } \
65  pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &prev_cancel_state); \
66  } while(0)
67 
68 #define RPM_MUTEX_UNLOCK(mutex_ptr) \
69  do { \
70  int prev_cancel_state = -1; \
71  if (pthread_mutex_unlock(mutex_ptr) != 0) { \
72  dE("Can't unlock mutex. Aborting..."); \
73  abort(); \
74  } \
75  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &prev_cancel_state); \
76  } while(0)
77 
78 #ifdef HAVE_RPM46
79 int rpmErrorCb (rpmlogRec rec, rpmlogCallbackData data);
80 #endif
81 
82 // todo: HAVE_RPM412 needs to be set by configure,
83 // although fallback solution should have same result
84 #ifdef HAVE_RPM412
85 #define DISABLE_PLUGINS(ts) rpmtsSetFlags(ts, RPMTRANS_FLAG_NOPLUGINS)
86 #else
87 #define DISABLE_PLUGINS(ts) rpmDefineMacro(NULL,"__plugindir \"\"", 0);
88 #endif
89 
94 void rpmLibsPreload(void);
95 
96 #endif
Definition: rpm-helper.h:40
oscap debug helpers private header