Source for file man.php
Documentation is available at man.php
* Project: eSystem:: The Extended file system<br>
* File: eSystem/system.php
* Sub pcakge of eSystem package. This package includes extended system
* @subpackage eSystem_man
* @author JoungKyun.Kim <http://oops.org>
* @copyright (c) 2018, OOPS.org
* @link http://pear.oops.org/package/KSC5601
* include eSystem_system class
require_once 'eSystem/system.php';
// {{{ function so_man ($_file, $_base, $_int = '') {
* @param string path of man file
* @param string base path of man page
* @param string (optional) L10n code for international man pages
function so_man ($_file, $_base, $_int = '') {
$_dotso = $_func($_file);
if ( preg_match ("/\.so (.+)/m", $dotso, $_match) )
$_file = "{ $_base}/{$_int}{$_match[1]}{$_ext}";
// {{{ function manPath ($_name, $_path = '/usr/share/man', $_sec = 0)
* Return man page file path with man page section and name
* {@example eSystem/test.php 170 2}
* @return string Returns man page file path
* @param string Name of man page for searching
* @param string (optional) Base man page base path
* @param integer (optional) Section of man page
function manPath ($_name, $_path = '/usr/share/man', $_sec = 0) {
$_path = ! $_path ? '/usr/share/man/' : $_path;
$_f = "{ $_path}/man{$_sec}/{$_name}.{$_sec}";
$_fgz = "{ $_path}/man{$_sec}/{$_name}.{$_sec}.gz";
return ($_fac > 1 ) ? $_fa : $_fa[0];
// {{{ function man ($_name, $_no, $_int = NULL, $__base = null, $_s = false)
* Return man page contents for human readable
* @return string Returns man page file path
* @param string name of man page
* @param int Section of man page
* @param string (optional) L10n code for international man pages
* @param string (optional) Base man page base path
* @param boolean (optional) Defaults to 0. Set true, even if result
* is array, force convert plain text strings.
function man ($_name, $_no, $_int = NULL, $__base = null, $_s = false) {
echo "Error: man function requires zlib extension!\n";
$__base = $__base ? $__base : '/usr/share/man';
$_man = "{ $_name}.{ $_no}";
$_int = $_int ? "{ $_int}/ " : '';
$_base = "{ $__base}/{ $_int}{ $_mdir}";
$_file = "{ $_base}/{ $_man}";
$_gzfile = "{ $_base}/{ $_man}.gz ";
$mancmd = '/usr/bin/nroff -man';
$mancmd = '/usr/bin/groff -S -Wall -mtty-char -Tascii -man';
$_gzfile = $this->so_man ($_gzfile, $__base, $_int);
echo "Error: Can't write $tmpfile\n";
$this->_system ("$mancmd $tmpfile");
$_file = $this->so_man ($_file, $__base, $_int);
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
|