<?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>Sysadmin Ramblings &#187; Code</title>
	<atom:link href="http://ramblings.narrabilis.com/wp/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://ramblings.narrabilis.com/wp</link>
	<description>Scripts, settings, and fixes...</description>
	<lastBuildDate>Thu, 29 Jul 2010 13:29:37 +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>gethostbyaddr</title>
		<link>http://ramblings.narrabilis.com/wp/gethostbyaddr/</link>
		<comments>http://ramblings.narrabilis.com/wp/gethostbyaddr/#comments</comments>
		<pubDate>Tue, 28 Mar 2006 19:31:44 +0000</pubDate>
		<dc:creator>uphill</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://ramblings.narrabilis.com/wp/gethostbyaddr/</guid>
		<description><![CDATA[ipaddress to hostname without a single shred of error checking.  This code will take an ipaddress as an argument and return the hostname associated with it using gethostbyaddr.  It should have more error checking and a lot of other stuff, but this is just to show the base code.  Cut and paste [...]]]></description>
			<content:encoded><![CDATA[ipaddress to hostname without a single shred of error checking.  This code will take an ipaddress as an argument and return the hostname associated with it using gethostbyaddr.  It should have more error checking and a lot of other stuff, but this is just to show the base code.  Cut and paste away.

<code><span style="color: #000000">
#include&nbsp;&lt;unistd.h&gt;<br />#include&nbsp;&lt;netdb.h&gt;<br />#include&nbsp;&lt;netinet/in.h&gt;<br /><br />int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;struct&nbsp;hostent&nbsp;*hostname&nbsp;=&nbsp;malloc(sizeof(struct&nbsp;hostent));<br />&nbsp;&nbsp;&nbsp;&nbsp;extern&nbsp;int&nbsp;h_errno;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;struct&nbsp;in_addr&nbsp;*ipaddr&nbsp;=&nbsp;malloc(sizeof(struct&nbsp;in_addr));<br />&nbsp;&nbsp;&nbsp;&nbsp;ipaddr-&gt;s_addr=inet_addr(argv[1])&nbsp;;<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(&nbsp;(hostname&nbsp;=&nbsp;gethostbyaddr((char&nbsp;*)&nbsp;ipaddr,sizeof(ipaddr),AF_INET))&nbsp;==&nbsp;NULL&nbsp;)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;("%s\n","unknown");<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(1);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;printf&nbsp;("%s\n",hostname&nbsp;-&gt;&nbsp;h_name);<br />}<br /></span>
</code>]]></content:encoded>
			<wfw:commentRss>http://ramblings.narrabilis.com/wp/gethostbyaddr/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
