perlio.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* perlio.c
*
* Copyright (c) 1996-2001, Nick Ing-Simmons
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
*/
#define VOIDUSED 1
#include "config.h"
#define PERLIO_NOT_STDIO 0
#if !defined(PERLIO_IS_STDIO) && !defined(USE_SFIO)
#endif
/*
* This file provides those parts of PerlIO abstraction
* which are not #defined in iperlsys.h.
* Which these are depends on various Configure #ifdef's
*/
#include "EXTERN.h"
#define PERL_IN_PERLIO_C
#include "perl.h"
#if !defined(PERL_IMPLICIT_SYS)
#ifdef PERLIO_IS_STDIO
void
PerlIO_init(void)
{
/* Does nothing (yet) except force this file to be included
in perl binary. That allows this file to force inclusion
of other functions that may be required by loadable
extensions e.g. for FileHandle::tmpfile
*/
}
PerlIO *
PerlIO_tmpfile(void)
{
return tmpfile();
}
#else /* PERLIO_IS_STDIO */
#ifdef USE_SFIO
/* This section is just to make sure these functions
get pulled in from libsfio.a
*/
PerlIO *
PerlIO_tmpfile(void)
{
return sftmp(0);
}
void
PerlIO_init(void)
{
/* Force this file to be included in perl binary. Which allows
* this file to force inclusion of other functions that may be
* required by loadable extensions e.g. for FileHandle::tmpfile
*/
/* Hack
* sfio does its own 'autoflush' on stdout in common cases.
* Flush results in a lot of lseek()s to regular files and
* lot of small writes to pipes.
*/
}
#else /* USE_SFIO */
/* Implement all the PerlIO interface using stdio.
- this should be only file to include <stdio.h>
*/
PerlIO *
PerlIO_stderr(void)
{
}
PerlIO *
PerlIO_stdin(void)
{
}
PerlIO *
PerlIO_stdout(void)
{
}
int
{
return 1;
#else
return 0;
#endif
}
int
{
#if defined(USE_STDIO_PTR)
return 1;
#else
return 0;
#endif
}
int
{
#if defined(USE_STDIO_PTR) && defined(STDIO_CNT_LVALUE)
return 1;
#else
return 0;
#endif
}
void
{
dTHX;
#if defined(USE_STDIO_PTR) && defined(STDIO_CNT_LVALUE)
#else
#endif
}
void
{
dTHX;
#ifdef FILE_bufsiz
#endif
#if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE)
#else
#endif
#else
#if defined(STDIO_PTR_LVAL_SETS_CNT)
#else
#endif
#endif
}
int
PerlIO_get_cnt(PerlIO *f)
{
#ifdef FILE_cnt
return FILE_cnt(f);
#else
dTHX;
return -1;
#endif
}
int
{
#ifdef FILE_bufsiz
return FILE_bufsiz(f);
#else
dTHX;
return -1;
#endif
}
STDCHAR *
PerlIO_get_ptr(PerlIO *f)
{
#ifdef FILE_ptr
return FILE_ptr(f);
#else
dTHX;
return NULL;
#endif
}
STDCHAR *
{
#ifdef FILE_base
return FILE_base(f);
#else
dTHX;
return NULL;
#endif
}
int
{
#ifdef FILE_base
return 1;
#else
return 0;
#endif
}
int
PerlIO_puts(PerlIO *f, const char *s)
{
return fputs(s,f);
}
PerlIO *
{
}
PerlIO *
{
}
PerlIO *
{
}
int
PerlIO_close(PerlIO *f)
{
return fclose(f);
}
int
PerlIO_eof(PerlIO *f)
{
return feof(f);
}
char *
{
#ifdef VMS
#else
dTHX;
return NULL;
#endif
}
int
PerlIO_getc(PerlIO *f)
{
return fgetc(f);
}
int
PerlIO_error(PerlIO *f)
{
return ferror(f);
}
void
{
clearerr(f);
}
int
PerlIO_flush(PerlIO *f)
{
return Fflush(f);
}
int
PerlIO_fileno(PerlIO *f)
{
return fileno(f);
}
void
{
#ifdef HAS_SETLINEBUF
setlinebuf(f);
#else
# ifdef __BORLANDC__ /* Borland doesn't like NULL size for _IOLBF */
# else
# endif
#endif
}
int
{
}
int
{
}
{
}
{
}
int
{
}
PerlIO_tell(PerlIO *f)
{
return ftello(f);
#else
return ftell(f);
#endif
}
int
{
#else
#endif
}
void
PerlIO_rewind(PerlIO *f)
{
rewind(f);
}
int
{
int result;
return result;
}
int
PerlIO_stdoutf(const char *fmt,...)
{
int result;
return result;
}
PerlIO *
PerlIO_tmpfile(void)
{
return tmpfile();
}
PerlIO *
{
return f;
}
FILE *
{
return f;
}
FILE *
{
return f;
}
void
{
}
void
PerlIO_init(void)
{
/* Does nothing (yet) except force this file to be included
in perl binary. That allows this file to force inclusion
of other functions that may be required by loadable
extensions e.g. for FileHandle::tmpfile
*/
}
#endif /* USE_SFIO */
#endif /* PERLIO_IS_STDIO */
#ifndef HAS_FSETPOS
int
#ifdef USE_SFIO
#else
#endif
{
return PerlIO_seek(f,*pos,0);
}
#else
#ifndef PERLIO_IS_STDIO
int
{
#if defined(USE_64_BIT_STDIO) && defined(USE_FSETPOS64)
#else
#endif
}
#endif
#endif
#ifndef HAS_FGETPOS
int
#ifdef USE_SFIO
{
*pos = PerlIO_seek(f,0,0);
return 0;
}
#else
{
*pos = PerlIO_tell(f);
return 0;
}
#endif
#else
#ifndef PERLIO_IS_STDIO
int
{
#if defined(USE_64_BIT_STDIO) && defined(USE_FSETPOS64)
#else
#endif
}
#endif
#endif
int
{
return 0; /* wrong, but perl doesn't use the return value */
}
int
{
return 0; /* wrong, but perl doesn't use the return value */
}
#endif
#ifndef PerlIO_vsprintf
int
{
if (n >= 0)
{
{
dTHX;
my_exit(1);
}
}
return val;
}
#endif
#ifndef PerlIO_sprintf
int
PerlIO_sprintf(char *s, int n, const char *fmt,...)
{
int result;
return result;
}
#endif
#endif /* !PERL_IMPLICIT_SYS */