Sophie

Sophie

distrib > * > cooker > x86_64 > by-pkgid > 12036146830596fff8a6e80859ec761e > files > 40

lib64njb-devel-2.2.6-9.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>libnjb: getusage.c</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.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">libnjb&#160;<span id="projectnumber">2.2.6</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<h1>getusage.c</h1>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &quot;common.h&quot;</span>

<span class="keywordtype">int</span> main (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
{
  <a name="_a0"></a><a class="code" href="structnjb__struct.html">njb_t</a> njbs[<a name="a1"></a><a class="code" href="libnjb_8h.html#a46e41076f44166b6446e3fdae6db62a9">NJB_MAX_DEVICES</a>];
  <a class="code" href="structnjb__struct.html">njb_t</a> *njb;
  <span class="keywordtype">int</span> n, opt, debug;
  <span class="keyword">extern</span> <span class="keywordtype">char</span> *optarg;
  u_int64_t total;
  u_int64_t free;
  
  debug = 0;
  <span class="keywordflow">while</span> ( (opt = getopt(argc, argv, <span class="stringliteral">&quot;D:&quot;</span>)) != -1 ) {
    <span class="keywordflow">switch</span> (opt) {
    <span class="keywordflow">case</span> <span class="charliteral">&#39;D&#39;</span>:
      debug = atoi(optarg);
      <span class="keywordflow">break</span>;
    <span class="keywordflow">default</span>:
      fprintf(stderr, <span class="stringliteral">&quot;usage: handshake [ -D debuglvl ]\n&quot;</span>);
      <span class="keywordflow">return</span> 1;
    }
  }
  
  <span class="keywordflow">if</span> ( debug ) <a name="a2"></a><a class="code" href="group__internals.html#gaa5ff48cc89e320bc1c1d89efd2613d77">NJB_Set_Debug</a>(debug);

  <span class="keywordflow">if</span> (<a name="a3"></a><a class="code" href="group__basic.html#ga199efd7711a70ae5d63f4052c2e492d3">NJB_Discover</a>(njbs, 0, &amp;n) == -1) {
    fprintf(stderr, <span class="stringliteral">&quot;could not locate any jukeboxes\n&quot;</span>);
    <span class="keywordflow">return</span> 1;
  }

  <span class="keywordflow">if</span> ( n == 0 ) {
    fprintf(stderr, <span class="stringliteral">&quot;no NJB devices found\n&quot;</span>);
    <span class="keywordflow">return</span> 0;
  }

  njb = &amp;njbs[0];

  <span class="keywordflow">if</span> ( <a name="a4"></a><a class="code" href="group__basic.html#gaa631536b597d8f8cb73eeb47eff6640a">NJB_Open</a>(njb) == -1 ) {
    <a name="a5"></a><a class="code" href="group__internals.html#gae9b849a9a883fe1fd697278bd8d49585">NJB_Error_Dump</a>(njb,stderr);
    <span class="keywordflow">return</span> 1;
  }
  
  <span class="keywordflow">if</span> (<a name="a6"></a><a class="code" href="group__basic.html#gab45cd3177a295ea8604423080e7e62ed">NJB_Get_Disk_Usage</a>(njb, &amp;total, &amp;free) == -1) {
    <a class="code" href="group__internals.html#gae9b849a9a883fe1fd697278bd8d49585">NJB_Error_Dump</a>(njb,stderr);
    <span class="keywordflow">return</span> 1;
  }
  
<span class="preprocessor">#ifdef __WIN32__</span>
<span class="preprocessor"></span>  printf(<span class="stringliteral">&quot;Total bytes on jukebox: %I64u (%I64u MB)\n&quot;</span>,
         total, total/(1024*1024));
  printf(<span class="stringliteral">&quot;Free bytes on jukebox: %I64u (%I64u MB)\n&quot;</span>,
         free, free/(1024*1024));
<span class="preprocessor">#else</span>
<span class="preprocessor"></span>  printf(<span class="stringliteral">&quot;Total bytes on jukebox: %llu (%llu MB)\n&quot;</span>,
         total, total/(1024*1024));
  printf(<span class="stringliteral">&quot;Free bytes on jukebox: %llu (%llu MB)\n&quot;</span>,
         free, free/(1024*1024));
<span class="preprocessor">#endif</span>
<span class="preprocessor"></span>  
  <a name="a7"></a><a class="code" href="group__basic.html#ga13a9c926c430f38f3a6535ecaaf3e9b9">NJB_Close</a>(njb);
  
  <span class="keywordflow">return</span> 0;
}

</pre></div> </div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Mon May 2 2011 06:05:24 for libnjb by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
</body>
</html>