|
| 1 | +/* |
| 2 | + +----------------------------------------------------------------------+ |
| 3 | + | PHP Version 5 | |
| 4 | + +----------------------------------------------------------------------+ |
| 5 | + | Copyright (c) 1997-2013 The PHP Group | |
| 6 | + +----------------------------------------------------------------------+ |
| 7 | + | This source file is subject to version 3.01 of the PHP license, | |
| 8 | + | that is bundled with this package in the file LICENSE, and is | |
| 9 | + | available through the world-wide-web at the following url: | |
| 10 | + | http://www.php.net/license/3_01.txt | |
| 11 | + | If you did not receive a copy of the PHP license and are unable to | |
| 12 | + | obtain it through the world-wide-web, please send a note to | |
| 13 | + | [email protected] so we can mail you a copy immediately. | |
| 14 | + +----------------------------------------------------------------------+ |
| 15 | + | Author: | |
| 16 | + +----------------------------------------------------------------------+ |
| 17 | +*/ |
| 18 | + |
| 19 | +/* $Id$ */ |
| 20 | + |
| 21 | +#ifdef HAVE_CONFIG_H |
| 22 | +#include "config.h" |
| 23 | +#endif |
| 24 | + |
| 25 | +#include "php.h" |
| 26 | +#include "php_ini.h" |
| 27 | +#include "ext/standard/info.h" |
| 28 | +#include "php_xz.h" |
| 29 | + |
| 30 | +/* If you declare any globals in php_xz.h uncomment this: |
| 31 | +ZEND_DECLARE_MODULE_GLOBALS(xz) |
| 32 | +*/ |
| 33 | + |
| 34 | +/* True global resources - no need for thread safety here */ |
| 35 | +static int le_xz; |
| 36 | + |
| 37 | +/* {{{ xz_functions[] |
| 38 | + * |
| 39 | + * Every user visible function must have an entry in xz_functions[]. |
| 40 | + */ |
| 41 | +const zend_function_entry xz_functions[] = { |
| 42 | + PHP_FE(xzopen, NULL) |
| 43 | + PHP_FE_END /* Must be the last line in xz_functions[] */ |
| 44 | +}; |
| 45 | +/* }}} */ |
| 46 | + |
| 47 | +/* {{{ xz_module_entry |
| 48 | + */ |
| 49 | +zend_module_entry xz_module_entry = { |
| 50 | +#if ZEND_MODULE_API_NO >= 20010901 |
| 51 | + STANDARD_MODULE_HEADER, |
| 52 | +#endif |
| 53 | + "xz", |
| 54 | + xz_functions, |
| 55 | + PHP_MINIT(xz), |
| 56 | + PHP_MSHUTDOWN(xz), |
| 57 | + PHP_RINIT(xz), /* Replace with NULL if there's nothing to do at request start */ |
| 58 | + PHP_RSHUTDOWN(xz), /* Replace with NULL if there's nothing to do at request end */ |
| 59 | + PHP_MINFO(xz), |
| 60 | +#if ZEND_MODULE_API_NO >= 20010901 |
| 61 | + "0.1", /* Replace with version number for your extension */ |
| 62 | +#endif |
| 63 | + STANDARD_MODULE_PROPERTIES |
| 64 | +}; |
| 65 | +/* }}} */ |
| 66 | + |
| 67 | +#ifdef COMPILE_DL_XZ |
| 68 | +ZEND_GET_MODULE(xz) |
| 69 | +#endif |
| 70 | + |
| 71 | +/* {{{ PHP_INI |
| 72 | + */ |
| 73 | +/* Remove comments and fill if you need to have entries in php.ini |
| 74 | +PHP_INI_BEGIN() |
| 75 | + STD_PHP_INI_ENTRY("xz.global_value", "42", PHP_INI_ALL, OnUpdateLong, global_value, zend_xz_globals, xz_globals) |
| 76 | + STD_PHP_INI_ENTRY("xz.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_xz_globals, xz_globals) |
| 77 | +PHP_INI_END() |
| 78 | +*/ |
| 79 | +/* }}} */ |
| 80 | + |
| 81 | +/* {{{ php_xz_init_globals |
| 82 | + */ |
| 83 | +/* Uncomment this function if you have INI entries |
| 84 | +static void php_xz_init_globals(zend_xz_globals *xz_globals) |
| 85 | +{ |
| 86 | + xz_globals->global_value = 0; |
| 87 | + xz_globals->global_string = NULL; |
| 88 | +} |
| 89 | +*/ |
| 90 | +/* }}} */ |
| 91 | + |
| 92 | +/* {{{ PHP_MINIT_FUNCTION |
| 93 | + */ |
| 94 | +PHP_MINIT_FUNCTION(xz) |
| 95 | +{ |
| 96 | + /* If you have INI entries, uncomment these lines |
| 97 | + REGISTER_INI_ENTRIES(); |
| 98 | + */ |
| 99 | + return SUCCESS; |
| 100 | +} |
| 101 | +/* }}} */ |
| 102 | + |
| 103 | +/* {{{ PHP_MSHUTDOWN_FUNCTION |
| 104 | + */ |
| 105 | +PHP_MSHUTDOWN_FUNCTION(xz) |
| 106 | +{ |
| 107 | + /* uncomment this line if you have INI entries |
| 108 | + UNREGISTER_INI_ENTRIES(); |
| 109 | + */ |
| 110 | + return SUCCESS; |
| 111 | +} |
| 112 | +/* }}} */ |
| 113 | + |
| 114 | +/* Remove if there's nothing to do at request start */ |
| 115 | +/* {{{ PHP_RINIT_FUNCTION |
| 116 | + */ |
| 117 | +PHP_RINIT_FUNCTION(xz) |
| 118 | +{ |
| 119 | + return SUCCESS; |
| 120 | +} |
| 121 | +/* }}} */ |
| 122 | + |
| 123 | +/* Remove if there's nothing to do at request end */ |
| 124 | +/* {{{ PHP_RSHUTDOWN_FUNCTION |
| 125 | + */ |
| 126 | +PHP_RSHUTDOWN_FUNCTION(xz) |
| 127 | +{ |
| 128 | + return SUCCESS; |
| 129 | +} |
| 130 | +/* }}} */ |
| 131 | + |
| 132 | +/* {{{ PHP_MINFO_FUNCTION |
| 133 | + */ |
| 134 | +PHP_MINFO_FUNCTION(xz) |
| 135 | +{ |
| 136 | + php_info_print_table_start(); |
| 137 | + php_info_print_table_header(2, "xz support", "enabled"); |
| 138 | + php_info_print_table_end(); |
| 139 | + |
| 140 | + /* Remove comments if you have entries in php.ini |
| 141 | + DISPLAY_INI_ENTRIES(); |
| 142 | + */ |
| 143 | +} |
| 144 | +/* }}} */ |
| 145 | + |
| 146 | + |
| 147 | +PHP_FUNCTION(xzopen) |
| 148 | +{ |
| 149 | + char *filename; |
| 150 | + char *mode; |
| 151 | + int filename_len, mode_len; |
| 152 | + php_stream *stream; |
| 153 | + |
| 154 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &filename, &filename_len, &mode, &mode_len) == FAILURE) { |
| 155 | + return; |
| 156 | + } |
| 157 | + |
| 158 | + stream = php_stream_xzopen(NULL, filename, mode, NULL, NULL STREAMS_CC TSRMLS_CC); |
| 159 | + |
| 160 | + if (!stream) { |
| 161 | + RETURN_FALSE; |
| 162 | + } |
| 163 | + |
| 164 | + php_stream_to_zval(stream, return_value); |
| 165 | +} |
| 166 | + |
| 167 | + |
| 168 | +/* |
| 169 | + * Local variables: |
| 170 | + * tab-width: 4 |
| 171 | + * c-basic-offset: 4 |
| 172 | + * End: |
| 173 | + * vim600: noet sw=4 ts=4 fdm=marker |
| 174 | + * vim<600: noet sw=4 ts=4 |
| 175 | + */ |
0 commit comments