<slide title="Structure">
<blurb>
The structure of a typical extension contains the following components:
</blurb>

<example title="includes" type="c"><![CDATA[#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_tidy.h"]]></example>

<example title="function_entry" type="c"><![CDATA[function_entry tidy_functions[] = {
    PHP_FE(confirm_tidy_compiled,    NULL)
    PHP_FE(tidy_create,    NULL)
    PHP_FALIAS(tidy_new, tidy_create)
    PHP_FE(example_function, { 2, BYREF_FORCE, BYREF_NONE } )
    PHP_NAMED_FE(transmogrify, my_transmogrify, NULL)
    {NULL, NULL, NULL}
};]]></example>

<example title="module_entry" type="c"><![CDATA[zend_module_entry tidy_module_entry = {
    "tidy",
    tidy_functions,
    PHP_MINIT(tidy),
    PHP_MSHUTDOWN(tidy),
    PHP_RINIT(tidy),
    PHP_RSHUTDOWN(tidy),
    PHP_MINFO(tidy),
    STANDARD_MODULE_PROPERTIES
};]]></example>

<example fontsize="1.5em" title="PHP_INI_BEGIN" type="c"><![CDATA[PHP_INI_BEGIN()
    STD_PHP_INI_ENTRY("tidy.value",      "42",
                      PHP_INI_ALL, OnUpdateInt, global_value,
		      zend_tidy_globals, tidy_globals)
    STD_PHP_INI_ENTRY("tidy.string", "tidybar",
                      PHP_INI_ALL, OnUpdateString, global_string,
		      zend_tidy_globals, tidy_globals)
PHP_INI_END()]]></example>

<example title="PHP_MINIT_FUNCTION" type="c"><![CDATA[PHP_MINIT_FUNCTION(tidy)
{
    REGISTER_INI_ENTRIES();
    return SUCCESS;
}]]></example>

<example title="PHP_MSHUTDOWN_FUNCTION" type="c"><![CDATA[PHP_MSHUTDOWN_FUNCTION(tidy)
{
    UNREGISTER_INI_ENTRIES();
    return SUCCESS;
}]]></example>

<example title="PHP_RINIT_FUNCTION" type="c"><![CDATA[PHP_RINIT_FUNCTION(tidy)
{
    return SUCCESS;
}]]></example>

<example title="PHP_RSHUTDOWN_FUNCTION" type="c"><![CDATA[PHP_RSHUTDOWN_FUNCTION(tidy)
{
    return SUCCESS;
}]]></example>

<example fontsize="1.5em" title="PHP_MINFO_FUNCTION" type="c"><![CDATA[PHP_MINFO_FUNCTION(tidy)
{
    php_info_print_table_start();
    php_info_print_table_header(2, "tidy support", "enabled");
    php_info_print_table_end();

    DISPLAY_INI_ENTRIES();
}]]></example>

<example fontsize="1.5em" title="functions" type="c"><![CDATA[PHP_FUNCTION(confirm_tidy_compiled)
{
    char *arg = NULL;
    int arg_len, len;
    char string[256];   
    
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
                              "s", &arg, &arg_len) == FAILURE) {
        return;
    }

    len = sprintf(string, "Congratulations!
You have successfully modified ext/%.78s/config.m4. 
Module %.78s is now compiled into PHP.", "tidy", Z_STRVAL_PP(arg));
    RETURN_STRINGL(string, len, 1);
}]]></example>

</slide>
