Sophie

Sophie

distrib > Mandriva > current > x86_64 > by-pkgid > d76e9d0335eb50de9ef01195761a76f9 > files > 94

lib64kate-devel-0.3.7-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>libkate: high.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.1 -->
<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>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>high.c</h1><div class="fragment"><pre class="fragment"><span class="comment">/*</span>
<span class="comment">  This shows how to use the high level decoding API to easily decode</span>
<span class="comment">  a Kate stream.</span>
<span class="comment">  For clarity, error checking is omitted.</span>
<span class="comment">  For simplicity, the input is assumed to be a single Kate stream.</span>
<span class="comment">  Usually, Kate streams will be multiplexed with other streams (either</span>
<span class="comment">  other Kate streams, or audio, or video). In these cases, the Ogg</span>
<span class="comment">  part will have to be more complex, but the Kate specific code will</span>
<span class="comment">  be the same.</span>
<span class="comment">  */</span>

<span class="preprocessor">#include &lt;stdio.h&gt;</span>
<span class="preprocessor">#include &lt;string.h&gt;</span>
<span class="preprocessor">#include &lt;ogg/ogg.h&gt;</span>
<span class="preprocessor">#include &quot;common.h&quot;</span>

<span class="comment">/* All the libkate API is available from the main kate header file: */</span>

<span class="preprocessor">#include &lt;<a class="code" href="kate_8h.html">kate/kate.h</a>&gt;</span>

<span class="keywordtype">int</span> main()
{
  ogg_sync_state oy;
  ogg_stream_state os;
  <span class="keywordtype">int</span> init=0;
  ogg_packet op;
  <a name="_a0"></a><a class="code" href="structkate__state.html">kate_state</a> k;
  <span class="keyword">const</span> <a name="_a1"></a><a class="code" href="structkate__event.html">kate_event</a> *ev;
  <a name="_a2"></a><a class="code" href="structkate__packet.html">kate_packet</a> kp;

  <span class="comment">/* for the benefit of windows, which mangles data otherwise */</span>
  set_binary_file(stdin);

  <span class="comment">/* we initialize ogg and the kate state  */</span>
  ogg_sync_init(&amp;oy);
  <span class="keywordtype">int</span> ret=<a name="a3"></a><a class="code" href="group__high.html#ga810984fb4ec910632c250672d39feee4">kate_high_decode_init</a>(&amp;k);

  <span class="comment">/*</span>
<span class="comment">    We then read packets and feed them to the libkate high level API. When</span>
<span class="comment">    kate_high_decode_packetin returns a positive number, this signals the</span>
<span class="comment">    end of the stream.</span>
<span class="comment">    */</span>
  <span class="keywordflow">while</span> (1) {
    <span class="keywordflow">if</span> (get_packet(&amp;oy,&amp;os,&amp;init,&amp;op)) <span class="keywordflow">break</span>;
    <a name="a4"></a><a class="code" href="group__packet.html#ga7c0c2af28df8ea89f5f62e830dc916b1">kate_packet_wrap</a>(&amp;kp,op.bytes,op.packet);
    <span class="keywordflow">if</span> (<a name="a5"></a><a class="code" href="group__high.html#ga4c9bac57e090c34e778b6f080cd4df82">kate_high_decode_packetin</a>(&amp;k,&amp;kp,&amp;ev)&gt;0) <span class="keywordflow">break</span>;
    <span class="comment">/* if the event is non NULL, we have an event */</span>
    <span class="keywordflow">if</span> (ev) {
      printf(<span class="stringliteral">&quot;Kate stream has text: %s\n&quot;</span>,ev-&gt;<a name="a6"></a><a class="code" href="structkate__event.html#ae10745a5078521816cc07a09654fbfd4">text</a>);
    }
  }

  <span class="comment">/* That&apos;s it, we can now cleanup */</span>
  ogg_stream_clear(&amp;os);
  ogg_sync_clear(&amp;oy);

  <a name="a7"></a><a class="code" href="group__high.html#ga8faebcd4839fb5a2bced259f8560f47f">kate_high_decode_clear</a>(&amp;k);

  <span class="keywordflow">return</span> 0;
}

</pre></div> </div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Wed Dec 23 04:05:07 2009 for libkate by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>