aboutsummaryrefslogtreecommitdiffstats
path: root/URPM.xs
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-07-22 03:15:21 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-07-22 03:15:21 +0000
commitf60ad53050bcbcfbfaa1fe4d43a77f43a6c04f49 (patch)
tree2bf1d959464d7c88967447067fbe6dc40099ddb4 /URPM.xs
parent1a4d8108ef94266bb631b4c3aaa066f8a788b368 (diff)
downloadperl-URPM-f60ad53050bcbcfbfaa1fe4d43a77f43a6c04f49.tar
perl-URPM-f60ad53050bcbcfbfaa1fe4d43a77f43a6c04f49.tar.gz
perl-URPM-f60ad53050bcbcfbfaa1fe4d43a77f43a6c04f49.tar.bz2
perl-URPM-f60ad53050bcbcfbfaa1fe4d43a77f43a6c04f49.tar.xz
perl-URPM-f60ad53050bcbcfbfaa1fe4d43a77f43a6c04f49.zip
Add URPM::stream2header (borrowed from perl-Hdlist, thanks to Olivier
Thauvin)
Diffstat (limited to 'URPM.xs')
-rw-r--r--URPM.xs23
1 files changed, 23 insertions, 0 deletions
diff --git a/URPM.xs b/URPM.xs
index 6db9d48..1f384d7 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -4064,3 +4064,26 @@ Urpm_import_pubkey(...)
#endif
OUTPUT:
RETVAL
+
+void
+Urpm_stream2header(pio)
+ PerlIO *pio;
+ PREINIT:
+ FILE *fp;
+ FD_t fd;
+ URPM__Package pkg;
+ PPCODE:
+ if (!(fp = PerlIO_findFILE(pio))) croak("Can't get perlio");
+ if ((fd = fdDup(fileno(fp)))) {
+ pkg = (URPM__Package)malloc(sizeof(struct s_Package));
+ memset(pkg, 0, sizeof(struct s_Package));
+ pkg->h = headerRead(fd, HEADER_MAGIC_YES);
+ if (pkg->h) {
+ SV *sv_pkg;
+ EXTEND(SP, 1);
+ sv_pkg = sv_newmortal();
+ sv_setref_pv(sv_pkg, "URPM::Package", (void*)pkg);
+ PUSHs(sv_pkg);
+ }
+ Fclose(fd);
+ }