Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > f48b0484566fe5f15f1edab7e7e31247 > files > 22

lib64usb1.0-devel-1.0.7-3mdv2010.1.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>libusb: Library initialization/deinitialization</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<script type="text/javascript">
<!--
function changeDisplayState (e){
  var num=this.id.replace(/[^[0-9]/g,'');
  var button=this.firstChild;
  var sectionDiv=document.getElementById('dynsection'+num);
  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
    sectionDiv.style.display='block';
    button.src='open.gif';
  }else{
    sectionDiv.style.display='none';
    button.src='closed.gif';
  }
}
function initDynSections(){
  var divs=document.getElementsByTagName('div');
  var sectionCounter=1;
  for(var i=0;i<divs.length-1;i++){
    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
      var header=divs[i];
      var section=divs[i+1];
      var button=header.firstChild;
      if (button!='IMG'){
        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
        button=document.createElement('img');
        divs[i].insertBefore(button,divs[i].firstChild);
      }
      header.style.cursor='pointer';
      header.onclick=changeDisplayState;
      header.id='dynheader'+sectionCounter;
      button.src='closed.gif';
      section.id='dynsection'+sectionCounter;
      section.style.display='none';
      section.style.marginLeft='14px';
      sectionCounter++;
    }
  }
}
window.onload = initDynSections;
-->
</script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>Library initialization/deinitialization</h1>
<p>This page details how to initialize and deinitialize libusb.  
<a href="#_details">More...</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Typedefs</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Structure representing a libusb session.  <a href="#ga4ec088aa7b79c4a9599e39bf36a72833"></a><br/></td></tr>
<tr><td colspan="2"><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lib.html#ga5f8376b7a863a5a8d5b8824feb8a427a">libusb_set_debug</a> (<a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a> *ctx, int level)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set message verbosity.  <a href="#ga5f8376b7a863a5a8d5b8824feb8a427a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lib.html#ga9517c37281bba0b51cc62eba728be48b">libusb_init</a> (<a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a> **context)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initialize libusb.  <a href="#ga9517c37281bba0b51cc62eba728be48b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__lib.html#ga86532f222d4f1332a5f8f5eef9a92da9">libusb_exit</a> (struct <a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a> *ctx)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Deinitialize libusb.  <a href="#ga86532f222d4f1332a5f8f5eef9a92da9"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>This page details how to initialize and deinitialize libusb. </p>
<p>Initialization must be performed before using any libusb functionality, and similarly you must not call any libusb functions after deinitialization. </p>
<hr/><h2>Typedef Documentation</h2>
<a class="anchor" id="ga4ec088aa7b79c4a9599e39bf36a72833"></a><!-- doxytag: member="libusb.h::libusb_context" ref="ga4ec088aa7b79c4a9599e39bf36a72833" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef struct <a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a> <a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Structure representing a libusb session. </p>
<p>The concept of individual libusb sessions allows for your program to use two libraries (or dynamically load two modules) which both independently use libusb. This will prevent interference between the individual libusb users - for example <a class="el" href="group__lib.html#ga5f8376b7a863a5a8d5b8824feb8a427a" title="Set message verbosity.">libusb_set_debug()</a> will not affect the other user of the library, and <a class="el" href="group__lib.html#ga86532f222d4f1332a5f8f5eef9a92da9" title="Deinitialize libusb.">libusb_exit()</a> will not destroy resources that the other user is still using.</p>
<p>Sessions are created by <a class="el" href="group__lib.html#ga9517c37281bba0b51cc62eba728be48b" title="Initialize libusb.">libusb_init()</a> and destroyed through <a class="el" href="group__lib.html#ga86532f222d4f1332a5f8f5eef9a92da9" title="Deinitialize libusb.">libusb_exit()</a>. If your application is guaranteed to only ever include a single libusb user (i.e. you), you do not have to worry about contexts: pass NULL in every function call where a context is required. The default context will be used.</p>
<p>For more information, see <a class="el" href="contexts.html">Contexts</a>. </p>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="ga5f8376b7a863a5a8d5b8824feb8a427a"></a><!-- doxytag: member="core.c::libusb_set_debug" ref="ga5f8376b7a863a5a8d5b8824feb8a427a" args="(libusb_context *ctx, int level)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void libusb_set_debug </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a> *&nbsp;</td>
          <td class="paramname"> <em>ctx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>level</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Set message verbosity. </p>
<ul>
<li>Level 0: no messages ever printed by the library (default)</li>
<li>Level 1: error messages are printed to stderr</li>
<li>Level 2: warning and error messages are printed to stderr</li>
<li>Level 3: informational messages are printed to stdout, warning and error messages are printed to stderr</li>
</ul>
<p>The default level is 0, which means no messages are ever printed. If you choose to increase the message verbosity level, ensure that your application does not close the stdout/stderr file descriptors.</p>
<p>You are advised to set level 3. libusb is conservative with its message logging and most of the time, will only log messages that explain error conditions and other oddities. This will help you debug your software.</p>
<p>If the LIBUSB_DEBUG environment variable was set when libusb was initialized, this function does nothing: the message verbosity is fixed to the value in the environment variable.</p>
<p>If libusb was compiled without any message logging, this function does nothing: you'll never get any messages.</p>
<p>If libusb was compiled with verbose debug message logging, this function does nothing: you'll always get messages from all levels.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>ctx</em>&nbsp;</td><td>the context to operate on, or NULL for the default context </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>level</em>&nbsp;</td><td>debug level to set </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ga9517c37281bba0b51cc62eba728be48b"></a><!-- doxytag: member="core.c::libusb_init" ref="ga9517c37281bba0b51cc62eba728be48b" args="(libusb_context **context)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libusb_init </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a> **&nbsp;</td>
          <td class="paramname"> <em>context</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initialize libusb. </p>
<p>This function must be called before calling any other libusb function. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>context</em>&nbsp;</td><td>Optional output location for context pointer. Only valid on return code 0. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>0 on success, or a LIBUSB_ERROR code on failure </dd></dl>

</div>
</div>
<a class="anchor" id="ga86532f222d4f1332a5f8f5eef9a92da9"></a><!-- doxytag: member="core.c::libusb_exit" ref="ga86532f222d4f1332a5f8f5eef9a92da9" args="(struct libusb_context *ctx)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void libusb_exit </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="group__lib.html#ga4ec088aa7b79c4a9599e39bf36a72833">libusb_context</a> *&nbsp;</td>
          <td class="paramname"> <em>ctx</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Deinitialize libusb. </p>
<p>Should be called after closing all open devices and before your application terminates. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>ctx</em>&nbsp;</td><td>the context to deinitialize, or NULL for the default context </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Apr 28 09:03:58 2010 for libusb by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>