<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.dio.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.dio-fcntl.php',
    1 => 'dio_fcntl',
    2 => 'Esegue la funzione C fcntl su un descrittore di file',
  ),
  'up' => 
  array (
    0 => 'ref.dio.php',
    1 => 'Direct IO Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.dio-close.php',
    1 => 'dio_close',
  ),
  'next' => 
  array (
    0 => 'function.dio-open.php',
    1 => 'dio_open',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/dio/functions/dio-fcntl.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.dio-fcntl" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">dio_fcntl</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5 &lt; 5.1.0)</p><p class="refpurpose"><span class="refname">dio_fcntl</span> &mdash; <span class="dc-title">Esegue la funzione C fcntl su un descrittore di file</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.dio-fcntl-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>dio_fcntl</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$fd</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$cmd</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$args</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   La funzione <span class="function"><strong>dio_fcntl()</strong></span> esegue le operazioni
   specificate dal parametro <code class="parameter">cmd</code> sul descrittore
   di file <code class="parameter">fd</code>. Qualora i comandi richiedano
   informazioni addizionali occorre valorizzare <code class="parameter">args</code> con tali informazioni.
  </p>
  <blockquote class="note"><p><strong class="note">Nota</strong>: <span class="simpara">Questa funzione non è
implementata sulle piattaforme Windows.</span></p></blockquote>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.dio-fcntl-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">fd</code></dt>
      <dd>
       <p class="para">
        Descrittore di file restituito da <span class="function"><a href="function.dio-open.php" class="function">dio_open()</a></span>.
       </p>
      </dd>
     
     
      <dt><code class="parameter">cmd</code></dt>
      <dd>
       <p class="para">
        Può indicare una delle seguenti operazioni:
        <ul class="itemizedlist">
         <li class="listitem">
          <p class="para">
           <strong><code><a href="dio.constants.php#constant.f-setlk">F_SETLK</a></code></strong> - imposta o azzera un lock. Se il lock è impostato
           da un&#039;altro processo la funzione <span class="function"><strong>dio_fcntl()</strong></span> restituisce
           -1.
          </p>
         </li>
         <li class="listitem">
          <p class="para">
           <strong><code><a href="dio.constants.php#constant.f-setlkw">F_SETLKW</a></code></strong> - come <strong><code><a href="dio.constants.php#constant.f-setlk">F_SETLK</a></code></strong>, ma nel caso in cui il lock sia impostato da 
           un&#039;altro processo la funzione <span class="function"><strong>dio_fcntl()</strong></span> attende
           sino a quando il blocco non viene rimosso.
          </p>
         </li>
         <li class="listitem">
          <p class="para">
           <strong><code><a href="dio.constants.php#constant.f-getlk">F_GETLK</a></code></strong> - la <span class="function"><strong>dio_fcntl()</strong></span> restituisce un array
           associativo (come descritto precedentemente) se qualche altro processo
           impedisce il lock. Se non vi sono problemi la chiave &quot;type&quot; sarà impostata
           a <strong><code><a href="dio.constants.php#constant.f-unlck">F_UNLCK</a></code></strong>.
          </p>
         </li>
         <li class="listitem">
          <p class="para">
           <strong><code><a href="dio.constants.php#constant.f-dupfd">F_DUPFD</a></code></strong> - trova il più piccolo numero di descrittore di file disponibile
           che sia maggiore o uguale rispetto ad <code class="parameter">args</code>
           e lo restituisce.
          </p>
         </li>
         <li class="listitem">
          <p class="para">
           <strong><code>F_SETF</code></strong>L - Imposta i flag del descrittore di file al valore specificato da
           <code class="parameter">args</code>. Tale valore può essere <strong><code><a href="dio.constants.php#constant.o-append">O_APPEND</a></code></strong>,
           <strong><code><a href="dio.constants.php#constant.o-nonblock">O_NONBLOCK</a></code></strong> oppure <strong><code><a href="dio.constants.php#constant.o-async">O_ASYNC</a></code></strong>. Per utilizzare
           <strong><code><a href="dio.constants.php#constant.o-async">O_ASYNC</a></code></strong> occorre utilizzare l&#039;estensione
           <a href="ref.pcntl.php" class="link">PCNTL</a>.
          </p>
         </li>
        </ul>
       </p>
      </dd>
     
     
      <dt><code class="parameter">args</code></dt>
      <dd>
       <p class="para">
        Il parametro <code class="parameter">args</code> è un array associativo, nei casi in cui
        <code class="parameter">cmd</code> è impostato a <strong><code><a href="dio.constants.php#constant.f-setlk">F_SETLK</a></code></strong> oppure a <strong><code>F_SETLLW</code></strong>, contiene
        le seguenti chiavi:
        <ul class="itemizedlist">
        <li class="listitem">
         <p class="para">
          &quot;start&quot; - offset da cui comincia il lock
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          &quot;length&quot; - dimensione dell&#039;area bloccata, zero significa fine file
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          &quot;wenth&quot; - a cosa  l_start è relativo: 
           può valere <strong><code><a href="filesystem.constants.php#constant.seek-set">SEEK_SET</a></code></strong>,
          <strong><code><a href="filesystem.constants.php#constant.seek-end">SEEK_END</a></code></strong> o <strong><code><a href="filesystem.constants.php#constant.seek-cur">SEEK_CUR</a></code></strong>
         </p>
        </li>
        <li class="listitem">
         <p class="para">
          &quot;type&quot; - tipo di lock: può essere <strong><code><a href="dio.constants.php#constant.f-rdlck">F_RDLCK</a></code></strong> (lock in lettura),
          <strong><code><a href="dio.constants.php#constant.f-wrlck">F_WRLCK</a></code></strong> (lock in scrittura) oppure
          <strong><code><a href="dio.constants.php#constant.f-unlck">F_UNLCK</a></code></strong> (rimozione del lock)
         </p>
        </li>
       </ul>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.dio-fcntl-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Restituisce il valore della chiamata C.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.dio-fcntl-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 Impostare e cancellare un lock</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?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">=&gt;</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 succesfully 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">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>

</div><?php manual_footer($setup); ?>