<?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>No Znx!</title>
	<atom:link href="http://znx.no/feed/" rel="self" type="application/rss+xml" />
	<link>http://znx.no</link>
	<description>the pigeons!!!!</description>
	<lastBuildDate>Mon, 22 Feb 2010 01:29:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Unrar Bug</title>
		<link>http://znx.no/2010/02/unrar-bu/</link>
		<comments>http://znx.no/2010/02/unrar-bu/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 01:29:50 +0000</pubDate>
		<dc:creator>znx</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[rpm]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://znx.no/?p=274</guid>
		<description><![CDATA[So I was recently scripting with the unrar tool and discovered something stupid:

unrar t file.rar
if &#91; $? -eq 0 &#93;; then
  echo &#34;Rar file is good?&#34;
fi

However it was returning zero all the time, even when the file wasn&#8217;t a rar:

# unrar t file.rar
&#160;
UNRAR 3.80 freeware      Copyright &#40;c&#41; 1993-2008 Alexander [...]]]></description>
			<content:encoded><![CDATA[<p>So I was recently scripting with the unrar tool and discovered something stupid:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">unrar t file.rar
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Rar file is good?&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>However it was returning zero all the time, even when the file wasn&#8217;t a rar:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># unrar t file.rar</span>
&nbsp;
UNRAR <span style="color: #000000;">3.80</span> freeware      Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">1993</span>-<span style="color: #000000;">2008</span> Alexander Roshal
&nbsp;
file.rar is not RAR archive
<span style="color: #666666; font-style: italic;"># echo $?</span>
<span style="color: #000000;">0</span></pre></div></div>

<p>So it fails the test but returns zero regardless. This makes it very unhelpful for using in scripting. Fortunately enough a mate on IRC discovered that his version did.</p>
<p>So I first download the existing SRPM and installed it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yumdownloader --source unrar</span>
<span style="color: #666666; font-style: italic;"># rpm -i unrar*.srpm</span></pre></div></div>

<p>Then I installed that and simply modified  so I downloaded the latest, created a RPM and installed.</p>
<p>I have submitted the updated spec file to <a href='https://bugzilla.rpmfusion.org/show_bug.cgi?id=1091'>RPMfusion</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://znx.no/2010/02/unrar-bu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPA2 Wireless With Linux</title>
		<link>http://znx.no/2010/02/wpa2-wireless-with-linux/</link>
		<comments>http://znx.no/2010/02/wpa2-wireless-with-linux/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 18:02:57 +0000</pubDate>
		<dc:creator>znx</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[gentoo]]></category>

		<guid isPermaLink="false">http://znx.no/?p=106</guid>
		<description><![CDATA[This is a simple tutorial produced by me and my good mate enigma. It is aimed at Gentoo and uses the Broadcom drivers but this should replicate to other systems.
The first step is to get your drivers and for Broadcom, which is relatively easy as they produce them for us. So first download the driver [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple tutorial produced by me and my good mate <a href="http://www.gentoo-fun.com/">enigma</a>. It is aimed at Gentoo and uses the Broadcom drivers but this should replicate to other systems.</p>
<p>The first step is to get your drivers and for Broadcom, which is relatively easy as they produce them for us. So first <a href="http://www.broadcom.com/support/802.11/linux_sta.php">download</a> the driver (these drivers support BM4311-, BCM4312-, BCM4321-, and BCM4322-based cards) and was also successful in this case with BCM4328.</p>
<p>Check that the package &#8216;linux-headers&#8217; is installed, this is really just for completeness sakes. Gentoo would not work for long without this package!</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#40;</span>gentoo<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #666666; font-style: italic;"># emerge linux-headers</span>
... output ...</pre></div></div>

<p>Unpack the downloaded drivers and build for your current kernel:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#40;</span>gentoo<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #666666; font-style: italic;"># tar -xzf hybrid-portsrc-ARCH-VERSION.tar.gz</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span>gentoo<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #666666; font-style: italic;"># make -C /lib/modules/`uname -r`/build M=`pwd`</span>
... output ...</pre></div></div>

<p>Remove any existing wireless drivers.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#40;</span>gentoo<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #666666; font-style: italic;"># rmmod ndiswrapper b43 ssb bcm43xx b43legacy</span></pre></div></div>

<p>Add in some modules required for WPA wireless:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#40;</span>gentoo<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #666666; font-style: italic;"># modprobe ieee80211_crypt_tkip</span></pre></div></div>

<p>Test the newly built wireless driver:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#40;</span>gentoo<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #666666; font-style: italic;"># insmod wl.ko</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span>gentoo<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #666666; font-style: italic;"># iwconfig</span>
.. output ...
<span style="color: #7a0874; font-weight: bold;">&#40;</span>gentoo<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #666666; font-style: italic;"># iwlist scanning</span>
... output ...</pre></div></div>

<p>If that is working we can copy in the driver to the kernel and add to the autoload:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#40;</span>gentoo<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #666666; font-style: italic;"># cp wl.ko /lib/modules/`uname-r`/kernel/net/wireless/</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span>gentoo<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #666666; font-style: italic;"># rmmod wl</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span>gentoo<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #666666; font-style: italic;"># modprobe wl</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span>gentoo<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #666666; font-style: italic;"># echo 'wl' &gt;&gt;/etc/modules.autoload.d/kernel-2.6</span></pre></div></div>

<p>So now we have a working driver we can go on to configure for WPA. Alter the <i>/etc/conf.d/net</i> (note we assume that eth0 is wireless):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Prefer wpa_supplicant over wireless-tools</span>
<span style="color: #007800;">modules</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #ff0000;">&quot;wpa_supplicant&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># It's important that we tell wpa_supplicant which driver we should</span>
<span style="color: #666666; font-style: italic;"># be using as it's not very good at guessing yet</span>
<span style="color: #007800;">wpa_supplicant_eth0</span>=<span style="color: #ff0000;">&quot;-Dmadwifi&quot;</span></pre></div></div>

<p>Next set up the network in the <i>/etc/wpa_supplicant/wpa_supplicant.conf</i>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># This setting is required or the connection will not work</span>
<span style="color: #007800;">ctrl_interface</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>wpa_supplicant
&nbsp;
<span style="color: #666666; font-style: italic;"># Ensure that only root can read the WPA configuration</span>
<span style="color: #007800;">ctrl_interface_group</span>=<span style="color: #000000;">0</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Let wpa_supplicant take care of scanning and AP selection</span>
<span style="color: #007800;">ap_scan</span>=<span style="color: #000000;">1</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Only WPA-PSK is used. Any valid cipher combination is accepted</span>
<span style="color: #007800;">network</span>=<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #007800;">ssid</span>=<span style="color: #ff0000;">&quot;example&quot;</span>
  <span style="color: #007800;">proto</span>=WPA RSN   <span style="color: #666666; font-style: italic;"># RSN is needed for WPA2</span>
  <span style="color: #007800;">key_mgmt</span>=WPA-PSK
  <span style="color: #007800;">pairwise</span>=CCMP TKIP
  <span style="color: #007800;">group</span>=CCMP TKIP WEP104 WEP40
  <span style="color: #007800;">psk</span>=06b4be19da289f475aa46a33cb793029d4ab3db7a23ee92382eb0106c72ac7bb
  <span style="color: #666666; font-style: italic;">#The higher the priority the faster it connects</span>
  <span style="color: #007800;">priority</span>=<span style="color: #000000;">2</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>And that is it, you should find that your wireless is enabled on boot.</p>
<p>Thanks should also go to <a href="http://djkaos.wordpress.com/2008/10/25/installing-broadcom-80211-linux-sta-driver/">DJ Kaos</a> for the preparation of the driver.</p>
]]></content:encoded>
			<wfw:commentRss>http://znx.no/2010/02/wpa2-wireless-with-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bit Flags</title>
		<link>http://znx.no/2010/02/bit-flag/</link>
		<comments>http://znx.no/2010/02/bit-flag/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 23:20:15 +0000</pubDate>
		<dc:creator>znx</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://znx.no/?p=253</guid>
		<description><![CDATA[I was further discussing C ideas and this time we came across bit flags (also called bit fields). The idea behind them is conservation of memory, a boolean data type consumes 1 byte of memory but all that is really needed is a single bit. Therefore you can store several booleans in a single byte.
Here [...]]]></description>
			<content:encoded><![CDATA[<p>I was further discussing C ideas and this time we came across bit flags (also called bit fields). The idea behind them is conservation of memory, a boolean data type consumes 1 byte of memory but all that is really needed is a single bit. Therefore you can store several booleans in a single byte.</p>
<p>Here is a simple example, note that each has a specific value to ensure that each matches a single bit in the 8-bit variable:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">enum</span> options <span style="color: #009900;">&#123;</span>
  option_a <span style="color: #339933;">=</span> <span style="color: #208080;">0x01</span><span style="color: #339933;">,</span>  <span style="color: #808080; font-style: italic;">/*   1 == 00000001 */</span>
  option_b <span style="color: #339933;">=</span> <span style="color: #208080;">0x02</span><span style="color: #339933;">,</span>  <span style="color: #808080; font-style: italic;">/*   2 == 00000010 */</span>
  option_c <span style="color: #339933;">=</span> <span style="color: #208080;">0x04</span><span style="color: #339933;">,</span>  <span style="color: #808080; font-style: italic;">/*   4 == 00000100 */</span>
  option_d <span style="color: #339933;">=</span> <span style="color: #208080;">0x08</span><span style="color: #339933;">,</span>  <span style="color: #808080; font-style: italic;">/*   8 == 00001000 */</span>
  option_e <span style="color: #339933;">=</span> <span style="color: #208080;">0x10</span><span style="color: #339933;">,</span>  <span style="color: #808080; font-style: italic;">/*  16 == 00010000 */</span>
  option_f <span style="color: #339933;">=</span> <span style="color: #208080;">0x20</span><span style="color: #339933;">,</span>  <span style="color: #808080; font-style: italic;">/*  32 == 00100000 */</span>
  option_g <span style="color: #339933;">=</span> <span style="color: #208080;">0x40</span><span style="color: #339933;">,</span>  <span style="color: #808080; font-style: italic;">/*  64 == 01000000 */</span>
  option_h <span style="color: #339933;">=</span> <span style="color: #208080;">0x80</span><span style="color: #339933;">,</span>  <span style="color: #808080; font-style: italic;">/* 128 == 10000000 */</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>So basically we have 8 boolean flags (0 off/false, 1 on/true). We can use these by utilising bitwise operations. There is really only 3 operations that you will use regularly on bit flags so lets see them.</p>
<p>Switching individual/multiple options &#8220;on&#8221; (or setting value true):</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">options <span style="color: #339933;">|=</span> option_a<span style="color: #339933;">;</span>
<span style="color: #808080; font-style: italic;">/* Translates to:
  options = options | option_a;
  options = 00000000 | 00000001;
  options = 00000001;
*/</span>
&nbsp;
options <span style="color: #339933;">=</span> option_a <span style="color: #339933;">|</span> option_c <span style="color: #339933;">|</span> option_h<span style="color: #339933;">;</span>
<span style="color: #808080; font-style: italic;">/* Translates to:
  options = 00000001 | 00000100 | 10000000;
  options = 10000101;
*/</span></pre></div></div>

<p>Equally switching options &#8220;off&#8221; (or setting false) can be done as follows (note we are using the options from above, thus a, c and h are on):</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">options <span style="color: #339933;">&amp;=</span> ~option_a<span style="color: #339933;">;</span>
<span style="color: #808080; font-style: italic;">/* Translates to:
  options = options &amp; ~option_a;
  options = 10000101 &amp; ~00000001;
  options = 10000101 &amp; 11111110;
  options = 10000100;
*/</span></pre></div></div>

<p>Obviously you need a basic grasp of boolean mathematics to be able to handle this but learning the basics shouldn&#8217;t be too hard. Finally the last thing to do is check to see if a flag is &#8220;on&#8221; or &#8220;off&#8221; (again using the options from before, so c and h are &#8220;on&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> options <span style="color: #339933;">&amp;</span> option_b <span style="color: #009900;">&#41;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;B is ON<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #808080; font-style: italic;">/* 10000100 &amp; 00000010 = 00000000 .. i.e. false, so no output */</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> options <span style="color: #339933;">&amp;</span> option_c <span style="color: #009900;">&#41;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;C is ON<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #808080; font-style: italic;">/* 10000100 &amp; 00000100 = 00000100 .. i.e. true, so &quot;C is ON&quot; is outputting */</span></pre></div></div>

<p>As with most things in C, once you start using and abusing it should start to fall into place. I hope that this serves as a basic introduction to bit fields.</p>
]]></content:encoded>
			<wfw:commentRss>http://znx.no/2010/02/bit-flag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Variable Function Parameters</title>
		<link>http://znx.no/2010/02/variable-function-parameter/</link>
		<comments>http://znx.no/2010/02/variable-function-parameter/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 22:42:42 +0000</pubDate>
		<dc:creator>znx</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://znx.no/?p=238</guid>
		<description><![CDATA[With C++ there is ways of handling optional function parameters or overloading functions to handle different amounts of parameters, obviously within C these abilities do not exist. However if we wanted to handle a variable list of parameters then C and C++ would work the same.
Let&#8217;s see how we&#8217;d do that:

#include &#60;stdarg.h&#62;
#include &#60;stdio.h&#62;
&#160;
int Adding&#40;int cnt, [...]]]></description>
			<content:encoded><![CDATA[<p>With C++ there is ways of handling optional function parameters or overloading functions to handle different amounts of parameters, obviously within C these abilities do not exist. However if we wanted to handle a variable list of parameters then C and C++ would work the same.</p>
<p>Let&#8217;s see how we&#8217;d do that:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdarg.h&gt;</span>
<span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> Adding<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> cnt<span style="color: #339933;">,</span> ...<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  <span style="color: #808080; font-style: italic;">/* the three ... indicate a variable list */</span>
    <span style="color: #993333;">int</span> add<span style="color: #339933;">,</span> tmp<span style="color: #339933;">,</span> i<span style="color: #339933;">;</span>
    va_list args<span style="color: #339933;">;</span>            <span style="color: #808080; font-style: italic;">/* make a va_list */</span>
    va_start<span style="color: #009900;">&#40;</span>args<span style="color: #339933;">,</span> cnt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>     <span style="color: #808080; font-style: italic;">/* variable list starts after 'cnt' */</span>
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> cnt<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        tmp <span style="color: #339933;">=</span> va_arg<span style="color: #009900;">&#40;</span>args<span style="color: #339933;">,</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* grab the next */</span>
        add <span style="color: #339933;">=</span> add <span style="color: #339933;">+</span> tmp<span style="color: #339933;">;</span>         <span style="color: #808080; font-style: italic;">/* add to the sum */</span>
    <span style="color: #009900;">&#125;</span>
    va_end<span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #808080; font-style: italic;">/* finished using variable list */</span>
    <span style="color: #b1b100;">return</span> add<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<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>
    <span style="color: #993333;">int</span> a<span style="color: #339933;">;</span>
    a <span style="color: #339933;">=</span> Adding<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">2</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;%u<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>     <span style="color: #808080; font-style: italic;">/* Outputs 3 */</span>
    a <span style="color: #339933;">=</span> Adding<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">3</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">3</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;%u<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>     <span style="color: #808080; font-style: italic;">/* Outputs 6 */</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>So the first argument indicates how many variables we are going to pass and the rest are summed together. The function <code>Adding()</code> would be identical in C++.</p>
]]></content:encoded>
			<wfw:commentRss>http://znx.no/2010/02/variable-function-parameter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Import Missing GPG Keys</title>
		<link>http://znx.no/2010/01/import-missing-gpg-keys/</link>
		<comments>http://znx.no/2010/01/import-missing-gpg-keys/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 17:58:39 +0000</pubDate>
		<dc:creator>znx</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[gpg]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://znx.no/?p=231</guid>
		<description><![CDATA[Sometimes when people are using Linux they will find that they come across a simple security check that confirms the authenticity of the RPM/Deb files that they are installing. Every so often the key is missing but that is easy to remedy. Here I will use an example with the YUM install of Adobe Flash:
[root@marine]# [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes when people are using Linux they will find that they come across a simple security check that confirms the authenticity of the RPM/Deb files that they are installing. Every so often the key is missing but that is easy to remedy. Here I will use an example with the YUM install of Adobe Flash:</p>
<pre>[root@marine]# ls
adobe-release-i386-1.0-1.noarch.rpm
[root@marine]# yum localinstall adobe-release-i386-1.0-1.noarch.rpm
Loaded plugins: fastestmirror, priorities
Setting up Local Package Process
Examining adobe-release-i386-1.0-1.noarch.rpm: adobe-release-i386-1.0-1.noarch
Marking adobe-release-i386-1.0-1.noarch.rpm to be installed
Loading mirror speeds from cached hostfile
* addons: anorien.csc.warwick.ac.uk
* base: anorien.csc.warwick.ac.uk
* centosplus: anorien.csc.warwick.ac.uk
* contrib: anorien.csc.warwick.ac.uk
* extras: anorien.csc.warwick.ac.uk
* rpmforge: fr2.rpmfind.net
* updates: anorien.csc.warwick.ac.uk
588 packages excluded due to repository priority protections
Resolving Dependencies
--&gt; Running transaction check
---&gt; Package adobe-release-i386.noarch 0:1.0-1 set to be updated
--&gt; Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package              Arch     Version Repository                          Size
================================================================================
Installing:
adobe-release-i386   noarch   1.0-1   /adobe-release-i386-1.0-1.noarch   1.9 k

Transaction Summary
================================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total size: 1.9 k
Is this ok [y/N]: y
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID f6777c67

Public key for adobe-release-i386-1.0-1.noarch.rpm is not installed</pre>
<p>As you can see it attempted to install but because the key was missing it refused to install. So what do we do to find that key? First we must download the key from somewhere, there is various key servers around the world, some of the most popular are (note hkp is the HTTP keyserver protocol):</p>
<ul>
<li>hkp://subkeys.pgp.net</li>
<li>hkp://pgp.mit.edu</li>
<li>hkp://keys.gnupg.net</li>
<li>hkp://wwwkeys.uk.pgp.net  (where UK can be replaced by any country code)</li>
</ul>
<p>So lets search for the missing key:</p>
<pre>[root@marine]# gpg --keyserver hkp://wwwkeys.uk.pgp.net --recv-keys f6777c67
gpg: requesting key F6777C67 from hkp server wwwkeys.uk.pgp.net
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key F6777C67: public key "Adobe Systems Incorporated (Linux RPM
  Signing Key) <secure@adobe.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1</pre>
<p>So now we have the key and see that it is indeed Adobe&#8217;s key. Now all we need to do is add into RPM:</p>
<pre>[root@marine]# gpg --armor --export f6777c67 >tmp-gpg.key
[root@marine]# rpm --import tmp-gpg.key</pre>
<p>Simple as that, the install will work now!</p>
<p>This post is a refreshed look at a <a href='http://znx.no/2009/08/gpg-errors/'>previous</a> post on the same matter.</p>
]]></content:encoded>
			<wfw:commentRss>http://znx.no/2010/01/import-missing-gpg-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acer Aspire One Battery Issues</title>
		<link>http://znx.no/2009/12/acer-aspire-one-battery-issues/</link>
		<comments>http://znx.no/2009/12/acer-aspire-one-battery-issues/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 20:20:10 +0000</pubDate>
		<dc:creator>znx</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[aa1]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://znx.no/?p=227</guid>
		<description><![CDATA[A couple of days ago I opened up my AAO and discovered that it was out of charge. I plugged it in and started using it, then I spotted that the power indicator said the battery was full. I knew that couldn&#8217;t be right as it was only 5 minutes since I plugged it in.
I [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago I opened up my AAO and discovered that it was out of charge. I plugged it in and started using it, then I spotted that the power indicator said the battery was full. I knew that couldn&#8217;t be right as it was only 5 minutes since I plugged it in.</p>
<p>I stopped what I was doing and shutdown, then I removed the power and attempted to turn on again. Once more the machine wouldn&#8217;t turn on but I noted that the charging light wasn&#8217;t showing either.</p>
<p>A quick google and I discovered that I was not alone with this issue. It seems two types of AAO (the AOA100 and AOA150) can suffer from this problem. There is a fix and a workaround, the fix is obviously the better option. The workaround is to unplugged the battery from the device then power it up. After a moment, plug the battery back in and it should start charging, not ideal.</p>
<p>The fix is to download a BIOS update and patch it! Obviously you must insure that your AAO is the correct model before you attempt to flash the BIOS otherwise you might leave yourself with a very pretty brick. To ensure this you should find a label on the bottom of you device saying AOA150 or AOA100. Although my model indicated ZG5, a quick check on another label and I spotted AOA150.</p>
<p>The instructions on how to do this are available from <a href="http://netbooks-us.custhelp.com/app/answers/detail/a_id/133/session/L3NpZC83VFRuVGFRag%3D%3D/sno/0">Acer&#8217;s Support</a> website. I will reproduce here what I did:</p>
<ol>
<li>Turn on the netbook and enter the BIOS by pressing the button F2</li>
<li>Take note of the version number, this should change if the upgrade is successful.</li>
<li>Open a browser and go to the <a href="www.acer.com">Acer</a> website.</li>
<li>Browse through: Service &amp; Support &gt; Driver Download &gt; Netbook &gt; Aspire One &gt; AOA150 (or 100) &gt; BIOS</li>
<li>Donwload the file, it will be a zip.</li>
<li>Extract the zip and rename the file 3310.fd to be zg5ia32.fd.</li>
<li>Plug in a USB stick, and copy two files over, the zg5ia32.fd and FLASHIT.EXE</li>
<li>Make sure you have your netbook plugged in and powered on.</li>
<li>Power down the netbook</li>
<li>Press and hold down the Fn and Esc keys and then press the power button</li>
<li>When the power light comes on, wait a couple of seconds and then let go of the buttons</li>
<li>It will look like very little is happening, the screen stays blank, but you should see your USB light blinking.</li>
<li>After a while (it took around 2 minutes for me) the netbook will reboot itself and power on.</li>
</ol>
<p>After this I powered up the device and spotted that the same thing was occurring. I rebooted and did the same process again. This time I entered the BIOS and spotted that the version number had changed.</p>
<p>So once it was back up, I waited a few minutes and spotted that the power indicator said it was charging the battery, success! Whilst I would normally not advise this sort of process for the average user, Acer had made it relatively simple and I feel some what foolproof.</p>
<p>Obviously if it doesn&#8217;t work for you then the next step would be to try the workaround or maybe go ahead and contact Acer if your warranty is still valid.</p>
<p>Oh and Happy Christmas to all <img src='http://znx.no/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> !</p>
]]></content:encoded>
			<wfw:commentRss>http://znx.no/2009/12/acer-aspire-one-battery-issues/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Updates</title>
		<link>http://znx.no/2009/11/updates/</link>
		<comments>http://znx.no/2009/11/updates/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 20:23:49 +0000</pubDate>
		<dc:creator>znx</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://znx.no/?p=201</guid>
		<description><![CDATA[So it has been a while since I posted last and I felt like updating and cleaning stuff up. The tags and categories have been improved and reduced to help with clarity. I have switched to a new theme, although it is still created by the previous designer.
I have also added a Google CSE to [...]]]></description>
			<content:encoded><![CDATA[<p>So it has been a while since I posted last and I felt like updating and cleaning stuff up. The tags and categories have been improved and reduced to help with clarity. I have switched to a new theme, although it is still created by the previous designer.</p>
<p>I have also added a Google CSE to assist with searching for a particular post, although I don&#8217;t exactly have too many.</p>
<p>I am very impressed with how WordPress has improved over recent times. The automatic upgrade is impressive and will surely ensure that less WP installs are hacked. The theme/plug-in search is quick and very easy to use, thus insuring that people will not be stuck with one design, or missing a vital plug-in. These two can be upgraded on the fly. Overall a real improvement proving that WP is a mature and stable piece of software.</p>
<p>There is only one minor annoyance and that is the speed at which pages are served, I do feel it could be slightly quicker.</p>
<p>Hope you all enjoy the updates that I applied!</p>
]]></content:encoded>
			<wfw:commentRss>http://znx.no/2009/11/updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acer Aspire One Tips</title>
		<link>http://znx.no/2009/09/acer-aspire-one-tips/</link>
		<comments>http://znx.no/2009/09/acer-aspire-one-tips/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 22:10:24 +0000</pubDate>
		<dc:creator>znx</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[aa1]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://znx.no/?p=162</guid>
		<description><![CDATA[Just came across a really good site with lots of tips and tricks for the AA1.
I have owned this dinky wee notebook for sometime now and can highly advise it for anyone looking for a Linux Notebook.
Some tricks I have are:
Alt+F2 &#62; xfce-settings-show &#62; Desktop &#62; Behaviour &#62; Show desktop menu on right click.
The will [...]]]></description>
			<content:encoded><![CDATA[<p>Just came across a really good <a title="Macles Blog" href="http://macles.blogspot.com/">site</a> with lots of tips and tricks for the AA1.</p>
<p>I have owned this dinky wee notebook for sometime now and can highly advise it for anyone looking for a Linux Notebook.</p>
<p>Some tricks I have are:</p>
<p><b>Alt+F2 &gt; xfce-settings-show &gt; Desktop &gt; Behaviour &gt; Show desktop menu on right click.</b><br />
The will enable the XFCE menu on right click, which is useful to me.</p>
<p><b>Alt+F2 &gt; xfce-settings-show &gt; Sessions and Startup &gt; Advanced &gt; Launch Gnome services on startup</b><br />
This will allow NetworkManger to use gnome-keyring and therefore finally store the keys for wireless!</p>
<p>Simple but effective!</p>
]]></content:encoded>
			<wfw:commentRss>http://znx.no/2009/09/acer-aspire-one-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Renaming Files In A Directory</title>
		<link>http://znx.no/2009/09/renaming-files/</link>
		<comments>http://znx.no/2009/09/renaming-files/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 20:58:32 +0000</pubDate>
		<dc:creator>znx</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[ms]]></category>
		<category><![CDATA[powershell]]></category>

		<guid isPermaLink="false">http://znx.no/?p=159</guid>
		<description><![CDATA[So I had a problem on Windows in that I have lots of directories that are named correctly but I wish the files under them to be uniformly named.
The solution was to use PowerShell, which is an extremely effective scripting tool for Windows, especially if you come from a UNIX shell background.
There is actually quite [...]]]></description>
			<content:encoded><![CDATA[<p>So I had a problem on Windows in that I have lots of directories that are named correctly but I wish the files under them to be uniformly named.</p>
<p>The solution was to use <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx">PowerShell</a>, which is an extremely effective scripting tool for Windows, especially if you come from a UNIX shell background.</p>
<p>There is actually quite a lot of documentation available for it and rather than go into detail I will simply show you the script:</p>

<div class="wp_syntax"><div class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;">#</span>
<span style="color: #008000;"># RenameDirectoryFiles.ps1</span>
<span style="color: #008000;">#</span>
&nbsp;
<span style="color: #0000FF;">param</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$paths</span> <span style="color: #000000;">&#41;</span>
<span style="color: #008080; font-weight: bold;">Set-PSDebug</span> <span style="color: #008080; font-style: italic;">-Strict</span>
&nbsp;
<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span> <span style="color: #800080;">$path</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$paths</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span> <span style="color: pink;">!</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Test-Path</span> <span style="color: #800080;">$path</span> <span style="color: #008080; font-style: italic;">-PathType</span> Container<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-weight: bold;">Write-Error</span> <span style="color: #800000;">&quot;'$path' doesn't exist or isn't a directory&quot;</span>
        exit <span style="color: #000000;">1</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #800080;">$i</span> <span style="color: pink;">=</span> <span style="color: #000000;">0</span>
    <span style="color: #008080; font-weight: bold;">Get-ChildItem</span> <span style="color: #800080;">$path</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">sort</span> FullName <span style="color: pink;">|</span> <span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #800080;">$tmp</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;{0:000}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$i</span>
        <span style="color: #800080;">$ext</span> <span style="color: pink;">=</span> <span style="color: #000080;">$_</span>.Extension
        <span style="color: #800080;">$newname</span> <span style="color: pink;">=</span> <span style="color: #800000;">&quot;$path - $tmp$ext&quot;</span>
        <span style="color: #008080; font-weight: bold;">Rename-Item</span> <span style="color: #000080;">$_</span>.fullname <span style="color: #800080;">$newname</span>
        <span style="color: #800080;">$newname</span>
        <span style="color: #800080;">$i</span> <span style="color: pink;">=</span> <span style="color: #800080;">$i</span> <span style="color: pink;">+</span> <span style="color: #000000;">1</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>So the usage is extremely simple:</p>
<pre>RenameDirectoryFiles.ps1 'My Directory'</pre>
<p>After which all the files under &#8216;My Directory&#8217; will be renamed to &#8216;My Directory &#8211; 000.fileextension&#8217;.</p>
]]></content:encoded>
			<wfw:commentRss>http://znx.no/2009/09/renaming-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft Business Productivity Racism?</title>
		<link>http://znx.no/2009/08/microsoft-business-productivity-racism/</link>
		<comments>http://znx.no/2009/08/microsoft-business-productivity-racism/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 21:50:05 +0000</pubDate>
		<dc:creator>znx</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[funny]]></category>
		<category><![CDATA[ms]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://znx.no/?p=152</guid>
		<description><![CDATA[I was recently pointed to the English and Polish pages for the MS Business Productivity. The most striking thing about the difference between the pages is that one depicts a white individual in place of a black individual. What could be the purpose of altering the image, surely it isn&#8217;t racism, after all the Chinese [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently pointed to the <a href='http://www.microsoft.com/businessproductivity/default.mspx'>English</a> and <a href='http://www.microsoft.com/poland/businessproductivity/default.mspx'>Polish</a> pages for the MS Business Productivity. The most striking thing about the difference between the pages is that one depicts a white individual in place of a black individual. What could be the purpose of altering the image, surely it isn&#8217;t racism, after all the Chinese individual is still in place.</p>
<p>Strange what goes through the brain of MS Business Productivity.</p>
<div id="attachment_153" class="wp-caption alignleft" style="width: 309px"><img class="size-full wp-image-153 " title="ms-diff1" src="http://znx.no/i/2009/08/ms-diff1.png" alt="Polish Alternative" width="299" height="158" /><p class="wp-caption-text">Polish Alternative</p></div>
<div id="attachment_154" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-154 " title="ms-diff2" src="http://znx.no/i/2009/08/ms-diff2-300x153.png" alt="English Alternative" width="300" height="153" /><p class="wp-caption-text">English Alternative</p></div>
]]></content:encoded>
			<wfw:commentRss>http://znx.no/2009/08/microsoft-business-productivity-racism/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
