RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Olivier Thauvin Root: /v/rpm/cvs Email: [EMAIL PROTECTED] Module: rpm Date: 06-Aug-2007 00:12:36 Branch: HEAD Handle: 2007080523123500 Modified files: rpm/perl Makefile.PL.in Makefile.am RPM.xs rpmxs.c rpmxs.h typemap Log: - return of perl class RPM::PackageIterator Summary: Revision Changes Path 1.11 +10 -1 rpm/perl/Makefile.PL.in 1.14 +1 -0 rpm/perl/Makefile.am 1.18 +1 -0 rpm/perl/RPM.xs 1.2 +35 -0 rpm/perl/rpmxs.c 1.3 +4 -0 rpm/perl/rpmxs.h 1.8 +1 -1 rpm/perl/typemap ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/perl/Makefile.PL.in ============================================================================ $ cvs diff -u -r1.10 -r1.11 Makefile.PL.in --- rpm/perl/Makefile.PL.in 4 Aug 2007 21:25:42 -0000 1.10 +++ rpm/perl/Makefile.PL.in 5 Aug 2007 22:12:35 -0000 1.11 @@ -7,9 +7,18 @@ my @ldaddp = map { '[EMAIL PROTECTED]@/' . $_ . '/.libs' } @libdir; my @ldadd = map { '-l' . $_ } qw(rpmio rpmbuild rpm popt rpmdb rpmconstant); +my @objects = qw( + rpmxs.o + RPM.o + RPM_Constant.o + RPM_Header.o + RPM_Transaction.o + RPM_PackageIterator.o +); + WriteMakefile( 'NAME' => 'RPM', - 'OBJECT' => 'rpmxs.o RPM.o RPM_Ts.o RPM_Header.o RPM_Constant.o', + 'OBJECT' => join(' ', @objects), 'VERSION' => '@VERSION@', 'MAKEFILE'=> 'Makefile.perl', 'LIBS' => [join(' ', @ldaddp) . ' ' . join(' ', @ldadd) . ' @LDFLAGS@ @LIBS@'], @@ . patch -p0 <<'@@ .' Index: rpm/perl/Makefile.am ============================================================================ $ cvs diff -u -r1.13 -r1.14 Makefile.am --- rpm/perl/Makefile.am 5 Aug 2007 12:47:14 -0000 1.13 +++ rpm/perl/Makefile.am 5 Aug 2007 22:12:35 -0000 1.14 @@ -11,6 +11,7 @@ RPM/Constant.pm RPM_Constant.xs t/02.rpmconstant.t \ RPM_Header.xs RPM/Header.pm t/03.header.t \ RPM_Transaction.xs RPM/Transaction.pm t/04.transaction.t \ + RPM_PackageIterator.xs RPM/PackageIterator.pm t/05.packageiterator.t \ t/00.pod.coverage.t t/00.pod.t \ hdlist-test.hdr test-rpm-1.0-1.noarch.rpm test-rpm-1.0-1.src.rpm @@ . patch -p0 <<'@@ .' Index: rpm/perl/RPM.xs ============================================================================ $ cvs diff -u -r1.17 -r1.18 RPM.xs --- rpm/perl/RPM.xs 5 Aug 2007 14:01:44 -0000 1.17 +++ rpm/perl/RPM.xs 5 Aug 2007 22:12:35 -0000 1.18 @@ -48,6 +48,7 @@ crutch_stack_wrap(boot_RPM__Constant(aTHX_ cv)); crutch_stack_wrap(boot_RPM__Header(aTHX_ cv)); crutch_stack_wrap(boot_RPM__Transaction(aTHX_ cv)); + crutch_stack_wrap(boot_RPM__PackageIterator(aTHX_ cv)); #if DYING { HV *header_tags, *constants; */ @@ . patch -p0 <<'@@ .' Index: rpm/perl/rpmxs.c ============================================================================ $ cvs diff -u -r1.1 -r1.2 rpmxs.c --- rpm/perl/rpmxs.c 4 Aug 2007 21:03:27 -0000 1.1 +++ rpm/perl/rpmxs.c 5 Aug 2007 22:12:35 -0000 1.2 @@ -56,6 +56,13 @@ return val; } +rpmTag sv2dbquerytag(SV * sv_tag) { + int val = 0; + if (!scalar2constant(sv_tag, "rpmdbi", &val) && !scalar2constant(sv_tag, "rpmtag", &val)) + croak("unknown tag value '%s'", SvPV_nolen(sv_tag)); + return val; +} + void _rpm2header(rpmts ts, char * filename, int checkmode) { FD_t fd; Header ret = NULL; @@ -82,3 +89,31 @@ return; } +void _newiterator(rpmts ts, SV * sv_tagname, SV * sv_tagvalue, int keylen) { + rpmdbMatchIterator mi; + int tag = RPMDBI_PACKAGES; + void * value = NULL; + int i = 0; + dSP; + if (sv_tagname == NULL || !SvOK(sv_tagname)) { + tag = RPMDBI_PACKAGES; /* Assume search into installed packages */ + } else { + tag = sv2dbquerytag(sv_tagname); + } + if (sv_tagvalue != NULL && SvOK(sv_tagvalue)) { + switch (tag) { + case RPMDBI_PACKAGES: + i = SvIV(sv_tagvalue); + value = &i; + keylen = sizeof(i); + break; + default: + value = (void *) SvPV_nolen(sv_tagvalue); + break; + } + } + mi = rpmtsInitIterator(ts, tag, value, keylen); + XPUSHs(sv_2mortal(sv_setref_pv(newSVpv("", 0), "RPM::PackageIterator", mi))); + PUTBACK; + return; +} @@ . patch -p0 <<'@@ .' Index: rpm/perl/rpmxs.h ============================================================================ $ cvs diff -u -r1.2 -r1.3 rpmxs.h --- rpm/perl/rpmxs.h 5 Aug 2007 00:31:35 -0000 1.2 +++ rpm/perl/rpmxs.h 5 Aug 2007 22:12:35 -0000 1.3 @@ -18,8 +18,12 @@ 0x8e, 0xad, 0xe8, 0x3f, 0x00, 0x00, 0x00, 0x00 }; +rpmTag sv2dbquerytag(SV * sv_tag); + void _rpm2header(rpmts ts, char * filename, int checkmode); +void _newiterator(rpmts ts, SV * sv_tagname, SV * sv_tagvalue, int keylen); + int sv2constant(SV * svconstant, const char * context); #endif @@ . patch -p0 <<'@@ .' Index: rpm/perl/typemap ============================================================================ $ cvs diff -u -r1.7 -r1.8 typemap --- rpm/perl/typemap 5 Aug 2007 12:47:14 -0000 1.7 +++ rpm/perl/typemap 5 Aug 2007 22:12:35 -0000 1.8 @@ -43,7 +43,7 @@ O_OBJECT_rpmdb sv_setref_pv( $arg, "RPM::C::DB", (void*)$var ); O_OBJECT_rpmmi - sv_setref_pv( $arg, "RPM::C::PackageIterator", (void*)$var ); + sv_setref_pv( $arg, "RPM::PackageIterator", (void*)$var ); O_OBJECT_header sv_setref_pv( $arg, "RPM::Header", (void*)$var ); O_OBJECT_rpmts @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org