diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-26 12:33:26 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-26 12:33:26 +0200 |
commit | 7bf3bf2eb83ce317283ccf8ab3e7a784238a8aeb (patch) | |
tree | dc52cea5ea98e5c9281a228f30982a723eef2f0e | |
parent | e68f779b9e8719978b164968fdfdc7c54a0c15b3 (diff) | |
download | abrt-7bf3bf2eb83ce317283ccf8ab3e7a784238a8aeb.tar.gz abrt-7bf3bf2eb83ce317283ccf8ab3e7a784238a8aeb.tar.xz abrt-7bf3bf2eb83ce317283ccf8ab3e7a784238a8aeb.zip |
class CRPM: make a few functions nono-members
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | src/Daemon/MiddleWare.cpp | 8 | ||||
-rw-r--r-- | src/Daemon/RPM.cpp | 33 | ||||
-rw-r--r-- | src/Daemon/RPM.h | 70 |
3 files changed, 55 insertions, 56 deletions
diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index 57f5892a..58ac10e9 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -439,7 +439,7 @@ static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecuta } else { - package = s_RPM.GetPackage(pExecutable); + package = GetPackage(pExecutable); packageName = package.substr(0, package.rfind("-", package.rfind("-") - 1)); if (packageName == "" || (s_setBlackList.find(packageName) != s_setBlackList.end())) @@ -459,7 +459,7 @@ static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecuta error_msg("package isn't signed with proper key"); return MW_GPG_ERROR; } - if (!s_RPM.CheckHash(packageName, pExecutable)) + if (!CheckHash(packageName, pExecutable)) { error_msg("executable has bad hash"); return MW_GPG_ERROR; @@ -467,8 +467,8 @@ static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecuta } } - std::string description = s_RPM.GetDescription(packageName); - std::string component = s_RPM.GetComponent(pExecutable); + std::string description = GetDescription(packageName); + std::string component = GetComponent(pExecutable); CDebugDump dd; try diff --git a/src/Daemon/RPM.cpp b/src/Daemon/RPM.cpp index 6659457f..d2451ada 100644 --- a/src/Daemon/RPM.cpp +++ b/src/Daemon/RPM.cpp @@ -39,9 +39,9 @@ bool CRPM::CheckFingerprint(const std::string& pPackage) bool ret = false; rpmts ts = rpmtsCreate(); rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pPackage.c_str(), 0); - Header header; + Header header = rpmdbNextIterator(iter); - if ((header = rpmdbNextIterator(iter)) != NULL) + if (header != NULL) { rpmTag rpmTags[] = { RPMTAG_DSAHEADER, RPMTAG_RSAHEADER, RPMTAG_SHA1HEADER }; int ii; @@ -80,13 +80,13 @@ bool CRPM::CheckFingerprint(const std::string& pPackage) return ret; } -bool CRPM::CheckHash(const std::string& pPackage, const std::string& pPath) +bool CheckHash(const std::string& pPackage, const std::string& pPath) { bool ret = false; rpmts ts = rpmtsCreate(); rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pPackage.c_str(), 0); - Header header; - if ((header = rpmdbNextIterator(iter)) != NULL) + Header header = rpmdbNextIterator(iter); + if (header != NULL) { rpmfi fi = rpmfiNew(ts, header, RPMTAG_BASENAMES, RPMFI_NOHEADER); pgpHashAlgo hashAlgo; @@ -114,13 +114,13 @@ bool CRPM::CheckHash(const std::string& pPackage, const std::string& pPath) return ret; } -std::string CRPM::GetDescription(const std::string& pPackage) +std::string GetDescription(const std::string& pPackage) { std::string pDescription = ""; rpmts ts = rpmtsCreate(); rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pPackage.c_str(), 0); - Header header; - if ((header = rpmdbNextIterator(iter)) != NULL) + Header header = rpmdbNextIterator(iter); + if (header != NULL) { rpmtd td = rpmtdNew(); headerGet(header, RPMTAG_SUMMARY, td, HEADERGET_DEFAULT); @@ -129,19 +129,19 @@ std::string CRPM::GetDescription(const std::string& pPackage) const char* description = rpmtdGetString(td); pDescription = summary + std::string("\n\n") + description; rpmtdFree(td); - } rpmdbFreeIterator(iter); rpmtsFree(ts); return pDescription; } -std::string CRPM::GetComponent(const std::string& pFileName) + +std::string GetComponent(const std::string& pFileName) { std::string ret = ""; rpmts ts = rpmtsCreate(); rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_BASENAMES, pFileName.c_str(), 0); - Header header; - if ((header = rpmdbNextIterator(iter)) != NULL) + Header header = rpmdbNextIterator(iter); + if (header != NULL) { rpmtd td = rpmtdNew(); headerGet(header,RPMTAG_SOURCERPM, td, HEADERGET_DEFAULT); @@ -149,7 +149,7 @@ std::string CRPM::GetComponent(const std::string& pFileName) if (srpm != NULL) { std::string srcrpm(srpm); - ret = srcrpm.erase(srcrpm.rfind('-',srcrpm.rfind('-')-1)); + ret = srcrpm.erase(srcrpm.rfind('-', srcrpm.rfind('-')-1)); } rpmtdFree(td); } @@ -158,13 +158,14 @@ std::string CRPM::GetComponent(const std::string& pFileName) rpmtsFree(ts); return ret; } -std::string CRPM::GetPackage(const std::string& pFileName) + +std::string GetPackage(const std::string& pFileName) { std::string ret = ""; rpmts ts = rpmtsCreate(); rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_BASENAMES, pFileName.c_str(), 0); - Header header; - if ((header = rpmdbNextIterator(iter)) != NULL) + Header header = rpmdbNextIterator(iter); + if (header != NULL) { char* nerv = headerGetNEVR(header, NULL); if (nerv != NULL) diff --git a/src/Daemon/RPM.h b/src/Daemon/RPM.h index 4fe1eab4..1be0eb11 100644 --- a/src/Daemon/RPM.h +++ b/src/Daemon/RPM.h @@ -1,5 +1,5 @@ /* - RPMInfo.h - header file for rpm database + RPM.h - header file for rpm database - it implements query for local rpm database Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) @@ -20,8 +20,8 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef RPMINFO_H_ -#define RPMINFO_H_ +#ifndef RPM_H_ +#define RPM_H_ #include "MiddleWareTypes.h" @@ -36,9 +36,6 @@ class CRPM { private: - - typedef set_strings_t set_fingerprints_t; - /** * A context for librpm library. */ @@ -46,7 +43,7 @@ class CRPM /** * A set, which contains finger prints. */ - set_fingerprints_t m_setFingerprints; + set_strings_t m_setFingerprints; public: /** @@ -67,34 +64,35 @@ class CRPM * @param pPackage A package name. */ bool CheckFingerprint(const std::string& pPackage); - /** - * A method, which checks if an application is modified by thir party. - * @param pPackage A package name. The package contains the application. - * @param pPath A path to the application. - */ - bool CheckHash(const std::string& pPackage, const std::string& pPath); - /** - * A method, which gets a package description. - * @param pPackage A package name. - * @return A package description. - */ - std::string GetDescription(const std::string& pPackage); - /** - * A method, which gets a package name. This package contains particular - * file. If the file doesn't belong to any package, empty string is - * returned. - * @param pFileName A file name. - * @return A package name. - */ - std::string GetPackage(const std::string& pFileName); - /** - * A method to find a main package for given file. This package contains particular - * file. If the file doesn't belong to any package, empty string is - * returned. - * @param pFileName A file name. - * @return A package name. - */ - std::string GetComponent(const std::string& pFileName); }; -#endif /* RPMINFO_H_ */ +/** + * Checks if an application is modified by third party. + * @param pPackage A package name. The package contains the application. + * @param pPath A path to the application. + */ +bool CheckHash(const std::string& pPackage, const std::string& pPath); +/** + * Gets a package description. + * @param pPackage A package name. + * @return A package description. + */ +std::string GetDescription(const std::string& pPackage); +/** + * Gets a package name. This package contains particular + * file. If the file doesn't belong to any package, empty string is + * returned. + * @param pFileName A file name. + * @return A package name. + */ +std::string GetPackage(const std::string& pFileName); +/** + * Finds a main package for given file. This package contains particular + * file. If the file doesn't belong to any package, empty string is + * returned. + * @param pFileName A file name. + * @return A package name. + */ +std::string GetComponent(const std::string& pFileName); + +#endif |