From c2852b2a0c0aceb36250effc977e6cc30e1de1a0 Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Sun, 4 Nov 2007 10:05:27 +0000 Subject: [PATCH] - decoupling zypper and zypp-checkpatches code --- src/zypp-checkpatches.cc | 7 ++++--- src/zypper-updates.cc | 5 +++-- src/zypper-updates.h | 10 ++++++++++ src/zypper.h | 13 +------------ 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/zypp-checkpatches.cc b/src/zypp-checkpatches.cc index fad7bad..824e722 100644 --- a/src/zypp-checkpatches.cc +++ b/src/zypp-checkpatches.cc @@ -37,6 +37,7 @@ using namespace boost; ZYpp::Ptr God; RuntimeData gData; Settings gSettings; +std::list errors; ostream no_stream(NULL); @@ -89,7 +90,7 @@ namespace utils int exit_with_error( const std::string &error_str ) { - gData.errors.push_back(Error(error_str)); + errors.push_back(Error(error_str)); std::ofstream os(RESULT_FILE); if ( os.good() ) @@ -181,7 +182,7 @@ int main(int argc, char **argv) { // TranslatorExplanation %s = detailed low level (unstranslated) error message string error = excpt_r.msg(); - gData.errors.push_back(str::form(_("Couldn't restore repository.\nDetail: %s"), error.c_str())); + errors.push_back(str::form(_("Couldn't restore repository.\nDetail: %s"), error.c_str())); } } @@ -231,7 +232,7 @@ int main(int argc, char **argv) if ( gData.repos.size() == 0 ) { - gData.errors.push_back( str::form( _( "There are no update repositories defined. Please add one or more update repositories in order to be notified of updates.") ) ); + errors.push_back( str::form( _( "There are no update repositories defined. Please add one or more update repositories in order to be notified of updates.") ) ); } God->addResolvables( God->target()->resolvables(), true); diff --git a/src/zypper-updates.cc b/src/zypper-updates.cc index 17c06b9..bf93d6c 100644 --- a/src/zypper-updates.cc +++ b/src/zypper-updates.cc @@ -25,6 +25,7 @@ using namespace zypp; extern ZYpp::Ptr God; extern RuntimeData gData; extern Settings gSettings; +extern std::list errors; Edition read_old_version() { @@ -59,7 +60,7 @@ void render_error( const Edition &version, std::ostream &out ) out << "" << std::endl; out << "" << std::endl; out << " " << std::endl; - for ( std::list::const_iterator it = gData.errors.begin(); it != gData.errors.end(); ++it ) + for ( std::list::const_iterator it = errors.begin(); it != errors.end(); ++it ) { out << " " << xml_escape(it->description) << "" << endl; } @@ -77,7 +78,7 @@ void render_result( const Edition &version, std::ostream &out, const zypp::ResPo //out << " " << std::endl; out << " " << std::endl; - for ( std::list::const_iterator it = gData.errors.begin(); it != gData.errors.end(); ++it ) + for ( std::list::const_iterator it = errors.begin(); it != errors.end(); ++it ) { out << " " << xml_escape(it->description) << "" << endl; } diff --git a/src/zypper-updates.h b/src/zypper-updates.h index 9f24142..ebe9023 100644 --- a/src/zypper-updates.h +++ b/src/zypper-updates.h @@ -19,6 +19,16 @@ #define XML_FILE_VERSION "/var/lib/zypp/cache/updates_xml_version" #define RESULT_FILE "/var/lib/zypp/cache/updates_result.xml" +struct Error +{ + Error( const std::string &desc ) + : description(desc) + {} + std::string description; +}; + +extern std::list errors; + std::string read_old_token(); void save_token( const std::string &token ); zypp::Edition read_old_version(); diff --git a/src/zypper.h b/src/zypper.h index 6946829..6bd928a 100644 --- a/src/zypper.h +++ b/src/zypper.h @@ -21,7 +21,6 @@ #define ZYPP_CHECKPATCHES_LOG "/var/log/zypper.log" #undef ZYPP_BASE_LOGGER_LOGGROUP #define ZYPP_BASE_LOGGER_LOGGROUP "zypper" -#define RANDOM_TOKEN "sad987432JJDJD948394DDDxxx22" // ===== exit codes ====== @@ -46,7 +45,7 @@ struct Settings { Settings() - : previous_token(RANDOM_TOKEN), + : verbosity(0), previous_code(-1), disable_system_sources(false), @@ -60,7 +59,6 @@ struct Settings {} std::list additional_sources; - std::string previous_token; /** * Level of the amount of output. @@ -86,21 +84,12 @@ struct Settings zypp::RepoManagerOptions rm_options; }; -struct Error -{ - Error( const std::string &desc ) - : description(desc) - {} - std::string description; -}; - struct RuntimeData { RuntimeData() : patches_count(0), security_patches_count(0), show_media_progress_hack(false) {} - std::list errors; std::list repos; int patches_count; int security_patches_count; -- 2.7.4