Home | History | Annotate | only in /PHP_TRUNK
Up to higher level directory
NameDateSize
.gdbinit11-Mar-201212K
acinclude.m427-Dec-201176.2K
build/09-Aug-2011
buildconf06-Mar-2012817
buildconf.bat23-Mar-2010334
CODING_STANDARDS23-Mar-201010.9K
config.guess23-Mar-201043.8K
config.sub23-Mar-201032.6K
configure.in01-Mar-201244.4K
CREDITS23-Mar-201091
ext/20-Nov-2010
EXTENSIONS04-Dec-201124.3K
footer23-Mar-2010137
genfiles23-Mar-2010486
header01-Jan-20121.2K
INSTALL27-Apr-201191.6K
LICENSE05-Oct-20103.1K
ltmain.sh23-Mar-2010195K
main/08-Mar-2012
makedist23-Mar-20103.5K
Makefile.frag23-Mar-20101K
Makefile.gcov20-Feb-20122.4K
Makefile.global13-Nov-20105.4K
makerpm23-Mar-20105.2K
netware/23-Mar-2010
NEWS04-Mar-20121.9K
pear/09-Jun-2010
php.gif23-Mar-20102.5K
php.ini-development17-Mar-201265.3K
php.ini-production17-Mar-201265.3K
php5.spec.in23-Mar-20101.5K
README.EXT_SKEL23-Mar-20106.1K
README.EXTENSIONS23-Mar-20101.5K
README.input_filter09-Jun-20105.3K
README.MAILINGLIST_RULES23-Mar-20103.3K
README.namespaces23-Mar-20105.9K
README.NEW-OUTPUT-API09-Jun-20105.5K
README.PARAMETER_PARSING_API07-Jun-20116.8K
README.PHP4-TO-PHP5-THIN-CHANGES23-Mar-20104.6K
README.REDIST.BINS18-Jul-201120.4K
README.RELEASE_PROCESS03-Feb-201211K
README.SELF-CONTAINED-EXTENSIONS23-Mar-20104.7K
README.STREAMS23-Mar-201015.1K
README.SUBMITTING_PATCH09-Jun-20107.4K
README.SVN-RULES14-Nov-20115.8K
README.TESTING23-Mar-20106.5K
README.TESTING223-Mar-20104.8K
README.UNIX-BUILD-SYSTEM23-Mar-20104.2K
README.WIN32-BUILD-SYSTEM23-Mar-2010109
README.Zeus23-Mar-20104.2K
run-tests.php17-Mar-201274.8K
sapi/09-Jun-2010
scripts/07-Jun-2011
server-tests-config.php23-Mar-20102.1K
server-tests.php23-Mar-201050.5K
snapshot23-Mar-2010108
stamp-h.in23-Mar-201010
stub.c23-Mar-20101
svnclean.bat23-Mar-201050
tests/23-Mar-2010
TSRM/30-Jan-2012
UPGRADING05-Mar-20121.9K
UPGRADING.INTERNALS22-Feb-2012831
vcsclean23-Mar-2010297
win32/04-Mar-2012
Zend/11-Mar-2012

README.EXT_SKEL

      1 (NOTE: you may also want to take a look at the pear package
      2 	     PECL_Gen, a PHP-only alternative for this script that
      3 			 supports way more extension writing tasks and is 
      4 			 supposed to replace ext_skel completely in the long run ...)
      5 
      6 WHAT IT IS
      7 
      8   It's a tool for automatically creating the basic framework for a PHP module
      9   and writing C code handling arguments passed to your functions from a simple
     10   configuration file. See an example at the end of this file.
     11 
     12 HOW TO USE IT
     13 
     14   Very simple. First, change to the ext/ directory of the PHP 4 sources. If
     15   you just need the basic framework and will be writing all the code in your
     16   functions yourself, you can now do
     17 
     18    ./ext_skel --extname=module_name
     19 
     20   and everything you need is placed in directory module_name. 
     21 
     22   [ Note that GNU awk is likely required for this script to work.  Debian 
     23     systems seem to default to using mawk, so you may need to change the 
     24     #! line in skeleton/create_stubs and the cat $proto | awk line in
     25     ext_skel to use gawk explicitly. ]
     26 
     27   If you don't need to test the existence of any external header files, 
     28   libraries or functions in them, the module is already almost ready to be 
     29   compiled in PHP.  Just remove 3 comments in your_module_name/config.m4, 
     30   change back up to PHP sources top directory, and do
     31 
     32     ./buildconf; ./configure --enable-module_name; make
     33 
     34   But if you already have planned the overall scheme of your module, what
     35   functions it will contain, their return types and the arguments they take
     36   (a very good idea) and don't want to bother yourself with creating function
     37   definitions and handling arguments passed yourself, it's time to create a
     38   function definitions file, which you will give as an argument to ext_skel
     39   with option
     40 
     41     --proto=filename.
     42 
     43 FORMAT OF FUNCTION DEFINITIONS FILE
     44 
     45   All the definitions must be on one line. In it's simplest form, it's just
     46   the function name, e.g.
     47 
     48     my_function
     49 
     50   but then you'll be left with an almost empty function body without any
     51   argument handling.
     52 
     53   Arguments are given in parenthesis after the function name, and are of
     54   the form 'argument_type argument_name'. Arguments are separated from each
     55   other with a comma and optional space. Argument_type can be one of int,
     56   bool, double, float, string, array, object or mixed.
     57 
     58   An optional argument is separated from the previous by an optional space,
     59   then '[' and of course comma and optional space, like all the other
     60   arguments. You should close a row of optional arguments with same amount of
     61   ']'s as there where '['s. Currently, it does not harm if you forget to do it
     62   or there is a wrong amount of ']'s, but this may change in the future.
     63 
     64 	An additional short description may be added after the parameters. 
     65   If present it will be filled into the 'proto' header comments in the stubs
     66   code and the <refpurpose> tag in the XML documentation.
     67 
     68   An example:
     69 
     70     my_function(int arg1, int arg2 [, int arg3 [, int arg4]]) this is my 1st
     71 
     72   Arguments arg3 and arg4 are optional.
     73 
     74   If possible, the function definition should also contain it's return type
     75   in front of the definition. It's not actually used for any C code generating
     76   purposes but PHP in-source documentation instead, and as such, very useful.
     77   It can be any of int, double, string, bool, array, object, resource, mixed
     78   or void.
     79 
     80   The file must contain nothing else but function definitions, no comments or
     81   empty lines.
     82 
     83 OTHER OPTIONS
     84 
     85     --no-help
     86 
     87   By default, ext_skel creates both comments in the source code and a test
     88   function to help first time module writers to get started and testing
     89   configuring and compiling their module. This option turns off all such things
     90   which may just annoy experienced PHP module coders. Especially useful with
     91 
     92     --stubs=file
     93 
     94   which will leave out also all module specific stuff and write just function
     95   stubs with function value declarations and passed argument handling, and
     96   function entries and definitions at the end of the file, for copying and
     97   pasting into an already existing module.
     98 
     99     --xml[=file]
    100 
    101   Creates the basics for phpdoc .xml file.
    102 
    103     --full-xml
    104 
    105   Not implemented yet. When or if there will ever be created a framework for
    106   self-contained extensions to use phpdoc system for their documentation, this
    107   option enables it on the created xml file.
    108 
    109 CURRENT LIMITATIONS, BUGS AND OTHER ODDITIES
    110 
    111   Only arguments of types int, bool, double, float, string and array are
    112   handled. For other types you must write the code yourself. And for type
    113   mixed, it wouldn't even be possible to write anything, because only you
    114   know what to expect.
    115   
    116   It can't handle correctly, and probably never will, variable list of
    117   of arguments. (void foo(int bar [, ...])
    118 
    119   Don't trust the generated code too much. It tries to be useful in most of
    120   the situations you might encounter, but automatic code generation will never
    121   beat a programmer who knows the real situation at hand. ext_skel is generally
    122   best suited for quickly generating a wrapper for c-library functions you
    123   might want to have available in PHP too.
    124 
    125   This program doesn't have a --help option. It has --no-help instead.
    126 
    127 EXAMPLE
    128 
    129   The following _one_ line
    130 
    131   bool my_drawtext(resource image, string text, resource font, int x, int y [, int color])
    132 
    133   will create this function definition for you (note that there are a few
    134   question marks to be replaced by you, and you must of course add your own
    135   value definitions too):
    136 
    137 /* {{{ proto bool my_drawtext(resource image, string text, resource font, int x, int y [, int color])
    138     */
    139 PHP_FUNCTION(my_drawtext)
    140 {
    141     char *text = NULL;
    142     int argc = ZEND_NUM_ARGS();
    143     int image_id = -1;
    144     int text_len;
    145     int font_id = -1;
    146     long x;
    147     long y;
    148     long color;
    149     zval *image = NULL;
    150     zval *font = NULL;
    151 
    152     if (zend_parse_parameters(argc TSRMLS_CC, "rsrll|l", &image, &text, &text_len, &font, &x, &y, &color) == FAILURE)
    153         return;
    154 
    155     if (image) {
    156         ZEND_FETCH_RESOURCE(???, ???, image, image_id, "???", ???_rsrc_id);
    157     }
    158     if (font) {
    159         ZEND_FETCH_RESOURCE(???, ???, font, font_id, "???", ???_rsrc_id);
    160     }
    161 
    162     php_error(E_WARNING, "my_drawtext: not yet implemented");
    163 }
    164 /* }}} */
    165 
    166 

README.EXTENSIONS

      1 Between PHP 4.0.6 and 4.1.0, the Zend module struct changed in a way
      2 that broke both source and binary compatibility.  If you are
      3 maintaining a third party extension, here's how to update it:
      4 
      5 If this was your old module entry:
      6 
      7 zend_module_entry foo_module_entry = {
      8     "foo",                /* extension name */
      9     foo_functions,        /* extension function list */
     10     NULL,                 /* extension-wide startup function */
     11     NULL,                 /* extension-wide shutdown function */
     12     PHP_RINIT(foo),       /* per-request startup function */
     13     PHP_RSHUTDOWN(foo),   /* per-request shutdown function */
     14     PHP_MINFO(foo),       /* information function */
     15     STANDARD_MODULE_PROPERTIES
     16 };
     17 
     18 Here's how it should look if you want your code to build with PHP
     19 4.1.0 and up:
     20 
     21 zend_module_entry foo_module_entry = {
     22 #if ZEND_MODULE_API_NO >= 20010901
     23     STANDARD_MODULE_HEADER,
     24 #endif
     25     "foo",                /* extension name */
     26     foo_functions,        /* extension function list */
     27     NULL,                 /* extension-wide startup function */
     28     NULL,                 /* extension-wide shutdown function */
     29     PHP_RINIT(foo),       /* per-request startup function */
     30     PHP_RSHUTDOWN(foo),   /* per-request shutdown function */
     31     PHP_MINFO(foo),       /* information function */
     32 #if ZEND_MODULE_API_NO >= 20010901
     33     FOO_VERSION,          /* extension version number (string) */
     34 #endif
     35     STANDARD_MODULE_PROPERTIES
     36 };
     37 
     38 If you don't care about source compatibility with earlier PHP releases
     39 than 4.1.0, you can drop the #if/#endif lines.
     40 

README.input_filter

      1 Input Filter Support in PHP 5
      2 -----------------------------
      3 
      4 XSS (Cross Site Scripting) hacks are becoming more and more prevalent,
      5 and can be quite difficult to prevent.  Whenever you accept user data
      6 and somehow display this data back to users, you are likely vulnerable
      7 to XSS hacks.
      8 
      9 The Input Filter support in PHP 5 is aimed at providing the framework
     10 through which a company-wide or site-wide security policy can be
     11 enforced.  It is implemented as a SAPI hook and is called from the
     12 treat_data and post handler functions.  To implement your own security
     13 policy you will need to write a standard PHP extension.  There is also
     14 a powerful standard implementation in ext/filter that should suit most
     15 peoples' needs.  However, if you want to implement your own security 
     16 policy, read on.
     17 
     18 A simple implementation might look like the following.  This stores the
     19 original raw user data and adds a my_get_raw() function while the normal
     20 $_POST, $_GET and $_COOKIE arrays are only populated with stripped
     21 data.  In this simple example all I am doing is calling strip_tags() on
     22 the data.
     23 
     24 ZEND_BEGIN_MODULE_GLOBALS(my_input_filter)
     25         zval *post_array;
     26         zval *get_array;
     27         zval *cookie_array;
     28 ZEND_END_MODULE_GLOBALS(my_input_filter)
     29 
     30 #ifdef ZTS
     31 #define IF_G(v) TSRMG(my_input_filter_globals_id, zend_my_input_filter_globals *, v)
     32 #else
     33 #define IF_G(v) (my_input_filter_globals.v)
     34 #endif
     35 
     36 ZEND_DECLARE_MODULE_GLOBALS(my_input_filter)
     37 
     38 zend_function_entry my_input_filter_functions[] = {
     39     PHP_FE(my_get_raw,   NULL)
     40     {NULL, NULL, NULL}
     41 };
     42 
     43 zend_module_entry my_input_filter_module_entry = {
     44     STANDARD_MODULE_HEADER,
     45     "my_input_filter",
     46     my_input_filter_functions,
     47     PHP_MINIT(my_input_filter),
     48     PHP_MSHUTDOWN(my_input_filter),
     49     NULL,
     50     PHP_RSHUTDOWN(my_input_filter),
     51     PHP_MINFO(my_input_filter),
     52     "0.1",
     53     STANDARD_MODULE_PROPERTIES
     54 };
     55 
     56 PHP_MINIT_FUNCTION(my_input_filter)
     57 {
     58     ZEND_INIT_MODULE_GLOBALS(my_input_filter, php_my_input_filter_init_globals, NULL);
     59 
     60     REGISTER_LONG_CONSTANT("POST", PARSE_POST, CONST_CS | CONST_PERSISTENT);
     61     REGISTER_LONG_CONSTANT("GET", PARSE_GET, CONST_CS | CONST_PERSISTENT);
     62     REGISTER_LONG_CONSTANT("COOKIE", PARSE_COOKIE, CONST_CS | CONST_PERSISTENT);
     63 
     64     sapi_register_input_filter(my_sapi_input_filter);
     65     return SUCCESS;
     66 }
     67 
     68 PHP_RSHUTDOWN_FUNCTION(my_input_filter)
     69 {
     70     if(IF_G(get_array)) {
     71         zval_ptr_dtor(&IF_G(get_array));
     72         IF_G(get_array) = NULL;
     73     }
     74     if(IF_G(post_array)) {
     75         zval_ptr_dtor(&IF_G(post_array));
     76         IF_G(post_array) = NULL;
     77     }
     78     if(IF_G(cookie_array)) {
     79         zval_ptr_dtor(&IF_G(cookie_array));
     80         IF_G(cookie_array) = NULL;
     81     }
     82     return SUCCESS;
     83 }
     84 
     85 PHP_MINFO_FUNCTION(my_input_filter)
     86 {
     87     php_info_print_table_start();
     88     php_info_print_table_row( 2, "My Input Filter Support", "enabled" );
     89     php_info_print_table_row( 2, "Revision", "$Revision: 298241 $");
     90     php_info_print_table_end();
     91 }
     92 
     93 /* The filter handler. If you return 1 from it, then PHP also registers the
     94  * (modified) variable. Returning 0 prevents PHP from registering the variable;
     95  * you can use this if your filter already registers the variable under a
     96  * different name, or if you just don't want the variable registered at all. */
     97 SAPI_INPUT_FILTER_FUNC(my_sapi_input_filter)
     98 {
     99     zval new_var;
    100     zval *array_ptr = NULL;
    101     char *raw_var;
    102     int var_len;
    103 
    104     assert(*val != NULL);
    105 
    106     switch(arg) {
    107         case PARSE_GET:
    108             if(!IF_G(get_array)) {
    109                 ALLOC_ZVAL(array_ptr);
    110                 array_init(array_ptr);
    111                 INIT_PZVAL(array_ptr);
    112             }
    113             IF_G(get_array) = array_ptr;
    114             break;
    115         case PARSE_POST:
    116             if(!IF_G(post_array)) {
    117                 ALLOC_ZVAL(array_ptr);
    118                 array_init(array_ptr);
    119                 INIT_PZVAL(array_ptr);
    120             }
    121             IF_G(post_array) = array_ptr;
    122             break;
    123         case PARSE_COOKIE:
    124             if(!IF_G(cookie_array)) {
    125                 ALLOC_ZVAL(array_ptr);
    126                 array_init(array_ptr);
    127                 INIT_PZVAL(array_ptr);
    128             }
    129             IF_G(cookie_array) = array_ptr;
    130             break;
    131     }
    132     Z_STRLEN(new_var) = val_len;
    133     Z_STRVAL(new_var) = estrndup(*val, val_len);
    134     Z_TYPE(new_var) = IS_STRING;
    135 
    136     var_len = strlen(var);
    137     raw_var = emalloc(var_len+5);  /* RAW_ and a \0 */
    138     strcpy(raw_var, "RAW_");
    139     strlcat(raw_var,var,var_len+5);
    140 
    141     php_register_variable_ex(raw_var, &new_var, array_ptr TSRMLS_DC);
    142 
    143     php_strip_tags(*val, val_len, NULL, NULL, 0);
    144 
    145     *new_val_len = strlen(*val);
    146     return 1;
    147 }
    148 
    149 PHP_FUNCTION(my_get_raw)
    150 {
    151     long arg;
    152     char *var;
    153     int var_len;
    154     zval **tmp;
    155     zval *array_ptr = NULL;
    156 
    157     if(zend_parse_parameters(2 TSRMLS_CC, "ls", &arg, &var, &var_len) == FAILURE) {
    158         return;
    159     }
    160 
    161     switch(arg) {
    162         case PARSE_GET:
    163             array_ptr = IF_G(get_array);
    164             break;
    165         case PARSE_POST:
    166             array_ptr = IF_G(post_array);
    167             break;
    168         case PARSE_COOKIE:
    169             array_ptr = IF_G(post_array);
    170             break;
    171     }
    172 
    173     if(!array_ptr) {
    174         RETURN_FALSE;
    175     }
    176 
    177     if(zend_hash_find(HASH_OF(array_ptr), var, var_len+5, (void **)&tmp) == SUCCESS) {
    178         *return_value = **tmp;
    179         zval_copy_ctor(return_value);
    180     } else {
    181         RETVAL_FALSE;
    182     }
    183 }
    184 
    185 

README.MAILINGLIST_RULES

      1 ====================
      2   Mailinglist Rules
      3 ====================
      4 
      5 This is the first file you should be reading before doing any posts on PHP
      6 mailinglists. Following these rules is considered imperative to the success of
      7 the PHP project. Therefore expect your contributions to be of much less positive
      8 impact if you do not follow these rules. More importantly you can actually
      9 assume that not following these rules will hurt the PHP project.
     10 
     11 PHP is developed through the efforts of a large number of people.
     12 Collaboration is a Good Thing(tm), and mailinglists lets us do this. Thus,
     13 following some basic rules with regards to mailinglist usage will:
     14 
     15    a. Make everybody happier, especially those responsible for developing PHP
     16       itself.
     17 
     18    b. Help in making sure we all use our time more efficiently.
     19 
     20    c. Prevent you from making a fool of yourself in public.
     21 
     22    d. Increase the general level of good will on planet Earth.
     23 
     24 
     25 Having said that, here are the organizational rules:
     26 
     27    1. Respect other people working on the project.
     28 
     29    2. Do not post when you are angry. Any post can wait a few hours. Review
     30       your post after a good breather or a good nights sleep.
     31 
     32    3. Make sure you pick the right mailinglist for your posting. Please review
     33       the descriptions on the mailinglist overview page
     34       (http://www.php.net/mailing-lists.php). When in doubt ask a friend or
     35       someone you trust on IRC.
     36 
     37    4. Make sure you know what you are talking about. PHP is a very large project
     38       that strives to be very open. The flip side is that the core developers
     39       are faced with a lot of requests. Make sure that you have done your
     40       research before posting to the entire developer community.
     41 
     42    5. Patches have a much greater chance of acceptance than just asking the
     43       PHP developers to implement a feature for you. For one it makes the
     44       discussion more concrete and it shows that the poster put thought and time
     45       into the request.
     46 
     47    6. If you are posting to an existing thread, make sure that you know what
     48       previous posters have said. This is even more important the longer the
     49       thread is already.
     50 
     51    7. Please configure your email client to use a real name and keep message
     52       signatures to a maximum of 2 lines if at all necessary.
     53 
     54 The next few rules are more some general hints:
     55 
     56    1. If you notice that your posting ratio is much higher than that of other
     57       people, double check the above rules. Try to wait a bit longer before
     58       sending your replies to give other people more time to digest your answers
     59       and more importantly give you the opportunity to make sure that you
     60       aggregate your current position into a single mail instead of multiple
     61       ones.
     62 
     63    2. Consider taking a step back from a very active thread now and then. Maybe
     64       talking to some friends and fellow developers will help in understanding
     65       the other opinions better.
     66 
     67    3. Do not top post. Place your answer underneath anyone you wish to quote
     68       and remove any previous comment that is not relevant to your post.
     69 
     70    4. Do not high-jack threads, by bringing up entirely new topics. Please
     71       create an entirely new thread copying anything you wish to quote into the
     72       new thread.
     73 
     74 Finally, additional hints on how to behave inside the virtual community can be
     75 found in RFC 1855 (http://www.faqs.org/rfcs/rfc1855.html).
     76 
     77 Happy hacking,
     78 
     79 PHP Team
     80 

README.namespaces

      1 Design
      2 ======
      3 
      4 Main assumption of the model is that the problem that we are to solve is the
      5 problem of the very long class names in PHP libraries. We would not attempt
      6 to take autoloader's job or create packaging model - only make names
      7 manageable.
      8 
      9 Namespaces are defined the following way:
     10 
     11 Zend/DB/Connection.php:
     12 <?php
     13 namespace Zend\DB;
     14 
     15 class Connection {
     16 }
     17 
     18 function connect() {
     19 }
     20 ?>
     21 
     22 Namespace definition does the following:
     23 All class and function names inside are automatically prefixed with
     24 namespace name. Inside namespace, local name always takes precedence over
     25 global name. Several files may be using the same namespace.
     26 The namespace declaration statement must be the very first statement in
     27 the file. The only exception is "declare" statement that can be used before.
     28 
     29 Every class and function in a namespace can be referred to by the full name
     30 - e.g. Zend\DB\Connection or Zend\DB\connect - at any time.
     31 
     32 <?php
     33 require 'Zend/Db/Connection.php';
     34 $x = new Zend\DB\Connection;
     35 Zend\DB\connect();
     36 ?>
     37 
     38 Namespace or class name can be imported:
     39 
     40 <?php
     41 require 'Zend/Db/Connection.php';
     42 use Zend\DB;
     43 use Zend\DB\Connection as DbConnection;
     44 
     45 $x = new Zend\DB\Connection();
     46 $y = new DB\connection();
     47 $z = new DbConnection();
     48 DB\connect();
     49 ?>
     50 
     51 The use statement only defines name aliasing. It may create name alias for
     52 namespace or class. The simple form of statement "use A\B\C\D;" is
     53 equivalent to "use A\B\C\D as D;". The use statement can be used at any
     54 time in the global scope (not inside function/class) and takes effect from 
     55 the point of definition down to the end of file. It is recommended however to
     56 place the use statements at the beginning of the file. The use statements have
     57 effect only on the file where they appear.
     58 
     59 The special "empty" namespace (\ prefix) is useful as explicit global
     60 namespace qualification. All class and function names started from \
     61 interpreted as global.
     62 
     63 <?php 
     64 namespace A\B\C;
     65 
     66 $con = \mysql_connect(...);
     67 ?>
     68 
     69 A special constant __NAMESPACE__ contains the name of the current namespace. 
     70 It can be used to construct fully-qualified names to pass them as callbacks.
     71 
     72 <?php
     73 namespace A\B\C;
     74 
     75 function foo() {
     76 }
     77 
     78 set_error_handler(__NAMESPACE__ . "\foo");
     79 ?>
     80 
     81 In global namespace __NAMESPACE__ constant has the value of empty string.
     82 
     83 Names inside namespace are resolved according to the following rules:
     84 
     85 1) all qualified names are translated during compilation according to
     86 current import rules. So if we have "use A\B\C" and then "C\D\e()"
     87 it is translated to "A\B\C\D\e()".
     88 2) unqualified class names translated during compilation according to
     89 current import rules. So if we have "use A\B\C" and then "new C()" it
     90 is translated to "new A\B\C()".
     91 3) inside namespace, calls to unqualified functions that are defined in 
     92 current namespace (and are known at the time the call is parsed) are 
     93 interpreted as calls to these namespace functions.
     94 4) inside namespace, calls to unqualified functions that are not defined 
     95 in current namespace are resolved at run-time. The call to function foo() 
     96 inside namespace (A\B) first tries to find and call function from current 
     97 namespace A\B\foo() and if it doesn't exist PHP tries to call internal
     98 function foo(). Note that using foo() inside namespace you can call only 
     99 internal PHP functions, however using \foo() you are able to call any
    100 function from the global namespace.
    101 5) unqualified class names are resolved at run-time. E.q. "new Exception()"
    102 first tries to use (and autoload) class from current namespace and in case 
    103 of failure uses internal PHP class. Note that using "new A" in namespace 
    104 you can only create class from this namespace or internal PHP class, however
    105 using "new \A" you are able to create any class from the global namespace.
    106 6) Calls to qualified functions are resolved at run-time. Call to
    107 A\B\foo() first tries to call function foo() from namespace A\B, then
    108 it tries to find class A\B (__autoload() it if necessary) and call its
    109 static method foo()
    110 7) qualified class names are interpreted as class from corresponding
    111 namespace. So "new A\B\C()" refers to class C from namespace A\B.
    112 
    113 Examples
    114 --------
    115 <?php
    116 namespace A;
    117 foo();   // first tries to call "foo" defined in namespace "A"
    118          // then calls internal function "foo"
    119 \foo(); // calls function "foo" defined in global scope
    120 ?>
    121 
    122 <?php
    123 namespace A;
    124 new B();   // first tries to create object of class "B" defined in namespace "A"
    125            // then creates object of internal class "B"
    126 new \B(); // creates object of class "B" defined in global scope
    127 ?>
    128 
    129 <?php
    130 namespace A;
    131 new A(); // first tries to create object of class "A" from namespace "A" (A\A)
    132          // then creates object of internal class "A"
    133 ?>
    134 
    135 <?php
    136 namespace A;
    137 B\foo();   // first tries to call function "foo" from namespace "A\B"
    138             // then calls method "foo" of internal class "B"
    139 \B\foo(); // first tries to call function "foo" from namespace "B"
    140             // then calls method "foo" of class "B" from global scope
    141 ?>
    142 
    143 The worst case if class name conflicts with namespace name
    144 <?php
    145 namespace A;
    146 A\foo();   // first tries to call function "foo" from namespace "A\A"
    147             // then tries to call method "foo" of class "A" from namespace "A"
    148             // then tries to call function "foo" from namespace "A"
    149             // then calls method "foo" of internal class "A"
    150 \A\foo(); // first tries to call function "foo" from namespace "A"
    151             // then calls method "foo" of class "A" from global scope
    152 ?>
    153 
    154 TODO
    155 ====
    156 
    157 * Support for namespace constants?
    158 
    159 * performance problems
    160   - calls to internal functions in namespaces are slower, because PHP first
    161     looks for such function in current namespace
    162   - calls to static methods are slower, because PHP first tries to look
    163     for corresponding function in namespace
    164 
    165 * Extend the Reflection API?
    166   * Add ReflectionNamespace class
    167     + getName()
    168     + getClasses()
    169     + getFunctions()
    170     + getFiles()
    171   * Add getNamespace() methods to ReflectionClass and ReflectionFunction
    172 
    173 * Rename namespaces to packages?
    174 
    175 

README.NEW-OUTPUT-API

      1 $Id: README.NEW-OUTPUT-API 219039 2006-08-30 07:39:09Z mike $
      2 
      3 
      4 API adjustment to the old output control code:
      5 
      6 	Everything now resides beneath the php_output namespace, 
      7 	and there's an API call for every output handler op.
      8 
      9 	Checking output control layers status:
     10 		// Using OG()
     11 		php_output_get_status(TSRMLS_C);
     12 
     13 	Starting the default output handler:
     14 		// php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
     15 		php_output_start_default(TSRMLS_C);
     16 
     17 	Starting an user handler by zval:
     18 		// php_start_ob_buffer(zhandler, chunk_size, erase TSRMLS_CC);
     19 		php_output_start_user(zhandler, chunk_size, flags TSRMLS_CC);
     20 
     21 	Starting an internal handler whithout context:
     22 		// php_ob_set_internal_handler(my_php_output_handler_func_t, buffer_size, "output handler name", erase TSRMLS_CC);
     23 		php_output_start_internal(handler_name, handler_name_len, my_php_output_handler_func_t, chunk_size, flags TSRMLS_CC);
     24 
     25 	Starting an internal handler with context:
     26 		// not possible with old API
     27 		php_output_handler *h;
     28 		h = php_output_handler_create_internal(handler_name, handler_name_len, my_php_output_handler_context_func_t, chunk_size, flags TSRMLS_CC);
     29 		php_output_handler_set_context(h, my_context, my_context_dtor);
     30 		php_output_handler_start(h TSRMLS_CC);
     31 
     32 	Testing whether a certain output handler has already been started:
     33 		// php_ob_handler_used("output handler name" TSRMLS_CC);
     34 		php_output_handler_started(handler_name, handler_name_len TSRMLS_CC);
     35 
     36 	Flushing one output buffer:
     37 		// php_ob_end_buffer(1, 1 TSRMLS_CC);
     38 		php_output_flush(TSRMLS_C);
     39 
     40 	Flushing all output buffers:
     41 		// not possible with old API
     42 		php_output_flush_all(TSRMLS_C);
     43 
     44 	Cleaning one output buffer:
     45 		// php_ob_end_buffer(0, 1 TSRMLS_CC);
     46 		php_output_clean(TSRMLS_C);
     47 
     48 	Cleaning all output buffers:
     49 		// not possible with old API
     50 		php_output_clean_all(TSRMLS_C);
     51 
     52 	Discarding one output buffer:
     53 		// php_ob_end_buffer(0, 0 TSRMLS_CC);
     54 		php_output_discard(TSRMLS_C);
     55 
     56 	Discarding all output buffers:
     57 		// php_ob_end_buffers(0 TSRMLS_CC);
     58 		php_output_discard_all(TSRMLS_C);
     59 
     60 	Stopping (and dropping) one output buffer:
     61 		// php_ob_end_buffer(1, 0 TSRMLS_CC)
     62 		php_output_end(TSRMLS_C);
     63 
     64 	Stopping (and dropping) all output buffers:
     65 		// php_ob_end_buffers(1, 0 TSRMLS_CC);
     66 		php_output_end_all(TSRMLS_C);
     67 
     68 	Retrieving output buffers contents:
     69 		// php_ob_get_buffer(zstring TSRMLS_CC);
     70 		php_output_get_contents(zstring TSRMLS_CC);
     71 
     72 	Retrieving output buffers length:
     73 		// php_ob_get_length(zlength TSRMLS_CC);
     74 		php_output_get_length(zlength TSRMLS_CC);
     75 
     76 	Retrieving output buffering level:
     77 		// OG(nesting_level);
     78 		php_output_get_level(TSRMLS_C);
     79 
     80 	Issue a warning because of an output handler conflict:
     81 		// php_ob_init_conflict("to be started handler name", "to be tested if already started handler name" TSRMLS_CC);
     82 		php_output_handler_conflict(new_handler_name, new_handler_name_len, set_handler_name, set_handler_name_len TSRMLS_CC);
     83 
     84 	Registering a conflict checking function, which will be checked prior starting the handler:
     85 		// not possible with old API, unless hardcoding into output.c
     86 		php_output_handler_conflict_register(handler_name, handler_name_len, my_php_output_handler_conflict_check_t TSRMLS_CC);
     87 
     88 	Registering a reverse conflict checking function, which will be checked prior starting the specified foreign handler:
     89 		// not possible with old API
     90 		php_output_handler_reverse_conflict_register(foreign_handler_name, foreign_handler_name_len, my_php_output_handler_conflict_check_t TSRMLS_CC);
     91 
     92 	Facilitating a context from within an output handler callable with ob_start():
     93 		// not possible with old API
     94 		php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ, (void *) &custom_ctx_ptr_ptr TSRMLS_CC);
     95 
     96 	Disabling of the output handler by itself:
     97 		//not possible with old API
     98 		php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_DISABLE, NULL TSRMLS_CC);
     99 
    100 	Marking an output handler immutable by itself because of irreversibility of its operation:
    101 		// not possible with old API
    102 		php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);
    103 
    104 	Restarting the output handler because of a CLEAN operation:
    105 		// not possible with old API
    106 		if (flags & PHP_OUTPUT_HANDLER_CLEAN) { ... }
    107 
    108 	Recognizing by the output handler itself if it gets discarded:
    109 		// not possible with old API
    110 		if ((flags & PHP_OUTPUT_HANDLER_CLEAN) && (flags & PHP_OUTPUT_HANDLER_FINAL)) { ... }
    111 
    112 
    113 Output handler hooks
    114 
    115 	The output handler can change its abilities at runtime. Eg. the gz handler can
    116 	remove the CLEANABLE and REMOVABLE bits when the first output has passed through it;
    117 	or handlers implemented in C to be used with ob_start() can contain a non-global
    118 	context:
    119 		PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ
    120 			pass a void*** pointer as second arg to receive the address of a pointer
    121 			pointer to the opaque field of the output handler context
    122 		PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS
    123 			pass a int* pointer as second arg to receive the flags set for the output handler
    124 		PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL
    125 			pass a int* pointer as second arg to receive the level of this output handler
    126 			(starts with 0)
    127 		PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE
    128 			the second arg is ignored; marks the output handler to be neither cleanable
    129 			nor removable
    130 		PHP_OUTPUT_HANDLER_HOOK_DISABLE
    131 			the second arg is ignored; marks the output handler as disabled
    132 
    133 
    134 Open questions
    135 
    136 	Should the userland API be adjusted and unified?
    137 	
    138 	Many bits of the manual (and very first implementation) do not comply
    139 	with the behaviour of the current (to be obsoleted) code, thus should
    140 	the manual or the behaviour be adjusted?
    141 
    142 END
    143 

README.PARAMETER_PARSING_API

      1 New parameter parsing functions
      2 ===============================
      3 
      4 It should be easier to parse input parameters to an extension function.
      5 Hence, borrowing from Python's example, there are now a set of functions
      6 that given the string of type specifiers, can parse the input parameters
      7 and store the results in the user specified variables. This avoids most
      8 of the IS_* checks and convert_to_* conversions. The functions also
      9 check for the appropriate number of parameters, and try to output
     10 meaningful error messages.
     11 
     12 
     13 Prototypes
     14 ----------
     15 /* Implemented. */
     16 int zend_parse_parameters(int num_args TSRMLS_DC, char *type_spec, ...);
     17 int zend_parse_parameters_ex(int flags, int num_args TSRMLS_DC, char *type_spec, ...);
     18 
     19 The zend_parse_parameters() function takes the number of parameters
     20 passed to the extension function, the type specifier string, and the
     21 list of pointers to variables to store the results in. The _ex() version
     22 also takes 'flags' argument -- current only ZEND_PARSE_PARAMS_QUIET can
     23 be used as 'flags' to specify that the function should operate quietly
     24 and not output any error messages.
     25 
     26 Both functions return SUCCESS or FAILURE depending on the result.
     27 
     28 The auto-conversions are performed as necessary. Arrays, objects, and
     29 resources cannot be auto-converted.
     30 
     31 
     32 Type specifiers
     33 ---------------
     34  The following list shows the type specifier, its meaning and the parameter 
     35  types that need to be passed by address. All passed paramaters are set
     36  if the PHP parameter is non optional and untouched if optional and the 
     37  parameter is not present. The only exception is O where the zend_class_entry*
     38  has to be provided on input and is used to verify the PHP parameter is an 
     39  instance of that class.
     40 
     41  a  - array (zval*)
     42  A  - array or object (zval *)
     43  b  - boolean (zend_bool)
     44  C  - class (zend_class_entry*)
     45  d  - double (double)
     46  f  - function or array containing php method call info (returned as 
     47       zend_fcall_info and zend_fcall_info_cache)
     48  h  - array (returned as HashTable*)
     49  H  - array or HASH_OF(object) (returned as HashTable*)
     50  l  - long (long)
     51  L  - long, limits out-of-range numbers to LONG_MAX/LONG_MIN (long)
     52  o  - object of any type (zval*)
     53  O  - object of specific type given by class entry (zval*, zend_class_entry)
     54  p  - valid path (string without null bytes in the middle) and its length (char*, int)
     55  r  - resource (zval*)
     56  s  - string (with possible null bytes) and its length (char*, int)
     57  z  - the actual zval (zval*)
     58  Z  - the actual zval (zval**)
     59  *  - variable arguments list (0 or more)
     60  +  - variable arguments list (1 or more)
     61 
     62  The following characters also have a meaning in the specifier string:
     63     | - indicates that the remaining parameters are optional, they
     64         should be initialized to default values by the extension since they
     65         will not be touched by the parsing function if they are not
     66         passed to it.
     67     / - use SEPARATE_ZVAL_IF_NOT_REF() on the parameter it follows
     68     ! - the parameter it follows can be of specified type or NULL (applies
     69 		to all specifiers except for 'b', 'l', and 'd'). If NULL is passed, the
     70 		results pointer is set to NULL as well.
     71 
     72 
     73 Note on 64bit compatibility
     74 ---------------------------
     75 Please do not forget that int and long are two different things on 64bit 
     76 OSes (int is 4 bytes and long is 8 bytes), so make sure you pass longs to "l" 
     77 and ints to strings length (i.e. for "s" you need to pass char * and int), 
     78 not the other way round!
     79 Remember: "l" is the only case when you need to pass long (and that's why 
     80 it's "l", not "i" btw).
     81 
     82 Both mistakes cause memory corruptions and segfaults on 64bit OSes:
     83 1)
     84   char *str;
     85   long str_len; /* XXX THIS IS WRONG!! Use int instead. */
     86   zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len)
     87 
     88 2)
     89   int num; /* XXX THIS IS WRONG!! Use long instead. */
     90   zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &num)
     91 
     92 If you're in doubt, use check_parameters.php script to the parameters 
     93 and their types (it can be found in ./scripts/dev/ directory of PHP sources):
     94 
     95 # php ./scripts/dev/check_parameters.php /path/to/your/sources/
     96 
     97 
     98 Examples
     99 --------
    100 /* Gets a long, a string and its length, and a zval */
    101 long l;
    102 char *s;
    103 int s_len;
    104 zval *param;
    105 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lsz",
    106                           &l, &s, &s_len, &param) == FAILURE) {
    107     return;
    108 }
    109 
    110 
    111 /* Gets an object of class specified by my_ce, and an optional double. */
    112 zval *obj;
    113 double d = 0.5;
    114 zend_class_entry *my_ce;
    115 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|d",
    116                           &obj, my_ce, &d) == FAILURE) {
    117     return;
    118 }
    119 
    120 
    121 /* Gets an object or null, and an array.
    122    If null is passed for object, obj will be set to NULL. */
    123 zval *obj;
    124 zval *arr;
    125 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o!a",
    126                           &obj, &arr) == FAILURE) {
    127     return;
    128 }
    129 
    130 
    131 /* Gets a separated array which can also be null. */
    132 zval *arr;
    133 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!",
    134                           &arr) == FAILURE) {
    135     return;
    136 }
    137 
    138 /* Get either a set of 3 longs or a string. */
    139 long l1, l2, l3;
    140 char *s;
    141 /* 
    142  * The function expects a pointer to a integer in this case, not a long
    143  * or any other type.  If you specify a type which is larger
    144  * than a 'int', the upper bits might not be initialized
    145  * properly, leading to random crashes on platforms like
    146  * Tru64 or Linux/Alpha.
    147  */
    148 int length;
    149 
    150 if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
    151                              "lll", &l1, &l2, &l3) == SUCCESS) {
    152     /* manipulate longs */
    153 } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
    154                                     "s", &s, &length) == SUCCESS) {
    155     /* manipulate string */
    156 } else {
    157     /* output error */
    158 
    159     return;
    160 }
    161 
    162 
    163 /* Function that accepts only varargs (0 or more) */
    164 
    165 int i, num_varargs;
    166 zval ***varargs = NULL;
    167 
    168 
    169 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "*", &varargs, &num_varargs) == FAILURE) {
    170     return;
    171 }
    172 
    173 for (i = 0; i < num_varargs; i++) {
    174     /* do something with varargs[i] */
    175 }
    176 
    177 if (varargs) {
    178     efree(varargs);
    179 }
    180 
    181 
    182 /* Function that accepts a string, followed by varargs (1 or more) */
    183 
    184 char *str;
    185 int str_len;
    186 int i, num_varargs;
    187 zval ***varargs = NULL;
    188 
    189 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s+", &str, &str_len, &varargs, &num_varargs) == FAILURE) {
    190     return;
    191 }
    192 
    193 for (i = 0; i < num_varargs; i++) {
    194     /* do something with varargs[i] */
    195 }
    196 
    197 if (varargs) {
    198     efree(varargs);
    199 }
    200 
    201 
    202 /* Function that takes an array, followed by varargs, and ending with a long */
    203 long num;
    204 zval *array;
    205 int i, num_varargs;
    206 zval ***varargs = NULL;
    207 
    208 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a*l", &array, &varargs, &num_varargs, &num) == FAILURE) {
    209     return;
    210 }
    211 
    212 for (i = 0; i < num_varargs; i++) {
    213     /* do something with varargs[i] */
    214 }
    215 
    216 if (varargs) {
    217     efree(varargs);
    218 }
    219 
    220 

README.PHP4-TO-PHP5-THIN-CHANGES

      1 1. strrpos() and strripos() now use the entire string as a needle.  Be aware
      2    that the existing scripts may no longer work as you expect.
      3 
      4    EX :
      5    <?php
      6    var_dump(strrpos("ABCDEF","DEF"));
      7    var_dump(strrpos("ABCDEF","DAF"));
      8    ?>
      9 
     10    Will give you different results. The former returns 3 while the latter
     11    returns false rather than the position of the last occurrence of 'D'.
     12    The same applies to strripos().
     13 
     14 2. Illegal use of string offsets causes E_ERROR instead of E_WARNING.
     15 
     16    EX :
     17    <?php
     18    $a = "foo";
     19    unset($a[0][1][2]);
     20    ?>
     21 
     22    Fatal error: Cannot use string offset as an array in ... on line 1
     23 
     24 3. array_merge() was changed to accept only arrays. If a non-array variable is
     25    passed, a E_WARNING will be thrown for every such parameter. Be careful
     26    because your code may start emitting E_WARNING out of the blue.
     27 
     28 4. Be careful when porting from ext/mysql to ext/mysqli. The following
     29    functions return NULL when no more data is available in the result set
     30    (ext/mysql's functions return FALSE).
     31 
     32     - mysqli_fetch_row()
     33     - mysqli_fetch_array()
     34     - mysqli_fetch_assoc()
     35 
     36 5. PATH_TRANSLATED server variable is no longer set implicitly under
     37    Apache2 SAPI in contrast to the situation in PHP 4, where it is set to the
     38    same value as the SCRIPT_FILENAME server variable when it is not populated
     39    by Apache.  This change was made to comply with the CGI specification.
     40    Please refer to bug #23610 for further information.
     41 
     42 6. Starting PHP 5.0.0 the T_ML_CONSTANT constant is no longer defined by the
     43    ext/tokenizer extension. If error_reporting is set to E_ALL notices will
     44    be produced. Instead of T_ML_CONSTANT for /* */ the T_COMMENT constant 
     45    is used, thus both // and /* */ are resolved as the T_COMMENT constant.
     46    However the PHPDoc style comments /** */ ,which starting PHP 5 are parsed
     47    by PHP, are recongnized as T_DOC_COMMENT.
     48 
     49 7. $_SERVER should be populated with argc and argv if variables_order
     50    includes "S".  If you have specifically configured your system to not
     51    create $_SERVER, then of course it shouldn't be there.  The change was to
     52    always make argc and argv available in the CLI version regardless of the
     53    variables_order setting.  As in, the CLI version will now always populate
     54    the global $argc and $argv variables.
     55 
     56 8. In some cases classes must be declared before used. It only happens only
     57    if some of the new features of PHP 5 are used. Otherwise the behaviour is
     58    the old.
     59    Example 1 (works with no errors):
     60    <?php
     61    $a = new a();
     62    class a {
     63    }
     64    ?>
     65  
     66    Example 2 (throws an error):
     67    <?php 
     68    $a = new a();
     69    interface b{
     70    }
     71    class a implements b {
     72    } 
     73    ?>
     74 
     75    Output (example 2) :
     76    Fatal error: Class 'a' not found in /tmp/cl.php on line 2
     77 
     78 9. get_class() starting PHP 5 returns the name of the class as it was
     79    declared which may lead to problems in older scripts that rely on
     80    the previous behaviour - the class name is lowercased. Expect the
     81    same behaviour from get_parent_class() when applicable.
     82    Example :
     83    <?php
     84    class FooBar {
     85    }
     86    class ExtFooBar extends FooBar{}
     87    $a = new FooBar();
     88    var_dump(get_class($a), get_parent_class($a));
     89    ?>
     90 
     91    Output (PHP 4):
     92    string(6) "foobar"
     93    string(9) "extfoobar"
     94 
     95    Output (PHP 5):
     96    string(6) "FooBar"
     97    string(9) "ExtFooBar"
     98    ----------------------------------------------------------------------
     99    Example code that will break :
    100    //....
    101    function someMethod($p) {
    102      if (get_class($p) != 'helpingclass') {
    103        return FALSE;
    104      }
    105      //...
    106    }
    107    //...
    108    Possible solution is to search for get_class() and get_parent_class() in
    109    all your scripts and use strtolower().
    110 
    111 10. get_class_methods() returns the names of the methods of a class as they
    112    declared. In PHP4 the names are all lowercased.
    113    Example code :
    114    <?php
    115    class Foo{
    116      function doFoo(){}
    117      function hasFoo(){}
    118    }
    119    var_dump(get_class_methods("Foo")); 
    120    ?>
    121    Output (PHP4):
    122    array(2) {
    123      [0]=>
    124      string(5) "dofoo"
    125      [1]=>
    126      string(6) "hasfoo"
    127    }
    128    Output (PHP5):
    129    array(2) {
    130      [0]=>
    131      string(5) "doFoo"
    132      [1]=>
    133      string(6) "hasFoo"
    134    }
    135 
    136 11. Assignment $this is impossible. Starting PHP 5.0.0 $this has special
    137     meaning in class methods and is recognized by the PHP parser. The latter
    138     will generate a parse error when assignment to $this is found
    139     Example code :
    140     <?php
    141     class Foo {
    142       function assignNew($obj) {
    143         $this = $obj;
    144       }
    145     }
    146     $a = new Foo();
    147     $b = new Foo();
    148     $a->assignNew($b);
    149     echo "I was executed\n";
    150     ?>
    151     Output (PHP 4):
    152     I was executed
    153     Output (PHP 5):
    154     PHP Fatal error:  Cannot re-assign $this in /tmp/this_ex.php on line 4
    155 
    156 

README.REDIST.BINS

      1 1. libmagic (ext/fileinfo) see ext/fileinfo/libmagic/LICENSE
      2 2. Oniguruma (ext/mbstring) see ext/mbstring/oniguruma/COPYING
      3 3. libmbfl (ext/mbstring) see ext/mbstring/libmbfl/LICENSE
      4 4. pcrelib (ext/pcre) see ext/pcre/pcrelib/LICENCE
      5 5. ext/standard crypt
      6 6. ext/standard crypt's blowfish implementation
      7 7. Sqlite/Sqlite3 ext/sqlite3 ext/sqlite
      8 8. ext/json/json_parser
      9 9. ext/standard/rand
     10 10. ext/standard/scanf
     11 11. ext/standard/strnatcmp.c
     12 12. ext/standard/uuencode
     13 13. libxmlrpc ext/xmlrpc
     14 14. libzip ext/zip
     15 15. main/snprintf.c
     16 16. main/strlcat
     17 17. main/strlcpy
     18 18. libgd see ext/gd/libgd/COPYING
     19 
     20 5. ext/standard crypt
     21 
     22 FreeSec: libcrypt for NetBSD
     23 
     24 Copyright (c) 1994 David Burren
     25 All rights reserved.
     26 
     27 Redistribution and use in source and binary forms, with or without
     28 modification, are permitted provided that the following conditions
     29 are met:
     30 1. Redistributions of source code must retain the above copyright
     31 	 notice, this list of conditions and the following disclaimer.
     32 2. Redistributions in binary form must reproduce the above copyright
     33 	 notice, this list of conditions and the following disclaimer in the
     34 	 documentation and/or other materials provided with the distribution.
     35 3. Neither the name of the author nor the names of other contributors
     36 	 may be used to endorse or promote products derived from this software
     37 	 without specific prior written permission.
     38 
     39 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     40 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     41 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     42 ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     43 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     44 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     45 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     46 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     47 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     48 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     49 SUCH DAMAGE.
     50  
     51 
     52 6. ext/standard crypt's blowfish implementation
     53 
     54 The crypt_blowfish homepage is:
     55 
     56 http://www.openwall.com/crypt/
     57 
     58 This code comes from John the Ripper password cracker, with reentrant
     59 and crypt(3) interfaces added, but optimizations specific to password
     60 cracking removed.
     61 
     62 Written by Solar Designer <solar at openwall.com> in 1998-2011.
     63 No copyright is claimed, and the software is hereby placed in the public
     64 domain. In case this attempt to disclaim copyright and place the software
     65 in the public domain is deemed null and void, then the software is
     66 Copyright (c) 1998-2011 Solar Designer and it is hereby released to the
     67 general public under the following terms:
     68 
     69 Redistribution and use in source and binary forms, with or without
     70 modification, are permitted.
     71 
     72 There's ABSOLUTELY NO WARRANTY, express or implied.
     73 
     74 It is my intent that you should be able to use this on your system,
     75 as part of a software package, or anywhere else to improve security,
     76 ensure compatibility, or for any other purpose. I would appreciate
     77 it if you give credit where it is due and keep your modifications in
     78 the public domain as well, but I don't require that in order to let
     79 you place this code and any modifications you make under a license
     80 of your choice.
     81 
     82 This implementation is mostly compatible with OpenBSD's bcrypt.c (prefix
     83 "$2a$") by Niels Provos <provos at citi.umich.edu>, and uses some of his
     84 ideas. The password hashing algorithm was designed by David Mazieres
     85 <dm at lcs.mit.edu>. For more information on the level of compatibility,
     86 please refer to the comments in BF_set_key() and to the crypt(3) man page
     87 included in the crypt_blowfish tarball.
     88 
     89 There's a paper on the algorithm that explains its design decisions:
     90 
     91 http://www.usenix.org/events/usenix99/provos.html
     92 
     93 Some of the tricks in BF_ROUND might be inspired by Eric Young's
     94 Blowfish library (I can't be sure if I would think of something if I
     95 hadn't seen his code).
     96  
     97 
     98 7. Sqlite/Sqlite3 ext/sqlite3 ext/sqlite
     99 
    100 The author disclaims copyright to this source code.  In place of
    101 a legal notice, here is a blessing:
    102   May you do good and not evil.
    103   May you find forgiveness for yourself and forgive others.
    104   May you share freely, never taking more than you give.
    105 
    106 
    107 8. ext/json/json_parser
    108 Copyright (c) 2005 JSON.org
    109 
    110 Permission is hereby granted, free of charge, to any person obtaining a copy
    111 of this software and associated documentation files (the "Software"), to deal
    112 in the Software without restriction, including without limitation the rights
    113 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    114 copies of the Software, and to permit persons to whom the Software is
    115 furnished to do so, subject to the following conditions:
    116 
    117 The above copyright notice and this permission notice shall be included in all
    118 copies or substantial portions of the Software.
    119 
    120 The Software shall be used for Good, not Evil.
    121 
    122 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    123 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    124 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    125 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    126 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    127 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    128 SOFTWARE.
    129 
    130 
    131 9. ext/standard/rand
    132 The following php_mt_...() functions are based on a C++ class MTRand by
    133 Richard J. Wagner. For more information see the web page at
    134 http://www-personal.engin.umich.edu/~wagnerr/MersenneTwister.html
    135 
    136 Mersenne Twister random number generator -- a C++ class MTRand
    137 Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
    138 Richard J. Wagner  v1.0  15 May 2003  rjwagner (a] writeme.com
    139 
    140 The Mersenne Twister is an algorithm for generating random numbers.  It
    141 was designed with consideration of the flaws in various other generators.
    142 The period, 2^19937-1, and the order of equidistribution, 623 dimensions,
    143 are far greater.  The generator is also fast; it avoids multiplication and
    144 division, and it benefits from caches and pipelines.  For more information
    145 see the inventors' web page at http://www.math.keio.ac.jp/~matumoto/emt.html
    146 
    147 Reference
    148 M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally
    149 Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on
    150 Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.
    151 
    152 Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
    153 Copyright (C) 2000 - 2003, Richard J. Wagner
    154 All rights reserved.                          
    155 
    156 Redistribution and use in source and binary forms, with or without
    157 modification, are permitted provided that the following conditions
    158 are met:
    159 
    160 1. Redistributions of source code must retain the above copyright
    161 	 notice, this list of conditions and the following disclaimer.
    162 
    163 2. Redistributions in binary form must reproduce the above copyright
    164 	 notice, this list of conditions and the following disclaimer in the
    165 	 documentation and/or other materials provided with the distribution.
    166 
    167 3. The names of its contributors may not be used to endorse or promote 
    168 	 products derived from this software without specific prior written 
    169 	 permission.
    170 
    171 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    172 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    173 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    174 A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    175 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    176 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    177 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    178 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    179 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    180 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    181 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    182 
    183 
    184 10. ext/standard/scanf
    185 scanf.c --
    186 
    187 This file contains the base code which implements sscanf and by extension
    188 fscanf. Original code is from TCL8.3.0 and bears the following copyright:
    189 
    190 This software is copyrighted by the Regents of the University of
    191 California, Sun Microsystems, Inc., Scriptics Corporation,
    192 and other parties.  The following terms apply to all files associated
    193 with the software unless explicitly disclaimed in individual files.
    194 
    195 The authors hereby grant permission to use, copy, modify, distribute,
    196 and license this software and its documentation for any purpose, provided
    197 that existing copyright notices are retained in all copies and that this
    198 notice is included verbatim in any distributions. No written agreement,
    199 license, or royalty fee is required for any of the authorized uses.
    200 Modifications to this software may be copyrighted by their authors
    201 and need not follow the licensing terms described here, provided that
    202 the new terms are clearly indicated on the first page of each file where
    203 they apply.
    204 
    205 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
    206 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
    207 ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
    208 DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
    209 POSSIBILITY OF SUCH DAMAGE.
    210 
    211 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
    212 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
    213 FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
    214 IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
    215 NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
    216 MODIFICATIONS.
    217 
    218 GOVERNMENT USE: If you are acquiring this software on behalf of the
    219 U.S. government, the Government shall have only "Restricted Rights"
    220 in the software and related documentation as defined in the Federal
    221 Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you
    222 are acquiring the software on behalf of the Department of Defense, the
    223 software shall be classified as "Commercial Computer Software" and the
    224 Government shall have only "Restricted Rights" as defined in Clause
    225 252.227-7013 (c) (1) of DFARs.  Notwithstanding the foregoing, the
    226 authors grant the U.S. Government and others acting in its behalf
    227 permission to use and distribute the software in accordance with the
    228 terms specified in this license.
    229 
    230 11. ext/standard/strnatcmp.c
    231 
    232 strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
    233 Copyright (C) 2000 by Martin Pool <mbp (a] humbug.org.au>
    234 
    235 This software is provided 'as-is', without any express or implied
    236 warranty.  In no event will the authors be held liable for any damages
    237 arising from the use of this software.
    238 
    239 Permission is granted to anyone to use this software for any purpose,
    240 including commercial applications, and to alter it and redistribute it
    241 freely, subject to the following restrictions:
    242 
    243 1. The origin of this software must not be misrepresented; you must not
    244 	 claim that you wrote the original software. If you use this software
    245 	 in a product, an acknowledgment in the product documentation would be
    246 	 appreciated but is not required.
    247 2. Altered source versions must be plainly marked as such, and must not be
    248 	 misrepresented as being the original software.
    249 3. This notice may not be removed or altered from any source distribution.
    250 
    251 12. ext/standard/uuencode
    252 Portions of this code are based on Berkeley's uuencode/uudecode
    253 implementation.
    254 
    255 Copyright (c) 1983, 1993
    256 The Regents of the University of California.  All rights reserved.
    257 
    258 Redistribution and use in source and binary forms, with or without
    259 modification, are permitted provided that the following conditions
    260 are met:
    261 1. Redistributions of source code must retain the above copyright
    262 	notice, this list of conditions and the following disclaimer.
    263 2. Redistributions in binary form must reproduce the above copyright
    264 	notice, this list of conditions and the following disclaimer in the
    265 	documentation and/or other materials provided with the distribution.
    266 3. All advertising materials mentioning features or use of this software
    267 	must display the following acknowledgement:
    268 This product includes software developed by the University of
    269 California, Berkeley and its contributors.
    270 4. Neither the name of the University nor the names of its contributors
    271 	may be used to endorse or promote products derived from this software
    272 	without specific prior written permission.
    273 
    274 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    275 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    276 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    277 ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    278 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    279 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    280 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    281 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    282 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    283 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    284 SUCH DAMAGE.
    285 
    286 
    287 13. libxmlrpc ext/xmlrpc
    288 
    289 Copyright 2000 Epinions, Inc. 
    290 
    291 Subject to the following 3 conditions, Epinions, Inc.  permits you, free 
    292 of charge, to (a) use, copy, distribute, modify, perform and display this 
    293 software and associated documentation files (the "Software"), and (b) 
    294 permit others to whom the Software is furnished to do so as well.  
    295 
    296 1) The above copyright notice and this permission notice shall be included 
    297 without modification in all copies or substantial portions of the 
    298 Software.  
    299 
    300 2) THE SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF 
    301 ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY 
    302 IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR 
    303 PURPOSE OR NONINFRINGEMENT.  
    304 
    305 3) IN NO EVENT SHALL EPINIONS, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, 
    306 SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT 
    307 OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER ARISING, INCLUDING 
    308 NEGLIGENCE), EVEN IF EPINIONS, INC.  IS AWARE OF THE POSSIBILITY OF SUCH 
    309 DAMAGES.
    310 
    311 14. libzip ext/zip
    312 zip.h -- exported declarations.
    313 Copyright (C) 1999-2009 Dieter Baron and Thomas Klausner
    314 
    315 This file is part of libzip, a library to manipulate ZIP archives.
    316 The authors can be contacted at <libzip (a] nih.at>
    317 
    318 Redistribution and use in source and binary forms, with or without
    319 modification, are permitted provided that the following conditions
    320 are met:
    321 1. Redistributions of source code must retain the above copyright
    322 	 notice, this list of conditions and the following disclaimer.
    323 2. Redistributions in binary form must reproduce the above copyright
    324 	 notice, this list of conditions and the following disclaimer in
    325 	 the documentation and/or other materials provided with the
    326 	 distribution.
    327 3. The names of the authors may not be used to endorse or promote
    328 	 products derived from this software without specific prior
    329 	 written permission.
    330 
    331 THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
    332 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    333 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    334 ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
    335 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    336 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
    337 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    338 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
    339 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    340 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
    341 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    342 
    343 15. main/snprintf.c
    344 Copyright (c) 2002, 2006 Todd C. Miller <Todd.Miller (a] courtesan.com>
    345 
    346 Permission to use, copy, modify, and distribute this software for any
    347 purpose with or without fee is hereby granted, provided that the above
    348 copyright notice and this permission notice appear in all copies.
    349 
    350 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    351 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
    352 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
    353 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    354 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
    355 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    356 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    357 
    358 Sponsored in part by the Defense Advanced Research Projects
    359 Agency (DARPA) and Air Force Research Laboratory, Air Force
    360 Materiel Command, USAF, under agreement number F39502-99-1-0512.
    361 
    362 main/spprintf
    363 Copyright (c) 1995-1998 The Apache Group.  All rights reserved.
    364 
    365 Redistribution and use in source and binary forms, with or without
    366 modification, are permitted provided that the following conditions
    367 are met:
    368 
    369 1. Redistributions of source code must retain the above copyright
    370 	 notice, this list of conditions and the following disclaimer.
    371 
    372 2. Redistributions in binary form must reproduce the above copyright
    373 	 notice, this list of conditions and the following disclaimer in
    374 	 the documentation and/or other materials provided with the
    375 	 distribution.
    376 
    377 3. All advertising materials mentioning features or use of this
    378 	 software must display the following acknowledgment:
    379 	 "This product includes software developed by the Apache Group
    380 	 for use in the Apache HTTP server project (http://www.apache.org/)."
    381 
    382 4. The names "Apache Server" and "Apache Group" must not be used to
    383 	 endorse or promote products derived from this software without
    384 	 prior written permission.
    385 
    386 5. Redistributions of any form whatsoever must retain the following
    387 	 acknowledgment:
    388 	 "This product includes software developed by the Apache Group
    389 	 for use in the Apache HTTP server project (http://www.apache.org/)."
    390 
    391 THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
    392 EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    393 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    394 PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
    395 ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    396 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    397 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    398 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    399 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    400 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    401 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    402 OF THE POSSIBILITY OF SUCH DAMAGE.
    403 ====================================================================
    404 
    405 This software consists of voluntary contributions made by many
    406 individuals on behalf of the Apache Group and was originally based
    407 on public domain software written at the National Center for
    408 Supercomputing Applications, University of Illinois, Urbana-Champaign.
    409 For more information on the Apache Group and the Apache HTTP server
    410 project, please see <http://www.apache.org/>.
    411 
    412 This code is based on, and used with the permission of, the
    413 SIO stdio-replacement strx_* functions by Panos Tsirigotis
    414 <panos (a] alumni.cs.colorado.edu> for xinetd.
    415 
    416 16. main/strlcat
    417 17. main/strlcpy
    418 Copyright (c) 1998 Todd C. Miller <Todd.Miller (a] courtesan.com>
    419 All rights reserved.
    420 
    421 Redistribution and use in source and binary forms, with or without
    422 modification, are permitted provided that the following conditions
    423 are met:
    424 1. Redistributions of source code must retain the above copyright
    425 	notice, this list of conditions and the following disclaimer.
    426 2. Redistributions in binary form must reproduce the above copyright
    427 	notice, this list of conditions and the following disclaimer in the
    428 	documentation and/or other materials provided with the distribution.
    429 3. The name of the author may not be used to endorse or promote products
    430 	derived from this software without specific prior written permission.
    431 
    432 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
    433 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    434 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
    435 THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    436 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    437 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    438 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    439 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    440 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
    441 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    442 
    443 

README.RELEASE_PROCESS

      1 =======================
      2   PHP Release Process
      3 =======================
      4 
      5 General notes and tips
      6 ----------------------
      7 
      8 1. Do not release on Fridays, Saturdays or Sundays
      9 because the sysadmins can not upgrade stuff then.
     10 
     11 2. Package the day before a release. So if the release is to be on Thursday,
     12 package on Wednesday.
     13 
     14 3. Ensure that Windows builds will work before packaging
     15 
     16 4. Follow all steps to the letter. When unclear ask previous RM's (Derick/Ilia)
     17 before proceeding. Ideally make sure that for the first releases one of the
     18 previous RM's is around to answer questions. For the steps related to the
     19 php/QA/bug websites try to have someone from the webmaster team (Bjori) on hand.
     20 
     21 5. Verify the tags to be extra sure everything was tagged properly.
     22 
     23 6. Moving extensions from/to PECL requires write acces to the destination.
     24 Most developers should have this. 
     25 
     26 Moving extensions from php-src to PECL
     27 - Checkout the pecl directory, most likely you want a sparse-root checkout
     28   svn co --depth=empty https://svn.php.net/repository/pecl
     29 - Create an directory for the extension incl. branch and tag structure,
     30   no trunk at this point and commit this to svn
     31   cd pecl; mkdir foo foo/tags foo/branches; svn add foo; svn commit
     32 - Move the extension from php-src to the new location
     33   svn mv https://svn.php.net/repository/php/php-src/trunk/ext/foo \
     34          https://svn.php.net/repository/pecl/foo/trunk
     35 
     36 If the extension is still usable or not dead, in cooperation with the extension
     37 maintainers if any:
     38 - create the pecl.php.net/foo package and its content, license, maintainer
     39 - create the package.xml, commit
     40 - release the package
     41 
     42 For Moving extensions from PECL to php-src the svn mv has to be tone the other
     43 way round.
     44 
     45 Rolling a non stable release (alpha/beta/RC)
     46 --------------------------------------------
     47 
     48 1. Check windows snapshot builder logs (http://windows.php.net/downloads/snaps/ the last revision)
     49 
     50 2. run the "scripts/dev/credits" script in php-src and commit the changes in the
     51 credits files in ext/standard.
     52 
     53 3. Bump the version numbers in ``main/php_version.h``, ``configure.in`` and possibly ``NEWS``.
     54 Do not use abbreviations for alpha and beta.
     55 
     56 4. Commit those changes and note the revision id.
     57 
     58 5. tag the repository with the version. To do the tag in a fast way do a svn copy on the server using full URLs. You should use the revision id from the above commit to prevent mistakes in case there was a commit in between. f.e. "``svn cp https://svn.php.net/repository/php/php-src/branches/PHP_5_3@308399  https://svn.php.net/repository/php/php-src/tags/php_5_3_6RC1``"
     59 (of course, you need to change that to the version you're rolling an RC for). Mail php-internals to announce the tag so tests/validation/check can be done prior to package it. It is especially important for RCs.
     60 
     61 6. Bump up the version numbers in ``main/php_version.h``, ``configure.in``
     62 and possibly ``NEWS`` again, to the **next** version. F.e. if the release
     63 candidate was "4.4.1RC1" then the new one should be "4.4.1RC2-dev" - regardless
     64 if we get a new RC or not. This is to make sure ``version_compare()`` can
     65 correctly work.
     66 
     67 7. Commit those changes
     68 
     69 8. Log in onto the snaps box and go into the correct tree (f.e. the PHP_4_4
     70 branch if you're rolling 4.4.x releases).
     71 
     72 9. You do not have to update the tree, but of course you can with "``svn up``".
     73 
     74 10. run: ``./makedist php 4.4.1RC1``, this will export the tree, create configure
     75 and build two tarballs (one gz and one bz2).
     76 
     77 11. Copy those two tarballs to www.php.net, in your homedir there should be a
     78 directory "downloads/". Copy them into there, so that the system can generate
     79 MD5 sums. If you do not have this directory, talk to Derick.
     80 
     81 12. Now the RC can be found on http://downloads.php.net/yourname,
     82 f.e. http://downloads.php.net/derick/
     83 
     84 13. Once the release has been tagged, contact the PHP Windows development team
     85 (internals-win (a] lists.php.net) so that Windows binaries can be created. Once
     86 those are made, they should be placed into the same directory as the source snapshots.
     87 
     88 Getting the non stable release (alpha/beta/RC) announced
     89 --------------------------------------------------------
     90 
     91 1. Send an email (see example here: http://news.php.net/php.internals/19486)
     92 **To** ``internals (a] lists.php.net`` and ``php-general (a] lists.php.net`` lists
     93 pointing out "the location of the release" and "the possible release date of
     94 either the next RC, or the final release".
     95 
     96 2. Send an email (see example here http://news.php.net/php.pear.qa/5201) **To**
     97 ``php-qa (a] lists.php.net`` and ``primary-qa-tests (a] lists.php.net``.
     98 This email is to notify the selected projects about a new release so that they
     99 can make sure their projects keep working. Make sure that you have been setup
    100 as a moderator for ``primary-qa-tests (a] lists.php.net`` by having someone (Wez,
    101 Derick) run the following commands for you:
    102 
    103 ``ssh lists.php.net``
    104 
    105 ``sudo -u ezmlm ezmlm-sub ~ezmlm/primary-qa-tester/mod moderator-email-address``
    106 
    107 3. Update ``qa.git/include/release-qa.php`` with the appropriate information.
    108    See the documentation within release-qa.php for more information, but all releases
    109    and RCs are configured here. Only $QA_RELEASES needs to be edited.
    110 
    111    Example: When rolling an RC, set the 'rc' with appropriate information for the
    112    given version.
    113 
    114    Note: Remember to update the MD5 checksum information.
    115 
    116 4. Update ``php.git/include/version.inc`` (x=major version number)
    117 
    118  a. ``$PHP_x_RC`` = "5.4.0RC1"
    119 
    120  b. ``$PHP_x_RC_DATE`` = "06 September 2007"
    121 
    122 5. Commit and push those changes:
    123 
    124  a. ``git commit -a && git push origin master``
    125 
    126 6. For the first RC, write the doc team (phpdoc (a] lists.php.net) about updating the
    127 INSTALL and win32/install.txt files which are generated from the PHP manual sources.
    128 
    129 7. Publish the announce on www.php.net as well (for all releases, alpha, RCs or other)
    130 
    131 Rolling a stable release
    132 ------------------------
    133 
    134 1. Check windows snapshot builder logs (http://snaps.php.net/win32/snapshot-STABLE.log f.e.)
    135 
    136 2. Bump the version numbers in ``main/php_version.h``, ``configure.in`` and possibly ``NEWS``.
    137 
    138 3. **Merge** all related sections in NEWS (f.e. merge the 4.4.1RC1 and 4.4.0 sections)
    139 
    140 4. Commit those changes
    141 
    142 5. run the "scripts/dev/credits" script in php-src and commit the changes in the
    143 credits files in ext/standard.
    144 
    145 6. tag the repository with the version f.e. "``cvs tag php_4_4_1``"
    146 (of course, you need to change that to the version you're rolling an RC for).
    147 When making 5.X release, you need to tag the Zend directory separately!!
    148 
    149 7. Bump up the version numbers in ``main/php_version.h``, ``configure.in`` and
    150 possibly ``NEWS`` again, to the **next** version. F.e. if the release candidate
    151 was "4.4.1RC1" then the new one should be "4.4.1RC2-dev" - regardless if we get
    152 a new RC or not. This is to make sure ``version_compare()`` can correctly work.
    153 
    154 8. Commit those changes
    155 
    156 9. Log in onto the snaps box and go into the correct tree (f.e. the PHP_4_4
    157 branch if you're rolling 4.4.x releases).
    158 
    159 10. You do not have to update the tree, but of course you can with "``cvs up -dP``".
    160 
    161 11. run: ``./makedist php 4.4.1``, this will export the tree, create configure
    162 and build two tarballs (one gz and one bz2).
    163 
    164 12. Commit those two tarballs to CVS (phpweb/distributions)
    165 
    166 13. Once the release has been tagged, contact the PHP Windows development team
    167 (internals-win (a] lists.php.net) so that Windows binaries can be created. Once
    168 those are made, they should be committed to SVN too.
    169 
    170 14. Check if the pear files are updated (phar for 5.1+ or run pear/make-pear-bundle.php with 4.4)
    171 
    172 15. When making a final release, also remind the PHP Windows development team
    173 (internals-win (a] lists.php.net) to prepare the installer packages for Win32.
    174 
    175 Getting the stable release announced
    176 ------------------------------------
    177 
    178 1. Run the bumpRelease script for phpweb on your local checkout
    179 
    180  a. ``php bin/bumpRelease 5`` (or ``php bin/bumpRelease 4`` for PHP4)
    181 
    182 2. Edit ``phpweb/include/version.inc`` and change (X=major release number):
    183 
    184  a. ``$PHP_X_VERSION`` to the correct version
    185 
    186  b. ``$PHP_X_DATE`` to the release date
    187 
    188  c. ``$PHP_X_MD5`` array and update all the md5 sums
    189 
    190  d. set ``$PHP_X_RC`` to false!
    191 
    192  e. Make sure there are no outdated "notes" or edited "date" keys in the
    193  ``$RELEASES[X][$PHP_X_VERSION]["source"]`` array
    194 
    195  f. if the windows builds aren't ready yet prefix the "windows" key with a dot (".windows")
    196 
    197 3. Update the ChangeLog file for the given major version
    198 f.e. ``ChangeLog-4.php`` from the NEWS file
    199 
    200  a. go over the list and put every element on one line
    201 
    202  b. check for &, < and > and escape them if necessary
    203 
    204  c. remove all the names at the ends of lines
    205 
    206  d. for marking up, you can do the following (with VI):
    207 
    208   I. ``s/^- /<li>/``
    209 
    210   II. ``s/$/<\/li>/``
    211 
    212   III. ``s/Fixed bug #\([0-9]\+\)/<?php bugfix(\1); ?>/``
    213 
    214   IV. ``s/Fixed PECL bug #\([0-9]\+\)/<?php peclbugfix(\1); ?>/``
    215 
    216   V. ``s/FR #\([0-9]\+\)/FR <?php bugl(\1); ?>/``
    217 
    218 4. ``cp releases/4_4_0.php releases/4_4_1.php``
    219 
    220 5. ``cvs add releases/4_4_1.php``
    221 
    222 6. Update the ``releases/*.php`` file with relevant data. The release
    223 announcement file should list in detail:
    224 
    225  a. security fixes,
    226 
    227  b. changes in behavior (whether due to a bug fix or not)
    228 
    229 7. Add a short notice to phpweb stating that there is a new release, and
    230 highlight the major important things (security fixes) and when it is important
    231 to upgrade.
    232 
    233  a. Call php bin/createNewsEntry in your local phpweb checkout
    234 
    235  b. Add the content for the news entry
    236 
    237 8. Commit all the changes.
    238 
    239 9. Wait an hour or two, then send a mail to php-announce (a] lists.php.net,
    240 php-general (a] lists.php.net and internals (a] lists.php.net with a text similar to
    241 http://news.php.net/php.internals/17222.
    242 
    243 10. Update ``php-bugs-web/include/functions.php`` to include the new version
    244 number, and remove the RC from there.
    245 
    246 11. Update ``qaweb/include/release-qa.php``
    247 
    248  - Update $QA_RELEASES with the appropriate information, which means bumping
    249    the version number to an upcoming version. 
    250 
    251    Example: If PHP 5.3.7 is being released, then PHP 5.3.8 is the next QA version,
    252    so replace 5.3.7 with 5.3.8 within $QA_RELEASES.
    253 
    254 Re-releasing the same version (or -pl)
    255 --------------------------------------
    256 
    257 1. Commit the new binaries to ``phpweb/distributions/``
    258 
    259 2. Edit ``phpweb/include/version.inc`` and change (X=major release number):
    260 
    261  a. If only releasing for one OS, make sure you edit only those variables
    262 
    263  b. ``$PHP_X_VERSION`` to the correct version
    264 
    265  c. ``$PHP_X_DATE`` to the release date
    266 
    267  d. ``$PHP_X_MD5`` array and update all the md5 sums
    268 
    269  e. Make sure there are no outdated "notes" or edited "date" keys in the
    270  ``$RELEASES[X][$PHP_X_VERSION]["source"]`` array
    271 
    272 3. Add a short notice to phpweb stating that there is a new release, and
    273 highlight the major important things (security fixes) and when it is important
    274 to upgrade.
    275 
    276  a. Call php bin/createNewsEntry in your local phpweb checkout
    277 
    278  b. Add the content for the news entry
    279 
    280 4. Commit all the changes (``include/version.inc``, ``archive/archive.xml``,
    281 ``archive/entries/YYYY-MM-DD-N.xml``)
    282 
    283 5. Wait an hour or two, then send a mail to php-announce (a] lists.php.net,
    284 php-general (a] lists.php.net and internals (a] lists.php.net with a text similar to
    285 the news entry.
    286 

README.SELF-CONTAINED-EXTENSIONS

      1 $Id: README.SELF-CONTAINED-EXTENSIONS 242949 2007-09-26 15:44:16Z cvs2svn $
      2 =============================================================================
      3 
      4 HOW TO CREATE A SELF-CONTAINED PHP EXTENSION
      5 
      6   A self-contained extension can be distributed independently of
      7   the PHP source. To create such an extension, two things are
      8   required:
      9 
     10   - Configuration file (config.m4)
     11   - Source code for your module
     12 
     13   We will describe now how to create these and how to put things
     14   together.
     15 
     16 PREPARING YOUR SYSTEM
     17 
     18   While the result will run on any system, a developer's setup needs these
     19   tools:
     20 
     21     GNU autoconf
     22     GNU automake
     23     GNU libtool
     24     GNU m4
     25 
     26   All of these are available from 
     27 
     28     ftp://ftp.gnu.org/pub/gnu/
     29 
     30 CONVERTING AN EXISTING EXTENSION
     31 
     32   Just to show you how easy it is to create a self-contained
     33   extension, we will convert an embedded extension into a
     34   self-contained one. Install PHP and execute the following
     35   commands.
     36   
     37      $ mkdir /tmp/newext
     38      $ cd /tmp/newext
     39 
     40   You now have an empty directory. We will copy the files from
     41   the mysql extension:
     42 
     43      $ cp -rp php-4.0.X/ext/mysql/* .
     44 
     45   It is time to finish the module. Run:
     46 
     47      $ phpize
     48 
     49   You can now ship the contents of the directory - the extension
     50   can live completely on its own.
     51 
     52   The user instructions boil down to
     53 
     54      $ ./configure \
     55             [--with-php-config=/path/to/php-config] \
     56             [--with-mysql=MYSQL-DIR]
     57      $ make install
     58 
     59   The MySQL module will either use the embedded MySQL client 
     60   library or the MySQL installation in MYSQL-DIR.
     61 
     62 
     63 DEFINING THE NEW EXTENSION
     64 
     65   Our demo extension is called "foobar".
     66 
     67   It consists of two source files "foo.c" and "bar.c"
     68   (and any arbitrary amount of header files, but that is not
     69   important here).
     70   
     71   The demo extension does not reference any external 
     72   libraries (that is important, because the user does not
     73   need to specify anything).
     74 
     75 
     76   LTLIBRARY_SOURCES specifies the names of the sources files. You can
     77   name an arbitrary number of source files here.
     78 
     79 CREATING THE M4 CONFIGURATION FILE
     80 
     81   The m4 configuration can perform additional checks. For a 
     82   self-contained extension, you do not need more than a few
     83   macro calls.
     84 
     85 ------------------------------------------------------------------------------
     86 PHP_ARG_ENABLE(foobar,whether to enable foobar,
     87 [  --enable-foobar            Enable foobar])
     88 
     89 if test "$PHP_FOOBAR" != "no"; then
     90   PHP_NEW_EXTENSION(foobar, foo.c bar.c, $ext_shared)
     91 fi
     92 ------------------------------------------------------------------------------
     93 
     94   PHP_ARG_ENABLE will automatically set the correct variables, so
     95   that the extension will be enabled by PHP_NEW_EXTENSION in shared mode.
     96 
     97   The first argument of PHP_NEW_EXTENSION describes the name of the
     98   extension.  The second names the source-code files.  The third passes
     99   $ext_shared which is set by PHP_ARG_ENABLE/WITH to PHP_NEW_EXTENSION.
    100   
    101   Please use always PHP_ARG_ENABLE or PHP_ARG_WITH. Even if you do not
    102   plan to distribute your module with PHP, these facilities allow you
    103   to integrate your module easily into the main PHP module framework.
    104 
    105 CREATING SOURCE FILES
    106 
    107   ext_skel can be of great help when creating the common code for all modules
    108   in PHP for you and also writing basic function definitions and C code for
    109   handling arguments passed to your functions. See README.EXT_SKEL for further
    110   information.
    111 
    112   As for the rest, you are currently alone here. There are a lot of existing
    113   modules, use a simple module as a starting point and add your own code.
    114 
    115 
    116 CREATING THE SELF-CONTAINED EXTENSION
    117 
    118   Put config.m4 and the source files into one directory. Then, run phpize
    119   (this is installed during make install by PHP 4.0).
    120 
    121   For example, if you configured PHP with --prefix=/php, you would run
    122 
    123      $ /php/bin/phpize
    124 
    125   This will automatically copy the necessary build files and create
    126   configure from your config.m4.
    127 
    128   And that's it. You now have a self-contained extension.
    129 
    130 INSTALLING A SELF-CONTAINED EXTENSION
    131 
    132   An extension can be installed by running:
    133 
    134      $ ./configure \
    135             [--with-php-config=/path/to/php-config]
    136      $ make install
    137 
    138 ADDING SHARED MODULE SUPPORT TO A MODULE
    139 
    140   In order to be useful, a self-contained extension must be loadable
    141   as a shared module. I will explain now how you can add shared module 
    142   support to an existing module called foo.
    143 
    144   1. In config.m4, use PHP_ARG_WITH/PHP_ARG_ENABLE. Then you will
    145      automatically be able to use --with-foo=shared[,..] or
    146      --enable-foo=shared[,..].
    147 
    148   2. In config.m4, use PHP_NEW_EXTENSION(foo,.., $ext_shared) to enable
    149      building the extension.
    150 
    151   3. Add the following lines to your C source file:
    152 
    153         #ifdef COMPILE_DL_FOO
    154         ZEND_GET_MODULE(foo)
    155         #endif
    156 

README.STREAMS

      1 An Overview of the PHP Streams abstraction
      2 ==========================================
      3 $Id: README.STREAMS 242949 2007-09-26 15:44:16Z cvs2svn $
      4 
      5 WARNING: some prototypes in this file are out of date.
      6 The information contained here is being integrated into
      7 the PHP manual - stay tuned...
      8 
      9 Please send comments to: Wez Furlong <wez (a] thebrainroom.com>
     10 
     11 Why Streams?
     12 ============
     13 You may have noticed a shed-load of issock parameters flying around the PHP
     14 code; we don't want them - they are ugly and cumbersome and force you to
     15 special case sockets and files every time you need to work with a "user-level"
     16 PHP file pointer.
     17 Streams take care of that and present the PHP extension coder with an ANSI
     18 stdio-alike API that looks much nicer and can be extended to support non file
     19 based data sources.
     20 
     21 Using Streams
     22 =============
     23 Streams use a php_stream* parameter just as ANSI stdio (fread etc.) use a
     24 FILE* parameter.
     25 
     26 The main functions are:
     27 
     28 PHPAPI size_t php_stream_read(php_stream * stream, char * buf, size_t count);
     29 PHPAPI size_t php_stream_write(php_stream * stream, const char * buf, size_t
     30         count);
     31 PHPAPI size_t php_stream_printf(php_stream * stream TSRMLS_DC, 
     32         const char * fmt, ...);
     33 PHPAPI int php_stream_eof(php_stream * stream);
     34 PHPAPI int php_stream_getc(php_stream * stream);
     35 PHPAPI char *php_stream_gets(php_stream * stream, char *buf, size_t maxlen);
     36 PHPAPI int php_stream_close(php_stream * stream);
     37 PHPAPI int php_stream_flush(php_stream * stream);
     38 PHPAPI int php_stream_seek(php_stream * stream, off_t offset, int whence);
     39 PHPAPI off_t php_stream_tell(php_stream * stream);
     40 PHPAPI int php_stream_lock(php_stream * stream, int mode);
     41 
     42 These (should) behave in the same way as the ANSI stdio functions with similar
     43 names: fread, fwrite, fprintf, feof, fgetc, fgets, fclose, fflush, fseek, ftell, flock.
     44 
     45 Opening Streams
     46 ===============
     47 In most cases, you should use this API:
     48 
     49 PHPAPI php_stream *php_stream_open_wrapper(char *path, char *mode,
     50     int options, char **opened_path TSRMLS_DC);
     51 
     52 Where:
     53     path is the file or resource to open.
     54     mode is the stdio compatible mode eg: "wb", "rb" etc.
     55     options is a combination of the following values:
     56         IGNORE_PATH  (default) - don't use include path to search for the file
     57         USE_PATH        - use include path to search for the file
     58         IGNORE_URL      - do not use plugin wrappers
     59         REPORT_ERRORS   - show errors in a standard format if something
     60                           goes wrong.
     61         STREAM_MUST_SEEK - If you really need to be able to seek the stream
     62                            and don't need to be able to write to the original
     63                            file/URL, use this option to arrange for the stream
     64                            to be copied (if needed) into a stream that can
     65                            be seek()ed.
     66                            
     67     opened_path is used to return the path of the actual file opened,
     68     but if you used STREAM_MUST_SEEK, may not be valid.  You are
     69     responsible for efree()ing opened_path.  opened_path may be (and usually
     70     is) NULL.
     71 
     72 If you need to open a specific stream, or convert standard resources into
     73 streams there are a range of functions to do this defined in php_streams.h.
     74 A brief list of the most commonly used functions:
     75 
     76 PHPAPI php_stream *php_stream_fopen_from_file(FILE *file, const char *mode);
     77     Convert a FILE * into a stream.
     78 
     79 PHPAPI php_stream *php_stream_fopen_tmpfile(void);
     80     Open a FILE * with tmpfile() and convert into a stream.
     81 
     82 PHPAPI php_stream *php_stream_fopen_temporary_file(const char *dir,
     83     const char *pfx, char **opened_path TSRMLS_DC);
     84     Generate a temporary file name and open it.
     85 
     86 There are some network enabled relatives in php_network.h:
     87 
     88 PHPAPI php_stream *php_stream_sock_open_from_socket(int socket, int persistent);
     89     Convert a socket into a stream.
     90 
     91 PHPAPI php_stream *php_stream_sock_open_host(const char *host, unsigned short port,
     92 		int socktype, int timeout, int persistent);
     93     Open a connection to a host and return a stream.
     94 
     95 PHPAPI php_stream *php_stream_sock_open_unix(const char *path, int persistent,
     96     struct timeval *timeout);
     97     Open a UNIX domain socket.
     98    
     99 
    100 Stream Utilities
    101 ================
    102 
    103 If you need to copy some data from one stream to another, you will be please
    104 to know that the streams API provides a standard way to do this:
    105 
    106 PHPAPI size_t php_stream_copy_to_stream(php_stream *src,
    107     php_stream *dest, size_t maxlen);
    108 
    109 If you want to copy all remaining data from the src stream, pass
    110 PHP_STREAM_COPY_ALL as the maxlen parameter, otherwise maxlen indicates the
    111 number of bytes to copy.
    112 This function will try to use mmap where available to make the copying more
    113 efficient.
    114 
    115 If you want to read the contents of a stream into an allocated memory buffer,
    116 you should use:
    117 
    118 PHPAPI size_t php_stream_copy_to_mem(php_stream *src, char **buf,
    119     size_t maxlen, int persistent);
    120 
    121 This function will set buf to the address of the buffer that it allocated,
    122 which will be maxlen bytes in length, or will be the entire length of the
    123 data remaining on the stream if you set maxlen to PHP_STREAM_COPY_ALL.
    124 The buffer is allocated using pemalloc(); you need to call pefree() to
    125 release the memory when you are done.
    126 As with copy_to_stream, this function will try use mmap where it can.
    127 
    128 If you have an existing stream and need to be able to seek() it, you
    129 can use this function to copy the contents into a new stream that can
    130 be seek()ed:
    131 
    132 PHPAPI int php_stream_make_seekable(php_stream *origstream, php_stream **newstream);
    133 
    134 It returns one of the following values:
    135 #define PHP_STREAM_UNCHANGED	0 /* orig stream was seekable anyway */
    136 #define PHP_STREAM_RELEASED		1 /* newstream should be used; origstream is no longer valid */
    137 #define PHP_STREAM_FAILED		2 /* an error occurred while attempting conversion */
    138 #define PHP_STREAM_CRITICAL		3 /* an error occurred; origstream is in an unknown state; you should close origstream */
    139 
    140 make_seekable will always set newstream to be the stream that is valid
    141 if the function succeeds.
    142 When you have finished, remember to close the stream.
    143 
    144 NOTE: If you only need to seek forward, there is no need to call this
    145 function, as the php_stream_seek can emulate forward seeking when the
    146 whence parameter is SEEK_CUR.
    147 
    148 NOTE: Writing to the stream may not affect the original source, so it
    149 only makes sense to use this for read-only use.
    150 
    151 NOTE: If the origstream is network based, this function will block
    152 until the whole contents have been downloaded.
    153 
    154 NOTE: Never call this function with an origstream that is referenced
    155 as a resource! It will close the origstream on success, and this
    156 can lead to a crash when the resource is later used/released.
    157 
    158 NOTE: If you are opening a stream and need it to be seekable, use the
    159 STREAM_MUST_SEEK option to php_stream_open_wrapper();
    160 
    161 PHPAPI int php_stream_supports_lock(php_stream * stream);
    162 
    163 This function will return either 1 (success) or 0 (failure) indicating whether or
    164 not a lock can be set on this stream. Typically you can only set locks on stdio streams.
    165 
    166 Casting Streams
    167 ===============
    168 What if your extension needs to access the FILE* of a user level file pointer?
    169 You need to "cast" the stream into a FILE*, and this is how you do it:
    170 
    171 FILE * fp;
    172 php_stream * stream; /* already opened */
    173 
    174 if (php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void*)&fp, REPORT_ERRORS) == FAILURE)    {
    175     RETURN_FALSE;
    176 }
    177 
    178 The prototype is:
    179 
    180 PHPAPI int php_stream_cast(php_stream * stream, int castas, void ** ret, int
    181         show_err);
    182 
    183 The show_err parameter, if non-zero, will cause the function to display an
    184 appropriate error message of type E_WARNING if the cast fails.
    185 
    186 castas can be one of the following values:
    187 PHP_STREAM_AS_STDIO - a stdio FILE*
    188 PHP_STREAM_AS_FD - a generic file descriptor
    189 PHP_STREAM_AS_SOCKETD - a socket descriptor
    190 
    191 If you ask a socket stream for a FILE*, the abstraction will use fdopen to
    192 create it for you.  Be warned that doing so may cause buffered data to be lost
    193 if you mix ANSI stdio calls on the FILE* with php stream calls on the stream.
    194 
    195 If your system has the fopencookie function, php streams can synthesize a
    196 FILE* on top of any stream, which is useful for SSL sockets, memory based
    197 streams, data base streams etc. etc.
    198 
    199 In situations where this is not desirable, you should query the stream
    200 to see if it naturally supports FILE *.  You can use this code snippet
    201 for this purpose:
    202 
    203     if (php_stream_is(stream, PHP_STREAM_IS_STDIO)) {
    204         /* can safely cast to FILE* with no adverse side effects */
    205     }
    206 
    207 You can use:
    208 
    209 PHPAPI int php_stream_can_cast(php_stream * stream, int castas)
    210 
    211 to find out if a stream can be cast, without actually performing the cast, so
    212 to check if a stream is a socket you might use:
    213 
    214 if (php_stream_can_cast(stream, PHP_STREAM_AS_SOCKETD) == SUCCESS)  {
    215     /* it can be a socket */
    216 }
    217 
    218 Please note the difference between php_stream_is and php_stream_can_cast;
    219 stream_is tells you if the stream is a particular type of stream, whereas
    220 can_cast tells you if the stream can be forced into the form you request.
    221 The former doesn't change anything, while the later *might* change some
    222 state in the stream.
    223 
    224 Stream Internals
    225 ================
    226 
    227 There are two main structures associated with a stream - the php_stream
    228 itself, which holds some state information (and possibly a buffer) and a
    229 php_stream_ops structure, which holds the "virtual method table" for the
    230 underlying implementation.
    231 
    232 The php_streams ops struct consists of pointers to methods that implement
    233 read, write, close, flush, seek, gets and cast operations.  Of these, an
    234 implementation need only implement write, read, close and flush.  The gets
    235 method is intended to be used for streams if there is an underlying method
    236 that can efficiently behave as fgets.  The ops struct also contains a label
    237 for the implementation that will be used when printing error messages - the
    238 stdio implementation has a label of "STDIO" for example.
    239 
    240 The idea is that a stream implementation defines a php_stream_ops struct, and
    241 associates it with a php_stream using php_stream_alloc.
    242 
    243 As an example, the php_stream_fopen() function looks like this:
    244 
    245 PHPAPI php_stream * php_stream_fopen(const char * filename, const char * mode)
    246 {
    247     FILE * fp = fopen(filename, mode);
    248     php_stream * ret;
    249     
    250     if (fp) {
    251         ret = php_stream_alloc(&php_stream_stdio_ops, fp, 0, 0, mode);
    252         if (ret)
    253             return ret;
    254 
    255         fclose(fp);
    256     }
    257     return NULL;
    258 }
    259 
    260 php_stream_stdio_ops is a php_stream_ops structure that can be used to handle
    261 FILE* based streams.
    262 
    263 A socket based stream would use code similar to that above to create a stream
    264 to be passed back to fopen_wrapper (or it's yet to be implemented successor).
    265 
    266 The prototype for php_stream_alloc is this:
    267 
    268 PHPAPI php_stream * php_stream_alloc(php_stream_ops * ops, void * abstract,
    269         size_t bufsize, int persistent, const char * mode)
    270 
    271 ops is a pointer to the implementation,
    272 abstract holds implementation specific data that is relevant to this instance
    273 of the stream,
    274 bufsize is the size of the buffer to use - if 0, then buffering at the stream
    275 level will be disabled (recommended for underlying sources that implement
    276 their own buffering - such a FILE*),
    277 persistent controls how the memory is to be allocated - persistently so that
    278 it lasts across requests, or non-persistently so that it is freed at the end
    279 of a request (it uses pemalloc),
    280 mode is the stdio-like mode of operation - php streams places no real meaning
    281 in the mode parameter, except that it checks for a 'w' in the string when
    282 attempting to write (this may change).
    283 
    284 The mode parameter is passed on to fdopen/fopencookie when the stream is cast
    285 into a FILE*, so it should be compatible with the mode parameter of fopen().
    286 
    287 Writing your own stream implementation
    288 ======================================
    289 
    290 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    291 RULE #1: when writing your own streams: make sure you have configured PHP with
    292 --enable-debug.
    293 I've taken some great pains to hook into the Zend memory manager to help track
    294 down allocation problems.  It will also help you spot incorrect use of the
    295 STREAMS_DC, STREAMS_CC and the semi-private STREAMS_REL_CC macros for function
    296 definitions.
    297 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    298 
    299 RULE #2: Please use the stdio stream as a reference; it will help you
    300 understand the semantics of the stream operations, and it will always
    301 be more up to date than these docs :-)
    302 
    303 First, you need to figure out what data you need to associate with the
    304 php_stream.  For example, you might need a pointer to some memory for memory
    305 based streams, or if you were making a stream to read data from an RDBMS like
    306 MySQL, you might want to store the connection and rowset handles.
    307 
    308 The stream has a field called abstract that you can use to hold this data.
    309 If you need to store more than a single field of data, define a structure to
    310 hold it, allocate it (use pemalloc with the persistent flag set
    311 appropriately), and use the abstract pointer to refer to it.
    312 
    313 For structured state you might have this:
    314 
    315 struct my_state {
    316     MYSQL conn;
    317     MYSQL_RES * result;
    318 };
    319 
    320 struct my_state * state = pemalloc(sizeof(struct my_state), persistent);
    321 
    322 /* initialize the connection, and run a query, using the fields in state to
    323  * hold the results */
    324 
    325 state->result = mysql_use_result(&state->conn);
    326 
    327 /* now allocate the stream itself */
    328 stream = php_stream_alloc(&my_ops, state, 0, persistent, "r");
    329 
    330 /* now stream->abstract == state */
    331 
    332 Once you have that part figured out, you can write your implementation and
    333 define the your own php_stream_ops struct (we called it my_ops in the above
    334 example).
    335 
    336 For example, for reading from this weird MySQL stream:
    337 
    338 static size_t php_mysqlop_read(php_stream * stream, char * buf, size_t count)
    339 {
    340     struct my_state * state = (struct my_state*)stream->abstract;
    341 
    342     if (buf == NULL && count == 0)  {
    343         /* in this special case, php_streams is asking if we have reached the
    344          * end of file */
    345         if (... at end of file ...)
    346             return EOF;
    347         else
    348             return 0;
    349     }
    350     
    351     /* pull out some data from the stream and put it in buf */
    352     ... mysql_fetch_row(state->result) ...
    353     /* we could do something strange, like format the data as XML here,
    354         and place that in the buf, but that brings in some complexities,
    355         such as coping with a buffer size too small to hold the data,
    356         so I won't even go in to how to do that here */
    357 }
    358 
    359 Implement the other operations - remember that write, read, close and flush
    360 are all mandatory.  The rest are optional.  Declare your stream ops struct:
    361 
    362 php_stream_ops my_ops = {
    363     php_mysqlop_write, php_mysqlop_read, php_mysqlop_close,
    364     php_mysqlop_flush, NULL, NULL, NULL,
    365     "Strange MySQL example"
    366 }
    367 
    368 Thats it!
    369 
    370 Take a look at the STDIO implementation in streams.c for more information
    371 about how these operations work.
    372 The main thing to remember is that in your close operation you need to release
    373 and free the resources you allocated for the abstract field.  In the case of
    374 the example above, you need to use mysql_free_result on the rowset, close the
    375 connection and then use pefree to dispose of the struct you allocated.
    376 You may read the stream->persistent field to determine if your struct was
    377 allocated in persistent mode or not.
    378 
    379 vim:tw=78:et
    380 

README.SUBMITTING_PATCH

      1 Submitting Enhancements and Patches to PHP
      2 ==========================================
      3 
      4 This document describes how to submit an enhancement or patch for PHP.
      5 It's easy!
      6 
      7 You don't need any login accounts or special access to download,
      8 build, debug and begin submitting PHP, PECL or PEAR code, tests or
      9 documentation.  Once you've followed this README and had several
     10 patches accepted, commit privileges are often quickly granted.
     11 
     12 An excellent article to read first is:
     13 http://phpadvent.org/2008/less-whining-more-coding-by-elizabeth-smith
     14 
     15 
     16 Online Forums
     17 -------------
     18 There are several IRC channels where PHP developers are often
     19 available to discuss questions.  They include #php.pecl, #php.doc and
     20 #pear on the EFNet network and #php-dev-win on FreeNode.
     21 
     22 
     23 PHP Patches
     24 -----------
     25 If you are fixing broken functionality in PHP C source code first
     26 create a bug or identify an existing bug at http://bugs.php.net/.  A
     27 bug can be used to track the patch progress and prevent your changes
     28 getting lost in the PHP mail archives.
     29 
     30 If your change is large then create a Request For Comment (RFC) page
     31 on http://wiki.php.net/rfc, discuss it with the extension maintainer,
     32 and discuss it on the development mail list internals (a] lists.php.net.
     33 RFC Wiki accounts can be requested on
     34 http://wiki.php.net/start?do=register.  PHP extension maintainers can
     35 be found in the EXTENSIONS file in the PHP source.  Mail list
     36 subscription is explained on http://www.php.net/mailing-lists.php.
     37 
     38 Information on PHP internal C functions is at
     39 http://www.php.net/internals, though this is considered incomplete.
     40 Various external resources can be found on the web.  A standard
     41 printed reference is the book "Extending and Embedding PHP" by Sara
     42 Golemon.
     43 
     44 Attach the patch to the PHP bug and consider sending a notification
     45 email about the change to internals (a] lists.php.net.  Also CC the
     46 extension maintainer.  Explain what has been changed by your patch.
     47 Test scripts should be included.
     48 
     49 Please make the mail subject prefix "[PATCH]".  If attaching a patch,
     50 ensure it has a file extension of ".txt".  This is because only MIME
     51 attachments of type 'text/*' are accepted.
     52 
     53 
     54 PHP Documentation Patches
     55 -------------------------
     56 If you are fixing incorrect PHP documentation first create a bug or
     57 identify an existing bug at http://bugs.php.net/.  A bug can be used
     58 to track the patch progress and prevent your changes getting lost in
     59 the PHP mail archives.
     60 
     61 If your change is large, then first discuss it with the mail list
     62 phpdoc (a] lists.php.net.  Subscription is explained on
     63 http://www.php.net/mailing-lists.php.
     64 
     65 Information on contributing to PHP documentation is at
     66 http://php.net/dochowto and http://wiki.php.net/doc/howto
     67 
     68 Attach the patch to the PHP bug and consider sending a notification
     69 email about the change to phpdoc (a] lists.php.net.  Explain what has been
     70 fixed/added/changed by your patch.
     71 
     72 Please make the mail subject prefix "[PATCH]".  Include the bug id(s)
     73 which can be closed by your patch.  If attaching a patch, ensure it
     74 has a file extension of ".txt".  This is because only MIME attachments
     75 of type 'text/*' are accepted.
     76 
     77 
     78 PECL Extension Patches: http://pecl.php.net/
     79 --------------------------------------------
     80 If you are fixing broken functionality in a PECL extension then create
     81 a bug or identify an existing bug at http://pecl.php.net/bugs/.  A bug
     82 can be used to track the patch progress and prevent your changes
     83 getting lost in the PHP mail archives.
     84 
     85 If your change is large then create a Request For Comment (RFC) page
     86 on http://wiki.php.net/rfc, discuss it with the extension maintainer,
     87 and discuss it on the development mail list pecl-dev (a] lists.php.net.
     88 PECL mail list subscription is explained on
     89 http://pecl.php.net/support.php.  RFC Wiki accounts can be requested
     90 on http://wiki.php.net/start?do=register
     91 
     92 Information on PHP internal C functions is at
     93 http://www.php.net/internals, though this is considered incomplete.
     94 Various external resources can be found on the web.  A standard
     95 printed reference is the book "Extending and Embedding PHP" by Sara
     96 Golemon.
     97 
     98 Update any open bugs and add a link to the source of your patch.  Send
     99 the patch or pointer to the bug to pecl-dev (a] lists.php.net.  Also CC
    100 the extension maintainer.  Explain what has been changed by your
    101 patch.  Test scripts should be included.
    102 
    103 Please make the mail subject prefix "[PATCH] ...".  Include the patch
    104 as an attachment with a file extension of ".txt".  This is because
    105 only MIME attachments of type 'text/*' are accepted.
    106 
    107 
    108 PEAR Package Patches: http://pear.php.net/
    109 ------------------------------------------
    110 Information on contributing to PEAR is available at
    111 http://pear.php.net/manual/en/developers-newmaint.php and
    112 http://pear.php.net/manual/en/guide-developers.php
    113 
    114 
    115 How to create your PHP, PHP Documentation or PECL patch
    116 -------------------------------------------------------
    117 PHP and PECL use Subversion (SVN) for revision control.  Read
    118 http://www.php.net/svn.php for help on using SVN to get and build PHP
    119 source code.  We recommend using a Sparse Directory checkout described
    120 in http://wiki.php.net/vcs/svnfaq.  If you are new to SVN, read
    121 http://svnbook.red-bean.com.
    122 
    123 Generally we ask that bug fix patches work on the current stable PHP
    124 development branches and on "trunk".  New PHP features only need to
    125 work on "trunk".
    126 
    127 Read CODING_STANDARDS before you start working.
    128 
    129 After modifying the source see README.TESTING and
    130 http://qa.php.net/write-test.php for how to test.  Submitting test
    131 scripts helps us to understand what functionality has changed.  It is
    132 important for the stability and maintainability of PHP that tests are
    133 comprehensive.
    134 
    135 After testing is finished, create a patch file using the command:
    136 
    137   svn diff > your_patch.txt
    138 
    139 For ease of review and later troubleshooting, submit individual
    140 patches for each bug or feature.
    141 
    142 
    143 Checklist for submitting your PHP or PECL code patch
    144 ----------------------------------------------------
    145  - Update SVN source just before running your final 'diff' and
    146    before testing.
    147  - Add in-line comments and/or have external documentation ready.
    148    Use only "/* */" style comments, not "//".
    149  - Create test scripts for use with "make test".
    150  - Run "make test" to check your patch doesn't break other features.
    151  - Rebuild PHP with --enable-debug (which will show some kinds of
    152    memory errors) and check the PHP and web server error logs after
    153    running your PHP tests.
    154  - Rebuild PHP with --enable-maintainer-zts to check your patch
    155    compiles on multi-threaded web servers.
    156  - Review the patch once more just before submitting it.
    157 
    158 
    159 What happens after submitting your PHP, PHP Documentation or PECL patch
    160 -----------------------------------------------------------------------
    161 If your patch is easy to review and obviously has no side-effects,
    162 it might be committed relatively quickly.
    163 
    164 Because PHP is a volunteer-driven effort more complex patches will
    165 require patience on your side.  If you do not receive feedback in a
    166 few days, consider resubmitting the patch.  Before doing this think
    167 about these questions:
    168 
    169  - Did I send the patch to the right mail list?
    170  - Did I review the mail list archives to see if these kind of
    171    changes had been discussed before?
    172  - Did I explain my patch clearly?
    173  - Is my patch too hard to review? Because of what factors?
    174 
    175 
    176 What happens when your PHP or PECL patch is applied
    177 ---------------------------------------------------
    178 Your name will likely be included in the SVN commit log.  If your
    179 patch affects end users, a brief description and your name might be
    180 added to the NEWS file.
    181 
    182 Thank you for patching PHP!
    183 

README.SVN-RULES

      1 ====================
      2   SVN Commit Rules
      3 ====================
      4 
      5 This is the first file you should be reading after you get your SVN account.
      6 We'll assume you're basically familiar with SVN, but feel free to post
      7 your questions on the mailing list. Please have a look at
      8 http://svnbook.red-bean.com/ for more detailed information on SVN.
      9 
     10 PHP is developed through the efforts of a large number of people.
     11 Collaboration is a Good Thing(tm), and SVN lets us do this. Thus, following
     12 some basic rules with regards to SVN usage will::
     13 
     14    a. Make everybody happier, especially those responsible for maintaining
     15       the SVN itself.
     16 
     17    b. Keep the changes consistently well documented and easily trackable.
     18 
     19    c. Prevent some of those 'Oops' moments.
     20 
     21    d. Increase the general level of good will on planet Earth.
     22 
     23 Having said that, here are the organizational rules::
     24 
     25    1. Respect other people working on the project.
     26 
     27    2. Discuss any significant changes on the list before committing and get
     28       confirmation from the release manager for the given branch.
     29 
     30    3. Look at EXTENSIONS file to see who is the primary maintainer of
     31       the code you want to contribute to.
     32 
     33    4. If you "strongly disagree" about something another person did, don't
     34       start fighting publicly - take it up in private email.
     35 
     36    5. If you don't know how to do something, ask first!
     37 
     38    6. Test your changes before committing them. We mean it. Really.
     39       To do so use "make test".
     40 
     41    7. For development use the --enable-maintainer-zts switch to ensure your
     42       code handles TSRM correctly and doesn't break for those who need that.
     43 
     44 Currently we have the following branches in use::
     45 
     46   trunk             The active development branch. 
     47 
     48   branches/PHP_5_4  Is used to release the PHP 5.4.x series. It still allows for
     49                     larger enhancements.
     50 
     51   branches/PHP_5_3  Is used to release the PHP 5.3.x series. This is current 
     52                     stable version and is open for bugfixes and small
     53                     improvements (check with RMs if in doubt).
     54 
     55   branches/PHP_5_2  Is used to release the PHP 5.2.x series. It is closed for 
     56                     changes now.
     57 
     58   branches/PHP_5_1  This branch is closed.
     59 
     60   branches/PHP_4_4  This branch is closed.
     61 
     62 The next few rules are more of a technical nature::
     63 
     64    1. All changes should first go to trunk and then get merged from trunk
     65       (aka MFH'ed) to all other relevant branches.
     66 
     67    2. DO NOT TOUCH ChangeLog! It is automagically updated from the commit
     68       messages every day. Woe be to those who attempt to mess with it.
     69 
     70    3. All news updates intended for public viewing, such as new features,
     71       bug fixes, improvements, etc., should go into the NEWS file of the
     72       *first* to be released version with the given change. In other words
     73       any NEWS file change only needs to done in one branch.
     74 
     75       NB! Lines, starting with @ will go automagically into NEWS file, but
     76       this is NOT recommended, though. Please, add news entries directly to
     77       NEWS file and don't forget to keep them adjusted and sorted.
     78 
     79    4. Do not commit multiple file and dump all messages in one commit. If you
     80       modified several unrelated files, commit each group separately and
     81       provide a nice commit message for each one. See example below.
     82 
     83    5. Do write your commit message in such a way that it makes sense even
     84       without the corresponding diff. One should be able to look at it, and
     85       immediately know what was modified. Definitely include the function name
     86       in the message as shown below.
     87 
     88    6. In your commit messages, keep each line shorter than 80 characters. And
     89       try to align your lines vertically, if they wrap. It looks bad otherwise.
     90 
     91    7. If you modified a function that is callable from PHP, prepend PHP to
     92       the function name as shown below.
     93 
     94 
     95 The format of the commit messages is pretty simple.
     96 
     97 Use a - to start a new item in your commit message.
     98 
     99 If a line begins with #, it is taken to be a comment and will not appear
    100 in the ChangeLog. Everything else goes into the ChangeLog.
    101 
    102 It is important to note that if your comment or news logline spans multiple
    103 lines, you have to put # at the beginning of **every** such line.
    104 
    105 Example. Say you modified two files, datetime.c and string.c. In datetime.c you
    106 added a new format option for the date() function, and in string.c you fixed a
    107 memory leak in php_trim(). Don't commit both of these at once. Commit them
    108 separately and try to make sure your commit messages look something like the
    109 following.
    110 
    111 For datetime.c::
    112 
    113   - Added new 'K' format modifier to date() for printing out number of days
    114     until New Year's Eve.
    115 
    116 For string.c::
    117 
    118   - Fixed a memory leak in php_trim() resulting from improper use of zval_dtor().
    119   #- Man, that thing was leaking all over the place!
    120 
    121 The # lines will be omitted from the ChangeLog automagically.
    122 
    123 Use the [DOC] tag in your log message whenever you feel that your changes
    124 imply a documentation modification. The php-doc team will automatically
    125 get notified about your commit through the php-doc mailing list.
    126 
    127 If you fix some bugs, you should note the bug ID numbers in your
    128 commit message. Bug ID should be prefixed by "#" for easier access to
    129 bug report when developers are browsing CVS via LXR or Bonsai.
    130 
    131 Example::
    132 
    133   Fixed bug #14016 (pgsql notice handler double free crash bug.)
    134 
    135 If you don't see your messages in ChangeLog right away, don't worry!
    136 These files are updated once a day, so your stuff will not show up until
    137 somewhat later.
    138 
    139 When you change the NEWS file for a bug fix, then please keep the bugs
    140 sorted in decreasing order under the fixed version.
    141 
    142 You can use LXR (http://lxr.php.net/) and Bonsai (http://bonsai.php.net/)
    143 to look at PHP SVN repository in various ways.
    144 
    145 To receive daily updates to ChangeLog and NEWS, send an empty message to
    146 php-cvs-daily-subscribe (a] lists.php.net.
    147 
    148 Happy hacking,
    149 
    150 PHP Team
    151 

README.TESTING

      1 [IMPORTANT NOTICE]
      2 ------------------
      3  Failed tests usualy indicate a problem with your local system setup
      4 and not within PHP itself (at least for official PHP release versions).
      5 You may decide to automaticaly submit a test summary to our QA workflow
      6 at the end of a test run.
      7  Please do *not* submit a failed test as a bug or ask for help on why
      8 it failed on your system without providing substantial backup information
      9 on *why* the test failed on your special setup. Thank you :-)
     10 
     11 
     12 [Testing Basics] 
     13 ----------------
     14  The easiest way to test your PHP build is to run "make test" from the
     15 command line after successfully compiling. This will run the complete
     16 tests for all enabled functionalities and extensions using the PHP
     17 CLI binary.
     18  To execute test scripts, you must build PHP with some SAPI, then you
     19 type "make test" to execute all or some test scripts saved under
     20 "tests" directory under source root directory.
     21 
     22 Usage:
     23 make test
     24 
     25  "make test" basically executes "run-tests.php" script
     26 under the source root (parallel builds will not work). Therefore you
     27 can execute the script as follows:
     28 
     29 TEST_PHP_EXECUTABLE=sapi/cli/php \
     30 sapi/cli/php [-c /path/to/php.ini] run-tests.php [ext/foo/tests/GLOB]
     31 
     32 
     33 [Which "php" executable "make test" look for]
     34 ---------------------------------------------
     35 If you are running the run-tests.php script from the command line (as above)
     36 you must set the TEST_PHP_EXECUTABLE environment variable to explicitly
     37 select the PHP executable that is to be tested, that is, used to run the test scripts.
     38 
     39 If you run the tests using make test, the PHP CLI and CGI executables are 
     40 automatically set for you. "make test" executes "run-tests.php" script with the CLI binary.  Some
     41 test scripts such as session must be executed by CGI SAPI. Therefore,
     42 you must build PHP with CGI SAPI to perform all tests.
     43 
     44 NOTE: PHP binary executing "run-tests.php" and php binary used for
     45 executing test scripts may differ. If you use different PHP binary for
     46 executing "run-tests.php" script, you may get errors.
     47 
     48 
     49 [Which php.ini is used]
     50 -----------------------
     51  "make test" uses the same php.ini file as it would once installed.
     52 The tests have been written to be independent of that php.ini file,
     53 so if you find a test that is affected by a setting, please report
     54 this, so we can address the issue.
     55 
     56 
     57 [Which test scripts are executed]
     58 ---------------------------------
     59  "run-tests.php" ("make test"), without any arguments executes all
     60 test scripts by extracting all directories named "tests"
     61 from the source root and any subdirectories below. If there are files,
     62 which have a "phpt" extension, "run-tests.php" looks at the sections
     63 in these files, determines whether it should run it, by evaluating
     64 the 'SKIP' section. If the test is eligible for execution, the 'FILE'
     65 section is extracted into a ".php" file (with the same name besides 
     66 the extension) and gets executed.
     67 When an argument is given or TESTS environment variable is set, the
     68 GLOB is expanded by the shell and any file with extension "*.phpt" is
     69 regarded as a test file.
     70 
     71  Tester can easily execute tests selectively with as follows.
     72 
     73 Examples:
     74 ./sapi/cli/php run-tests.php ext/mbstring/*
     75 ./sapi/cli/php run-tests.php ext/mbstring/020.phpt
     76 
     77 
     78 [Test results]
     79 --------------
     80  Test results are printed to standard output. If there is a failed test, 
     81 the "run-tests.php" script saves the result, the expected result and the
     82 code executed to the test script directory. For example, if 
     83 ext/myext/tests/myext.phpt fails to pass, the following files are created:
     84 
     85 ext/myext/tests/myext.php   - actual test file executed
     86 ext/myext/tests/myext.log   - log of test execution (L)
     87 ext/myext/tests/myext.exp   - expected output (E)
     88 ext/myext/tests/myext.out   - output from test script (O)
     89 ext/myext/tests/myext.diff  - diff of .out and .exp (D)
     90 
     91  Failed tests are always bugs. Either the test is bugged or not considering
     92 factors applying to the tester's environment, or there is a bug in PHP.
     93 If this is a known bug, we strive to provide bug numbers, in either the
     94 test name or the file name. You can check the status of such a bug, by
     95 going to: http://bugs.php.net/12345 where 12345 is the bug number.
     96 For clarity and automated processing, bug numbers are prefixed by a hash
     97 sign '#' in test names and/or test cases are named bug12345.phpt.
     98 
     99 NOTE: The files generated by tests can be selected by setting the
    100 environment variable TEST_PHP_LOG_FORMAT. For each file you want to be
    101 generated use the character in brackets as shown above (default is LEOD).
    102 The php file will be generated always.
    103 
    104 NOTE: You can set environment variable TEST_PHP_DETAILED to enable
    105 detailed test information.
    106 
    107 [Automated testing]
    108  If you like to keep up to speed, with latest developments and quality
    109 assurance, setting the environment variable NO_INTERACTION to 1, will not
    110 prompt the tester for any user input.
    111 
    112 Normally, the exit status of "make test" is zero, regardless of the results
    113 of independent tests. Set the environment variable REPORT_EXIT_STATUS to 1,
    114 and "make test" will set the exit status ("$?") to non-zero, when an
    115 individual test has failed.
    116 
    117 Example script to be run by cron(1):
    118 ========== qa-test.sh =============
    119 #!/bin/sh
    120 
    121 CO_DIR=$HOME/cvs/php5
    122 MYMAIL=qa-test (a] domain.com
    123 TMPDIR=/var/tmp
    124 TODAY=`date +"%Y%m%d"`
    125 
    126 # Make sure compilation enviroment is correct
    127 CONFIGURE_OPTS='--disable-all --enable-cli --with-pcre'
    128 export MAKE=gmake
    129 export CC=gcc
    130 
    131 # Set test environment
    132 export NO_INTERACTION=1
    133 export REPORT_EXIT_STATUS=1
    134 
    135 cd $CO_DIR
    136 cvs update . >>$TMPDIR/phpqatest.$TODAY
    137 ./cvsclean ; ./buildconf ; ./configure $CONFIGURE_OPTS ; $MAKE
    138 $MAKE test >>$TMPDIR/phpqatest.$TODAY 2>&1
    139 if test $? -gt 0
    140 then
    141         cat $TMPDIR/phpqatest.$TODAY | mail -s"PHP-QA Test Failed for $TODAY" $MYMAIL
    142 fi
    143 ========== end of qa-test.sh =============
    144 
    145 NOTE: the exit status of run-tests.php will be 1 when
    146 REPORT_EXIT_STATUS is set. The result of "make test" may be higher
    147 than that. At present, gmake 3.79.1 returns 2, so it is
    148 advised to test for non-zero, rather then a specific value.
    149 
    150 
    151 [Creating new test files]
    152 -------------------------
    153  Writing test file is very easy if you are used to PHP. 
    154 See the HOWTO at http://qa.php.net/write-test.php
    155 
    156 
    157 [How to help us]
    158 ----------------
    159  If you find bug in PHP, you can submit bug report AND test script 
    160 for us. You don't have to write complete script, just give us test
    161 script with following format. Please test the script and make sure
    162 you write the correct ACTUAL OUTPUT and EXPECTED OUTPUT before you
    163 submit.
    164 
    165 <?php
    166 /* 
    167 Bug #12345
    168 substr() bug. Do not return expected string.
    169 
    170 ACTUAL OUTPUT
    171 XYXA
    172 
    173 EXPECTED OUTPUT
    174 ABCD
    175 */
    176 
    177 $str = "XYZABCD";
    178 echo substr($str,3,7);
    179 
    180 ?>
    181 

README.TESTING2

      1 [IMPORTANT NOTICE]
      2 ------------------
      3 This is an addendum to README.TESTING with additional information 
      4 specific to server-tests.php.
      5 
      6 server-tests.php is backward compatible with tests developed for
      7 the original run-tests.php script.  server-tests is *not* used by
      8 'make test'.  server-tests was developed to provide support for
      9 testing PHP under it's primary environment, HTTP, and can run the
     10 PHP tests under any of the SAPI modules that are direct executables, 
     11 or are accessable via HTTP.
     12 
     13 [New features]
     14 ----------------
     15 * Command line interface:
     16   You can run 'php server-tests.php -h' to get all the possible options.
     17 * Configuration file:
     18   the -c argument will allow you to use a configuration file.  This is
     19   handy if you are testing multiple environments and need various options
     20   depending on the environment.
     21   see server-tests-config.php for details.
     22 * CGI Emulation:
     23   Will emulate a CGI environment when testing with the cgi sapi executable.
     24 * HTTP testing:
     25   can be configured to run test scripts through an HTTP server running
     26   on localhost.  localhost is required since either the web server must
     27   alias a directory to the php source directory, or the test scripts
     28   must be copied to a directory under the web server 
     29   (see config options TEST_WEB_BASE_URL, TEST_BASE_PATH, and TEST_WEB_EXT)
     30 * New sections supported for test files (see below)
     31 
     32 When running tests over http, tests that require ini settings different that what
     33 the web server runs under will be skipped.  Since the test harness defines a number
     34 of ini settings by default, the web server may require special configuration to
     35 make testing work.
     36 
     37 [Example Usage]
     38 ----------------
     39 Some (but not all!) examples of usage:
     40 
     41 1. run tests from the php source directory
     42     php server-tests.php -p /path/to/php-cli
     43 
     44 2. run tests using cgi emulation
     45     php server-tests.php -p /path/to/php-cgi
     46 
     47 3. run tests over http, copying test files into document root
     48     php server-tests.php -w -u http://localhost/test -m /path/to/htdocs/test
     49 
     50 4. run tests over http, php sources have been aliased in web server
     51     php server-tests.php -w -u http://localhost/test
     52     
     53 5. run tests using configuration file
     54     php server-tests.php -c /path/to/server-tests-config.php
     55 
     56 6. run tests using configuration file, but overriding some settings:
     57    (config file must be first)
     58     php server-tests.php -c /path/to/server-tests-config.php -w -t 3 -d /path/to/testdir
     59 
     60 NOTE: configuration as described in README.TESTING still works.
     61 
     62 [New Test Sections] 
     63 ----------------
     64 In addition to the traditional test sections 
     65 (see http://qa.php.net/write-test.php), several new sections are available 
     66 under server-tests.
     67 
     68 --POST--
     69 This is not a new section, but not multipart posts are supported for testing
     70 file uploads, or other types of POST data.
     71 
     72 --CGI--
     73 This section takes no value.  It merely provides a simple marker for tests
     74 that MUST be run as CGI, even if there is no --POST-- or --GET-- sections
     75 in the test file.
     76 
     77 --DESCRIPTION--
     78 Not used for anything, just a section for documenting the test
     79 
     80 --ENV--
     81 This section get's eval()'d to help build an environment for the 
     82 execution of the test.  This can be used to change environment
     83 vars that are used for CGI emulation, or simply to set env vars
     84 for cli testing.  A full example looks like:
     85 
     86   --ENV--
     87   return <<<END
     88   PATH_TRANSLATED=$filename
     89   PATH_INFO=$scriptname
     90   SCRIPT_NAME=$scriptname
     91   END;
     92 
     93 Some variables are made easily available for use in this section, they
     94 include:
     95   $filename     full native path to file, will become PATH_TRANSLATED
     96   $filepath     =dirname($filename)
     97   $scriptname   this is what will become SCRIPT_NAME unless you override it
     98   $docroot      the equivelant of DOCUMENT_ROOT under Apache
     99   $cwd          the directory that the test is being initiated from
    100   $this->conf   all server-tests configuration vars
    101   $this->env    all environment variables that will get passed to the test
    102 
    103 
    104 --REQUEST--
    105 This section is also eval'd, and is similar in nature to --ENV--.  However,
    106 this section is used to build the url used in an HTTP request.  Valid values
    107 to set in this section would include:
    108   SCRIPT_NAME   The inital part of the request url
    109   PATH_INFO     The pathinfo part of a request url
    110   FRAGMENT      The fragment section of a url (after #)
    111   QUERY_STRING  The query part of a url (after ?)
    112 
    113   --REQUEST--
    114   return <<<END
    115   PATH_INFO=/path/info
    116   END;
    117 
    118 --HEADERS--
    119 This section is also eval'd.  It is used to provide additional headers sent
    120 in an HTTP request, such as content type for multipart posts, cookies, etc.
    121 
    122   --HEADERS--
    123   return <<<END
    124   Content-Type=multipart/form-data; boundary=---------------------------240723202011929
    125   Content-Length=100
    126   END;
    127 
    128 --EXPECTHEADERS--
    129 This section can be used to define what headers are required to be
    130 received back from a request, and is checked in addition to the
    131 regular expect sections.  For example:
    132 
    133   --EXPECTHEADERS--
    134   Status: 404
    135 
    136 
    137 
    138 

README.UNIX-BUILD-SYSTEM

      1 PHP Build System V5 Overview
      2 
      3 - supports Makefile.ins during transition phase
      4 - not-really-portable Makefile includes have been eliminated
      5 - supports separate build directories without VPATH by using
      6   explicit rules only
      7 - does not waste disk-space/CPU-time for building temporary libraries
      8   => especially noticeable on slower systems
      9 - slow recursive make replaced with one global Makefile
     10 - eases integration of proper dependencies
     11 - adds PHP_DEFINE(what[, value]) which creates a single include-file
     12   per what.  This will allow more fine-grained dependencies.
     13 - abandoning the "one library per directory" concept
     14 - improved integration of the CLI
     15 - several new targets
     16   build-modules: builds and copies dynamic modules into modules/
     17   install-cli: installs the CLI only, so that the install-sapi
     18                target does only what its name says
     19 - finally abandoned automake (still requires aclocal at this time)
     20 - changed some configure-time constructs to run at buildconf-time
     21 - upgraded shtool to 1.5.4
     22 - removed $(moduledir) (use EXTENSION_DIR)
     23 
     24 The Reason For a New System
     25 
     26 It became more and more apparent that there is a severe need
     27 for addressing the portability concerns and improving the chance
     28 that your build is correct (how often have you been told to
     29 "make clean"? When this is done, you won't need to anymore).
     30 
     31 
     32 If You Build PHP on a Unix System
     33 
     34 
     35 You, as a user of PHP, will notice no changes.  Of course, the build
     36 system will be faster, look better and work smarter.
     37 
     38 
     39 
     40 If You Are Developing PHP
     41 
     42 
     43 
     44 
     45 Extension developers:
     46 
     47 Makefile.ins are abandoned.  The files which are to be compiled
     48 are specified in the config.m4 now using the following macro:
     49 
     50 PHP_NEW_EXTENSION(foo, foo.c bar.c baz.cpp, $ext_shared)
     51 
     52 E.g. this enables the extension foo which consists of three source-code
     53 modules, two in C and one in C++.  And, depending on the user's wishes,
     54 the extension will even be built as a dynamic module.
     55 
     56 The full syntax:
     57 
     58 PHP_NEW_EXTENSION(extname, sources [, shared [,sapi_class[, extra-cflags]]])
     59 
     60 Please have a look at acinclude.m4 for the gory details and meanings
     61 of the other parameters.
     62 
     63 And that's basically it for the extension side.
     64 
     65 If you previously built sub-libraries for this module, add
     66 the source-code files here as well.  If you need to specify
     67 separate include directories, do it this way:
     68 
     69 PHP_NEW_EXTENSION(foo, foo.c mylib/bar.c mylib/gregor.c,,,-I@ext_srcdir@/lib)
     70 
     71 E.g. this builds the three files which are located relative to the
     72 extension source directory and compiles all three files with the
     73 special include directive (@ext_srcdir@ is automatically replaced).
     74 
     75 Now, you need to tell the build system that you want to build files
     76 in a directory called $ext_builddir/lib:
     77 
     78 PHP_ADD_BUILD_DIR($ext_builddir/lib)
     79 
     80 Make sure to call this after PHP_NEW_EXTENSION, because $ext_builddir
     81 is only set by the latter.
     82 
     83 If you have a complex extension, you might to need add special
     84 Make rules.  You can do this by calling PHP_ADD_MAKEFILE_FRAGMENT
     85 in your config.m4 after PHP_NEW_EXTENSION.
     86 
     87 This will read a file in the source-dir of your extension called
     88 Makefile.frag.  In this file, $(builddir) and $(srcdir) will be
     89 replaced by the values which are correct for your extension
     90 and which are again determined by the PHP_NEW_EXTENSION macro.
     91 
     92 Make sure to prefix *all* relative paths correctly with either
     93 $(builddir) or $(srcdir).  Because the build system does not
     94 change the working directory anymore, we must use either
     95 absolute paths or relative ones to the top build-directory.
     96 Correct prefixing ensures that.
     97 
     98 
     99 SAPI developers:
    100 
    101 Instead of using PHP_SAPI=foo/PHP_BUILD_XYZ, you will need to type
    102 
    103 PHP_SELECT_SAPI(name, type, sources.c)
    104 
    105 I.e. specify the source-code files as above and also pass the
    106 information regarding how PHP is supposed to be built (shared
    107 module, program, etc).
    108 
    109 For example for APXS:
    110 
    111 PHP_SELECT_SAPI(apache, shared, sapi_apache.c mod_php5.c php_apache.c)
    112 
    113 
    114 
    115 General info
    116 
    117 The foundation for the new system is the flexible handling of
    118 sources and their contexts.  With the help of macros you
    119 can define special flags for each source-file, where it is
    120 located, in which target context it can work, etc.
    121 
    122 Have a look at the well documented macros
    123 PHP_ADD_SOURCES(_X) in acinclude.m4.
    124 

README.WIN32-BUILD-SYSTEM

      1 The Win32 Build System.
      2 
      3 See http://wiki.php.net/internals/windows/stepbystepbuild 
      4 
      5 vim:tw=78:sw=1:ts=1:et
      6 
      7 

README.Zeus

      1 Using PHP 5 with the Zeus Web Server
      2 -----------------------------------
      3 
      4 Zeus fully supports running PHP in combination with our
      5 webserver. There are three different interfaces that can be used to
      6 enable PHP:
      7 
      8 * CGI
      9 * ISAPI
     10 * FastCGI
     11 
     12 Of the three, we recommend using FastCGI, which has been tested and
     13 benchmarked as providing the best performance and reliability.
     14 
     15 Full details of how to install PHP are available from our
     16 website, at:
     17 
     18 http://support.zeus.com/products/php.html
     19 
     20 If you have any problems, please check the support site for more
     21 up-to-date information and advice.
     22 
     23 
     24 Quick guide to installing CGI/FastCGI with Zeus
     25 -----------------------------------------------
     26 
     27 Step 1 - Compile PHP as FastCGI.
     28 
     29 Compile as follows:
     30         ./configure --enable-fastcgi
     31         make
     32 
     33 Note that PHP has many options to the configure script -
     34 e.g. --with-mysql. You will probably want to select your usual options
     35 before compiling; the above is just a bare minimum, for illustration.
     36 
     37 After compilation finishes, you will be left with an executable
     38 program called 'php'. Copy this into your document root, under a
     39 dedicated FastCGI directory (e.g. $DOCROOT/fcgi-bin/php)
     40 
     41 
     42 Step 2 - configure Zeus
     43 
     44 Four stages:
     45         -  enable FastCGI
     46         -  configure FastCGI
     47         -  setup alias for FastCGI
     48         -  setup alias for PHP
     49 
     50 1) Using the admin server, go to the 'module configuration' page for
     51 your virtual server, and ensure that 'fastcgi' is enabled (select the
     52 tickbox to the left).
     53 
     54 2) While we can run FastCGI's locally, there are known problems with
     55 some OS's (specifically, the communication between web server and
     56 FastCGI happens over a unix domain socket, and some OS's have trouble
     57 sustaining high connection rates over these sockets). So instead, we
     58 are going to set up the PHP FastCGI to run 'remotely' over localhost
     59 (this uses TCP sockets, which do not suffer this problem). Go to the
     60 'fastcgi configuration' page, and under 'add remote fastcgi':
     61         Add Remote FastCGI
     62                 Docroot path            /fcgi-bin/php
     63                 Remote machine          localhost:8002
     64 The first entry is where you saved PHP, above.
     65 The second entry is localhost:<any unused port>
     66 We will start the FastCGI listening on this port shortly.
     67 Click 'update' to commit these changes.
     68 
     69 3) Go to the path mapping module and add an alias for FastCGI:
     70         Add Alias
     71                 Docroot path            /fcgi-bin
     72                 Filesystem directory    /path/to/docroot/fcgi-bin
     73                 Alias type              fastcgi
     74 Click 'update' to commit these changes
     75 
     76 4) Also on the path mapping module, add a handler for PHP:
     77         Add handler
     78                 File extension          php
     79                 Handler                 /fcgi-bin/php
     80 Click 'update' to commit these changes
     81 
     82 Finally restart your virtual server for these changes to take effect.
     83 
     84 
     85 Step 3 - start PHP as a FastCGI runner
     86 
     87 When you start PHP, it will pre-fork a given number of child processes
     88 to handle incoming PHP requests. Each process will handle a given
     89 number of requests before exiting (and being replaced by a newly
     90 forked process). You can control these two parameters by setting the
     91 following environment variables BEFORE starting the FastCGI runner:
     92 
     93 PHP_FCGI_CHILDREN - the number of child processes to pre-fork. This
     94 variable MUST be set, if not then the PHP will not run as a FastCGI.
     95 We recommend a value of 8 for a fairly busy site. If you have many,
     96 long-running PHP scripts, then you may need to increase this further.
     97 
     98 PHP_FCGI_MAX_REQUESTS - the number of requests each PHP child process
     99 handles before exiting. If not set, defaults to 500.
    100 
    101 To start the FastCGI runner, execute '$ZEUSHOME/web/bin/fcgirunner
    102 8002 $DOCROOT/fcgi-bin/php'.  Substitute the appropriate values for
    103 $ZEUSHOME and $DOCROOT; also substitute for 8002 the port you chose,
    104 above.
    105 
    106 To stop the runner (e.g. to experiment with the above environment
    107 variables) you will need to manually stop and running PHP
    108 processes. (Use 'ps' and 'kill'). As it is PHP which is forking lots
    109 of children and not the runner, Zeus unfortunately cannot keep track
    110 of what processes are running, sorry. A typical command line may look
    111 like 'ps -efl | grep $DOCROOT/fcgi-bin/php | grep -v grep | awk
    112 '{print $4}' | xargs kill'
    113