Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 23fdeec2afeeb035357795bcffb419c6 > files > 21

libmtp-doc-1.0.2-1mdv2010.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>libmtp: getplaylist.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.6.2 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</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>
      <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="contents">
<h1>getplaylist.c</h1><div class="fragment"><pre class="fragment">
<span class="preprocessor">#include &quot;common.h&quot;</span>
<span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<span class="preprocessor">#include &lt;limits.h&gt;</span>

<span class="keyword">static</span> uint32_t dump_playlist(<a name="_a0"></a><a class="code" href="structLIBMTP__mtpdevice__struct.html">LIBMTP_mtpdevice_t</a> *device, <a name="_a1"></a><a class="code" href="structLIBMTP__playlist__struct.html">LIBMTP_playlist_t</a> *pl)
{
  uint32_t i;

  printf(<span class="stringliteral">&quot;Number of items: %u\n&quot;</span>, pl-&gt;<a name="a2"></a><a class="code" href="structLIBMTP__playlist__struct.html#a868f74d17f319549b7e14d9f95826c6f">no_tracks</a>);
  <span class="keywordflow">if</span>(pl-&gt;<a class="code" href="structLIBMTP__playlist__struct.html#a868f74d17f319549b7e14d9f95826c6f">no_tracks</a> &gt; 0) {
    <span class="keywordflow">for</span>(i=0;i&lt;pl-&gt;<a class="code" href="structLIBMTP__playlist__struct.html#a868f74d17f319549b7e14d9f95826c6f">no_tracks</a>;i++) {
      <a name="_a3"></a><a class="code" href="structLIBMTP__track__struct.html">LIBMTP_track_t</a> *track;
      
      track = <a name="a4"></a><a class="code" href="group__tracks.html#ga93aaa8ce0db15dff891a4e0c8e5fd094">LIBMTP_Get_Trackmetadata</a>(device, pl-&gt;<a name="a5"></a><a class="code" href="structLIBMTP__playlist__struct.html#aaa520f5654349df19e4be8cf6f96a6f7">tracks</a>[i]);
      <span class="keywordflow">if</span> (track != NULL) {
        printf(<span class="stringliteral">&quot;   %u: %s - %s\n&quot;</span>, pl-&gt;<a class="code" href="structLIBMTP__playlist__struct.html#aaa520f5654349df19e4be8cf6f96a6f7">tracks</a>[i], track-&gt;<a name="a6"></a><a class="code" href="structLIBMTP__track__struct.html#ae0706099f555fa7a36d55f7d7afce45b">artist</a>, track-&gt;<a name="a7"></a><a class="code" href="structLIBMTP__track__struct.html#a08f9a52cac093232f14543bbd87d586d">title</a>);
        <a name="a8"></a><a class="code" href="group__tracks.html#gafeb0d51f0d25ef2389b786f8d319e88f">LIBMTP_destroy_track_t</a>(track);
      } <span class="keywordflow">else</span> {
        printf(<span class="stringliteral">&quot;   %u: INVALID TRACK REFERENCE!\n&quot;</span>, pl-&gt;<a class="code" href="structLIBMTP__playlist__struct.html#aaa520f5654349df19e4be8cf6f96a6f7">tracks</a>[i]);
        <a name="a9"></a><a class="code" href="group__basic.html#ga682c81a83fa04b2caf5c962db1eaff82">LIBMTP_Dump_Errorstack</a>(device);
        <a name="a10"></a><a class="code" href="group__basic.html#ga6c05b927310ac830c149ae3eeae94047">LIBMTP_Clear_Errorstack</a>(device);
      }
    }
  }
  <span class="keywordflow">return</span> 0;
}

<span class="keywordtype">int</span> main (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
{
  <a class="code" href="structLIBMTP__mtpdevice__struct.html">LIBMTP_mtpdevice_t</a> *device;
  <a class="code" href="structLIBMTP__playlist__struct.html">LIBMTP_playlist_t</a> *playlist;
  uint32_t id;
  <span class="keywordtype">char</span> *endptr;

  fprintf(stdout, <span class="stringliteral">&quot;libmtp version: &quot;</span> LIBMTP_VERSION_STRING <span class="stringliteral">&quot;\n\n&quot;</span>);

  <span class="comment">// We need file ID</span>
  <span class="keywordflow">if</span> ( argc != 2 ) {
    fprintf(stderr, <span class="stringliteral">&quot;Just a playlist ID is required\n&quot;</span>);
    <span class="keywordflow">return</span> 1;
  }

  <span class="comment">// Sanity check playlist ID</span>
  <span class="keywordtype">id</span> = strtoul(argv[1], &amp;endptr, 10);
  <span class="keywordflow">if</span> ( *endptr != 0 ) {
    fprintf(stderr, <span class="stringliteral">&quot;illegal value %s\n&quot;</span>, argv[1]);
    <span class="keywordflow">return</span> 1;
  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( ! <span class="keywordtype">id</span> ) {
    fprintf(stderr, <span class="stringliteral">&quot;bad playlist id %u\n&quot;</span>, <span class="keywordtype">id</span>);
    <span class="keywordflow">return</span> 1;
 }

  <a name="a11"></a><a class="code" href="group__internals.html#gaaca880ea9ab434e8cf1a1051128318ef">LIBMTP_Init</a>();
  device = <a name="a12"></a><a class="code" href="group__basic.html#gacd19150fce8688a56746c5b4e57be3ff">LIBMTP_Get_First_Device</a>();
  <span class="keywordflow">if</span> (device == NULL) {
    printf(<span class="stringliteral">&quot;No devices. Connect/replug device and try again.\n&quot;</span>);
    exit (0);
  }

  playlist = <a name="a13"></a><a class="code" href="group__playlists.html#ga463909ddaa9e0e26055aa21f4d895598">LIBMTP_Get_Playlist</a>(device,<span class="keywordtype">id</span>);  

  <span class="keywordflow">if</span> (playlist != NULL) {
    dump_playlist(device,playlist);
  }

  <a name="a14"></a><a class="code" href="group__playlists.html#ga8d6ce37c43c3cbbac49de849d8aafe77">LIBMTP_destroy_playlist_t</a>(playlist);
  
  <a name="a15"></a><a class="code" href="group__basic.html#ga55377eb5a8ff6ce2b1a557356fe12039">LIBMTP_Release_Device</a>(device);
  printf(<span class="stringliteral">&quot;OK.\n&quot;</span>);
  exit (0);
}

</pre></div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2 </small></address>
</body>
</html>