#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <php/main/php.h>
#include <stdio.h>

PHP_FUNCTION(hello_string);
PHP_FUNCTION(hello_long);
PHP_FUNCTION(hello_double);
PHP_FUNCTION(hello_bool);
PHP_FUNCTION(hello_array);

// list of custom PHP functions provided by this extension
// set {NULL, NULL, NULL} as the last record to mark the end of list
static zend_function_entry my_functions[] = {
    PHP_FE(hello_string, NULL)
    PHP_FE(hello_long, NULL)
    PHP_FE(hello_double, NULL)
    PHP_FE(hello_bool, NULL)
    PHP_FE(hello_array, NULL)
    {NULL, NULL, NULL}
};

// the following code creates an entry for the module and registers it with Zend.
zend_module_entry hello_world_module_entry = {
    STANDARD_MODULE_HEADER,
    "hello_world",
    my_functions,
    NULL, // name of the MINIT function or NULL if not applicable
    NULL, // name of the MSHUTDOWN function or NULL if not applicable
    NULL, // name of the RINIT function or NULL if not applicable
    NULL, // name of the RSHUTDOWN function or NULL if not applicable
    NULL, // name of the MINFO function or NULL if not applicable
    NO_VERSION_YET,
    STANDARD_MODULE_PROPERTIES
};

ZEND_GET_MODULE(hello_world)

// implementation of a custom hello_php()
PHP_FUNCTION(hello_string) {
    RETURN_STRING("hello", 1);
}

PHP_FUNCTION(hello_long) {
    RETURN_LONG(100500);
}

PHP_FUNCTION(hello_double) {
    RETURN_DOUBLE(100.5);
}

PHP_FUNCTION(hello_bool) {
    RETURN_TRUE;
}

PHP_FUNCTION(hello_array) {
    array_init(return_value);
    add_assoc_string(return_value, "hello", "world", 1);
}