mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2026-03-03 19:47:13 +08:00
v0.0.2
This commit is contained in:
@@ -1,177 +1,177 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title>Performs a c library fcntl on fd</title>
|
||||
</head>
|
||||
<body class="docs"><div id="layout">
|
||||
<div id="layout-content"><div id="function.dio-fcntl" class="refentry">
|
||||
<div class="refnamediv">
|
||||
<h1 class="refname">dio_fcntl</h1>
|
||||
<p class="verinfo">(PHP 4 >= 4.2.0, PHP 5 < 5.1.0)</p><p class="refpurpose"><span class="refname">dio_fcntl</span> — <span class="dc-title">Performs a c library fcntl on fd</span></p>
|
||||
|
||||
</div>
|
||||
<div class="refsect1 description" id="refsect1-function.dio-fcntl-description">
|
||||
<h3 class="title">说明</h3>
|
||||
<div class="methodsynopsis dc-description">
|
||||
<span class="methodname"><strong>dio_fcntl</strong></span>
|
||||
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$fd</code></span>
|
||||
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$cmd</code></span>
|
||||
[, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$args</code></span>
|
||||
] ) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>
|
||||
|
||||
<p class="para rdfs-comment">
|
||||
The <span class="function"><strong>dio_fcntl()</strong></span> function performs the
|
||||
operation specified by <code class="parameter">cmd</code> on the file
|
||||
descriptor <code class="parameter">fd</code>. Some commands require
|
||||
additional arguments <code class="parameter">args</code> to be supplied.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="refsect1 parameters" id="refsect1-function.dio-fcntl-parameters">
|
||||
<h3 class="title">参数</h3>
|
||||
<p class="para">
|
||||
<dl>
|
||||
|
||||
|
||||
<dt>
|
||||
<code class="parameter">fd</code></dt>
|
||||
|
||||
<dd>
|
||||
|
||||
<p class="para">
|
||||
The file descriptor returned by <span class="function"><a href="dio_open.html" class="function">dio_open()</a></span>.
|
||||
</p>
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
<dt>
|
||||
<code class="parameter">cmd</code></dt>
|
||||
|
||||
<dd>
|
||||
|
||||
<p class="para">
|
||||
Can be one of the following operations:
|
||||
<ul class="itemizedlist">
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<strong><code>F_SETLK</code></strong> - Lock is set or cleared. If the lock
|
||||
is held by someone else <span class="function"><strong>dio_fcntl()</strong></span> returns
|
||||
-1.
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<strong><code>F_SETLKW</code></strong> - like <strong><code>F_SETLK</code></strong>,
|
||||
but in case the lock is held by someone else,
|
||||
<span class="function"><strong>dio_fcntl()</strong></span> waits until the lock is released.
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<strong><code>F_GETLK</code></strong> - <span class="function"><strong>dio_fcntl()</strong></span>
|
||||
returns an associative array (as described below) if someone else
|
||||
prevents lock. If there is no obstruction key "type" will set
|
||||
to <strong><code>F_UNLCK</code></strong>.
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<strong><code>F_DUPFD</code></strong> - finds the lowest numbered available
|
||||
file descriptor greater than or equal to <code class="parameter">args</code>
|
||||
and returns them.
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<strong><code>F_SETFL</code></strong> - Sets the file descriptors flags to
|
||||
the value specified by <code class="parameter">args</code>, which can be
|
||||
<strong><code>O_APPEND</code></strong>, <strong><code>O_NONBLOCK</code></strong> or
|
||||
<strong><code>O_ASYNC</code></strong>. To use <strong><code>O_ASYNC</code></strong>
|
||||
you will need to use the <a href="ref.pcntl.html" class="link">PCNTL</a>
|
||||
extension.
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
<dt>
|
||||
<code class="parameter">args</code></dt>
|
||||
|
||||
<dd>
|
||||
|
||||
<p class="para">
|
||||
<code class="parameter">args</code> is an associative array, when
|
||||
<code class="parameter">cmd</code> is <strong><code>F_SETLK</code></strong> or
|
||||
<strong><code>F_SETLLW</code></strong>, with the following keys:
|
||||
<ul class="itemizedlist">
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<em>start</em> - offset where lock begins
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<em>length</em> - size of locked area. zero means to end
|
||||
of file
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<em>whence</em> - Where l_start is relative to: can be
|
||||
<strong><code>SEEK_SET</code></strong>,
|
||||
<strong><code>SEEK_END</code></strong> and <strong><code>SEEK_CUR</code></strong>
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<em>type</em> - type of lock: can be
|
||||
<strong><code>F_RDLCK</code></strong> (read lock),
|
||||
<strong><code>F_WRLCK</code></strong> (write lock) or
|
||||
<strong><code>F_UNLCK</code></strong> (unlock)
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
</dd>
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="refsect1 returnvalues" id="refsect1-function.dio-fcntl-returnvalues">
|
||||
<h3 class="title">返回值</h3>
|
||||
<p class="para">
|
||||
Returns the result of the C call.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="refsect1 examples" id="refsect1-function.dio-fcntl-examples">
|
||||
<h3 class="title">范例</h3>
|
||||
<p class="para">
|
||||
<div class="example" id="example-2742">
|
||||
<p><strong>Example #1 Setting and clearing a lock</strong></p>
|
||||
<div class="example-contents">
|
||||
<div class="phpcode"><pre><span style="color: #000000">
|
||||
<span style="color: #0000BB"><?php<br /><br />$fd </span><span style="color: #007700">= </span><span style="color: #0000BB">dio_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'/dev/ttyS0'</span><span style="color: #007700">, </span><span style="color: #0000BB">O_RDWR</span><span style="color: #007700">);<br /><br />if (</span><span style="color: #0000BB">dio_fcntl</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">, </span><span style="color: #0000BB">F_SETLK</span><span style="color: #007700">, Array(</span><span style="color: #DD0000">"type"</span><span style="color: #007700">=></span><span style="color: #0000BB">F_WRLCK</span><span style="color: #007700">)) == -</span><span style="color: #0000BB">1</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">// the file descriptor appears locked<br /> </span><span style="color: #007700">echo </span><span style="color: #DD0000">"The lock can not be cleared. It is held by someone else."</span><span style="color: #007700">;<br />} else {<br /> echo </span><span style="color: #DD0000">"Lock successfully set/cleared"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">dio_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
|
||||
</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="refsect1 notes" id="refsect1-function.dio-fcntl-notes">
|
||||
<h3 class="title">注释</h3>
|
||||
<blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数未在 Windows 平台下实现。</span></p></blockquote>
|
||||
</div>
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<title>Performs a c library fcntl on fd</title>
|
||||
</head>
|
||||
<body class="docs"><div id="layout">
|
||||
<div id="layout-content"><div id="function.dio-fcntl" class="refentry">
|
||||
<div class="refnamediv">
|
||||
<h1 class="refname">dio_fcntl</h1>
|
||||
<p class="verinfo">(PHP 4 >= 4.2.0, PHP 5 < 5.1.0)</p><p class="refpurpose"><span class="refname">dio_fcntl</span> — <span class="dc-title">Performs a c library fcntl on fd</span></p>
|
||||
|
||||
</div>
|
||||
<div class="refsect1 description" id="refsect1-function.dio-fcntl-description">
|
||||
<h3 class="title">说明</h3>
|
||||
<div class="methodsynopsis dc-description">
|
||||
<span class="methodname"><strong>dio_fcntl</strong></span>
|
||||
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$fd</code></span>
|
||||
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$cmd</code></span>
|
||||
[, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$args</code></span>
|
||||
] ) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>
|
||||
|
||||
<p class="para rdfs-comment">
|
||||
The <span class="function"><strong>dio_fcntl()</strong></span> function performs the
|
||||
operation specified by <code class="parameter">cmd</code> on the file
|
||||
descriptor <code class="parameter">fd</code>. Some commands require
|
||||
additional arguments <code class="parameter">args</code> to be supplied.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="refsect1 parameters" id="refsect1-function.dio-fcntl-parameters">
|
||||
<h3 class="title">参数</h3>
|
||||
<p class="para">
|
||||
<dl>
|
||||
|
||||
|
||||
<dt>
|
||||
<code class="parameter">fd</code></dt>
|
||||
|
||||
<dd>
|
||||
|
||||
<p class="para">
|
||||
The file descriptor returned by <span class="function"><a href="dio_open.html" class="function">dio_open()</a></span>.
|
||||
</p>
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
<dt>
|
||||
<code class="parameter">cmd</code></dt>
|
||||
|
||||
<dd>
|
||||
|
||||
<p class="para">
|
||||
Can be one of the following operations:
|
||||
<ul class="itemizedlist">
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<strong><code>F_SETLK</code></strong> - Lock is set or cleared. If the lock
|
||||
is held by someone else <span class="function"><strong>dio_fcntl()</strong></span> returns
|
||||
-1.
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<strong><code>F_SETLKW</code></strong> - like <strong><code>F_SETLK</code></strong>,
|
||||
but in case the lock is held by someone else,
|
||||
<span class="function"><strong>dio_fcntl()</strong></span> waits until the lock is released.
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<strong><code>F_GETLK</code></strong> - <span class="function"><strong>dio_fcntl()</strong></span>
|
||||
returns an associative array (as described below) if someone else
|
||||
prevents lock. If there is no obstruction key "type" will set
|
||||
to <strong><code>F_UNLCK</code></strong>.
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<strong><code>F_DUPFD</code></strong> - finds the lowest numbered available
|
||||
file descriptor greater than or equal to <code class="parameter">args</code>
|
||||
and returns them.
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<strong><code>F_SETFL</code></strong> - Sets the file descriptors flags to
|
||||
the value specified by <code class="parameter">args</code>, which can be
|
||||
<strong><code>O_APPEND</code></strong>, <strong><code>O_NONBLOCK</code></strong> or
|
||||
<strong><code>O_ASYNC</code></strong>. To use <strong><code>O_ASYNC</code></strong>
|
||||
you will need to use the <a href="ref.pcntl.html" class="link">PCNTL</a>
|
||||
extension.
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
<dt>
|
||||
<code class="parameter">args</code></dt>
|
||||
|
||||
<dd>
|
||||
|
||||
<p class="para">
|
||||
<code class="parameter">args</code> is an associative array, when
|
||||
<code class="parameter">cmd</code> is <strong><code>F_SETLK</code></strong> or
|
||||
<strong><code>F_SETLLW</code></strong>, with the following keys:
|
||||
<ul class="itemizedlist">
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<em>start</em> - offset where lock begins
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<em>length</em> - size of locked area. zero means to end
|
||||
of file
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<em>whence</em> - Where l_start is relative to: can be
|
||||
<strong><code>SEEK_SET</code></strong>,
|
||||
<strong><code>SEEK_END</code></strong> and <strong><code>SEEK_CUR</code></strong>
|
||||
</p>
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<p class="para">
|
||||
<em>type</em> - type of lock: can be
|
||||
<strong><code>F_RDLCK</code></strong> (read lock),
|
||||
<strong><code>F_WRLCK</code></strong> (write lock) or
|
||||
<strong><code>F_UNLCK</code></strong> (unlock)
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
</dd>
|
||||
|
||||
|
||||
</dl>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="refsect1 returnvalues" id="refsect1-function.dio-fcntl-returnvalues">
|
||||
<h3 class="title">返回值</h3>
|
||||
<p class="para">
|
||||
Returns the result of the C call.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="refsect1 examples" id="refsect1-function.dio-fcntl-examples">
|
||||
<h3 class="title">范例</h3>
|
||||
<p class="para">
|
||||
<div class="example" id="example-2742">
|
||||
<p><strong>Example #1 Setting and clearing a lock</strong></p>
|
||||
<div class="example-contents">
|
||||
<div class="phpcode"><pre><span style="color: #000000">
|
||||
<span style="color: #0000BB"><?php<br /><br />$fd </span><span style="color: #007700">= </span><span style="color: #0000BB">dio_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'/dev/ttyS0'</span><span style="color: #007700">, </span><span style="color: #0000BB">O_RDWR</span><span style="color: #007700">);<br /><br />if (</span><span style="color: #0000BB">dio_fcntl</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">, </span><span style="color: #0000BB">F_SETLK</span><span style="color: #007700">, Array(</span><span style="color: #DD0000">"type"</span><span style="color: #007700">=></span><span style="color: #0000BB">F_WRLCK</span><span style="color: #007700">)) == -</span><span style="color: #0000BB">1</span><span style="color: #007700">) {<br /> </span><span style="color: #FF8000">// the file descriptor appears locked<br /> </span><span style="color: #007700">echo </span><span style="color: #DD0000">"The lock can not be cleared. It is held by someone else."</span><span style="color: #007700">;<br />} else {<br /> echo </span><span style="color: #DD0000">"Lock successfully set/cleared"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">dio_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
|
||||
</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="refsect1 notes" id="refsect1-function.dio-fcntl-notes">
|
||||
<h3 class="title">注释</h3>
|
||||
<blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数未在 Windows 平台下实现。</span></p></blockquote>
|
||||
</div>
|
||||
|
||||
</div></div></div></body></html>
|
||||
Reference in New Issue
Block a user