Open SCAP Library: rpm-helper.h Source File

Open SCAP Library

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

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/rpmlib.h>
29 #include <rpm/rpmts.h>
30 #include <rpm/rpmmacro.h>
31 #include <rpm/rpmlog.h>
32 #include <rpm/header.h>
33
34 #include <pthread.h>
35 #include "common/util.h"
36 #include "common/debug_priv.h"
37 #include "pthread.h"
38
39 struct rpm_probe_global {
40 rpmts rpmts;
41 pthread_mutex_t mutex;
42 };
43
44 #ifndef HAVE_HEADERFORMAT
45 # define HAVE_LIBRPM44 1 /* hack */
46 # define headerFormat(_h, _fmt, _emsg) headerSprintf((_h),( _fmt), rpmTagTable, rpmHeaderFormats, (_emsg))
47 #endif
48
49 #ifndef HAVE_RPMFREECRYPTO
50 # define rpmFreeCrypto() while(0)
51 #endif
52
53 #ifndef HAVE_RPMFREEFILESYSTEMS
54 # define rpmFreeFilesystems() while(0)
55 #endif
56
57 #define RPM_MUTEX_LOCK(mutex_ptr) \
58 do { \
59 int prev_cancel_state = -1; \
60 if (pthread_mutex_lock(mutex_ptr) != 0) { \
61 dE("Can't lock mutex"); \
62 return (-1); \
63 } \
64 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &prev_cancel_state); \
65 } while(0)
66
67 #define RPM_MUTEX_UNLOCK(mutex_ptr) \
68 do { \
69 int prev_cancel_state = -1; \
70 if (pthread_mutex_unlock(mutex_ptr) != 0) { \
71 dE("Can't unlock mutex. Aborting..."); \
72 abort(); \
73 } \
74 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &prev_cancel_state); \
75 } while(0)
76
77 int rpmErrorCb (rpmlogRec rec, rpmlogCallbackData data);
78
83 void rpmLibsPreload(void);
84
85 #endif
rpm_probe_global
Definition: rpm-helper.h:39
debug_priv.h
oscap debug helpers private header