Read Source Code the HTML Way
The first thing you'll see when you open the file is a definition for a variable called v. As with programming languages, you can define your own variables and use them later in the configuration file. Wherever they occur, they will be replaced by whatever value they have. Variable values are referenced by the configuration file by $/variable-name. Variable definitions follow one of two possible formats:
variable: /variable-identifier, variable-name, /(/list-of-values/), /default-value/
variable: /variable-identifier, variable-name, /[/file-containing-list-of-values/], /default-value/
Here's what the terms stand for:
variable-identifier: the name the variable will be known as throughout the configuration file.
variable-name: the actual name of the variable that will be displayed to the user.
list-of-values: comma-separated list of values to be displayed.
file-containing: a file that contains a list of possible values.
list-of-values: the list has each entry on a separate line. The user can select any one of them. The absolute path of the file should be provided.
default-value: the value that the variable will take on by default. The first value is automatically set if this is not specified.
The baseurl is the URL relative to which all of the scripts required by LXR are placed. It should be accessible via a browser. In my configuration, it's http://my-ip/lxr/http/ <http://localhost/lxr/http/>. Make sure to place the / at the end, or the last directory will be ignored.
When the HTML for the source is generated, LXR can add headers and footers to the pages. Sample headers and footers are provided in the $INSTALLPREFIX/http/ directory. They're called template-head and template-tail. In addition, you also can change the way files and directories are displayed by LXR by modifying the template-dir file. The locations of these files can be specified by the htmlhead, htmltail and htmldir options in the lxr.conf file.
This option tells LXR where to look for the actual source code. In my case, it's /var/www/htdocs/lxr/source/glibc-2.3.5. If you want to cross-reference multiple projects, all you have to do is create a variable specifying the location of each of the directories that contain the source code. Then, you can specify the value of the variable as the sourceroot. For example, I set up the sources for glibc-2.3.5 and OpenMOSIX-2.4.26, placing the sources for both of them in /var/www/htdocs/lxr/source in their individual directories with the same names as above. In lxr.conf, I had a line like:
variable: s, Source, (glibc-2.3.5, OpenMOSIX-2.4.26)
Thus, the appropriate source code is automatically selected based on the value of the source variable.
srcrootname specifies the name of the project whose source code is displayed—for example:
This is the location of the fileidx and xref files generated by genxref. If you have multiple projects, specify a separate location for each, as follows:
These are the only options you need to set when configuring LXR. Additionally, you can specify the location of the glimpse binary using glimpsebin.
glimpse allows users to search for specific files within the source code and to search for any text within source files. You can obtain the latest version of glimpse from webglimpse.net/trial/glimpse-latest.tar.gz. Extract and install it. Once you are done installing glimpse, go to the directory where the source code is installed, such as /var/www/htdocs/lxr/source/glibc-2.3.5, and do the following:
bash# glimpseindex -H . .
The output should look something like this:
This is glimpseindex version 4.18.2, 2006. Indexing "/var/www/htdocs/lxr/source/glibc-2.3.5" ... Size of files being indexed = 81711416 B, Total #of files = 10075 Index-directory: "/var/www/htdocs/lxr/source/glibc-2.3.5" Glimpse-files created here: -rw-r--r-- 1 root root 676398 2006-09-08 05:51 .glimpse_filenames -rw-r--r-- 1 root root 40300 2006-09-08 05:51 .glimpse_filenames_index -rw-r--r-- 1 root root 0 2006-09-08 05:50 .glimpse_filetimes -rw------- 1 root root 1783314 2006-09-08 05:51 .glimpse_index -rw-r--r-- 1 root root 686 2006-09-08 05:51 .glimpse_messages -rw------- 1 root root 836 2006-09-08 05:51 .glimpse_partitions -rw-r--r-- 1 root root 23888 2006-09-08 05:51 .glimpse_statistics
This creates the required glimpse index files in the current directory. Once they're created, make sure read permission is set for others:
bash# chmod o+r .glimpse-*
Now, set the glimpsebin option in lxr.conf to wherever you installed glimpse. I installed it in /usr/local/bin/glimpse.
That's it; save and close the lxr.conf file. The only thing remaining to do now is configure the Web server to work with LXR.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Tips for Optimizing Linux Memory Usage
- Secure Desktops with Qubes: Introduction
- Working with Command Arguments
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Secure Desktops with Qubes: Installation
- Fancy Tricks for Changing Numeric Base
- CentOS 6.8 Released
- Linux Mint 18
- The Italian Army Switches to LibreOffice
- Petros Koutoupis' RapidDisk
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide