Does AUTO_INCLUDE work for C ( like CPP )?
'Config' =>
'AUTO_INCLUDE' => [ undef,
myheader.h,
...
]
Cheers.
On Tue, Nov 12, 2002 at 05:19:54PM -0500, Patrick LeBoutillier wrote:
> Hi all,
>
> I'm writing a simple Inline wrapper to the rpmVersionCompare
> function from librpm. The way the rpm headers are made (rpm 4.0.2-8),
> I can't compile if I do:
>
> #include "EXTERN.h"
> #include "perl.h"
> #include "XSUB.h"
> #include "INLINE.h"
> #include <rpm/rpmlib.h>
>
> I have to do:
>
> #include <rpm/rpmlib.h>
> #include "EXTERN.h"
> #include "perl.h"
> #include "XSUB.h"
> #include "INLINE.h"
>
> Is there a way to suppress these 4 default header lines in Inline::C or
> insert my own headers in front?
> I can get around it like this, but it's not really elegant:
>
> #!/usr/bin/perl
>
> use strict ;
> BEGIN {
> require Inline::C ;
> *Inline::C::validate_ori = \&Inline::C::validate ;
> *Inline::C::validate = sub {
> my $o = shift ;
>
> $o->{ILSM}{AUTO_INCLUDE} = "/*\n" ;
> Inline::C::validate_ori($o, @_) ;
> } ;
> }
>
>
> use Inline (
> C => 'DATA',
> LIBS => '-lrpm -lrpmio -lpopt',
> INC => '-I/usr/include/rpm',
> AUTO_INCLUDE => "*/",
> ) ;
>
>
> sub rpmVersionCompare {
> my $fv1 = shift ;
> my $fv2 = shift ;
>
> my ($v1, $r1) = split(/-/, $fv1) ;
> my ($v2, $r2) = split(/-/, $fv2) ;
>
> return __rpmVersionCompare(
> $v1 || "", $r1 || "",
> $v2 || "", $r2 || "",
> ) ;
> }
>
>
> my $v1 = "1.3.23-4" ;
> my $v2 = "1.3.9-7" ;
>
> print "$v1 > $v2 ? " . rpmVersionCompare($v1, $v2) . "\n" ;
>
> __END__
> __C__
> #include <rpm/rpmlib.h>
> #include "EXTERN.h"
> #include "perl.h"
> #include "XSUB.h"
> #include "INLINE.h"
>
> int __rpmVersionCompare(char *v1, char *r1, char *v2, char *r2){
> Header h1 = headerNew() ;
> Header h2 = headerNew() ;
>
> headerAddEntry(h1, RPMTAG_VERSION, RPM_CHAR_TYPE, v1, strlen(v1)) ;
> headerAddEntry(h1, RPMTAG_RELEASE, RPM_CHAR_TYPE, r1, strlen(r1)) ;
> headerAddEntry(h2, RPMTAG_VERSION, RPM_CHAR_TYPE, v2, strlen(v2)) ;
> headerAddEntry(h2, RPMTAG_RELEASE, RPM_CHAR_TYPE, r2, strlen(r2)) ;
>
> return rpmVersionCompare(h1, h2) ;
> }
>
>
>
> Thanks,
>
> Patrick
>
> ---------------------
> Patrick LeBoutillier
> Laval, Quebec, Canada