Sophie

Sophie

distrib > Mageia > 6 > x86_64 > media > core-updates > by-pkgid > e6ecaac536a8aa0be6d711d3b7a26b69 > files > 28

libmtp-doc-1.1.16-1.1.mga6.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"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libmtp: getfile.c</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libmtp
   &#160;<span id="projectnumber">1.1.16</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',false,false,'search.php','Search');
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">getfile.c</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;stdlib.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;limits.h&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;common.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;pathutils.h&quot;</span></div><div class="line"><span class="preprocessor">#include &quot;connect.h&quot;</span></div><div class="line"></div><div class="line"><span class="keyword">extern</span> <a name="_a0"></a><a class="code" href="structLIBMTP__folder__struct.html">LIBMTP_folder_t</a> *folders;</div><div class="line"><span class="keyword">extern</span> <a name="_a1"></a><a class="code" href="structLIBMTP__file__struct.html">LIBMTP_file_t</a> *files;</div><div class="line"><span class="keyword">extern</span> <a name="_a2"></a><a class="code" href="structLIBMTP__mtpdevice__struct.html">LIBMTP_mtpdevice_t</a> *device;</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> getfile_usage (<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  fprintf(stderr, <span class="stringliteral">&quot;getfile &lt;fileid/trackid&gt; &lt;filename&gt;\n&quot;</span>);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">int</span></div><div class="line">getfile_function(<span class="keywordtype">char</span> * from_path,<span class="keywordtype">char</span> * to_path)</div><div class="line">{</div><div class="line">  <span class="keywordtype">int</span> <span class="keywordtype">id</span> = parse_path (from_path,files,folders);</div><div class="line">  <span class="keywordflow">if</span> (<span class="keywordtype">id</span> &gt; 0) {</div><div class="line">    printf(<span class="stringliteral">&quot;Getting %s to %s\n&quot;</span>,from_path,to_path);</div><div class="line">    <span class="keywordflow">if</span> (<a name="a3"></a><a class="code" href="group__files.html#ga7c7d210d89a8ce35220914346db56e1b">LIBMTP_Get_File_To_File</a>(device, <span class="keywordtype">id</span>, to_path, progress, NULL) != 0 ) {</div><div class="line">      printf(<span class="stringliteral">&quot;\nError getting file from MTP device.\n&quot;</span>);</div><div class="line">      <a name="a4"></a><a class="code" href="group__basic.html#ga682c81a83fa04b2caf5c962db1eaff82">LIBMTP_Dump_Errorstack</a>(device);</div><div class="line">      <a name="a5"></a><a class="code" href="group__basic.html#ga6c05b927310ac830c149ae3eeae94047">LIBMTP_Clear_Errorstack</a>(device);</div><div class="line">      <span class="keywordflow">return</span> 1;</div><div class="line">    }</div><div class="line">  }</div><div class="line">  <span class="keywordflow">return</span> 0;</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> getfile_command(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)</div><div class="line">{</div><div class="line">  uint32_t id;</div><div class="line">  <span class="keywordtype">char</span> *endptr;</div><div class="line">  <span class="keywordtype">char</span> *file;</div><div class="line">  <span class="keywordtype">int</span> ret = 0;</div><div class="line"></div><div class="line">  <span class="comment">// We need file ID and filename</span></div><div class="line">  <span class="keywordflow">if</span> ( argc != 3 ) {</div><div class="line">    getfile_usage();</div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">// Sanity check song ID</span></div><div class="line">  <span class="keywordtype">id</span> = strtoul(argv[1], &amp;endptr, 10);</div><div class="line">  <span class="keywordflow">if</span> ( *endptr != 0 ) {</div><div class="line">    fprintf(stderr, <span class="stringliteral">&quot;illegal value %s\n&quot;</span>, argv[1]);</div><div class="line">    <span class="keywordflow">return</span> 1;</div><div class="line">  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( ! <span class="keywordtype">id</span> ) {</div><div class="line">    fprintf(stderr, <span class="stringliteral">&quot;bad file/track id %u\n&quot;</span>, <span class="keywordtype">id</span>);</div><div class="line">    <span class="keywordflow">return</span> 1;</div><div class="line"> }</div><div class="line"></div><div class="line">  <span class="comment">// Filename, e.g. &quot;foo.mp3&quot;</span></div><div class="line">  file = argv[2];</div><div class="line">  printf(<span class="stringliteral">&quot;Getting file/track %d to local file %s\n&quot;</span>, <span class="keywordtype">id</span>, file);</div><div class="line"></div><div class="line">  <span class="comment">// This function will also work just as well for tracks.</span></div><div class="line">  <span class="keywordflow">if</span> (<a class="code" href="group__files.html#ga7c7d210d89a8ce35220914346db56e1b">LIBMTP_Get_File_To_File</a>(device, <span class="keywordtype">id</span>, file, progress, NULL) != 0 ) {</div><div class="line">    printf(<span class="stringliteral">&quot;\nError getting file from MTP device.\n&quot;</span>);</div><div class="line">    ret = 1;</div><div class="line">  }</div><div class="line">  <span class="comment">// Terminate progress bar.</span></div><div class="line">  printf(<span class="stringliteral">&quot;\n&quot;</span>);</div><div class="line"></div><div class="line">  <span class="keywordflow">return</span> ret;</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>