<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5267091008358194058</id><updated>2012-01-12T22:58:19.171+08:00</updated><title type='text'>Kailas Patil</title><subtitle type='html'>Student of National University of Singapore</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>51</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-3191358077196010376</id><published>2011-11-14T17:40:00.000+08:00</published><updated>2011-11-14T17:40:40.581+08:00</updated><title type='text'>Email Address verification using Perl script</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Checking correctness of one email address is easy and can be done manually, however, if you want to validate a bunch of email addresses then automated script plays a very handy role.&amp;nbsp;&lt;div&gt;I would like to thank my&amp;nbsp;colleague&amp;nbsp;and friend "Sai Sathyanarayam" for giving me this script. I think this might be useful for others therefore, I am posting it here.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;# email.pl file&lt;/div&gt;&lt;div&gt;#open "email.txt" file from current directory,&amp;nbsp;&lt;/div&gt;&lt;div&gt;# email.txt file contains email addresses&amp;nbsp;separated&amp;nbsp;by , (comma) and each address is on new line&lt;/div&gt;&lt;div&gt;&lt;div&gt;open(FILE,"email.txt");&lt;/div&gt;&lt;div&gt;while($line = &amp;lt;FILE&amp;gt; ) {&lt;/div&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;chomp($line);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; if($line =~ /,/) { $line = $`; }else { print $line." is invalid\n";}&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; if ($line =~ /^(\w|\-|\_|\.)+\@((\w|\-|\_)+\.)+[a-zA-Z]{2,}$/)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print "$line is valid\n";&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;else {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;print "$line is invalid\n";&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Sample email.txt file is as follows:&lt;/div&gt;&lt;div&gt;&lt;div&gt;xyz@abc.com,&lt;/div&gt;&lt;div&gt;pqr@mnr.ac.in,&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To perform validation test run following command:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: purple;"&gt;$ perl email.pl&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: purple;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: purple;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-3191358077196010376?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/3191358077196010376/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2011/11/email-address-verification-using-perl.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/3191358077196010376'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/3191358077196010376'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2011/11/email-address-verification-using-perl.html' title='Email Address verification using Perl script'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-658026156665578732</id><published>2011-08-26T11:58:00.001+08:00</published><updated>2011-08-26T11:59:18.592+08:00</updated><title type='text'>JaegerMonkey Architecture</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="text-align: justify;"&gt;JaegerMonkey is a JavaScript engine used in Firefox 4.0 and later versions. The SpiderMonkey JavaScript engine was used by Firefox for version 3.0 or&amp;nbsp;earlier. TraceMonkey is a tracing engine which is an improvement to SpiderMonkey. Trace Monkey was used in Firefox 3.5 and above versions. &amp;nbsp;Before we will look into architecture of JaegerMonkey, lets first have a glance at TraceMonkey JavaScript engine who is a predecessor of JaegerMonkey.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;TraceMonkey Overview&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;TraceMonkey uses a trace monitor called &lt;span class="Apple-style-span" style="color: #666666;"&gt;jstracer&lt;/span&gt;. The jstracer monitors a script as interpreted by SpiderMonkey. Whenever jstracer sees a code that would benefit from the native compilation, it activates it recorder. The recorder records the execution of the IR and creates NanoJIT Low Level Intermediate Representation, which is then compiled into native code. NanoJIT produces optimized code. More information on TraceMonkey and its architecture&amp;nbsp;diagram&amp;nbsp;is available &amp;nbsp;&lt;a href="https://developer.mozilla.org/En/SpiderMonkey/Internals/Tracing_JIT"&gt;here&lt;/a&gt;.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;JaegerMonkey Architecture&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;JaegerMonkey used in Fireox 4.0 and above version is Just-in-Time (JIT) JavaScript execution engine. &amp;nbsp;JaegerMonkey JIT engine produces native code for JavaScripts. Usually JIT engines take an intermediate representation (IR) from a compiler and produce native (machine) code and execute it on the fly. &amp;nbsp;Therefore, JIT engines do not parse the code or check its syntax, or create intermediate representation (IR) of code.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Hence, JavaScript engine in Mozilla Firefox we divide into two parts: front-end and back-end. The front-end is responsible to parse the script, check its syntax and generate intermediate representation (IR) of script required for native code generation. &amp;nbsp;The back-end is responsible for generating native code and memory management.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;In Mozilla Firefox front-end is SpiderMonkey which parses script syntax and generates an intermediate representation (IR) of the script. In SpiderMonkey intermediate&amp;nbsp;representation&amp;nbsp;of script is &lt;span class="Apple-style-span" style="color: #666666;"&gt;bytecode &lt;/span&gt;of the script.&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;This generated bytecode is then fed to JaegerMonkey JIT engine to be compiled into machine code. JaegerMonkey is a method-base JIT JavaScript engine which compiles script into non-optimized machine code. &amp;nbsp;JaegerMoneky uses &lt;span class="Apple-style-span" style="color: #666666;"&gt;Nitro&lt;/span&gt; (borrowed&amp;nbsp;from the WebKit project) as its back-end assembler. &amp;nbsp; &lt;/div&gt;&lt;div style="text-align: justify;"&gt;Nitro does memory management and code generation in JaegerMonkey.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Nitro contains two parts assembler and memory unit. Assembler handles the code assembly and memory unit handles allocation and deallocation of memory for native code. The bulk of the bytecode to native code translation is performed in the &lt;span class="Apple-style-span" style="color: #666666;"&gt;mjit::compiler&lt;/span&gt; class and it can be found in &lt;span class="Apple-style-span" style="color: #999999;"&gt;js/src/methodjit/Compiler.cpp&lt;/span&gt;. &amp;nbsp;This compiler class translates SpiderMonkey bytecode instructions to their native code block equivalents using the &lt;span class="Apple-style-span" style="color: #666666;"&gt;AssemblerBuffer&lt;/span&gt; and &lt;span class="Apple-style-span" style="color: #666666;"&gt;LinkBuffer&lt;/span&gt; helper classes.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;JaegerMonkey uses inline cache to improve the performance. Inline cache is used to perform faster object type lookups. &amp;nbsp;JavaScript supports dynamic typing during runtime. To support this feature, in SpiderMonkey &lt;span class="Apple-style-span" style="color: #666666;"&gt;JSOP_GETPROP&lt;/span&gt; bytecode is responsible to return the value of a specific property by looking up its type first. SpiderMonkey uses property cache which stores the &lt;span class="Apple-style-span" style="color: #666666;"&gt;Shape&lt;/span&gt; of existing objects. &amp;nbsp;Shape is a structure in SpiderMonkey that defines how the object can be accessed.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Inline Caching for good locality&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;When JIT compiles a property access bytecode, emitted machine code look like as follows:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="background-color: black; color: white;"&gt;type &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;- load addressof(object) + offsetof(JSObject, type)&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="background-color: black; color: white;"&gt;shapeIsKnown &amp;nbsp; &amp;nbsp;&amp;lt;- type equals IMPOSSIBLE_TYPE&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="background-color: black; color: white;"&gt;None &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;- goto slowLookupCode if shapeIsKnown is False&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="background-color: black; color: white;"&gt;property &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;- load addressof(object) + IMPOSSIBLE_SLOT&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;JagerMonkey uses self modifying code to inline cache the Shape of the object. Self modifying code is a code that modifies code that currently exists in memory. &amp;nbsp;When first time JaegerMonkey performs a&amp;nbsp;property&amp;nbsp;access on object its shape is unknown&amp;nbsp;therefore&amp;nbsp;&lt;span class="Apple-style-span" style="color: #666666;"&gt;shapeIsKnow&lt;/span&gt; will be false. &amp;nbsp;Hence &lt;span class="Apple-style-span" style="color: #666666;"&gt;slowLookupCode&lt;/span&gt; will be executed. &amp;nbsp;After &lt;span class="Apple-style-span" style="color: #666666;"&gt;slowLookupCode&lt;/span&gt; resolves the property it fills the appropriate value for &lt;span class="Apple-style-span" style="color: #666666;"&gt;IMPOSSIBLE_TYPE&lt;/span&gt; and &lt;span class="Apple-style-span" style="color: #666666;"&gt;IMPOSSIBLE_SLOT&lt;/span&gt;. &amp;nbsp;Hence, next time when this piece of code is&amp;nbsp;executed, if the type of object is not change then &lt;span class="Apple-style-span" style="color: #666666;"&gt;shapeIsKnown&lt;/span&gt; return true and there is no need to go into &lt;span class="Apple-style-span" style="color: #666666;"&gt;slowLookupCode&lt;/span&gt;. &amp;nbsp;This technique of modifying JIT-compiled code to reflect a probable value is called as &lt;b&gt;inline caching: &lt;/b&gt;inline, as in "in the emitted code"; &amp;nbsp;caching, as in "cache a probable value".&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;However, JavaScript supports dynamic typing. This is handles by polymorphic inline caching (PIC). &amp;nbsp;Lets consider an example of PIC code:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="background-color: black;"&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;var vals = {1, "hello", [1, 2, 3]};&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="background-color: black;"&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;for (var i in vals) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="background-color: black;"&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;&amp;nbsp; &amp;nbsp;document.write(vals[i].toString());&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="background-color: black;"&gt;&lt;span class="Apple-style-span" style="color: white;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;In above code &lt;span class="Apple-style-span" style="color: #666666;"&gt;vals&lt;/span&gt; array contains&amp;nbsp;different&amp;nbsp;data types such as a Number, a String and a array. For each object in the array, the interpreter has to perform an expressive type lookup and determine the correct &lt;span class="Apple-style-span" style="color: #666666;"&gt;toString&lt;/span&gt; method to call. &amp;nbsp;JaegerMonkey uses PIC slots to colve this problem, that is make a chain of cache entries. It creates several blocks of native code that perform property lookups for types the object has already been seen as. It the first type does not match, then a branch is taken to the next code block to perform a lookup. If type is match then it performs a fast slot lookup. &amp;nbsp;According to our example, first time it recognizes &lt;span class="Apple-style-span" style="color: #666666;"&gt;Number&lt;/span&gt; object and fills cache entry for it. Second time its a &lt;span class="Apple-style-span" style="color: #666666;"&gt;String&lt;/span&gt;. So a new piece of code memory is created for type &lt;span class="Apple-style-span" style="color: #666666;"&gt;String&lt;/span&gt; and modify the jump of first lookup (that is, &lt;span class="Apple-style-span" style="color: #666666;"&gt;Number&lt;/span&gt; type mismatch in our example) to go to this newly created piece of code memory instead of &lt;span class="Apple-style-span" style="color: #666666;"&gt;slowLookupCode&lt;/span&gt;. &amp;nbsp;and so on.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;References:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;1.&amp;nbsp;&lt;a href="http://blog.cdleary.com/2010/09/picing-on-javascript-for-fun-and-profit/"&gt;PICing on JavaScript for fun and profit&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;2.&amp;nbsp;&lt;a href="http://www.matasano.com/research/Attacking_Clientside_JIT_Compilers_Paper.pdf"&gt;Attacking Clientside JIT Compilers [BlackHat 2011]&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-658026156665578732?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/658026156665578732/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2011/08/jaegermonkey-architecture.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/658026156665578732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/658026156665578732'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2011/08/jaegermonkey-architecture.html' title='JaegerMonkey Architecture'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-2800168132512226090</id><published>2011-04-01T15:43:00.000+08:00</published><updated>2011-04-01T15:43:16.859+08:00</updated><title type='text'>How to Merge Multiple PDF files into single PDF file on Ubuntu</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;Multiple PDF files can be merged into single PDF using two different ways: ghostscript or pdftk&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #cc0000;"&gt;A. Use Ghostscript to merge PDF files&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #741b47;"&gt;Steps:&lt;/span&gt;&lt;br /&gt;1. Install two pacakeges GhostScript and PDFtk tools.&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;$ sudo apt-get install gs pdftk&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2. Use following command to combine multiple files into single PDF file. The output file name is "singleCombinedPdfFile.pdf". The input file names are all files in the current directory, bcoz we used "*.pdf".&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;$ gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=singleCombinedPdfFile.pdf -dBATCH *.pdf&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you want to join PDF files in specific order then you can also use file names.&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;$ gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=singleCombinedPdfFile.pdf -dBATCH 1.pdf 2.pdf 3.pdf&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #990000;"&gt;B. Use pdftk (PDF toolkit) to merge multiple PDF files into Single PDF file&lt;/span&gt;&lt;br /&gt;1. &amp;nbsp;To merge PDF files by using names of the source PDF files:&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;$ pdftk one.pdf &amp;nbsp;two.pdf &amp;nbsp;three.pdf &amp;nbsp;cat &amp;nbsp;output &amp;nbsp;123-combined.pdf&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2. To merge PDF files using wildcard when number of files are large and its not feasible to input filenames of all files:&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;$&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: monospace; font-size: 15px;"&gt;pdftk *.pdf cat output combined.pdf&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; font-size: 15px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;3.&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; font-size: 15px;"&gt;Select specific pages from Multiple PDFs and create new PDF document:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="font-family: arial, helvetica, sans-serif; font-size: 15px;"&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: monospace; font-size: 15px;"&gt;$ pdftk A=one.pdf B=two.pdf cat A1-7 B1-5 A8 output combined.pdf&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-2800168132512226090?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/2800168132512226090/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2011/04/how-to-merge-multiple-pdf-files-into.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2800168132512226090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2800168132512226090'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2011/04/how-to-merge-multiple-pdf-files-into.html' title='How to Merge Multiple PDF files into single PDF file on Ubuntu'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-6146046689525909100</id><published>2011-03-14T11:53:00.001+08:00</published><updated>2011-03-14T18:47:51.454+08:00</updated><title type='text'>Embed fonts in PDF file using PDFLaTex</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="text-align: justify;"&gt;This post explains how to embed fonts in PDF file.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Embedding the font in the PDF file is useful when you are preparing a paper for conference submission or you want to ensure that your PDF file looks exactly same on other's machine as it does on your computer.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;In this post I will explain how to do it on Linux machine. &amp;nbsp;I am not sure how to achieve the same on Windows computer.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;We will use tool "&lt;span class="Apple-style-span" style="color: orange;"&gt;pdffonts&lt;/span&gt;" to examine PDF file.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;$ pdffonts &amp;nbsp;mypaper.pdf&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;type &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;emb &amp;nbsp;sub uni object ID&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;------------------------------------ ----------------- --- --- --- ---------&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;HVGYIY+NimbusRomNo9L-Medi &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Type 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes &amp;nbsp; yes no &amp;nbsp; &amp;nbsp; 110 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;TFVQMQ+NimbusRomNo9L-Regu &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Type 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes &amp;nbsp; yes no &amp;nbsp; &amp;nbsp; 111 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;XHGNKU+NimbusRomNo9L-MediItal &amp;nbsp; &amp;nbsp; &amp;nbsp; Type 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes &amp;nbsp; yes no &amp;nbsp; &amp;nbsp; 113 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;UUGCZC+NimbusRomNo9L-ReguItal &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Type 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes &amp;nbsp; yes no &amp;nbsp; &amp;nbsp; 114 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;FDULPW+CMSY7 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Type 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes &amp;nbsp; yes no &amp;nbsp; &amp;nbsp; 148 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;SPCNWZ+NimbusMonL-Regu &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Type 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes &amp;nbsp; yes no &amp;nbsp; &amp;nbsp; 150 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;ABCDEE+Times &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TrueType &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes &amp;nbsp; yes no &amp;nbsp; &amp;nbsp; 152 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;Arial &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TrueType &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no &amp;nbsp; no &amp;nbsp;no &amp;nbsp; &amp;nbsp; 153 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;Arial &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CID TrueType &amp;nbsp; &amp;nbsp; &amp;nbsp;yes &amp;nbsp;no &amp;nbsp;yes &amp;nbsp; &amp;nbsp;154 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;Arial &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TrueType &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no &amp;nbsp;no &amp;nbsp;no &amp;nbsp; &amp;nbsp; 220 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;Arial &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CID TrueType &amp;nbsp; &amp;nbsp; &amp;nbsp;yes &amp;nbsp;no &amp;nbsp;yes &amp;nbsp; &amp;nbsp;221 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;ABCDEE+Times &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TrueType &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes &amp;nbsp;yes no &amp;nbsp; &amp;nbsp; 222 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;Arial,Italic &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TrueType &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no &amp;nbsp; no &amp;nbsp;no &amp;nbsp; &amp;nbsp; 223 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;ZLLMAJ+CMMI10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Type 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes &amp;nbsp;yes no &amp;nbsp; &amp;nbsp; 257 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;Arial &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TrueType &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no &amp;nbsp; no &amp;nbsp;no &amp;nbsp; &amp;nbsp; 259 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;ABCDEE+Calibri &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TrueType &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes &amp;nbsp;yes no &amp;nbsp; &amp;nbsp; 260 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;Arial,Italic &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TrueType &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no &amp;nbsp; no &amp;nbsp;no &amp;nbsp; &amp;nbsp; 261 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;Arial &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TrueType &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no &amp;nbsp; no &amp;nbsp;no &amp;nbsp; &amp;nbsp; 282 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Times, 'Times New Roman', serif;"&gt;Arial,Italic &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TrueType &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;no &amp;nbsp; no &amp;nbsp;no &amp;nbsp; &amp;nbsp; 283 &amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;$&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The important columns are &lt;span class="Apple-style-span" style="color: red;"&gt;name&lt;/span&gt; and &lt;span class="Apple-style-span" style="color: red;"&gt;emb&lt;/span&gt;. &amp;nbsp;The "name" column displays the name of the font and the "emb" column shows whether that font is embedded in your PDF file or not. "yes" is "emb" column indicates that the font is embedded in the PDF file and "no" indicates that the font is not embedded in the PDF file. &amp;nbsp;&lt;/div&gt;&lt;div&gt;For example, in the above oputput, Arial, and Arial,Italic fonts are not embedded in the PDF file.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;To embed the un-embedded fonts into your PDF file using PDFLaTex:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;$ &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;updmap --edit&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;The above command will open the configuration file for pdflatex. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;Find the&amp;nbsp;&lt;/span&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="color: purple;"&gt;pdftexDownloadBase14&lt;/span&gt;&lt;/code&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&amp;nbsp;directive and make sure it is true. That is, when you're done, the following line should be in the file:&lt;/span&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="color: purple;"&gt;pdftexDownloadBase14 true&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;Save the file and rebuild your PDF file using "pdflatex".&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;Then check your PDF file using "pdffonts" command. It should now have&amp;nbsp;embedded&amp;nbsp;all the fonts use in your PDF file.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;If there are still some fonts missing then it might be because your have embedded another pdf file (as a graphics) into your "mypaper.pdf" file.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;In that case, you need to embedded the fonts into those embedded PDF files as well.&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;If you included figures in your PDF file then follow the steps given below:&lt;br /&gt;1. &amp;nbsp;Convert your PDF file to PS file&lt;br /&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;&amp;nbsp;&amp;nbsp;$&amp;nbsp;pdftops &amp;nbsp;mypaper.pdf&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2. C&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 15px;"&gt;onvert back ps file to pdf using "&lt;span class="Apple-style-span" style="color: orange;"&gt;prepress&lt;/span&gt;" settings&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 15px;"&gt;&amp;nbsp;&lt;span class="Apple-style-span" style="color: red;"&gt;&amp;nbsp;$&amp;nbsp;ps2pdf14 -dPDFSETTINGS=/prepress mypaper.ps&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 15px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 15px;"&gt;Conversion from PDF to PS and again back from PS to PDF my cause some formatting errors. I recommend you to double check your PDF file for formatting errors.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 15px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 15px;"&gt;3. Check PDF fonts using pdffonts command&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: sans-serif; font-size: 15px;"&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;&amp;nbsp;&amp;nbsp;$ pdffonts mypaper.pdf&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-6146046689525909100?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/6146046689525909100/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2011/03/embed-fonts-in-pdf-file-using-pdflatex.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6146046689525909100'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6146046689525909100'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2011/03/embed-fonts-in-pdf-file-using-pdflatex.html' title='Embed fonts in PDF file using PDFLaTex'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-2954489318594826691</id><published>2011-03-11T00:14:00.032+08:00</published><updated>2011-03-11T17:44:39.474+08:00</updated><title type='text'>LibXML Tutorial</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;In this blog post I will show some basic function of &lt;b&gt;libxml&lt;/b&gt;, which is a freely licensed C language XML library.&lt;br /&gt;This post gives an idea to beginners how to manipulate xml files using libxml library function. This post does not cover all XML API available in libxml, but it just gives an idea how to use libxml API's with the help of some basic functions.&lt;br /&gt;&lt;br /&gt;For detailed XML API list please visit official website of &lt;a href="http://xmlsoft.org/html/index.html"&gt;libxml&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;To Parse XML file:&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;xmlDocPtr doc; &amp;nbsp;// pointer to parse xml Document&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;// Parse XML file&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;doc = xmlParseFile(xmlFileName);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;// Check to see that the document was successfully parsed.&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;if (doc == NULL ) {&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;fprintf(stderr,"Error!. Document is not parsed successfully. \n");&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To Get the root Document:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #666666;"&gt;// Retrieve the document's root element.&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; cur = xmlDocGetRootElement(doc);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; // Check to make sure the document actually contains something&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; if (cur == NULL) {&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr,"Document is Empty\n");&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlFreeDoc(doc);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To Get the child Nodes of the current node element:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class="Apple-style-span" style="color: #999999;"&gt;cur = cur-&amp;gt;xmlChildrenNode;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To Search for an attribute:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;// search for "hash" attribute in the node pointed by cur&lt;br /&gt;&amp;nbsp;&lt;span class="Apple-style-span" style="color: #999999;"&gt;attr = xmlHasProp(cur, (const xmlChar*)"hash");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To add new Attribute:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;/&lt;span class="Apple-style-span" style="color: #999999;"&gt;*&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;* New Attribute "hash" is added to element node pointed by cur,&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;* &amp;nbsp;and default value of the attribute is set to "12345678"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;attr = xmlNewProp(cur, (const xmlChar*)"hash", (const xmlChar*)"12345678");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To Save XML document to Disk:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;xmlSaveFormatFile (xmlFileName, doc, 1);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Complete Example is given below:&lt;/b&gt;&lt;br /&gt;Suppose data.xml file is as follows:&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;lt;!DOCTYPE root SYSTEM "secPolicy2.dtd"&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;lt;root&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;nbsp; &amp;lt;url&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;host hash="12345678"&amp;gt;www.example1.com&amp;lt;/host&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sctxid&amp;gt;2&amp;lt;/sctxid&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;nbsp; &amp;lt;/url&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;nbsp; &amp;lt;url&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;host&amp;gt;www.example2.com&amp;lt;/host&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sctxid&amp;gt;2&amp;lt;/sctxid&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;nbsp; &amp;lt;/url&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;url&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;host&amp;gt;www.example3.com&amp;lt;/host&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sctxid&amp;gt;3&amp;lt;/sctxid&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;nbsp; &amp;lt;/url&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #999999;"&gt;&amp;lt;/root&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Following program reads the above xml file supplied as command line argument. &lt;br /&gt;It adds "hash" attribute with default value set to "12345678" if its not present in the "host" element node.&lt;br /&gt;&lt;br /&gt;&lt;div style="color: #666666;"&gt;/*&lt;/div&gt;&lt;div style="color: #666666;"&gt;&amp;nbsp;* Filename = xmlexample.c &lt;/div&gt;&lt;div style="color: #666666;"&gt;*/&lt;/div&gt;&lt;span style="color: #666666;"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;#include &amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;#include &amp;lt;libxml/xmlmemory.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;#include &amp;lt;libxml/parser.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;/* &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;* Parse URL Element Node in XML file&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;* &amp;lt;url&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;host hash="hash_val_of_hostname"&amp;gt;www.example.com&amp;lt;/host&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;sctxid&amp;gt;Integer&amp;lt;/sctxid&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;* &amp;lt;/url&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;void parseURL (xmlDocPtr doc, xmlNodePtr cur) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; xmlChar *key;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; xmlAttrPtr attr;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; // Get the childern Element Node of "url" node&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; cur = cur-&amp;gt;xmlChildrenNode;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; while (cur != NULL) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // check for "host" childern element node of "url" node&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((!xmlStrcmp(cur-&amp;gt;name, (const xmlChar *)"host"))) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; key = xmlNodeListGetString(doc, cur-&amp;gt;xmlChildrenNode, 1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr,"host: %s\n", key);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlFree(key);&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // search for "hash" attribute in the "host" node&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attr = xmlHasProp(cur, (const xmlChar*)"hash");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // if attr is not found then set it&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(attr == NULL){&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;* Add the Attribute and value of the attribute&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; attr = xmlNewProp(cur, (const xmlChar*)"hash", (const xmlChar*)"12345678");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Attribute is now set and has value.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;* Just retrieve the value and display it&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; key = xmlGetProp(cur, (const xmlChar*)"hash");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr,"hash: %s\n", key);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlFree(key);&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }else{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Attribute is available&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;* Just retrieve the value and display it&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; key = xmlGetProp(cur, (const xmlChar*)"hash");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr, "hash: %s\n", key);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlFree(key);&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } // end of IF loop " host"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // check for "sctxid" childern element node of "url" node&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((!xmlStrcmp(cur-&amp;gt;name, (const xmlChar *)"sctxid"))) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; key = xmlNodeListGetString(doc, cur-&amp;gt;xmlChildrenNode, 1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr,"sctxid: %s\n", key);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlFree(key);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } // end of If loop "sctxid"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur = cur-&amp;gt;next;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; } // end of While loop&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; return;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;} // end of parseURL function()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;/*&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;* Parsing the XML file and Reading the Element Nodes&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;static void parseDoc(char *xmlFileName) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; xmlDocPtr doc;&amp;nbsp; // pointer to parse xml Document&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; xmlNodePtr cur; // node pointer. It interacts with individual node&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; // Parse XML file &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; doc = xmlParseFile(xmlFileName);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; // Check to see that the document was successfully parsed.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; if (doc == NULL ) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr,"Error!. Document is not parsed successfully. \n");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; // Retrieve the document's root element.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; cur = xmlDocGetRootElement(doc);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; // Check to make sure the document actually contains something&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; if (cur == NULL) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr,"Document is Empty\n");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlFreeDoc(doc);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; /* We need to make sure the document is the right type. &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; * "root" is the root type of the documents used in user Config XML file &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; if (xmlStrcmp(cur-&amp;gt;name, (const xmlChar *) "root")) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fprintf(stderr,"Document is of the wrong type, root node != root");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlFreeDoc(doc);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; /* Get the first child node of cur.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; * At this point, cur points at the document root, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; * which is the element "root"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; cur = cur-&amp;gt;xmlChildrenNode;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; // This loop iterates through the elements that are children of "root"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; while (cur != NULL) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((!xmlStrcmp(cur-&amp;gt;name, (const xmlChar *)"url"))){&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parseURL (doc, cur);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur = cur-&amp;gt;next;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; /* Save XML document to the Disk&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; * Otherwise, you changes will not be reflected to the file.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; * Currently it's only in the memory&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; xmlSaveFormatFile (xmlFileName, doc, 1);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; /*free the document */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; xmlFreeDoc(doc);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; /*&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; * Free the global variables that may&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; * have been allocated by the parser.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlCleanupParser(); &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; return;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;} // end of XMLParseDoc function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;int main(int argc, char **argv) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; char *xmlFileName;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; if (argc &amp;lt;= 1) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("Usage: %s inputfile.xml\n", argv[0]);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return(0);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; // Get the file name from the argv[1]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; xmlFileName = argv[1];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; // Custom function to parse XML file&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; parseDoc (xmlFileName);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;&amp;nbsp; return (1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To compile the above program use following command:&lt;br /&gt;&lt;span style="color: #666666;"&gt;$ gcc `xml2-config --cflags --libs` -o xmlexample xmlexample.c &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To run the program, use following command:&lt;br /&gt;&lt;span style="color: #999999;"&gt;$ ./xmlexample data.xml&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-2954489318594826691?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/2954489318594826691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2011/03/libxml-tutorial.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2954489318594826691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2954489318594826691'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2011/03/libxml-tutorial.html' title='LibXML Tutorial'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-1292145495534442741</id><published>2011-02-28T22:47:00.002+08:00</published><updated>2011-08-22T13:00:52.738+08:00</updated><title type='text'>Mercurial HG HOWTO guide</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;In this tutorial I will cover the basic commands you will need to use mercurial.&lt;br /&gt;&lt;i&gt;hg help&lt;/i&gt; is your first friend and&amp;nbsp;&lt;a href="http://mercurial.selenic.com/wiki/"&gt;Mercurial Wiki&lt;/a&gt;&amp;nbsp;is your second.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Help for Command:&lt;/b&gt;&lt;br /&gt;$ hg help &amp;lt;command&amp;gt;&lt;br /&gt;or&lt;br /&gt;$ hg &amp;lt;command&amp;gt; - -help&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;b&gt;Commands to Create, Clone Repository&lt;/b&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;To make a new repository:&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;$ hg init &amp;lt;path&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;To copy a repository from an existing repository:&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;$ hg clone &amp;lt;sourcePath&amp;gt; &amp;nbsp;[&amp;lt;DestinationPath&amp;gt;]&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;To clone specific branch of the repository:&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;$ hg clone -r &amp;lt;barnchName&amp;gt; &amp;lt;sourcePath&amp;gt; [&amp;lt;destinationPath&amp;gt;]&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;To copy existing repository to a new locaiton:&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;$ hg clone . &amp;lt;newPath&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;To get changes from server repository and update working set:&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;$ hg pull -u&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;To get changes for specific branch from server repository:&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;$ hg pull -r &amp;lt;branchName&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;To see what changes will come in on a PULL command:&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;$ hg incoming&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;To publish changes to specific branch on server repository:&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;$ hg push -r &amp;lt;branchName&amp;gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;To see what changes will go out on a PUSH command:&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;$ hg outgoing&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Commands for Add, Remove, Rename, Copy Operation&lt;/b&gt;&lt;br /&gt;Add Specific file to repository:&lt;br /&gt;$ hg add &amp;lt;filename1, filename2, ...&amp;gt;&lt;br /&gt;&lt;br /&gt;To remove file from repository but don't delete from file system:&lt;br /&gt;$hg remove &amp;lt;filename1, filename2...&amp;gt;&lt;br /&gt;&lt;br /&gt;To remove file from repository and delete from file system as well"&lt;br /&gt;$ hg remove -f &amp;lt;filename1, filename2,...&amp;gt;&lt;br /&gt;&lt;br /&gt;To add all new files and remove all deleted files from repository:&lt;br /&gt;$ hg addremove&lt;br /&gt;&lt;br /&gt;To move or rename files in the repository:&lt;br /&gt;$ hg move &amp;lt;oldfilename&amp;gt; &amp;lt;newfilename&amp;gt;&lt;br /&gt;&lt;br /&gt;To copy files in the repository:&lt;br /&gt;$ hg copy &amp;lt;oldfilename&amp;gt; &amp;lt;newfilename&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Commands for Commit, Revert Changes&lt;/b&gt;&lt;br /&gt;To commit Changes to server repository:&lt;br /&gt;$ hg commit&lt;br /&gt;$ hg push&lt;br /&gt;&lt;br /&gt;To commit as a&amp;nbsp;particular&amp;nbsp;user:&lt;br /&gt;$ hg commit -u &amp;lt;username&amp;gt;&lt;br /&gt;&lt;br /&gt;To revert all changes in local repository:&lt;br /&gt;$ hg revert -a&lt;br /&gt;&lt;br /&gt;To revert specific changes in local repositroy&lt;br /&gt;$ hg revert &amp;lt;filename1, filename2, ..&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Commands to View Changes&lt;/b&gt;&lt;br /&gt;To view changes between working set on your local repository and repository tip:&lt;br /&gt;$ hg diff&lt;br /&gt;&lt;br /&gt;To view changes between working set on your local repository and specific revision:&lt;br /&gt;$ hg diff -r &amp;lt;revisionNumber&amp;gt;&lt;br /&gt;&lt;br /&gt;To view changes between two revisions:&lt;br /&gt;$ hg diff -r &amp;lt;revisionNumber&amp;gt; -r &amp;lt;revisionNumber&amp;gt;&lt;br /&gt;&lt;br /&gt;To check what are changes in working set:&lt;br /&gt;$ hg status&lt;br /&gt;&lt;br /&gt;To list all changesets:&lt;br /&gt;$ hg log&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Commands to Update Working Set&lt;/b&gt;&lt;br /&gt;To change working set to tip:&lt;br /&gt;$ hg pull&lt;br /&gt;$ hg up&lt;br /&gt;&lt;br /&gt;To change working set with discarding any current work:&lt;br /&gt;$ hg update -C&lt;br /&gt;&lt;br /&gt;To change working set to specific revision:&lt;br /&gt;$ hg update -r &amp;lt;revisionNumber&amp;gt;&lt;br /&gt;&lt;br /&gt;To change working set to specific branch:&lt;br /&gt;$ hg update -r &amp;lt;branchName&amp;gt;&lt;br /&gt;&lt;br /&gt;To see the list of branches&amp;nbsp;available&amp;nbsp;for merging:&lt;br /&gt;$ hg heads&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Commands for Handling tags and Branches&lt;/b&gt;&lt;br /&gt;To delete a tag:&lt;br /&gt;$ hg tag -r &amp;lt;tagtext&amp;gt;&lt;br /&gt;&lt;br /&gt;To tag a revision:&lt;br /&gt;$ hg tag [-r &amp;lt;revisionNumber] &amp;lt;tagtext&amp;gt;&lt;br /&gt;&lt;br /&gt;To list tags:&lt;br /&gt;$ hg tags&lt;br /&gt;&lt;br /&gt;To create new branch:&lt;br /&gt;$ hg branch &amp;lt;branchName&amp;gt;&lt;br /&gt;$ hg commit -m "New Branch created &amp;lt;branchName&amp;gt;"&lt;br /&gt;&lt;br /&gt;To delete a branch:&lt;br /&gt;$ hg commit - - close-branch &amp;lt;branchName&amp;gt;&lt;br /&gt;&lt;br /&gt;To see the list of branches available:&lt;br /&gt;$ hg branches&lt;br /&gt;&lt;br /&gt;&lt;b&gt;For HG Diff command setting in .hgrc file in /home/username folder:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;[diff]&lt;br /&gt;git=1&lt;br /&gt;showfunc=1&lt;br /&gt;unified=8&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Commands related to Patch:&lt;/b&gt;&lt;br /&gt;Generating a patch:&lt;br /&gt;$ hg diff &amp;nbsp;&amp;gt; &amp;nbsp;patchfilename&lt;br /&gt;&lt;br /&gt;Discarding all local changes:&lt;br /&gt;$ hg revert -a&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-1292145495534442741?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/1292145495534442741/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2011/02/mercurial-hg-howto-guide.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/1292145495534442741'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/1292145495534442741'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2011/02/mercurial-hg-howto-guide.html' title='Mercurial HG HOWTO guide'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-4383420739613793023</id><published>2011-02-03T19:51:00.011+08:00</published><updated>2011-08-24T10:53:57.316+08:00</updated><title type='text'>Ubuntu commands</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;I am user of Ubuntu. I am writing this post to help people like me who forgets the stuff they used before.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How to check Installed Ubuntu version and its Codename&lt;/b&gt;&lt;br /&gt;$&amp;nbsp;lsb_release -a&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How to check Disk Space:&lt;/b&gt;&lt;br /&gt;$ df -Th&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Video editor in Ubuntu:&lt;/b&gt;&lt;br /&gt;$ avidemux&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To Upgrade Ubuntu Version Online:&lt;/b&gt;&lt;br /&gt;Press ALT+F2 , then type "update-manager -d" without quotes and hit Enter key.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Mounting ISO image as a drive on Ubuntu:&lt;/b&gt;&lt;br /&gt;$ sudo mount -o loop &amp;nbsp;~/Desktop/filename.iso &amp;nbsp;/media/cdrom0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;HOWTO: Move the Minimize/Maximize/Close Buttons back the Right Side&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;Hit ALT - F2&lt;/span&gt;&lt;br /&gt;Type &lt;span class="Apple-style-span" style="color: #666666;"&gt;gconf-editor&lt;/span&gt;&lt;br /&gt;Go to the following:&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;apps --&amp;gt; metacity --&amp;gt; general&lt;/span&gt;&lt;br /&gt;Find the &lt;span class="Apple-style-span" style="color: #666666;"&gt;button_layout&lt;/span&gt; parameter, right mouse click, and select Edit Key&lt;br /&gt;Change the value to the following:&lt;br /&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;menu&lt;/span&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;:minimize,maximize,close&lt;/span&gt;&lt;br /&gt;Don't forget the colon on the left side of the text. "&lt;span class="Apple-style-span" style="color: orange;"&gt;men&lt;/span&gt;u" is not&amp;nbsp;necessary.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To change scree resolution from Command prompt:&lt;/b&gt;&lt;br /&gt;$ xrandr -s 1024*768&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How to change MAC address of NIC card in Ubuntu:&lt;/b&gt;&lt;br /&gt;Type following command either in &lt;span class="Apple-style-span" style="color: orange;"&gt;/etc/rc.local&lt;/span&gt; file or at command&amp;nbsp;prompt:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="color: purple;"&gt;ifconfig eth0 down&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: purple;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;ifconfig eth0 hw ether NEW_MAC_ADDR&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: purple;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;ifconfig eth0 up&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: purple;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;b&gt;To view or cancel print Job on &amp;nbsp;Unix Printer&lt;/b&gt;&lt;br /&gt;1. Login as a user or super-user to unix computer.&lt;br /&gt;2. Use "lpq -Pprinter" &amp;nbsp;command to view printer queue.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="color: #444444;"&gt;$ lpq -Ppsc011&lt;/span&gt;&lt;br /&gt;3. Use "lprm -Pprinter [user_id] to cancel your job&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="color: #444444;"&gt;$ lprm -Ppsc011 g0xyzqwe&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #444444;"&gt;&lt;b&gt;&lt;span style="color: black;"&gt;&amp;nbsp;Public key error while trying to run update command&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #444444;"&gt;&lt;span style="color: black;"&gt;$ sudo apt-get update&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #444444;"&gt;&lt;span style="color: black;"&gt;gives following error :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #666666;"&gt;W: GPG error: http://ppa.launchpad.net lucid Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY D2B5F4E7C3BB95BB&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="color: black;"&gt;Solution: Take last 8 characters in the key and run following command&lt;/div&gt;$ gpg --keyserver keyserver.ubuntu.com --recv-keys C3BB95BB&lt;br /&gt;$ gpg --export -armor C3BB95BB | sudo apt-key add -&lt;br /&gt;&lt;br /&gt;To download the key on another computer and then to run on your computer :&lt;br /&gt;$ gpg --keyserver keyserver.ubuntu.com --recv-keys C3BB95BB&lt;br /&gt;$&amp;nbsp; gpg --export -armor C3BB95BB &amp;gt; key.asc&lt;br /&gt;&lt;br /&gt;Now Copy key.asc file on your computer and run following command:&lt;br /&gt;$ cat key.asc | sudo apt-key add -&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To reflect the changes done in ~/.bashrc file without restarting your Terminal window:&lt;/b&gt;&lt;br /&gt;$ source ~/.bashrc&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To get Ubuntu Command prompt:&lt;/b&gt;&lt;br /&gt;press : &lt;span class="Apple-style-span" style="color: #666666;"&gt;Ctrl + Alt + F2&lt;/span&gt; &amp;nbsp; &amp;nbsp;or&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class="Apple-style-span" style="color: #666666;"&gt;Ctrl &amp;nbsp;+ &amp;nbsp;Alt &amp;nbsp;+ F5&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;and to get back GUI screen (Xserver):&lt;/b&gt;&lt;br /&gt;press: &amp;nbsp;&lt;span class="Apple-style-span" style="color: #666666;"&gt;Ctrl + Alt + F7&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What to do if ubuntu hangs? Or how to restart Xserver:&lt;/b&gt;&lt;br /&gt;press : &lt;span class="Apple-style-span" style="color: #666666;"&gt;Ctrl + Alt + Backspace&lt;/span&gt;&lt;br /&gt;or press: &lt;span class="Apple-style-span" style="color: #666666;"&gt;Alt + Backspace&lt;/span&gt;&lt;br /&gt;This usually restarts xserver. You need to login again to the system.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Using Bash History Effectively:&lt;/b&gt;&lt;br /&gt;Type the following command to get a list of all related commands with their history numbers:&lt;br /&gt;$ &lt;span class="Apple-style-span" style="color: #666666;"&gt;history | grep -i "search string"&lt;/span&gt;&lt;br /&gt;Once you've found the command you want, you can execute it specifically by its number&lt;br /&gt;$ &lt;span class="Apple-style-span" style="color: #666666;"&gt;!&amp;lt;history_command_number&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How to prevent Auto Locking the computer Screen:&lt;/b&gt;&lt;br /&gt;1. Open file &lt;span class="Apple-style-span" style="font-family: inherit;"&gt;"/etc/default/acpi-support" and comment following line:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="color: #666666;"&gt;# Comment this out to disable screen locking on resume&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; LOCK_SCREEN=true&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2. &amp;nbsp;Open "&lt;span class="Apple-style-span" style="border-collapse: collapse; line-height: 17px;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;System &amp;gt; Preferences &amp;gt; Screen Saver&lt;/span&gt;" and uncheck following option:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; color: #333333; font-family: 'Ubuntu Beta', UbuntuBeta, Ubuntu, 'Bitstream Vera Sans', 'DejaVu Sans', Tahoma, sans-serif; font-size: 14px; line-height: 17px;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="Apple-style-span" style="border-collapse: collapse; font-family: 'Ubuntu Beta', UbuntuBeta, Ubuntu, 'Bitstream Vera Sans', 'DejaVu Sans', Tahoma, sans-serif; font-size: 14px; line-height: 17px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;Lock screen when screensaver is active&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How to Merge Multiple PDF files into single PDF file:&lt;/b&gt;&lt;br /&gt;Steps:&lt;br /&gt;1. Install two pacakeges GhostScript and PDFtk tools.&lt;br /&gt;&amp;nbsp;&lt;span class="Apple-style-span" style="color: #666666;"&gt;$ sudo apt-get install gs pdftk&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2. Use following command to combine multiple files into single PDF file. The output file name is "singleCombinedPdfFile.pdf". The input file names are all files in the current directory, bcoz we used "*.pdf".&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;$ gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=singleCombinedPdfFile.pdf -dBATCH *.pdf&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you want to join PDF files in specific order then you can also use file names.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;$ gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=singleCombinedPdfFile.pdf -dBATCH 1.pdf 2.pdf 3.pdf&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #000103; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: #000103; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 22px;"&gt;Wireless Networks: &lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;b style="font-family: inherit;"&gt;"Wireless is disabled"&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;span style="color: #666666; font-family: inherit; font-size: small;"&gt;&lt;b&gt;$ rfkill&amp;nbsp; list all&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: x-small;"&gt;&lt;b style="font-family: inherit;"&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;b&gt;&lt;span style="font-size: x-small;"&gt;&lt;b style="font-family: inherit;"&gt; &lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="color: black; font-family: inherit; text-align: left;"&gt;You should see both the &lt;u&gt;soft&lt;/u&gt; blocked and &lt;u&gt;hard&lt;/u&gt; blocked  as   &lt;u&gt;no&lt;/u&gt;. If either of them is yes then the connection would not be enabled.   To enable type the following:&lt;/div&gt;&lt;div style="color: #666666; font-family: inherit; text-align: left;"&gt;&lt;/div&gt;&lt;div style="color: #666666; text-align: left;"&gt;&lt;b&gt; $ &lt;/b&gt;rfkill unblock wifi&lt;/div&gt;&lt;div style="color: #666666; text-align: left;"&gt;&lt;/div&gt;&lt;b&gt;&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="color: orange;"&gt;Hard blocked: yes&lt;/div&gt;This suggests that the wireless button is not switched on.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-4383420739613793023?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/4383420739613793023/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2011/02/ubuntu-commands.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/4383420739613793023'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/4383420739613793023'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2011/02/ubuntu-commands.html' title='Ubuntu commands'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-6733764544250255735</id><published>2010-12-14T14:21:00.001+08:00</published><updated>2010-12-14T14:22:26.325+08:00</updated><title type='text'>String matching in a file using  (sed/grep) commands in LINUX</title><content type='html'>&lt;b&gt;SED command using &lt;span class="Apple-style-span" style="color: purple;"&gt;&amp;amp;&lt;/span&gt; for match string:&lt;/b&gt;&lt;br /&gt;&lt;u&gt;The special character "&lt;span class="Apple-style-span" style="color: purple;"&gt;&amp;amp;&lt;/span&gt;" corresponds to the pattern found.&lt;/u&gt;&lt;br /&gt;Suppose the filename &lt;span class="Apple-style-span" style="color: #444444;"&gt;ch.txt&lt;/span&gt; contains following lines. &amp;nbsp;And we want for each function name to add (* ) brackets .&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;xpcom_ProcessNextEvent(int state);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;loc_wer_test(int state);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;Following command converts content in&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="color: #444444;"&gt;ch.txt&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;into following format and stored output in&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="color: #444444;"&gt;ch1.txt&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;file.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #783f04; font-family: 'Courier New', Courier, monospace;"&gt;$sed 's/[a-zA-Z]*_*[a-zA-Z]*_*[a-zA-Z]*(/int (*&amp;amp;)/' &amp;lt; ch.txt &amp;gt; &amp;nbsp;ch1.txt&lt;/span&gt;&lt;br /&gt;The Output of above command in ch1.txt file is as per follows:&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;int (*xpcom_ProcessNextEvent()int state);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #444444;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;int (*loc_wer_test()int state);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #444444;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Now we want to swap "()" bracket with ")(" from the&amp;nbsp;output&amp;nbsp;of above command. Following commands does that job.&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #783f04; font-family: 'Courier New', Courier, monospace;"&gt;$sed 's/()/)(/' &amp;nbsp;&amp;lt; ch1.txt &amp;gt; ch2.txt&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;int (*xpcom_ProcessNextEvent)(int state);&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #444444;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;int (*loc_wer_test)(int state);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #444444;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;You could also double a pattern, e.g. the first number of a line:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #783f04; font-family: 'Courier New', Courier, monospace;"&gt;$ echo "123 abc" | sed 's/[0-9]*/&amp;amp; &amp;amp;/'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;123 123 abc&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;In above command "123 abc" was input and output was "123 123 abc".&lt;/div&gt;&lt;div&gt;&lt;u&gt;You can have any number of "&amp;amp;" in the replacement string.&lt;/u&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;GREP command to copy a matching string line from a file to another file.&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Suppose &lt;span class="Apple-style-span" style="color: #666666;"&gt;input_filename&lt;/span&gt; contains following:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&amp;nbsp;&lt;span class="Apple-style-span" style="color: #999999;"&gt;//Escape() Function hook&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;int js_js_str_fun (...)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;.....&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;int js_str_fun2 (...)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;.....&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Using following command we can extract a line with function name:&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #783f04; font-family: 'Courier New', Courier, monospace;"&gt;$grep "int .*(.*)" &amp;nbsp;input_filename &amp;gt; output_filename&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #783f04; font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Above commands stores following output in &lt;span class="Apple-style-span" style="color: #999999;"&gt;output_filename&lt;/span&gt; file:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;int js_js_str_fun (...)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;int js_str_fun2 (...)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-6733764544250255735?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/6733764544250255735/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/12/string-matching-in-file-using-sedgrep.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6733764544250255735'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6733764544250255735'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/12/string-matching-in-file-using-sedgrep.html' title='String matching in a file using  (sed/grep) commands in LINUX'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-646709668238655045</id><published>2010-12-08T13:56:00.002+08:00</published><updated>2010-12-08T13:58:18.863+08:00</updated><title type='text'>Dynamic Lib using dlopen and dlsym</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;b&gt;dlopen&lt;/b&gt; system call loads dynamic library and returns handle to dynamic library. &amp;nbsp;If dlopen() fails it returns &lt;span class="Apple-style-span" style="color: #444444;"&gt;NULL&lt;/span&gt;.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;dlsym&lt;/b&gt; takes the library &lt;span class="Apple-style-span" style="color: #666666;"&gt;handle&lt;/span&gt; returnd by dlopen and &lt;span class="Apple-style-span" style="color: #666666;"&gt;symbol name &lt;/span&gt;as input, and&amp;nbsp;&amp;nbsp;returns the address where that symbol is loaded.&amp;nbsp;If the symbol is not found, dlsym returns &lt;span class="Apple-style-span" style="color: #444444;"&gt;NULL&lt;/span&gt;.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;dlerror&lt;/b&gt; returns NULL if no errors have occurred since initialization or since it was last called. (Calling dlerror() twice consecutively, will always result in the second call returning &lt;span class="Apple-style-span" style="color: #444444;"&gt;NULL&lt;/span&gt;.)&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/div&gt;#include &amp;lt;dlfcn.h&amp;gt;&lt;br /&gt;&lt;br /&gt;typedef void *(*func_t)(hooks *);&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// declare handle variable for dynamic library&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;void *handle;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;double (*cosine)(double);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// open the dynamic library&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;handle = dlopen ("libm.so", RTLD_LAZY);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (!handle) {&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fprintf (stderr, "%s\n", dlerror());&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;exit(1);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;func_t initializer_fn = (func_t)dlsym(handle, "initializer");&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if (initializer_fn) {&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // call function&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt; &amp;nbsp;(*initializer_fn)(this);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Initialize &lt;span class="Apple-style-span" style="color: #444444;"&gt;cosine&lt;/span&gt; with function pointer of "&lt;span class="Apple-style-span" style="color: #444444;"&gt;cos&lt;/span&gt;".&lt;br /&gt;&amp;nbsp;&amp;nbsp; cosine = dlsym(handle, "cos");&lt;br /&gt;&amp;nbsp;&amp;nbsp; // call "&lt;span class="Apple-style-span" style="color: #444444;"&gt;cos&lt;/span&gt;" function using&amp;nbsp;function&amp;nbsp;pointer&lt;br /&gt;&amp;nbsp;&amp;nbsp; fprintf (stderr, "%f\n", (*cosine)(2.0));&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;dlclose(handle);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return 0;&lt;br /&gt;} // end of main&lt;br /&gt;&lt;br /&gt;// functions defined in library file&lt;br /&gt;void initializer(hooks *libifc)&lt;br /&gt;{&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-646709668238655045?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/646709668238655045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/12/dynamic-lib-using-dlopen-and-dlsym.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/646709668238655045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/646709668238655045'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/12/dynamic-lib-using-dlopen-and-dlsym.html' title='Dynamic Lib using dlopen and dlsym'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-7130508949328838384</id><published>2010-12-06T23:27:00.000+08:00</published><updated>2010-12-06T23:27:42.353+08:00</updated><title type='text'>Firefox about: urls</title><content type='html'>Firefox can be tweak using &lt;span style="color: #444444;"&gt;about:config&lt;/span&gt; url, that allows to change user preferences.&lt;br /&gt;There are other &lt;span style="color: #444444;"&gt;about:&lt;/span&gt; urls listed below. I tested them on FF 3.5.3. &lt;br /&gt;&lt;br /&gt;about:blank&amp;nbsp; : shows a blank web page.&lt;br /&gt;about:buildconfig&amp;nbsp; : shows mozilla build options&lt;br /&gt;about:cache&lt;br /&gt;about:cache?device=memory&amp;nbsp; : Lists memory cache entries&lt;br /&gt;about:config&amp;nbsp; : modifies user preferences.&lt;br /&gt;about:credits&amp;nbsp; : Shows an alphabetical list of mozilla contributors&lt;br /&gt;about:logo&amp;nbsp; : shows mozilla logo&lt;br /&gt;about:plugins&amp;nbsp; : shows all installed plugins &lt;br /&gt;about:crashes&amp;nbsp; : shows Firefox crash reports if any&lt;br /&gt;&lt;br /&gt;Other about: URLs showing some messages:&lt;br /&gt;about:mozilla&lt;br /&gt;about:robots&lt;br /&gt;about:privatebrowsing&lt;br /&gt;about:sessionrestore&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-7130508949328838384?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/7130508949328838384/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/12/firefox-about-urls.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/7130508949328838384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/7130508949328838384'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/12/firefox-about-urls.html' title='Firefox about: urls'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-7259982388401552981</id><published>2010-12-03T17:32:00.004+08:00</published><updated>2010-12-06T23:14:18.799+08:00</updated><title type='text'>Firefox Extension and Web Page Script Execution</title><content type='html'>&lt;b&gt;To access Web page Document from Extension&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;webpageDocument = top.window.content.document;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To Execute Web Page defined function from Firefox Extension&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var currentWindow = wm.getMostRecentWindow('navigator:browser').getBrowser().contentWindow;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var sandbox = new Components.utils.Sandbox(SandboxURL);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// __.proto__ &amp;nbsp;hack removes need of using window.a, window.alert()&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;sandbox.__proto__ = currentWindow.wrappedJSObject;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// &amp;nbsp;assume web page script defines variable "&lt;span class="Apple-style-span" style="color: #666666;"&gt;a&lt;/span&gt;"&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var pageResult = Components.utils.evalInSandbox("alert(a);", sandbox);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;dump("\n\n Web &amp;nbsp;page Function execution Result = " + pageResult);&lt;br /&gt;&lt;br /&gt;&lt;b&gt;In FF Extension to execute a Script in a Sandbox and allowing Extension function to be accessed by Sandbox object&lt;/b&gt;&lt;br /&gt;Following code I also added to MDN [1]. &lt;br /&gt;&lt;br /&gt;&amp;nbsp;// Chrome (FF Extension) custom Functions:&lt;br /&gt;function sandboxAlert(msg){&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;dump("\n Inside sandboxAlert");&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;msg = XPCSafeJSObjectWrapper(msg);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;dump("\n msg = " + msg);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// variable declared in Chrome code&lt;br /&gt;var tempval = 10; &lt;br /&gt;&lt;br /&gt;function sandboxFun1(){&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return tempval;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// Chrome (Firefox Extension) code&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// create sandbox enviornment to execute script.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// SandboxURL is required for XHR requests. Same domain are allowed.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var sandbox = new Components.utils.Sandbox(SandboxURL);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;sandbox.y = 5; &amp;nbsp;// insert property 'y' with value 5 into global scope.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var scriptText = "var x = 2 + sandboxFun1(); var k = y + 15; sandboxAlert('Testing'); x + 3";&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// // include chrome function into sandbox context.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;sandbox.importFunction(sandboxFun1);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;sandbox.importFunction(sandboxAlert);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// // execute script into sandbox object&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var sandboxResult = Components.utils.evalInSandbox(scriptText, sandbox);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;References:&lt;/b&gt;&lt;br /&gt;1. Mozilla FF Extension&amp;nbsp;&lt;a href="https://developer.mozilla.org/en/Components.utils.evalInSandbox"&gt;evalInSandbox&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-7259982388401552981?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/7259982388401552981/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/12/firefox-extension.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/7259982388401552981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/7259982388401552981'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/12/firefox-extension.html' title='Firefox Extension and Web Page Script Execution'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-3949914309284336439</id><published>2010-11-30T15:24:00.000+08:00</published><updated>2010-11-30T15:24:36.767+08:00</updated><title type='text'>Upgrading Ubuntu 10.04 (Lucid) to 10.10 (Maverick)</title><content type='html'>Steps to upgrade ubuntu v10.04 to v10.10 are very simple.&lt;br /&gt;&lt;b&gt;Option A.&lt;/b&gt; Using &lt;span class="Apple-style-span" style="color: orange;"&gt;Update Manager&lt;/span&gt; (System -&amp;gt; Adminstration -&amp;gt; Update Manager)&lt;br /&gt;&amp;nbsp;1. Start &lt;span class="Apple-style-span" style="color: blue;"&gt;Update Manager&lt;/span&gt;.&lt;br /&gt;&amp;nbsp;2. Click on &lt;span class="Apple-style-span" style="color: blue;"&gt;Settings&lt;/span&gt; button&lt;br /&gt;&amp;nbsp;3. Choose the &lt;span class="Apple-style-span" style="color: blue;"&gt;Update&lt;/span&gt; Tab in &lt;span class="Apple-style-span" style="color: orange;"&gt;Software Sources&lt;/span&gt;. &lt;br /&gt;&amp;nbsp;4. Select &lt;span class="Apple-style-span" style="color: blue;"&gt;Normal releases&lt;/span&gt; in the &lt;span class="Apple-style-span" style="color: #666666;"&gt;Show new distribution releases:&lt;/span&gt; drop-down menu and click on &lt;span class="Apple-style-span" style="color: #444444;"&gt;Close &lt;/span&gt;button.&lt;br /&gt;&amp;nbsp;5. Back in &lt;span class="Apple-style-span" style="color: blue;"&gt;Update Manager&lt;/span&gt;&amp;nbsp;&amp;nbsp;and click on &lt;span class="Apple-style-span" style="color: blue;"&gt;Check&lt;/span&gt; Button.&lt;br /&gt;&amp;nbsp;6. Update Manager shows the new release is&amp;nbsp;available. &amp;nbsp;Click on &lt;span class="Apple-style-span" style="color: blue;"&gt;Upgrade&lt;/span&gt; button to start new distribution upgrade on your system.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Option B.&lt;/b&gt;&lt;br /&gt;&amp;nbsp;1. Open &lt;span class="Apple-style-span" style="color: blue;"&gt;Software Sources&lt;/span&gt; (System -&amp;gt; Adminstration -&amp;gt; Software Sources)&lt;br /&gt;&amp;nbsp;2.&amp;nbsp;Choose the&amp;nbsp;&lt;span class="Apple-style-span" style="color: blue;"&gt;Update&lt;/span&gt;&amp;nbsp;Tab in&amp;nbsp;&lt;span class="Apple-style-span" style="color: orange;"&gt;Software Sources&lt;/span&gt;. &lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;3. Select&amp;nbsp;&lt;span class="Apple-style-span" style="color: blue;"&gt;Normal releases&lt;/span&gt;&amp;nbsp;in the&amp;nbsp;&lt;span class="Apple-style-span" style="color: #666666;"&gt;Show new distribution releases:&lt;/span&gt;&amp;nbsp;drop-down menu and click on&amp;nbsp;&lt;span class="Apple-style-span" style="color: #444444;"&gt;Close&amp;nbsp;&lt;/span&gt;button.&amp;nbsp;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;4. Open &lt;span class="Apple-style-span" style="color: blue;"&gt;Update Manager&lt;/span&gt; (System -&amp;gt; Adminstration -&amp;gt; Update Manager) and click on&amp;nbsp;&lt;span class="Apple-style-span" style="color: blue;"&gt;Check&lt;/span&gt;&amp;nbsp;Button.&amp;nbsp;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&amp;nbsp;5. Update Manager shows the new release is&amp;nbsp;available. &amp;nbsp;Click on&amp;nbsp;&lt;span class="Apple-style-span" style="color: blue;"&gt;Upgrade&lt;/span&gt;&amp;nbsp;button to start new distribution upgrade on your system.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;Hope this simple tutorial helps!&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-3949914309284336439?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/3949914309284336439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/11/upgrading-ubuntu-1004-lucid-to-1010.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/3949914309284336439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/3949914309284336439'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/11/upgrading-ubuntu-1004-lucid-to-1010.html' title='Upgrading Ubuntu 10.04 (Lucid) to 10.10 (Maverick)'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-508162501033474821</id><published>2010-11-15T16:34:00.000+08:00</published><updated>2010-11-15T16:34:10.792+08:00</updated><title type='text'>Food to control Abdominal Fat</title><content type='html'>It's better to know which food is good for healthy and provides nutrition to our body, so that we can control abdominal fat. &lt;br /&gt;First I will describe vegetables that helps against fighting abdominal fat, then I will explains fruits useful for the same purpose. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;A. Vegetables&lt;/b&gt;&lt;br /&gt;1. &lt;b&gt;Broccoli&lt;/b&gt;:&amp;nbsp;Broccoli is high in vitamins C, K, and A, as well as dietary fiber.&amp;nbsp;Broccoli is also an excellent source of indole-3-carbinol, a chemical which boosts DNA repair in cells and appears to block the growth of cancer cells. Broccoli is a potent modulator of the innate immune response system with anti-viral, anti-bacterial and anti-cancer activity.&lt;br /&gt;2.&amp;nbsp;&lt;b&gt;Tomatoes&lt;/b&gt;:&amp;nbsp;&amp;nbsp;It contains &lt;i&gt;lycopene&lt;/i&gt;, one of the most powerful natural antioxidants. Tomato consumption has been associated with decreased risk of &lt;u&gt;breast cancer&lt;/u&gt;, &lt;u&gt;head and neck cancers&lt;/u&gt; and might be strongly protective against neurodegenerative diseases.&lt;br /&gt;3. &lt;b&gt;Cauliflower&lt;/b&gt;:&amp;nbsp;Cauliflower is low in fat, high in dietary fiber, folate, water and vitamin C, possessing a very high nutritional density. &amp;nbsp;Cauliflower is a source of indole-3-carbinol, a chemical which boosts DNA repair in cells and appears to block the growth of cancer cells.&lt;br /&gt;4. &lt;b&gt;Cabbage&lt;/b&gt;:&amp;nbsp;Cabbage is an excellent source of vitamin C. It also contains significant amounts of glutamine, an amino acid that has anti-inflammatory properties.&amp;nbsp;Fresh cabbage juice has been shown to promote rapid healing of &lt;u&gt;peptic ulcers&lt;/u&gt;.&amp;nbsp;Cabbage can also be included in dieting programs, as it is a low calorie food.&lt;br /&gt;5. &lt;b&gt;Mushroom&lt;/b&gt;: Mushrooms are high in dietary fiber, protein, and vitamins such as thiamine, riboflavin, niacin, biotin, cobalamins, and ascorbic acid.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;B. Fruits&lt;/b&gt;&lt;br /&gt;1. &amp;nbsp;&lt;b&gt;Apple&lt;/b&gt;: Apples may reduce the risk of colon cancer, prostate cancer and lung cancer.[53] Compared to many other fruits and vegetables, apples contain relatively low amounts of vitamin C, but are a rich source of other antioxidant compounds.&amp;nbsp;However, apple seeds are mildly poisonous, containing a small amount of amygdalin, a cyanogenic glycoside; it usually is not enough to be dangerous to humans, but can deter birds.&lt;br /&gt;2. &amp;nbsp;&lt;b&gt;Pineapple&lt;/b&gt;:&amp;nbsp;Pineapple is a good source of manganese, and also contains significant amounts of vitamin C, and vitamin B1.&amp;nbsp;Consumers of pineapple have claimed that pineapple has benefits for some intestinal disorders, and others believe it serves as a pain reliever; still others claim that it helps to induce childbirth when a baby is overdue.&lt;br /&gt;3. &amp;nbsp;&lt;b&gt;Orange&lt;/b&gt;: Oranges contains carbohydrates and is a good source of&amp;nbsp;dietary&amp;nbsp;fibers.&lt;br /&gt;&lt;br /&gt;Above list may not be complete. But it gives some awareness to readers that use of fruits and&amp;nbsp;vegetables&amp;nbsp;in our daily diet not only provides nutritions but also dietary fiber to fight against abdominal fat.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-508162501033474821?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/508162501033474821/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/11/food-to-control-abdominal-fat.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/508162501033474821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/508162501033474821'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/11/food-to-control-abdominal-fat.html' title='Food to control Abdominal Fat'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-5922063456064828584</id><published>2010-11-04T17:16:00.006+08:00</published><updated>2011-04-23T00:55:01.083+08:00</updated><title type='text'>Examples of Creating Map of Maps in C++ or Multilevel Maps in C++</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;To create map of map in C++ is very simple. &lt;br /&gt;Map is a sorted associative array of unique keys and associated data. The elements of the map are internally sorted from lowest to highest key value.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: #38761d;"&gt;Example 1:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;//Program to create multi level map in C++&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;#include &amp;lt;map&amp;gt; // header file needed for to use MAP STL&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;int main(void)&lt;br /&gt;{ &lt;br /&gt;//Define multilevel map. map within a map. &lt;br /&gt;map&amp;lt;int, map&amp;lt;int,char&amp;gt; &amp;gt; myMap;&lt;br /&gt;myMap[1][1] = 'A';&lt;br /&gt;myMap[1][2] = 'B';&lt;br /&gt;myMap[2][1] = 'C';&lt;br /&gt;myMap[2][2] = 'D';&lt;br /&gt;&lt;br /&gt;cout &amp;lt;&amp;lt; "[1][1] = "  &amp;lt;&amp;lt; myMap[1][1] &amp;lt;&amp;lt; endl;&lt;br /&gt;cout &amp;lt;&amp;lt; "[1][2] = "  &amp;lt;&amp;lt; myMap[1][2] &amp;lt;&amp;lt; endl;&lt;br /&gt;cout &amp;lt;&amp;lt; "[2][1] = "  &amp;lt;&amp;lt; myMap[2][1] &amp;lt;&amp;lt; endl;&lt;br /&gt;cout &amp;lt;&amp;lt; "[2][2] = "  &amp;lt;&amp;lt; myMap[2][2] &amp;lt;&amp;lt; endl;&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//Save a file as multimap.cpp&lt;br /&gt;&lt;br /&gt;To Compile and execute it on Ubuntu use following commands:&lt;br /&gt;$ g++ multimap.cpp -o multimap&lt;br /&gt;$ ./multimap&lt;br /&gt;&lt;br /&gt;[1][1] = A&lt;br /&gt;[1][2] = B&lt;br /&gt;[2][1] = C&lt;br /&gt;[2][2] = D&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: #38761d;"&gt;Example 2:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;#include &amp;lt;string&amp;gt;&lt;br /&gt;#include &amp;lt;map&amp;gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;typedef map&amp;lt;int, string&amp;gt; innerMap;&lt;br /&gt;typedef map&amp;lt;double, innerMap&amp;gt; mainMap;&lt;br /&gt;&lt;br /&gt;mainMap m;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void print()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;map&amp;lt;double, innerMap &amp;gt;::iterator it;&lt;br /&gt;&amp;nbsp;&amp;nbsp;map&amp;lt;int, string&amp;gt;::iterator inner_it;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;for ( it=m.begin() ; it != m.end(); it++ ) {&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; "\n\nNew element\n" &amp;lt;&amp;lt; (*it).first &amp;lt;&amp;lt; endl;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for( inner_it=(*it).second.begin(); inner_it != (*it).second.end(); inner_it++)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; (*inner_it).first &amp;lt;&amp;lt; " =&amp;gt; " &amp;lt;&amp;lt; (*inner_it).second &amp;lt;&amp;lt; endl;&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main (int argc, char *argv[])&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// First insert an element into outermap&lt;br /&gt;&amp;nbsp;&amp;nbsp;m.insert (make_pair (2.4, innerMap ()));&lt;br /&gt;&amp;nbsp;&amp;nbsp;// Now insert elements into innermap&lt;br /&gt;&amp;nbsp;&amp;nbsp;m[2.4].insert (make_pair (2, "two"));&lt;br /&gt;&amp;nbsp;&amp;nbsp;m[2.4].insert (make_pair (5, "five"));&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// First insert an element into outermap&lt;br /&gt;&amp;nbsp;&amp;nbsp;m.insert (make_pair (0.6, innerMap ()));&lt;br /&gt;&amp;nbsp;&amp;nbsp;// Now insert elements into innermap&lt;br /&gt;&amp;nbsp;&amp;nbsp;m[0.6].insert (make_pair (5, "five"));&lt;br /&gt;&amp;nbsp;&amp;nbsp;m[0.6].insert (make_pair (1, "one"));&lt;br /&gt;&amp;nbsp;&amp;nbsp;m[0.6].insert (make_pair (2, "two"));&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// print elements in the mainMap&lt;br /&gt;&amp;nbsp;&amp;nbsp;print();&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;br /&gt;}&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Output of above program (Example 2):&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;New element&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;0.6&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;1 =&amp;gt; one&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;2 =&amp;gt; two&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;5 =&amp;gt; five&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;New element&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;2.4&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;2 =&amp;gt; two&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;5 =&amp;gt; five&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: #38761d;"&gt;Example 3: Uses "multimap" STL&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;Note that, "mutimap" STL does not support &lt;b&gt;&lt;span class="Apple-style-span" style="color: #38761d;"&gt;[]&lt;/span&gt;&lt;/b&gt;, therefore we cannot use syntax "m[].insert( make_pair())" &amp;nbsp;we used in Example 2 to insert element.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;#include &amp;lt;string&amp;gt;&lt;br /&gt;#include &amp;lt;map&amp;gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;typedef multimap&amp;lt;int, string&amp;gt; innerMap;&lt;br /&gt;multimap&amp;lt;double, innerMap&amp;gt; mainMap;&lt;br /&gt;&lt;br /&gt;void print()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;multimap&amp;lt;double, innerMap &amp;gt;::iterator it;&lt;br /&gt;&amp;nbsp;&amp;nbsp;multimap&amp;lt;int, string&amp;gt;::iterator inner_it;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;for ( it=mainMap.begin() ; it != mainMap.end(); it++ ) {&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; "\n\nNew element\n" &amp;lt;&amp;lt; (*it).first &amp;lt;&amp;lt; endl;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for( inner_it=(*it).second.begin(); inner_it != (*it).second.end(); inner_it++)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;cout &amp;lt;&amp;lt; (*inner_it).first &amp;lt;&amp;lt; " =&amp;gt; " &amp;lt;&amp;lt; (*inner_it).second &amp;lt;&amp;lt; endl;&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void insert1(multimap&amp;lt;double, innerMap &amp;gt;::iterator it)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;it-&amp;gt;second.insert (make_pair (2, "two"));&lt;br /&gt;&amp;nbsp;&amp;nbsp;it-&amp;gt;second.insert (make_pair (5, "five"));&lt;br /&gt;&amp;nbsp;&amp;nbsp;it-&amp;gt;second.insert (make_pair (2, "two"));&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main (int argc, char *argv[])&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;multimap&amp;lt;double, innerMap &amp;gt;::iterator it;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// First insert an element into outermap&lt;br /&gt;&amp;nbsp;&amp;nbsp;it = mainMap.insert (make_pair (2.4, innerMap ()));&lt;br /&gt;&amp;nbsp;&amp;nbsp;// Now insert elements into innermap&lt;br /&gt;&amp;nbsp;&amp;nbsp;insert1(it);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// First insert an element into outermap&lt;br /&gt;&amp;nbsp;&amp;nbsp;it = mainMap.insert (make_pair (0.6, innerMap ()));&lt;br /&gt;&amp;nbsp;&amp;nbsp;// Now insert elements into innermap&lt;br /&gt;&amp;nbsp;&amp;nbsp;it-&amp;gt;second.insert (make_pair (5, "five"));&lt;br /&gt;&amp;nbsp;&amp;nbsp;it-&amp;gt;second.insert (make_pair (1, "one"));&lt;br /&gt;&amp;nbsp;&amp;nbsp;it-&amp;gt;second.insert (make_pair (2, "two"));&lt;br /&gt;&amp;nbsp;&amp;nbsp;it-&amp;gt;second.insert (make_pair (5, "five"));&lt;br /&gt;&amp;nbsp;&amp;nbsp;it-&amp;gt;second.insert (make_pair (5, "five"));&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// print elements in the mainMap&lt;br /&gt;&amp;nbsp;&amp;nbsp;print();&amp;nbsp;&amp;nbsp; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #38761d; font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;Output of the above program (Example 3):&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;New element&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;0.6&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;1 =&amp;gt; one&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;2 =&amp;gt; two&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;5 =&amp;gt; five&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;5 =&amp;gt; five&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;5 =&amp;gt; five&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;New element&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;2.4&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;2 =&amp;gt; two&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;2 =&amp;gt; two&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;5 =&amp;gt; five&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-5922063456064828584?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/5922063456064828584/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/11/multilevel-map-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/5922063456064828584'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/5922063456064828584'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/11/multilevel-map-in-c.html' title='Examples of Creating Map of Maps in C++ or Multilevel Maps in C++'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-1990954364675782754</id><published>2010-11-03T01:26:00.004+08:00</published><updated>2010-11-04T17:10:59.094+08:00</updated><title type='text'>Creating C++ Component / Interface using Mozilla Build System</title><content type='html'>This is a step-by-step guide to create C++ Component / Interface, build using Mozilla build system, and test our component using extension and web page. I tested this on Ubuntu 10.04.&lt;br /&gt;&lt;br /&gt;1. Create a directory with the name of your extension under "/mozilla/extensions/" directory. Use only lowercase letter. Let say we created a directory "krpextension"&lt;br /&gt;&lt;br /&gt;2. Create "Makefile.in" in krpextension directory.&lt;br /&gt;#/* Makefile.in under /mozilla/extensions/krpextension directory */&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;DEPTH		= ../..&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;topsrcdir	= @top_srcdir@&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;srcdir		= @srcdir@&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;VPATH		= @srcdir@&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;include $(DEPTH)/config/autoconf.mk&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;MODULE = krpextension&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;DIRS		= public src&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;XPI_NAME		= krpextension&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;INSTALL_EXTENSION_ID	= krpextension@mycompany.com&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;XPI_PKGNAME		= krpextension&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;USE_EXTENSION_MANIFEST = 1&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;DIST_FILES = install.rdf&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;include $(topsrcdir)/config/rules.mk&lt;/span&gt;&lt;br /&gt;#/* End of Makefile */&lt;br /&gt;&lt;br /&gt;3. Create two subdirectories in "krpextension" directory namely "public" and "src". Public subdirectory to hold our ".idl" file and src subdirectory to hold component header and implementation files. &amp;nbsp;Each subdirectory in-turn contains its own makefile. Step 4 contains Makefile for "public" directory and Step 5 contains Makefile for "src" directory.&lt;br /&gt;&lt;br /&gt;4. change directory to "public" and create "Makefile.in"&lt;br /&gt;#/* Makefile.in under "/mozilla/extensions/krpextension/public" directory */&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;DEPTH&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;= ../../..&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;topsrcdir&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;= @top_srcdir@&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;srcdir&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;= @srcdir@&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;VPATH&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;= @srcdir@&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;include $(DEPTH)/config/autoconf.mk&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;MODULE&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;= krpextension&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;XPIDL_MODULE&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;= krpextension&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;XPI_NAME = krpextension&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;XPIDLSRCS&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;= \&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;krpIComponent.idl \&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;$(NULL)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;include $(topsrcdir)/config/rules.mk&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;#/* end of Makefile */&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;5. change directory to "src" and create "Makefile.in"&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;#/* Makefile.in under "/mozilla/extensions/krpextension/src" directory */&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;DEPTH&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;= ../../..&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;topsrcdir&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;= @top_srcdir@&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;srcdir&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;= @srcdir@&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;VPATH&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;= @srcdir@&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;include $(DEPTH)/config/autoconf.mk&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;IS_COMPONENT = 1&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;MODULE = krpextension&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;LIBRARY_NAME = &amp;nbsp;krpExtension&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;USE_STATIC_LIBS = 1&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;XPI_NAME = krpextension&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;REQUIRES&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;= xpcom \&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt; &amp;nbsp;string \&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt; &amp;nbsp;$(NULL)&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;CPPSRCS&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;= \&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt; &amp;nbsp;krpComponent.cpp \&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt; &amp;nbsp;krpExtension.cpp \&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt; &amp;nbsp;$(NULL)&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;include $(topsrcdir)/config/rules.mk&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;EXTRA_DSO_LDOPTS += \&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;$(XPCOM_GLUE_LDOPTS) \&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;$(NSPR_LIBS) \&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;$(NULL)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;#/* end of Makefile */&lt;/div&gt;&lt;br /&gt;&lt;div&gt;6. Change to "public" sub-directory under "/mozilla/extension/krpextension"&amp;nbsp;and now we will create our own Interface&amp;nbsp;definition&amp;nbsp;file (.idl) in public directory, Let say "krpIComponent.idl", if you used other name than "krpIComponent" then replace each&amp;nbsp;occurring&amp;nbsp;of &amp;nbsp;krpIComponent with your custom name of Interface.&amp;nbsp;&lt;/div&gt;&lt;div&gt;/* krpIComponent.idl file in public subdirectory */&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;stdio.h&gt;&lt;/stdio.h&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "nsISupports.idl"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;[scriptable, uuid(1c0856f7-ed61-471e-9dac-442565a5d1d2)]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;interface krpIComponent : nsISupports&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;unsigned long long Add(in unsigned long long num1, in unsigned long long num2);&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;unsigned long long Sub(in unsigned long long num1, in unsigned long long num2);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;};&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;/* End of krpIComponent.idl file */&lt;/div&gt;&lt;div&gt;&lt;br /&gt;7. Change to src sub-directory under /mozilla/extension/krpextension, now we will create header and implementation file for our interface.&lt;/div&gt;&lt;div&gt;/* krpComponent.h &amp;nbsp; header file for our component */&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#ifndef __KRPCOMPONENT_H__&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#define __KRPCOMPONENT_H__&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include &amp;nbsp;&amp;lt;stdio.h&amp;gt;&lt;stdio.h&gt;&lt;/stdio.h&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;unistd.h&gt;&lt;/unistd.h&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include &amp;lt;unistd.h&amp;gt;&lt;stdlib.h&gt;&lt;/stdlib.h&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "krpIComponent.h"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "nsIObserverService.h"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "nsServiceManagerUtils.h"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#define KRPCOMPONENT_CLASSNAME "krpcomponent"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#define KRPCOMPONENT_CID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{ /* 1c0856f7-ed61-471e-9dac-442565a5d1d2 */ &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;0x1C0856F7, 0xED61, 0x471E, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; \&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;{0x9D, 0xAC, 0x44, 0x25, 0x65, 0xA5, 0xD1, 0xD2} &amp;nbsp; &amp;nbsp; &amp;nbsp;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#define KRPCOMPONENT_CONTRACTID "@mycompany.com/krpcomponent;1"&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/* Header file */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;class krpComponent: public krpIComponent&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;public:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;NS_DECL_ISUPPORTS&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;NS_DECL_KRPICOMPONENT&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;krpComponent();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;private:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;~krpComponent();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;protected:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#endif // __KRPCOMPONENT_H__&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;/* End of krpComponent.h header file */&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;/*krpComponent.cpp C++ Implementation file of our component */&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "krpComponent.h"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/* Implementation file */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;NS_IMPL_ISUPPORTS1(krpComponent, krpIComponent)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;krpComponent::krpComponent()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;/* member initializers and constructor code */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;krpComponent::~krpComponent()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;/* destructor code */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/* unsigned long long Add (in unsigned long long num1, in unsigned long long num2); */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;NS_IMETHODIMP krpComponent::Add(PRUint64 num1, PRUint64 num2, PRUint64 *_retval NS_OUTPARAM)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;*_retval = num1 + num2;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return NS_OK;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/* unsigned long long Sub (in unsigned long long num1, in unsigned long long num2); */&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;NS_IMETHODIMP krpComponent::Sub(PRUint64 num1, PRUint64 num2, PRUint64 *_retval NS_OUTPARAM)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;if(num1 &amp;gt; num2)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;*_retval = num1 - num2;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;*_retval = num2 - num1;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;return NS_OK;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;/* End of implementation class of our component. */&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;8. Now we will create module&amp;nbsp;definition&amp;nbsp;file lets say "krpExtension.cpp". If you use other name then replace all&amp;nbsp;occurrences&amp;nbsp;of krpExtension or krpExtension.cpp with your custom name.&amp;nbsp;&lt;/div&gt;&lt;div&gt;/*krpExtension.cpp Module&amp;nbsp;definition&amp;nbsp;file */&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "nsXPCOM.h"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "nsIGenericFactory.h"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;* Components to be registered&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "krpComponent.h"&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;NS_GENERIC_FACTORY_CONSTRUCTOR(krpComponent)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;//----------------------------------------------------------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;static const nsModuleComponentInfo components[] =&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;KRPCOMPONENT_CLASSNAME,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;KRPCOMPONENT_CID,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;KRPCOMPONENT_CONTRACTID,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;krpComponentConstructor&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;},&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;NS_IMPL_NSGETMODULE(krpExtension, components)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;/* end of krpExtension.cpp File */&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;9. Now to integrate our component into Extension, we will create a custom extension. In "/mozilla/extensions/krpextension" create "install.rdf" file.&lt;/div&gt;&lt;div&gt;/*install.rdf file contents */&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;rdf &lt;="" font="" xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&gt;&lt;/rdf&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&amp;lt;?xml version="1.0" encoding="UTF-8"?&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666; white-space: pre;"&gt;	&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; xmlns:em="http://www.mozilla.org/2004/em-rdf#"&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;Description about="urn:mozilla:install-manifest"&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;em:id&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;krpextension@mycompany.com&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/em:id&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;em:version&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;0.1&amp;lt;/em:version&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666; white-space: pre;"&gt;	&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;em:targetApplication&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;!-- Firefox --&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;Description&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;em:id&amp;gt;{ec8030f7-c20a-464f-9b0e-13a3a9e97384}&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/em:id&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;em:minVersion&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;3.0&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/em:minVersion&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;em:maxVersion&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;3.6.*&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/em:maxVersion&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/Description&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/em:targetApplication&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666; white-space: pre;"&gt;	&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;!-- front-end metadata --&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;em:name&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;My First Interface Extension&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/em:name&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;em:description&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;Just an FF Interface Example.&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/em:description&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;em:creator&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;kailas&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/em:creator&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;em:homepageURL&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;http://kailaspatil.blogspot.com/&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/em:homepageURL&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/Description&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;/RDF&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;/*install.rdf file ends here */&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;10. Now create another file "jar.mn" in&amp;nbsp;"/mozilla/extensions/krpextension" directory.&lt;/div&gt;&lt;div&gt;/* jar.mn file contents */&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;krpextension.jar:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;% content krpextension %content/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;% locale krpextension en-US %locale/en-US/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;% skin krpextension classic/1.0 %skin/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;% overlay chrome://browser/content/browser.xul &amp;nbsp;chrome://krpextension/content/ff-overlay.xul&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;content/overlay.js&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;			&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;(chrome/content/overlay.js)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;content/ff-overlay.xul&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(chrome/content/ff-overlay.xul)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;content/ff-overlay.js&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;			&lt;/span&gt;(chrome/content/ff-overlay.js)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;content/about.xul&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;			&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(chrome/content/about.xul)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;locale/en-US/overlay.dtd&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(chrome/locale/en-US/overlay.dtd)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;locale/en-US/about.dtd&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;		&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(chrome/locale/en-US/overlay.dtd)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;locale/en-US/overlay.properties&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;	&lt;/span&gt;(chrome/locale/en-US/overlay.properties)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;skin/overlay.css&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;			&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(chrome/skin/overlay.css)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;/* end of jar.mn file */&lt;/div&gt;&lt;div&gt;The files in jar.mn reflects the XUL/JavaScript files in your custom Extension.&lt;/div&gt;&lt;div&gt;Use M&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;ozilla addon to build an empty extension for Firefox, with name krpextension. Copy its "chrome" directory including subdirectories "content, locale, and skin" in chrome directory into our extension directory, i.e "/mozilla/extensions/krpextension". Note that t&lt;span class="Apple-style-span" style="font-size: 14px; line-height: 23px;"&gt;he paths in parentheses point to actual files.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;11. Now run "make" command in "mozilla/$(OBJ_DIR)$" or "make -f client.mk build" command in "/mozilla" directory. If you are using make -f client.mk build command then make sure that you setup ".mozconfig" file. &amp;nbsp;Pls read an article&amp;nbsp;&lt;a href="https://developer.mozilla.org/en/build_documentation"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;https://developer.mozilla.org/en/build_documentation&lt;/span&gt;&lt;/a&gt;&amp;nbsp;to build firefox and&amp;nbsp;prerequisites&amp;nbsp;required&amp;nbsp;to build Firefox.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;12. Our component should be build&amp;nbsp;successfully, and in "Tools-&amp;gt;Addons-&amp;gt;Extension" Tab you should see our custom Extension.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;13. To test our component with Extension and Webpage. &amp;nbsp;First we will test it with Extension. Open overlay.js file in our extension folder "/mozilla/extensions/krpextension/chrome/content/overlay.js". &amp;nbsp;In OnLoad: function, add following lines of code to test our component.&amp;nbsp;&lt;/div&gt;&lt;div&gt;/*********************/&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &lt;span class="Apple-style-span" style="color: #666666;"&gt;var instance = Components.classes["@mycompany.com/krpcomponent;1"].getService();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var obj =instance.QueryInterface(Components.interfaces.krpIComponent);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;var result = obj.Sub(10, 5);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;alert("Sub(10-5) = " + result);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/******************/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Each time firefox will start, our custom extension will start, and during&amp;nbsp;initialization&amp;nbsp;of our extension it will call our component method (i.e Sub(10,5) which will return result of&amp;nbsp;Subtraction&amp;nbsp;operation and its get displayed to user using alert box.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now we test our component using a Web page. Create a HTML file on local system, and use following script to test our component. It should display the correct result of Addition operation.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"&gt;/************************/&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;try {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;const cid = "@mydomain.com/XPCOMSample/krpComponent;1";&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		var &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;obj = Components.classes[cid].createInstance();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		var &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;obj1 = obj.QueryInterface(Components.interfaces.KFFComponent);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="color: black; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var res = obj1.Add(10, 5);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: black; line-height: 1.3em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	       &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;alert('Performing 10 + 5 &amp;nbsp;= &amp;nbsp;' + &amp;nbsp;res );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;} catch (err) {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;alert(err);&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666; white-space: pre;"&gt;		&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;/************************************/&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-1990954364675782754?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/1990954364675782754/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/11/creating-c-component-interface-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/1990954364675782754'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/1990954364675782754'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/11/creating-c-component-interface-using.html' title='Creating C++ Component / Interface using Mozilla Build System'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-7722490836355933525</id><published>2010-11-02T00:27:00.009+08:00</published><updated>2010-11-03T00:21:48.301+08:00</updated><title type='text'>Creating C++ Component / Interface of Firefox Using Gecko-SDK</title><content type='html'>This is step-by-step guide to create, build, register and use a XPCOM component/Interface on Linux (Ubuntu)&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;&lt;b&gt;A. Creating A Component&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;Step 1: Download Gecko SDK (gecko-sdk-i686-pc-linux-gnu-X.X.X.X) and Extract it to local directory &amp;nbsp;"gecko-sdk".&lt;br /&gt;Step 2: Use a utility "uuidgen" to generate UUID for our main Interface.&lt;br /&gt;Step 3: Create an Interface defination file "KFFComponent.idl", use following template, simply replace uuid(1c0856f7-ed61-471e-9dac-442565a5d1d2)&amp;nbsp;with your unique uuid(your_UUID) field.&lt;br /&gt;&lt;meta content="text/html; charset=utf-8" http-equiv="content-type"&gt;&lt;/meta&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "nsISupports.idl"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;[scriptable, uuid(1c0856f7-ed61-471e-9dac-442565a5d1d2)]&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;interface KFFComponent : nsISupports&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;unsigned long long Add(in unsigned long long num1, in unsigned long long num2);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;unsigned long long Sub(in unsigned long long num1, in unsigned long long num2);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Step 4: Open command prompt and go to "gecko-sdk/bin" and run following command:&lt;br /&gt;$ &lt;span class="Apple-style-span" style="color: red;"&gt;./xpidl &amp;nbsp;-m &amp;nbsp;header &amp;nbsp;-I_DIR_ &amp;nbsp; &amp;nbsp;KFFComponent.idl&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Replace "_DIR_" with the full path to the "gecko-sdk/idl". Above command will create "KFFComponent.h" header file.&lt;br /&gt;&lt;br /&gt;Step 5: Now to create typelib file, execute following command&lt;br /&gt;$ &lt;span class="Apple-style-span" style="color: red;"&gt;./xpidl &amp;nbsp;-m &amp;nbsp;typelib &amp;nbsp;-I_DIR_ &amp;nbsp; KFFComponent.idl&lt;/span&gt;&lt;br /&gt;Replace "_DIR_" with the full path to the "gecko-sdk/idl". Above command will create &amp;nbsp;"KFFComponent.xpt" typelib file&lt;br /&gt;&lt;br /&gt;Step 6: Interface header file contains the template for building our component header file as well as C++ Implementation file.&lt;br /&gt;&lt;br /&gt;Step 7: Create our own&amp;nbsp;component&amp;nbsp;Header file "krpComponent.h", use following contents:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#ifndef _KRP_COMPONENT_H_&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#define _KRP_COMPONENT_H_&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "KFFComponent.h"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#define KRP_COMPONENT_CONTRACTID "@mydomain.com/XPCOMSample/krpComponent;1"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#define KRP_COMPONENT_CLASSNAME "First XPCOM Sample Interface"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#define KRP_COMPONENT_CID {0x462EF8EF, 0x9A05, 0x49DE, {0x97, 0xAC, 0x82, 0x2A, 0x6C, 0x46, 0xD2, 0xDC } }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/* KRP_COMPONENT_CID = GUID (462EF8EF-9A05-49DE-97AC-822A6C46D2DC)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Note: Replace GUID with your own GUID field &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;*/&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/* Header file */&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;class krpComponent : public KFFComponent&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;public:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;NS_DECL_ISUPPORTS&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;NS_DECL_KFFCOMPONENT&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;krpComponent();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;private:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;~krpComponent();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;protected:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;/* additional members */&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#endif &amp;nbsp;/* end of _KRP_COMPONENT_H_ */&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Step 8: Create our won C++ Implementation file for the Componenet "krpComponent.cpp".&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "krpComponent.h"&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/* Implementation file */&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;NS_IMPL_ISUPPORTS1(krpComponent, KFFComponent)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;krpComponent::krpComponent()&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;/* member initializers and constructor code */&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;krpComponent::~krpComponent()&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;/* destructor code */&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/* unsigned long long Add (in unsigned long long num1, in unsigned long long num2); */&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;NS_IMETHODIMP krpComponent::Add(PRUint64 num1, PRUint64 num2, PRUint64 *_retval)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;*_retval = num1 + num2;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;return NS_OK;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/* unsigned long long Sub (in unsigned long long num1, in unsigned long long num2); */&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;NS_IMETHODIMP krpComponent::Sub(PRUint64 num1, PRUint64 num2, PRUint64 *_retval)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;*_retval = num1 - num2;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp;return NS_OK;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;/* End of implementation class template. */&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 9: Create our own Module&amp;nbsp;definition&amp;nbsp;file "krpComponentModule.cpp".&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;// This is necessary file to include Mozill Generic definations&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "nsIGenericFactory.h"&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;//My Component Header File&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;#include "krpComponent.h"&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;NS_GENERIC_FACTORY_CONSTRUCTOR(krpComponent)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;static nsModuleComponentInfo components[] =&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; KRP_COMPONENT_CLASSNAME,&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; KRP_COMPONENT_CID,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; KRP_COMPONENT_CONTRACTID,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; krpComponentConstructor,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;};&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;NS_IMPL_NSGETMODULE("krpComponentsModule", components)&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;&lt;b&gt;B: Building our Component / Interface&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Step 1: Create Makefile or use your own template&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;CXX &amp;nbsp; = c++&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;CPPFLAGS += &amp;nbsp; &amp;nbsp; -fno-rtti &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;-fno-exceptions &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;-shared &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;# Change this to point at your Gecko SDK directory.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;GECKO_SDK_PATH = /home/username/cprogs/gecko-sdk&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;# GCC only define which allows us to not have to #include mozilla-config&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;# in every .cpp file. &amp;nbsp;If your not using GCC remove this line and add&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;# #include "mozilla-config.h" to each of your .cpp files.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;GECKO_CONFIG_INCLUDE = -include mozilla-config.h&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;GECKO_DEFINES &amp;nbsp;= -DXPCOM_GLUE&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;GECKO_INCLUDES = -I $(GECKO_SDK_PATH)/include&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;GECKO_LDFLAGS = &amp;nbsp;-L $(GECKO_SDK_PATH)/lib -lxpcomglue \&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -lnspr4 &amp;nbsp; &amp;nbsp; &amp;nbsp;\&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -lplds4 &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;FILES = krpComponent.cpp krpComponentModule.cpp&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;TARGET = krpComponent.so&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;build:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;$(CXX) -Wall -Os -o $(TARGET) $(GECKO_CONFIG_INCLUDE) $(GECKO_DEFINES) $(GECKO_INCLUDES) $(GECKO_LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(FILES)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;chmod +x $(TARGET)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;strip $(TARGET)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;clean:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;rm $(TARGET)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Step 2: Run "make" command, and it "krpComponent.so" file will be created.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;C: Registering the Component&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Step 1: Copy krpComponent.so and KFFComponent.xpt file to "~/.mozilla/component" directory&lt;/div&gt;&lt;div&gt;Step 2: use command "regxpcom" to register component&lt;/div&gt;&lt;div&gt;$ &lt;span class="Apple-style-span" style="color: red;"&gt;./regxpcom &amp;nbsp;-x &amp;nbsp;_DIR_PATH_OF_COMPONENT_&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;Replace _DIR_PATH_OF_COMPONENT with the path of component (krpComponent.so)&lt;/div&gt;&lt;div&gt;Step 3: Restart Mozilla.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;&lt;b&gt;D: Testing Component&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;You can either use Extension or HTML page to test our new Firefox C++ Component.&lt;br /&gt;HTML Code of "TestComponent.html" page is as follows&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;script&gt;&lt;/p&gt;&lt;p&gt;try {&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;const cid = "@mydomain.com/XPCOMSample/krpComponent;1";&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;obj = Components.classes[cid].createInstance();&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;obj = obj.QueryInterface(Components.interfaces.KFFComponent);&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;} catch (err) {&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;alert(err);&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;		&lt;/span&gt;return;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;}&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;var res = obj.Add(3, 4);&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;	&lt;/span&gt;alert('Performing 3+4. Returned ' + res + '.');&lt;/p&gt;&lt;p&gt;&lt;/script&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;try {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;const cid = "@mydomain.com/XPCOMSample/krpComponent;1";&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		var &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;obj = Components.classes[cid].createInstance();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		var &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;obj1 = obj.QueryInterface(Components.interfaces.KFFComponent);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var res = obj1.Sub(10, 5);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: black; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	       &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;alert('Performing 10 - 5 &amp;nbsp;= &amp;nbsp;' + &amp;nbsp;res );&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;} catch (err) {&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;alert(err);&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666; white-space: pre;"&gt;		&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;	&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="color: purple;"&gt;References:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;1.&amp;nbsp;&lt;a href="http://www.iosart.com/firefox/xpcom/"&gt;XPCOM GUIDE - http://www.iosart.com/firefox/xpcom/&lt;/a&gt;&lt;br /&gt;2.&amp;nbsp;&lt;a href="http://www.codeproject.com/KB/library/firefox_component.aspx"&gt;Firefox Component - http://www.codeproject.com/KB/library/firefox_component.aspx&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-7722490836355933525?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/7722490836355933525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/11/creating-c-component-interface-of.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/7722490836355933525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/7722490836355933525'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/11/creating-c-component-interface-of.html' title='Creating C++ Component / Interface of Firefox Using Gecko-SDK'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-4868952430939978476</id><published>2010-10-21T09:41:00.000+08:00</published><updated>2010-10-21T09:41:19.154+08:00</updated><title type='text'>Narcissus/Zaphod JavaScript Research VM for Firefox</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: 14px; letter-spacing: -1px; line-height: 24px;"&gt;&lt;strong&gt;&lt;span class="Apple-style-span" style="color: #333333; font-size: small; font-weight: normal; letter-spacing: normal; line-height: normal;"&gt;&lt;span class="Apple-style-span" style="letter-spacing: -1px; line-height: 24px;"&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;Narcissus&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;is a JavaScript virtual machine written in&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;JavaScript.&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="letter-spacing: -1px; line-height: 24px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;Firefox extension&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;Zaphod&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;allows using Narcissus as the default JavaScript engine in Firefox.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; font-size: 14px; letter-spacing: -1px; line-height: 24px;"&gt;&lt;strong&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: 'trebuchet ms', verdana, arial, sans-serif; font-size: small; font-weight: normal; letter-spacing: normal; line-height: normal;"&gt;&lt;span class="Apple-style-span" style="letter-spacing: -1px; line-height: 24px;"&gt;&lt;span class="Apple-style-span" style="letter-spacing: normal; line-height: 22px;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;Developers can write scripts specifically for the Narcissus engine (by specifying script tags with a type of "application/narcissus"), or they can replace SpiderMonkey with Narcissus as the default engine.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="letter-spacing: -1px; line-height: 24px;"&gt;&lt;span class="Apple-style-span" style="letter-spacing: normal; line-height: 22px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; letter-spacing: -1px; line-height: 24px;"&gt;&lt;span class="Apple-style-span" style="color: rgba(0, 0, 0, 0.792969); font-family: 'trebuchet ms', sans-serif; letter-spacing: normal; line-height: 22px;"&gt;References:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'trebuchet ms', sans-serif;"&gt;&lt;span class="Apple-style-span" style="line-height: 22px;"&gt;&lt;a href="https://mozillalabs.com/zaphod/" style="color: #3366cc; font-weight: bold;"&gt;More info about Zaphod&amp;nbsp;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; font-size: 14px; letter-spacing: -1px; line-height: 24px;"&gt;&lt;span class="Apple-style-span" style="color: rgba(0, 0, 0, 0.792969); font-family: 'trebuchet ms', sans-serif; letter-spacing: normal; line-height: 22px;"&gt;&lt;a href="https://mozillalabs.com/zaphod/example-pages/" style="color: #3366cc; font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Example Pages&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-4868952430939978476?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/4868952430939978476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/10/narcissuszaphod-javascript-research-vm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/4868952430939978476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/4868952430939978476'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/10/narcissuszaphod-javascript-research-vm.html' title='Narcissus/Zaphod JavaScript Research VM for Firefox'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-738604429734516763</id><published>2010-10-09T14:10:00.001+08:00</published><updated>2010-10-09T14:12:14.270+08:00</updated><title type='text'>How to use Huawei E1550 USB Modem On Ubuntu 10.04</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;I am using StarHub MaxMobile SurfLite plan. A USB modem device that comes with the plan is supported on Mac and Windows OS bydefault.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;I use&amp;nbsp;Ubuntu&amp;nbsp;and like to work on ubuntu than windows. It was very troublesome for me to change to windows whenever I needed Internet access. I was fed up with doing back and forth in windows and ubuntu OS. And desperately wanted to use my USB stick on ubuntu.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;My previous USB stick was ZTE MF628. And I don't know how to use it on ubuntu. If anyone knows it, I will appreciate if you post how to make it work on ubuntu.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;When I renewed my contract with StarHub, I got new USB stick Huawei E1550 that worked on ubuntu without any hurdles.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;Step by Step guide to use Huawei E1550 USB stick on Ubuntu:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;1. Plug in Huawei E1550 USB modem to USB port. You can notice its icon is loaded on Desktop.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;2. &amp;nbsp;Type following command at command prompt:&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt; $ gksu gedit /etc/udev/rules.d/15-huawei-e1550.rules&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;3. It will open gedit. Type following lines in it and then save it and close the file.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;SUBSYSTEM=="usb",&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; SYSFS{idProduct}=="1446",&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; SYSFS{idVendor}=="12d1",&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; RUN+="/lib/udev/modem-modeswitch --vendor 0x12d1 --product 0x1446 --type option-zerocd"&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;4. Restart the computer. After restart click on "Network connection" icon in the top panel. You will see new menu item under "Mobile Broadband" category.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;5. Click on that new entry. It will open a&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;New Mobile Broadband Connections &lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;dialog. Click Forward to continue.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;6. &amp;nbsp;Select you country (Singapore in my case) and click Forward. Then select service provider from the list and&amp;nbsp;click&amp;nbsp;forward. Then choose your Billing plan and click Forward. Then finally Click on Apply to save setting.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;It will connect you to the Internet. Enjoy, hurdle free Internet connectivity on ubuntu using USB Modem (Huawei E1550).&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-738604429734516763?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/738604429734516763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/10/how-to-use-huawei-e1550-usb-modem-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/738604429734516763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/738604429734516763'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/10/how-to-use-huawei-e1550-usb-modem-on.html' title='How to use Huawei E1550 USB Modem On Ubuntu 10.04'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-7530314056308499134</id><published>2010-08-18T11:30:00.001+08:00</published><updated>2010-08-20T21:52:54.252+08:00</updated><title type='text'>Mac OS theme on Ubuntu 10.04 (Lucid)</title><content type='html'>&lt;div style="text-align: justify;"&gt;Installing Mac OS theme on Ubuntu 10.04 (Lucid) is easy and&amp;nbsp;straightforward.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Step 1: &amp;nbsp;Install Gstyle (Gstyle is a full Gnome Theme Manager)&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class="Apple-style-span" style="color: blue;"&gt;sudo add-apt-repository ppa:s-lagui/ppa&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sudo apt-get update&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sudo apt-get install gstyle&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Step 2: &amp;nbsp;Once it is installed&amp;nbsp;successfully. Launch Gstyle application (System -&amp;gt; Preferences - &amp;gt; Gstyle).&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Step 3: &amp;nbsp;Click on &lt;span class="Apple-style-span" style="color: purple;"&gt;Download&lt;/span&gt; button and then Click on&amp;nbsp;&lt;span class="Apple-style-span" style="color: purple;"&gt;Refresh&lt;/span&gt;&amp;nbsp;button. &amp;nbsp;Select &lt;span class="Apple-style-span" style="color: purple;"&gt;Mac4Lin&lt;/span&gt; theme from the list.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Step 4: &amp;nbsp;Then in each category option in the left panel of Gstyle, select Mac4Lin. I choose Mac4Lin Aqua.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Step 5A: &amp;nbsp;Now to Configure Global Menu (Top panel bar). Perform&amp;nbsp;following&amp;nbsp;steps:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class="Apple-style-span" style="color: blue;"&gt;sudo add-apt-repository ppa:globalmenu-team&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sudo apt-get update &amp;amp;&amp;amp; sudo apt-get install gnome-globalmenu&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; killall gnome-panel&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Step 5B: &amp;nbsp;Once done, remove all stuffs from top left panel (Right click on the panel and select “Remove from Panel”). &amp;nbsp;Right click on the top panel and select Add to Panel. Select &lt;span class="Apple-style-span" style="color: purple;"&gt;Main Menu&lt;/span&gt;, follow by the &lt;span class="Apple-style-span" style="color: purple;"&gt;Global Menu Panel Applet&lt;/span&gt;.&amp;nbsp;Close the window. Now move the two items (right click and select Move) to the left hand corner and make sure they are side by side.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Step 6A: Now to configure Dock (Bottom panel bar). Perform following Steps:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="color: blue;"&gt;sudo apt-get install cairo-dock&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;There are lot of dock application, but I found this one is easy to use.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Step 6B:&amp;nbsp;Before you launch the Cairo dock application, remove the bottom panel (right click at the bottom panel and select Delete This Panel). &amp;nbsp;Cairo dock &lt;b&gt;needs&lt;/b&gt; a compositing manager to work, so make sure that your system support Compiz before launching the app.&amp;nbsp;Launch Cairo dock (Menu -&amp;gt; Accessories -&amp;gt; Cairo Dock). Make sure to set it to launch everytime you startup your computer.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Only if your system does not support Compiz: You can activate the in-built metacity compositing manager with the command:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="color: blue;"&gt;gconftool-2 --type boolean --set /apps/metacity/general/compositing_manager TRUE&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;To change the logo in the panel bar with apple logo:&lt;/b&gt;&lt;br /&gt;1. Download apple logo from google.&lt;br /&gt;2. &amp;nbsp;Then go to &lt;span class="Apple-style-span" style="color: purple;"&gt;/home/urprofilename/.icons/Mac4Lin_Icons_v1.0/scalable/places&lt;/span&gt; folder. &amp;nbsp;Check the&amp;nbsp;resolution&amp;nbsp;of distributor logo.png file. It may be 78 * 96. Now rescale the image you downloaded into 78 *96 or 96*96 size.&lt;br /&gt;3. Then replace &lt;span class="Apple-style-span" style="color: orange;"&gt;distributor-logo.png&lt;/span&gt;,&amp;nbsp;&lt;span class="Apple-style-span" style="color: orange;"&gt;gnome-main-menu.png&lt;/span&gt;,&amp;nbsp;&lt;span class="Apple-style-span" style="color: orange;"&gt;main-menu.png&lt;/span&gt;, and&amp;nbsp;&lt;span class="Apple-style-span" style="color: orange;"&gt;start-here.png&lt;/span&gt; with the apple logo file.&lt;br /&gt;4. Open the terminal window and type &amp;nbsp;&lt;span class="Apple-style-span" style="color: purple;"&gt;killall gnome-panel&lt;/span&gt; to restart the gnome-panel. Now you should see your new icon.&amp;nbsp;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-7530314056308499134?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/7530314056308499134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/08/mac-os-theme-on-ubuntu-1004-lucid.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/7530314056308499134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/7530314056308499134'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/08/mac-os-theme-on-ubuntu-1004-lucid.html' title='Mac OS theme on Ubuntu 10.04 (Lucid)'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-703312996444034327</id><published>2010-08-16T11:33:00.003+08:00</published><updated>2011-03-04T16:50:45.629+08:00</updated><title type='text'>How to create Patch on Liunx?</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;In this post I will explain how to create a patch file and how to apply patch. &lt;br /&gt;I only know the basic stuff. Therefore, if you want to know more then please use command &lt;span class="Apple-style-span" style="color: red;"&gt;man diff &lt;/span&gt;at command prompt to explore other possible options. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;How to Create a Patch File?&lt;/b&gt;&lt;br /&gt;Patch file is a readable text file which is created using &lt;span class="Apple-style-span" style="color: red;"&gt;diff&lt;/span&gt; command.&lt;br /&gt;To create a patch of entire source folder including its sub directories, do as follows:&lt;br /&gt;&lt;br /&gt;&amp;nbsp;$&lt;span class="Apple-style-span" style="color: red;"&gt; diff &lt;/span&gt;&lt;span class="Apple-style-span" style="color: purple;"&gt;-rauB&lt;/span&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;&amp;nbsp;&amp;nbsp;old_dir &amp;nbsp; new_dir &amp;nbsp; &amp;gt; &amp;nbsp;patchfile_name&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;options&amp;nbsp;&lt;span class="Apple-style-span" style="color: purple;"&gt;-rauB&lt;/span&gt; mean:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class="Apple-style-span" style="color: purple;"&gt;r&lt;/span&gt; &amp;nbsp;-&amp;gt;&amp;nbsp;recursive (multiple levels dir)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class="Apple-style-span" style="color: purple;"&gt;a&lt;/span&gt; -&amp;gt; &amp;nbsp;treat all files as text&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class="Apple-style-span" style="color: purple;"&gt;u&lt;/span&gt; -&amp;gt;&amp;nbsp;Output NUM (default 3) lines of unified context&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;span class="Apple-style-span" style="color: purple;"&gt;B&lt;/span&gt; -&amp;gt; B is to ignore Blank Lines&lt;br /&gt;&lt;br /&gt;Blank lines are usually useless in the patch file. &amp;nbsp;Therefore I used B option, however you are free to tune your patch file according to your choice.&lt;br /&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;old_dir&lt;/span&gt; is the original source code directory, &amp;nbsp;&lt;span class="Apple-style-span" style="color: red;"&gt;new_dir&lt;/span&gt; is the new version of source code and &lt;span class="Apple-style-span" style="color: red;"&gt;patchfile_name&lt;/span&gt; is the name of the patch file. &amp;nbsp;You can give any name to your patch file.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How to Apply Patch to your Source Code?&lt;/b&gt;&lt;br /&gt;Suppose you have got a patch file and you want to apply that patch to the version of your source code.&lt;br /&gt;It is not necessary but I&amp;nbsp;recommend&amp;nbsp;to do a &lt;i&gt;dry-run&lt;/i&gt; test first.&lt;br /&gt;&lt;br /&gt;To do a dry run:&lt;br /&gt;$&lt;span class="Apple-style-span" style="color: red;"&gt; patch --dry-run -p1 -i patchfile_name&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;-&lt;b&gt;i&lt;/b&gt; : Read the patch from patchfile.&lt;br /&gt;-&lt;b&gt;p&lt;/b&gt;&lt;i&gt;num&lt;/i&gt; :&amp;nbsp;Strip &amp;nbsp;the &amp;nbsp;smallest prefix containing num leading slashes from each&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;file name found in the patch file. &amp;nbsp;A sequence of one or more &amp;nbsp;adjacent &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;slashes &amp;nbsp;is counted as a single slash. &amp;nbsp;This controls how file&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;names found in the patch file are treated, in &amp;nbsp;case &amp;nbsp;you &amp;nbsp;keep &amp;nbsp;your&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;files &amp;nbsp;in &amp;nbsp;a &amp;nbsp;different &amp;nbsp;directory &amp;nbsp;than the person who sent out the&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;patch.&lt;br /&gt;&lt;br /&gt;If there is no failure then you can apply patch to your source code:&lt;br /&gt;$&amp;nbsp;&lt;span class="Apple-style-span" style="color: red;"&gt;patch -p1 -i&amp;nbsp;patchfile_name&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I hope this post will help you to generate patch from your source code and apply patch to your source code.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-703312996444034327?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/703312996444034327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/08/how-to-create-patch-on-liunx.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/703312996444034327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/703312996444034327'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/08/how-to-create-patch-on-liunx.html' title='How to create Patch on Liunx?'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-1848199430852895410</id><published>2010-08-14T19:21:00.004+08:00</published><updated>2010-08-15T22:55:37.519+08:00</updated><title type='text'>How to Build Lobo browser on Ubuntu 10.04</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Prerequisites:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;1. Eclipse SDK for Java.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;2. &lt;/span&gt;&lt;/span&gt;&lt;a href="http://izpack.org/"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;IzPack&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;(http://izpack.org/). Download cross platform installation jar file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Steps:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;1. Create a sudirectory "XAMJ_Project" in /opt folder. &amp;nbsp;In linux, /opt belongs to root user so you may need to change the owner of /opt folder, so that write operation will be allowed.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;2. Install IzPack in "/opt/IzPack". for installation of IzPack at command prompt run the command: java -jar IzPack-install-x.x.x.jar.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;3. Open Eclipse and change workspace path to "/opt/XAMJ_Project".&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;4. Now choose the Project Explorer (Window-&amp;gt;Show View -&amp;gt; Project Explorer).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;5. Right click in project explorer and select New -&amp;gt; Project -&amp;gt; CVS &amp;nbsp;- &amp;gt; Project from CVS.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;6. When prompted for server details fill out the server details as given in step 3 of&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;a href="http://lobobrowser.org/sourcecode.jsp"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Lobo Eclipse build instruction page&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;. &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 18px;"&gt;Host: xamj.cvs.sourceforge.net&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 18px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Repository path: /cvsroot/xamj&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 18px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;User: anonymous&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 18px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Password: [leave blank]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 18px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Connection type: pserver&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;7. &amp;nbsp;Next, select "Use an existing module" option.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;8. &amp;nbsp;Then select 8 modules from the XAMJ_Project folder for basic web browser build. &amp;nbsp;You can choose all modules. &amp;nbsp;eight modules I choose were as follows:&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: #333333; line-height: 18px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Common&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;cssparser&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;HTML_Renderer&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Platform_Public_API&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Platform_Core&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Primary_Extension&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;XAMJ_Build&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;IzPack_RegistryPanel&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;9. Next select the version of repository and check out.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;10. &amp;nbsp;Now right click on "&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;IzPack_RegistryPanel"&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; select "Properties" . Then select "Java Build Path". &amp;nbsp;select the "Libraries" tab.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;11. If you see cross for some libraries then its bcoz of the wrong path. As we have already installed IzPack, search for files in /opt/Izpack/lib or /opt/IzPack/bin/Panel, and correct the paths of library files.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;12. Now configure "Run Configuration" for your Java Application project.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Please see the README.txt file in Platform_Core for instructions, and set &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;VM&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; Variable and &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Program&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; Variable in the &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Arguments&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; tab according to the README.txt file. &amp;nbsp;Also set the&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;Project name and Main class name in the &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Main&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; tab. &amp;nbsp;The name of the main class is&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: lime;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;org.lobobrowser.main.EntryPoint&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;span class="Apple-style-span" style="font-family: inherit;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;13. Now apply your setting and run the project. It should work. If it doesn't then right click on IzPack_Registry Panel and add libraies:&amp;nbsp;xpp3-1.1.3.4.M.jar, and&amp;nbsp;cobra-no-commons.jar.zip. You can search and download these libraries if they are not present.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-1848199430852895410?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/1848199430852895410/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/08/how-to-build-lobo-browser-on-ubuntu.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/1848199430852895410'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/1848199430852895410'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/08/how-to-build-lobo-browser-on-ubuntu.html' title='How to Build Lobo browser on Ubuntu 10.04'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-1075388114981185539</id><published>2010-07-30T19:45:00.004+08:00</published><updated>2010-07-30T19:47:14.798+08:00</updated><title type='text'>What is Really Simple Syndication( RSS)?</title><content type='html'>&lt;div style="text-align: justify;"&gt;Really Simple Syndication (RSS) is a way to subscribe to a source of information, such as a Web site. &amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="font-family: VERDANA, ARIAL, Helvetica, Univers, Zurich, sans-serif; line-height: normal;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana, helvetica, sans-serif;"&gt;RSS works by having the website author maintain a list of notifications on their website in a standard way. This list of notifications is called an "RSS Feed".&lt;/span&gt;&amp;nbsp;Many Blog services automatically create RSS Feeds. For Websites, RSS Feeds can be created manually or with software(such as&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: verdana, helvetica, sans-serif;"&gt;Software Garden, Inc.'s ListGarden)&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: VERDANA, ARIAL, Helvetica, Univers, Zurich, sans-serif;"&gt;.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="font-family: VERDANA, ARIAL, Helvetica, Univers, Zurich, sans-serif;"&gt;The RSS Feed that is created is an XML file that lives on a Webserver.&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: VERDANA, ARIAL, Helvetica, Univers, Zurich, sans-serif;"&gt;Once RSS feed is ready on web server, RSS Feeds waits for an RSS Reader to subscribe to them.&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: VERDANA, ARIAL, Helvetica, Univers, Zurich, sans-serif;"&gt;The RSS Feed Reader reads the RSS Feed file and displays it. That is, the RSS Reader displays only new items from the RSS Feed.&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: VERDANA, ARIAL, Helvetica, Univers, Zurich, sans-serif;"&gt;An RSS Feed Reader reads the RSS feed file, finds what is new, converts it to HTML, and displays it.&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-1075388114981185539?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/1075388114981185539/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/07/what-is-really-simple-syndication-rss.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/1075388114981185539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/1075388114981185539'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/07/what-is-really-simple-syndication-rss.html' title='What is Really Simple Syndication( RSS)?'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-6726136616574959646</id><published>2010-05-24T13:58:00.000+08:00</published><updated>2010-05-24T13:58:27.063+08:00</updated><title type='text'>Spider-monkey Internals</title><content type='html'>&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;SpiderMonkey Internals&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The JavaScript engine compiles and executes scripts containing JavaScript statements and functions. The engine handles memory allocation for the objects needed to execute scripts, and it cleans up—garbage collects—objects it no longer needs.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;The word&amp;nbsp;&lt;em&gt;JavaScript&lt;/em&gt;&amp;nbsp;may bring to mind features such as event handlers (like&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;&lt;a href="https://developer.mozilla.org/en/DOM/element.onclick" rel="internal" style="color: #0479a7; text-decoration: none;"&gt;onclick&lt;/a&gt;&lt;/code&gt;),&amp;nbsp;&lt;a href="https://developer.mozilla.org/en/DOM" rel="internal" style="color: #0479a7; text-decoration: none;"&gt;DOM&lt;/a&gt;objects,&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;&lt;a href="https://developer.mozilla.org/en/DOM/window.open" rel="internal" style="color: #0479a7; text-decoration: none;"&gt;window.open&lt;/a&gt;&lt;/code&gt;, and&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;&lt;a href="https://developer.mozilla.org/en/XMLHttpRequest" rel="internal" style="color: #0479a7; text-decoration: none;"&gt;XMLHttpRequest&lt;/a&gt;&lt;/code&gt;. But in Mozilla, all of these features are actually provided by other components, not the SpiderMonkey engine itself. SpiderMonkey provides a few core JavaScript data types—numbers, strings,&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;Array&lt;/code&gt;s,&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;Object&lt;/code&gt;s, and so on—and a few methods, such as&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;Array.push&lt;/code&gt;. It also makes it easy for each application to expose some of its own objects and functions to JavaScript code. Browsers expose DOM objects.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;Spidermonkey includes/implemented JavaScript functions such as &lt;i&gt;&lt;span style="color: blue;"&gt;eval()&lt;/span&gt;&lt;/i&gt;&lt;span style="color: blue;"&gt;, &lt;/span&gt;&lt;i&gt;&lt;span style="color: blue;"&gt;charAt(), escape(), unescape(), encodeURI(), decodeURI()&lt;/span&gt;&lt;/i&gt;, etc.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;JavaScript Event Handlers (like &lt;i&gt;onClick&lt;/i&gt;) are implemented in &amp;nbsp;the &lt;i&gt;&lt;span style="color: blue;"&gt;content/event/&lt;/span&gt;&lt;/i&gt; module in Firefox. The file use to handle events is &lt;i&gt;content/event/src/nsEventStateManager.cpp&lt;/i&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;&lt;i&gt;Window.open&lt;/i&gt; is implemented in the &lt;/span&gt;&lt;span style="font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;&lt;span style="color: blue;"&gt;dom/&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt; module. The file &amp;nbsp;which implemented native function for window.open is &amp;nbsp;&lt;i&gt;dom/src/base/nsGlobalWindow::OpenJS()&lt;/i&gt; in Firefox. &lt;i&gt;window&lt;/i&gt; object is not standardized in DOM specifications, therefore, it has vendor specific implementation of it.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;&lt;i&gt;XMLHttpRequest()&lt;/i&gt; is implemented in the &lt;/span&gt;&lt;span style="font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;&lt;span style="color: blue;"&gt;content/base/&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt; module in Firefox. The file is &lt;i&gt;content/base/src/nsXMLHttpRequest.cpp&lt;/i&gt;&amp;nbsp;implementing&amp;nbsp;XHR request. &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: medium;"&gt;&lt;span style="font-size: 14px; line-height: 24px;"&gt;C/C++ code accesses SpiderMonkey via the JSAPI, by including the header "jsapi.h". The JSAPI provides functions for setting up the JavaScript runtime, compiling and executing scripts, creating and examining JavaScript data structures, handling errors, enabling security checks, and debugging scripts.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: medium;"&gt;&lt;span style="font-size: 14px; line-height: 24px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: medium;"&gt;&lt;span style="font-size: 14px; line-height: 24px;"&gt;In order to run any JavaScript code in SpiderMonkey, an application must have three key elements: a&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;JSRuntime&lt;/code&gt;, a&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;JSContext&lt;/code&gt;, and a global object.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: medium;"&gt;&lt;span style="font-size: 14px; line-height: 24px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: medium;"&gt;&lt;span style="font-size: 14px; line-height: 24px;"&gt;&lt;strong&gt;Runtimes.&lt;/strong&gt;&amp;nbsp;A&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;JSRuntime&lt;/code&gt;, or&amp;nbsp;&lt;em&gt;runtime&lt;/em&gt;, is the space in which the JavaScript variables, objects, scripts, and contexts used by your application are allocated. Every&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;JSContext&lt;/code&gt;&amp;nbsp;and every object in an application lives within a&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;JSRuntime&lt;/code&gt;. They cannot travel to other runtimes or be shared across runtimes. Most applications only need one runtime.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;A program typically has only one JSRuntime, even if it has many threads.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Contexts.&lt;/b&gt; A JSContext, or context, is like a little machine that can do many things involving JavaScript code and objects. It can compile and execute scripts, get and set object properties, call JavaScript functions, convert JavaScript data from one type to another, create objects, and so on. Almost all JSAPI functions require a JSContext * as the first argument.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;&lt;strong&gt;Global objects.&lt;/strong&gt;&amp;nbsp;Lastly, the&amp;nbsp;&lt;em&gt;global object&lt;/em&gt;&amp;nbsp;contains all the classes, functions, and variables that are available for JavaScript code to use. Whenever JavaScript code does something like&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;window.open("http://www.mozilla.org/")&lt;/code&gt;, it is accessing a global property, in this case&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;window&lt;/code&gt;. JSAPI applications have full control over what global properties scripts can see. The application starts out by creating an object and populating it with the standard JavaScript classes, like&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;Array&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;Object&lt;/code&gt;. Then it adds whatever custom classes, functions, and variables (like&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;window&lt;/code&gt;) the application wants to provide; see&amp;nbsp;&lt;a href="http://www.blogger.com/post-create.g?blogID=5267091008358194058#Custom_objects" style="color: #0479a7; text-decoration: none;"&gt;Custom objects&lt;/a&gt;&amp;nbsp;below. Each time the application runs a JS script (using, for example,&amp;nbsp;&lt;code style="color: #25221d; font-weight: inherit;"&gt;&lt;a href="https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_EvaluateScript" rel="internal" style="color: #0479a7; text-decoration: none;"&gt;JS_EvaluateScript&lt;/a&gt;&lt;/code&gt;), it provides the global object for that script to use. As the script runs, it can create global functions and variables of its own. All of these functions, classes, and variables are stored as properties of the global object.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;References:&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #25221d; font-family: Verdana, Tahoma, sans-serif; font-size: 14px; line-height: 24px;"&gt;1.&amp;nbsp;&lt;a href="https://developer.mozilla.org/En/SpiderMonkey/JSAPI_User_Guide#JSAPI_basics"&gt;https://developer.mozilla.org/En/SpiderMonkey/JSAPI_User_Guide#JSAPI_basics&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;2.&amp;nbsp;&lt;a href="https://developer.mozilla.org/En/JSRuntime"&gt;https://developer.mozilla.org/En/JSRuntime&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-6726136616574959646?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/6726136616574959646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/05/spider-monkey-internals.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6726136616574959646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6726136616574959646'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/05/spider-monkey-internals.html' title='Spider-monkey Internals'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-626494445012835888</id><published>2010-05-05T12:02:00.006+08:00</published><updated>2010-05-05T14:54:59.985+08:00</updated><title type='text'>V8 Build Error</title><content type='html'>&lt;div style="text-align: justify;"&gt;Hi,&lt;/div&gt;&lt;div style="text-align: justify;"&gt;I downloaded v8 and followed the build instruction given at&amp;nbsp;http://code.google.com/apis/v8/build.html#build .&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;However, When I executed the command "&lt;b&gt;scons&lt;/b&gt;" (without quotes) it shown following errors on my machine.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;cc1plus: error: dereferencing pointer 'dest' does break strict-aliasing rules&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;cc1plus: error: dereferencing pointer 'dest' does break strict-aliasing rules&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;cc1plus: error: dereferencing pointer 'dest' does break strict-aliasing rules&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;src/api.cc:3495: note: initialized from here&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;scons: *** [obj/release/api.o] Error 1&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;scons: building terminated because of errors.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;This is bcoz warnings are considered as errors by the compiler.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;To solve this problem,&lt;/div&gt;&lt;div style="text-align: justify;"&gt;open "&lt;b&gt;SConstruct&lt;/b&gt;" file in the source directory of v8 and look for "&lt;b&gt;V8_EXTRA_FLAGS&lt;/b&gt;"&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Then comment the line (use &lt;b&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;#&lt;/span&gt;&lt;/b&gt; to comment line) &lt;span class="Apple-style-span" style="color: #990000;"&gt;'-Werror' &lt;/span&gt;in&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;gcc:{&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;all:{&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; WARNINGFLAGS: [&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;]&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: #999999;"&gt;&amp;nbsp;&amp;nbsp;},&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;After doing this, I was able to build it. However, I was not able to embed v8 in C++ application.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The reason was, I was running ubuntu x64 bit OS and V8 build is of 32-bit.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;I ran following command to build 64-bit libaray of V8.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;$ &lt;span class="Apple-style-span" style="color: red;"&gt;scons mode=debug arch=x64&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Where &lt;span class="Apple-style-span" style="color: red;"&gt;mode=debug&lt;/span&gt; to build &lt;span class="Apple-style-span" style="color: red;"&gt;DEBUG&lt;/span&gt; version instead of by default release version. And &lt;span class="Apple-style-span" style="color: red;"&gt;arch=x64&lt;/span&gt; to build &lt;span class="Apple-style-span" style="color: red;"&gt;64-bit&lt;/span&gt; version instead of by-default 32-bit version.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-626494445012835888?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/626494445012835888/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/05/v8-build-error.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/626494445012835888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/626494445012835888'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/05/v8-build-error.html' title='V8 Build Error'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-1506450702596685053</id><published>2010-04-11T15:18:00.000+08:00</published><updated>2010-04-11T15:18:46.110+08:00</updated><title type='text'>Measure CPU usage time by Thread</title><content type='html'>&amp;nbsp;&amp;nbsp; &amp;nbsp;On Linux there are two commands you can use to measure CPU usage time of a thread in a multi threaded application. &amp;nbsp;Those commands are &lt;b&gt;getrusage()&lt;/b&gt; and &lt;b&gt;clock_gettime()&lt;/b&gt;. &amp;nbsp;You can sue same commands to measure CPU time consumed by process.&lt;br /&gt;&lt;br /&gt;Sample program to measure CPU time in a thread is given below:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;/stdio.h&gt;&lt;br /&gt;#include &lt;sys/resource.h&gt;&lt;/sys/resource.h&gt;&lt;br /&gt;#include &lt;sys/time.h&gt;&lt;/sys/time.h&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;int kResult = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;struct rusage start, end;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;struct timeval timeS, timeE;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;double t= 0.0, time= 0.0;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;struct timespec st, endt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;double t1= 0.0, time1= 0.0;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;// measure CPU time&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;kResult = getrusage(RUSAGE_THREAD, &amp;amp;start);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (kResult == -1)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fprintf(stderr, "\n\n Error in getrusage command");&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;timeS = start.ru_stime; // system time&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;t = (double)timeS.tv_sec + (double) timeS.tv_usec / 1000000.0;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;timeS = start.ru_utime; // user time&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;t = t + (double)timeS.tv_sec + (double) timeS.tv_usec / 1000000.0;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;kResult = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &amp;amp;st);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (kResult == -1)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fprintf(stderr, "\n\n Error in clock_gettime command");&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;t1 = (double) (st.tv_sec * 1000000.0 )+ (double) st.tv_nsec / 1000.0 ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; // Do some operation to consume CPU&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;// measure CPU time&lt;br /&gt;&lt;br /&gt;&amp;nbsp;kResult = getrusage(RUSAGE_THREAD, &amp;amp;end);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (kResult == -1)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fprintf(stderr, "\n\n Error in getrusage command");&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;timeE = end.ru_stime; // system time&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;time = (double)timeE.tv_sec + (double) timeE.tv_usec / 1000000.0;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;timeE = end.ru_utime; // user time&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;time = time + (double)timeE.tv_sec + (double) timeE.tv_usec / 1000000.0;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;time = time - t;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fprintf(stderr,"\n\n Total CPU usage time using 'getrusage' = %.12lf\n\n", time);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;kResult = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &amp;amp;endt);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (kResult == -1)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fprintf(stderr, "\n\n Error in clock_gettime command");&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;time1 = (double) (endt.tv_sec * 1000000.0)+ (double) endt.tv_nsec / 1000.0 ;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;time1 = (time1 - t1) / 1000000.0;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fprintf(stderr,"\n\n Total CPU usage time using 'clock_gettime' = %.12lf\n\n", time1);&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Note: clock_gettime will generate error if you will not provide -lrt library to linker.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-1506450702596685053?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/1506450702596685053/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/04/measure-cpu-usage-time-by-thread.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/1506450702596685053'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/1506450702596685053'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/04/measure-cpu-usage-time-by-thread.html' title='Measure CPU usage time by Thread'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-2369842385481992077</id><published>2010-03-19T13:32:00.001+08:00</published><updated>2010-03-19T13:46:31.706+08:00</updated><title type='text'>To remove old kernel from Ubuntu</title><content type='html'>To remove old&amp;nbsp;kernels&amp;nbsp;from ubuntu OS:&lt;br /&gt;&lt;br /&gt;First check the current kernel version:&lt;br /&gt;$ &lt;span class="Apple-style-span" style="color: orange;"&gt;uname -r&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Do not remove current version.&lt;br /&gt;&lt;br /&gt;To remove old kernel version use command:&lt;br /&gt;$&lt;span class="Apple-style-span" style="color: orange;"&gt;sudo apt-get purge linux-image-2.6.XX-XX-generic&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Then remove header of that version:&lt;br /&gt;$&lt;span class="Apple-style-span" style="color: orange;"&gt;sudo apt-get purge linux-headers-2.6.XX-XX&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-2369842385481992077?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/2369842385481992077/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/03/to-remove-old-kernel-from-ubuntu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2369842385481992077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2369842385481992077'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/03/to-remove-old-kernel-from-ubuntu.html' title='To remove old kernel from Ubuntu'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-3775341945970083838</id><published>2010-03-16T17:15:00.000+08:00</published><updated>2010-03-16T17:15:49.388+08:00</updated><title type='text'>Cannot Update Ubuntu</title><content type='html'>Recently, When I was trying to update ubuntu, I was getting following error message:&lt;div&gt;&lt;div&gt;E: Could not get lock /var/lib/apt/lists/lock - open (11 Resource temporarily unavailable)&lt;/div&gt;&lt;div&gt;E: Unable to lock the list directory&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After searching on Ubuntu forums I found the solution to solve this Problem.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Use following command to see is their any synaptic pkg manager running?&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;$&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: monospace; font-size: 12px; white-space: pre;"&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;ps -e | grep apt&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If yes, then kill all those processes using&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;$ sudo kill -9 processID&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then remove lock file from ur system:&lt;/div&gt;&lt;div&gt;&amp;nbsp;&amp;nbsp;$ &amp;nbsp;sudo rm /var/lib/apt/lists/lock&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now try to update ur system. It should work. Atleast it worked for me.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-3775341945970083838?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/3775341945970083838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/03/cannot-update-ubuntu.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/3775341945970083838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/3775341945970083838'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/03/cannot-update-ubuntu.html' title='Cannot Update Ubuntu'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-6260504182440914868</id><published>2010-03-16T16:35:00.002+08:00</published><updated>2010-03-16T16:37:37.935+08:00</updated><title type='text'>DOT Graphs</title><content type='html'>DOT (filename.dot) is a file format to draw graphs including directed graphs.&lt;br /&gt;DOT writes graphs in .ps, .pdf, .gif, .png formats.&lt;br /&gt;&lt;br /&gt;For example,&lt;br /&gt;&lt;br /&gt;$ dot -Tps src.dot -o dest.ps&lt;br /&gt;&lt;br /&gt;$ dot -Tpdf src.dot -o dest.pdf&lt;br /&gt;&lt;br /&gt;Dot file &amp;nbsp;format is as follows:&lt;br /&gt;&lt;br /&gt;digraph graphName {&lt;br /&gt;&amp;nbsp;"Node 1" &amp;nbsp;-&amp;gt; "Node 2" &amp;nbsp;;&lt;br /&gt;&amp;nbsp;"Node 1" -&amp;gt; "Node 2" -&amp;gt; "Node 3";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Each line is terminated by semicolon (;), and arrow (-&amp;gt;) is used to show directed arc.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: orange;"&gt;digraph&lt;/span&gt; means directed graph whereas &lt;span class="Apple-style-span" style="color: orange;"&gt;graph&lt;/span&gt; means undirected graph.&lt;br /&gt;&lt;br /&gt;Within a main graph a &lt;span class="Apple-style-span" style="color: orange;"&gt;subgraph&lt;/span&gt; define a subset of graph.&lt;br /&gt;For example,&lt;br /&gt;digraph GraphName {&lt;br /&gt;"Node 1" -&amp;gt; "Node 2";&lt;br /&gt;&amp;nbsp;subgraph SubGraphName{&lt;br /&gt;&amp;nbsp;&amp;nbsp; "Node 3" -&amp;gt; "Node 1";&lt;br /&gt;&amp;nbsp;&amp;nbsp; "Node 4" -&amp;gt; Node 3";&lt;br /&gt;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-6260504182440914868?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/6260504182440914868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/03/dot-graphs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6260504182440914868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6260504182440914868'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/03/dot-graphs.html' title='DOT Graphs'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-2854693928057728861</id><published>2010-03-02T19:19:00.001+08:00</published><updated>2010-03-02T19:20:51.795+08:00</updated><title type='text'>JavaScript Injection</title><content type='html'>&lt;div style="text-align: justify;"&gt;JavaScript Injection is a technique that allows you alter the content of current web page without actually leaving the current web page.&amp;nbsp; It is extremely useful when you want to spoof the contents that are sent to server using Forms.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Basics of JS Injection:&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;JS injection means inserting or executing a script. You can execute a script from the URL bar of the web page which you want to alter.&amp;nbsp; To execute JS code, you must first clear the URL bar (Note: Don't press enter yet), that is, no http:// or anything else.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Javascript can be executed from URL using &lt;span style="color: red;"&gt;javascript:&lt;/span&gt; protocol. &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Try following code in the URL bar of the web page to display your message.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;/span&gt;&lt;span style="color: lime;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;javascript:alert("Hello World!");&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;If you saw a window pop-up and saying Hello World, then congrats, you successfully did  a JS injection test.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Cookie Editing:&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;This time we will try penetrate one level deeper and we will try to modify server state.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;One of the mechanism used to represent server state is using Cookies. Server identifies client state and authorization using Cookies. Therefore, it is worth to learn cookie alteration using JS injection technique.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;To check the cookies set by web site, use following script at URL bar:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: lime; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; javascript:alert(document.cookie);&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Above script will show you cookies set by web site. To modify any &lt;span style="color: orange;"&gt;key=value&lt;/span&gt; pair, use following syntax:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;/span&gt;&lt;span style="color: lime; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;javascript:void(document.cookie="Key=Value");&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;Above command can either alter existing Key=Value pair or add new Key=Value pair if it doesn't exists.&amp;nbsp; To edit or alter information we use &lt;b&gt;void( )&lt;/b&gt; function of JavaScript. &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;For example, server set &lt;span style="color: orange;"&gt;Authorization=no&lt;/span&gt; in Cookie and you want to modify this Key=value pair.&amp;nbsp; Then you can use script given below:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;/span&gt;&lt;span style="color: lime; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;javascript:void(document.cookie="Autorization=yes");&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;It is also useful to try an &lt;i&gt;alert(document.cookie);&lt;/i&gt; script at the end of the same line to see what effect your altering had.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Form Modifications:&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;One way to edit values sent to web server from client using a Form is to store a web page on a local disk and modify its Form field values with whatever values you want and then submit the form to the server.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;For example:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp; Following HTML code snippet shows that hidden field is submitted when a submit button is clicked on Form. If we want to modify email address to get data sent by email to webmaster. &lt;br /&gt;&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&lt;pre id="line80" style="color: #666666;"&gt;&amp;lt;&lt;span class="start-tag"&gt;form&lt;/span&gt;&lt;span class="attribute-name"&gt; action&lt;/span&gt;=&lt;span class="attribute-value"&gt;"/missions/basic/process.php" &lt;/span&gt;&lt;span class="attribute-name"&gt;method&lt;/span&gt;=&lt;span class="attribute-value"&gt;"post"&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre id="line80" style="color: #666666;"&gt;&amp;lt;&lt;span class="start-tag"&gt;input&lt;/span&gt;&lt;span class="attribute-name"&gt; type&lt;/span&gt;=&lt;span class="attribute-value"&gt;"hidden" &lt;/span&gt;&lt;span class="attribute-name"&gt;name&lt;/span&gt;=&lt;span class="attribute-value"&gt;"to" &lt;/span&gt;&lt;span class="attribute-name"&gt;value&lt;/span&gt;=&lt;span class="attribute-value"&gt;"webmaster@mywebsite.com" &lt;/span&gt;&lt;span class="error"&gt;&lt;span class="attribute-name"&gt;/&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre id="line80" style="color: #666666;"&gt;&amp;lt;&lt;span class="start-tag"&gt;input&lt;/span&gt;&lt;span class="attribute-name"&gt; type&lt;/span&gt;=&lt;span class="attribute-value"&gt;"submit" &lt;/span&gt;&lt;span class="attribute-name"&gt;value&lt;/span&gt;=&lt;span class="attribute-value"&gt;"Click to Submit" &lt;/span&gt;&lt;span class="error"&gt;&lt;span class="attribute-name"&gt;/&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre id="line80" style="color: #666666;"&gt;&amp;lt;/&lt;span class="end-tag"&gt;form&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;br /&gt;First, we need to store this web page on local disk, and then modify it as shown below.&lt;br /&gt;&lt;br /&gt;&lt;pre id="line80" style="color: #999999;"&gt;&lt;span class="start-tag"&gt;&amp;lt;form&lt;/span&gt;&lt;span class="attribute-name"&gt; action&lt;/span&gt;=&lt;span class="attribute-value"&gt;"&lt;span style="color: orange;"&gt;http://mywebsite.com&lt;/span&gt;/missions/basic/process.php" &lt;/span&gt;&lt;span class="attribute-name"&gt;method&lt;/span&gt;=&lt;span class="attribute-value"&gt;"post"&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre id="line80" style="color: #999999;"&gt;&amp;lt;&lt;span class="start-tag"&gt;input&lt;/span&gt;&lt;span class="attribute-name"&gt; type&lt;/span&gt;=&lt;span class="attribute-value"&gt;"hidden" &lt;/span&gt;&lt;span class="attribute-name"&gt;name&lt;/span&gt;=&lt;span class="attribute-value"&gt;"to" &lt;/span&gt;&lt;span class="attribute-name"&gt;value&lt;/span&gt;=&lt;span class="attribute-value"&gt;"&lt;span style="color: orange;"&gt;altered@emailaddress.com&lt;/span&gt;" &lt;/span&gt;&lt;span class="error"&gt;&lt;span class="attribute-name"&gt;/&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre id="line80" style="color: #999999;"&gt;&amp;lt;&lt;span class="start-tag"&gt;input&lt;/span&gt;&lt;span class="attribute-name"&gt; type&lt;/span&gt;=&lt;span class="attribute-value"&gt;"submit" &lt;/span&gt;&lt;span class="attribute-name"&gt;value&lt;/span&gt;=&lt;span class="attribute-value"&gt;"Click to Submit" &lt;/span&gt;&lt;span class="error"&gt;&lt;span class="attribute-name"&gt;/&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre id="line80" style="color: #999999;"&gt;&amp;lt;/&lt;span class="end-tag"&gt;form&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;However, sometimes the website checks to see if you actually submitted it from the website&amp;nbsp; or not. To get around this, we can just edit the form using from javascript Injection.&lt;br /&gt;&lt;br /&gt;Every form on a given webpage (unless named otherwise) is stored in the forms[x] array... where "x" is the number, in order from top to bottom, of all the forms in a page. Note that the forms start at 0, so the first form on the page would actually be 0, and the second would be 1 and so on.&lt;br /&gt;&lt;br /&gt;Lets consider our previous form example: &lt;br /&gt;&lt;pre id="line80" style="color: #666666;"&gt;&amp;lt;&lt;span class="start-tag"&gt;form&lt;/span&gt;&lt;span class="attribute-name"&gt; action&lt;/span&gt;=&lt;span class="attribute-value"&gt;"/missions/basic/process.php" &lt;/span&gt;&lt;span class="attribute-name"&gt;method&lt;/span&gt;=&lt;span class="attribute-value"&gt;"post"&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre id="line80" style="color: #666666;"&gt;&amp;lt;&lt;span class="start-tag"&gt;input&lt;/span&gt;&lt;span class="attribute-name"&gt; type&lt;/span&gt;=&lt;span class="attribute-value"&gt;"hidden" &lt;/span&gt;&lt;span class="attribute-name"&gt;name&lt;/span&gt;=&lt;span class="attribute-value"&gt;"to" &lt;/span&gt;&lt;span class="attribute-name"&gt;value&lt;/span&gt;=&lt;span class="attribute-value"&gt;"webmaster@mywebsite.com" &lt;/span&gt;&lt;span class="error"&gt;&lt;span class="attribute-name"&gt;/&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre id="line80" style="color: #666666;"&gt;&amp;lt;&lt;span class="start-tag"&gt;input&lt;/span&gt;&lt;span class="attribute-name"&gt; type&lt;/span&gt;=&lt;span class="attribute-value"&gt;"submit" &lt;/span&gt;&lt;span class="attribute-name"&gt;value&lt;/span&gt;=&lt;span class="attribute-value"&gt;"Click to Submit" &lt;/span&gt;&lt;span class="error"&gt;&lt;span class="attribute-name"&gt;/&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;pre id="line80" style="color: #666666;"&gt;&amp;lt;/&lt;span class="end-tag"&gt;form&lt;/span&gt;&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Note:Since this is the first form on the page, it is forms[0].&lt;br /&gt;&lt;br /&gt;To check the value using JS, use following command:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; &lt;/span&gt;&lt;span style="color: lime; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;javascript:alert(document.forms[0].to.value)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In this case, It would pop up an alert that says "&lt;span class="attribute-value" style="color: #666666;"&gt;webmaster@mywebsite.com&lt;/span&gt;"&lt;br /&gt;&lt;br /&gt;So here's how to Inject your email into it. You can use the same technique as shown earlier in the cookies editing :&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color: lime; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;javascript:void(document.forms[0].to.value="altered@emailaddress.com");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Above script would change email address to altered@emailaddress.com. You can use alert( ) JavaScript function to check your work.&lt;br /&gt;&lt;br /&gt;These are the most basic things you need to know about JS injection and useful in many cases.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-2854693928057728861?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/2854693928057728861/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/03/javascript-injection.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2854693928057728861'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2854693928057728861'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/03/javascript-injection.html' title='JavaScript Injection'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-1546638000323200036</id><published>2010-02-23T11:22:00.000+08:00</published><updated>2010-02-23T11:22:08.325+08:00</updated><title type='text'>How Download accelerator Works?</title><content type='html'>&lt;div style="text-align: justify;"&gt;In this post I will explain the basic principle of Download accelerators (such as DAP, wxDownload Fast, etc) used to download files.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;How it speeds up the downloading.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;First Let me explain the difference between normal downloading of a file and&amp;nbsp;downloading&amp;nbsp;of a file using download accelerator. &amp;nbsp;If you use regular browser to download a file then it creates only one connection with the server to download the file,&amp;nbsp;whereas&amp;nbsp;if download accelerators is used to download file then it creates multiple connection with the server and&amp;nbsp;downloads&amp;nbsp;a file in chunks and upon completion of download it joins those chunks. &amp;nbsp;Number of chunks created by download accelerators is depend on its configuration. I used &lt;span class="Apple-style-span" style="color: red;"&gt;wxDownload Fast&lt;/span&gt; and configured it to create 3 chunks of a file. That is, it creates 3 connections with the server to&amp;nbsp;download&amp;nbsp;any file.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Lets consider an example.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;I used&amp;nbsp;&lt;span class="Apple-style-span" style="color: red;"&gt;wxDownload Fast&lt;/span&gt; as download accelerator and downloaded a file &lt;span class="Apple-style-span" style="color: purple;"&gt;ymsgr8us.exe&lt;/span&gt; (&lt;span class="Apple-style-span" style="color: purple;"&gt;Yahoo&amp;nbsp;messenger&lt;/span&gt;) which is of size &lt;b&gt;9.9 MB&lt;/b&gt;.&lt;br /&gt;The initial request sent by &lt;span class="Apple-style-span" style="color: red;"&gt;wxDownload Fast&lt;/span&gt; to server was ordinary request to&amp;nbsp;retrieve&amp;nbsp;file, as given below:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Hypertext Transfer Protocol&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;GET /dl/9073e1f8a8d00eb735874cd9d3b6769c/4b824b4c/30%2Fymsgr8us.exe HTTP/1.1\r\n&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Request Method: GET&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Request Version: HTTP/1.1&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;HOST: us.download.soft32.com\r\n&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;User-Agent: wxDownload Fast\r\n&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Range: bytes=0-\r\n&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In HTTP response, from &lt;span class="Apple-style-span" style="color: #0c343d;"&gt;Content-Length&lt;/span&gt; header field &lt;span class="Apple-style-span" style="color: red;"&gt;wxDownload Fast&lt;/span&gt; learned the actual size of file. &amp;nbsp;Once the file size is know to &lt;span class="Apple-style-span" style="color: red;"&gt;wxDownload Fast&lt;/span&gt; (in general, to download accelerators), depending on number of connection (chunks) to create it&amp;nbsp;decides&amp;nbsp;how big should be the chunk size. In our case, I configured it to create three chunks, therefore, it divides &lt;span class="Apple-style-span" style="color: #0c343d;"&gt;Content-Length&lt;/span&gt; value by 3 to create three&amp;nbsp;chunks.&lt;br /&gt;&lt;br /&gt;Then it sends another HTTP request to the server, by creating another connection. The HTTP request made by wxDownload to the server was as follows:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Hypertext Transfer Protocol&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;GET /download/63-164279-1/ymsgr8us.exe HTTP/1.1\r\n&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Request Method: GET&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Request URI: /download/63-164279-1/ymsgr8us.exe&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Request Version: HTTP/1.1&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;HOST: www.soft32.com\r\n&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;User-Agent: wxDownload Fast\r\n&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Range: bytes=3474600-\r\n&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note the &lt;span class="Apple-style-span" style="color: #0c343d;"&gt;Range&lt;/span&gt; field in HTTP request. &amp;nbsp;The range header field was&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Range: bytes=3474600-&lt;span class="Apple-style-span" style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;It instructs the server to return a file from &lt;/span&gt;3474600th&lt;span class="Apple-style-span" style="color: black;"&gt; byte onwards. &amp;nbsp;Although, download manager requested for entire file in its first connection, it would however terminate that connection as soon as it will receive upto bytes &lt;/span&gt;3474599&lt;span class="Apple-style-span" style="color: black;"&gt;. Hence it would not wast resources and download duplicate byte streams.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;&lt;span class="Apple-style-span" style="color: black;"&gt;As now you can image what would be the third HTTP request. It is given below. observe the &lt;/span&gt;&lt;span class="Apple-style-span" style="color: #0c343d;"&gt;Range&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black;"&gt; HTTP header field. &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Hypertext Transfer Protocol&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;GET /download/63-164279-1/ymsgr8us.exe HTTP/1.1\r\n&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Request Method: GET&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Request URI: /download/63-164279-1/ymsgr8us.exe&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Request Version: HTTP/1.1&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;HOST: www.soft32.com\r\n&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;User-Agent: wxDownload Fast\r\n&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #274e13;"&gt;Range: bytes=6949200-\r\n&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;This is the basic principle followed by download&amp;nbsp;accelerators&amp;nbsp;(such as wxDownload Fast, etc) &amp;nbsp;to download file quickly than normal browser download.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-1546638000323200036?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/1546638000323200036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/02/how-download-accelerator-works.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/1546638000323200036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/1546638000323200036'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/02/how-download-accelerator-works.html' title='How Download accelerator Works?'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-3005935304771788108</id><published>2010-02-19T13:37:00.022+08:00</published><updated>2010-02-19T13:56:42.854+08:00</updated><title type='text'>Heritrix and HTMLUnit</title><content type='html'>Hi folks, In this post I will explain how to build Heritrix from its source code and how to Integrate HTMLUnit into Heritrix.&lt;br /&gt;&lt;br /&gt;First question comes to mind is, What is Heritrix? and why do we need HTMLUnit to Integrate into Heritrix?&lt;br /&gt;&lt;br /&gt;Well, Heritrix is a open-source, Web crawler. Heritrix does not include web page level DOM model and JavaScript Interpreter. Therefore, if you want to&amp;nbsp;crawl&amp;nbsp;the web to look for malicious scripts or obfuscated JS, then you need a JS interpreter. Hence. HTMLUnit comes into play. HTMLUnit is a headless&amp;nbsp;browser, which has got JS interpreter.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Steps to Build Heritrix:&lt;/b&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Download latest version of &lt;span class="Apple-style-span" style="color: purple;"&gt;JDK&lt;/span&gt; rpm from sun website and install it.&amp;nbsp;&lt;/li&gt;&lt;li&gt;Set &lt;span class="Apple-style-span" style="color: blue;"&gt;JAVA_HOME&lt;/span&gt; and &lt;span class="Apple-style-span" style="color: blue;"&gt;PATH&lt;/span&gt; environment to .bashrc file (&lt;span class="Apple-style-span" style="color: red;"&gt;~/.bashrc&lt;/span&gt;)&lt;/li&gt;&lt;/ol&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class="Apple-style-span" style="color: #4c1130;"&gt;export JAVA_HOME=/usr/java/jdk1.6.x.x&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #4c1130;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;export PATH=$JAVA_HOME/bin:$PATH&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #4c1130;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt; Now JDK is ready to be used by Heritirx and Maven&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; 3. &amp;nbsp;We need &lt;b&gt;maven 1.0.2&lt;/b&gt; to build heritix. &amp;nbsp;&lt;span class="Apple-style-span" style="color: #666666;"&gt;Note: We need src of heritix so that we can modify it in future.&amp;nbsp;Therefore do not use heritix binaries&amp;nbsp;available&amp;nbsp;on Ineternet. Build heritirx from src. Also Note the&amp;nbsp;version of maven. it is very very important. Do not try with latest version of maven. It may not work.&lt;/span&gt;&lt;span class="Apple-style-span" style="color: #444444;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; 4.&amp;nbsp;Download &lt;span class="Apple-style-span" style="color: #444444;"&gt;binary&lt;/span&gt; of &lt;b&gt;maven 1.0.2&lt;/b&gt; and extract it somewhere on disk. Now set &lt;span class="Apple-style-span" style="color: blue;"&gt;MAVEN_HOME&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; environment for it as mention below.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Edit (&lt;span class="Apple-style-span" style="color: red;"&gt;/etc/profile&lt;/span&gt;) file to insert following lines before &lt;b&gt;unset i &lt;/b&gt;and &lt;b&gt;unset pathmunge&lt;/b&gt; commands at the end of file.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="color: #4c1130;"&gt;export MAVEN_HOME=/path_of_Maven_directory &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #4c1130;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;pathmunge $MAVEN_HOME/bin before&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;Now logout and login again to reflect environment variable changes done above to be get reflected.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;5. Run &lt;span class="Apple-style-span" style="color: #4c1130;"&gt;maven -v&lt;/span&gt; command to test maven is running properly.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;6.&amp;nbsp;Run &lt;span class="Apple-style-span" style="color: #4c1130;"&gt;maven jar&lt;/span&gt; command. this will create /root/.maven/repository directory.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;7.&amp;nbsp;Now go into heritirx directory and run command &lt;span class="Apple-style-span" style="color: #4c1130;"&gt;maven dist&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;8.&amp;nbsp;This will create subdirectory target, and many other subdirectories inside target directory.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class="Apple-style-span" style="color: red;"&gt;target/distribution&lt;/span&gt; directory holds heritirx build version.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; It there is failure due to any dependency jar file then download that file from Internet and store it in either &lt;span class="Apple-style-span" style="color: red;"&gt;/root/.maven/cache&lt;/span&gt; or &lt;span class="Apple-style-span" style="color: red;"&gt;/root/.maven/repository/.../jar/&lt;/span&gt; directory.&lt;br /&gt;&amp;nbsp;&amp;nbsp; 9.&amp;nbsp;Heritirx is build Successfully. Extract build version and test heritirx.&lt;br /&gt;&amp;nbsp;&amp;nbsp;10. &amp;nbsp;Launch heritrix by using command:&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;b&gt;$&lt;/b&gt; &lt;span class="Apple-style-span" style="color: #4c1130;"&gt;HERITRIX_HOME/bin/heritrix --admin=LOGIN:PASSWORD&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; where $HERITRIX_HOME is the location of your &lt;b&gt;untarred&lt;/b&gt; heritrix.?.?.?.tar.gz.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Integrating HTMLUNIT into Heritrix:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;This is little bit tricky. You are at this point means you already have heritrix, sun JDK and maven.&lt;br /&gt;&lt;br /&gt;Follow the steps given below:&lt;br /&gt;&lt;b&gt;Step 1&lt;/b&gt;: Download HTMLUnit (I used HTMLUnit 2.5). We don't need source code of HTMLUnit therefore download binary of HTMLUnit. We only need its JAR files.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step 2&lt;/b&gt;: Copy all JAR files in HTMLUnit into &lt;span class="Apple-style-span" style="color: red;"&gt;lib&lt;/span&gt; sub-directory of heritrix folder. Do not replace files, which are already there, if you replace them, then you need to modify &lt;span class="Apple-style-span" style="color: red;"&gt;project.properties&lt;/span&gt; file. Only add those files which are not there.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step 3&lt;/b&gt;: Edit &lt;span class="Apple-style-span" style="color: red;"&gt;project.xml&lt;/span&gt; file in heritrix directory. Bcoz we want to tell heritrix where HTMLUnit classes can be found. Add &lt;span class="Apple-style-span" style="color: #4c1130;"&gt;&lt;dependency&gt; &lt;/dependency&gt;&lt;/span&gt; tag for each JAR file of HTMLUnit.&lt;br /&gt;&lt;br /&gt;Sample of dependency tag is given below:&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;id&amp;gt;&lt;id&gt;htmlunit&amp;lt;/id&amp;gt;&lt;/id&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;version&amp;gt;&lt;version&gt;2.5&amp;lt;/version&amp;gt;&lt;/version&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;lt;url&amp;gt;&lt;url&gt;http://htmlunit.sourceforge.net/&amp;nbsp;&amp;lt;/url&amp;gt;&lt;/url&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;properties&gt;&amp;lt;properties&amp;gt;&lt;/properties&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;lt;war.bundle&amp;gt;&lt;war.bundle&gt;true&amp;nbsp;&amp;lt;/war.bundle &amp;nbsp;&amp;gt;&lt;/war.bundle&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ear.bundle&amp;gt;&lt;ear.bundle&gt;true&amp;lt;/ear.bundle&amp;gt;&lt;/ear.bundle&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;ear.bundle.dir&amp;gt;APP-INF/lib&amp;lt;/ear.bundle.dir&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;description&gt;&amp;lt;description&amp;gt;&lt;/description&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Use to handle JS obfuscation. It is a headless browser.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/description&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;license&amp;gt;Apache 2.0&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;http://www.apache.org/licenses/LICENSE-2.0 &amp;lt;/license&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/properties&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #666666;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;/dependency&amp;gt;&lt;/span&gt;&lt;br /&gt;Add this dependency tag for all JAR files of HTMLUnit.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step 4&lt;/b&gt;: Edit &lt;span class="Apple-style-span" style="color: red;"&gt;project.properties&lt;/span&gt; file in heritirx directory to instruct maven that, do not try to download those dependency files from Internet, rather look into &lt;b&gt;local directory&lt;/b&gt;. Syntax to do this can be easily found in &lt;span class="Apple-style-span" style="color: red;"&gt;project. properties&lt;/span&gt; file, simply make use of it.&lt;br /&gt;&lt;br /&gt;For example:&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="color: #666666;"&gt;maven.jar.htmlunit = ${basedir}/lib/htmlunit-2.5.jar&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Add a entry for each JAR file (that is, each dependency entry done in &lt;b&gt;Step 3 &lt;/b&gt;) of HTMLUnit.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Step 5&lt;/b&gt;. Done. Now build Heritrix again.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-3005935304771788108?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/3005935304771788108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2010/02/heritrix-and-htmlunit.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/3005935304771788108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/3005935304771788108'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2010/02/heritrix-and-htmlunit.html' title='Heritrix and HTMLUnit'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-2650421460638480037</id><published>2009-11-16T14:56:00.003+08:00</published><updated>2009-12-16T13:43:48.676+08:00</updated><title type='text'>How to Reset Sansa Mp3 Player when it Freezes</title><content type='html'>I got 2GB Sansa Mp3 player, as a complementary accessaries&amp;nbsp;with Nikon CoolPix L20.&lt;br /&gt;My Mp3 Player freezes, when I am charging it and accedentally unplug it, witout ejecting it. Some time it hungs while plying Song.&lt;br /&gt;&lt;br /&gt;After couple of try I found few solutions that can reboot Sansa MP3 Player, and it works with my Sansa MP3 player.&lt;br /&gt;&lt;br /&gt;1. &amp;nbsp;Turn &lt;span style="color: blue;"&gt;ON&lt;/span&gt; the &lt;span style="color: red;"&gt;Hold&lt;/span&gt; switch. (move hold button to Hold Position)&lt;br /&gt;2. &amp;nbsp;Press and hold &lt;span style="color: red;"&gt;Menu&lt;/span&gt; and &lt;span style="color: red;"&gt;Rec&lt;/span&gt; buttons at the s&lt;i&gt;ame time&lt;/i&gt; until the Sansa MP3 player reboots.&lt;br /&gt;&lt;br /&gt;Alternate Solution is :&lt;br /&gt;Hold &lt;span style="color: red;"&gt;Menu&lt;/span&gt; (Power) button for atleast 20 seconds. Sometimes this trick works.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;Hard Reset&lt;/span&gt; &lt;br /&gt;To perform hardware reset on the Sansa Express, press and hold the "Select" button while pressing the Volume UP (+) buttons simultaneously once.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-2650421460638480037?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/2650421460638480037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/11/how-to-reset-sansa-mp3-player-when-it.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2650421460638480037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2650421460638480037'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/11/how-to-reset-sansa-mp3-player-when-it.html' title='How to Reset Sansa Mp3 Player when it Freezes'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-100997563279997700</id><published>2009-11-16T14:28:00.008+08:00</published><updated>2009-11-16T15:45:58.336+08:00</updated><title type='text'>How to use ClamAv Antivirus on Ubuntu?</title><content type='html'>This tutorial will explain you, how to Install and use ClamAv Antivirus on Ubuntu. ClamAv antivirus is a free antivirus, available in ubuntu repository. &lt;br /&gt;&lt;br /&gt;To install ClamAv antivirus and GUI to manage it on ubuntu 9.10,&amp;nbsp; use &lt;span style="color: #274e13;"&gt;Ubuntu Software Center&lt;/span&gt; to install "&lt;span style="color: blue;"&gt;KlamAV&lt;/span&gt;".&amp;nbsp; KlamAV is an anti-virus manager for the KDE desktop. It allows virus scanning, software/update databases, etc.&lt;br /&gt;&lt;br /&gt;I am using "KlamAV" as a GUI tool to manage and use ClamAV antivirus. &amp;nbsp;You can also use "clamtk" as a GUI to use CLAMAV in Gnome or KDE.&lt;br /&gt;Use following command to install "clamtk"&lt;br /&gt;&lt;span style="color: blue;"&gt;sudo apt-get install clamtk&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Once it is installed on your machine,&amp;nbsp; then install anti-virus updater, so that you can get&amp;nbsp; latest update of ClamAV from Internet.&lt;br /&gt;&lt;div style="color: blue;"&gt;sudo apt-get install clamav-freshclam&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Use command "&lt;span style="color: purple;"&gt;sudo &lt;/span&gt;&lt;span style="color: purple; font-family: inherit;"&gt;freshclam&lt;/span&gt;&lt;span style="font-family: inherit;"&gt;" to update&lt;span style="font-family: inherit;"&gt; &lt;/span&gt;ClamAV database.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: inherit;"&gt;To check the version of ClamAV use following Command:&lt;span class="Apple-style-span" style="color: purple;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: purple;"&gt;clamdscan&amp;nbsp;-V&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="color: purple; font-family: inherit;"&gt;&lt;span style="color: black;"&gt;To do command line scanning:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple; font-family: inherit;"&gt;&lt;span style="color: black;"&gt;1.&amp;nbsp; To scan specific folder:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple; font-family: inherit;"&gt;&lt;span style="color: black;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;sudo clamscan -r /home/directoryname/subdirectory&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple; font-family: inherit;"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Above command will display the name of files in subdirectory on the screen. You can use &lt;span style="color: blue;"&gt;-i &lt;/span&gt;parameter to display only infected files.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple; font-family: inherit;"&gt;&lt;span style="color: black;"&gt;2.&amp;nbsp; To scan all files on your computer&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple; font-family: inherit;"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;sudo clamscan&amp;nbsp; -r&amp;nbsp;&amp;nbsp; --bell&amp;nbsp; -i&amp;nbsp;&amp;nbsp; /&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple; font-family: inherit;"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Above command will display only infected files and will bell the ring when virus found.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;3. To remove infected file from your computer&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;sudo clamscan -r -remove /&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: purple; font-family: inherit;"&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple; font-family: inherit;"&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple; font-family: inherit;"&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: purple; font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-100997563279997700?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/100997563279997700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/11/how-to-use-clamav-antivirus-on-ubuntu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/100997563279997700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/100997563279997700'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/11/how-to-use-clamav-antivirus-on-ubuntu.html' title='How to use ClamAv Antivirus on Ubuntu?'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-2353328876265498999</id><published>2009-11-13T15:41:00.011+08:00</published><updated>2009-11-16T19:38:20.844+08:00</updated><title type='text'>Lambda Calculus Type inference examples</title><content type='html'>1] &lt;span style="color: red;"&gt;\ x -&amp;gt; x&lt;/span&gt;&lt;br /&gt;&amp;nbsp;Above function takes one argument and returns the same argument as result, therefore type of argument and return value must be same.&lt;br /&gt;&lt;br /&gt;type: &lt;span style="color: blue;"&gt;a - &amp;gt; a&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2] &lt;span style="color: red;"&gt;\ x y -&amp;gt; x&lt;/span&gt;&lt;br /&gt;Above function takes two arguments and returns the first argument as result, therefore type of first argument and return value must be same.&lt;br /&gt;&lt;br /&gt;type: &lt;span style="color: blue;"&gt;a -&amp;gt; b -&amp;gt; a&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;3] &lt;span style="color: red;"&gt;\f g -&amp;gt; g (f g)&lt;/span&gt;&lt;br /&gt;Above function takes two parameter &lt;b&gt;f&lt;/b&gt; and &lt;b&gt;g&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;To solve this, my algorithm is as follows:&lt;br /&gt;&lt;br /&gt;First look at function body from &lt;b&gt;&lt;i&gt;right-to-left&lt;/i&gt;&lt;/b&gt;. Function body is&lt;span style="color: #783f04;"&gt; &lt;/span&gt;&lt;b&gt;&lt;span style="color: #783f04;"&gt;g&lt;/span&gt;(f &lt;span style="color: purple;"&gt;g&lt;/span&gt;)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Assume type of &lt;b style="color: purple;"&gt;g&lt;/b&gt; is &lt;i&gt;t1. That is,&amp;nbsp;&lt;/i&gt; ( &lt;b style="color: purple;"&gt;g&lt;/b&gt; = &lt;i&gt;t1&lt;/i&gt;).&lt;br /&gt;&lt;br /&gt;Now, take next variable from function body, which is &lt;b&gt;f&lt;/b&gt;.&amp;nbsp; &lt;b&gt;f&lt;/b&gt; is a function that take &lt;span style="color: purple;"&gt;g&lt;/span&gt; as argument and return value of any type, say return type is &lt;span style="color: lime;"&gt;a&lt;/span&gt;. So far, there is no restriction of return value of &lt;b&gt;f&lt;/b&gt;.&amp;nbsp; assume type of &lt;b&gt;f&lt;/b&gt; is &lt;i&gt;t1-&amp;gt; &lt;span style="color: lime;"&gt;a&lt;/span&gt;&lt;/i&gt;. That is,&amp;nbsp; (&lt;b&gt;f&lt;/b&gt; = &lt;i&gt;t1 -&amp;gt; &lt;span style="color: lime;"&gt;a&lt;/span&gt;&lt;/i&gt;).&lt;br /&gt;&lt;br /&gt;Now, take next variable, which is &lt;b&gt;&lt;span style="color: #783f04;"&gt;g&lt;/span&gt;&lt;/b&gt;.&amp;nbsp; &lt;b style="color: #783f04;"&gt;g&lt;/b&gt; is a function that takes return value of function &lt;b&gt;f&lt;/b&gt; as a argument (&lt;span style="color: lime;"&gt;a&lt;/span&gt;), and returns value of any type, say return type is &lt;span style="color: magenta;"&gt;b&lt;/span&gt;. So far there is no restriction of type of value return by &lt;b style="color: #783f04;"&gt;g&lt;/b&gt;.&amp;nbsp; But we already assume &lt;b&gt;g&lt;/b&gt; is of type &lt;i&gt;t1&lt;/i&gt;.&amp;nbsp; Now, we found that &lt;b&gt;g&lt;/b&gt; is function so, &lt;i&gt;t1&lt;/i&gt; is &lt;span style="color: lime;"&gt;a&lt;/span&gt; - &amp;gt; &lt;span style="color: magenta;"&gt;b&lt;/span&gt;.&lt;br /&gt;That is, (&lt;b&gt;&lt;span style="color: #783f04;"&gt;g&lt;/span&gt; = &lt;span style="color: purple;"&gt;g&lt;/span&gt;&lt;/b&gt; =&amp;nbsp; &lt;i&gt;t1 = &lt;span style="color: lime;"&gt;a&lt;/span&gt; -&amp;gt; &lt;span style="color: magenta;"&gt;b&lt;/span&gt;&lt;/i&gt;).&lt;br /&gt;&lt;br /&gt;Now replace &lt;i&gt;t1&lt;/i&gt; in &lt;b&gt;f&lt;/b&gt; with (&lt;span style="color: lime;"&gt;a&lt;/span&gt; -&amp;gt; &lt;span style="color: magenta;"&gt;b&lt;/span&gt;). So &lt;b&gt;f&lt;/b&gt; becomes &lt;b&gt;f &lt;/b&gt;= (&lt;span style="color: lime;"&gt;a&lt;/span&gt; -&amp;gt; &lt;span style="color: magenta;"&gt;b&lt;/span&gt; ) -&amp;gt; &lt;span style="color: lime;"&gt;a&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;we have done with function body. Now look at function declaration syntax. It takes two arguments &lt;b&gt;f&lt;/b&gt; and &lt;b&gt;g&lt;/b&gt;, and &lt;b&gt;f&lt;/b&gt; is first argument, &lt;b&gt;g&lt;/b&gt; is second argument, and return value is of same type of return value of &lt;b&gt;g&lt;/b&gt;. &lt;br /&gt;&lt;br /&gt;So type of function &lt;span style="color: red;"&gt;\f g -&amp;gt; g (f g&lt;/span&gt;) is as follows:&lt;br /&gt;&lt;br /&gt;((&lt;span style="color: lime;"&gt;a&lt;/span&gt; -&amp;gt; &lt;span style="color: magenta;"&gt;b&lt;/span&gt;) -&amp;gt; &lt;span style="color: lime;"&gt;a&lt;/span&gt;) -&amp;gt; ( &lt;span style="color: lime;"&gt;a&lt;/span&gt; -&amp;gt; &lt;span style="color: magenta;"&gt;b&lt;/span&gt;) -&amp;gt; &lt;span style="color: magenta;"&gt;b&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;4] &lt;span style="color: red;"&gt;\ x f g -&amp;gt; f g (x g)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;Above function accepts three arguments &lt;b&gt;x&lt;/b&gt;, &lt;b&gt;f&lt;/b&gt; and &lt;b&gt;g&lt;/b&gt;.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;Assume g is of type &lt;span style="color: orange;"&gt;a&lt;span style="color: black;"&gt;. that is,&lt;/span&gt; &lt;span style="color: black;"&gt;(&lt;b&gt;g&lt;/b&gt; = a).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;Now, &lt;b&gt;x&lt;/b&gt; takes g as a argument and returns any type of value. So far there is no restriction on type of value returned by &lt;b&gt;x&lt;/b&gt;, say return type of value is &lt;span style="color: purple;"&gt;b&lt;/span&gt;.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;Therefore, &lt;b&gt;x&lt;/b&gt; = &lt;span style="color: orange;"&gt;a&lt;/span&gt; -&amp;gt; &lt;span style="color: purple;"&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;Now, &lt;b&gt;f&lt;/b&gt; takes two argument &lt;b&gt;g&lt;/b&gt; and return type of &lt;b&gt;x&lt;/b&gt;. Return type of &lt;b&gt;f&lt;/b&gt; has no restriction, so say it is of type &lt;span style="color: blue;"&gt;c&lt;/span&gt;.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;Therefore, f = &lt;span style="color: orange;"&gt;a&lt;/span&gt; -&amp;gt; &lt;span style="color: purple;"&gt;b&lt;/span&gt; -&amp;gt; &lt;span style="color: blue;"&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(Note: For simplicity as assume &lt;b&gt;g&lt;/b&gt; as a variable. And is of type &lt;span style="color: orange;"&gt;a&lt;/span&gt;. However, you can consider it &lt;b&gt;g&lt;/b&gt; as a function then you have to unify &lt;span style="color: orange;"&gt;a&lt;/span&gt; = &lt;span style="color: orange;"&gt;d-&amp;gt;e&lt;/span&gt; and replace all occurrences of &lt;span style="color: orange;"&gt;a&lt;/span&gt; with &lt;span style="color: orange;"&gt;d-&amp;gt;e&lt;/span&gt;) &lt;br /&gt;&lt;br /&gt;&amp;nbsp; Return type of &lt;b&gt;f&lt;/b&gt; is the return type of this function.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: blue;"&gt;&lt;span style="color: black;"&gt;Now look at function definition and arrange its type accordingly. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: red;"&gt;\ x f g -&amp;gt; f g (x g) &lt;span style="color: black;"&gt;type is as follows:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="color: black;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;a&lt;/span&gt; -&amp;gt; &lt;span style="color: purple;"&gt;b&lt;span style="color: black;"&gt;) -&amp;gt;&lt;/span&gt; &lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;a&lt;/span&gt; -&amp;gt; &lt;span style="color: purple;"&gt;b&lt;/span&gt; -&amp;gt; &lt;span style="color: blue;"&gt;c&lt;span style="color: black;"&gt;)&lt;/span&gt; &lt;span style="color: black;"&gt;-&amp;gt; &lt;span style="color: orange;"&gt;a&lt;/span&gt; - &amp;gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: blue;"&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: orange;"&gt;&lt;span style="color: black;"&gt;&lt;span style="color: blue;"&gt;&lt;span style="color: black;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="color: black;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;5] &lt;span style="color: red;"&gt;\ f g x -&amp;gt; f ( g x)&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;br /&gt;Above function takes three arguments, namely, &lt;b&gt;f&lt;/b&gt; , &lt;b&gt;g&lt;/b&gt; ,and &lt;b&gt;x&lt;/b&gt;. &lt;br /&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;br /&gt;Assume &lt;b&gt;x&lt;/b&gt; is of type &lt;span style="color: orange;"&gt;a&lt;/span&gt;., That is ( &lt;b&gt;x&lt;/b&gt; = &lt;span style="color: orange;"&gt;a&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;Now &lt;b&gt;g&lt;/b&gt; takes &lt;b&gt;x&lt;/b&gt; as argument and returns a value. Assume return type of &lt;b&gt;g&lt;/b&gt; is &lt;span style="color: magenta;"&gt;b&lt;/span&gt;.&lt;br /&gt;Therefore, (&lt;b&gt;g&lt;/b&gt; = &lt;span style="color: orange;"&gt;a&lt;/span&gt; -&amp;gt; &lt;span style="color: magenta;"&gt;b&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;Now&lt;b&gt; f&lt;/b&gt; takes return value of &lt;b&gt;g&lt;/b&gt; as argument (that is, &lt;span style="color: magenta;"&gt;b&lt;/span&gt;) and returns a value. &lt;br /&gt;Therefore, ( &lt;b&gt;f&lt;/b&gt; = &lt;span style="color: magenta;"&gt;b&lt;/span&gt; -&amp;gt; &lt;span style="color: lime;"&gt;c&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;So type of &lt;span style="color: red;"&gt;\f g x -&amp;gt; f (g x)&lt;/span&gt; is:&lt;br /&gt;Now, look at function declaration: &lt;span style="color: red;"&gt;\f g x&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;(&lt;span style="color: magenta;"&gt;b&lt;/span&gt; -&amp;gt; &lt;span style="color: lime;"&gt;c&lt;/span&gt;) -&amp;gt; (&lt;span style="color: orange;"&gt;a&lt;/span&gt; -&amp;gt; &lt;span style="color: magenta;"&gt;b&lt;/span&gt;) -&amp;gt; &lt;span style="color: orange;"&gt;a&lt;/span&gt; -&amp;gt;&lt;span style="color: lime;"&gt;c&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6] &lt;span style="color: red;"&gt;\x y f -&amp;gt; f (x (\w -&amp;gt; f w)) (y f x)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Above function takes three arguments, &lt;b&gt;x y&lt;/b&gt; and &lt;b&gt;f&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;Now look at Function body, and assume type for each variable.&lt;br /&gt;Let w = a&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; x = t1 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = t2 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f&amp;nbsp; = t3&lt;br /&gt;&lt;br /&gt;&amp;nbsp;Observe the function body, &lt;b&gt;f &lt;/b&gt;will be applied to on first argument &lt;i&gt;(x (\w -&amp;gt; f x))&lt;/i&gt;,&amp;nbsp; and then it will be applied on second argument &lt;i&gt;(y f x)&lt;/i&gt;. &lt;br /&gt;&lt;br /&gt;Go inside \w function,&lt;br /&gt;&lt;br /&gt;&amp;nbsp;f = t3 = a - &amp;gt; b&lt;br /&gt;&lt;br /&gt;Therefore, x = t1 = (a -&amp;gt; b) -&amp;gt; c&lt;br /&gt;&lt;br /&gt;Return type of &lt;b&gt;x&lt;/b&gt; is &lt;b&gt;c&lt;/b&gt;, which will become the argument of &lt;b&gt;f&lt;/b&gt;, therefore unification is possible here, and &lt;i&gt;c = a&lt;/i&gt;;&lt;br /&gt;&lt;br /&gt;Hence, x = t1 = (a-&amp;gt;b) -&amp;gt;a&lt;br /&gt;&lt;br /&gt;Now we examine ( y f x) part,&lt;br /&gt;&lt;br /&gt;y = t2 = (a -&amp;gt; b) -&amp;gt; (a-&amp;gt;b-&amp;gt;a) -&amp;gt; d&lt;br /&gt;&lt;br /&gt;&lt;b&gt;d&lt;/b&gt; is the return type of &lt;b&gt;y&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;After applying the first argument&lt;i&gt; (x(\w-&amp;gt;f w))&lt;/i&gt;, &lt;b&gt;f&lt;/b&gt; returns &lt;b&gt;b&lt;/b&gt;. &lt;br /&gt;&lt;br /&gt;Therefore, d is parameter of b.&lt;br /&gt;&lt;br /&gt;b should take d as argument and return a value, That is, b = d -&amp;gt; e&lt;br /&gt;&lt;br /&gt;Now replace each occurrence of b with d -&amp;gt; e&lt;br /&gt;&lt;br /&gt;f = a -&amp;gt; b = a -&amp;gt; d -&amp;gt; e&lt;br /&gt;&lt;br /&gt;x = (a -&amp;gt;b -&amp;gt; a ) = ((a -&amp;gt; d -&amp;gt; e)- &amp;gt; a)&lt;br /&gt;&lt;br /&gt;y = (a -&amp;gt;d -&amp;gt; e) -&amp;gt; ( a -&amp;gt; d -&amp;gt; e) -&amp;gt; a) -&amp;gt; d&lt;br /&gt;&lt;br /&gt;Hence type of entire expression is, (arrenge according to function definition:&lt;br /&gt;&lt;br /&gt;((a -&amp;gt; d -&amp;gt; e)- &amp;gt; a) -&amp;gt;&lt;br /&gt;&amp;nbsp;(a -&amp;gt;d -&amp;gt; e) -&amp;gt; ( a -&amp;gt; d -&amp;gt; e) -&amp;gt; a) -&amp;gt; d -&amp;gt;&lt;br /&gt;(a -&amp;gt; d -&amp;gt; e) -&amp;gt; &lt;span style="color: blue;"&gt;e&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;e&lt;/span&gt; is the return type of entire expression which is also the return type of &lt;b&gt;f&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="color: magenta;"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt; &lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-2353328876265498999?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/2353328876265498999/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/11/lambda-calculas-type-inefernce-examples.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2353328876265498999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2353328876265498999'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/11/lambda-calculas-type-inefernce-examples.html' title='Lambda Calculus Type inference examples'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-2598191787454123354</id><published>2009-11-04T11:05:00.000+08:00</published><updated>2009-11-04T11:05:14.154+08:00</updated><title type='text'>Plugins Vs Extension</title><content type='html'>Extension and plugins often confused people. And Mostly people believe both are same.&lt;br /&gt;However, there is subtle difference between Extension and Plugin.&amp;nbsp; Extensions are mostly written in JavaScript and/or XUL and relies on XPCOM APIs to access resources. Whereas, plugins are binary applications and they make use of operating system and can do interaction with operating system or access events from OS. &lt;br /&gt;&lt;br /&gt;Securing plugins is more complex than extension.&amp;nbsp; Extension are individual identity so one extension needs one set of privileges, whereas plugins are more complicated and needs to identify privileges for each application runs plugins rather than a whole plugin.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-2598191787454123354?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/2598191787454123354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/11/plugins-vs-extension.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2598191787454123354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2598191787454123354'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/11/plugins-vs-extension.html' title='Plugins Vs Extension'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-5913854132440486264</id><published>2009-10-13T15:32:00.001+08:00</published><updated>2009-10-13T15:32:54.797+08:00</updated><title type='text'>JavaScript Call Stack</title><content type='html'>This post explains how to get JavaScript Calls stack in Mozilla extension. You can also use jsdI interface hooks to get JS call stack. Pls refer &lt;a href="http://mxr.mozilla.org/mozilla/source/js/jsd/idl/jsdIDebuggerService.idl"&gt;jsdIDebuggerService&lt;/a&gt;&amp;nbsp;on MDC.&lt;br /&gt;&lt;br /&gt;You need to call the function callstack( ) to get the JSCall stack. From where to call this function is depend on need of user.&amp;nbsp; You can call this function wherever you want to get JS call stack.&lt;br /&gt;&lt;br /&gt;function callstack( ){&lt;br /&gt;/* stackFrameStrings holds entire JS calls stack in string format */&lt;br /&gt;&lt;br /&gt;var stackFrameStrings = new Error().stack.split('\n');&lt;br /&gt;&lt;br /&gt;/* remove first two stack frames because they are frames of callstack() and error() functions */&lt;br /&gt;stackFrameStrings.splice(0,2);&lt;br /&gt;&lt;br /&gt;&amp;nbsp; for (var i in stackFrameStrings) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A stack frame string split into parts. (example of stack frame string is: &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; href("http://www.comp.nus.edu.sg")@:0)&amp;nbsp;&amp;nbsp; Note 0 indicates native function call in Mozilla firefox,&amp;nbsp;and 1 is for onclick, onmouseover functions, ie. JS event functions, otherwise the number is line number in source file and&amp;nbsp;contains URL of source file. Anothe rexample of stack frame string is&amp;nbsp;:&lt;br /&gt;&amp;nbsp;onclick([object MouseEvent])@file:///home/patilkr/Desktop/Html%20Test/js_http_test.html:1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var stackFrame = stackFrameStrings[i].split(&lt;a href="mailto:'@'"&gt;'@'&lt;/a&gt;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (stackFrame &amp;amp;&amp;amp; stackFrame.length == 2) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dump("\n stackFrame[0]=" + stackFrame[0] + " stackFrame[1]=" + stackFrame[1] ); &lt;br /&gt;&amp;nbsp;&amp;nbsp; } // end of if loop&lt;br /&gt;&lt;br /&gt;&amp;nbsp;}//end of for loop &lt;br /&gt;} //end of callstack function &lt;br /&gt;&amp;nbsp;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-5913854132440486264?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/5913854132440486264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/10/javascript-call-stack.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/5913854132440486264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/5913854132440486264'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/10/javascript-call-stack.html' title='JavaScript Call Stack'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-4072827249939841592</id><published>2009-10-07T14:06:00.006+08:00</published><updated>2010-05-24T13:58:48.658+08:00</updated><title type='text'>Mozilla Firefox about:config Tweaks</title><content type='html'>&lt;strong&gt;Accessing your &lt;em&gt;about:config&lt;/em&gt; page&lt;/strong&gt;&lt;br /&gt;In your Firefox, type &lt;em&gt;about:config&lt;/em&gt; in the address bar.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Disable Delay Time When Installing Add-on&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Config name: &lt;i&gt;security.dialog_enable_delay&lt;/i&gt;&lt;br /&gt;Default: &lt;i&gt;2000 (in msec)&lt;/i&gt;&lt;br /&gt;Modified value:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;0 – start installation immediately&amp;nbsp; &lt;br /&gt;&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;any other value (in msec)&lt;/i&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;View Source in Your Favorite Editor&amp;nbsp;&lt;/b&gt;&lt;br /&gt;There are two configuration need to be made:&lt;br /&gt;Config name: &lt;i&gt;view_source.editor.external&lt;/i&gt;&lt;br /&gt;Default:&lt;i&gt; False&lt;/i&gt;&lt;br /&gt;Modified value: &lt;i&gt;True ( enable view source using external text editor)&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Config name: &lt;i&gt;view_source.editor.path&lt;/i&gt;&lt;br /&gt;Default: &lt;i&gt;blank&lt;/i&gt;&lt;br /&gt;Modified value: &lt;i&gt;insert the file path to your editor here.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Autohide Toolbar in Fullscreen mode&amp;nbsp;&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;Config name: &lt;em&gt;browser.fullscreen.autohide&lt;/em&gt;&lt;br /&gt;Default: &lt;em&gt;True (always autohide)&lt;/em&gt;&lt;br /&gt;Modified value: &lt;em&gt;False (always show the toolbar)&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-4072827249939841592?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/4072827249939841592/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/10/mozilla-firefox-aboutconfig-tweaks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/4072827249939841592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/4072827249939841592'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/10/mozilla-firefox-aboutconfig-tweaks.html' title='Mozilla Firefox about:config Tweaks'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-5993738250764465970</id><published>2009-10-02T12:21:00.003+08:00</published><updated>2009-10-02T12:24:51.396+08:00</updated><title type='text'>90/10 and Self assement Principals</title><content type='html'>&lt;div style="text-align: justify;"&gt;This is a non-technical post. It is about, how to improve yourself. How to improve your thinking and your life. Principals describe here, if you applied in your life then, they will surely help you to feel satisfaction.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;First principal is &lt;span style="color: blue;"&gt;90/10 Rule&lt;/span&gt;:&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;What is 90/10 Principal? Well, it is very simple. 10% of life is made of what happens to you and 90% of life is decided by how you react to things happens in your day to day life.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Let me explain this in more detail:&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;We really have &lt;span style="color: purple;"&gt;NO&lt;/span&gt; control over 10% of incidences that happens to us. &lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;For example, We cannot stop plane from arriving late, we cannot stop mechanical devices from breaking down.&amp;nbsp; We cannot control this 10% of incidences happens to us, However, over the 90% of incidences we have control and our reaction to the situation is the key factor which plays an important role in deciding 90% of our life.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;If someone says something negative about you,&amp;nbsp; do not be a sponge or do not lose your tamper. &lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Let the attack roll off like water on glass. You do not have to let the negative comments affect you.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;React properly and it will not ruin your day. A wrong reaction could result in losing a friend, or getting stressed out. &lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Remember the 90/10 Principle and don’t worry about life.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;You are told you lost your job. Why lose sleep and get irritated?&amp;nbsp; It will work out. &lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Use your worrying energy and time to find a new job.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Millions of people are suffering from stress,&amp;nbsp; problems and headaches. &lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;We all must understand and apply the 90/10 Principle.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;It can change your life! You will lose nothing if you apply it.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Second Principal is &lt;span style="color: blue;"&gt;Self Assessment&lt;/span&gt;:&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Self assessment means do a regular review of your daily activity/reaction/behavior&amp;nbsp; at the end of day.&amp;nbsp; It helps to make judgment about our own actions.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;If you apply this two principals in your life, you will surely be get benefited from it, without lossing anything. You will observe its good effect in you life by yourself.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-5993738250764465970?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/5993738250764465970/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/10/9010-and-self-assement-principals.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/5993738250764465970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/5993738250764465970'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/10/9010-and-self-assement-principals.html' title='90/10 and Self assement Principals'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-2342143734291943738</id><published>2009-09-18T15:37:00.003+08:00</published><updated>2009-09-18T15:43:08.186+08:00</updated><title type='text'>How to access other VMs and Internet on VirtualBox</title><content type='html'>&lt;div style="text-align: justify;"&gt;VirtualBox supports &lt;span style="color: #444444;"&gt;NAT&lt;/span&gt;, &lt;span style="color: #444444;"&gt;host-only&lt;/span&gt;, &lt;span style="color: #444444;"&gt;Internal network&lt;/span&gt; and &lt;span style="color: #444444;"&gt;Bridged&lt;/span&gt; network options.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;When Network card of VirtualBox VM is configured with "&lt;span style="color: blue;"&gt;NAT&lt;/span&gt;" option then VM can access host machine and can access Internet, but cannot access other VMs. When I looked at IP address of VM's, I found that they all have same IP address.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;VirtualBox assigns same IP to all virtual machine (for example, 10.0.2.15) when NAT is configured.&amp;nbsp; That is, it treats all VM as they on different physical network.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;When Network Card of VirtualBox VM is configured with "&lt;span style="color: blue;"&gt;Internal Network&lt;/span&gt;" option then VM can access other VMs but cannot access Internet.&amp;nbsp; In this case, all VM are on same physical network.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;If you want to access other VMs as well as Internet, then the simplest solution is install two network cards in VM and assign one to NAT and another to internal network.&amp;nbsp; Then login to all VMs and assign unique address to internal network card of each VM. Note that, you have to assign address to network card which is configured for "Internal Network"&amp;nbsp; in VirtualBox.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;That's it. Done. Now you can access Internet as well as other VMs.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-2342143734291943738?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/2342143734291943738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/virtual-box-ip-problem.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2342143734291943738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2342143734291943738'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/virtual-box-ip-problem.html' title='How to access other VMs and Internet on VirtualBox'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-6954290397420960749</id><published>2009-09-18T14:56:00.002+08:00</published><updated>2009-09-18T16:19:04.033+08:00</updated><title type='text'>Object Oriented Programming</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="color: blue;"&gt;Struct&lt;/span&gt; is use to define data types and group them into one object. Struct does not contain methods or functions, and its data members are all &lt;i&gt;public&lt;/i&gt;. Struct are useful when we want sets of element with different data types.&amp;nbsp; Struct is a group of data elements grouped under one name. Those data elements are know as members and can have differnet type and different lengths.&amp;nbsp; Struct creates a new type. Once a struct is created a new type with the name of struct is created. It can be used later on in the program to create objects of struct. &lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;A &lt;span style="color: blue;"&gt;Class&lt;/span&gt; have both data members and functions/methods associated with it. A class can contain sever variables and functions/methods, those are called members of class. Bydefault all its members are &lt;i&gt;private&lt;/i&gt;. &lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Class can define its member as private, protected, public.&amp;nbsp; Protected has a special meaning to inheritance. Protected members are accessible in the class that defines them as well as in the classes that inherit from that base class or friend of it.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp;Class can contain special member functions called as constructors or destructors. Constructors cannot be explicitly called like regular member functions. They are automatically executed when new object of class is created.&amp;nbsp; &lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;In principal, private and protected members of a class cannot be accessed from outside the scope of the same class in which they are declared.&amp;nbsp; However this rule does not affect &lt;span style="color: blue;"&gt;friends&lt;/span&gt;. Friendship is no transitive and it is not bidirectional. &lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: blue;"&gt;Inheritance &lt;/span&gt;is a key feature of C++ class. It allows to create a class which is derived from other classes, so it can automatically include/inherit members of base class.&amp;nbsp; When class inhertis from another class the members of derived class can access only the public/protected members of&amp;nbsp; base class, but cannot access private members of base class.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;In principal, a derived class inherits every member of base class except its constructor, destructor, and its friends. &lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: blue;"&gt;Virtual function/member&lt;/span&gt;: A member of class can be redefined in its derived classes is know as a virtual member.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;When the type of pointer is pointer to base class but it is pointing to an object of th derived class, &lt;span style="color: #666666;"&gt;virtual&lt;/span&gt; keyword in-front of member functions allows a member function of a derived class with the same name as one in base class to be called from base class pointer to derived class object.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;A class that declares or inherits a virtual function/member&amp;nbsp; is called a &lt;span style="color: blue;"&gt;polymorphic&lt;/span&gt; class.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: blue;"&gt;Abstract base class&lt;/span&gt; is a class that lacks implementation of atleast one member. Therefore, we cannot create object of that class (cannot create object of ABC - Abstract Base Class). These are the main differences between abstract class and a regular polymorphic class. &amp;nbsp; The function which lacks implementation is called as &lt;span style="color: blue;"&gt;pure virtual function&lt;/span&gt;. for example, &lt;span style="color: red;"&gt;virtual int function_name() = 0; &lt;span style="color: black;"&gt;However, pointers of ABC (Abstract Base Class) can be used to point to objects of derived classes.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: red;"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;span style="color: blue;"&gt;Templates&lt;/span&gt; are special types that can operate with &lt;span style="color: blue;"&gt;generic types&lt;/span&gt;. Templates allows us to create a function template whose functionality can be adapted to more than one type without repeating the entire code. That is, we don't need to write the same functionality code for different types such as int, float, char, etc. This allows generic programming, bocz it access any type object. &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-6954290397420960749?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/6954290397420960749/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/object-oriented-programming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6954290397420960749'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6954290397420960749'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/object-oriented-programming.html' title='Object Oriented Programming'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-5112158361079546660</id><published>2009-09-18T14:27:00.004+08:00</published><updated>2009-09-18T14:36:36.834+08:00</updated><title type='text'>Vector better than Array and works as Array</title><content type='html'>&lt;div style="text-align: justify;"&gt;Vector is a template class and it allows programmers to create a dynamic array of elements of one type per instance.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&amp;nbsp; Vector is conceptually same as arrays in C. However, vector size can expand to hold more elements and can shrink when fewer will suffice.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Note: Accessing members of vector or appending elements does not depend on vector size and takes fixed amount of time, however, locating a specific value element or inserting value element into vector takes the amount of time directly proportional to its location in vector.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;////////////////////////////////////////////////////////////////////// &lt;br /&gt;// Standard Template Library&amp;nbsp; (STL)&lt;br /&gt;//&lt;br /&gt;// Vector Functions:&lt;br /&gt;//&lt;br /&gt;// vector::push_back - Appends (inserts) an element to the end of a&lt;br /&gt;// vector, allocating memory for it if necessary.&lt;br /&gt;//&lt;br /&gt;// vector::pop_back -&amp;nbsp; Erases the last element of the vector.&lt;br /&gt;//&lt;br /&gt;// vector::size - Returns number of elements in the vector.&lt;br /&gt;//&lt;br /&gt;//////////////////////////////////////////////////////////////////////&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#include &lt;iostream&gt;&lt;iostream&gt;&amp;lt;iostream&amp;gt;&lt;br /&gt;#include &amp;lt;vector &amp;gt;&lt;vector&gt;&lt;vector&gt;&lt;br /&gt;&lt;br /&gt;using namespace std ;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Dynamically allocated vector begins with 0 elements.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vector&amp;lt;int&amp;gt;&lt;int&gt; theVector;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add one element to the end of the vector, an int with the value 1.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Allocate memory if necessary.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; theVector.push_back(1) ;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add two more elements to the end of the vector.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // theVector will contain [ 1, 2, 3 ].&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; theVector.push_back(2) ;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; theVector.push_back(3) ;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int tmp;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; "\n Enter new element on new line. press Ctrl +D to terminate " &amp;lt;&lt;endl;&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (cin &amp;gt;&amp;gt; tmp)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; theVector.push_back(tmp);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Erase last element in the vector.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; theVector.pop_back();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; theVector.pop_back();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Print contents of theVector.&amp;nbsp;&lt;/endl;&gt;&lt;/int&gt;&lt;/vector&gt;&lt;/vector&gt;&lt;/iostream&gt;&lt;/iostream&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; "theVector [" ;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int k =0; k &amp;lt; theVector.size(); k++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt;" " &amp;lt;&amp;lt; theVector[k];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cout &amp;lt;&amp;lt; " ]" &amp;lt;&amp;lt; endl ;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-5112158361079546660?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/5112158361079546660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/vector-better-than-array-and-works-as.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/5112158361079546660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/5112158361079546660'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/vector-better-than-array-and-works-as.html' title='Vector better than Array and works as Array'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-5311153185337424171</id><published>2009-09-11T18:09:00.005+08:00</published><updated>2009-09-11T18:11:54.660+08:00</updated><title type='text'>Who calls main() function in C</title><content type='html'>&lt;div style="text-align: justify;"&gt;The &lt;span style="color: blue;"&gt;run-time&lt;/span&gt; environment calls the &lt;code&gt;main&lt;/code&gt; function to begin program execution.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;On Linux operating system, C runtime file can be found in either &lt;span style="color: blue;"&gt;/usr/lib &lt;/span&gt;directory or &lt;span style="color: blue;"&gt;/lib&lt;/span&gt; directory.&amp;nbsp; &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;crt0&lt;/b&gt; (or crt0.o, gcrt0.o, mcrt0.o) is a set of execution startup routines&amp;nbsp; that are platform-dependent, and is required in order to compile using the GCC and other GNU tools.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;crt stands for '&lt;span style="color: blue;"&gt;C runtime&lt;/span&gt;'.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Let me explain you the life cycle of c program:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;1. Create a C program&lt;/div&gt;&lt;div style="text-align: justify;"&gt;2. Compile C program to generate object file.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;3. Link object files (s)&lt;/div&gt;&lt;div style="text-align: justify;"&gt;4. execute the program&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;During compilation, compiler generates the object code for the program and for standard&amp;nbsp; C library functions used in program such as printf(), scanf (), etc, it puts the&amp;nbsp; entry in object file saying that "&lt;span style="color: black;"&gt;unresolved reference".&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: inherit; text-align: justify;"&gt;&lt;span style="color: black;"&gt;Linking can be static or dynamic.&amp;nbsp; During static linking, &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;pre style="font-family: inherit;" wrap=""&gt;&lt;span style="color: black;"&gt;the static linker (&lt;span style="color: blue;"&gt;ld&lt;/span&gt;) sees the unresolved reference to printf(), scanf(), and searches the available libraries for an implementation for printf(), scanf(), etc. In general this will be found in the C library (for example, &lt;span style="color: blue;"&gt;libC&lt;/span&gt; ). Now, the linker has two options:&lt;/span&gt;&lt;/pre&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;    &lt;br /&gt;&lt;pre style="font-family: inherit;" wrap=""&gt;&lt;span style="color: black;"&gt;Linker can take the printf(), scanf(), implementation from the library and copy it into the final executable accordingly. The linker then  searches the printf(), scanf() implementation for other unresolved references, and again consult the libraries for resolution. This  process will be performed iteratively until all references to the symbols were resolved. This is known as &lt;b&gt;static linking&lt;/b&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: inherit;" wrap=""&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;    &lt;br /&gt;&lt;pre style="font-family: inherit;" wrap=""&gt;&lt;span style="color: black;"&gt;If the C library is realized as a `shared library', the linker can simply put a reference to the C library into the final  executable.&lt;/span&gt;&lt;span style="color: black;"&gt; &lt;/span&gt;&lt;span style="color: black;"&gt;This is known as &lt;b&gt;dynamic linking.&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: inherit;" wrap=""&gt;&lt;span style="color: black;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: inherit;" wrap=""&gt;&lt;span style="color: black;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black;"&gt;A statically linked executable is self contained. It is loaded into memory. The entry point, whose designation is system  dependent (for eg, the `__main' symbol) is found and called.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black;"&gt;In a dynamically linked executable, after loading the executable binary into memory, the dynamic linker (ld.so.1) takes control first. It reads the library references to dynamic libraries produced by the static linker, and loads them into memory. It then performs symbol resolution and updates all references to symbols in the shared library to point to their actual location, which can only be determined at runtime, because the shared libraries might be loaded to different memory locations each time the executable binary gets executed.&lt;br /&gt;&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;&lt;pre style="font-family: inherit;" wrap=""&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-5311153185337424171?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/5311153185337424171/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/who-calls-main-function-in-c.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/5311153185337424171'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/5311153185337424171'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/who-calls-main-function-in-c.html' title='Who calls main() function in C'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-2481618236090094991</id><published>2009-09-10T13:56:00.002+08:00</published><updated>2009-09-10T13:57:10.010+08:00</updated><title type='text'>C++ pointer</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;b&gt;Pointers&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Reference Operator (&amp;amp;)&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The address that locates a variable within memory is what we call a &lt;i&gt;reference&lt;/i&gt; to that variable.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;A variable which stores a reference to another variable is called a &lt;i&gt;pointer&lt;/i&gt;.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: blue;"&gt;&amp;amp;&lt;/span&gt; is the reference operator and can be read as "&lt;span style="color: blue;"&gt;address of&lt;/span&gt;"&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: blue;"&gt;*&lt;/span&gt; is the dereference operator and can be read as "&lt;span style="color: blue;"&gt;value pointed by&lt;/span&gt;"&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The declaration of pointers follows this format:&lt;br /&gt;&lt;span style="color: red;"&gt;type * name;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: red;"&gt;&amp;nbsp;&lt;span style="color: #666666;"&gt;where type is the data type of the value that the pointer is intended to point to. This type is not the type of the &lt;/span&gt;&lt;span style="color: #666666;"&gt;pointer itself! but the type of the data the pointer points to.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="color: black; text-align: justify;"&gt;For example:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: red;"&gt;&lt;span style="color: #666666;"&gt;&lt;span style="color: blue;"&gt;int * number;&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;char * character;&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;float * realnumber;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #666666;"&gt;These are three declarations of pointers. Each one is intended to point to a different data type, but in fact all of them are pointers and all of them will occupy the same amount of space in memory. Nevertheless, the data to which they point to do not occupy the same amount of space nor are of the same type: the first one points to an int, the second one to a char and the last one to a float.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: black;"&gt;Void Pointer&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: black;"&gt;The void type of pointer is a special type of pointer. In C++, void represents the absence of type, so void pointers are pointers that point to a value that has no type.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-2481618236090094991?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/2481618236090094991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/c-points.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2481618236090094991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/2481618236090094991'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/c-points.html' title='C++ pointer'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-8685877838674717458</id><published>2009-09-03T21:33:00.091+08:00</published><updated>2009-09-03T22:27:23.481+08:00</updated><title type='text'>Makefile</title><content type='html'>&lt;div style="font-family: Verdana,sans-serif; text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;Compiling the source code of your program/project on Linux/UNIX system is tedious, specially when program/project has several source files and you have to type command every time you want to compile it.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;There is a utility called &lt;b&gt;make&lt;/b&gt; to build the applications.&amp;nbsp;&amp;nbsp; Make looks for a text file in the current directory called "makefile" or "Makefile" to execute.&amp;nbsp; &lt;b style="color: blue;"&gt;Makefile&lt;/b&gt; is a file that instructs the program &lt;i&gt;make&lt;/i&gt; how to compile and link a program. In this post I will explain, how to use GNU make utility with Makefiles.&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;How to write comments in the makefile&lt;/b&gt;:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif; text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;The &lt;b&gt;comment&lt;/b&gt; in the Makefile is indicated by the comment&lt;b&gt; &lt;/b&gt;character “&lt;b&gt;#&lt;/b&gt;”. All text from the comment character to the end of the line is ignored.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif; text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;Example:&lt;/span&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: Verdana,sans-serif; text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;# This is the comment in the Makefile&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif; text-align: justify;"&gt;&lt;span style="color: blue; font-size: small;"&gt;# Comment&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;How to define Variable in the Makefile&lt;/b&gt;:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif; text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;You can define variable in the makefile.&amp;nbsp; Variable definition format is as follows:&lt;/span&gt;&lt;/div&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="color: blue; font-size: small;"&gt;VARNAME = Value&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div style="font-family: Verdana,sans-serif; text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;For example, Lets define a variable and set it to the compiler which I want to use to compile my program code.&lt;/span&gt;&lt;/div&gt;&lt;pre style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;CC = g++&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;CC is the variable name and g++ is the compiler I want to use to compile my program.&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;How to use the variable&lt;/b&gt;:&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;We have define the variable CC above, now let me explain you, how to use it.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;To use the variable syntax is as follows:&lt;/span&gt;&lt;/pre&gt;&lt;pre style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;$(VARNAME)&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;In our example, we define CC variable, we can access the variable as follows:&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="color: blue; font-size: small;"&gt;$(CC)&lt;/span&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;How to compile program using command line&lt;/b&gt;:&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Suppose my program name is myprog.cpp. To compile it, I have to type following command:&lt;/span&gt;&lt;/pre&gt;&lt;pre style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;g++ -o myexe myprog.cpp&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Whereas myexe is an executable file name and myprog.cpp is the source file of my program.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;If I want to compile my program multiple times then I have to issue this command multiple times.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Things become more complicated when I need to give some parameter to compile my program such as&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;optimization parameters, library paths, etc.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Makefile comes for rescue here.  Create a new text file and named it as Makefile. Do not give any extension to it.&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Simply put the command (g++ -o myexe myprog.cpp) in the makefile, save the file, and at command&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;prompt type &lt;b&gt;make&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;#Makefile&lt;br /&gt;     g++ -o myexe myprog.cpp&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style="font-family: Verdana,sans-serif; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Now suppose we have three source files namely &lt;i&gt;mainprog.cpp&lt;/i&gt;, &lt;i&gt;file1.cpp&lt;/i&gt; and &lt;i&gt;file2.cpp&lt;/i&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Verdana,sans-serif; text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Then you can create a makefile as follows:&lt;/span&gt;&lt;/div&gt;&lt;pre style="color: #666666; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;g++ -c -o file1.o file1.cpp&lt;br /&gt;g++ -c -o file2.o file2.cpp&lt;br /&gt;g++ -o myexe mainprog.cpp file1.o file2.o&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;You can now make use of variables and can make the Makefile much simpler as shown below:&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;COMPILER=g++&lt;br /&gt;OBJS=mainprog.o file1.o file2.o&lt;br /&gt;default: myapp&lt;/span&gt;&lt;/pre&gt;&lt;pre style="color: blue; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;myapp: $(OBJS)&lt;br /&gt; $(COMPILER) -o myexe $(OBJS)&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;You only need to issue only the &lt;b&gt;make&lt;/b&gt; command everytime you want to compile you program, that's it.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;If the source file in your project increses then you only have to add filename.o to&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;OBJS variable list, that's it. Very simple. &lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-8685877838674717458?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/8685877838674717458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/makefile.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/8685877838674717458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/8685877838674717458'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/makefile.html' title='Makefile'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-6101757640154964467</id><published>2009-09-02T11:37:00.021+08:00</published><updated>2009-09-02T11:47:33.479+08:00</updated><title type='text'>JavaScript Scramblers / Obfuscators Softwares and Techniques they used</title><content type='html'>&lt;div style="font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif; text-align: justify;"&gt;&lt;pre wrap=""&gt;&lt;span style="font-size: large;"&gt;There are many JavaScript Scrambling softwares/tools available on Internet.&lt;br /&gt;All of them aims to scramble the JavaScript source code to prevent the theft of JavaScript Code.&lt;br /&gt;Obfuscated code is a source code that is very hard to read and understand. &lt;br /&gt;Macro preprocessors are often used to create hard to read code by masking the standard language syntax and grammar from the main code.&lt;br /&gt;&lt;br /&gt;How to create hard to read code (Obfuscated code)?&lt;br /&gt;Take a JavaScript code in .JS files or in HTML files as a input  and replace descriptive variable and function names like Customer, Salary, FirstName... with meaningless names like x0de234f, III111000, oo00ooo... &lt;br /&gt;Also removes comments and unnecessary whitespace characters (space, tab, carriage return, line feed). The functionality of the code remains the same while source code changes dramatically. This process is called obfuscation, and the tool is called obfuscator.&lt;br /&gt;&lt;br /&gt;I tried to find and collect under one roof information about JavaScript Obfuscators.&lt;br /&gt;&lt;br /&gt;1. Stunnix JavaScript Obfuscator&lt;br /&gt; Stunnix JavaScript Obfuscator converts scripts in input files into highly mangled and obfuscated form, while fully retaining  functionality of the original code.&lt;br /&gt; It provides different encoding techniques such as MD5 (Message Digest version 5), set of o and 0, and set of I and 1 for identifiers/variables/function names. Similarly it provides different encoding technique such as Hex escapes, List of codes for strings. It uses regular expression to replace numbers. It gives freedom to the programmer to select encoding technique of there choice to make JavaScript code difficult to study and analyze. It is also possible to encode the code using one set of encoding techniques and again encode the encoded code using different set of encoding techniques supported by the tool. For example, first encode using a set {MD5, Hex escapes, regular expression} and then encode the encoded code using same or another set of supported techniques by the tool such as {set of o and 0, List of codes, regular expressions}.   &lt;br /&gt; Examples of Encoding techniques of Stunnix tool are given below:&lt;br /&gt; Encoding for Identifiers/variables/function name:&lt;br /&gt;  1. MD5: Message Digest version 5, &lt;br /&gt;   It generates hash value for identifier/variable_name or function_name and replaces the occurrence of identifier/variable with its hash value. (for example every occurrence of FACTORIAL function name in the script is replaced with it hash value Z001C775808)&lt;br /&gt;  2. set of I and 1&lt;br /&gt;   It generates a unique set of I's and 1's for each identifier/variable_name ( for example every occurrence of      SHOW_TOP_RECORDS function name in the script is replaced by IlIlIIIllI)&lt;br /&gt;  3. set of o and 0 &lt;br /&gt;   It generates a unique set of o's and 0's for each identifier/variable_name ( for example every occurrence of      SHOW_TOP_RECORDS function name in the script is replaced by o0o0ooo00o)&lt;br /&gt; Encoding for strings in the script:&lt;br /&gt;  1. Hex escapes&lt;br /&gt;   It uses Hex encoding for strings (for example &lt;b&gt;no entries&lt;/b&gt; is replaced with  \x3c\x62\x3e\x6e\x6f\x20\x65\x6e\x74\x72\x69\x65\x73\x3c\x2f\x62\x3e)&lt;br /&gt;  2. List of Codes&lt;br /&gt;   Adds some constant prefix such as ReplacementFor_ to every occurance of string. (for example  strcomputer variable is replaced with ReplacementFor_strcomputer)&lt;br /&gt; Encoding for numbers/digits&lt;br /&gt;  It uses regular expression to encode numbers in the script. (For example every occurrence of number 232 is get replaced with 0x14b6+2119-0x1c15 in the script)&lt;br /&gt;&lt;br /&gt;2. TagsLock Pro. &lt;br /&gt; Replaces string characters (ASCII) with hexadecimal equivalent value and each preceded by a percent symbol. (For example, space character is hexadecimal 20, so the encoded version of a space character is %20)&lt;br /&gt; It uses JavaScript inbuilt function escape() to generate encoded version of string and uses inbuilt JavaScript function unescape() to decode it.&lt;br /&gt;&lt;br /&gt; For example:&lt;br /&gt;   Original JavaScript:&lt;br /&gt;      &lt;/span&gt;&lt;span style="color: blue; font-size: large;"&gt;document.write("Hello, world!"); &lt;/span&gt;&lt;span style="font-size: large;"&gt;   &lt;/span&gt;&lt;script&gt;&lt;br /&gt;&lt;!--&lt;br /&gt;document.write("Hello, world!");&lt;br /&gt;// --&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span style="font-size: large;"&gt;&lt;span style="font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;Scrambled JavaScript:&lt;br /&gt;&lt;br /&gt;          &lt;span style="color: blue;"&gt;document.write(unescape('%3cs%63ript%3e%3c%21%2d-%0d%0ado%63ument.write("%48%65llo%2c %77orld%21")&lt;/span&gt;&lt;/span&gt;;&lt;/span&gt;&lt;span style="color: blue; font-size: large;"&gt; %0d%0a%2f%2f %2d%2d%3e%0d%0a%3c/s%63%72i'+'pt%3e %0d%0a%0d%0a'))      &lt;/span&gt;&lt;script language="JavaScript"&gt;&lt;br /&gt;document.write(unescape('%3cs%63ript%3e%3c%21%2d-%0d%0ado%63ument.write("%48%65llo%2c %77orld%21");&lt;br /&gt;%0d%0a%2f%2f %2d%2d%3e%0d%0a%3c/s%63%72i'+'pt%3e %0d%0a%0d%0a'))&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;&lt;span style="font-size: large;"&gt;3. iWeb Tool. &lt;br /&gt; Similar to TagsLock Pro, iWeb tool uses escape() function to convert string (ASCII) into hex encoding.  But to make it more confusing it perform encoding on hex encoded string and converts hex encoded string into unicode. &lt;br /&gt; To decrept it uses a inbuilt JavaScript function String fromCharCode() to convert it from Unicode to hex codes and then using unescape () function converts hex codes into a string (ASCII). &lt;br /&gt; It keeps the Javascript inbuilt function name as it is, such as document.write in original source code will as it is appear in encoded code.&lt;br /&gt; For example:&lt;br /&gt; Original Code:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;  &lt;script&gt;&lt;br /&gt;document.write("Hello")&lt;br /&gt;&lt;/script&gt;&lt;span style="font-size: large;"&gt; &lt;/span&gt;&lt;span style="color: blue; font-size: large;"&gt;document.write("Hello")&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre wrap=""&gt;&lt;span style="font-size: large;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre wrap=""&gt;&lt;span style="font-size: large;"&gt;Encrypted Code:&lt;br /&gt;  &lt;/span&gt;&lt;span style="color: blue; font-size: large;"&gt;var enkripsi="'1Aqapkrv'1Gfmawoglv,upkvg'0:'00Jgnnm'00'0;'1A-qapkrv'1G"; teks=""; teksasli="";var    panjang;panjang=enkripsi.length;for (i=0;i&lt;/span&gt;&lt;span style="font-size: large;"&gt;&lt;panjang;i++){ class="moz-txt-sup" teks+="String.fromCharCode(enkripsi.charCodeAt(i)&amp;lt;sup"&gt;&lt;span style="color: blue;"&gt;2) }teksasli=unescape(teks);document.write(teksasli);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;4. Javascript Obfuscator v2.53. &lt;br /&gt; It reads files with JavaScript code and replaces each occurance of descriptive&lt;br /&gt;variable and function names like CHILDNODE, FIRSTNAME, LASTNAME... with meaningless names like Ia, g, m... &lt;br /&gt;It also removes comments and unnecessary whitespace characters (such as space, tab, carriage return, line feed).&lt;br /&gt;&lt;br /&gt;5. Ajaxian JavaScript Obfucator. &lt;br /&gt; It is same as JavaScript Obfuscator v2.53. &lt;br /&gt; And Like a iWeb tool, it does not replace document.write() function name, that is the rule is not to replace the function name or vaiable name if it has ".". &lt;br /&gt;&lt;br /&gt;6. JavaScript Scrambler v1.11. &lt;br /&gt; It is the simplest JavaScript Obfuscator, which removes comments and unnecessary whitespace characters. It keeps the variable names and Javascript code as it is; except only changes function names in the original code. (for example,  every occurance of function name "doTICKER" is get replaced with "x0822631")&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;References&lt;/b&gt;&lt;br /&gt;1. Stunnix JavaScript Obfuscator. &lt;a class="moz-txt-link-freetext" href="http://www.stunnix.com/prod/jo/"&gt;http://www.stunnix.com/prod/jo/&lt;/a&gt;&lt;br /&gt;2. TagsLock Pro. &lt;a class="moz-txt-link-freetext" href="http://www.aerotags.com/faq/tips-js-protection.php"&gt;http://www.aerotags.com/faq/tips-js-protection.php&lt;/a&gt;&lt;br /&gt;3. iWeb Tool. &lt;a class="moz-txt-link-freetext" href="http://www.virtualpromote.com/tools/javascript-encrypt/"&gt;http://www.virtualpromote.com/tools/javascript-encrypt/&lt;/a&gt;&lt;br /&gt;4. Javascript Obfuscator v2.53. &lt;a class="moz-txt-link-freetext" href="http://javascript-source.com/javascript-obfuscator.html"&gt;http://javascript-source.com/javascript-obfuscator.html&lt;/a&gt;&lt;br /&gt;5. Ajaxian JavaScript Obfucator. &lt;a class="moz-txt-link-freetext" href="http://ajaxian.com/archives/utility-javascript-obfuscator"&gt;http://ajaxian.com/archives/utility-javascript-obfuscator&lt;/a&gt;&lt;br /&gt;6. JavaScript Scrambler v1.11. &lt;a class="moz-txt-link-freetext" href="http://www.quadhead.de/jss.html"&gt;http://www.quadhead.de/jss.html&lt;/a&gt;&lt;/panjang;i++){&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-6101757640154964467?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/6101757640154964467/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/javascript-scramblers-obfuscators.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6101757640154964467'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6101757640154964467'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/javascript-scramblers-obfuscators.html' title='JavaScript Scramblers / Obfuscators Softwares and Techniques they used'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-7576255901045165442</id><published>2009-09-02T11:26:00.007+08:00</published><updated>2009-09-02T11:32:38.985+08:00</updated><title type='text'>Obfuscated code examples</title><content type='html'>&lt;div style="text-align: justify;"&gt;In this post I will give to some examples of JavaScript Obfuscation.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Example 1:&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;This following code is obfuscated using online JavaScript Obfuscator on &lt;a href="http://www.javascriptobfuscator.com/"&gt;http://www.javascriptobfuscator.com/&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Plain text Code:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="color: blue; text-align: justify;"&gt;var a="Hello World!";&lt;br /&gt;function MsgBox(msg)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert(msg+"\n"+a);&lt;br /&gt;}&lt;br /&gt;MsgBox("OK");&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Obfuscated code:&lt;br /&gt;&lt;span style="color: blue;"&gt;var _0x8e48=["\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21","\x0A","\x4F\x4B"];var a=_0x8e48[0];function MsgBox(_0xab5dx3){alert(_0xab5dx3+_0x8e48[1]+a);} ;MsgBox(_0x8e48[2]);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;You can apply multiple level of obfuscation by repeatedly obfuscating the obfuscated code.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Following obfuscated code is 2 level obfuscation of plain text code given above.&amp;nbsp; That is, obfuscation of obfuscated code.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Obfuscated code of the Obfuscated code given above:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: blue;"&gt;var _0x1c08=["\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21","\x0A","\x4F\x4B"];var _0x1bae=[_0x1c08[0],_0x1c08[1],_0x1c08[2]];var a=_0x1bae[0];function MsgBox(_0xc9d7x4){alert(_0xc9d7x4+_0x1bae[1]+a);} ;MsgBox(_0x1bae[2]);&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;b&gt;Example 2:&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The following code is obfuscated using&amp;nbsp; online JavaScript Obfuscator. &lt;a href="http://www.virtualpromote.com/tools/javascript-encrypt/"&gt;http://www.virtualpromote.com/tools/javascript-encrypt/&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Plain text code:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: blue;"&gt;document.write("hello, world");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Obfuscated code:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: blue;"&gt;var enkripsi="'1Aqapkrv'1G'2Cfmawoglv,upkvg'0:'00jgnnm'0A'02umpnf'00'0;'1@'2C'1A-qapkrv'1G"; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;teks=""; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;teksasli="";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;var panjang;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;panjang=enkripsi.length;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;for (i=0;i&lt;panjang;i++){&gt;&lt;/panjang;i++){&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;&amp;nbsp; teks+=String.fromCharCode(enkripsi.charCodeAt(i)^2) &lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;teksasli=unescape(teks);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: blue;"&gt;document.write(teksasli);&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;In the second example, document.write is used. So during parsing of the code in the browser (for example, Firefox), DOM nodes will be get created for obfuscated code and for each level of&amp;nbsp; de-obfuscated code.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-7576255901045165442?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/7576255901045165442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/obfuscated-code-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/7576255901045165442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/7576255901045165442'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/09/obfuscated-code-examples.html' title='Obfuscated code examples'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-818155530396247757</id><published>2009-08-29T18:32:00.008+08:00</published><updated>2009-08-31T20:53:00.756+08:00</updated><title type='text'>Obfuscated Code</title><content type='html'>&lt;div style="text-align: justify;"&gt;When source code in programming language is transform to human unreadable form then it is known as &lt;b&gt;Obfuscated Code&lt;/b&gt;.&amp;nbsp; The software that performs obfuscation on code are called as &lt;i&gt;obfuscators&lt;/i&gt;. &lt;/div&gt;&lt;div style="text-align: justify;"&gt;Obfuscation on the source code can be used for good purpose as well as for bad purpose. Programmers can obfuscate there code to conceal its purpose, to avoid theft of there code. This is also known as security through obscurity. On other hand, attackers can use obfuscator to hide malicious program.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The code written in languages which can be obfuscated&amp;nbsp; includes but not limited to are C, C++, Perl, JavaScript, etc.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Obfuscation by &lt;b&gt;code morphing&lt;/b&gt;&amp;nbsp; refers to obfuscating &lt;i&gt;machine language&lt;/i&gt; code or &lt;i&gt;object&lt;/i&gt; code rather than obfuscating the source code.&lt;br /&gt;&lt;br /&gt;Obfuscated code makes it difficult to reverse engineer the code, but it is not impossible to reverse engineer the obfuscated code.&amp;nbsp; Obfuscated code makes it difficult to debug, because the variable names no longer make sense, and the structure of code is hard to recognize.&lt;br /&gt;&lt;br /&gt;In this post I will mainly focus on the JavaScript Obfuscators, techniques used for JavaScript Obfuscation, and JavaScript Obfuscation used in malicious software.&lt;br /&gt;&lt;br /&gt;Obfuscated JavaScript code is mostly used by spammers in spam messages.&amp;nbsp;&amp;nbsp; The obfuscation makes it difficult for investigators to identify what exactly the JavaScript code does? or where the link goes?. Attackers used JavaScript Obfuscation to conceal an entire or some part of code that runs browser exploit.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The good news about JavaScript source code obfuscation techniques&amp;nbsp; is, they are limited to number of techniques (de-obfuscation) supported by Web browser. However the bad news is, it is not limited to number of levels of obfuscation on source code. &amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-818155530396247757?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/818155530396247757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/08/obfuscated-code.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/818155530396247757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/818155530396247757'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/08/obfuscated-code.html' title='Obfuscated Code'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-6767746824288705989</id><published>2009-08-28T19:16:00.005+08:00</published><updated>2009-08-29T10:38:01.305+08:00</updated><title type='text'>While mixing C and C++ code, how to avoid name mangling done by C++ compiler for C Code</title><content type='html'>&lt;div style="font-family: inherit; text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;C language does not have overloading, that's why C&amp;nbsp; function names are not mangled by C compiler (such as GCC), but C++ has overloading. Overloading means the same function name can appear for more than two functions in C++ with different parameters. That's why C++ complier do name mangling to identify the function names uniquely.&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: inherit; text-align: justify;"&gt;&lt;span style="font-size: small;"&gt;You may encounter a problem while writing you own library by mixing C and C++ code. because you&amp;nbsp; have to compile it with C++ compiler and it will mangled the function names. If you want to avoid the mangling of function names done by C++ compiler then you can use &lt;b&gt;extern "C"&lt;/b&gt; keyword in the code. This will tell C++ compiler that do not mangled function names, variable names, defined in extern "C" brackets.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&lt;span style="font-size: small;"&gt;For example:&lt;/span&gt;&lt;/div&gt;&lt;pre style="font-family: inherit;"&gt;&lt;span style="font-size: small;"&gt;extern "C"&lt;br /&gt;{&lt;br /&gt;   int functionx();&lt;br /&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: inherit;"&gt;&lt;span style="font-size: small;"&gt;The name of &lt;b&gt;functionx&lt;/b&gt; will not be get mangled by C++ compiler. &lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-6767746824288705989?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/6767746824288705989/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/08/mixing-c-and-c-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6767746824288705989'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6767746824288705989'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/08/mixing-c-and-c-code.html' title='While mixing C and C++ code, how to avoid name mangling done by C++ compiler for C Code'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-4453687512823204784</id><published>2009-08-26T19:19:00.007+08:00</published><updated>2009-08-29T10:36:58.285+08:00</updated><title type='text'>Firefox-3.5 debugging problem on Ubuntu9.04</title><content type='html'>&lt;div style="text-align: justify;"&gt;I and my colleague Xinshu are working on Firefox-3.5 web browser and from last few months since Firefox-3.5 is released we were searching for how to debug Firefox-3.5 with gdb on ubuntu v9.04. We are able to debug Firefox-3.0 with gdb on ubuntu v9.04, but we were not be able to debug Firefox-3.5. Whenever we tried to debug Firefox-3.5 with gdb debugger, GDB  sometimes terminated by giving "Segmentation Fault" error , or sometimes terminated by giving memory leak error. So we developed a wrong impression that Firefox-3.5 cannot be debug with gdb in Ubuntu v9.04, because official version of Firefox-3.5 for ubuntu is not yet released. Ubuntu has Firefox v3.0.13 in its repository. However for Fedora and Windows, Firefox v3.5.2 is available. We searched on many blogs/forums, etc for the solution or does somebody faced/facing the same problem as we do. Many of them misdirected by saying some package is missing on your machine, which is required for Firefox-3.5 to debug on Ubuntu v9.04. We installed all the packages named on those forums, but had no luck, till today.&lt;br /&gt;My colleague   (Xinshu)  finally discovered the caused of error. And the solution was very simple, but not convenient for users who has many Firefox profiles for different purpose . &lt;br /&gt;When we looked into terminal window, we found that GDB terminated after Firefox creates a new process. And new process is created when you have multiple profiles on your system, and selecting the one out of them each time Firefox starts, was the source of error. Firefox creates a new process whenever we select the profile.&lt;br /&gt;So we tried by  deleting all profiles, and it was miracle, it really worked. The solution is very simple, delete all Firefox profiles and then try Firefox-3.5 to debug with GDB on Ubuntu. It works!.&lt;br /&gt;Although it is not convenient to users who have many profiles.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-4453687512823204784?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/4453687512823204784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/08/firefox-35-debugging-problem-on.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/4453687512823204784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/4453687512823204784'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/08/firefox-35-debugging-problem-on.html' title='Firefox-3.5 debugging problem on Ubuntu9.04'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-6585312809827317397</id><published>2009-08-26T19:13:00.008+08:00</published><updated>2009-08-29T10:39:04.306+08:00</updated><title type='text'>DOS attack on Firefox</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;b&gt;Denial of Service (DOS) Attack for Firefox &lt;/b&gt; &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;It is caused by consuming memory on user computer.  &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The main reason, why this attack is possible on Firefox is insufficient memory check at document.write function.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The parser first builds DOM tree on received input before it is displayed to user (or it is given to rendering unit). Following code consumes all available memory on your system, if you have quad-core processor with 4GB RAM then following code will terminate on that machine after few hours. (approx, 8 to 10 hrs)&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;hr style="margin-left: 0px; margin-right: 0px;" /&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;The sample code is given below:&lt;/b&gt;&lt;br /&gt;var a; &lt;br /&gt;for (var i=0; i &amp;lt; 32000; i++) { &lt;br /&gt;&lt;blockquote&gt;document.write(a+=i)); &lt;/blockquote&gt;} &lt;br /&gt;document.write("Terminated"); &lt;br /&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt; &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;script&gt; &lt;/p&gt;&lt;p&gt;var a; &lt;/p&gt;&lt;p&gt;for (var i=0; i &lt;&gt; &lt;blockquote&gt; &lt;p&gt;document.write(a+=String.fromCharCode(i)); &lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;} &lt;/p&gt;&lt;p&gt;document.write("Terminated"); &lt;/p&gt;&lt;p&gt;&lt;/script&gt; &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;hr style="margin-left: 0px; margin-right: 0px;" /&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Backtrace is as follows:&lt;/b&gt; &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;nsScannerString::AppendBuffer() &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;nsScanner::AppendToBuffer() &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;nsScanner::Append() &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;nsParser::Parse() &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;nsHTMLDocument::WriteCommon() &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;nsHTMLDocument::ScriptWriteCommon() &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;nsHTMLDocument::Write() &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;hr style="margin-left: 0px; margin-right: 0px;" /&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Chrome browser uses behavior analysis to detect unresponsive scripts/programs. &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Function call analysis will not work correctly on such kind of examples, bcoz attacker can create the same effect (DOS attack) in many different ways. &lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Mozilla has dom.max_script_run_time variable which is set 10 by default. In debug mode, Firefox would prompt user with a warning against that unresponsive script; however, this warning does not appear in normal mode and the script hangs Firefox (or even the whole system) after some time. In another word, Firefox has built-in check for unresponsive script, but this mechanism somehow just won't work for this example in normal mode.&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;I tested the above code in Internet Explorer, but IE show a pop-up window and ask user, he want to terminate the script&amp;nbsp; or want to continue the execution of script. I think that's the expected behaviour.&amp;nbsp; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-6585312809827317397?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/6585312809827317397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/08/dos-attack-on-firefox.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6585312809827317397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/6585312809827317397'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/08/dos-attack-on-firefox.html' title='DOS attack on Firefox'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5267091008358194058.post-4397167276236273763</id><published>2009-08-25T17:20:00.011+08:00</published><updated>2009-08-29T18:54:56.116+08:00</updated><title type='text'>Encrypted Virtual File System (EVFS): Building a encrypted Linux filesystem from an ordinary linux file</title><content type='html'>&lt;div style="text-align: justify;"&gt;This tutorial will explain step-by-step process to create Encrypted Virtual  Linux File System (EVFS).&lt;br /&gt;&lt;br /&gt;First let me explain you, What are the advantages of EVFS:&lt;br /&gt;1. You can take a disk file, format it as an vfat, ext3 filesystem, and then mount it, just like a physical drive. This is an excellent way to investigate different filesystems without hassle of reformatting a physical drive.&lt;br /&gt;&lt;br /&gt;2.  It protects unauthorized access to the information.&lt;br /&gt;&lt;br /&gt;3. It is a single file which will acts as encrypted virtual disk, that will store files, directories inside it.&lt;br /&gt;&lt;br /&gt;4. The big advantage is, it is Portable.  The file we create here will open as encrypted virtual disk  in windows, Linux, etc.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We will use LUKS (Linux Unified Key Setup) standard for creating encrypted virtual file system.&lt;/div&gt;LUKS is a standard for hard disk encryption. Most disk encryption software implements different and incompatible formats, LUKS specifies a platform-independent standard on disk format for use in various tools on different operating systems such as Windows, Linux, etc&lt;br /&gt;&lt;br /&gt;In this article, I will explain how to create encrypted virtual disk, how to use it on Linux and how to use it on windows.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;A. How to create Encrypted Virtual Disk&lt;/span&gt;&lt;br /&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Step1: Create a file with desired size. (The size you will specify here will be the size of your virtual disk.)&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #3366ff;"&gt;          dd if=/dev/urandom of=disk.img bs=1M count=10&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I used urandom to fill the file with random values. You can use&lt;span style="font-weight: bold;"&gt; if=/dev/zero&lt;/span&gt; instead of&lt;span style="font-weight: bold;"&gt; if=/dev/urandom&lt;/span&gt; to fill the file with zeros. Bydefault dd uses 512bytes as a size parameter. We define custom size using&lt;span style="font-weight: bold;"&gt; bs&lt;/span&gt; argument, as show in example (in blue colour). The&lt;span style="font-weight: bold;"&gt; bs&lt;/span&gt; argument accepts common suffixes (k, M, G) for large numbers. &lt;span style="font-weight: bold;"&gt;bs&lt;/span&gt; specifies the number of bytes read into memory with single read() system call and written out with s single write() system call. I created 10MB file in this example. (size = bs * count). You can tune the&lt;span style="font-weight: bold;"&gt; bs&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;count&lt;/span&gt; parameters according to your need.&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Step 2: Make the file we created as a disk device&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #3366ff;"&gt;sudo losetup /dev/loop0 disk.img&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Loop device makes a file accessible as a block device. &lt;span style="font-weight: bold;"&gt;losetup&lt;/span&gt; command associats the file (disk.img in our example) with loop device (loop0 in our example)&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Step 3: Now we have a partition of 10MB. In this step we will encrypt that partition.&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #3366ff;"&gt;sudo cryptsetup luksFormat -c aes -s 256 /dev/loop0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;-c&lt;/span&gt; parameter is used to specify cipher. I used AES (Advanced Encryption Standard) in this example.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;-s&lt;/span&gt; parameter is used to specify keysize for cipher in bits. It must be multiple of 8 bits. In this example I used 256 bit cipher key.&lt;br /&gt;&lt;br /&gt;(Note: You can tune above parameters according to ur need)&lt;br /&gt;&lt;br /&gt;(Note: This will ask you for confirmation before proceeding, you have to type YES in uppercase, if you want to continue. Then it will ask you for password for EVFS. This password you have to use whenever you want to access EVFS).&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Step4: Now tell Linux to treat the encrypted partition as a Disk Device.&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #3366ff;"&gt; sudo cryptsetup luksOpen /dev/loop0 krp&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;krp is the name of disk device. you can use any name there.&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;Step5: Now Format the file system on ths disk&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #3366ff;"&gt; sudo mkfs -t vfat /dev/mapper/krp&lt;/span&gt;&lt;/div&gt;&lt;ul style="text-align: justify;"&gt;&lt;li&gt;   Step6: Done. Cleanup the system now.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="color: #3366ff;"&gt; sudo cryptsetup luksClose krp&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #3366ff;"&gt;            sudo losetup -d /dev/loop0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now we have a single file as a encrypted virtual file system. In that file we can store any data which we want to hide from others. And as it is a single file you can move it from one machine to another machine without hassle of reformatting and installation of OS.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;B. How to use Encrypted Virtual File System on Linux&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Step 1: Tell Linux to treat this file as a disk device&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #3366ff;"&gt;sudo losetup /dev/loop0 disk.img&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Step2: Tell Linux to treat the encrypted partition as a disk device&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #3366ff;"&gt;sudo cryptsetup luksOpen /dev/loop0 kailas&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Step3: Mount the disk&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #3366ff;"&gt;sudo mount /dev/mapper/kailas    /mnt&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now you can access the files in directory /mnt&lt;br /&gt;You can create new files there or copy files there. Those files will be stored in your encrypted Virtual FileSystem.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;C. How to cleanup EVFS after using it on Linux&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #3366ff;"&gt;sudo umount /dev/mapper/kailas&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #3366ff;"&gt;sudo cryptsetup luksClose kailas&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #3366ff;"&gt;sudo losetup -d /dev/loop0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;D. How to use Encrypted Virtual File System on Windows&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To open/access the EVFS we created above on Windows, download a open source free software &lt;a href="http://www.freeotfe.org/"&gt;FreeOTFE&lt;/a&gt;.&lt;br /&gt;Install the FreeOTFE software, then launch the FreeOTFE software.&lt;br /&gt;Select "&lt;span style="font-weight: bold;"&gt;File-&amp;gt; Linux Volume -&amp;gt; Mount File&lt;/span&gt;"&lt;br /&gt;&lt;br /&gt;Enter the password of EVFS. FreeOTFE will show the virtual drive. Done!.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5267091008358194058-4397167276236273763?l=kailaspatil.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kailaspatil.blogspot.com/feeds/4397167276236273763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kailaspatil.blogspot.com/2009/08/encrypted-virtual-file-system-evfs.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/4397167276236273763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5267091008358194058/posts/default/4397167276236273763'/><link rel='alternate' type='text/html' href='http://kailaspatil.blogspot.com/2009/08/encrypted-virtual-file-system-evfs.html' title='Encrypted Virtual File System (EVFS): Building a encrypted Linux filesystem from an ordinary linux file'/><author><name>Kailas</name><uri>http://www.blogger.com/profile/16574412525905854420</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_8BP8ckYf_qs/SpQG9Coa1QI/AAAAAAAAAAM/buVlVibzYlc/S220/Kailas.JPG'/></author><thr:total>2</thr:total></entry></feed>
