/home/lnzliplg/www/alt-php82-pecl-eio_3.1.3-3.el8.zip
PKG��\�*�ZZtests/eio_chown_variation.phptnu�[���--TEST--
Check for eio_chown function basic behaviour
--SKIPIF--
<?php
if (!extension_loaded('posix')) {
	die('SKIP The posix extension is not loaded');
}
?>
--FILE--
<?php
ini_set('display_errors', 'On');
ini_set('log_errors', 'Off');
$temp_filename = "eio-temp-file.tmp";

touch($temp_filename);



function my_eio_chown_cb($data, $result) {
	var_dump($result);
}

if (class_exists('ArgumentCountError')) { // PHP 8+
    try {
        eio_chown($temp_filename);
    } catch (ArgumentCountError $e) {
        trigger_error($e->getMessage(), E_USER_WARNING);
    }
} else {
    eio_chown($temp_filename);
}


//Fatal error: Uncaught ArgumentCountError: eio_chown() expects at least 2 arguments, 1 given in /home/ruslan/projects/pecl/pecl-eio/tests/eio_chown_variation.phpt:23
eio_event_loop();
eio_chown($temp_filename, -1, -1);
eio_event_loop();
eio_chown($temp_filename, posix_getuid(), -1, EIO_PRI_DEFAULT, "my_eio_chown_cb");
eio_event_loop();
?>
--CLEAN--
<?php
@unlink($temp_filename);
?>
--EXPECTF--

%Aeio_chown() expects at least 2 %s, 1 given%A

Warning: eio_chown(): invalid uid and/or gid in %a
int(0)
PKG��\We�N��tests/eio_write_variation.phptnu�[���--TEST--
Check for eio_write function behaviour with `use' keyword within a nested call
--FILE--
<?php
$str      = str_repeat('1', 20);
$filename = '/tmp/tmp_file' .uniqid();
@unlink($filename);
touch($filename);


eio_open($filename, EIO_O_RDWR, 0, EIO_PRI_DEFAULT, function($filename, $fd) use ($str) {
	eio_write($fd, $str, strlen($str), 0, 0, function($fd, $written) use ($str, $filename) {
		var_dump([
			'written'  => $written,
			'strlen'   => strlen($str),
			'filesize' => filesize($filename),
			'count'    => substr_count(file_get_contents($filename), '1')
			]);
	}, $fd);
}, $filename);
eio_event_loop();
?>
--EXPECT--
array(4) {
  ["written"]=>
  int(20)
  ["strlen"]=>
  int(20)
  ["filesize"]=>
  int(20)
  ["count"]=>
  int(20)
}
PKG��\8�'�tests/bug65293.phptnu�[���--TEST--
Check for bug #65293
--FILE--
<?php 

eio_close(0, 0, function ($d, $r) {
	var_dump($r);
});
eio_event_loop();
?>
--EXPECT--
int(0)
PKG��\3�����tests/eio_unlink_basic.phptnu�[���--TEST--
Check for eio_unlink function basic behaviour
--FILE--
<?php 
$temp_filename = "eio-temp.tmp";

$fp = fopen($temp_filename, "w");
fwrite($fp, "a");
fclose($fp);

function my_unlink_callback($data, $result) {
	global $temp_filename;

	if ($result == 0 && !file_exists($temp_filename)) {
		echo "eio_unlink";
	} 		
	@unlink($temp_filename);	
}



eio_unlink($temp_filename, EIO_PRI_DEFAULT, "my_unlink_callback");
eio_event_loop();
?>
--CLEAN--
<?php
?>
--EXPECT--
eio_unlink
PKH��\���fftests/eio_truncate_basic.phptnu�[���--TEST--
Check for eio_truncate function basic behaviour
--SKIPIF--
--FILE--
<?php 
error_reporting(0);

$temp_filename = "eio-temp-file.tmp";

$fp = fopen($temp_filename, "w");
for ($i = 0; $i < 10; $i++) {
	fwrite($fp, "a");
}
fclose($fp);

function my_file_truncated_callback($data, $result) {
	global $temp_filename;

	if ($result >= 0 && filesize($temp_filename) == 5) {
		echo "eio_truncate_ok";
	}
	@unlink($temp_filename);
}


$req = eio_truncate($temp_filename, 5, EIO_PRI_DEFAULT, "my_file_truncated_callback");
eio_event_loop();
?>
--CLEAN--
<?php
@unlink($temp_filename);
?>
--EXPECT--
eio_truncate_ok
PKH��\�p�i

tests/eio_custom_basic.phptnu�[���--TEST--
Check for eio_custom function basic behaviour
--SKIPIF--
<?php
if (PHP_ZTS) {
	die("skip doesn't support ZTS");
}
?>
--FILE--
<?php
//error_reporting(0);

function my_custom_callback($data, $result, $req) {
	var_dump($data);
	var_dump(count($result));
	var_dump($result['data_modified']);
	var_dump($result['result']);
}

function my_custom($data) {
	var_dump($data);

	$result  = array(
		'result'	=> 1001,
		'data_modified' => "my custom data",
	);
	return $result;
}



$data = "my_custom_data";
$req = eio_custom("my_custom", 0, "my_custom_callback", $data);
var_dump($req);
eio_event_loop();
?>
--CLEAN--
--EXPECTF--
resource(%d) of type (EIO Request Descriptor)
string(14) "my_custom_data"
string(14) "my_custom_data"
int(2)
string(14) "my custom data"
int(1001)
PKH��\@<����tests/fork.phptnu�[���--TEST--
Check for eio fork support using pcntl
--SKIPIF--
<?php
if (!extension_loaded('pcntl')) {
	die('SKIP The pcntl extension is not loaded');
}
?>
--FILE--
<?php
$str      = str_repeat('1', 20);
$filename = '/tmp/tmp_file' .uniqid();
$filename2 = '/tmp/tmp_file2' .uniqid();
@unlink($filename);
@unlink($filename2);
touch($filename);
touch($filename2);

$pid = pcntl_fork();
if ($pid == -1) {
	die('could not fork');
} else if ($pid) {
	eio_open($filename, EIO_O_RDWR, 0, EIO_PRI_DEFAULT, function($filename, $fd) use ($str) {
		eio_write($fd, $str, strlen($str), 0, 0, function($fd, $written) use ($str, $filename) {
			printf("w: %d l: %d f: %d c: %d\n",
				$written,
				strlen($str),
				filesize($filename),
				substr_count(file_get_contents($filename), '1'));
		}, $fd);
	}, $filename);
	eio_event_loop();

	// we are the parent
	pcntl_wait($status); //Protect against Zombie children

} else {
	// we are the child
	eio_open($filename2, EIO_O_RDWR, 0, EIO_PRI_DEFAULT, function($filename2, $fd) use ($str) {
		eio_write($fd, $str, strlen($str), 0, 0, function($fd, $written) use ($str, $filename2) {
			printf("w: %d l: %d f: %d c: %d\n",
				$written,
				strlen($str),
				filesize($filename2),
				substr_count(file_get_contents($filename2), '1'));
		}, $fd);
	}, $filename2);
	eio_event_loop();
}

@unlink($filename);
@unlink($filename2);
?>
--EXPECT--
w: 20 l: 20 f: 20 c: 20
w: 20 l: 20 f: 20 c: 20
PKH��\�Ҷ��tests/eio_read_basic.phptnu�[���--TEST--
Check for eio_read function basic behaviour
--SKIPIF--
--FILE--
<?php 
error_reporting(0);

$temp_filename = "eio-temp-file.tmp";
$fp = fopen($temp_filename, "w");
fwrite($fp, "1234567890");
fclose($fp);

function my_read_cb($data, $result) {
	global $temp_filename;

	var_dump($result);

	eio_close($data);
	eio_event_loop();

	@unlink($temp_filename);
}

function my_file_opened_callback($data, $result) {
	if ($result > 0) {
		eio_read($result, 5, 2, EIO_PRI_DEFAULT, "my_read_cb", $result);
		eio_event_loop();
	} else {
		unlink($data);	
	}
}


eio_open($temp_filename, EIO_O_CREAT | EIO_O_RDWR, NULL, 
	EIO_PRI_DEFAULT, "my_file_opened_callback", $temp_filename);
eio_event_loop();
?>
--EXPECT--
string(5) "34567"
PKH��\��B�''tests/eio_grp_add.phptnu�[���--TEST--
Check for eio_grp_add function basic behaviour
--FILE--
<?php 
$temp_filename = dirname(__FILE__) ."/eio-file.tmp";
$fp = fopen($temp_filename, "w");
fwrite($fp, "some data");
fclose($fp);

function my_grp_done($data, $result) {
	global $temp_filename;
	var_dump($result == 0); 
	@unlink($temp_filename);
}
function my_grp_file_opened_callback($data, $result) {
	global $my_file_fd, $grp;

	$my_file_fd = $result;

	var_dump($result > 0);

	$req = eio_read($my_file_fd, 4, 0, EIO_PRI_DEFAULT, "my_grp_file_read_callback");
	eio_grp_add($grp, $req);
}

function my_grp_file_read_callback($data, $result) {
	global $my_file_fd, $grp;

	var_dump($result);

	$req = eio_close($my_file_fd);
	eio_grp_add($grp, $req);

	eio_event_loop();
}


$grp = eio_grp("my_grp_done", "my_grp_data");
$req = eio_open($temp_filename, EIO_O_RDWR | EIO_O_APPEND , 0, 0, "my_grp_file_opened_callback", NULL);
eio_grp_add($grp, $req);

var_dump($grp);

eio_event_loop();
?>
--CLEAN--
--EXPECTF--
resource(%d) of type (EIO Group Descriptor)
bool(true)
string(%d) "%s"
bool(true)
PKI��\=��k��tests/eio_sync.phptnu�[���--TEST--
Check for eio_sync, eio_fsync, eio_fdatasync functions' basic behaviour
--FILE--
<?php 

error_reporting(0);

$temp_filename = "eio-temp-file.tmp";

function my_close_cb($data, $result) {
	global $temp_filename;

	var_dump($result == 0);

	@unlink($temp_filename);
}

function my_fdatasync_cb($data, $result) {
	var_dump($result == 0);
}

function my_fsync_cb($data, $result) {
	var_dump($result == 0);
}

function my_sync_cb($data, $result) {
	var_dump($result == 0);
}

function my_file_opened_callback($data, $result) {
	var_dump($result > 0);
	if ($result > 0) {
		eio_fdatasync ($result, 0, "my_fdatasync_cb", "fdatasync");
		eio_fsync ($result, 0, "my_fsync_cb", "fsync");
		eio_sync (0, "my_sync_cb", "sync");
		eio_event_loop();

		eio_close($result, EIO_PRI_DEFAULT, "my_close_cb");
		eio_event_loop();
	}
}


eio_open($temp_filename, EIO_O_CREAT, NULL, EIO_PRI_DEFAULT, "my_file_opened_callback", NULL);
eio_event_loop();

?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
PKI��\������tests/eio_chmod_basic.phptnu�[���--TEST--
Check for eio_chmod function basic behaviour
--FILE--
<?php 
$temp_filename = "eio-temp-file.tmp";

touch($temp_filename);



function my_chmod_callback($data, $result) {
	global $temp_filename;
	if ($result == 0 && fileperms($temp_filename) & 0200) {
		echo "eio_chmod_ok";
	}
	@unlink($temp_filename);
}

eio_chmod($temp_filename, 0200, EIO_PRI_DEFAULT, "my_chmod_callback");
eio_event_loop();
?>
--EXPECT--
eio_chmod_ok
PKI��\1@�qHHtests/eio_open_basic.phptnu�[���--TEST--
Check for eio_open function basic behaviour
--SKIPIF--
--FILE--
<?php 
error_reporting(0);

$temp_filename = "eio-temp-file.tmp";

function my_close_cb($data, $result) {
	global $temp_filename;

	var_dump($result == 0);
	@unlink($temp_filename);
}

function my_file_opened_callback($data, $result) {
	var_dump($result > 0);
	if ($result > 0) {
		eio_close($result, EIO_PRI_DEFAULT, "my_close_cb");
		eio_event_loop();
	}
}


eio_open($temp_filename, EIO_O_CREAT, NULL, EIO_PRI_DEFAULT, "my_file_opened_callback", NULL);
eio_event_loop();

?>
--EXPECT--
bool(true)
bool(true)
PKI��\
��		tests/eio_utime_basic.phptnu�[���--TEST--
Check for eio_utime function basic behaviour
--FILE--
<?php 
$temp_filename = "eio-temp.tmp";

touch($temp_filename);

function my_utime_callback($data, $result) {
	global $temp_filename;

	$s = stat($temp_filename);

	if ($result == 0 && $s['atime'] == '1317665072' && $s['mtime'] == '1317665073') {
		echo "eio_utime_ok";
	} 

	@unlink($temp_filename);
}


eio_utime($temp_filename, 1317665072, 1317665073, EIO_PRI_DEFAULT, "my_utime_callback");
eio_event_loop();
?>
--CLEAN--
<?php
?>
--EXPECT--
eio_utime_ok
PKI��\!>�
��tests/eio_stat_basic.phptnu�[���--TEST--
Check for eio_stat, eio_lstat, eio_fstat functions' basic behaviour
--FILE--
<?php 
error_reporting(E_ERROR);
$tmp_filename = dirname(__FILE__) ."/eio-file.tmp";
//touch($tmp_filename);
$fp = fopen($tmp_filename, 'w');
fwrite($fp, '123');
fclose($fp);

function my_res_cb($data, $result) {
	var_dump($data);
	var_dump($result['mtime']);
	var_dump($result['size']);
}

function my_open_cb($data, $result) {
	global $tmp_filename;

	eio_fstat($result, EIO_PRI_DEFAULT, "my_res_cb", "eio_fstat");
	eio_event_loop();

	eio_close($result);
	eio_event_loop();

	@unlink($tmp_filename);
}



eio_stat($tmp_filename, EIO_PRI_DEFAULT, "my_res_cb", "eio_stat");
eio_lstat($tmp_filename, EIO_PRI_DEFAULT, "my_res_cb", "eio_lstat");
eio_event_loop();

eio_open($tmp_filename, EIO_O_RDONLY, NULL, EIO_PRI_DEFAULT, "my_open_cb", "eio_open");
eio_event_loop();
?>
--EXPECTF--
string(%d) "eio_%stat"
int(%d)
int(3)
string(%d) "eio_%stat"
int(%d)
int(3)
string(%d) "eio_%stat"
int(%d)
int(3)
PKI��\�����tests/eio_mknod_basic.phptnu�[���--TEST--
Check for eio_mknod function basic behaviour
--FILE--
<?php 
$temp_filename = "eio-temp-fifo";

function my_mknod_callback($data, $result) {
	global $temp_filename;

	$s = stat($temp_filename);
	if ($result == 0 && $data == "mknod") {
		echo "eio_mknod_ok";
	} 

	if (file_exists($temp_filename)) {
		unlink($temp_filename);
	}
}


eio_mknod($temp_filename, EIO_S_IFIFO, 0, 0, "my_mknod_callback", "mknod");
eio_event_loop();
?>
--EXPECT--
eio_mknod_ok
PKJ��\n3?Q��tests/eio_sendfile_basic.phptnu�[���--TEST--
Check for eio_sendfile function basic behaviour
--FILE--
<?php

function my_cb($data, $result) {
	var_dump($data);
	var_dump($result);
}

$tmp_file_from = sprintf("/tmp/tmp_%s", uniqid());
$tmp_file_to = sprintf("/tmp/tmp_%s", uniqid());

@unlink($tmp_file_from);
@unlink($tmp_file_to);

$fp_from = fopen($tmp_file_from, 'w');
fwrite($fp_from, '123456789');
fclose($fp_from);
$fp_from = fopen($tmp_file_from, 'r');

$fp_to = fopen($tmp_file_to, 'w');


eio_sendfile($fp_to, $fp_from, 0, 3, 0, 'my_cb', 'sendfile_data');
eio_event_loop();

fclose($fp_from);
fclose($fp_to);

@unlink($tmp_file_from);
@unlink($tmp_file_to);
?>
--EXPECT--
string(13) "sendfile_data"
int(3)
PKJ��\�Ѝ��tests/eio_sendfile_sockets.phptnu�[���--TEST--
Check for eio_sendfile function work with sockets in PHP version less than 8
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
	die('SKIP The sockets extension is not loaded');
}
if (version_compare(PHP_VERSION, '8.0.0', '>=')) {
    die('skip target is PHP version >= 8');
}
?>
--FILE--
<?php
ini_set('display_errors', 'On');
ini_set('log_errors', 'Off');

function my_cb($socket, $result) {
	var_dump($socket);
	var_dump($result);

	if ($result <= 0) {
		return;
	}

	$data = socket_read($socket, 10, PHP_BINARY_READ);
	var_dump($data);
}

$tmp_file = sprintf("/tmp/tmp_%s", uniqid());
$fp = fopen($tmp_file, 'w+');
$data = "ABCdef123";
var_dump($data);
fwrite($fp, $data);

$sock_path = sprintf("/tmp/%s.sock", uniqid());
if (file_exists($sock_path))
	die('Temporary socket already exists.');

/* Setup socket */
$server = socket_create(AF_UNIX, SOCK_STREAM, 0);
if (!$server) {
	die('Unable to create AF_UNIX socket [server]');
}
if (!socket_bind($server,  $sock_path)) {
	die("Unable to bind to $sock_path");
}
if (!socket_listen($server, 2)) {
	die('Unable to listen on socket');
}

/* Connect to socket */
$client = socket_create(AF_UNIX, SOCK_STREAM, 0);
if (!$client) {
	die('Unable to create AF_UNIX socket [client]');
}
if (!socket_connect($client, $sock_path)) {
	die('Unable to connect to server socket');
}

/* Accept socket connection */
$socket = socket_accept($server);
if (!$socket) {
	die('Unable to accept connection');
}


eio_sendfile($client, $fp, 0, 8, 0, 'my_cb', $socket);
eio_event_loop();

fclose($fp);
socket_close($client);
socket_close($socket);
socket_close($server);
@unlink($sock_path);
@unlink($tmp_file);
?>
--EXPECT--
string(9) "ABCdef123"
resource(8) of type (Socket)
int(8)
string(8) "ABCdef12"
PKJ��\
c�PPtests/eio_rename_basic.phptnu�[���--TEST--
Check for eio_rename function basic behaviour
--FILE--
<?php 
$filename = dirname(__FILE__)."/eio-temp-file.dat";
touch($filename);
$new_filename = dirname(__FILE__)."/eio-temp-file-new.dat";


function my_rename_cb($data, $result) {
	global $filename, $new_filename;

	if ($result == 0 && !file_exists($filename) && file_exists($new_filename)) {
		@unlink($new_filename);
		echo "eio_rename_ok";
	} else {
		@unlink($filename);
	}
}


eio_rename($filename, $new_filename, EIO_PRI_DEFAULT, "my_rename_cb", $filename);
eio_event_loop();
?>
--CLEAN--
<?php
?>
--EXPECT--
eio_rename_ok
PKJ��\
K���tests/eio_rmdir_basic.phptnu�[���--TEST--
Check for eio_rmdir function basic behaviour
--FILE--
<?php
$temp_dirname = "eio-temp-dir";

if (!is_dir($temp_dirname)) {
    mkdir($temp_dirname);
}

function my_rmdir_callback($data, $result) {
	global $temp_dirname;

	if ($result == 0 && !file_exists($temp_dirname)) {
		echo "eio_rmdir_ok";
	} else if (file_exists($temp_dirname)) {
		rmdir($temp_dirname);
	}
}



eio_rmdir($temp_dirname, EIO_PRI_DEFAULT, "my_rmdir_callback");
eio_event_loop();
?>
--CLEAN--
<?php
?>
--EXPECT--
eio_rmdir_ok
PKJ��\%���tests/eio_stat_error.phptnu�[���--TEST--
Check for eio_*stat functions' error behaviour
--FILE--
<?php 
ini_set('display_errors', 'On');
ini_set('log_errors', 'Off');
$tmp_filename= './tmpfile';
touch($tmp_filename);

function my_res_cb($data, $result) {
	var_dump($data);
	if (is_array($result)) {
		var_dump($result['mtime']);
	} else {
		var_dump($result);
	}
}
function my_open_cb($data, $result) {
	if ($result > 0) {
		eio_fstat($result, EIO_PRI_DEFAULT, "my_res_cb", "eio_fstat");
		eio_event_loop();

		eio_close($result);
		eio_event_loop();
	} else {
		var_dump($result);
	}
}


eio_stat($tmp_filename, EIO_PRI_DEFAULT, "my_res_cb", "eio_stat");
eio_lstat($tmp_filename, EIO_PRI_DEFAULT, "my_res_cb", "eio_lstat");
eio_event_loop();
eio_open($tmp_filename, EIO_O_RDONLY, 0, EIO_PRI_DEFAULT, "my_open_cb", "eio_open");
eio_event_loop();

@unlink($tmp_filename);

eio_stat($tmp_filename, EIO_PRI_DEFAULT, "my_res_cb", "eio_stat");
eio_lstat($tmp_filename, EIO_PRI_DEFAULT, "my_res_cb", "eio_lstat");
eio_event_loop();
?>
--EXPECTF--
string(%d) "eio_%stat"
int(%d)
string(%d) "eio_%stat"
int(%d)
string(%d) "eio_%stat"
int(%d)
string(%d) "eio_%stat"
int(-1)
string(%d) "eio_%stat"
int(-1)
PKJ��\-�%4��tests/eio001.phptnu�[���--TEST--
Check for eio presence
--SKIPIF--
<?php if (!extension_loaded("eio")) print "skip"; ?>
--FILE--
<?php
echo "eio extension is available";
?>
--EXPECT--
eio extension is available
PKK��\R�E���tests/eio_link.phptnu�[���--TEST--
Check for eio_link, eio_readlink, eio_symlink function basic behaviour
--FILE--
<?php 
$filename = dirname(__FILE__)."/symlink.dat";
touch($filename);
$link = dirname(__FILE__)."/symlink.link";
$hardlink = dirname(__FILE__)."/hardlink.link";

function my_hardlink_cb($data, $result) {
	global $link, $filename;
	var_dump(file_exists($data) && !is_link($data));
	@unlink($data);

	eio_symlink($filename, $link, EIO_PRI_DEFAULT, "my_symlink_cb", $link);
}

function my_symlink_cb($data, $result) {
	global $link, $filename;
	var_dump(file_exists($data) && is_link($data));

	if (!eio_readlink($data, EIO_PRI_DEFAULT, "my_readlink_cb", NULL)) {
		@unlink($link);
		@unlink($filename);
	}
}

function my_readlink_cb($data, $result) {
	global $filename, $link;
	var_dump($result);

	@unlink($link);
	@unlink($filename);
}


eio_link($filename, $hardlink, EIO_PRI_DEFAULT, "my_hardlink_cb", $hardlink);
eio_event_loop();
?>
--EXPECTF--
bool(true)
bool(true)
string(%d) "%ssymlink.dat"
PKK��\�d0���tests/eio_seek.phptnu�[���--TEST--
Check for eio_seek function basic behaviour
--SKIPIF--
--FILE--
<?php 
ini_set('display_errors', 'On');
ini_set('log_errors', 'Off');

$temp_filename = "eio-temp-file.tmp";
$fp = fopen($temp_filename, "w+");
fwrite($fp, "1234567890");

function my_seek_cb($fp, $result) {
	var_dump($result);
	if ($result == 0) {
		var_dump($fp);
		if (is_resource($fp)) {
			var_dump(fread($fp, 32));
		}
	}
}

if (!eio_seek($fp, 6, EIO_SEEK_SET, 0, 'my_seek_cb', $fp)) {
	die("Failed to eio_seek");
}
eio_event_loop();
if (!eio_seek($fp, -6, EIO_SEEK_END, 0, 'my_seek_cb', $fp)) {
	die("Failed to eio_seek");
}
eio_event_loop();
if (!eio_seek($fp, -100, EIO_SEEK_CUR, 0, 'my_seek_cb', $fp)) {
	die("Failed to eio_seek");
}
eio_event_loop();

fclose($fp);
@unlink($temp_filename);
?>
--EXPECTF--
int(0)
resource(5) of type (stream)
string(4) "7890"
int(0)
resource(5) of type (stream)
string(6) "567890"
int(-1)
PKK��\q�Z��$tests/eio_sendfile_sockets_php8.phptnu�[���--TEST--
Check for eio_sendfile function work with sockets in PHP version 8 and greater
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
	die('SKIP The sockets extension is not loaded');
}
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
    die('skip target PHP version is less than 8');
}
?>
--FILE--
<?php
ini_set('display_errors', 'On');
ini_set('log_errors', 'Off');

function my_cb($socket, $result) {
	var_dump(is_object($socket) ? get_class($socket) : null);
	var_dump($result);

	if ($result <= 0) {
		return;
	}

	$data = socket_read($socket, 10, PHP_BINARY_READ);
	var_dump($data);
}

$tmp_file = sprintf("/tmp/tmp_%s", uniqid());
$fp = fopen($tmp_file, 'w+');
$data = "ABCdef123";
var_dump($data);
fwrite($fp, $data);

$sock_path = sprintf("/tmp/%s.sock", uniqid());
if (file_exists($sock_path))
	die('Temporary socket already exists.');

/* Setup socket */
$server = socket_create(AF_UNIX, SOCK_STREAM, 0);
if (!$server) {
	die('Unable to create AF_UNIX socket [server]');
}
if (!socket_bind($server,  $sock_path)) {
	die("Unable to bind to $sock_path");
}
if (!socket_listen($server, 2)) {
	die('Unable to listen on socket');
}

/* Connect to socket */
$client = socket_create(AF_UNIX, SOCK_STREAM, 0);
if (!$client) {
	die('Unable to create AF_UNIX socket [client]');
}
if (!socket_connect($client, $sock_path)) {
	die('Unable to connect to server socket');
}

/* Accept socket connection */
$socket = socket_accept($server);
if (!$socket) {
	die('Unable to accept connection');
}


eio_sendfile($client, $fp, 0, 8, 0, 'my_cb', $socket);
eio_event_loop();

fclose($fp);
socket_close($client);
socket_close($socket);
socket_close($server);
@unlink($sock_path);
@unlink($tmp_file);
?>
--EXPECT--
string(9) "ABCdef123"
string(6) "Socket"
int(8)
string(8) "ABCdef12"
PKK��\ѳ@99tests/eio_mkdir_basic.phptnu�[���--TEST--
Check for eio_mkdir function basic behaviour
--FILE--
<?php 
$temp_dirname = dirname(__FILE__) ."/eio-temp-dir";
if (file_exists($temp_dirname)) {
	rmdir($temp_dirname);
}

function my_mkdir_callback($data, $result) {
	global $temp_dirname;
	if ($result == 0 && is_dir($temp_dirname) 
		&& fileperms($temp_dirname) & 0300) {
			echo "eio_mkdir_ok";
		} else {
			echo "eio_mkdir_failed";
		}
	if (file_exists($temp_dirname))
		rmdir($temp_dirname);
}


eio_mkdir($temp_dirname, 0300, 1, "my_mkdir_callback", NULL);
eio_event_loop();
?>
--EXPECT--
eio_mkdir_ok
PKK��\MV_�zztests/eio_cancel_basic.phptnu�[���--TEST--
Check for eio_cancel function basic behaviour
--FILE--
<?php
//error_reporting(0);

function my_nop_cb($data, $result) {
	echo "my_nop";
}



$req = eio_nop(EIO_PRI_DEFAULT, "my_nop_cb", NULL);
var_dump($req);
eio_cancel($req);
eio_nop(EIO_PRI_DEFAULT, "my_nop_cb", NULL);
eio_event_loop();
?>
--CLEAN--
--EXPECTF--
resource(%i) of type (EIO Request Descriptor)
my_nop
PKK��\�+��tests/eio_readdir.phptnu�[���--TEST--
Check for eio_readdir function basic behaviour
--SKIPIF--
--FILE--
<?php

$dir = "./eio-unknown-dir";
$files = array ("$dir/abc", "$dir/def");
$data = "readdir_data";

mkdir($dir, 0700);
foreach ($files as $f) {
	touch($f);
}

eio_readdir($dir, EIO_READDIR_STAT_ORDER,0,
	function ($data, $result) {
		var_dump($data);
        usort($result['names'], function ($a, $b) { return strcmp($a, $b); });
        usort($result['dents'], function ($a, $b) { return strcmp($a['name'], $b['name']); });
		var_dump($result);
	}, $data
);
eio_event_loop();

foreach ($files as $f) {
	unlink($f);
}

rmdir($dir);
?>
--EXPECTF--
string(12) "readdir_data"
array(2) {
  ["names"]=>
  array(2) {
    [0]=>
    string(3) "abc"
    [1]=>
    string(3) "def"
  }
  ["dents"]=>
  array(2) {
    [0]=>
    array(3) {
      ["name"]=>
      string(3) "abc"
      ["type"]=>
      int(%d)
      ["inode"]=>
      int(%d)
    }
    [1]=>
    array(3) {
      ["name"]=>
      string(3) "def"
      ["type"]=>
      int(%d)
      ["inode"]=>
      int(%d)
    }
  }
}
PKK��\�)���tests/eio_fallocate_basic.phptnu�[���--TEST--
Check for eio_fallocate function basic behaviour
--SKIPIF--
<?php if (PHP_OS != "Linux") die("skip, only for linux"); ?>
--FILE--
<?php
error_reporting(0);

$temp_filename = "eio-temp-file.tmp";

function my_close_cb($data, $result) {
        global $temp_filename;

        echo 'close: ', var_export($result == 0, true), PHP_EOL;
        @unlink($temp_filename);
}

function my_falloc_cb($data, $result, $req) {
    $notImplemented = eio_get_last_error($req) === 'Function not implemented';
        echo "falloc: ", var_export($result == 0 || $notImplemented, true),  PHP_EOL;
}

function my_file_opened_callback($data, $result) {

        echo 'open: ', var_export($result > 0, true), PHP_EOL;
        if ($result > 0) {
                eio_fallocate($result, NULL, 0, 10, EIO_PRI_DEFAULT, "my_falloc_cb", NULL);
                eio_event_loop();

                eio_close($result, EIO_PRI_DEFAULT, "my_close_cb");
                eio_event_loop();
        }
}


eio_open($temp_filename, EIO_O_CREAT | EIO_O_RDWR, NULL, EIO_PRI_DEFAULT, "my_file_opened_callback", NULL);
eio_event_loop();
?>
--CLEAN--
--EXPECT--
open: true
falloc: true
close: true
PKK��\:����tests/eio_open_error.phptnu�[���--TEST--
Check for eio_open function error behaviour
--SKIPIF--
--FILE--
<?php 
error_reporting(0);

$temp_filename = "eio-temp-file-nonexistant.tmp";
function my_file_opened_callback($data, $result) {
	if ($result < 0) {
		echo "eio_open_ok";
	}
}


$req = eio_open($temp_filename, NULL, NULL, EIO_PRI_DEFAULT, "my_file_opened_callback", NULL);
eio_event_loop();
if (!$req) {
	echo "eio_open_ok";
}

error_reporting($old_error_reporting);
?>
--CLEAN--
<?php
?>
--EXPECT--
eio_open_ok
PKG��\�*�ZZtests/eio_chown_variation.phptnu�[���PKG��\We�N���tests/eio_write_variation.phptnu�[���PKG��\8�'��tests/bug65293.phptnu�[���PKG��\3������tests/eio_unlink_basic.phptnu�[���PKH��\���ff�
tests/eio_truncate_basic.phptnu�[���PKH��\�p�i

�
tests/eio_custom_basic.phptnu�[���PKH��\@<�����tests/fork.phptnu�[���PKH��\�Ҷ���tests/eio_read_basic.phptnu�[���PKH��\��B�''�tests/eio_grp_add.phptnu�[���PKI��\=��k��Atests/eio_sync.phptnu�[���PKI��\������w"tests/eio_chmod_basic.phptnu�[���PKI��\1@�qHHq$tests/eio_open_basic.phptnu�[���PKI��\
��		'tests/eio_utime_basic.phptnu�[���PKI��\!>�
��U)tests/eio_stat_basic.phptnu�[���PKI��\�����v-tests/eio_mknod_basic.phptnu�[���PKJ��\n3?Q���/tests/eio_sendfile_basic.phptnu�[���PKJ��\�Ѝ���2tests/eio_sendfile_sockets.phptnu�[���PKJ��\
c�PP�9tests/eio_rename_basic.phptnu�[���PKJ��\
K���><tests/eio_rmdir_basic.phptnu�[���PKJ��\%����>tests/eio_stat_error.phptnu�[���PKJ��\-�%4��XCtests/eio001.phptnu�[���PKK��\R�E���TDtests/eio_link.phptnu�[���PKK��\�d0���sHtests/eio_seek.phptnu�[���PKK��\q�Z��$?Ltests/eio_sendfile_sockets_php8.phptnu�[���PKK��\ѳ@99�Stests/eio_mkdir_basic.phptnu�[���PKK��\MV_�zz
Vtests/eio_cancel_basic.phptnu�[���PKK��\�+���Wtests/eio_readdir.phptnu�[���PKK��\�)���3\tests/eio_fallocate_basic.phptnu�[���PKK��\:����atests/eio_open_error.phptnu�[���PK
9c