<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Dump environment of a C program</title>
	<atom:link href="http://jeremy.visser.name/2009/10/29/dump-environment-of-a-c-program/feed/" rel="self" type="application/rss+xml" />
	<link>https://jeremy.visser.name/2009/10/29/dump-environment-of-a-c-program/</link>
	<description></description>
	<lastBuildDate>Sun, 05 Sep 2010 12:55:22 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Jeremy</title>
		<link>https://jeremy.visser.name/2009/10/29/dump-environment-of-a-c-program/comment-page-1/#comment-4684</link>
		<dc:creator>Jeremy</dc:creator>
		<pubDate>Thu, 29 Oct 2009 09:35:06 +0000</pubDate>
		<guid isPermaLink="false">http://jeremy.visser.name/?p=1308#comment-4684</guid>
		<description>Cheers. :)</description>
		<content:encoded><![CDATA[<p>Cheers. <img src='https://jeremy.visser.name/wordpress/wp-content/plugins/tango-smilies/tango/face-smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Ferlito</title>
		<link>https://jeremy.visser.name/2009/10/29/dump-environment-of-a-c-program/comment-page-1/#comment-4683</link>
		<dc:creator>John Ferlito</dc:creator>
		<pubDate>Thu, 29 Oct 2009 09:15:27 +0000</pubDate>
		<guid isPermaLink="false">http://jeremy.visser.name/?p=1308#comment-4683</guid>
		<description>You can also do

&lt;pre lang=&quot;C&quot;&gt;#include &lt;stdio.h&gt;

int main (int argc, char *argv[], char *envp[]) {
    int e = 0;

    while (envp[e] != NULL) {
        printf(&quot;%s\r\n&quot;, envp[e]);
        e++;
    }

    return 0;
}&lt;/pre&gt;

which I think looks nicer than introducing a magic variable onto your stack :)</description>
		<content:encoded><![CDATA[<p>You can also do</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>
&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: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>envp<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;">int</span> e <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>envp<span style="color: #009900;">&#91;</span>e<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> NULL<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;%s<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> envp<span style="color: #009900;">&#91;</span>e<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        e<span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <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>which I think looks nicer than introducing a magic variable onto your stack <img src='https://jeremy.visser.name/wordpress/wp-content/plugins/tango-smilies/tango/face-smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy</title>
		<link>https://jeremy.visser.name/2009/10/29/dump-environment-of-a-c-program/comment-page-1/#comment-4682</link>
		<dc:creator>Jeremy</dc:creator>
		<pubDate>Thu, 29 Oct 2009 08:59:31 +0000</pubDate>
		<guid isPermaLink="false">http://jeremy.visser.name/?p=1308#comment-4682</guid>
		<description>Uh heh heh. Actually my specific need was to write it out through syslog, and I couldn&#039;t be bothered figuring out how to connect the stdout of &lt;code&gt;env&lt;/code&gt; to some &lt;code&gt;/dev/log&lt;/code&gt; file handle. Not that I didn&#039;t have &lt;code&gt;env&lt;/code&gt; available.

(I can do it in Python with &lt;a href=&quot;http://docs.python.org/library/subprocess.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;subprocess&lt;/code&gt;&lt;/a&gt;, but no idea with normal POSIX stuff.)

Key words here: &lt;em&gt;quick &#039;n dirty&lt;/em&gt;. :)</description>
		<content:encoded><![CDATA[<p>Uh heh heh. Actually my specific need was to write it out through syslog, and I couldn&#8217;t be bothered figuring out how to connect the stdout of <code>env</code> to some <code>/dev/log</code> file handle. Not that I didn&#8217;t have <code>env</code> available.</p>
<p>(I can do it in Python with <a href="http://docs.python.org/library/subprocess.html" rel="nofollow"><code>subprocess</code></a>, but no idea with normal POSIX stuff.)</p>
<p>Key words here: <em>quick &#8216;n dirty</em>. <img src='https://jeremy.visser.name/wordpress/wp-content/plugins/tango-smilies/tango/face-smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TimC</title>
		<link>https://jeremy.visser.name/2009/10/29/dump-environment-of-a-c-program/comment-page-1/#comment-4681</link>
		<dc:creator>TimC</dc:creator>
		<pubDate>Thu, 29 Oct 2009 07:45:10 +0000</pubDate>
		<guid isPermaLink="false">http://jeremy.visser.name/?p=1308#comment-4681</guid>
		<description>How often don&#039;t you have env, but you do have gcc and its libraries?</description>
		<content:encoded><![CDATA[<p>How often don&#8217;t you have env, but you do have gcc and its libraries?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
