[PHP-DOC] cvs: phpdoc /en/reference/stream reference.xml /en/reference/stream/functions stream-filter-append.xml stream-filter-prepend.xml From: Sara Golemon (php <email protected>)
Date: 02/20/03

pollita Thu Feb 20 14:10:24 2003 EDT

  Modified files:
    /phpdoc/en/reference/stream reference.xml
    /phpdoc/en/reference/stream/functions stream-filter-append.xml
                                                 stream-filter-prepend.xml
  Log:
  Changes per filter chain splits
  
  
Index: phpdoc/en/reference/stream/reference.xml
diff -u phpdoc/en/reference/stream/reference.xml:1.9 phpdoc/en/reference/stream/reference.xml:1.10
--- phpdoc/en/reference/stream/reference.xml:1.9 Tue Feb 4 07:12:03 2003
+++ phpdoc/en/reference/stream/reference.xml Thu Feb 20 14:10:23 2003
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.9 $ -->
+<!-- $Revision: 1.10 $ -->
  <reference id="ref.stream">
   <title>Stream functions</title>
   <titleabbrev>Streams</titleabbrev>
@@ -110,6 +110,32 @@
         </row>
        </thead>
        <tbody>
+ <row>
+ <entry><constant>STREAM_FILTER_READ</constant></entry>
+ <entry>
+ Used with <function>stream_filter_append</function> and
+ <function>stream_filter_prepend</function> to indicate
+ that the specified filter should only be applied when
+ <emphasis>reading</emphasis>
+ </entry>
+ </row>
+ <row>
+ <entry><constant>STREAM_FILTER_WRITE</constant></entry>
+ <entry>
+ Used with <function>stream_filter_append</function> and
+ <function>stream_filter_prepend</function> to indicate
+ that the specified filter should only be applied when
+ <emphasis>writting</emphasis>
+ </entry>
+ </row>
+ <row>
+ <entry><constant>STREAM_FILTER_ALL</constant></entry>
+ <entry>
+ This constant is equivalent to
+ <literal><constant>STREAM_FILTER_READ</constant> |
+ <constant>STREAM_FILTER_WRITE</constant></literal>
+ </entry>
+ </row>
         <row>
          <entry><constant>STREAM_USE_PATH</constant></entry>
          <entry><literal>Flag</literal> indicating if the <literal>stream</literal>
Index: phpdoc/en/reference/stream/functions/stream-filter-append.xml
diff -u phpdoc/en/reference/stream/functions/stream-filter-append.xml:1.2 phpdoc/en/reference/stream/functions/stream-filter-append.xml:1.3
--- phpdoc/en/reference/stream/functions/stream-filter-append.xml:1.2 Mon Jan 6 20:57:08 2003
+++ phpdoc/en/reference/stream/functions/stream-filter-append.xml Thu Feb 20 14:10:24 2003
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
   <refentry id="function.stream-filter-append">
    <refnamediv>
     <refname>stream_filter_append</refname>
@@ -11,6 +11,7 @@
       <type>bool</type><methodname>stream_filter_append</methodname>
       <methodparam><type>resource</type><parameter>stream</parameter></methodparam>
       <methodparam><type>string</type><parameter>filtername</parameter></methodparam>
+ <methodparam choice="opt"><type>int</type><parameter>read_write</parameter></methodparam>
       <methodparam choice="opt"><type>string</type><parameter>params</parameter></methodparam>
      </methodsynopsis>
     <para>
@@ -22,7 +23,62 @@
      add a filter to the beginning of the list, use
      <function>stream_filter_prepend</function>.
     </para>
+ <para>
+ By default, <function>stream_filter_append</function> will
+ attach the filter to the <literal>read filter chain</literal>
+ if the file was opened for reading (i.e. File Mode:
+ <literal>r</literal>, and/or <literal>+</literal>). The filter
+ will also be attached to the <literal>write filter chain</literal>
+ if the file was opened for writting (i.e. File Mode:
+ <literal>w</literal>, <literal>a</literal>, and/or <literal>+</literal>).
+ <constant>STREAM_FILTER_READ</constant>,
+ <constant>STREAM_FILTER_WRITE</constant>, and/or
+ <constant>STREAM_FILTER_ALL</constant> can also be passed to the
+ <parameter>read_write</parameter> parameter to override this behavior.
+ </para>
+ <para>
+ <example>
+ <title>Controlling where filters are applied</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+/* Open a test file for reading and writting */
+$fp = fopen("test.txt","rw");
+
+/* Apply the ROT13 filter to the
+ * write filter chain, but not the
+ * read filter chain */
+stream_filter_append($fp, "string.rot13", STREAM_FILTER_WRITE);
+
+/* Write a simple string to the file
+ * it will be ROT13 transformed on the
+ * way out */
+fwrite($fp, "This is a test\n");
+
+/* Back up to the beginning of the file */
+rewind($fp);
+
+/* Read the contents of the file back out.
+ * Had the filter been applied to the
+ * read filter chain as well, we would see
+ * the text ROT13ed back to its original state */
+fpassthru($fp);
+
+fclose($fp);
+
+/* Expected Output
+ ---------------
+
+Guvf vf n grfg
+
+ */
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
     <note>
+ <title>When using custom (user) filters</title>
      <simpara>
       <function>stream_register_filter</function> must be called first
       in order to register the desired user filter to <parameter>filtername</parameter>.
Index: phpdoc/en/reference/stream/functions/stream-filter-prepend.xml
diff -u phpdoc/en/reference/stream/functions/stream-filter-prepend.xml:1.2 phpdoc/en/reference/stream/functions/stream-filter-prepend.xml:1.3
--- phpdoc/en/reference/stream/functions/stream-filter-prepend.xml:1.2 Mon Jan 6 20:57:08 2003
+++ phpdoc/en/reference/stream/functions/stream-filter-prepend.xml Thu Feb 20 14:10:24 2003
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
   <refentry id="function.stream-filter-prepend">
    <refnamediv>
     <refname>stream_filter_prepend</refname>
@@ -11,18 +11,35 @@
       <type>bool</type><methodname>stream_filter_prepend</methodname>
       <methodparam><type>resource</type><parameter>stream</parameter></methodparam>
       <methodparam><type>string</type><parameter>filtername</parameter></methodparam>
+ <methodparam choice="opt"><type>int</type><parameter>read_write</parameter></methodparam>
       <methodparam choice="opt"><type>string</type><parameter>params</parameter></methodparam>
      </methodsynopsis>
     <para>
- Adds <parameter>filtername</parameter> to the list of filters
+ Adds <parameter>filtername</parameter> to the list of filters
      attached to <parameter>stream</parameter>. This filter will be
      added with the specified <parameter>params</parameter>
      to the <emphasis>beginning</emphasis> of the list and
      will therefore be called first during stream opperations. To
- add a filter to the end of the list, use
+ add a filter to the end of the list, use
      <function>stream_filter_append</function>.
     </para>
+ <para>
+ By default, <function>stream_filter_prepend</function> will
+ attach the filter to the <literal>read filter chain</literal>
+ if the file was opened for reading (i.e. File Mode:
+ <literal>r</literal>, and/or <literal>+</literal>). The filter
+ will also be attached to the <literal>write filter chain</literal>
+ if the file was opened for writting (i.e. File Mode:
+ <literal>w</literal>, <literal>a</literal>, and/or <literal>+</literal>).
+ <constant>STREAM_FILTER_READ</constant>,
+ <constant>STREAM_FILTER_WRITE</constant>, and/or
+ <constant>STREAM_FILTER_ALL</constant> can also be passed to the
+ <parameter>read_write</parameter> parameter to override this behavior.
+ See <function>stream_filter_append</function> for an example of
+ using this parameter.
+ </para>
     <note>
+ <title>When using custom (user) filters</title>
      <simpara>
       <function>stream_register_filter</function> must be called first
       in order to register the desired user filter to <parameter>filtername</parameter>.

-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php