cvs: phpdoc-ja /internals/streams common.xml constants.xml dir.xml file.xml index.xml socket.xml structs.xml

From: Date: Mon, 22 Aug 2005 08:17:12 +0000
Subject: cvs: phpdoc-ja /internals/streams common.xml constants.xml dir.xml file.xml index.xml socket.xml structs.xml
Groups: php.doc.ja 
Request: Send a blank email to doc-ja+get-1153@lists.php.net to get a copy of this message
takagi Mon Aug 22 04:17:12 2005 EDT Added files: /phpdoc-ja/internals/streams structs.xml socket.xml index.xml file.xml dir.xml constants.xml common.xml Log: moved from /phpdoc-ja/chapters/streams* .

http://cvs.php.net/co.php/phpdoc-ja/internals/streams/structs.xml?r=1.1&p=1 Index: phpdoc-ja/internals/streams/structs.xml +++ phpdoc-ja/internals/streams/structs.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.1 Maintainer: hirokawa Status: ready --> <!-- CREDITS: shimooka,takagi --> <!-- Author: Wez Furlong <wez@thebrainroom.com> Please contact me before making any major amendments to the content of this section. Splitting/Merging are fine if they are required for php-doc restructuring purposes - just drop me a line if you make a change (so I can update my local copy). --> <sect1 id="streams.structs"> <title>ストリーム構造体</title> <refentry id="streams.struct-php-stream-statbuf"> <refnamediv> <refname>struct php_stream_statbuf</refname> <refpurpose>ファイルまたはURLに関する情報を保持する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <synopsis> <structname>php_stream_statbuf</structname> <type>struct stat</type> <structfield>sb</structfield> </synopsis> <para> <structfield>sb</structfield> は、通常のシステムが定義する struct statです。 </para> </refsect1> </refentry> <refentry id="streams.struct-php-stream-dirent"> <refnamediv> <refname>struct php_stream_dirent</refname> <refpurpose> ディレクトリ探索の際に一つのファイルに関する情報を保持する </refpurpose> </refnamediv> <refsect1> <title>説明</title> <synopsis> <structname>php_stream_dirent</structname> <type>char</type> <structfield>d_name[MAXPATHLEN]</structfield> </synopsis> <para> <structfield>d_name</structfield> は、探索するディレクトリに関して 相対的なファイル名を保持します。 </para> </refsect1> </refentry> <refentry id="streams.struct-php-stream-ops"> <refnamediv> <refname>struct php_stream_ops</refname> <refpurpose>Holds member functions for a stream implementation</refpurpose> </refnamediv> <refsect1> <title>Description</title> <programlisting role="c"> <![CDATA[ typedef struct _php_stream_ops { /* all streams MUST implement these operations */ size_t (*write)(php_stream *stream, const char *buf, size_t count TSRMLS_DC); size_t (*read)(php_stream *stream, char *buf, size_t count TSRMLS_DC); int (*close)(php_stream *stream, int close_handle TSRMLS_DC); int (*flush)(php_stream *stream TSRMLS_DC); const char *label; /* name describing this class of stream */ /* these operations are optional, and may be set to NULL if the stream does not * support a particular operation */ int (*seek)(php_stream *stream, off_t offset, int whence TSRMLS_DC); char *(*gets)(php_stream *stream, char *buf, size_t size TSRMLS_DC); int (*cast)(php_stream *stream, int castas, void **ret TSRMLS_DC); int (*stat)(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC); } php_stream_ops; ]]> </programlisting> </refsect1> </refentry> <refentry id="streams.struct-php-stream-wrapper"> <refnamediv> <refname>struct php_stream_wrapper</refname> <refpurpose>Holds wrapper properties and pointer to operations</refpurpose> </refnamediv> <refsect1> <title>Description</title> <programlisting role="c"> <![CDATA[ struct _php_stream_wrapper { php_stream_wrapper_ops *wops; /* operations the wrapper can perform */ void *abstract; /* context for the wrapper */ int is_url; /* so that PG(allow_url_fopen) can be respected */ /* support for wrappers to return (multiple) error messages to the stream opener */ int err_count; char **err_stack; } php_stream_wrapper; ]]> </programlisting> </refsect1> </refentry> <refentry id="streams.struct-php-stream-wrapper-ops"> <refnamediv> <refname>struct php_stream_wrapper_ops</refname> <refpurpose>Holds member functions for a stream wrapper implementation</refpurpose> </refnamediv> <refsect1> <title>Description</title> <programlisting role="c"> <![CDATA[ typedef struct _php_stream_wrapper_ops { /* open/create a wrapped stream */ php_stream *(*stream_opener)(php_stream_wrapper *wrapper, char *filename, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); /* close/destroy a wrapped stream */ int (*stream_closer)(php_stream_wrapper *wrapper, php_stream *stream TSRMLS_DC); /* stat a wrapped stream */ int (*stream_stat)(php_stream_wrapper *wrapper, php_stream *stream, php_stream_statbuf *ssb TSR$ /* stat a URL */ int (*url_stat)(php_stream_wrapper *wrapper, char *url, php_stream_statbuf *ssb TSRMLS_DC); /* open a "directory" stream */ php_stream *(*dir_opener)(php_stream_wrapper *wrapper, char *filename, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC); const char *label; /* Delete/Unlink a file */ int (*unlink)(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC); } php_stream_wrapper_ops; ]]> </programlisting> </refsect1> </refentry> <refentry id="streams.struct-php-stream-filter"> <refnamediv> <refname>struct php_stream_filter</refname> <refpurpose>Holds filter properties and pointer to operations</refpurpose> </refnamediv> <refsect1> <title>Description</title> <programlisting role="c"> <![CDATA[ struct _php_stream_filter { php_stream_filter_ops *fops; void *abstract; /* for use by filter implementation */ php_stream_filter *next; php_stream_filter *prev; int is_persistent; /* link into stream and chain */ php_stream_filter_chain *chain; /* buffered buckets */ php_stream_bucket_brigade buffer; } php_stream_filter; ]]> </programlisting> </refsect1> </refentry> <refentry id="streams.struct-php-stream-filter-ops"> <refnamediv> <refname>struct php_stream_filter_ops</refname> <refpurpose>Holds member functions for a stream filter implementation</refpurpose> </refnamediv> <refsect1> <title>Description</title> <programlisting role="c"> <![CDATA[ typedef struct _php_stream_filter_ops { php_stream_filter_status_t (*filter)( php_stream *stream, php_stream_filter *thisfilter, php_stream_bucket_brigade *buckets_in, php_stream_bucket_brigade *buckets_out, size_t *bytes_consumed, int flags TSRMLS_DC); void (*dtor)(php_stream_filter *thisfilter TSRMLS_DC); const char *label; } php_stream_filter_ops; ]]> </programlisting> </refsect1> </refentry> </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/phpdoc-ja/internals/streams/socket.xml?r=1.1&p=1 Index: phpdoc-ja/internals/streams/socket.xml +++ phpdoc-ja/internals/streams/socket.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.1 Maintainer: hirokawa Status: ready --> <!-- CREDITS: shimooka,takagi --> <!-- Author: Wez Furlong <wez@thebrainroom.com> Please contact me before making any major amendments to the content of this section. Splitting/Merging are fine if they are required for php-doc restructuring purposes - just drop me a line if you make a change (so I can update my local copy). --> <sect1 id="streams.socket-api"> <title>ストリーム ソケット API リファレンス</title> <refentry id="streams.php-stream-sock-open-from-socket"> <refnamediv> <refname>php_stream_sock_open_from_socket</refname> <refpurpose>ソケットデスクリプタをストリームに変換する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>php_stream *</type><methodname>php_stream_sock_open_from_socket</methodname> <methodparam><type>int</type><parameter>socket</parameter></methodparam> <methodparam><type>int</type><parameter>persistent</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_sock_open_from_socket</function> は、 <parameter>socket</parameter> を元にしたストリームを返します。 <parameter>persistent</parameter> は、ストリームを恒久的ストリームとして 開くかどうかを指定します。一般的には、この値は 0 になることがほとんどです。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-sock-open-host"> <refnamediv> <refname>php_stream_sock_open_host</refname> <refpurpose>ホストへの接続をオープンし、ストリームを返す</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>php_stream *</type><methodname>php_stream_sock_open_host</methodname> <methodparam><type>const char *</type><parameter>host</parameter></methodparam> <methodparam><type>unsigned short</type><parameter>port</parameter></methodparam> <methodparam><type>int</type><parameter>socktype</parameter></methodparam> <methodparam><type>struct timeval *</type><parameter>timeout</parameter></methodparam> <methodparam><type>int</type><parameter>persistent</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_sock_open_host</function> は、指定されたホスト <parameter>host</parameter> のポート <parameter>port</parameter> に対する 接続を確立します。<parameter>socktype</parameter> は、 接続に適用される様式を指定します。<parameter>socktype</parameter> に 指定できる値はシステムに依存していますが、大抵は (少なくとも) <constant>SOCK_STREAM</constant> を、時系列的な、信頼性のある、 双方向接続のソケット (TCP)、 <constant>SOCK_DGRAM</constant> を、 接続型でなく信頼性の少ない固定長メッセージのソケット (UDP) に対して 指定できます。 </para> <para> <parameter>persistent</parameter> は、ストリームを恒久的ストリームとして 開くかどうかを指定します。一般的には、この値は 0 になることがほとんどです。 </para> <para> <parameter>timeout</parameter> が NULL でない場合、接続する間に許される 最長の時間を指定します。 もし、タイムアウトの値よりも長く接続に時間がかかったときは、 接続は中断され、ストリームがオープンできなかったことを示すよう NULL が返されます。 </para> <note> <simpara> タイムアウトの値は DNS ルックアップにかかる時間を含みません。 ブロックしない DNS ルックアップを実装する移植性の高い方法がないからです。 </simpara> <simpara> また、タイムアウトは、接続フェーズにのみ適用されます。 もし、後に続く読み出しや書き込み操作についてタイムアウト時間を設定したい場合は、 一旦開かれたストリームに対し、 <function>php_stream_sock_set_timeout</function> を使ってください。 </simpara> </note> <para> ストリーム API は、<parameter>socktype</parameter> に指定できる値に 制限を設けていませんが、自分の拡張モジュールをリリースする際には、 その値がどれくらいの移植可能性を持つかについて考慮しましょう。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-sock-open-unix"> <refnamediv> <refname>php_stream_sock_open_unix</refname> <refpurpose> Unix ドメインソケットをオープンし、ストリームへ変換する </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>php_stream *</type><methodname>php_stream_sock_open_unix</methodname> <methodparam><type>const char *</type><parameter>path</parameter></methodparam> <methodparam><type>int</type><parameter>pathlen</parameter></methodparam> <methodparam><type>int</type><parameter>persistent</parameter></methodparam> <methodparam><type>struct timeval *</type><parameter>timeout</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_sock_open_unix</function> は <parameter>path</parameter> で指定された Unix ドメインソケットを開きます。<parameter>pathlen</parameter> は、<parameter>path</parameter> の長さを指定します。 <parameter>timeout</parameter> は NULL でない場合、 接続試行におけるタイムアウト時間を指定します。 <parameter>persistent</parameter> は、ストリームを恒久的ストリームとして 開くかどうかを指定します。一般的には、この値は 0 になることがほとんどです。 </para> <note> <simpara> この関数は Unix ドメインソケットが実装されていない Windows では動きません。 ただ、PHP のバイナリが cygwin を用いて作られている場合はこの限りではありません。 自分の拡張モジュールをリリースする際には、移植可能性について考慮しましょう。 </simpara> </note> <note> <simpara> この関数は <parameter>path</parameter> を (Linux など) 抽象名前空間をもち、 パス名の最初が NUL 文字になることがあるシステムに適すよう、 バイナリセーフに扱います。 </simpara> </note> </refsect1> </refentry> </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/phpdoc-ja/internals/streams/index.xml?r=1.1&p=1 Index: phpdoc-ja/internals/streams/index.xml +++ phpdoc-ja/internals/streams/index.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.1 Maintainer: hirokawa Status: working --> <!-- CREDITS: shimooka,takagi --> <!-- Author: Wez Furlong <wez@thebrainroom.com> Please contact me before making any major amendments to the content of this section. Splitting/Merging are fine if they are required for php-doc restructuring purposes - just drop me a line if you make a change (so I can update my local copy). --> <chapter id="streams"> <title>PHP拡張モジュールの作者用のストリームAPI</title> <sect1 id="streams.overview"> <title>概要</title> <para> PHPストリームAPIは、PHP拡張モジュールにファイルおよびソケット処理 用の統一化された手段を導入するものです。 共通の操作を行なうための標準関数を有する単一のAPIを使用することに より、ストリームAPIは拡張モジュールがファイル、ソケット、URL、メモリ スクリプトが定義したオブジェクトにアクセスすることを可能にします。 ストリームは、新規ストリームを登録するために動的にロードされる モジュール(およびスクリプト!)とすることができる実行時に拡張可能な APIです。 </para> <para> ストリームAPIの目的は、ファイル、URL、その他のストリームにできるデータ ソースを平易な統一されたAPIにより、開発者が容易にオープンできるように することです。APIは、ほぼANSI C stdio関数と(多くの主な関数について同等 の意味を有しており、)類似しています。このため、Cプログラマは、 ストリームに慣れている印象を受けるはずです。 </para> <para> ストリームAPIは、いくつかの異なるレベルを処理します。 基本レベルでは、APIはストリーマブルなデータソースを表す php_streamオブジェクトを定義します。 やや高いレベルでは、APIは、URLからのデータおよびメタデータの取得を サポートするために低レベルAPIをラップしたphp_stream_wrapper オブジェクトを定義します。 An additional <literal>context</literal> parameter, accepted by most stream creation functions, is passed to the wrapper's <literal>stream_opener</literal> method to fine-tune the behavior of the wrapper. </para> <para> Any stream, once opened, can also have any number of <literal>filters</literal> applied to it, which process data as it is read from/written to the stream. </para> <para> ストリームは、ファイル処理の他の形式にキャスト(変換)でき、 大きな問題もなくサードパーティ製のライブラリと組み合わせて使用する ことができます。これにより、これらのライブラリがURLソースからデータに 直接アクセスできるようになります。 使用するシステムに<function>fopencookie</function>または <function>funopen</function>関数がある場合、 任意のPHPストリームをANSI stdioを使う任意のライブラリに渡すことさえ できます! </para> <para> <note> <para> The functions in this chapter are for use in the PHP source code and are not PHP functions. Userland stream functions can be found in the <link linkend="ref.stream">Stream Reference</link>. </para> </note> </para> </sect1> <sect1 id="streams.basics"> <title>ストリームの基本</title> <para> ストリームの使用方法は、ANSI stdio関数の使用と非常に似ています。 主な違いは、使用を開始するストリームを得る方法です。 多くの場合、ストリームのハンドルを得るために <function>php_stream_open_wrapper</function>を使用します。 この関数の動作は、以下の例で示すようにfopenと非常によくにています。 </para> <para> <example> <title>PHPホームページを表示するための簡単なストリームの例</title> <programlisting role="c"> <![CDATA[ php_stream * stream = php_stream_open_wrapper("http://www.php.net", "rb", REPORT_ERRORS, NULL); if (stream) { while(!php_stream_eof(stream)) { char buf[1024]; if (php_stream_gets(stream, buf, sizeof(buf))) { printf(buf); } else { break; } } php_stream_close(stream); } ]]> </programlisting> </example> </para> <para> 以下の表にその他の一般的なANSI stdio関数と等価なストリーム関数を 示します。注記で除外されていない限り、関数の意味は同じです。 <table> <title>ANSI stdioと等価なストリームAPI関数</title> <tgroup cols="3"> <thead> <row> <entry>ANSI stdio関数</entry> <entry>PHP ストリーム関数</entry> <entry>注意</entry> </row> </thead> <tbody> <row> <entry>fopen</entry> <entry>php_stream_open_wrapper</entry> <entry>ストリームではパラメータが増えています</entry> </row> <row> <entry>fclose</entry> <entry>php_stream_close</entry> <entry></entry> </row> <row> <entry>fgets</entry> <entry>php_stream_gets</entry> <entry></entry> </row> <row> <entry>fread</entry> <entry>php_stream_read</entry> <entry>パラメータnmembの値を1と仮定すると、プロトタイプはread(2)により似ることになります</entry> </row> <row> <entry>fwrite</entry> <entry>php_stream_write</entry> <entry>パラメータnmembの値を1と仮定すると、プロトタイプはwrite(2)により似ることになります</entry> </row> <row> <entry>fseek</entry> <entry>php_stream_seek</entry> <entry></entry> </row> <row> <entry>ftell</entry> <entry>php_stream_tell</entry> <entry></entry> </row> <row> <entry>rewind</entry> <entry>php_stream_rewind</entry> <entry></entry> </row> <row> <entry>feof</entry> <entry>php_stream_eof</entry> <entry></entry> </row> <row> <entry>fgetc</entry> <entry>php_stream_getc</entry> <entry></entry> </row> <row> <entry>fputc</entry> <entry>php_stream_putc</entry> <entry></entry> </row> <row> <entry>fflush</entry> <entry>php_stream_flush</entry> <entry></entry> </row> <row> <entry>puts</entry> <entry>php_stream_puts</entry> <entry>fputsではなく、putsと同じ意味</entry> </row> <row> <entry>fstat</entry> <entry>php_stream_stat</entry> <entry>ストリームはより情報の多いstat構造体を有しています</entry> </row> </tbody> </tgroup> </table> </para> </sect1> <sect1 id="streams.resources"> <title>リソースとしてのストリーム</title> <para> All streams are registered as resources when they are created. This ensures that they will be properly cleaned up even if there is some fatal error. All of the filesystem functions in PHP operate on streams resources - that means that your extensions can accept regular PHP file pointers as parameters to, and return streams from their functions. The streams API makes this process as painless as possible: </para> <para> <example> <title>How to accept a stream as a parameter</title> <programlisting role="c"> <![CDATA[ PHP_FUNCTION(example_write_hello) { zval *zstream; php_stream *stream; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream)) return; php_stream_from_zval(stream, &zstream); /* you can now use the stream. However, you do not "own" the stream, the script does. That means you MUST NOT close the stream, because it will cause PHP to crash! */ php_stream_write(stream, "hello\n"); RETURN_TRUE(); } ]]> </programlisting> </example> </para> <para> <example> <title>How to return a stream from a function</title> <programlisting role="c"> <![CDATA[ PHP_FUNCTION(example_open_php_home_page) { php_stream *stream; stream = php_stream_open_wrapper("http://www.php.net", "rb", REPORT_ERRORS, NULL); php_stream_to_zval(stream, return_value); /* after this point, the stream is "owned" by the script. If you close it now, you will crash PHP! */ } ]]> </programlisting> </example> </para> <para> Since streams are automatically cleaned up, it's tempting to think that we can get away with being sloppy programmers and not bother to close the streams when we are done with them. Although such an approach might work, it is not a good idea for a number of reasons: streams hold locks on system resources while they are open, so leaving a file open after you have finished with it could prevent other processes from accessing it. If a script deals with a large number of files, the accumulation of the resources used, both in terms of memory and the sheer number of open files, can cause web server requests to fail. Sounds bad, doesn't it? The streams API includes some magic that helps you to keep your code clean - if a stream is not closed by your code when it should be, you will find some helpful debugging information in you web server error log. </para> <note> <simpara> Always use a debug build of PHP when developing an extension (<option>--enable-debug</option> when running configure), as a lot of effort has been made to warn you about memory and stream leaks. </simpara> </note> <para> In some cases, it is useful to keep a stream open for the duration of a request, to act as a log or trace file for example. Writing the code to safely clean up such a stream is not difficult, but it's several lines of code that are not strictly needed. To save yourself the trouble of writing the code, you can mark a stream as being OK for auto cleanup. What this means is that the streams API will not emit a warning when it is time to auto-cleanup a stream. To do this, you can use <function>php_stream_auto_cleanup</function>. </para> </sect1> &internals.streams.common; &internals.streams.dir; &internals.streams.file; &internals.streams.socket; &internals.streams.structs; &internals.streams.constants; </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/phpdoc-ja/internals/streams/file.xml?r=1.1&p=1 Index: phpdoc-ja/internals/streams/file.xml +++ phpdoc-ja/internals/streams/file.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.1 Maintainer: hirokawa Status: ready --> <!-- CREDITS: shimooka,takagi --> <!-- Author: Wez Furlong <wez@thebrainroom.com> Please contact me before making any major amendments to the content of this section. Splitting/Merging are fine if they are required for php-doc restructuring purposes - just drop me a line if you make a change (so I can update my local copy). --> <sect1 id="streams.file-api"> <title>ストリームファイル API リファレンス</title> <refentry id="streams.php-stream-fopen-from-file"> <refnamediv> <refname>php_stream_fopen_from_file</refname> <refpurpose>ANSI FILE* をストリームに変換する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>php_stream *</type><methodname>php_stream_fopen_from_file</methodname> <methodparam><type>FILE *</type><parameter>file</parameter></methodparam> <methodparam><type>char *</type><parameter>mode</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_fopen_from_file</function> は、 <parameter>file</parameter>に基づくストリームを返します。 <parameter>mode</parameter> は、<parameter>file</parameter>をオープンする 際に使用されたモードと同じである必要があり、さもないと、 ストリームがファイルのモードと異なった場合に、書き込みを行うと、 おかしな結果を生じる可能性があります。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-fopen-tmpfile"> <refnamediv> <refname>php_stream_fopen_tmpfile</refname> <refpurpose>tmpfile()でFILE*をオープンし、ストリームに変換する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>php_stream *</type><methodname>php_stream_fopen_tmpfile</methodname> <methodparam><type>void</type><parameter></parameter></methodparam> </methodsynopsis> <para> <function>php_stream_fopen_tmpfile</function> は、モード "w+b" で開かれた テンポラリファイルを元にしたストリームを返します。 テンポラリファイルは、ストリームか閉じられるか、プロセスの終了時に 削除されます。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-fopen-temporary-file"> <refnamediv> <refname>php_stream_fopen_temporary_file</refname> <refpurpose> ファイル名を生成し、そのファイルへのストリームをオープンする </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>php_stream *</type><methodname>php_stream_fopen_temporary_file</methodname> <methodparam><type>const char *</type><parameter>dir</parameter></methodparam> <methodparam><type>const char *</type><parameter>pfx</parameter></methodparam> <methodparam><type>char **</type><parameter>opened</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_fopen_temporary_file</function> は、<parameter>dir</parameter> で指定されたディレクトリに、<parameter>pfx</parameter> で指定された プレフィックスを持つテンポラリファイルを生成します。 生成されたファイル名は <parameter>opened</parameter> パラメータに返されますが、 この値は、後で <function>efree</function> を使って開放する必要があります。 ストリームは生成されたファイル名で、"w+b" モードで開かれます。 なお、ファイルは自動的には削除されませんので、利用が終わったら自分で削除 するか適切な場所に移動するかしなくてはなりません。 </para> </refsect1> </refentry> </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/phpdoc-ja/internals/streams/dir.xml?r=1.1&p=1 Index: phpdoc-ja/internals/streams/dir.xml +++ phpdoc-ja/internals/streams/dir.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.4 Maintainer: hirokawa Status: ready --> <!-- CREDITS: shimooka,takagi --> <!-- Author: Wez Furlong <wez@thebrainroom.com> Please contact me before making any major amendments to the content of this section. Splitting/Merging are fine if they are required for php-doc restructuring purposes - just drop me a line if you make a change (so I can update my local copy). --> <sect1 id="streams.dir-api"> <title>ストリームディレクトリAPIリファレンス</title> <para> 本セクションに示す一連の関数は、ローカルファイルおよびリモートファイル (この機能をラッパーがサポートする場合!)で動作します。 </para> <refentry id="streams.php-stream-opendir"> <refnamediv> <refname>php_stream_opendir</refname> <refpurpose> ファイルのリストを得るためにディレクトリをオープンする </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>php_stream *</type><methodname>php_stream_opendir</methodname> <methodparam><type>char *</type><parameter>path</parameter></methodparam> <methodparam><type>php_stream_context *</type><parameter>context</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_opendir</function> は、<parameter>path</parameter> で 指定されたディレクトリ内のファイルの一覧を取得するのに用いるストリーム を返します。 この関数の動作は、POSIX の <function>opendir</function> 関数とほぼ同一です。 この関数は php_stream オブジェクトを返しますが、このストリーム オブジェクトに対して共通 API の関数を使うことはお勧めできません。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-readdir"> <refnamediv> <refname>php_stream_readdir</refname> <refpurpose> オープンしたディレクトリから次のディレクトリエントリを得る </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>php_stream_dirent *</type><methodname>php_stream_readdir</methodname> <methodparam><type>php_stream *</type><parameter>dirstream</parameter></methodparam> <methodparam><type>php_stream_dirent *</type><parameter>ent</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_readdir</function> は、<parameter>dirstream</parameter> より次のディレクトリエントリを読み出し、<parameter>ent</parameter> に格納します。 成功した場合の返り値は <parameter>ent</parameter> で、失敗した場合の 返り値は <type>NULL</type> です。 各ディレクトリエントリに返された情報に関するより詳細については、<link linkend="streams.struct-php-stream-dirent">php_stream_dirent</link> を参照してください。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-rewinddir"> <refnamediv> <refname>php_stream_rewinddir</refname> <refpurpose>最初のエントリにディレクトリストリームを戻す</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>int</type><methodname>php_stream_rewinddir</methodname> <methodparam><type>php_stream *</type><parameter>dirstream</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_rewinddir</function> は、 指定されたディレクトリストリームが最初のエントリを指すよう巻き戻します。 成功時に 0 を、失敗時に -1 を返します。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-closedir"> <refnamediv> <refname>php_stream_closedir</refname> <refpurpose>ディレクトリストリームを閉じ、リソースを解放する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis> <type>int</type><methodname>php_stream_closedir</methodname> <methodparam><type>php_stream *</type><parameter>dirstream</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_closedir</function> は、ディレクトリストリームを閉じ、 それに関連付けられたリソースを開放します。 成功時に 0 を、失敗時に -1 を返します。 </para> </refsect1> </refentry> </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/phpdoc-ja/internals/streams/constants.xml?r=1.1&p=1 Index: phpdoc-ja/internals/streams/constants.xml +++ phpdoc-ja/internals/streams/constants.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.1 Maintainer: hirokawa Status: ready --> <!-- CREDITS: shimooka,takagi --> <!-- Author: Wez Furlong <wez@thebrainroom.com> Please contact me before making any major amendments to the content of this section. Splitting/Merging are fine if they are required for php-doc restructuring purposes - just drop me a line if you make a change (so I can update my local copy). --> <sect1 id="streams.constants"> <title>ストリーム定数</title> <refentry id="streams.options"> <refnamediv> <refname>ストリームをオープンする際のオプション</refname> <refpurpose>ストリーム生成関数の処理を設定する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <para> これらの値は OR 演算子を使って一つ以上組み合わることができます。 <variablelist> <varlistentry> <term> <constant>IGNORE_PATH</constant> </term> <listitem> <simpara> これはストリームのデフォルトのオプションです。要求されたファイルに ついて、include_path に列挙されたパスを検索しないようにします。 </simpara> </listitem> </varlistentry> <varlistentry> <term> <constant>USE_PATH</constant> </term> <listitem> <simpara> 要求されたファイルについて、include_path で列挙されたパスも検索します。 </simpara> </listitem> </varlistentry> <varlistentry> <term> <constant>IGNORE_URL</constant> </term> <listitem> <simpara> ストリームを開く際に、登録された URL ラッパーの存在を無視します。 非 URL ラッパーについては考慮され、これらがパスをデコードします。 このフラグの逆はありません; ストリームAPIは登録されたすべての ラッパーをデフォルトで使用しようとします。 </simpara> </listitem> </varlistentry> <varlistentry> <term> <constant>IGNORE_URL_WIN</constant> </term> <listitem> <simpara> Windows においては、IGNORE_URL と等価です。 他のシステムでは効果はありません。 </simpara> </listitem> </varlistentry> <varlistentry> <term> <constant>ENFORCE_SAFE_MODE</constant> </term> <listitem> <simpara> ファイルを開く前に、ストリームの背後の実装が safe_mode チェックを ファイルに対して行うよう指示します。 このフラグを省くと、safe_mode チェックが行われず、PHP プロセスが アクセス権をもつすべてのファイルに対してオープンが可能になります。 </simpara> </listitem> </varlistentry> <varlistentry> <term> <constant>REPORT_ERRORS</constant> </term> <listitem> <simpara> このフラグがセットされていて、ファイルまたは URL を開く際に何らかのエラーが 発生した場合に、ストリーム API は php_error 関数をあなたの代わりに 実行します。これは、パスや URL がユーザ名やパスワードなど エラー時にブラウザに表示されるべきでない情報を含むときに (それがセキュリティー上のリスクになるため) 有用です。 ストリーム API がエラーを出すときは、まずユーザ名やパスワードといった 情報をパスから取り除いた後で、エラーメッセージを安全な形にしてから エラーを出力します。 </simpara> </listitem> </varlistentry> <varlistentry> <term> <constant>STREAM_MUST_SEEK</constant> </term> <listitem> <simpara> このフラグは、拡張モジュール内で、本当にストリームをランダムにシーク する必要があるときに有用です。 いくつかの種類のストリームはそのままの形ではシークができないことが あるので、このフラグをセットしておくと、ストリーム API は、 まず開かれたストリームがシーク可能かどうかを調べ、シークできない場合は、 ストリームのデータをシーク可能な一時的なストレージ (テンポラリファイル あるいはメモリーストリーム) にコピーします。 このフラグは、ストリームに対してシーク動作を行ってから書き込みを行うような 場合には適していません。アクセス対象のストリームは当初アクセスを要求した リソースに必ずしも関連付けられているとは限らないからです。 </simpara> <note> <simpara> もし、要求されたリソースがネットワークベースであった場合、 この関数は、すべてのデータが読み込まれるまでブロックします。 </simpara> </note> </listitem> </varlistentry> <varlistentry> <term> <constant>STREAM_WILL_CAST</constant> </term> <listitem> <simpara> もしあなたの拡張モジュールがサードパーティのライブラリを利用していて、 そのライブラリには FILE* かファイルディスクリプタを渡さなくては ならないとき、このフラグを使うと、ストリーム API にリソースを オープンしても、バッファリングは行わないよう指示することができます。 その後、<function>php_stream_cast</function> を使い、そのライブラリの 必要とする FILE* や ファイルディスクリプタを取得できます。 </simpara> <simpara> このフラグは HTTP URL にアクセスしたとき、 実際のストリームのデータが不定なオフセットの先から始まるような 場合において、特に有用です。 </simpara> <simpara> このオプションはストリーム API のレベルでのバッファリングを 無効にするため、ストリーム関数のパフォーマンスが悪くなるかも しれませんが、このオプションを利用するということは、あなたが ストリームの背後にある実装に合わせるよう ストリーム API 関数を使うことをストリームに宣言したということ ですから、それは許容範囲内と考えられます。 このオプションは本当に必要だと確信があるときにのみ用いてください。 </simpara> </listitem> </varlistentry> </variablelist> </para> </refsect1> </refentry> </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/phpdoc-ja/internals/streams/common.xml?r=1.1&p=1 Index: phpdoc-ja/internals/streams/common.xml +++ phpdoc-ja/internals/streams/common.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.1 Maintainer: hirokawa Status: ready --> <!-- CREDITS: shimooka,takagi --> <!-- Author: Wez Furlong <wez@thebrainroom.com> Please contact me before making any major amendments to the content of this section. Splitting/Merging are fine if they are required for php-doc restructuring purposes - just drop me a line if you make a change (so I can update my local copy). --> <sect1 id="streams.common-api"> <title>ストリーム共通APIリファレンス</title> <refentry id="streams.php-stream-stat-path"> <refnamediv> <refname>php_stream_stat_path</refname> <refpurpose>ファイルまたはURLのステータスを得る</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_stream_stat_path</methodname> <methodparam><type>char *</type><parameter>path</parameter></methodparam> <methodparam><type>php_stream_statbuf *</type><parameter>ssb</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_stat_path</function> は、 <parameter>path</parameter>で指定したファイルまたはURLを調べ、 ファイルサイズ、アクセス権、作成日時といった情報を返します。 返り値は成功時に0、エラー時に-1となります。返される情報の詳細に ついては、 <link linkend="streams.struct-php-stream-statbuf">php_stream_statbuf</link> を参照ください。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-stat"> <refnamediv> <refname>php_stream_stat</refname> <refpurpose>ストリームを保持するストレージに関する情報を得る</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_stream_stat</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> <methodparam><type>php_stream_statbuf *</type><parameter>ssb</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_stat</function> は、<parameter>stream</parameter> にバインドされているストレージに関する情報を調べ、ファイルサイズ、 アクセス権、作成日時といった情報を返します。 返り値は成功時に0、エラー時に-1となります。返される情報の詳細に ついては、 <link linkend="streams.struct-php-stream-statbuf">php_stream_statbuf</link> を参照ください。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-open-wrapper"> <refnamediv> <refname>php_stream_open_wrapper</refname> <refpurpose>ファイルまたはURLをオープンする</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>php_stream *</type><methodname>php_stream_open_wrapper</methodname> <methodparam><type>char *</type><parameter>path</parameter></methodparam> <methodparam><type>char *</type><parameter>mode</parameter></methodparam> <methodparam><type>int</type><parameter>options</parameter></methodparam> <methodparam><type>char **</type><parameter>opened</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_open_wrapper</function> は <parameter>path</parameter> で指定されたファイルやURLなどのラップされたリソースのストリームを開きます。 <parameter>mode</parameter> によって、ストリームを読み出し用、書き出し用、 追記用、あるいはその組み合わせで開くことができます。指定できる種々のモード については下記の表をご覧ください。それらの文字列に加え、文字 'b' を モード文字列の2文字目、または末尾に含めることができます。 この文字 'b' は、該当するストリームの実装に対し、バイナリセーフなモードで ストリームを開くよう指示します。 </para> <para> 文字 'b' は、すべての POSIX に準拠したシステム上では、バイナリファイルと テキストファイルが同列に扱われるため、無視されます。アクセスするデータ において、8 ビットすべてが重要な際には、この 'b' 文字を指定しておくのは、 'b' フラグが意味を持つシステムでも同じスクリプトを動かせるので、 よいアイディアといえます。 </para> <para> ストリーム API によって作成されたすべてのローカルにあるファイルの パーミッションは、オペレーティングシステムのデフォルトに従って 設定されます - Unix ベースのシステムでは、ファイルを作成したプロセスの umask が反映されます。また、Windows では、ファイルを作成したプロセスが ファイルを所有します。 リモートにあるファイルについては、ファイルを開くのに用いた URL ラッパー の設定や、リモートのサーバに与えられた信頼情報に応じて作成されます。 </para> <para> <variablelist> <varlistentry> <term> <constant>r</constant> </term> <listitem> <simpara> ファイルを読み出し用に開きます。このとき、ストリームの位置は、 ファイルの先頭に移動されます。 </simpara> </listitem> </varlistentry> <varlistentry> <term> <constant>r+</constant> </term> <listitem> <simpara> ファイルを読み書き用に開きます。このとき、ストリームの位置は、 ファイルの先頭に移動されます。 </simpara> </listitem> </varlistentry> <varlistentry> <term> <constant>w</constant> </term> <listitem> <simpara> ファイルの内容を長さ 0 に切り詰めるか、新規にファイルを作成し、 書き出しモードで開きます。このとき、ストリームの位置は、 ファイルの先頭に移動されます。 </simpara> </listitem> </varlistentry> <varlistentry> <term> <constant>w+</constant> </term> <listitem> <simpara> ファイルを読み書き用に開きます。もし指定されたファイルが存在 しない場合は、新規に作成し、存在する場合は、長さを切り詰めます。 このとき、ストリームの位置は、ファイルの先頭に移動されます。 </simpara> </listitem> </varlistentry> <varlistentry> <term> <constant>a</constant> </term> <listitem> <simpara> ファイルを書き出し用に開きます。もしファイルが存在しない場合は、 新規に作成します。このとき、ストリームの位置は、ファイルの 末尾に移動されます。 </simpara> </listitem> </varlistentry> <varlistentry> <term> <constant>a+</constant> </term> <listitem> <simpara> ファイルを読み書き用に開きます。もし指定されたファイルが存在 しない場合は、新規に作成します。このとき、ストリームの位置は、 ファイルの末尾に移動されます。 </simpara> </listitem> </varlistentry> </variablelist> </para> <para> <parameter>options</parameter> は、ストリームへのパスや URL をどのように 解釈するかや、セーフモードチェック、ストリームを開くときにエラーが 発生した場合のアクションに影響します。このオプションに関しては、 <link linkend="streams.options">Stream open options</link> を参照ください。 </para> <para> もし <parameter>opened</parameter> が NULL でなければ、実際に 開かれたファイルやリソースの名前がセットされます。これは、 オプションに include_path に列挙されたパスからファイルを探すよう指示する <constant>USE_PATH</constant> が含まれている時に重要になります。 呼び出し元は、最後にこのパラメータによって返されたファイル名を <function>efree</function> の呼び出しによって開放する必要があります。 </para> <note> <simpara> もし、<constant>STREAM_MUST_SEEK</constant> を <parameter>options</parameter> に指定した場合、<parameter>opened</parameter> に返されたファイルへのパス は、実際に返されるストリームのものと違う場合があります。しかし、これは シーク可能なストリームを作るのに用いられた元のストリームの名前になります。 </simpara> </note> </refsect1> </refentry> <refentry id="streams.php-stream-read"> <refnamediv> <refname>php_stream_read</refname> <refpurpose>ストリームからバッファに指定バイト数読み込む</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>size_t</type><methodname>php_stream_read</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> <methodparam><type>char *</type><parameter>buf</parameter></methodparam> <methodparam><type>size_t</type><parameter>count</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_read</function> は <parameter>count</parameter> バイトで指定されたバイト数まで <parameter>stream</parameter> から データを読み取り、バッファ <parameter>buf</parameter> にコピーします。 </para> <para> <function>php_stream_read</function> は、正常に読み込むことのできた バイト数を返します。読み込みが失敗したのか、ファイルの終端に達したのか をこから知ることはできませんので、<function>php_stream_eof</function> を、<constant>EOF</constant> 条件のテストに使います。 </para> <para> ストリームの内部位置は、次回以降続きから読めるよう、 読み込まれた分だけ進められます。 </para> <para> もし、<parameter>count</parameter> バイトよりも少ないデータしか揃って いない場合、この関数は、ストリームのブロックモードの設定に応じて、 すべてのデータが揃うまでブロックします(待ちます)。デフォルトでは、 ストリームはブロックモードで開かれます。 もし通常のファイルから読み込む場合は、ブロックモードはあまり意味を 持ちません。ストリームが、<constant>EOF</constant> に達した場合は、 <function>php_stream_read</function> は、<parameter>count</parameter> よりも少ない値を返し、次回以降は、0 を返します。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-write"> <refnamediv> <refname>php_stream_write</refname> <refpurpose>バッファからストリームに指定バイト数書き込む</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>size_t</type><methodname>php_stream_write</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> <methodparam><type>const char *</type><parameter>buf</parameter></methodparam> <methodparam><type>size_t</type><parameter>count</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_write</function> は、<parameter>count</parameter> バイトのデータを <parameter>buf</parameter> から <parameter>stream</parameter> に書き出します。 </para> <para> <function>php_stream_write</function> は正常に書き込むことのできた バイト数を返します。もし、何らかのエラーがあった場合は、 書き込むことのできたバイト数は <parameter>count</parameter> よりも 小さくなります。 </para> <para> ストリームの内部位置は、次回以降続きから書き込めるよう、 読み込まれた分だけ進められます。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-eof"> <refnamediv> <refname>php_stream_eof</refname> <refpurpose>ストリームがファイル終端に達したかどうか調べる</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_stream_eof</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_eof</function> は、<parameter>stream</parameter> が、 ファイルの終端に達したかどうかを調べます。 </para> <para> <function>php_stream_eof</function> が 1 を返すということは、 <constant>EOF</constant> に達したことを意味します。0 ならば、 まだ <constant>EOF</constant> でなく、-1 はエラーを意味します。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-getc"> <refnamediv> <refname>php_stream_getc</refname> <refpurpose>ストリームから1バイト読み込む</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_stream_getc</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_getc</function> は <parameter>stream</parameter> から 1 文字読み込み、unsigned char を int としてキャストした形で 返します。 ファイルの終端に達したか、エラーが発生した場合は、 <constant>EOF</constant> を返します。 </para> <para> <function>php_stream_getc</function> のブロックに関する挙動は、 <function>php_stream_read</function> のものと一緒です。 </para> <para> 正常に実行できた場合、ストリームの内部位置は 1 だけ進められます。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-gets"> <refnamediv> <refname>php_stream_gets</refname> <refpurpose>ストリームからバッファに1行分のデータを読み込む</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>char *</type><methodname>php_stream_gets</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> <methodparam><type>char *</type><parameter>buf</parameter></methodparam> <methodparam><type>size_t</type><parameter>maxlen</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_gets</function> は、最大で <parameter>count</parameter>-1 バイトまでのデータを <parameter>stream</parameter> から読み込み、 バッファ <parameter>buf</parameter> にコピーします。読み込みは、 <constant>EOF</constant> あるいは行末記号に到達した時点でストップします。 もし、行末まで読み込まれた場合、行末記号は、<parameter>buf</parameter> の一部として含まれます。NUL 終端文字が、バッファの末尾に付加されます。 </para> <para> <function>php_stream_read</function> は正常に終了すると、<parameter>buf</parameter> を、その他の場合は NULL を返します。 </para> <para> ストリームの内部位置は、次回以降続きから読めるよう、 読み込まれた分だけ進められます。 </para> <para> この関数のブロックに関する挙動は、<function>php_stream_read</function> のものと一緒です。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-close"> <refnamediv> <refname>php_stream_close</refname> <refpurpose>ストリームを閉じる</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_stream_close</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_close</function> は、<parameter>stream</parameter> を 安全にクローズし、それに関連付けられたリソースを同時に開放します。 一旦 <parameter>stream</parameter> を閉じると、その値は不定になります。 再び利用してはいけません。 </para> <para> <function>php_stream_close</function> は正常にストリームを閉じられた 場合、0 を、エラーが発生した場合には、<constant>EOF</constant> を返します。関数の実行の成否にかかわらず、<parameter>stream</parameter> は不定になりますので、この関数の実行後に利用してはいけません。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-flush"> <refnamediv> <refname>php_stream_flush</refname> <refpurpose>ストリームバッファをストレージにフラッシュする</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_stream_flush</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_flush</function> は、<parameter>stream</parameter> の書き込みバッファに保持されたデータを下層にあるストレージに コミットします。 </para> <para> <function>php_stream_flush</function> は、バッファをフラッシュできた場合に あるいは、バッファをフラッシュする必要がなかった場合に、0 を返します。 エラーが発生した場合は、<constant>EOF</constant> を返します。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-seek"> <refnamediv> <refname>php_stream_seek</refname> <refpurpose>ストリーム内で移動する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_stream_seek</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> <methodparam><type>off_t</type><parameter>offset</parameter></methodparam> <methodparam><type>int</type><parameter>whence</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_seek</function> は <parameter>stream</parameter> の内部位置を移動します。 新しい位置は、<parameter>offset</parameter> の値を、 <parameter>whence</parameter> で示された位置に加算することで決定されます。 <parameter>whence</parameter> が <constant>SEEK_SET</constant> にセット されていた場合は、ストリームの開始位置を、<constant>SEEK_CUR</constant> の場合は、ストリームの現在位置を、<constant>SEEK_END</constant> の場合は、 ストリームの終端位置を、それぞれ計算の基準とします。 </para> <para> <function>php_stream_seek</function> は成功時に 0 を、失敗時に -1 を 返します。 </para> <note> <para> すべての種類のストリームがシーク動作をサポートしているわけでは ありませんが、ストリーム API は、<parameter>whence</parameter> <constant>SEEK_CUR</constant> に設定されていて、かつ <parameter>offset</parameter> が正の値の場合、 <function>php_stream_read</function> で <parameter>offset</parameter> バイト分だけ読み込んで、読み込まれた内容を破棄することで、シークを エミュレートしようとします。 </para> <para> エミュレーションは、下層にあるストリームの実装が、シークをサポート していないときのみに行われます。つまり、仮に開かれているストリームが ファイルベースのストリームで、それがシークできないパイプを ラップしていたとしても、ストリーム API はエミュレーションを行いません。 ファイルベースのストリームはシーク動作を実装しているからです。 このとき、シークは失敗し、エラーが呼び出し元に返されます。 </para> </note> </refsect1> </refentry> <refentry id="streams.php-stream-tell"> <refnamediv> <refname>php_stream_tell</refname> <refpurpose>ストリーム内の位置を調べる</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>off_t</type><methodname>php_stream_tell</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_tell</function> は、<parameter>stream</parameter> の 内部位置をストリームの開始位置からの相対値で返します。 エラーが発生した場合は -1 が返されます。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-copy-to-stream"> <refnamediv> <refname>php_stream_copy_to_stream</refname> <refpurpose> あるストリームから別のストリームへデータをコピーする </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>size_t</type><methodname>php_stream_copy_to_stream</methodname> <methodparam><type>php_stream *</type><parameter>src</parameter></methodparam> <methodparam><type>php_stream *</type><parameter>dest</parameter></methodparam> <methodparam><type>size_t</type><parameter>maxlen</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_copy_to_stream</function> は、最大 <parameter>maxlen</parameter> バイトのデータを <parameter>src</parameter> から読み込み、 <parameter>dest</parameter> に書き出したのち、正常にコピーできた バイト数を返します。 </para> <para> <parameter>src</parameter> ストリームにある残りの(内部位置移行にある) データすべてをコピーしたい場合は、 定数 <constant>PHP_STREAM_COPY_ALL</constant> を、 <parameter>maxlen</parameter> に指定してください。 </para> <note> <simpara> この関数は、データを、メモリマップができればそれを使い、 最大限効率的な方法でコピーを行おうとします。 </simpara> </note> </refsect1> </refentry> <refentry id="streams.php-stream-copy-to-mem"> <refnamediv> <refname>php_stream_copy_to_mem</refname> <refpurpose> ストリームから確保されたバッファにデータをコピーする </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>size_t</type><methodname>php_stream_copy_to_mem</methodname> <methodparam><type>php_stream *</type><parameter>src</parameter></methodparam> <methodparam><type>char **</type><parameter>buf</parameter></methodparam> <methodparam><type>size_t</type><parameter>maxlen</parameter></methodparam> <methodparam><type>int</type><parameter>persistent</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_copy_to_mem</function> は <parameter>maxlen</parameter>+1 バイトのバッファを <function>pemalloc</function> (パラメータ <parameter>persistent</parameter> はそのまま渡されます) を使ってバッファを確保したのち、最大 <parameter>maxlen</parameter> バイトを <parameter>src</parameter> から読み込んで、その内容を確保されたバッファに 格納します。 </para> <para> 確保されたバッファを <parameter>buf</parameter> で示されたポインタに 返したのち、正常に読み込めたバイト数を返します。 呼び出し下は、返されたバッファを、同じ <parameter>persistent</parameter> パラメータとともに <function>pefree</function> で開放する必要があります。 </para> <para> <parameter>src</parameter> ストリームにある残りの(内部位置移行にある) データすべてをコピーしたい場合は、 定数 <constant>PHP_STREAM_COPY_ALL</constant> を、 <parameter>maxlen</parameter> に指定してください。 </para> <note> <simpara> この関数は、データを、メモリマップができればそれを使い、 最大限効率的な方法でコピーを行おうとします。 </simpara> </note> </refsect1> </refentry> <refentry id="streams.php-stream-make-seekable"> <refnamediv> <refname>php_stream_make_seekable</refname> <refpurpose>ストリームをシーク可能なストリームへ変換する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_stream_make_seekable</methodname> <methodparam><type>php_stream *</type><parameter>origstream</parameter></methodparam> <methodparam><type>php_stream **</type><parameter>newstream</parameter></methodparam> <methodparam><type>int</type><parameter>flags</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_make_seekable</function> は、まず <parameter>origstream</parameter> が シーク可能かどうか調べます。もしシークできない場合は、新たに一時的ストリーム を作り、元のストリームのデータをすべてそこにコピーします。 成功の場合は、<parameter>newstream</parameter> には、元のストリームが シーク可能だったとしても、常に利用可能なストリームが返されます。 </para> <para> <parameter>flags</parameter> で、どのような形のシーク可能なストリームが 返されるかを指定することができます。デフォルトのシーク可能なストリームを 利用したい場合は、<constant>PHP_STREAM_NO_PREFERENCE</constant> を (通常では動的に増大するメモリ上のバッファを利用するが、 もしストリーム内のデータが巨大な場合は、テンポラリファイルに裏打ちされた ストリームに切り替える)、または通常のテンポラリファイルに裏打ちされた ストリームを利用したい場合は、<constant>PHP_STREAM_PREFER_STDIO</constant> を指定してください。 </para> <para> <table> <title><function>php_stream_make_seekable</function> の返り値</title> <tgroup cols="2"> <thead> <row> <entry>Value</entry> <entry>Meaning</entry> </row> </thead> <tbody> <row> <entry>PHP_STREAM_UNCHANGED</entry> <entry>元のストリームがシーク可能だった。<parameter>newstream</parameter> には <parameter>origstream</parameter> がセットされます。 </entry> </row> <row> <entry>PHP_STREAM_RELEASED</entry> <entry>元のストリームはシーク可能ではないので、開放された。 <parameter>newstream</parameter> には、新たに作成されたシーク可能なストリームがセットされます。 以後、<parameter>origstream</parameter> にアクセスしてはいけません。 </entry> </row> <row> <entry>PHP_STREAM_FAILED</entry> <entry>ストリームの変換中にエラーが発生した。 <parameter>newstream</parameter> には NULL がセットされます。 このとき <parameter>origstream</parameter> はまだ有効なストリームです。 </entry> </row> <row> <entry>PHP_STREAM_CRITICAL</entry> <entry>ストリームの変換中にエラーが発生し、元のストリームは <parameter>origstream</parameter> 不定な状態になっている。<parameter>newstream</parameter> には NULL がセットされます。このときは、<parameter>origstream</parameter> を閉じることを強く推奨します。 </entry> </row> </tbody> </tgroup> </table> </para> <note> <simpara> 新しいストリームに対してシークを行い書き込みを行うような場合、 そのストリームは、必ずしも元のストリームと同じリソースに 関連付けられていると保証されているわけではないので、 この関数を呼び出す意味はあまりありません。 </simpara> </note> <note> <simpara> もし、前方へのシークのみが必要なときは、この関数を利用してストリームを シーク可能にする必要はありません。ストリーム API は、 whence パラメータが <constant>SEEK_CUR</constant> の時、前方シークを エミュレートするからです。 </simpara> </note> <note> <simpara> もし、<parameter>origstream</parameter> がネットワークベースのストリーム の場合は、この関数は、すべてのデータが読み込まれるまでブロックします。 </simpara> </note> <note> <simpara> 絶対に、PHP スクリプト内で使用されているファイルポインタを参照する ストリームを、<parameter>origstream</parameter> に指定しないでください。 この関数は、そのストリームを閉じる場合があるので、スクリプト内で次に そのファイルポインタに対してアクセスが行われた場合に、クラッシュが 起こる可能性があります。 </simpara> </note> <note> <simpara> ほとんどの場合において、この関数は、<parameter>origstream</parameter> が新たに開かれたストリームで、しかもストリーム層においてデータが バッファリングされていない時にのみ成功します。これにより、 また、この関数は正しく使うには多少複雑なので、できれば、 この関数を直接呼び出すのではなく、 <function>php_stream_open_wrapper</function> を使い、 <constant>PHP_STREAM_MUST_SEEK</constant> をオプションとして渡す方法 を検討してみてください。 </simpara> </note> </refsect1> </refentry> <refentry id="streams.php-stream-cast"> <refnamediv> <refname>php_stream_cast</refname> <refpurpose> ストリームをFILE*またはソケットのような他の形式に変換する </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_stream_cast</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> <methodparam><type>int</type><parameter>castas</parameter></methodparam> <methodparam><type>void **</type><parameter>ret</parameter></methodparam> <methodparam><type>int</type><parameter>flags</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_cast</function> は <parameter>stream</parameter> で 指定されたストリームを <parameter>castas</parameter> で指示されたリソースに 変換しようと試みます。 もし、<parameter>ret</parameter> が NULL であった場合は、実際に 変換は行われず、単にストリームに対してそのような変換が可能であるかどうか だけを調べます。(しかし、この場合何らかのストリームの状態が変化することが あります。) もし、<parameter>flags</parameter> に <constant>REPORT_ERRORS</constant> が セットされていた場合は、変換中にエラーがあると、エラーメッセージが 表示されます。 </para> <note> <para> この関数は、成功時に <constant>SUCCESS</constant> を、失敗時に <constant>FAILURE</constant> を返します。 返り値の判定の際は単純に値の真偽を見るのではなく、 定数 <constant>SUCCESS</constant> や <constant>FAILURE</constant> と 明示的に比較しなければならないことに注意してください。 これらの定数値は単純なブール値ではないからです。 </para> </note> <para> <table> <title><parameter>castas</parameter> に指定できるリソースの種類</title> <tgroup cols="2"> <thead> <row> <entry>値</entry> <entry>意味</entry> </row> </thead> <tbody> <row> <entry>PHP_STREAM_AS_STDIO</entry> <entry>ストリームを表す ANSI FILE* ファイルポインタを要求する</entry> </row> <row> <entry>PHP_STREAM_AS_FD</entry> <entry>ストリームを表す POSIX ファイルデスクリプタを要求する</entry> </row> <row> <entry>PHP_STREAM_AS_SOCKETD</entry> <entry>ストリームを表すソケットのデスクリプタを要求する</entry> </row> </tbody> </tgroup> </table> </para> <para> 上に示したような基本的なリソースの種類を指定するのに加え、 変換動作を、リソースの種類を表す値と次に示した値とを OR 演算子で 組み合わせることでしていすることができます: <table> <title>Resource types for <parameter>castas</parameter></title> <tgroup cols="2"> <thead> <row> <entry>値</entry> <entry>意味</entry> </row> </thead> <tbody> <row> <entry>PHP_STREAM_CAST_TRY_HARD</entry> <entry>別のリソースをあえて利用するなど、できるだけ変換が成功するような試行を行う</entry> </row> <row> <entry>PHP_STREAM_CAST_RELEASE</entry> <entry>ストリームAPI に、この関数を呼び出した ストリームAPI 以外のコード (おそらくはサードパーティのライブラリ) の内部で、ストリームがラップしているリソースやハンドルを閉じることを 通知します。これにより、<parameter>stream</parameter> が、 ストリームの背後にあるハンドルそのものを閉じずに <parameter>ret</parameter> に返したところで閉じられます。 このとき、この関数が成功したら、 <parameter>stream</parameter> はその時点で閉じられたと判断されるべきで、 以降そのストリームを使ってはいけません。 </entry> </row> </tbody> </tgroup> </table> </para> <note> <simpara> もし使っているシステム(glibc 2 または以降を使っているシステム)が <function>fopencookie</function> をサポートしている場合、 ストリーム API は常にどのストリームからも ANSI FILE * ポインタを 合成できます。この特長はあらゆる PHP ストリームをサードパーティの ライブラリに渡せるので非常に便利ですが、一方で、移植可能性は高く ありません。この場合は、あなたの作成した拡張モジュールを配布する際に、 移植可能性についての表示を行っておいたほうがよいでしょう。 もし fopencookie による合成が望ましくない場合は、問題とするストリームが ネイティブに FILE* をサポートしているかどうか <function>php_stream_is</function> で調べましょう。 </simpara> </note> <note> <simpara> ソケットベースのストリームを FILE* に変換する際、ストリーム API は <function>fdopen</function> を使ってそれを生成します。 そうすることは、ストリーム API のコールと ANSI 標準入出力 API のコールを 交互に行った際に、ストリーム層においてバッファされたデータが失われる 危険性を生じることに注意してください。 </simpara> </note> <para> <function>php_stream_is</function> と <function>php_stream_can_cast</function> も参照ください。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-can-cast"> <refnamediv> <refname>php_stream_can_cast</refname> <refpurpose> ストリームがFILE*またはソケットのような他の形式に変換できるかどうかを 調べる </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_stream_can_cast</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> <methodparam><type>int</type><parameter>castas</parameter></methodparam> </methodsynopsis> <para> この関数の挙動は、<function>php_stream_cast</function> の <parameter>ret</parameter> 引数を NULL にし、<parameter>flags</parameter> を 0 にした時の呼び出しと等価です。 要求された形にストリームが変換できるときは、<constant>SUCCESS</constant> を、変換ができないときは、<constant>FAILURE</constant> を返します。 </para> <note> <simpara> この関数は実際に変換を行うわけではありませんが、何らかのストリームの状態が 変化する可能性があります。 </simpara> </note> <note> <simpara> この関数の返り値は、<function>php_stream_cast</function> で説明されたように、 明示的に定数と比較される必要があります。 </simpara> </note> <para> <function>php_stream_cast</function> と <function>php_stream_is</function> も参照ください。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-is-persistent"> <refnamediv> <refname>php_stream_is_persistent</refname> <refpurpose> ストリームが持続的なストリームであるかどうかを調べる </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_stream_is_persistent</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_is_persistent</function> は、ストリームが恒久的であると、1 を、そうでない場合は 0 を返します。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-is"> <refnamediv> <refname>php_stream_is</refname> <refpurpose>ストリームが特定の型であるかどうかを調べる</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_stream_is</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> <methodparam><type>int</type><parameter>istype</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_is</function> は <parameter>stream</parameter> が <parameter>istype</parameter> で指定された型である時に 1 を、そうでない場合に 0 を返します。 <table> <title><parameter>istype</parameter>に指定できる値</title> <tgroup cols="2"> <thead> <row> <entry>値</entry> <entry>意味</entry> </row> </thead> <tbody> <row> <entry>PHP_STREAM_IS_STDIO</entry> <entry>ストリームは標準入出力の実装を用いて実装されている</entry> </row> <row> <entry>PHP_STREAM_IS_SOCKET</entry> <entry>ストリームはソケットを用いて実装されている</entry> </row> <row> <entry>PHP_STREAM_IS_USERSPACE</entry> <entry>ストリームはユーザ空間にあるオブジェクトを用いて実装されている</entry> </row> <row> <entry>PHP_STREAM_IS_MEMORY</entry> <entry>ストリームは動的にサイズを増やすメモリーストリームの実装を用いて実装されている</entry> </row> </tbody> </tgroup> </table> </para> <note> <simpara> PHP_STREAM_IS_XXX "定数は" 実際には、ストリーム操作を定義する構造体への ポインタです。もしあなたの拡張モジュールや、別の拡張モジュール内で、 新たなストリームの実装が定義されている場合、同時にこの関数による比較に 使えるような PHP_STREAM_IS_XXX 定数をそのヘッダーファイル内で 定義しておくべきです。 </simpara> </note> <note> <simpara> この関数は、単純な(かつ高速な) ポインターの比較だけを行うよう 実装されており、ストリームの状態を変更することはありません。 </simpara> </note> <para> <function>php_stream_cast</function> や <function>php_stream_can_cast</function> も参照ください。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-passthru"> <refnamediv> <refname>php_stream_passthru</refname> <refpurpose>ストリームから残りのデータを全て出力する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>size_t</type><methodname>php_stream_passthru</methodname> <methodparam><type>php_stream *</type><parameter>stream</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_passthru</function> は、<parameter>stream</parameter> に残されたすべてのデータを、現在有効な出力バッファに対して出力し、 何バイト出力されたかを返します。 もし出力バッファリングが無効になっている場合は、データは 直接出力先に書き込まれます。この出力先は、PHP がウェブサーバの上で 動いている際にはブラウザになり、CLI ベースの PHP の場合は標準出力 となります。 この関数はパフォーマンス向上のため、可能であればメモリマッピング を利用します。 </para> </refsect1> </refentry> <refentry id="streams.php-register-url-stream-wrapper"> <refnamediv> <refname>php_register_url_stream_wrapper</refname> <refpurpose>ストリームAPI用のラッパを登録する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_register_url_stream_wrapper</methodname> <methodparam><type>char *</type><parameter>protocol</parameter></methodparam> <methodparam><type>php_stream_wrapper *</type><parameter>wrapper</parameter></methodparam> <methodparam><type>TSRMLS_DC</type><parameter></parameter></methodparam> </methodsynopsis> <para> <function>php_register_url_stream_wrapper</function> は <parameter>wrapper</parameter> を <parameter>protocol</parameter> で指定されたハンドラとして 登録します。 </para> <note> <simpara> もしこの関数をロード可能なモジュールから呼び出す場合、 必ず <function>php_unregister_url_stream_wrapper</function> を そのモジュールのシャットダウンルーチンから呼び出してください。 そうしないと、PHP はクラッシュしてしまいます。 </simpara> </note> </refsect1> </refentry> <refentry id="streams.php-unregister-url-stream-wrapper"> <refnamediv> <refname>php_unregister_url_stream_wrapper</refname> <refpurpose>ストリームAPI用のラッパの登録を解除する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>int</type><methodname>php_unregister_url_stream_wrapper</methodname> <methodparam><type>char *</type><parameter>protocol</parameter></methodparam> <methodparam><type>TSRMLS_DC</type><parameter></parameter></methodparam> </methodsynopsis> <para> <function>php_unregister_url_stream_wrapper</function> は <parameter>protocol</parameter> に関連付けられたラッパーの登録を解除します。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-open-wrapper-ex"> <refnamediv> <refname>php_stream_open_wrapper_ex</refname> <refpurpose> コンテキストを指定して、ファイルまたはURLにストリームをオープンする </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>php_stream *</type><methodname>php_stream_open_wrapper_ex</methodname> <methodparam><type>char *</type><parameter>path</parameter></methodparam> <methodparam><type>char *</type><parameter>mode</parameter></methodparam> <methodparam><type>int</type><parameter>options</parameter></methodparam> <methodparam><type>char **</type><parameter>opened</parameter></methodparam> <methodparam><type>php_stream_context *</type><parameter>context</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_open_wrapper_ex</function> は <function>php_stream_open_wrapper</function> と非常に似ていますが、 php_stream_context オブジェクトを <parameter>context</parameter> で 指定することができる点で異なります。 ストリームコンテキストに関する詳細は <link linkend="stream.contexts">ストリームコンテキスト</link> を参照ください。 </para> </refsect1> </refentry> <refentry id="streams.php-stream-open-wrapper-as-file"> <refnamediv> <refname>php_stream_open_wrapper_as_file</refname> <refpurpose> ファイルまたはURLをオープンし、FILE*に変換する </refpurpose> </refnamediv> <refsect1> <title>説明</title> <methodsynopsis role="c"> <type>FILE *</type><methodname>php_stream_open_wrapper_as_file</methodname> <methodparam><type>char *</type><parameter>path</parameter></methodparam> <methodparam><type>char *</type><parameter>mode</parameter></methodparam> <methodparam><type>int</type><parameter>options</parameter></methodparam> <methodparam><type>char **</type><parameter>opened</parameter></methodparam> </methodsynopsis> <para> <function>php_stream_open_wrapper_as_file</function> は <function>php_stream_open_wrapper</function> と非常に似ていますが、 ストリームを ANSI 標準入出力の FILE* ポインタに変換してストリームの代わりに それを返す点が異なります。 この関数は、サードパーティのライブラリに FILE* を直接渡すための 近道として用意されています。 </para> </refsect1> </refentry> </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.doc.ja (#1153) next »