|
Open SCAP Library
|
00001 /* 00002 * Copyright 2016 Red Hat Inc., Durham, North Carolina. 00003 * All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 * 00019 */ 00020 #ifndef __RPM_HELPER__ 00021 #define __RPM_HELPER__ 00022 00023 #ifdef HAVE_CONFIG_H 00024 #include <config.h> 00025 #endif 00026 00027 #include <rpm/rpmdb.h> 00028 #include <rpm/rpmfi.h> 00029 #include <rpm/rpmlib.h> 00030 #include <rpm/rpmts.h> 00031 #include <rpm/rpmmacro.h> 00032 #include <rpm/rpmlog.h> 00033 #include <rpm/header.h> 00034 00035 #include <pthread.h> 00036 #include "common/util.h" 00037 #include "common/debug_priv.h" 00038 #include "pthread.h" 00039 00040 struct rpm_probe_global { 00041 rpmts rpmts; 00042 pthread_mutex_t mutex; 00043 }; 00044 00045 #ifndef HAVE_HEADERFORMAT 00046 # define HAVE_LIBRPM44 1 /* hack */ 00047 # define headerFormat(_h, _fmt, _emsg) headerSprintf((_h),( _fmt), rpmTagTable, rpmHeaderFormats, (_emsg)) 00048 #endif 00049 00050 #ifndef HAVE_RPMFREECRYPTO 00051 # define rpmFreeCrypto() while(0) 00052 #endif 00053 00054 #ifndef HAVE_RPMFREEFILESYSTEMS 00055 # define rpmFreeFilesystems() while(0) 00056 #endif 00057 00058 #define RPM_MUTEX_LOCK(mutex_ptr) \ 00059 do { \ 00060 int prev_cancel_state = -1; \ 00061 if (pthread_mutex_lock(mutex_ptr) != 0) { \ 00062 dE("Can't lock mutex"); \ 00063 return (-1); \ 00064 } \ 00065 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &prev_cancel_state); \ 00066 } while(0) 00067 00068 #define RPM_MUTEX_UNLOCK(mutex_ptr) \ 00069 do { \ 00070 int prev_cancel_state = -1; \ 00071 if (pthread_mutex_unlock(mutex_ptr) != 0) { \ 00072 dE("Can't unlock mutex. Aborting..."); \ 00073 abort(); \ 00074 } \ 00075 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &prev_cancel_state); \ 00076 } while(0) 00077 00078 #ifdef HAVE_RPM46 00079 int rpmErrorCb (rpmlogRec rec, rpmlogCallbackData data); 00080 #endif 00081 00082 // todo: HAVE_RPM412 needs to be set by configure, 00083 // although fallback solution should have same result 00084 #ifdef HAVE_RPM412 00085 #define DISABLE_PLUGINS(ts) rpmtsSetFlags(ts, RPMTRANS_FLAG_NOPLUGINS) 00086 #else 00087 #define DISABLE_PLUGINS(ts) rpmDefineMacro(NULL,"__plugindir \"\"", 0); 00088 #endif 00089 00094 void rpmLibsPreload(void); 00095 00096 #endif
1.7.3