array('pipe', 'r'),//stdin 1 => array('pipe', 'w'),//stdout 2 => array('pipe', 'w') //stderr ); $process = proc_open('rst2html', $descriptorspec, $pipes); if (!is_resource($process)) { return '
' . 'Cannot open process to execute rst2html' . '
'; } fwrite($pipes[0], $file->getContent()); fclose($pipes[0]); $html = stream_get_contents($pipes[1]); fclose($pipes[1]); $errors = stream_get_contents($pipes[2]); fclose($pipes[2]); $retval = proc_close($process); //cheap extraction of the rst html body $html = substr($html, strpos($html, '') + 6); $html = substr($html, 0, strpos($html, '')); if ($retval != 0) { $html = '
' . 'rst2html encountered some error; return value ' . $retval . '
' . 'Error message: ' . $errors . '
' . $html; } return $html; } } ?>