Sophie

Sophie

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

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: playlists.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>playlists.c</h1>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &quot;common.h&quot;</span>
<span class="preprocessor">#include &lt;string.h&gt;</span>

<span class="keyword">static</span> <span class="keywordtype">void</span> playlist_dump (<a name="_a0"></a><a class="code" href="structnjb__playlist__struct.html">njb_playlist_t</a> *pl, FILE *fp)
{
  <a name="_a1"></a><a class="code" href="structnjb__playlist__track__struct.html">njb_playlist_track_t</a> *track;
  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 1;
  
  fprintf(fp, <span class="stringliteral">&quot;Playlist: %s\n&quot;</span>, pl-&gt;<a name="a2"></a><a class="code" href="structnjb__playlist__struct.html#a39e73f00d43c351fbbe95441fd3c00ed">name</a>);
  fprintf(fp, <span class="stringliteral">&quot;ID:       %u\n&quot;</span>, pl-&gt;<a name="a3"></a><a class="code" href="structnjb__playlist__struct.html#ac581be97d7858c7e304faecf6a36aef0">plid</a>);
  fprintf(fp, <span class="stringliteral">&quot;Tracks:   %u\n&quot;</span>, pl-&gt;<a name="a4"></a><a class="code" href="structnjb__playlist__struct.html#a20cc10b697f65aaa195709be7e866420">ntracks</a>);
  fprintf(fp, <span class="stringliteral">&quot;State:    %d\n&quot;</span>, pl-&gt;<a name="a5"></a><a class="code" href="structnjb__playlist__struct.html#a5a008f055a72c6734236b3a61655278d">_state</a>);
  
  <a name="a6"></a><a class="code" href="group__playlistapi.html#ga73e493de30c483a0ea4dc7fe3435f494">NJB_Playlist_Reset_Gettrack</a>(pl);
  <span class="keywordflow">while</span> ( (track = <a name="a7"></a><a class="code" href="group__playlistapi.html#ga67bff0505f033f31e6be034d8e9be13f">NJB_Playlist_Gettrack</a>(pl)) ) {
    fprintf(fp, <span class="stringliteral">&quot;%5u - track ID %u\n&quot;</span>, i, track-&gt;<a name="a8"></a><a class="code" href="structnjb__playlist__track__struct.html#a0c0d66923d6acb571453427b5a540d61">trackid</a>);
    i++;
  }
}

<span class="keywordtype">int</span> main (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
{
  <a name="_a9"></a><a class="code" href="structnjb__struct.html">njb_t</a> njbs[<a name="a10"></a><a class="code" href="libnjb_8h.html#a46e41076f44166b6446e3fdae6db62a9">NJB_MAX_DEVICES</a>], *njb;
  <span class="keywordtype">int</span> n, debug;
  <a class="code" href="structnjb__playlist__struct.html">njb_playlist_t</a> *playlist;
  <span class="keyword">extern</span> <span class="keywordtype">char</span> *optarg;
  <span class="keywordtype">int</span> opt;
  <span class="keywordtype">char</span> *lang;
  
  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: playlists [ -D debuglvl ]\n&quot;</span>);
      <span class="keywordflow">return</span> 1;
    }
  }
  
  <span class="keywordflow">if</span> ( debug ) <a name="a11"></a><a class="code" href="group__internals.html#gaa5ff48cc89e320bc1c1d89efd2613d77">NJB_Set_Debug</a>(debug);

  <span class="comment">/*</span>
<span class="comment">   * Check environment variables $LANG and $LC_CTYPE</span>
<span class="comment">   * to see if we want to support UTF-8 unicode</span>
<span class="comment">   * $LANG = &quot;xx_XX.UTF-8&quot; or $LC_CTYPE = &quot;?&quot;</span>
<span class="comment">   * trigger unicode support.</span>
<span class="comment">   */</span>
  lang = getenv(<span class="stringliteral">&quot;LANG&quot;</span>);
  <span class="keywordflow">if</span> (lang != NULL) {
    <span class="keywordflow">if</span> (strlen(lang) &gt; 5) {
      <span class="keywordflow">if</span> (!strcmp(&amp;lang[strlen(lang)-5], <span class="stringliteral">&quot;UTF-8&quot;</span>)) {
        <a name="a12"></a><a class="code" href="group__internals.html#ga22a893c243cd4398de35fcdea5b49b39">NJB_Set_Unicode</a>(<a name="a13"></a><a class="code" href="group__unicodeflags.html#ga388e9c70b7a684c777f6b25e2e9d801b">NJB_UC_UTF8</a>);
      }
    }
  }

  <span class="keywordflow">if</span> (<a name="a14"></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 = njbs;
  
  <span class="keywordflow">if</span> ( <a name="a15"></a><a class="code" href="group__basic.html#gaa631536b597d8f8cb73eeb47eff6640a">NJB_Open</a>(njb) == -1 ) {
    <a name="a16"></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="a17"></a><a class="code" href="group__basic.html#ga023eb258743b5961ec1b85cbd62a55cb">NJB_Capture</a>(njb) == -1 ) {
    <a class="code" href="group__internals.html#gae9b849a9a883fe1fd697278bd8d49585">NJB_Error_Dump</a>(njb,stderr);
    <span class="keywordflow">return</span> 1;
  }
  
  <a name="a18"></a><a class="code" href="group__playlistapi.html#ga3781a9a6f68d7ab3ac5970fc4f2c80d9">NJB_Reset_Get_Playlist</a>(njb);
  n = 0;
  <span class="keywordflow">while</span> ( (playlist = <a name="a19"></a><a class="code" href="group__playlistapi.html#ga85a098c666b569588a4bb8244b4070da">NJB_Get_Playlist</a>(njb)) ) {
    playlist_dump(playlist, stdout);
    printf(<span class="stringliteral">&quot;----------------------------------\n&quot;</span>);
    n ++;
  }
  
  <span class="comment">/* Dump any pending errors */</span>
  <span class="keywordflow">if</span> (<a name="a20"></a><a class="code" href="group__internals.html#ga2497a98361bc58544b96d6244d3ef050">NJB_Error_Pending</a>(njb)) {
    <a class="code" href="group__internals.html#gae9b849a9a883fe1fd697278bd8d49585">NJB_Error_Dump</a>(njb,stderr);
  }
  
  printf(<span class="stringliteral">&quot;Total: %d playlists\n&quot;</span>, n);
  
  <a name="a21"></a><a class="code" href="group__basic.html#ga69d4034384f1bd033ed2c9ba7a9b32d4">NJB_Release</a>(njb);
  
  <a name="a22"></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>