Mailinglist Archive: zypp-commit (171 mails)

< Previous Next >
[zypp-commit] <sat-solver> master : Add ruleinfo_command_string
  • From: Klaus Kämpf <kkaempf@xxxxxxx>
  • Date: Mon, 22 Jun 2009 22:24:56 +0200
  • Message-id: <E1MIq4b-0000nS-77@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit eb35f8919d5468c21f1b49c729603cf9dcd08e71
Author: Klaus Kämpf <kkaempf@xxxxxxx>
Date: Mon Jun 22 22:24:56 2009 +0200

Add ruleinfo_command_string
---
applayer/ruleinfo.c | 31 +++++++++++++++++++++++++++++++
applayer/ruleinfo.h | 1 +
bindings/ruby/tests/decisions.rb | 9 ++++-----
bindings/ruleinfo.i | 7 +++++--
4 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/applayer/ruleinfo.c b/applayer/ruleinfo.c
index 90a9fff..fcf464d 100644
--- a/applayer/ruleinfo.c
+++ b/applayer/ruleinfo.c
@@ -36,6 +36,37 @@ ruleinfo_free( Ruleinfo *ri )
}


+const char *
+ruleinfo_command_string(const Ruleinfo *ri)
+{
+ switch (ri->cmd)
+ {
+#define rulecase(r) case r: return #r; break
+ rulecase(SOLVER_RULE_UNKNOWN);
+ rulecase(SOLVER_RULE_RPM);
+ rulecase(SOLVER_RULE_RPM_NOT_INSTALLABLE);
+ rulecase(SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP);
+ rulecase(SOLVER_RULE_RPM_PACKAGE_REQUIRES);
+ rulecase(SOLVER_RULE_RPM_SELF_CONFLICT);
+ rulecase(SOLVER_RULE_RPM_PACKAGE_CONFLICT);
+ rulecase(SOLVER_RULE_RPM_SAME_NAME);
+ rulecase(SOLVER_RULE_RPM_PACKAGE_OBSOLETES);
+ rulecase(SOLVER_RULE_RPM_IMPLICIT_OBSOLETES);
+ rulecase(SOLVER_RULE_UPDATE);
+ rulecase(SOLVER_RULE_FEATURE);
+ rulecase(SOLVER_RULE_JOB);
+ rulecase(SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP);
+ rulecase(SOLVER_RULE_DISTUPGRADE);
+ rulecase(SOLVER_RULE_INFARCH);
+ rulecase(SOLVER_RULE_LEARNT);
+#undef rulecase
+ default:
+ break;
+ }
+ return "Unknown";
+}
+
+
int
ruleinfo_command(const Ruleinfo *ri)
{
diff --git a/applayer/ruleinfo.h b/applayer/ruleinfo.h
index 69674f7..314eebf 100644
--- a/applayer/ruleinfo.h
+++ b/applayer/ruleinfo.h
@@ -34,6 +34,7 @@ typedef struct _Ruleinfo {
Ruleinfo *ruleinfo_new( const Solver *solver, Id rule );
void ruleinfo_free( Ruleinfo *ri );

+const char *ruleinfo_command_string(const Ruleinfo *ri);
int ruleinfo_command(const Ruleinfo *ri);
XSolvable *ruleinfo_source(const Ruleinfo *ri);
XSolvable *ruleinfo_target(const Ruleinfo *ri);
diff --git a/bindings/ruby/tests/decisions.rb b/bindings/ruby/tests/decisions.rb
index 40d6339..8ad2b83 100644
--- a/bindings/ruby/tests/decisions.rb
+++ b/bindings/ruby/tests/decisions.rb
@@ -44,7 +44,6 @@ class DecisionTest < Test::Unit::TestCase
# installed: A-0.0-0, B-1.0-0, C-2.0-0, D-3.0-0
# C-2.0-0 requires D-3.0-0

-
repo = pool.create_repo( 'test' )
assert repo

@@ -76,13 +75,13 @@ class DecisionTest < Test::Unit::TestCase
i += 1
case d.op
when Satsolver::DECISION_INSTALL
- puts "#{i}: Install #{d.solvable} #{d.ruleinfo}"
+ puts "#{i}: Install #{d.solvable}\n\t#{d.ruleinfo.command_s}:
#{d.ruleinfo}"
when Satsolver::DECISION_REMOVE
- puts "#{i}: Remove #{d.solvable} #{d.ruleinfo}"
+ puts "#{i}: Remove #{d.solvable}\n\t#{d.ruleinfo.command_s}:
#{d.ruleinfo}"
when Satsolver::DECISION_OBSOLETE
- puts "#{i}: Obsolete #{d.solvable} #{d.ruleinfo}"
+ puts "#{i}: Obsolete #{d.solvable}\n\t#{d.ruleinfo.command_s}:
#{d.ruleinfo}"
when Satsolver::DECISION_UPDATE
- puts "#{i}: Update #{d.solvable} #{d.ruleinfo}"
+ puts "#{i}: Update #{d.solvable}\n\t#{d.ruleinfo.command_s}:
#{d.ruleinfo}"
else
puts "#{i}: Decision op #{d.op}"
end
diff --git a/bindings/ruleinfo.i b/bindings/ruleinfo.i
index bc2faf0..b8413af 100644
--- a/bindings/ruleinfo.i
+++ b/bindings/ruleinfo.i
@@ -34,8 +34,11 @@ typedef struct _Ruleinfo {} Ruleinfo;
%constant int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;

int command()
- { return $self->cmd; }
-
+ { return ruleinfo_command($self); }
+
+ const char *command_s()
+ { return ruleinfo_command_string($self); }
+
XSolvable *source()
{ return ruleinfo_source($self); }

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages