diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2006-04-07 10:07:18 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2006-04-07 10:07:18 +0000 |
commit | 11349f671efe63aa68cd5037e40c191135f3881d (patch) | |
tree | e94eb748fab01cc3716a0d8f27f27ce1fba1ad10 | |
parent | 65c5de8cefa0bda0a397610e4e92d536aa959904 (diff) | |
download | perl-URPM-11349f671efe63aa68cd5037e40c191135f3881d.tar perl-URPM-11349f671efe63aa68cd5037e40c191135f3881d.tar.gz perl-URPM-11349f671efe63aa68cd5037e40c191135f3881d.tar.bz2 perl-URPM-11349f671efe63aa68cd5037e40c191135f3881d.tar.xz perl-URPM-11349f671efe63aa68cd5037e40c191135f3881d.zip |
Add function to traverse transactions
-rw-r--r-- | URPM.pm | 5 | ||||
-rw-r--r-- | URPM.xs | 30 |
2 files changed, 35 insertions, 0 deletions
@@ -672,6 +672,11 @@ Recognized options are: They roughly correspond to command-line options to rpm(1). +=item $trans->traverse($callback) + +Executes the specified callback (a code reference) for each package in the +transaction, passing a C<URPM::Package> object as argument the callback. + =back =head2 Macro handling functions @@ -2889,6 +2889,36 @@ Trans_remove(trans, name) OUTPUT: RETVAL +int +Trans_traverse(trans, callback) + URPM::Transaction trans + SV *callback + PREINIT: + rpmdbMatchIterator mi; + Header h; + int c = 0; + CODE: + mi = rpmtsInitIterator(trans->ts, RPMDBI_PACKAGES, NULL, 0); + while ((h = rpmdbNextIterator(mi))) { + if (SvROK(callback)) { + dSP; + URPM__Package pkg = calloc(1, sizeof(struct s_Package)); + pkg->flag = FLAG_ID_INVALID | FLAG_NO_HEADER_FREE; + pkg->h = h; + PUSHMARK(SP); + XPUSHs(sv_2mortal(sv_setref_pv(newSVpv("", 0), "URPM::Package", pkg))); + PUTBACK; + call_sv(callback, G_DISCARD | G_SCALAR); + SPAGAIN; + pkg->h = 0; /* avoid using it anymore, in case it has been copied inside callback */ + } + ++c; + } + rpmdbFreeIterator(mi); + RETVAL = c; + OUTPUT: + RETVAL + void Trans_check(trans, ...) URPM::Transaction trans |