Translate

Image of Android Wireless Application Development
Image of Advanced Programming in the UNIX Environment, Second Edition (Addison-Wesley Professional Computing Series)
Image of Operating System Concepts
Image of RHCE Red Hat Certified Engineer Linux Study Guide (Exam RH302) (Certification Press)

Currently C Is the Most Popular Programming Language

The TIOBE Programming Community Index for April 2012 shows that C is the most popular programming language (17.5%), closely followed by Java (17.02%) followed by C++ at 8.89%. It is not that C is becoming more popular – it has been flatlined at 17-18% for a long time – it is that the use of Java in new code is declining. Frankly, I am not surprised by the decline in Java. It was dreadfully over-hyped in the first place and has become increasing difficult to support due to the large number of overlapping class libraries. Like Cobol, Java still has

Sprintf Portability and Leading Zeros

On some platforms, code such as the following can be used to output a string with leading zeros left padded to a length of 4. sprintf(*str, “%04s”, *pstr); This works on AIX for example. However if the same code is compiled on Linux using gcc, it outputs leading spaces, padded to a length of 4, instead of leading zeros. There is no simple way to fix this behavior. This particular usage of leading zero padding with the string format is explicitly undefined in the various C standards. What is outputted depends on a platform’s libraries rather than the compiler. As

Programmatically List Installed .deb Packages

While RPM packages have a robust ecosystem around them for programmatically retrieving information about package metadata, the Debian package management system is sorely lacking in this respect. Here is a simple C example which demonstrates how to programmatically list all installed Debian packages. #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <dpkg/dpkg.h> #include <dpkg/dpkg-db.h> #include <dpkg/pkg-array.h> #include "filesdb.h" const char thisname[] = "example1"; int main(int argc, const char *const *argv) { struct pkg_array array; struct pkginfo *pkg; int i; enum modstatdb_rw msdb_status; standard_startup(); filesdbinit(); msdb_status = modstatdb_open(msdbrw_readonly); pkg_infodb_init(msdb_status); pkg_array_init_from_db(&array); pkg_array_sort(&array, pkg_sorter_by_name); for (i = 0; i <

Programmatically Retrieve RPM Package Details

Recently, I needed to retrieve details about software packages installed on Fedora 15, Red Hat Enterprise Linux, CentOS and other distributions which distribute their software packages using the RPM Package Manager. To my surprise, what should have been a relatively simple task turned out to be quite messy because of changes in the RPM library APIs and internal format over the last few years. In this post, I demonstrate how to retrieve information about RPM packages using C and Python. RPM is a command-line or API driven package management system capable of installing, uninstalling, verifying, querying, and updating Linux or

V8 JavaScript Engine on Fedora 14

The recent announcement by Google of a new compilation infrastructure, aptly codenamed CrankShaft, for their V8 JavaScript engine prompted me to revisit this particular JavaScript engine and to compile and install it on a Fedora 14 X64 platform. Crankshaft is the latest iteration of the V8 JavaScript (V8) engine and is somewhat similar to Mozilla’s TraceMonkey JavaScript engine in that it attempts to aggressively optimize code that is regularly executed but avoid much optimization of code that is infrequently executed. Currently the Mozilla Spidermonkey JavaScript shell is available as a standard RPM package for Fedora 14. In a previous post