Read Source Code the HTML Way
The Web server I used was Apache 1.3.33. The first order of business is to set the permissions for the LXR directory. You can do that by editing the httpd.conf file, normally found under /etc/apache/httpd.conf. Add the following lines:
<Directory /var/www/htdocs/lxr> AllowOverride All Options All </Directory>
Simply replace the location with wherever you've installed LXR. Then, go to $INSTALLPREFIX/http/ and create and open a file named .htaccess for editing. Type the following lines:
<File ~ (search|find|source|diff|ident)?> SetHandler cgi-script </Files>
This tells the Web server to treat the above-mentioned files as CGI scripts. If you don't do this, the server will display only the contents of these files. Close and save .htaccess. We are now ready to browse the cross-referenced source code.
After all of the above steps are done, all you have to do is open a Web browser and go to the URL, http:///my-ip//lxr/http/source, where /my-ip/ is the IP of your Web server. When you open the Web page, you will get something like what is shown in Figure 1.
As you can see, users can select any of the source code files for browsing. At the top, I'm using the template provided by LXR. It includes links to navigate the source code, search for a particular identifier, search for any text within the source code and search for any file.
A few utilities of note:
Source navigation: select this option to browse the source code of your choice.
Identifier search: search for the definition and uses of a particular identifier. Requires the ident script.
Freetext search: search for any text within the source files. Requires the search script.
File search: search for files matching the passed string. Requires the find script.
All of these utilities also can search using regular expressions to match the strings.
LXR is an excellent tool. It makes life a lot easier for people who want to study source code, and it's powerful and easy to use. The fact that it uses dynamically generated Web pages to browse the source code gives users a lot of flexibility in configuring it. Also, because it can be accessed via any Web browser, it imposes no limitations on the platform, client or location of users. This interoperability is one of the reasons LXR is so powerful.
Kamran Soomro is a software engineering student at the National University of Sciences and Technology, Pakistan. He has had great interest in Linux since he first used it during his first semester. Since then, he has been avidly involved in promoting Linux in Pakistan.
|openHAB||Apr 24, 2017|
|Omesh Tickoo and Ravi Iyer's Making Sense of Sensors (Apress)||Apr 21, 2017|
|Low Power Wireless: 6LoWPAN, IEEE802.15.4 and the Raspberry Pi||Apr 20, 2017|
|CodeLathe's Tonido Personal Cloud||Apr 19, 2017|
|Wrapping Up the Mars Lander||Apr 18, 2017|
|MultiTaction's MT Canvus-Connect||Apr 17, 2017|
- Teradici's Cloud Access Platform: "Plug & Play" Cloud for the Enterprise
- Tech Tip: Really Simple HTTP Server with Python
- Simple Server Hardening
- Sunshine in a Room with No Windows
- Downloading an Entire Web Site with wget
- Gordon H. Williams' Making Things Smart (Maker Media, Inc.)
- Buddy Platform Limited's Parse on Buddy Service
- A Switch for Your RPi