<?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/"
	>

<channel>
	<title>Jack of All Trades</title>
	<atom:link href="http://www.sunran.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sunran.com</link>
	<description>On Programming, Culture and Little things that surround my life</description>
	<pubDate>Thu, 10 Jun 2010 18:45:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Test post</title>
		<link>http://www.sunran.com/test-post/</link>
		<comments>http://www.sunran.com/test-post/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 18:45:08 +0000</pubDate>
		<dc:creator>ranjith</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://www.sunran.com/?p=328</guid>
		<description><![CDATA[This post is intentionally left blank
]]></description>
			<content:encoded><![CDATA[<p>This post is intentionally left blank</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunran.com/test-post/feed/</wfw:commentRss>
		</item>
		<item>
		<title>In the clouds with Rackspace</title>
		<link>http://www.sunran.com/in-the-clouds-with-rackspace/</link>
		<comments>http://www.sunran.com/in-the-clouds-with-rackspace/#comments</comments>
		<pubDate>Thu, 21 May 2009 11:41:23 +0000</pubDate>
		<dc:creator>ranjith</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[cloud]]></category>

		<category><![CDATA[cloudcomputing]]></category>

		<guid isPermaLink="false">http://www.sunran.com/?p=291</guid>
		<description><![CDATA[
 


The heading says it all. Last weekend, I snapped and took the plunge to join the cloud computing bandwagon and moved my server to Rackspace. I moved the wordpress instance and this blog. I will be moving about 7 to 8 sites that either I own or is helping someone to host to my [...]]]></description>
			<content:encoded><![CDATA[<p>
 <a href="http://www.flickr.com/photos/23093363@N00/113338465" title="View 'Eye of God' on Flickr.com"><img src="http://farm1.static.flickr.com/52/113338465_e04213777c_m.jpg" alt="Eye of God" border="0" width="240" height="160" class="alignright" /></a>
</p>
<p>
<span class="drop_cap">T</span>he heading says it all. Last weekend, I snapped and took the plunge to join the cloud computing bandwagon and moved my server to <a href="http://mosso.com">Rackspace</a>. I moved the wordpress instance and this blog. I will be moving about 7 to 8 sites that either I own or is helping someone to host to my new home in cloud. i got a closer look at cloud in the process. This article is a humble attempt to document what I learned. Why I chose Rackspace against Amazon and What I would expect moving forward.<br />
<h2>What the heck is cloud computing ?</h2>
</p>
<p>Cloud is a fancy name for Internet. And computing; Well, remember the first class about computers you took. They said a computer comprises of a CPU, a storage device or memory and an input output device like keyboard or mouse. Cloud computing is a bold attempt to take that first two pieces and putting it in internet. In its simplified form thats all you need to know. However the whole technology is built on the same fundamentals of peer-to-peer, the one you used to download your music, or bit torrent. That is, if you let multiple machines to work on a task, divided into manageable pieces, you can achieve more throughput compared to one you would have achieved with one machine. Cloud computing in its present form is possible because of some ground breaking technological advances they made in the field of grid computing and server virtualization. </p>
<p>Cloud computing cleared your desk. It basically took the CPU and storage away from you, along with the dangling wires. This is the basic concept of the business model adopted by major players in the field. They sell you either just storage space or CPU and Storage. They meter your usage and bill you based on how much you had used. A storage is metered in GB of usage and CPU is metered on the basis of hours of usage. Amazon sell S3, the storage part of the cloud and EC2 the CPU part of the technology. Rackspace has named them cloudfiles and cloudserver respectively. Rackspace additionally have a service called cloudsites aswell; which is so cool, I will come to it in a bit.</p>
<p>Traditionally when you needed a web presence, you employ a hosting company. They lend you some space and assorted number of tools and some restrictive access to the part of the machine provisioned in your name. You upload your files, write web applications with the languages and tools they provide. Often times you have no control on installing anything new. Even if you can, you cannot accomplish anything without some help or advice from the support staff at your hosting company. Cloud, on the other hand,  breaks all these barriers and provides complete control. You get a whole server in your name. With complete access. For eg, you can even remote desktop into your machine provisioned for you. You even have your own static public IP (not with amazon EC2, though). However, flexibility comes with responsibility. If you had gotten yourself a windows machine then you should be worrying about software patches, viruses, malware .. you got the idea. The machine is vulnerable to any issues you would have faced if it were a real one. </p>
<h2>Why Rackspace not Amazon EC2 ?</h2>
<p>As I mentioned previously, Rackspace has a service called &#8220;cloudsites&#8221;. cloudsites is cool because the service is a blend of traditional web hosting and the cloud. It starts at a flat rate and you can throw in a virtual server and some cloudfiles space anytime you want. cloudsites in a very superficial aspect looks like a web hosting package, with a enormous high price (however the price is almost equivalent of running an EC2 server 24 hours for 30 days). But its a virtual server that runs 24&#215;7 servicing requests to a site hosted on that virtual server.  You can host multiple sites on this server and even can lease out space. There is a billing interface and an interface to monitor your client&#8217;s usage. This is what I have signed up for now. </p>
<p>When you sign up for a cloud server, either on amazon or on rackspace you have a choice of a Windows machine or a linux machine. If you are on EC2 you are stuck with it. Rackspace on the other hand is purely hybrid. Even if you are signed up for a linux machine you can decide to write a part of your application in ASP. You can place the ASP files along with the PHP files on the same folder. And you can see it co-exist flawlessly in there (I haven&#8217;t tested it yet).</p>
<p>Amazon doc is confusing. Jargon filled and uses too many 3 letter syllables to denote its various services. You have to pretty much sign up at three different places to get your virtual server up and running. First on AWS, then on S3 and finally on EC2. Logically it didn&#8217;t made any sense. Racspace has a much more straight forward approach. </p>
<p class ="note">
But you shouldn&#8217;t be looking at the docs. <a href="http://scripting.com">Dave Winer</a> had made an utterly simple <a href="http://howto.opml.org/dave/ec2/">EC2 for Poets</a> tutorial. I wonder if Amazon will consider retiring their jargon filled docs for this one !
</p>
<p>Amazon&#8217;s server is ephemeral. It can crash and could take all the data you saved along with it. Rackspace data is saved on a Raid and is completely oblivious to server&#8217;s condition. So you don&#8217;t have to worry about any server crashes. </p>
<p>That being said there are couple of turn offs for rackspace. Rackspace has APIs to manage their services. But I felt its lacking some features. Amazon has a much more flexible API set, IMHO. I can&#8217;t pin point where it is lacking, nor can I suggest what I need more. I would definitely take some time off during the weekend to get a closer look at the APIs. </p>
<h2>What is lacking ?</h2>
<p>I had expected that I can download a server instance on to my local machine. I then can take it else where and boom, I have the exact setup running in the new home.After all this is what server virtualization is; in its true spirit, right ?. Unfortunately thats not the case, now.  Moving from rackspace else where is as painful as changing your hosting provider. Though i know its a long shot, I am expecting that it would happen sooner or later.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunran.com/in-the-clouds-with-rackspace/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Thanks Obama; we got inspired</title>
		<link>http://www.sunran.com/thanks-obama-we-got-inspired/</link>
		<comments>http://www.sunran.com/thanks-obama-we-got-inspired/#comments</comments>
		<pubDate>Mon, 18 May 2009 11:41:51 +0000</pubDate>
		<dc:creator>ranjith</dc:creator>
		
		<category><![CDATA[Politics]]></category>

		<category><![CDATA[election]]></category>

		<category><![CDATA[india]]></category>

		<guid isPermaLink="false">http://sunran.com/?p=281</guid>
		<description><![CDATA[Election in india is over, finally. Dr. Singh and regained the power, this time with a blast. The Obama effect might have played a role. Indians saw how Americans thought out of the box and chose a change they all desperately wanted, electing the first black president. This, IMHO had psyched the indians too. They [...]]]></description>
			<content:encoded><![CDATA[<p>Election in india is over, finally. Dr. Singh and regained the power, this time with a blast. The Obama effect might have played a role. Indians saw how Americans thought out of the box and chose a change they all desperately wanted, electing the first black president. This, IMHO had psyched the indians too. They realized its high time to act and throw the crooks out and choose the right ones.</p>
<p>Indians notoriously favored the bunch who exploited us emotionally. BJP came to power 15 years ago after they went on a murdering rampage to re-establish the Rama Janma Bhumi, a temple they claimed will replace the Mosque that they thought was the birth place of Lord Rama. They took out the same card this time as-well. But indians didn&#8217;t bought it this time.</p>
<p>Samajvati Party claimed that they will abolish computers. The same winning card they played 30 years ago when their parent party came to power in 1978. We nicely ignored them too. Though SP wasn&#8217;t a national party, they could have provided a huge burden to the UPA coalition that Dr. Singh leads.</p>
<p>This election saw a the birth of a  third front, who offered a change that india needed. We realized that it is just an eye wash for few crooks to become the prime minister. indians said; Thanks but no thanks.</p>
<p>Yes, this election overall instilled a sense of nationalism and hope. Now its the time to perform and win. Let see.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunran.com/thanks-obama-we-got-inspired/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Pesaha appam</title>
		<link>http://www.sunran.com/pesaha-appam/</link>
		<comments>http://www.sunran.com/pesaha-appam/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 13:54:03 +0000</pubDate>
		<dc:creator>ranjith</dc:creator>
		
		<category><![CDATA[personal]]></category>

		<category><![CDATA[indary]]></category>

		<category><![CDATA[passover]]></category>

		<category><![CDATA[pesaha]]></category>

		<guid isPermaLink="false">http://sunran.com/?p=257</guid>
		<description><![CDATA[


Syro Malabar Catholic Church has unique traditions. This is one such. On a passover day we make unleavened bread like the one show above. The dip is a mix of rice flour and caramelized sugar candy. The head of the house hold sits and cuts the bread into small pieces. Pieces are distributed to kids [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/23093363@N00/3428308001" title="View 'Pesaha appam' on Flickr.com">
<div style="text-align:center;"><img src="http://farm4.static.flickr.com/3399/3428308001_54bb9975db.jpg" alt="Pesaha appam" border="0" width="500" height="333" /></div>
<p></a></p>
<p><a href="http://en.wikipedia.org/wiki/Syro-Malabar_Catholic_Church">Syro Malabar Catholic Church</a> has unique traditions. This is one such. On a passover day we make unleavened bread like the one show above. The dip is a mix of rice flour and caramelized sugar candy. The head of the house hold sits and cuts the bread into small pieces. Pieces are distributed to kids in their order of ages. Its one of the holiest traditions you celebrate with your family.</p>
<p>Since easter falls closely with the famous harvest festival called <a href="http://en.wikipedia.org/wiki/Vishu">Vishu</a>, catholics had adopted a bit of the cultures from vishu too. So we often put harvested rice paddies along with the bread. Its basically vestigial, but I guess it helps to spice up the mood. Hence you can see some dried wheat in the picture.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunran.com/pesaha-appam/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Almost Perfect</title>
		<link>http://www.sunran.com/almost-perfect/</link>
		<comments>http://www.sunran.com/almost-perfect/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 11:24:41 +0000</pubDate>
		<dc:creator>ranjith</dc:creator>
		
		<category><![CDATA[Book Review]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[books]]></category>

		<category><![CDATA[wordperfect]]></category>

		<guid isPermaLink="false">http://sunran.com/?p=255</guid>
		<description><![CDATA[Why is this books so drawing?. I started reading it thinking of it as another war story of software development. It is more than that. I can&#8217;t describe it any better other than just urge you to go and read it.

Almost Perfect by W. E. Peterson The Rise and Fall of WordPerfect Corporation: &#8220;&#8221;
(Via Rob [...]]]></description>
			<content:encoded><![CDATA[<p>Why is this books so drawing?. I started reading it thinking of it as another war story of software development. It is more than that. I can&#8217;t describe it any better other than just urge you to go and read it.</p>
<blockquote>
<p><a href="http://www.wordplace.com/ap/index.shtml">Almost Perfect by W. E. Peterson The Rise and Fall of WordPerfect Corporation</a>: &#8220;&#8221;</p>
<p>(Via <a href="http://rob.crabapples.net">Rob Fahrni</a>.)</p>
</blockquote>
<p>I wonder why the book went out of print, though it is one of the best books I ever read.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunran.com/almost-perfect/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Xcode Tip - Linking a library</title>
		<link>http://www.sunran.com/xcode-tip-linking-a-library/</link>
		<comments>http://www.sunran.com/xcode-tip-linking-a-library/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 13:29:28 +0000</pubDate>
		<dc:creator>ranjith</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[MacOSX]]></category>

		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://sunran.com/?p=253</guid>
		<description><![CDATA[From comp.sys.mac.programmer.help

To instruct ld to link against a library called &#8216;libName&#8217; you specify
the linker flag &#8216;-lName&#8217;. That&#8217;s the rule. To link against libxml2.dylyb
you would pass &#8216;-lxml2&#8242;. If you look in /usr/lib (on 10.5) you&#8217;ll see
that this is acutally a symlink to the currently shipped version
libxml2.2.dylib.

]]></description>
			<content:encoded><![CDATA[<p>From <a href="http://groups.google.com/group/comp.sys.mac.programmer.help/browse_thread/thread/226437534b326b3e">comp.sys.mac.programmer.help</a></p>
<blockquote><p>
To instruct ld to link against a library called &#8216;libName&#8217; you specify<br />
the linker flag &#8216;-lName&#8217;. That&#8217;s the rule. To link against libxml2.dylyb<br />
you would pass &#8216;-lxml2&#8242;. If you look in /usr/lib (on 10.5) you&#8217;ll see<br />
that this is acutally a symlink to the currently shipped version<br />
libxml2.2.dylib.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sunran.com/xcode-tip-linking-a-library/feed/</wfw:commentRss>
		</item>
		<item>
		<title>More libcurl Madness; HTTP basic authentication with libcurl</title>
		<link>http://www.sunran.com/more-libcurl-madness-http-basic-authentication-with-libcurl/</link>
		<comments>http://www.sunran.com/more-libcurl-madness-http-basic-authentication-with-libcurl/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 23:00:44 +0000</pubDate>
		<dc:creator>ranjith</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[libcurl]]></category>

		<guid isPermaLink="false">http://sunran.com/?p=250</guid>
		<description><![CDATA[This is getting worse, I am playing with curl more than I should be. This time, I would like to show a snippet of code that demonstrate basic http authentication. You might want to take a look at my previous code for the complete listing. The following code fetches the last 20 direct messages from [...]]]></description>
			<content:encoded><![CDATA[<p>This is getting worse, I am playing with curl more than I should be. This time, I would like to show a snippet of code that demonstrate basic http authentication. You might want to take a look at my <a href="http://sunran.com/2009/04/05/upload-your-pictures-to-twitpic-using-clibcurl/">previous code</a> for the complete listing. The following code fetches the last 20 direct messages from your twitter.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>43
44
45
46
47
48
49
50
51
52
53
54
55
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;">		curl_global_init<span style="color: #008000;">&#40;</span>CURL_GLOBAL_ALL<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> sAuth<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		sAuth <span style="color: #000040;">+</span><span style="color: #000080;">=</span> sUser <span style="color: #000040;">+</span> <span style="color: #FF0000;">&quot;:&quot;</span> <span style="color: #000040;">+</span> sPass<span style="color: #008080;">;</span>
		hCurl <span style="color: #000080;">=</span> curl_easy_init<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		hResult <span style="color: #000080;">=</span> curl_easy_setopt<span style="color: #008000;">&#40;</span>hCurl, CURLOPT_URL, <span style="color: #FF0000;">&quot;http://twitter.com/direct_messages.xml&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		hResult <span style="color: #000080;">=</span> curl_easy_setopt<span style="color: #008000;">&#40;</span>hCurl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		hResult <span style="color: #000080;">=</span> curl_easy_setopt<span style="color: #008000;">&#40;</span>hCurl, CURLOPT_USERPWD, sAuth.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		hResult <span style="color: #000080;">=</span> curl_easy_perform<span style="color: #008000;">&#40;</span>hCurl<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>CURLE_OK <span style="color: #000040;">!</span><span style="color: #000080;">=</span> hResult<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;May be twitter is on a whale hunt&quot;</span> <span style="color: #000080;">&lt;&lt;</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		curl_easy_cleanup<span style="color: #008000;">&#40;</span>hCurl<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		curl_global_cleanup<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>I can justify why I had decided to post it. I had tried with base64 encoding to convert a user/password and add it as a custom header field in the curl call. Had I had it known that libcurl supports basic authentication out of the box, I would have saved lot of time. I am sure there would be some hapless soul like me, that would head down my route. Who knows, may be I would completely forget about this and try the same path again. But; sure next time, I hope google will land me on my own blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunran.com/more-libcurl-madness-http-basic-authentication-with-libcurl/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Plug and Pray</title>
		<link>http://www.sunran.com/plug-and-pray/</link>
		<comments>http://www.sunran.com/plug-and-pray/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 15:38:13 +0000</pubDate>
		<dc:creator>ranjith</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[funny]]></category>

		<guid isPermaLink="false">http://sunran.com/?p=246</guid>
		<description><![CDATA[All you need is to have a belief. Well, isn&#8217;t that all motivational speakers tried to sell all these years. And even if it is not a development methodology isn&#8217;t that what we all do. Press F5 and hope that the software will build

Taking software development on faith - SD Times On The Web: &#8220;‘All [...]]]></description>
			<content:encoded><![CDATA[<p>All you need is to have a belief. Well, isn&#8217;t that all motivational speakers tried to sell all these years. And even if it is not a development methodology isn&#8217;t that what we all do. Press F5 and hope that the software will build</p>
<blockquote>
<p><a href="http://www.sdtimes.com/TAKING_SOFTWARE_DEVELOPMENT_ON_FAITH/About_TESTING/33364">Taking software development on faith - SD Times On The Web</a>: &#8220;‘All you have to do is believe, and we do this all the time,’ said Ebenezer Scroom, CEO of Faith-Based Software Development Inc. (FBSDI), which sponsored the conference. ‘We turn the car key and believe that our engine will start… and it does. We push bread down into the toaster and believe that toast will pop out… and it does. We write thousand of lines of C# or Java, click the ‘Build’ button and believe the application will execute correctly the first time. In his heart of hearts, every developer believes this! The good news is that if you follow the principles of Faith-Based Development, your app will work the first time.’<br />
&#8220;</p>
<p>(Via Email <a href="http://www.sitesdynamic.com/defaultpage.asp">Brad Eck</a>.)</p>
</blockquote>
<p>Ok, let me try. PRAISE THE LORD !!! It worked !!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunran.com/plug-and-pray/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Upload your pictures to Twitpic using C++/libcurl</title>
		<link>http://www.sunran.com/upload-your-pictures-to-twitpic-using-clibcurl/</link>
		<comments>http://www.sunran.com/upload-your-pictures-to-twitpic-using-clibcurl/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 20:03:39 +0000</pubDate>
		<dc:creator>ranjith</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[libcurl]]></category>

		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://sunran.com/?p=243</guid>
		<description><![CDATA[Here is a small program that will upload an image file less than 4MB to twitpic.com. The API endpoint that I used here is http://twitpic.com/api/upload". This won&#8217;t send an update to the twitter. Use uploadAndPost.
Needless to say this requires libcurl. Grab it from here in source or binary form.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include &#60;iostream&#62;
#include &#60;sstream&#62;
#include &#60;curl/curl.h&#62;
&#160;
#define END_POINT &#34;http://twitpic.com/api/upload&#34;
#define EXPECT_ARGS [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a small program that will upload an image file less than 4MB to twitpic.com. The API endpoint that I used here is <code>http://twitpic.com/api/upload"</code>. This won&#8217;t send an update to the twitter. Use <code>uploadAndPost</code>.</p>
<p>Needless to say this requires libcurl. Grab it from <a href="http://curl.haxx.se/">here</a> in source or binary form.</p>
<p><code></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;iostream&gt;</span>
<span style="color: #339900;">#include &lt;sstream&gt;</span>
<span style="color: #339900;">#include &lt;curl/curl.h&gt;</span>
&nbsp;
<span style="color: #339900;">#define END_POINT &quot;http://twitpic.com/api/upload&quot;</span>
<span style="color: #339900;">#define EXPECT_ARGS 4</span>
&nbsp;
<span style="color: #0000ff;">size_t</span> write_data<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span> <span style="color: #000040;">*</span>buffer, <span style="color: #0000ff;">size_t</span> size, <span style="color: #0000ff;">size_t</span> nmemb, <span style="color: #0000ff;">void</span><span style="color: #000040;">*</span> userp<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
&nbsp;
	std<span style="color: #008080;">::</span><span style="color: #007788;">stringstream</span> strmResponse<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">size_t</span> nReal <span style="color: #000080;">=</span> size <span style="color: #000040;">*</span> nmemb<span style="color: #008080;">;</span>
	strmResponse <span style="color: #000080;">&lt;&lt;</span> std<span style="color: #008080;">::</span><span style="color: #007788;">string</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">char</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span>buffer, size<span style="color: #000040;">*</span>nmemb<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> sLine<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>getline<span style="color: #008000;">&#40;</span>strmResponse, sLine<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> sLine.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">&lt;&lt;</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">return</span> nReal<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">int</span> main <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span> <span style="color: #0000ff;">const</span> argv<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
&nbsp;
	<span style="color: #0000ff;">int</span> result <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
	CURL<span style="color: #000040;">*</span> hCurl <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
	CURLcode hResult<span style="color: #008080;">;</span>
	std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> sUser<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> sPass<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> sFileName<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #666666;">//Curl for form data</span>
	<span style="color: #0000ff;">struct</span> curl_httppost <span style="color: #000040;">*</span>post <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">struct</span> curl_httppost <span style="color: #000040;">*</span>last <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">try</span><span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>argc <span style="color: #000080;">&lt;</span> EXPECT_ARGS<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Usage twitpic_upload twitterUserName twiiterPassword fileName&quot;</span> <span style="color: #000080;">&lt;&lt;</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #666666;">//Get the require params from command line args</span>
		sUser     <span style="color: #000080;">=</span> argv<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
		sPass     <span style="color: #000080;">=</span> argv<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
		sFileName <span style="color: #000080;">=</span> argv<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
&nbsp;
		<span style="color: #666666;">//Initialize curl, just don't let easy_init to do it for you</span>
		curl_global_init<span style="color: #008000;">&#40;</span>CURL_GLOBAL_ALL<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #666666;">//Handle to the curl</span>
		hCurl <span style="color: #000080;">=</span> curl_easy_init<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">NULL</span> <span style="color: #000080;">==</span> hCurl<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #666666;">//Construct the form</span>
		curl_formadd<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>post, <span style="color: #000040;">&amp;</span>last, CURLFORM_COPYNAME, <span style="color: #FF0000;">&quot;username&quot;</span>, CURLFORM_COPYCONTENTS, sUser.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, CURLFORM_END<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		curl_formadd<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>post, <span style="color: #000040;">&amp;</span>last, CURLFORM_COPYNAME, <span style="color: #FF0000;">&quot;password&quot;</span>, CURLFORM_COPYCONTENTS, sPass.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, CURLFORM_END<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		curl_formadd<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>post, <span style="color: #000040;">&amp;</span>last, CURLFORM_COPYNAME, <span style="color: #FF0000;">&quot;media&quot;</span>, CURLFORM_FILE, sFileName.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, CURLFORM_END<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #666666;">//Specify the API Endpoint</span>
		hResult <span style="color: #000080;">=</span> curl_easy_setopt<span style="color: #008000;">&#40;</span>hCurl,CURLOPT_URL, END_POINT<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #666666;">//Specify the HTTP Method</span>
		hResult <span style="color: #000080;">=</span> curl_easy_setopt<span style="color: #008000;">&#40;</span>hCurl, CURLOPT_HTTPPOST, post<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #666666;">//Post Away !!!</span>
		hResult <span style="color: #000080;">=</span> curl_easy_perform<span style="color: #008000;">&#40;</span>hCurl<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>hResult <span style="color: #000040;">!</span><span style="color: #000080;">=</span> CURLE_OK<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
			std<span style="color: #008080;">::</span><span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Cannot find the twitpic site &quot;</span> <span style="color: #000080;">&lt;&lt;</span> std<span style="color: #008080;">::</span><span style="color: #007788;">endl</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">throw</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">catch</span> <span style="color: #008000;">&#40;</span>...<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		result <span style="color: #000080;">=</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	curl_formfree<span style="color: #008000;">&#40;</span>post<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    curl_easy_cleanup<span style="color: #008000;">&#40;</span>hCurl<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	curl_global_cleanup<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">return</span> result<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunran.com/upload-your-pictures-to-twitpic-using-clibcurl/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Adding libcurl to Xcode&#8217;s linker settings</title>
		<link>http://www.sunran.com/adding-libcurl-to-xcodes-linker-settings/</link>
		<comments>http://www.sunran.com/adding-libcurl-to-xcodes-linker-settings/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 16:21:03 +0000</pubDate>
		<dc:creator>ranjith</dc:creator>
		
		<category><![CDATA[Link Blog]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[MacOSX]]></category>

		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://sunran.com/?p=239</guid>
		<description><![CDATA[I forget this every now and then and spend next 20 minutes searching when ever I want to add an external library to the XCode&#8217;s project linker settings. In VS2005 its just adding Additional Dependencies in Linker -> Inputs in Project Properties
For eg, Let say i want to add libcurl, openssl, libcrypto and zlib to [...]]]></description>
			<content:encoded><![CDATA[<p>I forget this every now and then and spend next 20 minutes searching when ever I want to add an external library to the XCode&#8217;s project linker settings. In VS2005 its just adding Additional Dependencies in Linker -> Inputs in Project Properties</p>
<p>For eg, Let say i want to add libcurl, openssl, libcrypto and zlib to the path. Go to Project -> Edit Project -> Linking -> Other Linker Flags</p>
<p><code><br />
-L/usr/lib -lcurl -lssl -lcrypto -lz<br />
</code></p>
<p>Note: libcurl, libxml2 are included with the XCode&#8217;s developer libs, so think again before you set out to compile the source for libcurl to generate the libs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sunran.com/adding-libcurl-to-xcodes-linker-settings/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
