<?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>Marius van Witzenburg &#187; C</title>
	<atom:link href="http://mariusvw.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://mariusvw.com</link>
	<description>We fight for our survival, we fight!</description>
	<lastBuildDate>Tue, 27 Dec 2011 10:35:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to add Base64 encoding and decoding in C</title>
		<link>http://mariusvw.com/2011/07/17/how-to-add-base64-encoding-and-decoding-in-c/</link>
		<comments>http://mariusvw.com/2011/07/17/how-to-add-base64-encoding-and-decoding-in-c/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 09:36:53 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Base64]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Decoding]]></category>
		<category><![CDATA[Encoding]]></category>
		<category><![CDATA[Mail]]></category>

		<guid isPermaLink="false">http://kitara.nl/?p=5948</guid>
		<description><![CDATA[I found this page on the web while searching for something else but I thought this might be useful to others Overview libb64 is a library of ANSI C routines for fast encoding/decoding data into and from a base64-encoded format. C++ wrappers are included, as well as the source code for standalone encoding and decoding [...]]]></description>
			<content:encoded><![CDATA[<p>I found this page on the web while searching for something else but I thought this might be useful to others <img src='http://mariusvw.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Overview</strong><br />
<a href="http://sourceforge.net/projects/libb64/">libb64</a> is a library of ANSI C routines for fast encoding/decoding data into and from a <a href="http://en.wikipedia.org/wiki/Base64">base64</a>-encoded format. C++ wrappers are included, as well as the source code for standalone encoding and decoding executables.</p>
<p>Base64 uses a subset of displayable ASCII characters, and is therefore a useful encoding for storing binary data in a text file, such as XML, or sending binary data over text-only email.</p>
<p><strong>Usage</strong></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;b64/encode.h&gt;</span>
<span style="color: #339933;">#include &lt;iostream&gt;</span>
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	base64<span style="color: #339933;">::</span><span style="color: #202020;">encoder</span> E<span style="color: #339933;">;</span>
	E.<span style="color: #202020;">encode</span><span style="color: #009900;">&#40;</span>std<span style="color: #339933;">::</span><span style="color: #202020;">cin</span><span style="color: #339933;">,</span> std<span style="color: #339933;">::</span><span style="color: #000066;">cout</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You can read more info and download the package on the url below:</p>
<p><a href="http://libb64.sourceforge.net/">http://libb64.sourceforge.net/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mariusvw.com/2011/07/17/how-to-add-base64-encoding-and-decoding-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shellproxy, an easy tool to run shell commands from PHP or other languages</title>
		<link>http://mariusvw.com/2010/03/02/shellproxy-an-easy-tool-to-run-shell-commands-from-php-or-other-languages/</link>
		<comments>http://mariusvw.com/2010/03/02/shellproxy-an-easy-tool-to-run-shell-commands-from-php-or-other-languages/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 19:53:02 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Command]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Return]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Value]]></category>

		<guid isPermaLink="false">http://mariusvw.com/?p=1302</guid>
		<description><![CDATA[This is a simple script that runs a shell command from PHP with the function system(). It sometimes happens that a command doesn't close the stdin or stdout, resulting the system() function to halt and wait for it to finish... This causes PHP to reach the 30 second time limit and kill the script. This [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple script that runs a shell command from PHP with the function <strong>system()</strong>.<br />
It sometimes happens that a command doesn't close the <strong>stdin</strong> or <strong>stdout</strong>, resulting the <strong>system()</strong> function to halt and wait for it to finish...<br />
This causes PHP to reach the 30 second time limit and kill the script.</p>
<p>This script runs it in the background and you could make your commands send their output to a log file and still having full control.</p>
<p>Read the code below how to use it.</p>
<p>You can compile it by placing the code into <strong>shellproxy.c</strong> and then compile it with the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #660033;">-o</span> shellproxy shellproxy.c</pre></div></div>

<p>I hope this is something useful for you as it was for me.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio .h&gt;</span>
<span style="color: #339933;">#include &lt;stdlib .h&gt;</span>
<span style="color: #339933;">#include &lt;string .h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">char</span> command<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1024</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">int</span> t<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>argc <span style="color: #339933;">==</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;nShell Proxyn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;By Marius van Witzenburg &lt;http ://kitara.nl&gt;nn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;You will mostly use this program from PHP or any othern&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;webscripting language to background run programsnn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Usage:n&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;- CLI:n&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;shellproxy &quot;</span><span style="color: #339933;">&lt;</span>cmd<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>arg<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;n&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;shellproxy &quot;</span><span style="color: #339933;">&lt;</span>cmd<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>arg<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&gt;</span> redirect.<span style="color: #202020;">txt</span><span style="color: #ff0000;">&quot;n&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;- PHP:n&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;system('shellproxy &quot;</span><span style="color: #339933;">&lt;</span>cmd<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>arg<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&amp;</span><span style="color: #ff0000;">&quot;');n&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;system('shellproxy &quot;</span><span style="color: #339933;">&lt;</span>cmd<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>arg<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&gt;</span> redirect.<span style="color: #202020;">txt</span><span style="color: #ff0000;">&quot;');nn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    command<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>t <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> t <span style="color: #339933;">&lt;</span> argc<span style="color: #339933;">;</span> t<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        strcat<span style="color: #009900;">&#40;</span>command<span style="color: #339933;">,</span> argv<span style="color: #009900;">&#91;</span>t<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        strcat<span style="color: #009900;">&#40;</span>command<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    fclose<span style="color: #009900;">&#40;</span>stdin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    fclose<span style="color: #009900;">&#40;</span>stdout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    fclose<span style="color: #009900;">&#40;</span>stderr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    system<span style="color: #009900;">&#40;</span>command<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It would be nice if you keep my name mentioned into this code if you use it.</p>
<p>Ps. Donations are welcome... <img src='http://mariusvw.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://mariusvw.com/2010/03/02/shellproxy-an-easy-tool-to-run-shell-commands-from-php-or-other-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

