7 #define PHP_ANCILLARY_VERSION "1.0"
8 #define PHP_ANCILLARY_EXTNAME "ancillary"
10 extern zend_module_entry ancillary_module_entry;
11 #define phpext_ancillary_ptr &ancillary_module_entry
13 // declaration of a custom mop_function()
14 PHP_FUNCTION(ancillary_getstream);
16 // list of custom PHP functions provided by this extension
17 // set {NULL, NULL, NULL} as the last record to mark the end of list
18 static function_entry ancillary_getstream[] = {
19 PHP_FE(ancillary_getstream, NULL)
23 // the following code creates an entry for the module and registers it with Zend.
24 zend_module_entry ancillary_module_entry = {
25 #if ZEND_MODULE_API_NO >= 20010901
26 STANDARD_MODULE_HEADER,
28 PHP_ANCILLARY_EXTNAME,
30 NULL, // name of the MINIT function or NULL if not applicable
31 NULL, // name of the MSHUTDOWN function or NULL if not applicable
32 NULL, // name of the RINIT function or NULL if not applicable
33 NULL, // name of the RSHUTDOWN function or NULL if not applicable
34 NULL, // name of the MINFO function or NULL if not applicable
35 #if ZEND_MODULE_API_NO >= 20010901
36 PHP_ANCILLARY_VERSION,
38 STANDARD_MODULE_PROPERTIES
41 ZEND_GET_MODULE(ancillary)
43 // starting from a unix socket receive a socket from an external process
44 PHP_FUNCTION(ancillary_getstream)
50 if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream))
53 php_stream_from_zval(stream, &zstream);
55 if (php_stream_cast(stream, PHP_STREAM_AS_FD, (void*)&fd_in, REPORT_ERRORS) == FAILURE) {
59 if(ancil_recv_fd(fd_in, &fd_out)) {
63 if ((stream = php_stream_fopen_from_fd(fd_out, "r+b", NULL)) == NULL) {
67 php_stream_to_zval(stream, return_value);