<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>underdog-blog &#187; streaming editor</title>
	<atom:link href="http://blog.underdog-projects.net/tag/streaming-editor/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.underdog-projects.net</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 23 Oct 2010 18:43:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Streaming editor improved</title>
		<link>http://blog.underdog-projects.net/2009/01/streaming-editor-improved/</link>
		<comments>http://blog.underdog-projects.net/2009/01/streaming-editor-improved/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 13:51:03 +0000</pubDate>
		<dc:creator>jens</dc:creator>
				<category><![CDATA[yahoo finance]]></category>
		<category><![CDATA[filter html tags]]></category>
		<category><![CDATA[filter stream]]></category>
		<category><![CDATA[streaming editor]]></category>

		<guid isPermaLink="false">http://blog.underdog-projects.net/?p=56</guid>
		<description><![CDATA[I recently ran into the situation that I needed a streaming editor which does not work line-wise. I was receiving an html stream and wanted to remove all the html tags. Although I tried different existing editors like sed or replace, non of it got it right for me. All implementations waited for a newline [...]]]></description>
			<content:encoded><![CDATA[<p>I recently ran into the situation that I needed a streaming editor which does not work line-wise. I was receiving an html stream and wanted to remove all the html tags.</p>
<p>Although I tried different existing editors like sed or replace, non of it got it right for me. All implementations waited for a newline to work with the data. I also tried disabling every possible buffer but the problem still persists.</p>
<p>So after quite some trial and error I started writing my own little program which could do the job. So here is the code:</p>
<pre class="prettyprint lang-c">#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

int main (int argc, char* argv[])
{
  setbuf(stdin,NULL);
  char c;
  int tag =0;
  do {
    c = getchar();
    if (c == '&lt;' &amp;&amp; tag==0) ++tag;
    if (c == '&gt;' &amp;&amp; tag&gt;0) {--tag; c='\n';}
    if (tag ==0 ){
      putchar(c);
      fflush(stdout);
    }
  } while (c != EOF);
  return 0;
}</pre>
<p>Just compile it with the following statement and it will filter everything which comes from stdin.</p>
<pre class="prettyprint lang-sh">gcc -fPIC -Wall -otransform transform.c</pre>
<p>Here is a sample statement of how to use it:</p>
<pre class="prettyprint lang-sh">curl -N -s google.com | ./transform</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.underdog-projects.net/2009/01/streaming-editor-improved/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

