develooper Front page | perl.perl5.porters | Postings from January 2001

PerlIO + native FILE*

Thread Next
From:
Doug MacEachern
Date:
January 5, 2001 10:20
Subject:
PerlIO + native FILE*
Message ID:
Pine.LNX.4.10.10101051014460.331-100000@mojo.covalent.net
using @8335, even though perl -V reports 8325 after Configure/make:
% ./perl -Mlib=lib -V | grep DEVEL
        DEVEL8325
% cat .patch 
8335

i'm having problems gluing third-party functions that return FILE*
i've tried various #define's, USE_STDIO, etc, but can't get it right.
consider this:

#include <stdio.h>

/* pretend this is linked in from a third-party library */
static FILE *getfile(void)
{
    return fopen(__FILE__, "r");
}

#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#define getfile_2() PerlIO_importFILE(getfile(),0)

MODULE = TestIO		PACKAGE = TestIO		

FILE *
getfile()

FILE *
getfile_2()

when getfile() is expanded (TestIO.i), RETVAL is turned into PerlIO:
    if (items != 0)
	Perl_croak(my_perl ,  "Usage: TestIO::getfile()");
    {
	PerlIO   *	RETVAL;

	RETVAL = getfile();

so i tried using importFILE:
    if (items != 0)
	Perl_croak(my_perl ,  "Usage: TestIO::getfile_2()");
    {
	PerlIO   *	RETVAL;

	RETVAL = PerlIO_importFILE(getfile(),0) ;

however, the prototype has changed from FILE * to PerlIO *:

extern PerlIO  *	PerlIO_importFILE	(PerlIO   *,int);

what is the proper magic to get this right?


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About