1998-09-09 07:00:04 +00:00
|
|
|
/* perlio.c
|
|
|
|
*
|
|
|
|
* Copyright (c) 1996, 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)
|
|
|
|
#define PerlIO FILE
|
|
|
|
#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"
|
|
|
|
#include "perl.h"
|
|
|
|
|
|
|
|
#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
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_tmpfile
|
|
|
|
PerlIO *
|
|
|
|
PerlIO_tmpfile(void)
|
|
|
|
{
|
|
|
|
return tmpfile();
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* PERLIO_IS_STDIO */
|
|
|
|
|
|
|
|
#ifdef USE_SFIO
|
|
|
|
|
|
|
|
#undef HAS_FSETPOS
|
|
|
|
#undef HAS_FGETPOS
|
|
|
|
|
|
|
|
/* This section is just to make sure these functions
|
|
|
|
get pulled in from libsfio.a
|
|
|
|
*/
|
|
|
|
|
|
|
|
#undef PerlIO_tmpfile
|
|
|
|
PerlIO *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_tmpfile(void)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return sftmp(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_init(void)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
sfset(sfstdout,SF_SHARE,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* USE_SFIO */
|
|
|
|
|
|
|
|
/* Implement all the PerlIO interface using stdio.
|
|
|
|
- this should be only file to include <stdio.h>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#undef PerlIO_stderr
|
|
|
|
PerlIO *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_stderr(void)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return (PerlIO *) stderr;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_stdin
|
|
|
|
PerlIO *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_stdin(void)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return (PerlIO *) stdin;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_stdout
|
|
|
|
PerlIO *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_stdout(void)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return (PerlIO *) stdout;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_fast_gets
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_fast_gets(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
#if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
|
|
|
|
return 1;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_has_cntptr
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_has_cntptr(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
#if defined(USE_STDIO_PTR)
|
|
|
|
return 1;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_canset_cnt
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_canset_cnt(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
#if defined(USE_STDIO_PTR) && defined(STDIO_CNT_LVALUE)
|
|
|
|
return 1;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_set_cnt
|
|
|
|
void
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_set_cnt(PerlIO *f, int cnt)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
if (cnt < -1)
|
|
|
|
warn("Setting cnt to %d\n",cnt);
|
|
|
|
#if defined(USE_STDIO_PTR) && defined(STDIO_CNT_LVALUE)
|
|
|
|
FILE_cnt(f) = cnt;
|
|
|
|
#else
|
|
|
|
croak("Cannot set 'cnt' of FILE * on this system");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_set_ptrcnt
|
|
|
|
void
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_set_ptrcnt(PerlIO *f, STDCHAR *ptr, int cnt)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
#ifdef FILE_bufsiz
|
|
|
|
STDCHAR *e = FILE_base(f) + FILE_bufsiz(f);
|
|
|
|
int ec = e - ptr;
|
|
|
|
if (ptr > e + 1)
|
|
|
|
warn("Setting ptr %p > end+1 %p\n", ptr, e + 1);
|
|
|
|
if (cnt != ec)
|
|
|
|
warn("Setting cnt to %d, ptr implies %d\n",cnt,ec);
|
|
|
|
#endif
|
|
|
|
#if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE)
|
|
|
|
FILE_ptr(f) = ptr;
|
|
|
|
#else
|
|
|
|
croak("Cannot set 'ptr' of FILE * on this system");
|
|
|
|
#endif
|
|
|
|
#if defined(USE_STDIO_PTR) && defined(STDIO_CNT_LVALUE)
|
|
|
|
FILE_cnt(f) = cnt;
|
|
|
|
#else
|
|
|
|
croak("Cannot set 'cnt' of FILE * on this system");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_get_cnt
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_get_cnt(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
#ifdef FILE_cnt
|
|
|
|
return FILE_cnt(f);
|
|
|
|
#else
|
|
|
|
croak("Cannot get 'cnt' of FILE * on this system");
|
|
|
|
return -1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_get_bufsiz
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_get_bufsiz(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
#ifdef FILE_bufsiz
|
|
|
|
return FILE_bufsiz(f);
|
|
|
|
#else
|
|
|
|
croak("Cannot get 'bufsiz' of FILE * on this system");
|
|
|
|
return -1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_get_ptr
|
|
|
|
STDCHAR *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_get_ptr(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
#ifdef FILE_ptr
|
|
|
|
return FILE_ptr(f);
|
|
|
|
#else
|
|
|
|
croak("Cannot get 'ptr' of FILE * on this system");
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_get_base
|
|
|
|
STDCHAR *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_get_base(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
#ifdef FILE_base
|
|
|
|
return FILE_base(f);
|
|
|
|
#else
|
|
|
|
croak("Cannot get 'base' of FILE * on this system");
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_has_base
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_has_base(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
#ifdef FILE_base
|
|
|
|
return 1;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_puts
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_puts(PerlIO *f, const char *s)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return fputs(s,f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_open
|
|
|
|
PerlIO *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_open(const char *path, const char *mode)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return fopen(path,mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_fdopen
|
|
|
|
PerlIO *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_fdopen(int fd, const char *mode)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return fdopen(fd,mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_reopen
|
|
|
|
PerlIO *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_reopen(const char *name, const char *mode, PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return freopen(name,mode,f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_close
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_close(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return fclose(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_eof
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_eof(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return feof(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_getname
|
|
|
|
char *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_getname(PerlIO *f, char *buf)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
#ifdef VMS
|
|
|
|
return fgetname(f,buf);
|
|
|
|
#else
|
|
|
|
croak("Don't know how to get file name");
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_getc
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_getc(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return fgetc(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_error
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_error(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return ferror(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_clearerr
|
|
|
|
void
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_clearerr(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
clearerr(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_flush
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_flush(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return Fflush(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_fileno
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_fileno(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return fileno(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_setlinebuf
|
|
|
|
void
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_setlinebuf(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
#ifdef HAS_SETLINEBUF
|
|
|
|
setlinebuf(f);
|
|
|
|
#else
|
|
|
|
# ifdef __BORLANDC__ /* Borland doesn't like NULL size for _IOLBF */
|
|
|
|
setvbuf(f, Nullch, _IOLBF, BUFSIZ);
|
|
|
|
# else
|
|
|
|
setvbuf(f, Nullch, _IOLBF, 0);
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_putc
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_putc(PerlIO *f, int ch)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return putc(ch,f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_ungetc
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_ungetc(PerlIO *f, int ch)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return ungetc(ch,f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_read
|
|
|
|
SSize_t
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_read(PerlIO *f, void *buf, Size_t count)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return fread(buf,1,count,f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_write
|
|
|
|
SSize_t
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_write(PerlIO *f, const void *buf, Size_t count)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return fwrite1(buf,1,count,f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_vprintf
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_vprintf(PerlIO *f, const char *fmt, va_list ap)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return vfprintf(f,fmt,ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#undef PerlIO_tell
|
1999-05-02 14:33:17 +00:00
|
|
|
Off_t
|
|
|
|
PerlIO_tell(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return ftell(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_seek
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_seek(PerlIO *f, Off_t offset, int whence)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return fseek(f,offset,whence);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_rewind
|
|
|
|
void
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_rewind(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
rewind(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_printf
|
|
|
|
int
|
|
|
|
PerlIO_printf(PerlIO *f,const char *fmt,...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
int result;
|
|
|
|
va_start(ap,fmt);
|
|
|
|
result = vfprintf(f,fmt,ap);
|
|
|
|
va_end(ap);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_stdoutf
|
|
|
|
int
|
|
|
|
PerlIO_stdoutf(const char *fmt,...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
int result;
|
|
|
|
va_start(ap,fmt);
|
|
|
|
result = PerlIO_vprintf(PerlIO_stdout(),fmt,ap);
|
|
|
|
va_end(ap);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_tmpfile
|
|
|
|
PerlIO *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_tmpfile(void)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return tmpfile();
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_importFILE
|
|
|
|
PerlIO *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_importFILE(FILE *f, int fl)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_exportFILE
|
|
|
|
FILE *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_exportFILE(PerlIO *f, int fl)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_findFILE
|
|
|
|
FILE *
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_findFILE(PerlIO *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef PerlIO_releaseFILE
|
|
|
|
void
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_releaseFILE(PerlIO *p, FILE *f)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_init(void)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
/* 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
|
|
|
|
#undef PerlIO_setpos
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_setpos(PerlIO *f, const Fpos_t *pos)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return PerlIO_seek(f,*pos,0);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#ifndef PERLIO_IS_STDIO
|
|
|
|
#undef PerlIO_setpos
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_setpos(PerlIO *f, const Fpos_t *pos)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return fsetpos(f, pos);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAS_FGETPOS
|
|
|
|
#undef PerlIO_getpos
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_getpos(PerlIO *f, Fpos_t *pos)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
*pos = PerlIO_tell(f);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#ifndef PERLIO_IS_STDIO
|
|
|
|
#undef PerlIO_getpos
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
PerlIO_getpos(PerlIO *f, Fpos_t *pos)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
return fgetpos(f, pos);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (defined(PERLIO_IS_STDIO) || !defined(USE_SFIO)) && !defined(HAS_VPRINTF)
|
|
|
|
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
vprintf(char *pat, char *args)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
_doprnt(pat, args, stdout);
|
|
|
|
return 0; /* wrong, but perl doesn't use the return value */
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-05-02 14:33:17 +00:00
|
|
|
vfprintf(FILE *fd, char *pat, char *args)
|
1998-09-09 07:00:04 +00:00
|
|
|
{
|
|
|
|
_doprnt(pat, args, fd);
|
|
|
|
return 0; /* wrong, but perl doesn't use the return value */
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PerlIO_vsprintf
|
|
|
|
int
|
|
|
|
PerlIO_vsprintf(char *s, int n, const char *fmt, va_list ap)
|
|
|
|
{
|
|
|
|
int val = vsprintf(s, fmt, ap);
|
|
|
|
if (n >= 0)
|
|
|
|
{
|
|
|
|
if (strlen(s) >= (STRLEN)n)
|
|
|
|
{
|
|
|
|
PerlIO_puts(PerlIO_stderr(),"panic: sprintf overflow - memory corrupted!\n");
|
|
|
|
my_exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PerlIO_sprintf
|
|
|
|
int
|
|
|
|
PerlIO_sprintf(char *s, int n, const char *fmt,...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
int result;
|
|
|
|
va_start(ap,fmt);
|
|
|
|
result = PerlIO_vsprintf(s, n, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|