1: PHP_FUNCTION(example_open)
2: {
3: char *filename;
4: long filename_len;
5: php_stream *stream;
6: struct my_stream_data *data;
7:
8: if (FAILURE == zend_parse_parameters(
9: ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename,
10: &filename_len)) {
11: return;
12: }
13:
14: data = emalloc(sizeof(struct my_stream_data));
15: data->filedes = open(filename, O_RDWR);
16:
17: stream = php_stream_alloc(&my_ops, data, NULL, "r+");
18:
19: php_stream_to_zval(stream, return_value);
20: }