📄 perlapio.1
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "PERLAPIO 1".TH PERLAPIO 1 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"perlapio \- perl's IO abstraction interface..SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 2\& #define PERLIO_NOT_STDIO 0 /* For co\-existence with stdio only */\& #include <perlio.h> /* Usually via #include <perl.h> */\&\& PerlIO *PerlIO_stdin(void);\& PerlIO *PerlIO_stdout(void);\& PerlIO *PerlIO_stderr(void);\&\& PerlIO *PerlIO_open(const char *path,const char *mode);\& PerlIO *PerlIO_fdopen(int fd, const char *mode);\& PerlIO *PerlIO_reopen(const char *path, const char *mode, PerlIO *old); /* deprecated */\& int PerlIO_close(PerlIO *f);\&\& int PerlIO_stdoutf(const char *fmt,...)\& int PerlIO_puts(PerlIO *f,const char *string);\& int PerlIO_putc(PerlIO *f,int ch);\& int PerlIO_write(PerlIO *f,const void *buf,size_t numbytes);\& int PerlIO_printf(PerlIO *f, const char *fmt,...);\& int PerlIO_vprintf(PerlIO *f, const char *fmt, va_list args);\& int PerlIO_flush(PerlIO *f);\&\& int PerlIO_eof(PerlIO *f);\& int PerlIO_error(PerlIO *f);\& void PerlIO_clearerr(PerlIO *f);\&\& int PerlIO_getc(PerlIO *d);\& int PerlIO_ungetc(PerlIO *f,int ch);\& int PerlIO_read(PerlIO *f, void *buf, size_t numbytes);\&\& int PerlIO_fileno(PerlIO *f);\&\& void PerlIO_setlinebuf(PerlIO *f);\&\& Off_t PerlIO_tell(PerlIO *f);\& int PerlIO_seek(PerlIO *f, Off_t offset, int whence);\& void PerlIO_rewind(PerlIO *f);\&\& int PerlIO_getpos(PerlIO *f, SV *save); /* prototype changed */\& int PerlIO_setpos(PerlIO *f, SV *saved); /* prototype changed */\&\& int PerlIO_fast_gets(PerlIO *f);\& int PerlIO_has_cntptr(PerlIO *f);\& int PerlIO_get_cnt(PerlIO *f);\& char *PerlIO_get_ptr(PerlIO *f);\& void PerlIO_set_ptrcnt(PerlIO *f, char *ptr, int count);\&\& int PerlIO_canset_cnt(PerlIO *f); /* deprecated */\& void PerlIO_set_cnt(PerlIO *f, int count); /* deprecated */\&\& int PerlIO_has_base(PerlIO *f);\& char *PerlIO_get_base(PerlIO *f);\& int PerlIO_get_bufsiz(PerlIO *f);\&\& PerlIO *PerlIO_importFILE(FILE *stdio, const char *mode);\& FILE *PerlIO_exportFILE(PerlIO *f, int flags);\& FILE *PerlIO_findFILE(PerlIO *f);\& void PerlIO_releaseFILE(PerlIO *f,FILE *stdio);\&\& int PerlIO_apply_layers(PerlIO *f, const char *mode, const char *layers);\& int PerlIO_binmode(PerlIO *f, int ptype, int imode, const char *layers);\& void PerlIO_debug(const char *fmt,...).Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"Perl's source code, and extensions that want maximum portability,should use the above functions instead of those defined in \s-1ANSI\s0 C's\&\fIstdio.h\fR. The perl headers (in particular \*(L"perlio.h\*(R") will\&\f(CW\*(C`#define\*(C'\fR them to the I/O mechanism selected at Configure time..PPThe functions are modeled on those in \fIstdio.h\fR, but parameter orderhas been \*(L"tidied up a little\*(R"..PP\&\f(CW\*(C`PerlIO *\*(C'\fR takes the place of \s-1FILE\s0 *. Like \s-1FILE\s0 * it should betreated as opaque (it is probably safe to assume it is a pointer tosomething)..PPThere are currently three implementations:.IP "1. \s-1USE_STDIO\s0" 4.IX Item "1. USE_STDIO"All above are #define'd to stdio functions or are trivial wrapperfunctions which call stdio. In this case \fIonly\fR PerlIO * is a \s-1FILE\s0 *.This has been the default implementation since the abstraction wasintroduced in perl5.003_02..IP "2. \s-1USE_SFIO\s0" 4.IX Item "2. USE_SFIO"A \*(L"legacy\*(R" implementation in terms of the \*(L"sfio\*(R" library. Used forsome specialist applications on Unix machines (\*(L"sfio\*(R" is not widelyported away from Unix). Most of above are #define'd to the sfiofunctions. PerlIO * is in this case Sfio_t *..IP "3. \s-1USE_PERLIO\s0" 4.IX Item "3. USE_PERLIO"Introduced just after perl5.7.0, this is a re-implementation of theabove abstraction which allows perl more control over how \s-1IO\s0 is doneas it decouples \s-1IO\s0 from the way the operating system and C librarychoose to do things. For \s-1USE_PERLIO\s0 PerlIO * has an extra layer ofindirection \- it is a pointer-to-a-pointer. This allows the PerlIO *to remain with a known value while swapping the implementation aroundunderneath \fIat run time\fR. In this case all the above are true (butvery simple) functions which call the underlying implementation..SpThis is the only implementation for which \f(CW\*(C`PerlIO_apply_layers()\*(C'\fRdoes anything \*(L"interesting\*(R"..SpThe \s-1USE_PERLIO\s0 implementation is described in perliol..PPBecause \*(L"perlio.h\*(R" is a thin layer (for efficiency) the semantics ofthese functions are somewhat dependent on the underlying implementation.Where these variations are understood they are noted below..PPUnless otherwise noted, functions return 0 on success, or a negativevalue (usually \f(CW\*(C`EOF\*(C'\fR which is usually \-1) and set \f(CW\*(C`errno\*(C'\fR on error..IP "\fB\f(BIPerlIO_stdin()\fB\fR, \fB\f(BIPerlIO_stdout()\fB\fR, \fB\f(BIPerlIO_stderr()\fB\fR" 4.IX Item "PerlIO_stdin(), PerlIO_stdout(), PerlIO_stderr()"Use these rather than \f(CW\*(C`stdin\*(C'\fR, \f(CW\*(C`stdout\*(C'\fR, \f(CW\*(C`stderr\*(C'\fR. They are writtento look like \*(L"function calls\*(R" rather than variables because this makesit easier to \fImake them\fR function calls if platform cannot export datato loaded modules, or if (say) different \*(L"threads\*(R" might have differentvalues..IP "\fBPerlIO_open(path, mode)\fR, \fBPerlIO_fdopen(fd,mode)\fR" 4.IX Item "PerlIO_open(path, mode), PerlIO_fdopen(fd,mode)"These correspond to \fIfopen()\fR/\fIfdopen()\fR and the arguments are the same.Return \f(CW\*(C`NULL\*(C'\fR and set \f(CW\*(C`errno\*(C'\fR if there is an error. There may be animplementation limit on the number of open handles, which may be lowerthan the limit on the number of open files \- \f(CW\*(C`errno\*(C'\fR may not be setwhen \f(CW\*(C`NULL\*(C'\fR is returned if this limit is exceeded..IP "\fBPerlIO_reopen(path,mode,f)\fR" 4.IX Item "PerlIO_reopen(path,mode,f)"While this currently exists in all three implementations perl itselfdoes not use it. \fIAs perl does not use it, it is not well tested.\fR.SpPerl prefers to \f(CW\*(C`dup\*(C'\fR the new low-level descriptor to the descriptorused by the existing PerlIO. This may become the behaviour of thisfunction in the future..IP "\fBPerlIO_printf(f,fmt,...)\fR, \fBPerlIO_vprintf(f,fmt,a)\fR" 4.IX Item "PerlIO_printf(f,fmt,...), PerlIO_vprintf(f,fmt,a)"These are \fIfprintf()\fR/\fIvfprintf()\fR equivalents..IP "\fBPerlIO_stdoutf(fmt,...)\fR" 4.IX Item "PerlIO_stdoutf(fmt,...)"This is \fIprintf()\fR equivalent. printf is #defined to this function,so it is (currently) legal to use \f(CW\*(C`printf(fmt,...)\*(C'\fR in perl sources..IP "\fBPerlIO_read(f,buf,count)\fR, \fBPerlIO_write(f,buf,count)\fR" 4.IX Item "PerlIO_read(f,buf,count), PerlIO_write(f,buf,count)"These correspond functionally to \fIfread()\fR and \fIfwrite()\fR but thearguments and return values are different. The \fIPerlIO_read()\fR and\&\fIPerlIO_write()\fR signatures have been modeled on the more sane low level\&\fIread()\fR and \fIwrite()\fR functions instead: The \*(L"file\*(R" argument is passedfirst, there is only one \*(L"count\*(R", and the return value can distinguishbetween error and \f(CW\*(C`EOF\*(C'\fR..SpReturns a byte count if successful (which may be zero orpositive), returns negative value and sets \f(CW\*(C`errno\*(C'\fR on error.Depending on implementation \f(CW\*(C`errno\*(C'\fR may be \f(CW\*(C`EINTR\*(C'\fR if operation wasinterrupted by a signal..IP "\fBPerlIO_close(f)\fR" 4.IX Item "PerlIO_close(f)"Depending on implementation \f(CW\*(C`errno\*(C'\fR may be \f(CW\*(C`EINTR\*(C'\fR if operation wasinterrupted by a signal..IP "\fBPerlIO_puts(f,s)\fR, \fBPerlIO_putc(f,c)\fR" 4.IX Item "PerlIO_puts(f,s), PerlIO_putc(f,c)"These correspond to \fIfputs()\fR and \fIfputc()\fR.Note that arguments have been revised to have \*(L"file\*(R" first..IP "\fBPerlIO_ungetc(f,c)\fR" 4.IX Item "PerlIO_ungetc(f,c)"This corresponds to \fIungetc()\fR. Note that arguments have been revised
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -